Class: Browser::CSS::Declaration
Instance Method Summary
collapse
#restricted?, #set_native_reference
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, value = nil) ⇒ Object
75
76
77
78
79
80
81
|
# File 'opal/browser/css/declaration.rb', line 75
def method_missing(name, value = nil)
if name.end_with? ?=
self[name[0 .. -2]] = value
else
self[name]
end
end
|
Instance Method Details
38
39
40
41
42
43
44
45
46
47
48
|
# File 'opal/browser/css/declaration.rb', line 38
def [](name)
%x{
var result = #@native.getPropertyValue(#{name});
if (result == null || result === "") {
return nil;
}
return result;
}
end
|
#[]=(name, value) ⇒ Object
50
51
52
|
# File 'opal/browser/css/declaration.rb', line 50
def []=(name, value)
`#@native.setProperty(#{name}, #{value.to_s}, "")`
end
|
#apply(&block) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'opal/browser/css/declaration.rb', line 24
def apply(&block)
Paggio::CSS::Definition.new(&block).each {|style|
if style.important
`#@native.setProperty(#{style.name}, #{style.value}, "important")`
else
`#@native.setProperty(#{style.name}, #{style.value}, "")`
end
}
end
|
#assign(data) ⇒ Object
12
13
14
15
16
17
18
|
# File 'opal/browser/css/declaration.rb', line 12
def assign(data)
data.each {|name, value|
self[name] = value
}
self
end
|
#delete(name) ⇒ Object
34
35
36
|
# File 'opal/browser/css/declaration.rb', line 34
def delete(name)
`#@native.removeProperty(#{name})`
end
|
#each(&block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'opal/browser/css/declaration.rb', line 58
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
|
#important?(name) ⇒ Boolean
54
55
56
|
# File 'opal/browser/css/declaration.rb', line 54
def important?(name)
`#@native.getPropertyPriority(#{name}) == "important"`
end
|
#replace(string) ⇒ Object
20
21
22
|
# File 'opal/browser/css/declaration.rb', line 20
def replace(string)
`#@native.cssText = #{string}`
end
|
8
9
10
|
# File 'opal/browser/css/declaration.rb', line 8
def rule
Rule.new(`#@native.parentRule`) if defined?(`#@native.parentRule`)
end
|