right-rails 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/right_rails/helpers/forms.rb +81 -47
- data/lib/right_rails/helpers.rb +9 -0
- data/public/javascripts/right/autocompleter-src.js +1 -1
- data/public/javascripts/right/autocompleter.js +1 -1
- data/public/javascripts/right/billboard-src.js +1 -1
- data/public/javascripts/right/billboard.js +1 -1
- data/public/javascripts/right/calendar-src.js +1 -1
- data/public/javascripts/right/calendar.js +1 -1
- data/public/javascripts/right/casting-src.js +183 -0
- data/public/javascripts/right/casting.js +7 -0
- data/public/javascripts/right/colorpicker-src.js +1 -1
- data/public/javascripts/right/colorpicker.js +1 -1
- data/public/javascripts/right/dialog-src.js +1 -1
- data/public/javascripts/right/dialog.js +1 -1
- data/public/javascripts/right/dnd-src.js +20 -20
- data/public/javascripts/right/dnd.js +2 -2
- data/public/javascripts/right/in-edit-src.js +1 -1
- data/public/javascripts/right/in-edit.js +1 -1
- data/public/javascripts/right/lightbox-src.js +24 -5
- data/public/javascripts/right/lightbox.js +2 -2
- data/public/javascripts/right/rails-src.js +1 -1
- data/public/javascripts/right/rails.js +1 -1
- data/public/javascripts/right/rater-src.js +1 -1
- data/public/javascripts/right/rater.js +1 -1
- data/public/javascripts/right/resizable-src.js +29 -3
- data/public/javascripts/right/resizable.js +2 -2
- data/public/javascripts/right/selectable-src.js +1 -1
- data/public/javascripts/right/selectable.js +1 -1
- data/public/javascripts/right/slider-src.js +5 -5
- data/public/javascripts/right/slider.js +2 -2
- data/public/javascripts/right/sortable-src.js +1 -1
- data/public/javascripts/right/sortable.js +1 -1
- data/public/javascripts/right/tabs-src.js +8 -6
- data/public/javascripts/right/tabs.js +2 -2
- data/public/javascripts/right/tags-src.js +745 -0
- data/public/javascripts/right/tags.js +7 -0
- data/public/javascripts/right/tooltips-src.js +1 -1
- data/public/javascripts/right/tooltips.js +1 -1
- data/public/javascripts/right/uploader-src.js +4 -3
- data/public/javascripts/right/uploader.js +2 -2
- data/public/javascripts/right-safe-src.js +2 -2
- data/public/javascripts/right-safe.js +2 -2
- data/public/javascripts/right-src.js +60 -47
- data/public/javascripts/right.js +2 -2
- data/spec/lib/right_rails/helpers/forms_spec.rb +67 -40
- metadata +10 -15
data/CHANGELOG
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# RightJS specific form features module
|
3
3
|
#
|
4
4
|
module RightRails::Helpers::Forms
|
5
|
-
|
5
|
+
|
6
6
|
#
|
7
7
|
# Generates the calendar field tag
|
8
8
|
#
|
@@ -11,18 +11,18 @@ module RightRails::Helpers::Forms
|
|
11
11
|
def calendar_field_tag(name, value=nil, options={})
|
12
12
|
text_field_tag name, value, Util.calendar_options(self, options)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
#
|
16
16
|
# The form_for level calendar field generator
|
17
17
|
#
|
18
18
|
def calendar_field(object_name, method, options={})
|
19
19
|
options = Util.calendar_options(self, options)
|
20
|
-
|
20
|
+
|
21
21
|
tag = ActionView::Helpers::InstanceTag.new(
|
22
22
|
object_name, method, self, options.delete(:object))
|
23
23
|
tag.to_calendar_field_tag(options)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
#
|
27
27
|
# Autocompletion field tag
|
28
28
|
#
|
@@ -31,21 +31,21 @@ module RightRails::Helpers::Forms
|
|
31
31
|
def autocomplete_field_tag(name, value, options)
|
32
32
|
text_field_tag name, value, Util.autocompleter_options(self, options)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
#
|
36
36
|
# The form_for level autocomplete-field generator
|
37
37
|
#
|
38
38
|
def autocomplete_field(object_name, method, options)
|
39
39
|
options = Util.autocompleter_options(self, options)
|
40
|
-
|
40
|
+
|
41
41
|
tag = ActionView::Helpers::InstanceTag.new(
|
42
42
|
object_name, method, self, options.delete(:object))
|
43
43
|
tag.to_autocomplete_field_tag(options)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
alias_method :autocompleter_field, :autocomplete_field
|
47
47
|
alias_method :autocompleter_field_tag, :autocomplete_field_tag
|
48
|
-
|
48
|
+
|
49
49
|
#
|
50
50
|
# The slider widget generator
|
51
51
|
#
|
@@ -53,7 +53,7 @@ module RightRails::Helpers::Forms
|
|
53
53
|
hidden_field_tag(name, value, Util.slider_options(self, options)) +
|
54
54
|
"\n" + Util.slider_generator(self, name, value, options)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
#
|
58
58
|
# The form_for level slider widget generator
|
59
59
|
#
|
@@ -63,7 +63,7 @@ module RightRails::Helpers::Forms
|
|
63
63
|
).to_slider_tag(Util.slider_options(self, options)) + "\n" +
|
64
64
|
Util.slider_generator(self, object_name, nil, options, method)
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
#
|
68
68
|
# The rater widget basic generator
|
69
69
|
#
|
@@ -71,7 +71,7 @@ module RightRails::Helpers::Forms
|
|
71
71
|
hidden_field_tag(name, value, Util.rater_options(self, options)) +
|
72
72
|
"\n" + Util.rater_generator(self, name, value, options)
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
#
|
76
76
|
# The form level rater generator
|
77
77
|
#
|
@@ -81,37 +81,55 @@ module RightRails::Helpers::Forms
|
|
81
81
|
).to_rater_tag(Util.rater_options(self, options)) +
|
82
82
|
"\n" + Util.rater_generator(self, object_name, nil, options, method)
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
#
|
86
86
|
# Builds a dummy rater, just for displaying purposes
|
87
87
|
#
|
88
88
|
def rater_display(value, options={})
|
89
89
|
rightjs_require_module 'rater'
|
90
|
-
|
90
|
+
|
91
91
|
content_tag :div, RightRails::Helpers.html_safe((0...(options[:size] || 5)).to_a.collect{ |i|
|
92
92
|
content_tag :div, RightRails::Helpers.html_safe('★'),
|
93
93
|
:class => i < value ? RightRails::Config.rightjs_version < 2 ? "right-rater-glow" : "active" : nil
|
94
94
|
}.join('')), :class => "#{RightRails::Helpers.css_prefix}-rater #{RightRails::Helpers.css_prefix}-rater-disabled"
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
#
|
98
98
|
# a standalone colorpicker field tag
|
99
99
|
#
|
100
100
|
def colorpicker_field_tag(name, value, options={})
|
101
101
|
text_field_tag name, value, Util.colorpicker_options(self, options)
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
#
|
105
105
|
# A colorpicker field for a form
|
106
106
|
#
|
107
107
|
def colorpicker_field(object_name, method, options={})
|
108
108
|
options = Util.colorpicker_options(self, options)
|
109
|
-
|
109
|
+
|
110
110
|
ActionView::Helpers::InstanceTag.new(
|
111
111
|
object_name, method, self, options.delete(:object)
|
112
112
|
).to_colorpicker_field_tag(options)
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
|
+
#
|
116
|
+
# a standalone tags field tag
|
117
|
+
#
|
118
|
+
def tags_field_tag(name, value, options={})
|
119
|
+
text_field_tag name, value, Util.tags_options(self, options)
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# a tags-field for a form
|
124
|
+
#
|
125
|
+
def tags_field(object_name, method, options={})
|
126
|
+
options = Util.tags_options(self, options)
|
127
|
+
|
128
|
+
ActionView::Helpers::InstanceTag.new(
|
129
|
+
object_name, method, self, options.delete(:object)
|
130
|
+
).to_tags_field_tag(options)
|
131
|
+
end
|
132
|
+
|
115
133
|
private
|
116
134
|
|
117
135
|
#
|
@@ -119,7 +137,7 @@ private
|
|
119
137
|
# so they didn't pollute the global scope
|
120
138
|
#
|
121
139
|
module Util
|
122
|
-
|
140
|
+
|
123
141
|
class << self
|
124
142
|
#
|
125
143
|
# Requires RightJS modules in the given context
|
@@ -127,21 +145,21 @@ private
|
|
127
145
|
def require_modules(context, *list)
|
128
146
|
RightRails::Helpers.require_js_module context, *list
|
129
147
|
end
|
130
|
-
|
148
|
+
|
131
149
|
#
|
132
150
|
# Preprocesses the RightJS module options
|
133
151
|
#
|
134
152
|
def unit_options(options, unit)
|
135
153
|
RightRails::Helpers.add_unit_options(options, unit)
|
136
154
|
end
|
137
|
-
|
155
|
+
|
138
156
|
#
|
139
157
|
# Checks if we are in the RightJS 1 mode
|
140
158
|
#
|
141
159
|
def in_rightjs_1
|
142
160
|
RightRails::Config.rightjs_version < 2
|
143
161
|
end
|
144
|
-
|
162
|
+
|
145
163
|
#
|
146
164
|
# Prepares a list of options for the calendar widget
|
147
165
|
#
|
@@ -149,23 +167,23 @@ private
|
|
149
167
|
require_modules(context, 'calendar')
|
150
168
|
unit_options(options, 'calendar').merge(in_rightjs_1 ? {:rel => 'calendar'} : {})
|
151
169
|
end
|
152
|
-
|
170
|
+
|
153
171
|
#
|
154
172
|
# Prepares the autocompleter field options hash
|
155
173
|
#
|
156
174
|
def autocompleter_options(context, options={})
|
157
175
|
require_modules(context, 'autocompleter')
|
158
|
-
|
176
|
+
|
159
177
|
options[:url] = context.escape_javascript(context.url_for(options[:url]))
|
160
|
-
|
178
|
+
|
161
179
|
url = options.delete(:url) if in_rightjs_1
|
162
|
-
|
180
|
+
|
163
181
|
options = unit_options(options, 'autocompleter').merge({:autocomplete => 'off'})
|
164
182
|
options.merge!({:rel => "autocompleter[#{url}]"}) if in_rightjs_1
|
165
|
-
|
183
|
+
|
166
184
|
options
|
167
185
|
end
|
168
|
-
|
186
|
+
|
169
187
|
#
|
170
188
|
# Prepares the list of slider options
|
171
189
|
#
|
@@ -173,7 +191,7 @@ private
|
|
173
191
|
require_modules context, 'dnd', 'slider'
|
174
192
|
RightRails::Helpers.remove_unit_options(options, 'slider')
|
175
193
|
end
|
176
|
-
|
194
|
+
|
177
195
|
#
|
178
196
|
# Generates the slider initialization script
|
179
197
|
#
|
@@ -185,7 +203,7 @@ private
|
|
185
203
|
options = RightRails::Helpers.unit_options(options.merge(:value => value), 'slider')
|
186
204
|
context.javascript_tag "new Slider(#{options}).insertTo('#{id}','after').assignTo('#{id}');"
|
187
205
|
end
|
188
|
-
|
206
|
+
|
189
207
|
#
|
190
208
|
# Prepares the rater widget options
|
191
209
|
#
|
@@ -193,7 +211,7 @@ private
|
|
193
211
|
require_modules context, 'rater'
|
194
212
|
RightRails::Helpers.remove_unit_options(options, 'rater')
|
195
213
|
end
|
196
|
-
|
214
|
+
|
197
215
|
#
|
198
216
|
# Generates the rater initialization script
|
199
217
|
#
|
@@ -205,7 +223,7 @@ private
|
|
205
223
|
options = RightRails::Helpers.unit_options(options.merge(:value => value), 'rater')
|
206
224
|
context.javascript_tag "new Rater(#{options}).insertTo('#{id}','after').assignTo('#{id}');"
|
207
225
|
end
|
208
|
-
|
226
|
+
|
209
227
|
#
|
210
228
|
# Prepares the Colorpicker widget options
|
211
229
|
#
|
@@ -213,42 +231,54 @@ private
|
|
213
231
|
require_modules context, 'colorpicker'
|
214
232
|
unit_options(options, 'colorpicker').merge(in_rightjs_1 ? {:rel => 'colorpicker'} : {})
|
215
233
|
end
|
234
|
+
|
235
|
+
#
|
236
|
+
# Prepares the Tags widget options
|
237
|
+
#
|
238
|
+
def tags_options(context, options)
|
239
|
+
require_modules context, 'tags'
|
240
|
+
unit_options(options, 'tags').merge(in_rightjs_1 ? {:rel => 'tags'} : {})
|
241
|
+
end
|
216
242
|
end
|
217
243
|
end
|
218
|
-
|
219
|
-
|
244
|
+
|
245
|
+
|
220
246
|
###################################################################################
|
221
247
|
#
|
222
248
|
# The ActiveView native form-builder extensions
|
223
249
|
#
|
224
250
|
###################################################################################
|
225
|
-
|
251
|
+
|
226
252
|
module FormBuilderMethods
|
227
253
|
def calendar_field(name, options={})
|
228
254
|
@template.calendar_field(@object_name, name, objectify_options(options))
|
229
255
|
end
|
230
|
-
|
256
|
+
|
231
257
|
def autocomplete_field(name, options={})
|
232
258
|
@template.autocomplete_field(@object_name, name, objectify_options(options))
|
233
259
|
end
|
234
|
-
|
260
|
+
|
235
261
|
def slider(name, options={})
|
236
262
|
@template.slider(@object_name, name, objectify_options(options))
|
237
263
|
end
|
238
|
-
|
264
|
+
|
239
265
|
def rater(name, options={})
|
240
266
|
@template.rater(@object_name, name, objectify_options(options))
|
241
267
|
end
|
242
|
-
|
268
|
+
|
243
269
|
def colorpicker_field(name, options={})
|
244
270
|
@template.colorpicker_field(@object_name, name, objectify_options(options))
|
245
271
|
end
|
272
|
+
|
273
|
+
def tags_field(name, options={})
|
274
|
+
@template.tags_field(@object_name, name, objectify_options(options))
|
275
|
+
end
|
246
276
|
end
|
247
|
-
|
277
|
+
|
248
278
|
module InstanceTagMethods
|
249
279
|
def to_calendar_field_tag(options)
|
250
280
|
options = options.stringify_keys
|
251
|
-
|
281
|
+
|
252
282
|
# formatting the date/time value if the format is specified
|
253
283
|
calendar_options = (options["data-calendar-options"] || options["data-calendar"])
|
254
284
|
if !options["value"] && calendar_options
|
@@ -258,30 +288,34 @@ private
|
|
258
288
|
options["value"] = time.to_time.strftime(format[0][1])
|
259
289
|
end
|
260
290
|
end
|
261
|
-
|
291
|
+
|
262
292
|
to_input_field_tag('text', options)
|
263
293
|
end
|
264
|
-
|
294
|
+
|
265
295
|
def to_autocomplete_field_tag(options)
|
266
296
|
to_input_field_tag('text', options)
|
267
297
|
end
|
268
|
-
|
298
|
+
|
269
299
|
def to_slider_tag(options)
|
270
300
|
to_input_field_tag('hidden', options)
|
271
301
|
end
|
272
|
-
|
302
|
+
|
273
303
|
def to_rater_tag(options)
|
274
304
|
to_input_field_tag('hidden', options)
|
275
305
|
end
|
276
|
-
|
306
|
+
|
277
307
|
def to_colorpicker_field_tag(options)
|
278
308
|
to_input_field_tag('text', options)
|
279
309
|
end
|
310
|
+
|
311
|
+
def to_tags_field_tag(options)
|
312
|
+
to_input_field_tag('text', options)
|
313
|
+
end
|
280
314
|
end
|
281
|
-
|
315
|
+
|
282
316
|
def self.included(base)
|
283
317
|
ActionView::Helpers::FormBuilder.instance_eval{ include FormBuilderMethods }
|
284
318
|
ActionView::Helpers::InstanceTag.instance_eval{ include InstanceTagMethods }
|
285
319
|
end
|
286
|
-
|
320
|
+
|
287
321
|
end
|
data/lib/right_rails/helpers.rb
CHANGED
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
|
|
98
98
|
var Klass = new RightJS.Class(AbstractWidget, methods);
|
99
99
|
|
100
100
|
// creating the widget related shortcuts
|
101
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
101
|
+
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
|
102
102
|
|
103
103
|
return Klass;
|
104
104
|
}
|
@@ -4,4 +4,4 @@
|
|
4
4
|
*
|
5
5
|
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
|
-
var Autocompleter=RightJS.Autocompleter=function(a,b){function g(a,c,d){var e=this.reAnchor||(this.reAnchor=new b.Element("div",{"class":"rui-re-anchor"})).insert(this),f=e.insertTo(a,"after").position(),g=a.dimensions(),h=this,i=parseInt(a.getStyle("borderTopWidth")),j=parseInt(a.getStyle("borderLeftWidth")),k=parseInt(a.getStyle("borderRightWidth")),l=parseInt(a.getStyle("borderBottomWidth")),m=g.top-f.y+i,n=g.left-f.x+j,o=g.width-j-k,p=g.height-i-l;h.setStyle("visibility:hidden").show(null),c==="right"?n+=o-h.size().x:m+=p,h.moveTo(n,m),d&&(c==="left"||c==="right"?h.setHeight(p):h.setWidth(o)),h.setStyle("visibility:visible").hide(null)}function f(a,c,d,e){b.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:b(a.fire).bind(a,c)},c==="hide"&&(e.duration=(b.Fx.Durations[e.duration]||e.duration)/2)))),(!b.Fx||!d)&&a.fire(c);return a.$super(d,e)}function c(a,c){c||(c=a,a="DIV");var d=new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof b.Input||this instanceof b.Form||e.unshift(a),this.$super.apply(this,e),b.isString(d)&&(d=b.$(d)),d instanceof b.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(a,c){c&&(a=b.Object.merge(a,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),a&&b.Options.setOptions.call(this,b.Object.merge(this.options,a));return this}}),e=new b.Class(d,c);b.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var d=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e={show:function(a,b){this.constructor.current=this;return f(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return f(this,"show",a,b)},showAt:function(a,c,d){this.hide(null).shownAt=a=b.$(a),g.call(this,a,c,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},h=b,i=b.$,j=b.$w,k=b.$E,l=b.Xhr,m=b.RegExp,n=b.isArray,o=new c("UL",{include:e,extend:{version:"2.2.1",EVENTS:j("show hide update load select done"),Options:{url:a.location.href,param:"search",method:"get",minLength:1,threshold:200,cache:!0,local:null,fxName:"slide",fxDuration:"short",spinner:"native",cssRule:"input[data-autocompleter]"}},initialize:function(a,b){this.input=i(a),this.$super("autocompleter",b).addClass("rui-dd-menu").onMousedown(this.clicked),this.input.autocompleter=this},destroy:function(){delete this.input.autocompleter;return this},prev:function(){return this.pick("prev")},next:function(){return this.pick("next")},done:function(a){a=a||this.first("li.current"),a&&(a.radioClass("current"),this.input.setValue(a._.textContent||a._.innerText),this.fire("done"));return this.hide()},setOptions:function(a){this.$super(a,this.input),a=this.options,h(a.url).includes("%{search}")||(a.url+=(h(a.url).includes("?")?"&":"?")+a.param+"=%{search}")},pick:function(a){var b=this.children(),c=b.first("hasClass","current"),d=b.indexOf(c);a=="prev"?c=d<1?b.last():b[d<0?0:d-1]:a=="next"&&(c=d<0||d==b.length-1?b.first():b[d+1]);return this.fire("select",{item:c.radioClass("current")})},clicked:function(a){this.done(a.stop().find("li"))},keypressed:function(a){if(this.input.value().length<this.options.minLength)return this.hide();this.timeout&&this.timeout.cancel(),this.timeout=h(this.trigger).bind(this).delay(this.options.threshold)},trigger:function(){this.timeout=null,this.cache=this.cache||{};var a=this.input.value(),b=this.options;if(a.length<b.minLength)return this.hide();this.cache[a]?this.suggest(this.cache[a],a):n(b.local)?this.suggest(this.findLocal(a),a):this.request=l.load(b.url.replace("%{search}",encodeURIComponent(a)),{method:b.method,spinner:this.getSpinner(),onComplete:h(function(b){this.fire("load").suggest(b.text,a)}).bind(this)})},suggest:function(a,b){this.options.cache&&(this.cache[b]=a);if(h(a).blank())this.hide();else{this.update(a.replace(/<ul[^>]*>|<\/ul>/im,"")),this.fire("update");if(!this._connected||this.hidden())this.showAt(this.input,"bottom","resize"),this._connected=!0}return this},findLocal:function(a){var b=new m("("+m.escape(a)+")","ig");return h(this.options.local).map(function(a){if(a.match(b))return"<li>"+a.replace(b,"<strong>$1</strong>")+"</li>"}).compact().join("")},getSpinner:function(){var a=this.options,b=a.spinner;b=="native"&&(b=a.spinner=(new d(3)).insertTo(this),b.addClass("rui-autocompleter-spinner")),b instanceof d&&g.call(b,this.input,"right","resize");return b}});i(a).on({focus:function(a){var c=a.target;c&&c instanceof b.Element&&(c.autocompleter||c.match(o.Options.cssRule))&&(c.autocompleter||new o(c))},blur:function(a){var b=a.target?a.target.autocompleter:null;b&&b.visible()&&b.hide()},keydown:function(a){var b=a.target?a.target.autocompleter:null;if(b&&b.visible()){var c=({27:"hide",38:"prev",40:"next",13:"done"})[a.keyCode];c&&(a.stop(),b[c]())}},keyup:function(a){var b=a.target?a.target.autocompleter:null;b&&!h([9,27,37,38,39,40,13]).include(a.keyCode)&&b.keypressed(a)}});var p=a.createElement("style"),q=a.createTextNode("*.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em}div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-autocompleter{border-top-color:#DDD !important;border-top-left-radius:0 !important;border-top-right-radius:0 !important;-moz-border-radius-topleft:0 !important;-moz-border-radius-topright:0 !important;-webkit-border-top-left-radius:0 !important;-webkit-border-top-right-radius:0 !important}.rui-autocompleter-spinner{border:none !important;background:none !important;position:absolute;z-index:9999}.rui-autocompleter-spinner div{margin-top:.2em !important; *margin-top:0.1em !important}");p.type="text/css",a.getElementsByTagName("head")[0].appendChild(p),p.styleSheet?p.styleSheet.cssText=q.nodeValue:p.appendChild(q);return o}(document,RightJS)
|
7
|
+
var Autocompleter=RightJS.Autocompleter=function(a,b){function g(a,c,d){var e=this.reAnchor||(this.reAnchor=new b.Element("div",{"class":"rui-re-anchor"})).insert(this),f=e.insertTo(a,"after").position(),g=a.dimensions(),h=this,i=parseInt(a.getStyle("borderTopWidth")),j=parseInt(a.getStyle("borderLeftWidth")),k=parseInt(a.getStyle("borderRightWidth")),l=parseInt(a.getStyle("borderBottomWidth")),m=g.top-f.y+i,n=g.left-f.x+j,o=g.width-j-k,p=g.height-i-l;h.setStyle("visibility:hidden").show(null),c==="right"?n+=o-h.size().x:m+=p,h.moveTo(n,m),d&&(c==="left"||c==="right"?h.setHeight(p):h.setWidth(o)),h.setStyle("visibility:visible").hide(null)}function f(a,c,d,e){b.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:b(a.fire).bind(a,c)},c==="hide"&&(e.duration=(b.Fx.Durations[e.duration]||e.duration)/2)))),(!b.Fx||!d)&&a.fire(c);return a.$super(d,e)}function c(a,c){c||(c=a,a="DIV");var d=new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof b.Input||this instanceof b.Form||e.unshift(a),this.$super.apply(this,e),b.isString(d)&&(d=b.$(d)),d instanceof b.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(a,c){c&&(a=b.Object.merge(a,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),a&&b.Options.setOptions.call(this,b.Object.merge(this.options,a));return this}}),e=new b.Class(d,c);b.Observer.createShortcuts(e.prototype,e.EVENTS||b([]));return e}var d=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e={show:function(a,b){this.constructor.current=this;return f(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return f(this,"show",a,b)},showAt:function(a,c,d){this.hide(null).shownAt=a=b.$(a),g.call(this,a,c,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},h=b,i=b.$,j=b.$w,k=b.$E,l=b.Xhr,m=b.RegExp,n=b.isArray,o=new c("UL",{include:e,extend:{version:"2.2.1",EVENTS:j("show hide update load select done"),Options:{url:a.location.href,param:"search",method:"get",minLength:1,threshold:200,cache:!0,local:null,fxName:"slide",fxDuration:"short",spinner:"native",cssRule:"input[data-autocompleter]"}},initialize:function(a,b){this.input=i(a),this.$super("autocompleter",b).addClass("rui-dd-menu").onMousedown(this.clicked),this.input.autocompleter=this},destroy:function(){delete this.input.autocompleter;return this},prev:function(){return this.pick("prev")},next:function(){return this.pick("next")},done:function(a){a=a||this.first("li.current"),a&&(a.radioClass("current"),this.input.setValue(a._.textContent||a._.innerText),this.fire("done"));return this.hide()},setOptions:function(a){this.$super(a,this.input),a=this.options,h(a.url).includes("%{search}")||(a.url+=(h(a.url).includes("?")?"&":"?")+a.param+"=%{search}")},pick:function(a){var b=this.children(),c=b.first("hasClass","current"),d=b.indexOf(c);a=="prev"?c=d<1?b.last():b[d<0?0:d-1]:a=="next"&&(c=d<0||d==b.length-1?b.first():b[d+1]);return this.fire("select",{item:c.radioClass("current")})},clicked:function(a){this.done(a.stop().find("li"))},keypressed:function(a){if(this.input.value().length<this.options.minLength)return this.hide();this.timeout&&this.timeout.cancel(),this.timeout=h(this.trigger).bind(this).delay(this.options.threshold)},trigger:function(){this.timeout=null,this.cache=this.cache||{};var a=this.input.value(),b=this.options;if(a.length<b.minLength)return this.hide();this.cache[a]?this.suggest(this.cache[a],a):n(b.local)?this.suggest(this.findLocal(a),a):this.request=l.load(b.url.replace("%{search}",encodeURIComponent(a)),{method:b.method,spinner:this.getSpinner(),onComplete:h(function(b){this.fire("load").suggest(b.text,a)}).bind(this)})},suggest:function(a,b){this.options.cache&&(this.cache[b]=a);if(h(a).blank())this.hide();else{this.update(a.replace(/<ul[^>]*>|<\/ul>/im,"")),this.fire("update");if(!this._connected||this.hidden())this.showAt(this.input,"bottom","resize"),this._connected=!0}return this},findLocal:function(a){var b=new m("("+m.escape(a)+")","ig");return h(this.options.local).map(function(a){if(a.match(b))return"<li>"+a.replace(b,"<strong>$1</strong>")+"</li>"}).compact().join("")},getSpinner:function(){var a=this.options,b=a.spinner;b=="native"&&(b=a.spinner=(new d(3)).insertTo(this),b.addClass("rui-autocompleter-spinner")),b instanceof d&&g.call(b,this.input,"right","resize");return b}});i(a).on({focus:function(a){var c=a.target;c&&c instanceof b.Element&&(c.autocompleter||c.match(o.Options.cssRule))&&(c.autocompleter||new o(c))},blur:function(a){var b=a.target?a.target.autocompleter:null;b&&b.visible()&&b.hide()},keydown:function(a){var b=a.target?a.target.autocompleter:null;if(b&&b.visible()){var c=({27:"hide",38:"prev",40:"next",13:"done"})[a.keyCode];c&&(a.stop(),b[c]())}},keyup:function(a){var b=a.target?a.target.autocompleter:null;b&&!h([9,27,37,38,39,40,13]).include(a.keyCode)&&b.keypressed(a)}});var p=a.createElement("style"),q=a.createTextNode("*.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em}div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-autocompleter{border-top-color:#DDD !important;border-top-left-radius:0 !important;border-top-right-radius:0 !important;-moz-border-radius-topleft:0 !important;-moz-border-radius-topright:0 !important;-webkit-border-top-left-radius:0 !important;-webkit-border-top-right-radius:0 !important}.rui-autocompleter-spinner{border:none !important;background:none !important;position:absolute;z-index:9999}.rui-autocompleter-spinner div{margin-top:.2em !important; *margin-top:0.1em !important}");p.type="text/css",a.getElementsByTagName("head")[0].appendChild(p),p.styleSheet?p.styleSheet.cssText=q.nodeValue:p.appendChild(q);return o}(document,RightJS)
|
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
|
|
98
98
|
var Klass = new RightJS.Class(AbstractWidget, methods);
|
99
99
|
|
100
100
|
// creating the widget related shortcuts
|
101
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
101
|
+
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
|
102
102
|
|
103
103
|
return Klass;
|
104
104
|
}
|
@@ -4,4 +4,4 @@
|
|
4
4
|
*
|
5
5
|
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
|
-
var Billboard=RightJS.Billboard=function(a){function b(b,c){c||(c=b,b="DIV");var d=new a.Class(a.Element.Wrappers[b]||a.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof a.Input||this instanceof a.Form||e.unshift(b),this.$super.apply(this,e),a.isString(d)&&(d=a.$(d)),d instanceof a.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return a.Wrapper.Cache[a.$uid(this._)]=this},setOptions:function(b,c){c&&(b=a.Object.merge(b,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),b&&a.Options.setOptions.call(this,a.Object.merge(this.options,b));return this}}),e=new a.Class(d,c);a.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var c=a,d=a.$,e=a.$$,f=a.$w,g=a.$E,h=a.Fx,i=a.Class,j=a.Object,k=new b("UL",{extend:{version:"2.2.0",EVENTS:f("change first last"),Options:{fxName:"stripe",fxDuration:"long",autostart:!0,delay:4e3,loop:!0,showButtons:!0,prevButton:"native",nextButton:"native",stripes:10,cssRule:"*.rui-billboard"}},initialize:function(a){this.$super("billboard",a),this.options.showButtons&&(this.prevButton=this.options.prevButton!=="native"?d(this.options.prevButton):g("div",{"class":"rui-billboard-button-prev",html:"‹"}).insertTo(this),this.nextButton=this.options.nextButton!=="native"?d(this.options.nextButton):g("div",{"class":"rui-billboard-button-next",html:"›"}).insertTo(this),this.prevButton.onClick(c(function(a){a.stop(),this.showPrev()}).bind(this)),this.nextButton.onClick(c(function(a){a.stop(),this.showNext()}).bind(this))),this.onChange(function(a){a.item===this.items().first()?this.fire("first"):a.item===this.items().last()&&this.fire("last")}),this.on({mouseover:function(){this.stop()},mouseout:function(a){this.options.autostart&&!a.find(".rui-billboard")&&this.start()}}),this.options.autostart&&this.start()},items:function(){return this.children().without(this.prevButton,this.nextButton)},showNext:function(){var a=this.items(),b=a.indexOf(this.current())+1;b==a.length&&this.options.loop&&(b=0);return this.current(b)},showPrev:function(){var a=this.items(),b=a.indexOf(this.current())-1;b<0&&this.options.loop&&(b=a.length-1);return this.current(b)},current:function(a){var b=this.items();if(arguments.length)a instanceof Element&&(a=b.indexOf(a)),this.runFx(b[a]);else return b.length?b.first("hasClass","rui-billboard-current")||b.first().addClass("rui-billboard-current"):null;return this},start:function(){this.timer=c(this.showNext).bind(this).periodical(this.options.delay)},stop:function(){this.timer&&this.timer.stop()},fire:function(a,b){return this.$super(a,j.merge({index:this.items().indexOf(this.current()),item:this.current()},b))},runFx:function(a){if(a&&!this._running){var b=k.Fx[c(this.options.fxName||"").capitalize()];b?(new b(this)).start(this.current(),a):(this.current().removeClass("rui-billboard-current"),a.addClass("rui-billboard-current"))}}});k.Fx=new i(h,{initialize:function(a){this.container=g("div",{"class":"rui-billboard-fx-container"}),this.$super(a,{duration:a.options.fxDuration,onStart:function(){a._running=!0,a.insert(this.container)},onFinish:function(){this.container.remove(),a._running=!1,a.fire("change")}})},prepare:function(a,b){a.removeClass("rui-billboard-current"),b.addClass("rui-billboard-current"),this.clone=a.clone(),this.container.update(this.clone)}}),k.Fx.Fade=new i(k.Fx,{prepare:function(a,b){this.$super(a,b)},render:function(a){this.container.setStyle({opacity:1-a})}}),k.Fx.Slide=new i(k.Fx,{prepare:function(a,b){this._width=this.element.current().size().x,this._direction=a.nextSiblings().include(b)?-1:1,this.$super(a,b),this.clone.setStyle({width:this._width+"px"})},render:function(a){this.clone._.style.left=this._direction*this._width*a+"px"}}),k.Fx.Stripe=new i(k.Fx,{directions:["down","up","left","right"],prepare:function(a,b){this.$super(a,b);var d=this.element.options.stripes,e=this.element.items()[0].size().x/d,f=100,h=this.directions.shift();this.directions.push(h),this.container.clean();for(var i=0;i<d;i++){var j=g("div",{"class":"rui-billboard-stripe",style:{width:e+1+"px",left:i*e+"px"}}).insert(a.clone().setStyle({width:e*d+"px",left:-i*e+"px"}));this.container.append(j);var k={duration:this.options.duration};if(h!=="right"&&i===d-1||h==="right"&&i===0)k.onFinish=c(this.finish).bind(this,!0);switch(h){case"up":c(function(a,b){a.setHeight(a.size().y),a.morph({height:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"down":j.setStyle("top: auto; bottom: 0px"),c(function(a,b){a.setHeight(a.size().y),a.morph({height:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"left":c(function(a,b){a.morph({width:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"right":c(function(a,b){a.morph({width:"0px"},b)}).bind(this,j,k).delay((d-i-1)*f);break;default:this.finish(!0)}}},finish:function(a){a&&this.$super();return this}}),d(document).onReady(function(){e(k.Options.cssRule).each(function(a){a instanceof k||(a=new k(a))})});var l=document.createElement("style"),m=document.createTextNode("*.rui-billboard, *.rui-billboard> *{margin:0;padding:0;list-style:none} *.rui-billboard{display:inline-block; *display:inline; *zoom:1;position:relative} *.rui-billboard> *{display:none;width:100%;height:100%} *.rui-billboard> *:first-child, *.rui-billboard> *.rui-billboard-current:first-child{display:block;position:relative} *.rui-billboard> *>img{margin:0;padding:0} *.rui-billboard-current{position:absolute;left:0;top:0;display:block;z-index:999} *.rui-billboard-button-prev, *.rui-billboard-button-next{position:absolute;z-index:99999;left:.25em;top:auto;bottom:.25em;display:block;width:.5em;height:auto;text-align:center;font-size:200%;font-family:Arial;font-weight:bold;padding:0em .5em .2em .5em;background:white;opacity:0;filter:alpha(opacity:0);cursor:pointer;border:.12em solid #888;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;user-select:none;-moz-user-select:none;-webkit-user-select:none;transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out} *.rui-billboard-button-next{left:auto;right:.25em;text-align:right} *.rui-billboard-button-prev:active{text-indent:-.1em} *.rui-billboard-button-next:active{text-indent:.2em} *.rui-billboard:hover *.rui-billboard-button-prev, *.rui-billboard:hover *.rui-billboard-button-next{opacity:0.4;filter:alpha(opacity:40)} *.rui-billboard:hover *.rui-billboard-button-prev:hover, *.rui-billboard:hover *.rui-billboard-button-next:hover{opacity:0.7;filter:alpha(opacity:70)}.rui-billboard-fx-container{position:absolute;left:0;top:0;display:block;z-index:9999;overflow:hidden}.rui-billboard-fx-container> *{position:absolute;left:0;top:0}.rui-billboard-stripe{overflow:hidden}.rui-billboard-stripe> *{position:relative}");l.type="text/css",document.getElementsByTagName("head")[0].appendChild(l),l.styleSheet?l.styleSheet.cssText=m.nodeValue:l.appendChild(m);return k}(RightJS)
|
7
|
+
var Billboard=RightJS.Billboard=function(a){function b(b,c){c||(c=b,b="DIV");var d=new a.Class(a.Element.Wrappers[b]||a.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof a.Input||this instanceof a.Form||e.unshift(b),this.$super.apply(this,e),a.isString(d)&&(d=a.$(d)),d instanceof a.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return a.Wrapper.Cache[a.$uid(this._)]=this},setOptions:function(b,c){c&&(b=a.Object.merge(b,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),b&&a.Options.setOptions.call(this,a.Object.merge(this.options,b));return this}}),e=new a.Class(d,c);a.Observer.createShortcuts(e.prototype,e.EVENTS||a([]));return e}var c=a,d=a.$,e=a.$$,f=a.$w,g=a.$E,h=a.Fx,i=a.Class,j=a.Object,k=new b("UL",{extend:{version:"2.2.0",EVENTS:f("change first last"),Options:{fxName:"stripe",fxDuration:"long",autostart:!0,delay:4e3,loop:!0,showButtons:!0,prevButton:"native",nextButton:"native",stripes:10,cssRule:"*.rui-billboard"}},initialize:function(a){this.$super("billboard",a),this.options.showButtons&&(this.prevButton=this.options.prevButton!=="native"?d(this.options.prevButton):g("div",{"class":"rui-billboard-button-prev",html:"‹"}).insertTo(this),this.nextButton=this.options.nextButton!=="native"?d(this.options.nextButton):g("div",{"class":"rui-billboard-button-next",html:"›"}).insertTo(this),this.prevButton.onClick(c(function(a){a.stop(),this.showPrev()}).bind(this)),this.nextButton.onClick(c(function(a){a.stop(),this.showNext()}).bind(this))),this.onChange(function(a){a.item===this.items().first()?this.fire("first"):a.item===this.items().last()&&this.fire("last")}),this.on({mouseover:function(){this.stop()},mouseout:function(a){this.options.autostart&&!a.find(".rui-billboard")&&this.start()}}),this.options.autostart&&this.start()},items:function(){return this.children().without(this.prevButton,this.nextButton)},showNext:function(){var a=this.items(),b=a.indexOf(this.current())+1;b==a.length&&this.options.loop&&(b=0);return this.current(b)},showPrev:function(){var a=this.items(),b=a.indexOf(this.current())-1;b<0&&this.options.loop&&(b=a.length-1);return this.current(b)},current:function(a){var b=this.items();if(arguments.length)a instanceof Element&&(a=b.indexOf(a)),this.runFx(b[a]);else return b.length?b.first("hasClass","rui-billboard-current")||b.first().addClass("rui-billboard-current"):null;return this},start:function(){this.timer=c(this.showNext).bind(this).periodical(this.options.delay)},stop:function(){this.timer&&this.timer.stop()},fire:function(a,b){return this.$super(a,j.merge({index:this.items().indexOf(this.current()),item:this.current()},b))},runFx:function(a){if(a&&!this._running){var b=k.Fx[c(this.options.fxName||"").capitalize()];b?(new b(this)).start(this.current(),a):(this.current().removeClass("rui-billboard-current"),a.addClass("rui-billboard-current"))}}});k.Fx=new i(h,{initialize:function(a){this.container=g("div",{"class":"rui-billboard-fx-container"}),this.$super(a,{duration:a.options.fxDuration,onStart:function(){a._running=!0,a.insert(this.container)},onFinish:function(){this.container.remove(),a._running=!1,a.fire("change")}})},prepare:function(a,b){a.removeClass("rui-billboard-current"),b.addClass("rui-billboard-current"),this.clone=a.clone(),this.container.update(this.clone)}}),k.Fx.Fade=new i(k.Fx,{prepare:function(a,b){this.$super(a,b)},render:function(a){this.container.setStyle({opacity:1-a})}}),k.Fx.Slide=new i(k.Fx,{prepare:function(a,b){this._width=this.element.current().size().x,this._direction=a.nextSiblings().include(b)?-1:1,this.$super(a,b),this.clone.setStyle({width:this._width+"px"})},render:function(a){this.clone._.style.left=this._direction*this._width*a+"px"}}),k.Fx.Stripe=new i(k.Fx,{directions:["down","up","left","right"],prepare:function(a,b){this.$super(a,b);var d=this.element.options.stripes,e=this.element.items()[0].size().x/d,f=100,h=this.directions.shift();this.directions.push(h),this.container.clean();for(var i=0;i<d;i++){var j=g("div",{"class":"rui-billboard-stripe",style:{width:e+1+"px",left:i*e+"px"}}).insert(a.clone().setStyle({width:e*d+"px",left:-i*e+"px"}));this.container.append(j);var k={duration:this.options.duration};if(h!=="right"&&i===d-1||h==="right"&&i===0)k.onFinish=c(this.finish).bind(this,!0);switch(h){case"up":c(function(a,b){a.setHeight(a.size().y),a.morph({height:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"down":j.setStyle("top: auto; bottom: 0px"),c(function(a,b){a.setHeight(a.size().y),a.morph({height:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"left":c(function(a,b){a.morph({width:"0px"},b)}).bind(this,j,k).delay(i*f);break;case"right":c(function(a,b){a.morph({width:"0px"},b)}).bind(this,j,k).delay((d-i-1)*f);break;default:this.finish(!0)}}},finish:function(a){a&&this.$super();return this}}),d(document).onReady(function(){e(k.Options.cssRule).each(function(a){a instanceof k||(a=new k(a))})});var l=document.createElement("style"),m=document.createTextNode("*.rui-billboard, *.rui-billboard> *{margin:0;padding:0;list-style:none} *.rui-billboard{display:inline-block; *display:inline; *zoom:1;position:relative} *.rui-billboard> *{display:none;width:100%;height:100%} *.rui-billboard> *:first-child, *.rui-billboard> *.rui-billboard-current:first-child{display:block;position:relative} *.rui-billboard> *>img{margin:0;padding:0} *.rui-billboard-current{position:absolute;left:0;top:0;display:block;z-index:999} *.rui-billboard-button-prev, *.rui-billboard-button-next{position:absolute;z-index:99999;left:.25em;top:auto;bottom:.25em;display:block;width:.5em;height:auto;text-align:center;font-size:200%;font-family:Arial;font-weight:bold;padding:0em .5em .2em .5em;background:white;opacity:0;filter:alpha(opacity:0);cursor:pointer;border:.12em solid #888;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;user-select:none;-moz-user-select:none;-webkit-user-select:none;transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out} *.rui-billboard-button-next{left:auto;right:.25em;text-align:right} *.rui-billboard-button-prev:active{text-indent:-.1em} *.rui-billboard-button-next:active{text-indent:.2em} *.rui-billboard:hover *.rui-billboard-button-prev, *.rui-billboard:hover *.rui-billboard-button-next{opacity:0.4;filter:alpha(opacity:40)} *.rui-billboard:hover *.rui-billboard-button-prev:hover, *.rui-billboard:hover *.rui-billboard-button-next:hover{opacity:0.7;filter:alpha(opacity:70)}.rui-billboard-fx-container{position:absolute;left:0;top:0;display:block;z-index:9999;overflow:hidden}.rui-billboard-fx-container> *{position:absolute;left:0;top:0}.rui-billboard-stripe{overflow:hidden}.rui-billboard-stripe> *{position:relative}");l.type="text/css",document.getElementsByTagName("head")[0].appendChild(l),l.styleSheet?l.styleSheet.cssText=m.nodeValue:l.appendChild(m);return k}(RightJS)
|
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
|
|
98
98
|
var Klass = new RightJS.Class(AbstractWidget, methods);
|
99
99
|
|
100
100
|
// creating the widget related shortcuts
|
101
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
101
|
+
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
|
102
102
|
|
103
103
|
return Klass;
|
104
104
|
}
|
@@ -4,4 +4,4 @@
|
|
4
4
|
*
|
5
5
|
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
6
6
|
*/
|
7
|
-
var Calendar=RightJS.Calendar=function(a,b,c){function j(a){return(a<10?"0":"")+a}function h(a,d,e){var f=this.reAnchor||(this.reAnchor=new c.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=b(a.getStyle("borderTopWidth")),k=b(a.getStyle("borderLeftWidth")),l=b(a.getStyle("borderRightWidth")),m=b(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),d==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(d==="left"||d==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function g(a,b,d,e){c.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:c(a.fire).bind(a,b)},b==="hide"&&(e.duration=(c.Fx.Durations[e.duration]||e.duration)/2)))),(!c.Fx||!d)&&a.fire(b);return a.$super(d,e)}function d(a,b){b||(b=a,a="DIV");var d=new c.Class(c.Element.Wrappers[a]||c.Element,{initialize:function(b,d){this.key=b;var e=[{"class":"rui-"+b}];this instanceof c.Input||this instanceof c.Form||e.unshift(a),this.$super.apply(this,e),c.isString(d)&&(d=c.$(d)),d instanceof c.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return c.Wrapper.Cache[c.$uid(this._)]=this},setOptions:function(a,b){b&&(a=c.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&c.Options.setOptions.call(this,c.Object.merge(this.options,a));return this}}),e=new c.Class(d,b);c.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var e=new c.Class(c.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),f={show:function(a,b){this.constructor.current=this;return g(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return g(this,"show",a,b)},showAt:function(a,b,d){this.hide(null).shownAt=a=c.$(a),h.call(this,a,b,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},i={assignTo:function(a,b){a=c.$(a),b=c.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var d=c(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:d,change:d}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=c,l=c.$,m=c.$$,n=c.$w,o=c.$ext,p=c.$uid,q=c.isString,r=c.isArray,s=c.isFunction,t=c.Class,u=c.Element,v=c.Input,w=c.RegExp,x=c.Browser,y=new d({include:[f,i],extend:{version:"2.2.0",EVENTS:n("show hide change done"),Options:{format:"ISO",showTime:null,showButtons:!1,minDate:!1,maxDate:!1,fxName:"fade",fxDuration:"short",firstDay:1,numberOfMonths:1,timePeriod:1,twentyFourHour:null,listYears:!1,hideOnPick:!1,update:null,trigger:null,cssRule:"*[data-calendar]"},Formats:{ISO:"%Y-%m-%d",POSIX:"%Y/%m/%d",EUR:"%d-%m-%Y",US:"%m/%d/%Y"},i18n:{Done:"Done",Now:"Now",NextMonth:"Next Month",PrevMonth:"Previous Month",NextYear:"Next Year",PrevYear:"Previous Year",dayNames:n("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),dayNamesShort:n("Sun Mon Tue Wed Thu Fri Sat"),dayNamesMin:n("Su Mo Tu We Th Fr Sa"),monthNames:n("January February March April May June July August September October November December"),monthNamesShort:n("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")},current:null,hideAll:function(a){m("div.rui-calendar").each(function(b){b instanceof y&&b!==a&&b.visible()&&!b.inlined()&&b.hide()})}},initialize:function(a){this.$super("calendar",a),this.addClass("rui-panel"),a=this.options,this.insert([this.swaps=new z(a),this.greed=new B(a)]),a.showTime&&this.insert(this.timepicker=new C(a)),a.showButtons&&this.insert(this.buttons=new D(a)),this.setDate(new Date).initEvents()},setDate:function(a,b){if(a=this.parse(a)){var c=this.options;c.minDate&&c.minDate>a&&(a=new Date(c.minDate)),c.maxDate&&c.maxDate<a&&(a=new Date(c.maxDate),a.setDate(a.getDate()-1)),this._date=b?new Date(this._date||this.date):null,this.greed.setDate(this._date||a,a),(c.minDate||c.maxDate)&&this.swaps.setDate(a),this.timepicker&&!b&&this.timepicker.setDate(a),a!=this.date&&this.fire("change",{date:this.date=a})}return this},getDate:function(){return this.date},setValue:function(a){return this.setDate(a)},getValue:function(a){return this.format(a)},insertTo:function(a,b){this.addClass("rui-calendar-inline");return this.$super(a,b)},done:function(){this.inlined()||this.hide(),this.fire("done",{date:this.date})},inlined:function(){return this.hasClass("rui-calendar-inline")},setOptions:function(a){a=a||{},this.$super(a,l(a.trigger||a.update));var b=this.constructor,c=this.options;c.i18n={};for(var d in b.i18n)c.i18n[d]=r(b.i18n[d])?b.i18n[d].clone():b.i18n[d];o(c.i18n,a.i18n),c.dayNames=c.i18n.dayNamesMin,c.firstDay&&c.dayNames.push(c.dayNames.shift()),r(c.numberOfMonths)||(c.numberOfMonths=[c.numberOfMonths,1]),c.minDate&&(c.minDate=this.parse(c.minDate)),c.maxDate&&(c.maxDate=this.parse(c.maxDate),c.maxDate.setDate(c.maxDate.getDate()+1)),c.format=k(b.Formats[c.format]||c.format).trim(),c.showTime===null&&(c.showTime=c.format.search(/%[HkIl]/)>-1),c.twentyFourHour===null&&(c.twentyFourHour=c.format.search(/%[Il]/)<0),c.timePeriod>60&&12%Math.ceil(c.timePeriod/60)&&(c.twentyFourHour=!0),c.update&&this.assignTo(c.update,c.trigger);return this},hideOthers:function(){y.hideAll(this);return this}}),z=new t(u,{initialize:function(a){this.$super("div",{"class":"swaps"}),this.options=a;var b=a.i18n;this.insert([this.prevMonth=new e("‹",{title:b.PrevMonth,"class":"prev-month"}),this.nextMonth=new e("›",{title:b.NextMonth,"class":"next-month"})]),a.listYears&&this.insert([this.prevYear=new e("«",{title:b.PrevYear,"class":"prev-year"}),this.nextYear=new e("»",{title:b.NextYear,"class":"next-year"})]),this.buttons=k([this.prevMonth,this.nextMonth,this.prevYear,this.nextYear]).compact(),this.onClick(this.clicked)},setDate:function(a){var b=this.options,c=b.numberOfMonths[0]*b.numberOfMonths[1],d=!0,e=!0,f=!0,g=!0;if(b.minDate){var h=new Date(a.getFullYear(),0,1,0,0,0),i=new Date(b.minDate.getFullYear(),0,1,0,0,0);d=h>i,h.setMonth(a.getMonth()-Math.ceil(c-c/2)),i.setMonth(b.minDate.getMonth()),f=h>=i}if(b.maxDate){var j=new Date(a),l=new Date(b.maxDate),m=k([j,l]);m.each(function(a){a.setDate(32),a.setMonth(a.getMonth()-1),a.setDate(32-a.getDate()),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0)}),g=j<l,m.each("setMonth",0),e=j<l}this.nextMonth[g?"enable":"disable"](),this.prevMonth[f?"enable":"disable"](),this.nextYear&&(this.nextYear[e?"enable":"disable"](),this.prevYear[d?"enable":"disable"]())},clicked:function(a){var b=a.target;b&&this.buttons.include(b)&&(b.enabled()&&this.fire(b.get("className").split(/\s+/)[0]))}}),A=new t(u,{initialize:function(a){this.$super("table",{"class":"month"}),this.options=a,this.insert(this.caption=new u("caption")),this.insert("<thead><tr>"+a.dayNames.map(function(a){return"<th>"+a+"</th>"}).join("")+"</tr></thead>"),this.days=[];var b=(new u("tbody")).insertTo(this),c,d,e;for(d=0;d<6;d++){e=(new u("tr")).insertTo(b);for(c=0;c<7;c++)this.days.push((new u("td")).insertTo(e))}this.onClick(this.clicked)},setDate:function(b,c){b.setDate(32);var d=32-b.getDate();b.setMonth(b.getMonth()-1);var e=Math.ceil(c.getTime()/864e5),f=this.options,g=f.i18n,h=this.days;for(var i=0,j=h.length-1,k,l,m;i<7;i++)k=h[i]._,l=h[j-i]._,m=h[j-i-7]._,k.innerHTML=l.innerHTML=m.innerHTML="",k.className=l.className=m.className="blank";for(var i=1,n=0,o,p;i<=d;i++){b.setDate(i);var q=b.getDay();f.firstDay===1&&(q=q>0?q-1:6);if(i===1||q===0)o=h.slice(n*7,n*7+7),n++;p=o[q]._,x.OLD?(p.innerHTML="",p.appendChild(a.createTextNode(i))):p.innerHTML=""+i,p.className=e===Math.ceil(b.getTime()/864e5)?"selected":"";if(f.minDate&&f.minDate>b||f.maxDate&&f.maxDate<b)p.className="disabled";o[q].date=new Date(b)}var r=(f.listYears?g.monthNamesShort[b.getMonth()]+",":g.monthNames[b.getMonth()])+" "+b.getFullYear(),s=this.caption._;x.OLD?(s.innerHTML="",s.appendChild(a.createTextNode(r))):s.innerHTML=r},clicked:function(a){var b=a.target,c=b.date;b&&c&&!b.hasClass("disabled")&&!b.hasClass("blank")&&(b.addClass("selected"),this.fire("date-set",{date:c.getDate(),month:c.getMonth(),year:c.getFullYear()}))}}),B=new t(u,{initialize:function(a){this.$super("table",{"class":"greed"}),this.months=[];var b=(new u("tbody")).insertTo(this),c;for(var d=0;d<a.numberOfMonths[1];d++){var e=(new u("tr")).insertTo(b);for(var f=0;f<a.numberOfMonths[0];f++)this.months.push(c=new A(a)),(new u("td")).insertTo(e).insert(c)}},setDate:function(a,b){var c=this.months,d=c.length;b=b||a;for(var e=-Math.ceil(d-d/2)+1,f=0;e<Math.floor(d-d/2)+1;e++,f++){var g=new Date(a);g.setMonth(a.getMonth()+e),c[f].setDate(g,b)}}}),C=new t(u,{initialize:function(a){this.$super("div",{"class":"timepicker"}),this.options=a;var b=k(this.timeChanged).bind(this);this.insert([this.hours=(new u("select")).onChange(b),this.minutes=(new u("select")).onChange(b)]);var c=a.timePeriod<60?a.timePeriod:60,d=a.timePeriod<60?1:Math.ceil(a.timePeriod/60);for(var e=0;e<60;e++){var f=j(e);e<24&&e%d==0&&(a.twentyFourHour?this.hours.insert(new u("option",{value:e,html:f})):e<12&&this.hours.insert(new u("option",{value:e,html:e==0?12:e}))),e%c==0&&this.minutes.insert(new u("option",{value:e,html:f}))}a.twentyFourHour||(this.meridian=(new u("select")).onChange(b).insertTo(this),k(k(a.format).includes(/%P/)?["am","pm"]:["AM","PM"]).each(function(a){this.meridian.insert(new u("option",{value:a.toLowerCase(),html:a}))},this))},setDate:function(a){var b=this.options,c=b.timePeriod<60?a.getHours():Math.round(a.getHours()/(b.timePeriod/60))*(b.timePeriod/60),d=Math.round(a.getMinutes()/(b.timePeriod%60))*b.timePeriod;this.meridian&&(this.meridian.setValue(c<12?"am":"pm"),c=c==0||c==12?12:c>12?c-12:c),this.hours.setValue(c),this.minutes.setValue(d)},timeChanged:function(a){a.stopPropagation();var c=b(this.hours.value()),d=b(this.minutes.value());this.meridian&&(c==12&&(c=0),this.meridian.value()=="pm"&&(c+=12)),this.fire("time-set",{hours:c,minutes:d})}}),D=new t(u,{initialize:function(a){this.$super("div",{"class":"buttons"}),this.insert([(new e(a.i18n.Now,{"class":"now"})).onClick("fire","now-clicked"),(new e(a.i18n.Done,{"class":"done"})).onClick("fire","done-clicked")])}});y.include({parse:function(a){var c;if(q(a)&&a){var d=w.escape(this.options.format),e=k(d.match(/%[a-z]/ig)).map("match",/[a-z]$/i).map("first").without("%"),f=new w("^"+d.replace(/%p/i,"(pm|PM|am|AM)").replace(/(%[a-z])/ig,"(.+?)")+"$"),g=k(a).trim().match(f);if(g){g.shift();var h=null,i=null,j=null,l=null,m=null,n;while(g.length){var o=g.shift(),p=e.shift();if(p.toLowerCase()=="b")i=this.options.i18n[p=="b"?"monthNamesShort":"monthNames"].indexOf(o);else if(p.toLowerCase()=="p")n=o.toLowerCase();else{o=b(o,10);switch(p){case"d":case"e":c=o;break;case"m":i=o-1;break;case"y":case"Y":h=o;break;case"H":case"k":case"I":case"l":j=o;break;case"M":l=o;break;case"S":m=o}}}n&&(j=j==12?0:j,j=n=="pm"?j+12:j),c=new Date(h,i,c,j,l,m)}}else if(a instanceof Date||Date.parse(a))c=new Date(a);return!c||isNaN(c.getTime())?null:c},format:function(a){var b=this.options.i18n,c=this.date.getDay(),d=this.date.getMonth(),e=this.date.getDate(),f=this.date.getFullYear(),g=this.date.getHours(),h=this.date.getMinutes(),i=this.date.getSeconds(),k=g==0?12:g<13?g:g-12,l={a:b.dayNamesShort[c],A:b.dayNames[c],b:b.monthNamesShort[d],B:b.monthNames[d],d:j(e),e:""+e,m:(d<9?"0":"")+(d+1),y:(""+f).substring(2,4),Y:""+f,H:j(g),k:""+g,I:(g>0&&(g<10||g>12&&g<22)?"0":"")+k,l:""+k,p:g<12?"AM":"PM",P:g<12?"am":"pm",M:j(h),S:j(i),"%":"%"},m=a||this.options.format;for(var n in l)m=m.replace("%"+n,l[n]);return m}}),y.include({initEvents:function(){var a="_shiftDate",b=this._terminate;this.on({"prev-day":[a,{Date:-1}],"next-day":[a,{Date:1}],"prev-week":[a,{Date:-7}],"next-week":[a,{Date:7}],"prev-month":[a,{Month:-1}],"next-month":[a,{Month:1}],"prev-year":[a,{FullYear:-1}],"next-year":[a,{FullYear:1}],"date-set":this._changeDate,"time-set":this._changeTime,"now-clicked":this._setNow,"done-clicked":this.done,click:b,mousedown:b,focus:b,blur:b})},_shiftDate:function(a){var b=new Date(this.date),c=this.options;for(var d in a)b["set"+d](b["get"+d]()+a[d]);this.setDate(b)},_changeDate:function(a){var b=new Date(this.date);b.setDate(a.date),b.setMonth(a.month),b.setFullYear(a.year),this.setDate(b,!0),this.options.hideOnPick&&this.done()},_changeTime:function(a){var b=new Date(this.date);b.setHours(a.hours),b.setMinutes(a.minutes),this.setDate(b)},_setNow:function(){this.setDate(new Date)},_terminate:function(a){a.stopPropagation(),this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}}),l(a).on({focus:function(a){var b=a.target instanceof v&&a.target.get("type")=="text"?a.target:null;y.hideAll(),b&&(b.calendar||b.match(y.Options.cssRule))&&(b.calendar||new y({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.calendar;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof u?a.target:null;if(b&&(b.calendar||b.match(y.Options.cssRule))){if(!(b instanceof v)||b.get("type")!="text")a.stop(),(b.calendar||new y({trigger:b})).hide(null).toggleAt(b.assignedInput)}else a.find("div.rui-calendar")||y.hideAll()},keydown:function(a){var b=y.current,c=({27:"hide",37:"prev-day",39:"next-day",38:"prev-week",40:"next-week",33:"prev-month",34:"next-month",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),s(b[c])?b[c]():b.fire(c))}});var E=a.createElement("style"),F=a.createTextNode(".rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default} *.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}div.rui-calendar .swaps,div.rui-calendar .greed,div.rui-calendar .timepicker,div.rui-calendar .buttons,div.rui-calendar table,div.rui-calendar table tr,div.rui-calendar table th,div.rui-calendar table td,div.rui-calendar table tbody,div.rui-calendar table thead,div.rui-calendar table caption{background:none;border:none;width:auto;height:auto;margin:0;padding:0}div.rui-calendar-inline{position:relative;display:inline-block; *display:inline; *zoom:1;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-calendar .swaps{position:relative}div.rui-calendar .swaps .rui-button{position:absolute;float:left;width:1em;padding:.15em .4em}div.rui-calendar .swaps .next-month{right:0em;_right:.5em}div.rui-calendar .swaps .prev-year{left:2.05em}div.rui-calendar .swaps .next-year{right:2.05em;_right:2.52em}div.rui-calendar .greed{border-spacing:0px;border-collapse:collapse;border-size:0}div.rui-calendar .greed td{vertical-align:top;padding-left:.4em}div.rui-calendar .greed>tbody>tr>td:first-child{padding:0}div.rui-calendar .month{margin-top:.2em;border-spacing:1px;border-collapse:separate}div.rui-calendar .month caption{text-align:center}div.rui-calendar .month th{color:#666;text-align:center}div.rui-calendar .month td{text-align:right;padding:.1em .3em;background-color:#FFF;border:1px solid #CCC;cursor:pointer;color:#555;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-calendar .month td:hover{background-color:#CCC;border-color:#AAA;color:#000}div.rui-calendar .month td.blank{background:transparent;cursor:default;border:none}div.rui-calendar .month td.selected{background-color:#BBB;border-color:#AAA;color:#222;font-weight:bold;padding:.1em .2em}div.rui-calendar .month td.disabled{color:#888;background:#EEE;border-color:#CCC;cursor:default}div.rui-calendar .timepicker{border-top:1px solid #ccc;margin-top:.3em;padding-top:.5em;text-align:center}div.rui-calendar .timepicker select{margin:0 .4em}div.rui-calendar .buttons{position:relative;margin-top:.5em}div.rui-calendar .buttons div.rui-button{width:4em;padding:.25em .5em}div.rui-calendar .buttons .done{position:absolute;right:0em;top:0}");E.type="text/css",a.getElementsByTagName("head")[0].appendChild(E),E.styleSheet?E.styleSheet.cssText=F.nodeValue:E.appendChild(F);return y}(document,parseInt,RightJS)
|
7
|
+
var Calendar=RightJS.Calendar=function(a,b,c){function j(a){return(a<10?"0":"")+a}function h(a,d,e){var f=this.reAnchor||(this.reAnchor=new c.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=b(a.getStyle("borderTopWidth")),k=b(a.getStyle("borderLeftWidth")),l=b(a.getStyle("borderRightWidth")),m=b(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),d==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(d==="left"||d==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function g(a,b,d,e){c.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:c(a.fire).bind(a,b)},b==="hide"&&(e.duration=(c.Fx.Durations[e.duration]||e.duration)/2)))),(!c.Fx||!d)&&a.fire(b);return a.$super(d,e)}function d(a,b){b||(b=a,a="DIV");var d=new c.Class(c.Element.Wrappers[a]||c.Element,{initialize:function(b,d){this.key=b;var e=[{"class":"rui-"+b}];this instanceof c.Input||this instanceof c.Form||e.unshift(a),this.$super.apply(this,e),c.isString(d)&&(d=c.$(d)),d instanceof c.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return c.Wrapper.Cache[c.$uid(this._)]=this},setOptions:function(a,b){b&&(a=c.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&c.Options.setOptions.call(this,c.Object.merge(this.options,a));return this}}),e=new c.Class(d,b);c.Observer.createShortcuts(e.prototype,e.EVENTS||c([]));return e}var e=new c.Class(c.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),f={show:function(a,b){this.constructor.current=this;return g(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return g(this,"show",a,b)},showAt:function(a,b,d){this.hide(null).shownAt=a=c.$(a),h.call(this,a,b,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},i={assignTo:function(a,b){a=c.$(a),b=c.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var d=c(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:d,change:d}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=c,l=c.$,m=c.$$,n=c.$w,o=c.$ext,p=c.$uid,q=c.isString,r=c.isArray,s=c.isFunction,t=c.Class,u=c.Element,v=c.Input,w=c.RegExp,x=c.Browser,y=new d({include:[f,i],extend:{version:"2.2.0",EVENTS:n("show hide change done"),Options:{format:"ISO",showTime:null,showButtons:!1,minDate:!1,maxDate:!1,fxName:"fade",fxDuration:"short",firstDay:1,numberOfMonths:1,timePeriod:1,twentyFourHour:null,listYears:!1,hideOnPick:!1,update:null,trigger:null,cssRule:"*[data-calendar]"},Formats:{ISO:"%Y-%m-%d",POSIX:"%Y/%m/%d",EUR:"%d-%m-%Y",US:"%m/%d/%Y"},i18n:{Done:"Done",Now:"Now",NextMonth:"Next Month",PrevMonth:"Previous Month",NextYear:"Next Year",PrevYear:"Previous Year",dayNames:n("Sunday Monday Tuesday Wednesday Thursday Friday Saturday"),dayNamesShort:n("Sun Mon Tue Wed Thu Fri Sat"),dayNamesMin:n("Su Mo Tu We Th Fr Sa"),monthNames:n("January February March April May June July August September October November December"),monthNamesShort:n("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")},current:null,hideAll:function(a){m("div.rui-calendar").each(function(b){b instanceof y&&b!==a&&b.visible()&&!b.inlined()&&b.hide()})}},initialize:function(a){this.$super("calendar",a),this.addClass("rui-panel"),a=this.options,this.insert([this.swaps=new z(a),this.greed=new B(a)]),a.showTime&&this.insert(this.timepicker=new C(a)),a.showButtons&&this.insert(this.buttons=new D(a)),this.setDate(new Date).initEvents()},setDate:function(a,b){if(a=this.parse(a)){var c=this.options;c.minDate&&c.minDate>a&&(a=new Date(c.minDate)),c.maxDate&&c.maxDate<a&&(a=new Date(c.maxDate),a.setDate(a.getDate()-1)),this._date=b?new Date(this._date||this.date):null,this.greed.setDate(this._date||a,a),(c.minDate||c.maxDate)&&this.swaps.setDate(a),this.timepicker&&!b&&this.timepicker.setDate(a),a!=this.date&&this.fire("change",{date:this.date=a})}return this},getDate:function(){return this.date},setValue:function(a){return this.setDate(a)},getValue:function(a){return this.format(a)},insertTo:function(a,b){this.addClass("rui-calendar-inline");return this.$super(a,b)},done:function(){this.inlined()||this.hide(),this.fire("done",{date:this.date})},inlined:function(){return this.hasClass("rui-calendar-inline")},setOptions:function(a){a=a||{},this.$super(a,l(a.trigger||a.update));var b=this.constructor,c=this.options;c.i18n={};for(var d in b.i18n)c.i18n[d]=r(b.i18n[d])?b.i18n[d].clone():b.i18n[d];o(c.i18n,a.i18n),c.dayNames=c.i18n.dayNamesMin,c.firstDay&&c.dayNames.push(c.dayNames.shift()),r(c.numberOfMonths)||(c.numberOfMonths=[c.numberOfMonths,1]),c.minDate&&(c.minDate=this.parse(c.minDate)),c.maxDate&&(c.maxDate=this.parse(c.maxDate),c.maxDate.setDate(c.maxDate.getDate()+1)),c.format=k(b.Formats[c.format]||c.format).trim(),c.showTime===null&&(c.showTime=c.format.search(/%[HkIl]/)>-1),c.twentyFourHour===null&&(c.twentyFourHour=c.format.search(/%[Il]/)<0),c.timePeriod>60&&12%Math.ceil(c.timePeriod/60)&&(c.twentyFourHour=!0),c.update&&this.assignTo(c.update,c.trigger);return this},hideOthers:function(){y.hideAll(this);return this}}),z=new t(u,{initialize:function(a){this.$super("div",{"class":"swaps"}),this.options=a;var b=a.i18n;this.insert([this.prevMonth=new e("‹",{title:b.PrevMonth,"class":"prev-month"}),this.nextMonth=new e("›",{title:b.NextMonth,"class":"next-month"})]),a.listYears&&this.insert([this.prevYear=new e("«",{title:b.PrevYear,"class":"prev-year"}),this.nextYear=new e("»",{title:b.NextYear,"class":"next-year"})]),this.buttons=k([this.prevMonth,this.nextMonth,this.prevYear,this.nextYear]).compact(),this.onClick(this.clicked)},setDate:function(a){var b=this.options,c=b.numberOfMonths[0]*b.numberOfMonths[1],d=!0,e=!0,f=!0,g=!0;if(b.minDate){var h=new Date(a.getFullYear(),0,1,0,0,0),i=new Date(b.minDate.getFullYear(),0,1,0,0,0);d=h>i,h.setMonth(a.getMonth()-Math.ceil(c-c/2)),i.setMonth(b.minDate.getMonth()),f=h>=i}if(b.maxDate){var j=new Date(a),l=new Date(b.maxDate),m=k([j,l]);m.each(function(a){a.setDate(32),a.setMonth(a.getMonth()-1),a.setDate(32-a.getDate()),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0)}),g=j<l,m.each("setMonth",0),e=j<l}this.nextMonth[g?"enable":"disable"](),this.prevMonth[f?"enable":"disable"](),this.nextYear&&(this.nextYear[e?"enable":"disable"](),this.prevYear[d?"enable":"disable"]())},clicked:function(a){var b=a.target;b&&this.buttons.include(b)&&(b.enabled()&&this.fire(b.get("className").split(/\s+/)[0]))}}),A=new t(u,{initialize:function(a){this.$super("table",{"class":"month"}),this.options=a,this.insert(this.caption=new u("caption")),this.insert("<thead><tr>"+a.dayNames.map(function(a){return"<th>"+a+"</th>"}).join("")+"</tr></thead>"),this.days=[];var b=(new u("tbody")).insertTo(this),c,d,e;for(d=0;d<6;d++){e=(new u("tr")).insertTo(b);for(c=0;c<7;c++)this.days.push((new u("td")).insertTo(e))}this.onClick(this.clicked)},setDate:function(b,c){b.setDate(32);var d=32-b.getDate();b.setMonth(b.getMonth()-1);var e=Math.ceil(c.getTime()/864e5),f=this.options,g=f.i18n,h=this.days;for(var i=0,j=h.length-1,k,l,m;i<7;i++)k=h[i]._,l=h[j-i]._,m=h[j-i-7]._,k.innerHTML=l.innerHTML=m.innerHTML="",k.className=l.className=m.className="blank";for(var i=1,n=0,o,p;i<=d;i++){b.setDate(i);var q=b.getDay();f.firstDay===1&&(q=q>0?q-1:6);if(i===1||q===0)o=h.slice(n*7,n*7+7),n++;p=o[q]._,x.OLD?(p.innerHTML="",p.appendChild(a.createTextNode(i))):p.innerHTML=""+i,p.className=e===Math.ceil(b.getTime()/864e5)?"selected":"";if(f.minDate&&f.minDate>b||f.maxDate&&f.maxDate<b)p.className="disabled";o[q].date=new Date(b)}var r=(f.listYears?g.monthNamesShort[b.getMonth()]+",":g.monthNames[b.getMonth()])+" "+b.getFullYear(),s=this.caption._;x.OLD?(s.innerHTML="",s.appendChild(a.createTextNode(r))):s.innerHTML=r},clicked:function(a){var b=a.target,c=b.date;b&&c&&!b.hasClass("disabled")&&!b.hasClass("blank")&&(b.addClass("selected"),this.fire("date-set",{date:c.getDate(),month:c.getMonth(),year:c.getFullYear()}))}}),B=new t(u,{initialize:function(a){this.$super("table",{"class":"greed"}),this.months=[];var b=(new u("tbody")).insertTo(this),c;for(var d=0;d<a.numberOfMonths[1];d++){var e=(new u("tr")).insertTo(b);for(var f=0;f<a.numberOfMonths[0];f++)this.months.push(c=new A(a)),(new u("td")).insertTo(e).insert(c)}},setDate:function(a,b){var c=this.months,d=c.length;b=b||a;for(var e=-Math.ceil(d-d/2)+1,f=0;e<Math.floor(d-d/2)+1;e++,f++){var g=new Date(a);g.setMonth(a.getMonth()+e),c[f].setDate(g,b)}}}),C=new t(u,{initialize:function(a){this.$super("div",{"class":"timepicker"}),this.options=a;var b=k(this.timeChanged).bind(this);this.insert([this.hours=(new u("select")).onChange(b),this.minutes=(new u("select")).onChange(b)]);var c=a.timePeriod<60?a.timePeriod:60,d=a.timePeriod<60?1:Math.ceil(a.timePeriod/60);for(var e=0;e<60;e++){var f=j(e);e<24&&e%d==0&&(a.twentyFourHour?this.hours.insert(new u("option",{value:e,html:f})):e<12&&this.hours.insert(new u("option",{value:e,html:e==0?12:e}))),e%c==0&&this.minutes.insert(new u("option",{value:e,html:f}))}a.twentyFourHour||(this.meridian=(new u("select")).onChange(b).insertTo(this),k(k(a.format).includes(/%P/)?["am","pm"]:["AM","PM"]).each(function(a){this.meridian.insert(new u("option",{value:a.toLowerCase(),html:a}))},this))},setDate:function(a){var b=this.options,c=b.timePeriod<60?a.getHours():Math.round(a.getHours()/(b.timePeriod/60))*(b.timePeriod/60),d=Math.round(a.getMinutes()/(b.timePeriod%60))*b.timePeriod;this.meridian&&(this.meridian.setValue(c<12?"am":"pm"),c=c==0||c==12?12:c>12?c-12:c),this.hours.setValue(c),this.minutes.setValue(d)},timeChanged:function(a){a.stopPropagation();var c=b(this.hours.value()),d=b(this.minutes.value());this.meridian&&(c==12&&(c=0),this.meridian.value()=="pm"&&(c+=12)),this.fire("time-set",{hours:c,minutes:d})}}),D=new t(u,{initialize:function(a){this.$super("div",{"class":"buttons"}),this.insert([(new e(a.i18n.Now,{"class":"now"})).onClick("fire","now-clicked"),(new e(a.i18n.Done,{"class":"done"})).onClick("fire","done-clicked")])}});y.include({parse:function(a){var c;if(q(a)&&a){var d=w.escape(this.options.format),e=k(d.match(/%[a-z]/ig)).map("match",/[a-z]$/i).map("first").without("%"),f=new w("^"+d.replace(/%p/i,"(pm|PM|am|AM)").replace(/(%[a-z])/ig,"(.+?)")+"$"),g=k(a).trim().match(f);if(g){g.shift();var h=null,i=null,j=null,l=null,m=null,n;while(g.length){var o=g.shift(),p=e.shift();if(p.toLowerCase()=="b")i=this.options.i18n[p=="b"?"monthNamesShort":"monthNames"].indexOf(o);else if(p.toLowerCase()=="p")n=o.toLowerCase();else{o=b(o,10);switch(p){case"d":case"e":c=o;break;case"m":i=o-1;break;case"y":case"Y":h=o;break;case"H":case"k":case"I":case"l":j=o;break;case"M":l=o;break;case"S":m=o}}}n&&(j=j==12?0:j,j=n=="pm"?j+12:j),c=new Date(h,i,c,j,l,m)}}else if(a instanceof Date||Date.parse(a))c=new Date(a);return!c||isNaN(c.getTime())?null:c},format:function(a){var b=this.options.i18n,c=this.date.getDay(),d=this.date.getMonth(),e=this.date.getDate(),f=this.date.getFullYear(),g=this.date.getHours(),h=this.date.getMinutes(),i=this.date.getSeconds(),k=g==0?12:g<13?g:g-12,l={a:b.dayNamesShort[c],A:b.dayNames[c],b:b.monthNamesShort[d],B:b.monthNames[d],d:j(e),e:""+e,m:(d<9?"0":"")+(d+1),y:(""+f).substring(2,4),Y:""+f,H:j(g),k:""+g,I:(g>0&&(g<10||g>12&&g<22)?"0":"")+k,l:""+k,p:g<12?"AM":"PM",P:g<12?"am":"pm",M:j(h),S:j(i),"%":"%"},m=a||this.options.format;for(var n in l)m=m.replace("%"+n,l[n]);return m}}),y.include({initEvents:function(){var a="_shiftDate",b=this._terminate;this.on({"prev-day":[a,{Date:-1}],"next-day":[a,{Date:1}],"prev-week":[a,{Date:-7}],"next-week":[a,{Date:7}],"prev-month":[a,{Month:-1}],"next-month":[a,{Month:1}],"prev-year":[a,{FullYear:-1}],"next-year":[a,{FullYear:1}],"date-set":this._changeDate,"time-set":this._changeTime,"now-clicked":this._setNow,"done-clicked":this.done,click:b,mousedown:b,focus:b,blur:b})},_shiftDate:function(a){var b=new Date(this.date),c=this.options;for(var d in a)b["set"+d](b["get"+d]()+a[d]);this.setDate(b)},_changeDate:function(a){var b=new Date(this.date);b.setDate(a.date),b.setMonth(a.month),b.setFullYear(a.year),this.setDate(b,!0),this.options.hideOnPick&&this.done()},_changeTime:function(a){var b=new Date(this.date);b.setHours(a.hours),b.setMinutes(a.minutes),this.setDate(b)},_setNow:function(){this.setDate(new Date)},_terminate:function(a){a.stopPropagation(),this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}}),l(a).on({focus:function(a){var b=a.target instanceof v&&a.target.get("type")=="text"?a.target:null;y.hideAll(),b&&(b.calendar||b.match(y.Options.cssRule))&&(b.calendar||new y({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.calendar;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof u?a.target:null;if(b&&(b.calendar||b.match(y.Options.cssRule))){if(!(b instanceof v)||b.get("type")!="text")a.stop(),(b.calendar||new y({trigger:b})).hide(null).toggleAt(b.assignedInput)}else a.find("div.rui-calendar")||y.hideAll()},keydown:function(a){var b=y.current,c=({27:"hide",37:"prev-day",39:"next-day",38:"prev-week",40:"next-week",33:"prev-month",34:"next-month",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),s(b[c])?b[c]():b.fire(c))}});var E=a.createElement("style"),F=a.createTextNode(".rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default} *.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}div.rui-calendar .swaps,div.rui-calendar .greed,div.rui-calendar .timepicker,div.rui-calendar .buttons,div.rui-calendar table,div.rui-calendar table tr,div.rui-calendar table th,div.rui-calendar table td,div.rui-calendar table tbody,div.rui-calendar table thead,div.rui-calendar table caption{background:none;border:none;width:auto;height:auto;margin:0;padding:0}div.rui-calendar-inline{position:relative;display:inline-block; *display:inline; *zoom:1;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-calendar .swaps{position:relative}div.rui-calendar .swaps .rui-button{position:absolute;float:left;width:1em;padding:.15em .4em}div.rui-calendar .swaps .next-month{right:0em;_right:.5em}div.rui-calendar .swaps .prev-year{left:2.05em}div.rui-calendar .swaps .next-year{right:2.05em;_right:2.52em}div.rui-calendar .greed{border-spacing:0px;border-collapse:collapse;border-size:0}div.rui-calendar .greed td{vertical-align:top;padding-left:.4em}div.rui-calendar .greed>tbody>tr>td:first-child{padding:0}div.rui-calendar .month{margin-top:.2em;border-spacing:1px;border-collapse:separate}div.rui-calendar .month caption{text-align:center}div.rui-calendar .month th{color:#666;text-align:center}div.rui-calendar .month td{text-align:right;padding:.1em .3em;background-color:#FFF;border:1px solid #CCC;cursor:pointer;color:#555;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-calendar .month td:hover{background-color:#CCC;border-color:#AAA;color:#000}div.rui-calendar .month td.blank{background:transparent;cursor:default;border:none}div.rui-calendar .month td.selected{background-color:#BBB;border-color:#AAA;color:#222;font-weight:bold;padding:.1em .2em}div.rui-calendar .month td.disabled{color:#888;background:#EEE;border-color:#CCC;cursor:default}div.rui-calendar .timepicker{border-top:1px solid #ccc;margin-top:.3em;padding-top:.5em;text-align:center}div.rui-calendar .timepicker select{margin:0 .4em}div.rui-calendar .buttons{position:relative;margin-top:.5em}div.rui-calendar .buttons div.rui-button{width:4em;padding:.25em .5em}div.rui-calendar .buttons .done{position:absolute;right:0em;top:0}");E.type="text/css",a.getElementsByTagName("head")[0].appendChild(E),E.styleSheet?E.styleSheet.cssText=F.nodeValue:E.appendChild(F);return y}(document,parseInt,RightJS)
|