red 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +25 -0
- data/lib/red/version.rb +1 -1
- data/lib/source/redshift/accessors.rb +580 -0
- data/lib/source/redshift/browser.rb +150 -0
- data/lib/source/redshift/chainable.rb +75 -0
- data/lib/source/redshift/code_events.rb +204 -0
- data/lib/source/redshift/cookie.rb +142 -0
- data/lib/source/redshift/document.rb +216 -0
- data/lib/source/redshift/element.rb +417 -0
- data/lib/source/redshift/event.rb +312 -0
- data/lib/source/redshift/redshift.red +5 -0
- data/lib/source/redshift/request.rb +276 -0
- data/lib/source/redshift/selectors.rb +374 -0
- data/lib/source/redshift/situated.rb +328 -0
- data/lib/source/redshift/store.rb +48 -0
- data/lib/source/redshift/transform.rb +199 -0
- data/lib/source/redshift/tween.rb +66 -0
- data/lib/source/redshift/user_events.rb +215 -0
- data/lib/source/redshift/validator.rb +21 -0
- data/lib/source/redshift/window.rb +11 -0
- data/lib/source/redspec/index.html +11 -0
- data/lib/source/redspec/lib/red_spec/red_spec.red +525 -0
- data/lib/source/redspec/lib/stylesheets/specs.sass +290 -0
- metadata +27 -2
data/Manifest.txt
CHANGED
@@ -22,6 +22,31 @@ lib/red/nodes/literal_nodes.rb
|
|
22
22
|
lib/red/nodes/logic_nodes.rb
|
23
23
|
lib/red/nodes/variable_nodes.rb
|
24
24
|
lib/source/ruby.rb
|
25
|
+
lib/source/redshift
|
26
|
+
lib/source/redshift/accessors.rb
|
27
|
+
lib/source/redshift/browser.rb
|
28
|
+
lib/source/redshift/chainable.rb
|
29
|
+
lib/source/redshift/code_events.rb
|
30
|
+
lib/source/redshift/cookie.rb
|
31
|
+
lib/source/redshift/document.rb
|
32
|
+
lib/source/redshift/element.rb
|
33
|
+
lib/source/redshift/event.rb
|
34
|
+
lib/source/redshift/redshift.red
|
35
|
+
lib/source/redshift/request.rb
|
36
|
+
lib/source/redshift/selectors.rb
|
37
|
+
lib/source/redshift/situated.rb
|
38
|
+
lib/source/redshift/store.rb
|
39
|
+
lib/source/redshift/transform.rb
|
40
|
+
lib/source/redshift/tween.rb
|
41
|
+
lib/source/redshift/user_events.rb
|
42
|
+
lib/source/redshift/validator.rb
|
43
|
+
lib/source/redshift/window.rb
|
44
|
+
lib/source/redspec
|
45
|
+
lib/source/redspec/index.html
|
46
|
+
lib/source/redspec/lib
|
47
|
+
lib/source/redspec/lib/red_spec
|
48
|
+
lib/source/redspec/lib/red_spec/red_spec.red
|
49
|
+
lib/source/redspec/lib/stylesheets/specs.sass
|
25
50
|
script/console
|
26
51
|
script/destroy
|
27
52
|
script/generate
|
data/lib/red/version.rb
CHANGED
@@ -0,0 +1,580 @@
|
|
1
|
+
require 'element'
|
2
|
+
|
3
|
+
class Element
|
4
|
+
`c$Element.__keyed_attributes__={class:'className',for:'htmlFor'}`
|
5
|
+
`c$Element.__boolean_attributes__={checked:'checked',declare:'declare',defer:'defer',disabled:'disabled',ismap:'ismap',multiple:'multiple',noresize:'noresize',noshade:'noshade',readonly:'readonly',selected:'selected'}`
|
6
|
+
|
7
|
+
# call-seq:
|
8
|
+
# elem.add_class(sym) -> elem
|
9
|
+
#
|
10
|
+
# Returns _elem_ with class name _sym_ added.
|
11
|
+
#
|
12
|
+
#
|
13
|
+
#
|
14
|
+
def add_class(sym)
|
15
|
+
`if(!this.m$has_class_bool(sym)){var el=this.__native__,c=el.className,s=sym.__value__;el.className=(c.length>0)?c+' '+s:s;}`
|
16
|
+
return self
|
17
|
+
end
|
18
|
+
|
19
|
+
# call-seq:
|
20
|
+
# elem.add_classes(sym, ...) -> elem
|
21
|
+
#
|
22
|
+
# Calls <tt>elem.add_class(sym)</tt> once for each argument.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
#
|
26
|
+
def add_classes(*args)
|
27
|
+
args.each {|x| self.add_class(x) }
|
28
|
+
return self
|
29
|
+
end
|
30
|
+
|
31
|
+
# call-seq:
|
32
|
+
# elem.class -> string
|
33
|
+
#
|
34
|
+
# Returns a string representation of _elem_'s class names, separated by " ".
|
35
|
+
#
|
36
|
+
#
|
37
|
+
#
|
38
|
+
def class
|
39
|
+
`$q(this.__native__.className)`
|
40
|
+
end
|
41
|
+
|
42
|
+
# call-seq:
|
43
|
+
# elem.class = str -> str
|
44
|
+
#
|
45
|
+
# Sets _elem_'s HTML class property to _str_, which consists of one or many
|
46
|
+
# class names separated by " ".
|
47
|
+
#
|
48
|
+
#
|
49
|
+
#
|
50
|
+
def class=(str)
|
51
|
+
`this.__native__.className=str.__value__`
|
52
|
+
return str
|
53
|
+
end
|
54
|
+
|
55
|
+
# call-seq:
|
56
|
+
# elem.classes -> object
|
57
|
+
#
|
58
|
+
# Returns an Element::Classes accessor object, which represents the classes
|
59
|
+
# assigned to _elem_, and allows for operations such as
|
60
|
+
# <tt>elem.classes << :klass</tt>, <tt>elem.classes.include? :klass</tt>,
|
61
|
+
# and <tt>elem.classes.toggle(:klass)</tt>.
|
62
|
+
#
|
63
|
+
#
|
64
|
+
#
|
65
|
+
def classes
|
66
|
+
@class_list ||= Element::Classes.new(self)
|
67
|
+
end
|
68
|
+
|
69
|
+
# call-seq:
|
70
|
+
# elem.classes = [sym, ...] -> array
|
71
|
+
#
|
72
|
+
# Sets _elem_'s HTML class property to a string equivalent to the
|
73
|
+
# concatenation of each of the classes in _array_ joined by " ", then
|
74
|
+
# returns _array_.
|
75
|
+
#
|
76
|
+
#
|
77
|
+
#
|
78
|
+
def classes=(ary)
|
79
|
+
`for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`
|
80
|
+
`this.__native__.className=result.join(' ')`
|
81
|
+
return ary
|
82
|
+
end
|
83
|
+
|
84
|
+
# call-seq:
|
85
|
+
# elem.clear_styles -> elem
|
86
|
+
#
|
87
|
+
# Removes the CSS styles that have been applied to _elem_.
|
88
|
+
#
|
89
|
+
#
|
90
|
+
#
|
91
|
+
def clear_styles
|
92
|
+
`this.__native__.style.cssText=''`
|
93
|
+
return self
|
94
|
+
end
|
95
|
+
|
96
|
+
# call-seq:
|
97
|
+
# elem.get_property(sym) -> object or nil
|
98
|
+
#
|
99
|
+
# Returns the value of _elem_'s property _sym_, or +nil+ if no value is set.
|
100
|
+
#
|
101
|
+
#
|
102
|
+
#
|
103
|
+
def get_property(attribute)
|
104
|
+
`var el=this.__native__,attr=attribute.__value__,key=c$Element.__keyed_attributes__[attr],bool=c$Element.__boolean_attributes__[attr]`
|
105
|
+
`var value=key||bool?el[key||bool]:el.getAttribute(attr,2)`
|
106
|
+
return `bool ? !!value : (value==null) ? nil : $q(value)`
|
107
|
+
end
|
108
|
+
|
109
|
+
# call-seq:
|
110
|
+
# elem.get_style(sym) -> object or nil
|
111
|
+
#
|
112
|
+
# Returns the value of the CSS style rule _sym_ applied to _elem_, or +nil+
|
113
|
+
# if no value is set.
|
114
|
+
#
|
115
|
+
#
|
116
|
+
#
|
117
|
+
def get_style(attribute)
|
118
|
+
`var el=this.__native__,attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();}),result=el.style[attr]`
|
119
|
+
`result===undefined?nil:$q(result)`
|
120
|
+
end
|
121
|
+
|
122
|
+
# call-seq:
|
123
|
+
# elem.has_class?(sym) -> true or false
|
124
|
+
#
|
125
|
+
# Returns +true+ if _elem_ has class _sym_, +false+ otherwise.
|
126
|
+
#
|
127
|
+
# <div id='div_a' class='container drop_target'></div>
|
128
|
+
#
|
129
|
+
# elem = Document['#div_a'] #=> #<Element: DIV id="div_element" class="container drop_target">
|
130
|
+
# elem.has_class?('container') #=> true
|
131
|
+
# elem.has_class?(:draggable) #=> false
|
132
|
+
#
|
133
|
+
def has_class?(sym)
|
134
|
+
`var str=' '+this.__native__.className+' ',match=' '+sym.__value__+' '`
|
135
|
+
`str.indexOf(match) > -1`
|
136
|
+
end
|
137
|
+
|
138
|
+
# call-seq:
|
139
|
+
# elem.html -> string
|
140
|
+
#
|
141
|
+
# Returns a string representation of the HTML inside _elem_.
|
142
|
+
#
|
143
|
+
#
|
144
|
+
#
|
145
|
+
def html
|
146
|
+
`$q(this.__native__.innerHTML)`
|
147
|
+
end
|
148
|
+
|
149
|
+
# call-seq:
|
150
|
+
# elem.html = str -> str
|
151
|
+
#
|
152
|
+
# Sets the HTML inside _elem_ to _str_.
|
153
|
+
#
|
154
|
+
#
|
155
|
+
#
|
156
|
+
def html=(str)
|
157
|
+
`this.__native__.innerHTML=str.__value__`
|
158
|
+
return str
|
159
|
+
end
|
160
|
+
|
161
|
+
# call-seq:
|
162
|
+
# elem.properties -> object
|
163
|
+
#
|
164
|
+
# Returns an Element::Properties accessor object, which represents the
|
165
|
+
# HTML properties assigned to _elem_, and allows for operations such as
|
166
|
+
# <tt>elem.properties[:title] = 'figure_1'</tt> and
|
167
|
+
# <tt>elem.properties.set? :name</tt>.
|
168
|
+
#
|
169
|
+
#
|
170
|
+
#
|
171
|
+
def properties
|
172
|
+
@properties ||= Element::Properties.new(self)
|
173
|
+
end
|
174
|
+
|
175
|
+
# call-seq:
|
176
|
+
# elem.remove_class(sym) -> elem
|
177
|
+
#
|
178
|
+
# Removes _sym_ from _elem_'s HTML class property if it was included, then
|
179
|
+
# returns _elem_.
|
180
|
+
#
|
181
|
+
#
|
182
|
+
#
|
183
|
+
def remove_class(sym)
|
184
|
+
`var el=this.__native__,klass=sym.__value__`
|
185
|
+
`el.className=el.className.replace(new(RegExp)('(^|\\\\s)'+klass+'(?:\\\\s|$)'),'$1')`
|
186
|
+
return self
|
187
|
+
end
|
188
|
+
|
189
|
+
# call-seq:
|
190
|
+
# elem.remove_classes(sym, ...) -> elem
|
191
|
+
#
|
192
|
+
# Calls <tt>elem.remove_class(sym)</tt> once for each argument.
|
193
|
+
#
|
194
|
+
#
|
195
|
+
#
|
196
|
+
def remove_classes(*args)
|
197
|
+
args.each {|x| self.remove_class(x) }
|
198
|
+
return self
|
199
|
+
end
|
200
|
+
|
201
|
+
# call-seq:
|
202
|
+
# elem.remove_property(sym) -> elem
|
203
|
+
#
|
204
|
+
# Unsets _elem_'s HTML property _sym_ if it was set, then returns _elem_.
|
205
|
+
#
|
206
|
+
#
|
207
|
+
#
|
208
|
+
def remove_property(attribute)
|
209
|
+
`var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`
|
210
|
+
`key ? el[key]=bool?false:'' : el.removeAttribute(attr)`
|
211
|
+
return self
|
212
|
+
end
|
213
|
+
|
214
|
+
# call-seq:
|
215
|
+
# elem.remove_properties(sym, ...) -> elem
|
216
|
+
#
|
217
|
+
# Calls <tt>elem.remove_property(sym)</tt> once for each argument.
|
218
|
+
#
|
219
|
+
#
|
220
|
+
#
|
221
|
+
def remove_properties(*args)
|
222
|
+
args.each {|x| self.remove_property(x) }
|
223
|
+
return self
|
224
|
+
end
|
225
|
+
|
226
|
+
# call-seq:
|
227
|
+
# elem.remove_style(sym) -> elem
|
228
|
+
#
|
229
|
+
# Unsets _elem_'s CSS style _sym_ if it was set, then returns _elem_.
|
230
|
+
#
|
231
|
+
#
|
232
|
+
#
|
233
|
+
def remove_style(attribute)
|
234
|
+
`var attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();})`
|
235
|
+
`this.__native__.style[attr]=null`
|
236
|
+
return self
|
237
|
+
end
|
238
|
+
|
239
|
+
# call-seq:
|
240
|
+
# elem.remove_styles(sym, ...) -> elem
|
241
|
+
#
|
242
|
+
# Calls <tt>elem.remove_style(sym)</tt> once for each argument.
|
243
|
+
#
|
244
|
+
#
|
245
|
+
#
|
246
|
+
def remove_styles(*args)
|
247
|
+
args.each {|x| self.remove_style(x) }
|
248
|
+
return self
|
249
|
+
end
|
250
|
+
|
251
|
+
# call-seq:
|
252
|
+
# elem.set_property(sym, value) -> elem
|
253
|
+
#
|
254
|
+
# Sets _elem_'s HTML property _sym_ to _value_, then returns _elem_.
|
255
|
+
#
|
256
|
+
#
|
257
|
+
#
|
258
|
+
def set_property(attribute, value)
|
259
|
+
`var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`
|
260
|
+
`key ? el[key]=bool?$T(value):value : el.setAttribute(attr,''+value)`
|
261
|
+
return self
|
262
|
+
end
|
263
|
+
|
264
|
+
# call-seq:
|
265
|
+
# elem.set_properties({key => value, ...}) -> elem
|
266
|
+
#
|
267
|
+
# Calls <tt>elem.set_property(key,value)</tt> once for each key-value pair.
|
268
|
+
#
|
269
|
+
#
|
270
|
+
#
|
271
|
+
def set_properties(hash)
|
272
|
+
hash.each {|k,v| self.set_property(k,v) }
|
273
|
+
return self
|
274
|
+
end
|
275
|
+
|
276
|
+
# call-seq:
|
277
|
+
# elem.set_style(sym, value) -> elem
|
278
|
+
#
|
279
|
+
# Sets _elem_'s CSS style _sym_ to _value_, then returns _elem_.
|
280
|
+
#
|
281
|
+
#
|
282
|
+
#
|
283
|
+
def set_style(attribute, value)
|
284
|
+
`var attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();}),val=value.__value__||value`
|
285
|
+
`if(attr==='float'){val=#{trident?}?'styleFloat':'cssFloat'}`
|
286
|
+
`if(attr==='opacity'){m$raise("nobody wrote the opacity setter yet!");}`
|
287
|
+
`if(val===String(Number(val))){val=Math.round(val)}`
|
288
|
+
`this.__native__.style[attr]=val`
|
289
|
+
return self
|
290
|
+
end
|
291
|
+
|
292
|
+
# call-seq:
|
293
|
+
# elem.set_styles({key => value, ...}) -> elem
|
294
|
+
#
|
295
|
+
# Calls <tt>elem.set_style(key,value)</tt> once for each key-value pair.
|
296
|
+
#
|
297
|
+
#
|
298
|
+
#
|
299
|
+
def set_styles(hash)
|
300
|
+
hash.each {|k,v| self.set_style(k,v) }
|
301
|
+
return self
|
302
|
+
end
|
303
|
+
|
304
|
+
# call-seq:
|
305
|
+
# elem.style -> string
|
306
|
+
#
|
307
|
+
# Returns the value of _elem_'s HTML style property.
|
308
|
+
#
|
309
|
+
#
|
310
|
+
#
|
311
|
+
def style
|
312
|
+
`$q(this.__native__.style.cssText)`
|
313
|
+
end
|
314
|
+
|
315
|
+
# call-seq:
|
316
|
+
# elem.style = str -> str
|
317
|
+
#
|
318
|
+
# Sets the value of _elem_'s HTML style property to _str_.
|
319
|
+
#
|
320
|
+
#
|
321
|
+
#
|
322
|
+
def style=(str)
|
323
|
+
`this.__native__.style.cssText=str.__value__`
|
324
|
+
return str
|
325
|
+
end
|
326
|
+
|
327
|
+
# call-seq:
|
328
|
+
# elem.styles -> object
|
329
|
+
#
|
330
|
+
# Returns an Element::Styles accessor object, which represents the CSS
|
331
|
+
# styles applied to _elem_, and allows for operations such as
|
332
|
+
# <tt>elem.styles[:color] = '#C80404'</tt> and
|
333
|
+
# <tt>elem.styles.set? :font_weight</tt>.
|
334
|
+
#
|
335
|
+
#
|
336
|
+
#
|
337
|
+
def styles
|
338
|
+
@styles ||= Element::Styles.new(self)
|
339
|
+
end
|
340
|
+
|
341
|
+
# call-seq:
|
342
|
+
# elem.text -> string
|
343
|
+
#
|
344
|
+
# Returns the text inside _elem_ as a string.
|
345
|
+
#
|
346
|
+
#
|
347
|
+
#
|
348
|
+
def text
|
349
|
+
`$q(#{trident?} ? this.__native__.innerText : this.__native__.textContent)`
|
350
|
+
end
|
351
|
+
|
352
|
+
# call-seq:
|
353
|
+
# elem.text = str -> str
|
354
|
+
#
|
355
|
+
# Sets the text inside _elem_ to the value _str_.
|
356
|
+
#
|
357
|
+
#
|
358
|
+
#
|
359
|
+
def text=(str)
|
360
|
+
trident? ? `this.__native__.innerText=str.__value__` : `this.__native__.textContent=str.__value__`
|
361
|
+
return str
|
362
|
+
end
|
363
|
+
|
364
|
+
# call-seq:
|
365
|
+
# elem.toggle_class(sym) -> elem
|
366
|
+
#
|
367
|
+
# Returns _elem_ with the HTML class _sym_ added to its HTML classes if
|
368
|
+
# they did not include _sym_, or with _sym_ removed from its HTML classes if
|
369
|
+
# they did include _sym_.
|
370
|
+
#
|
371
|
+
#
|
372
|
+
#
|
373
|
+
def toggle_class(sym)
|
374
|
+
self.has_class?(sym) ? self.remove_class(sym) : self.add_class(sym);
|
375
|
+
return self
|
376
|
+
end
|
377
|
+
|
378
|
+
#
|
379
|
+
#
|
380
|
+
class Classes
|
381
|
+
def initialize(element) # :nodoc:
|
382
|
+
@element = element
|
383
|
+
end
|
384
|
+
|
385
|
+
# call-seq:
|
386
|
+
# classes << sym -> classes
|
387
|
+
#
|
388
|
+
# Adds _sym_ to the HTML classes of the element represented by _classes_,
|
389
|
+
# then returns _classes_. See also <tt>Element#add_class</tt>.
|
390
|
+
#
|
391
|
+
#
|
392
|
+
#
|
393
|
+
def <<(sym)
|
394
|
+
`c$Element.prototype.m$add_class.call(#{@element},sym)`
|
395
|
+
return self
|
396
|
+
end
|
397
|
+
|
398
|
+
# call-seq:
|
399
|
+
# classes.include?(sym) -> true or false
|
400
|
+
#
|
401
|
+
# Returns +true+ if the element represented by _classes_ has the HTML
|
402
|
+
# class _sym_, +false+ otherwise. See also <tt>Element#has_class?</tt>.
|
403
|
+
#
|
404
|
+
#
|
405
|
+
#
|
406
|
+
def include?(sym)
|
407
|
+
`c$Element.prototype.m$has_class_bool.call(#{@element},sym)`
|
408
|
+
end
|
409
|
+
|
410
|
+
# call-seq:
|
411
|
+
# classes.toggle(sym) -> element
|
412
|
+
#
|
413
|
+
# If the element represented by _classes_ has the HTML class _sym_,
|
414
|
+
# removes _sym_; otherwise, adds _sym_ to the element's classes. See also
|
415
|
+
# <tt>Element#toggle_class</tt>.
|
416
|
+
#
|
417
|
+
#
|
418
|
+
#
|
419
|
+
def toggle(sym)
|
420
|
+
`c$Element.prototype.m$toggle_class.call(#{@element},sym)`
|
421
|
+
return @element
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
#
|
426
|
+
#
|
427
|
+
class Properties
|
428
|
+
def initialize(element) # :nodoc:
|
429
|
+
@element = element
|
430
|
+
end
|
431
|
+
|
432
|
+
# call-seq:
|
433
|
+
# properties[sym] -> object or nil
|
434
|
+
#
|
435
|
+
# Returns the value of the HTML property _sym_ for the element represented
|
436
|
+
# by _properties_, or +nil+ if the property is not set. See also
|
437
|
+
# <tt>Element#get_property</tt>.
|
438
|
+
#
|
439
|
+
#
|
440
|
+
#
|
441
|
+
def [](attribute)
|
442
|
+
`c$Element.prototype.m$get_property.call(#{@element},attribute)`
|
443
|
+
end
|
444
|
+
|
445
|
+
# call-seq:
|
446
|
+
# properties[sym] = value -> value
|
447
|
+
#
|
448
|
+
# Sets the value of the HTML property _sym_ to _value_ for the element
|
449
|
+
# represented by _properties_. See also <tt>Element#set_property</tt>.
|
450
|
+
#
|
451
|
+
#
|
452
|
+
#
|
453
|
+
def []=(attribute,value)
|
454
|
+
`c$Element.prototype.m$set_property.call(#{@element},attribute,value)`
|
455
|
+
end
|
456
|
+
|
457
|
+
# call-seq:
|
458
|
+
# properties.delete(sym) -> object or nil
|
459
|
+
#
|
460
|
+
# If the element represented by _properties_ has the HTML property _sym_,
|
461
|
+
# unsets the property and returns its value, otherwise returns +nil+. See
|
462
|
+
# also <tt>Element#remove_property</tt>.
|
463
|
+
#
|
464
|
+
#
|
465
|
+
#
|
466
|
+
def delete(attribute)
|
467
|
+
`c$Element.prototype.m$remove_property.call(#{@element},attribute)`
|
468
|
+
end
|
469
|
+
|
470
|
+
# call-seq:
|
471
|
+
# properties.set?(sym) -> true or false
|
472
|
+
#
|
473
|
+
# Returns +true+ if the HTML property _sym_ is set for the element
|
474
|
+
# represented by _properties_, +false+ otherwise.
|
475
|
+
#
|
476
|
+
#
|
477
|
+
#
|
478
|
+
def set?(attribute)
|
479
|
+
`$T(c$Element.prototype.m$get_property.call(#{@element},attribute))`
|
480
|
+
end
|
481
|
+
|
482
|
+
# call-seq:
|
483
|
+
# properties.update({key => value, ...}) -> properties
|
484
|
+
#
|
485
|
+
# Sets the value of the HTML property _key_ of the element represented by
|
486
|
+
# _properties_ to _value_ for each key-value pair, then returns
|
487
|
+
# _properties_. See also <tt>Element#set_properties</tt>.
|
488
|
+
#
|
489
|
+
#
|
490
|
+
#
|
491
|
+
def update(hash)
|
492
|
+
`c$Element.prototype.m$set_properties.call(#{@element},hash)`
|
493
|
+
return self
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
#
|
498
|
+
#
|
499
|
+
class Styles
|
500
|
+
def initialize(element) # :nodoc:
|
501
|
+
@element = element
|
502
|
+
end
|
503
|
+
|
504
|
+
# call-seq:
|
505
|
+
# styles[sym] -> object
|
506
|
+
#
|
507
|
+
# Returns the value of the CSS style _sym_ for the element represented by
|
508
|
+
# _styles_, or +nil+ if no such style is applied. See also
|
509
|
+
# <tt>Element#get_style</tt>.
|
510
|
+
#
|
511
|
+
#
|
512
|
+
#
|
513
|
+
def [](attribute)
|
514
|
+
`c$Element.prototype.m$get_style.call(#{@element},attribute)`
|
515
|
+
end
|
516
|
+
|
517
|
+
# call-seq:
|
518
|
+
# styles[sym] = value -> value
|
519
|
+
#
|
520
|
+
# Sets the value of the CSS style _sym_ to _value_ for the element
|
521
|
+
# represented by _styles_. See also <tt>Element#set_style</tt>.
|
522
|
+
#
|
523
|
+
#
|
524
|
+
#
|
525
|
+
def []=(attribute, value)
|
526
|
+
`c$Element.prototype.m$set_style.call(#{@element},attribute,value)`
|
527
|
+
end
|
528
|
+
|
529
|
+
# call-seq:
|
530
|
+
# styles.clear -> styles
|
531
|
+
#
|
532
|
+
# Removes the CSS styles that have been applied to the element represented
|
533
|
+
# by _styles_. See also <tt>Element#clear_styles</tt>.
|
534
|
+
#
|
535
|
+
#
|
536
|
+
#
|
537
|
+
def clear
|
538
|
+
`c$Element.prototype.m$clear_styles.call(#{@element})`
|
539
|
+
end
|
540
|
+
|
541
|
+
# call-seq:
|
542
|
+
# styles.delete(sym) -> object or nil
|
543
|
+
#
|
544
|
+
# If the element represented by _styles_ has the CSS style _sym_ applied,
|
545
|
+
# removes the style and returns its value, otherwise returns +nil+. See
|
546
|
+
# also <tt>Element#remove_style</tt>.
|
547
|
+
#
|
548
|
+
#
|
549
|
+
#
|
550
|
+
def delete(attribute)
|
551
|
+
`c$Element.prototype.m$remove_style.call(#{@element},attribute)`
|
552
|
+
end
|
553
|
+
|
554
|
+
# call-seq:
|
555
|
+
# styles.set?(sym) -> true or false
|
556
|
+
#
|
557
|
+
# Returns +true+ if the element represented by _styles_ has the CSS style
|
558
|
+
# _sym_ applied, +false+ otherwise.
|
559
|
+
#
|
560
|
+
#
|
561
|
+
#
|
562
|
+
def set?(attribute)
|
563
|
+
`$T(c$Element.prototype.m$get_style.call(#{@element},attribute))`
|
564
|
+
end
|
565
|
+
|
566
|
+
# call-seq:
|
567
|
+
# styles.update({key => value, ...}) -> styles
|
568
|
+
#
|
569
|
+
# Sets the value of the CSS style _key_ of the element represented by
|
570
|
+
# _styles_ to _value_ for each key-value pair, then returns _styles_.
|
571
|
+
# See also <tt>Element#set_styles</tt>.
|
572
|
+
#
|
573
|
+
#
|
574
|
+
#
|
575
|
+
def update(hash)
|
576
|
+
`c$Element.prototype.m$set_styles.call(#{@element},hash)`
|
577
|
+
return self
|
578
|
+
end
|
579
|
+
end
|
580
|
+
end
|