Sha256: da8a4eeb42b868d1e6abb53450f893d60f2d4f43bf3a992037bdf6c5d5177aa4
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Browser; module CSS class Declaration include Native include Enumerable def rule Rule.new(`#@native.parentRule`) if defined?(`#@native.parentRule`) end def assign(data) data.each {|name, value| self[name] = value } self end def replace(string) `#@native.cssText = #{string}` self end def apply(&block) Paggio::CSS::Definition.new(&block).each {|style| # FIXME: use ternary operator when it's fixed if style.important `#@native.setProperty(#{style.name}, #{style.value}, "important")` else `#@native.setProperty(#{style.name}, #{style.value}, "")` end } self end def delete(name) `#@native.removeProperty(#{name})` end def [](name) %x{ var result = #@native.getPropertyValue(#{name}); if (result == null || result === "") { return nil; } return result; } end def []=(name, value) `#@native.setProperty(#{name}, #{value.to_s}, "")` end def important?(name) `#@native.getPropertyPriority(#{name}) == "important"` end def each(&block) return enum_for :each unless block_given? %x{ for (var i = 0, length = #@native.length; i < length; i++) { var name = #@native.item(i); #{yield `name`, self[`name`]} } } self end alias_native :length alias_native :to_s, :cssText def method_missing(name, value = nil) if name.end_with? ?= self[name[0 .. -2]] = value else self[name] end end end end; end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-browser-0.1.0.beta1 | opal/browser/css/declaration.rb |