right-rails 1.0.3 → 1.0.5
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/CHANGELOG +8 -2
- data/Rakefile +28 -28
- data/lib/right_rails/java_script_generator.rb +59 -51
- data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
- data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
- data/public/javascripts/right-olds-src.js +47 -46
- data/public/javascripts/right-safe-src.js +103 -102
- data/public/javascripts/right-safe.js +1 -1
- data/public/javascripts/right-src.js +611 -541
- data/public/javascripts/right.js +86 -85
- data/public/javascripts/right/autocompleter-src.js +81 -77
- data/public/javascripts/right/autocompleter.js +1 -1
- data/public/javascripts/right/calendar-src.js +209 -197
- data/public/javascripts/right/calendar.js +6 -6
- data/public/javascripts/right/colorpicker-src.js +127 -117
- data/public/javascripts/right/colorpicker.js +6 -6
- data/public/javascripts/right/dnd-src.js +63 -63
- data/public/javascripts/right/dnd.js +2 -2
- data/public/javascripts/right/in-edit-src.js +53 -48
- data/public/javascripts/right/in-edit.js +2 -2
- data/public/javascripts/right/lightbox-src.js +107 -99
- data/public/javascripts/right/lightbox.js +2 -2
- data/public/javascripts/right/rater-src.js +48 -46
- data/public/javascripts/right/rater.js +3 -3
- data/public/javascripts/right/resizable-src.js +53 -61
- data/public/javascripts/right/resizable.js +4 -4
- data/public/javascripts/right/selectable-src.js +97 -95
- data/public/javascripts/right/selectable.js +2 -2
- data/public/javascripts/right/slider-src.js +47 -45
- data/public/javascripts/right/slider.js +8 -8
- data/public/javascripts/right/sortable-src.js +54 -52
- data/public/javascripts/right/tabs-src.js +181 -171
- data/public/javascripts/right/tooltip-src.js +39 -37
- data/public/javascripts/right/uploader-src.js +21 -19
- data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
- metadata +9 -7
@@ -10,7 +10,7 @@ u=c.isArray,p=new c.Wrapper(c.Element,{initialize:function(a){this.$super("div",
|
|
10
10
|
e;var h=[{"class":"rui-"+e}];this instanceof c.Input||this instanceof c.Form||h.unshift(a);this.$super.apply(this,h);if(c.isString(f))f=c.$(f);if(f instanceof c.Element){this._=f._;if("$listeners"in f)f.$listeners=f.$listeners;f={}}this.setOptions(f,this);return this},setOptions:function(e,f){f=f||this;c.Options.setOptions.call(this,c.Object.merge(e,eval("("+(f.get("data-"+this.key)||"{}")+")")));return this}});d=new c.Wrapper(d,b);c.Observer.createShortcuts(d.prototype,d.EVENTS||[]);return d})("UL",
|
11
11
|
{include:{show:function(a,b){this.constructor.current=this;return l.call(this,this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return l.call(this,this,"hide",a,b)},showAt:function(a,b,d){this.hide(null).shownAt=a=c.$(a);m.call(this,a,b,d);return this.show()},toggleAt:function(a,b,d){return this.hidden()?this.showAt(a,b,d):this.hide()}},extend:{version:"2.0.0",EVENTS:s("show hide update load select done"),Options:{url:j.location.href,param:"search",method:"get",minLength:1,threshold:200,
|
12
12
|
cache:true,local:null,fxName:"slide",fxDuration:"short",spinner:"native",cssRule:"input[data-autocompleter]"}},initialize:function(a,b){this.input=n(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){if(a=a||this.first("li.current")){this.input.setValue(g(a.html()).stripTags());
|
13
|
-
this.fire("done")}return this.hide()},setOptions:function(a){this.$super(a,this.input);a=this.options;g(a.url).includes("%{search}")||(a.url+=(g(a.url).includes("?")?"&":"?")+a.param+"=%{search}")},pick:function(a){var b=this.children(),d=b.first("hasClass","current"),e=b.indexOf(d);if(a=="prev")d=e<1?b.last():b[e<0?0:e-1];else if(a=="next")d=e<0||e==b.length-1?b.first():b[e+1];return this.fire("select",d.radioClass("current"))},clicked:function(a){this.done(a.stop().find("li"))},keypressed:function(){if(this.input.value().length>=
|
13
|
+
this.fire("done")}return this.hide()},setOptions:function(a){this.$super(a,this.input);a=this.options;g(a.url).includes("%{search}")||(a.url+=(g(a.url).includes("?")?"&":"?")+a.param+"=%{search}")},pick:function(a){var b=this.children(),d=b.first("hasClass","current"),e=b.indexOf(d);if(a=="prev")d=e<1?b.last():b[e<0?0:e-1];else if(a=="next")d=e<0||e==b.length-1?b.first():b[e+1];return this.fire("select",{item:d.radioClass("current")})},clicked:function(a){this.done(a.stop().find("li"))},keypressed:function(){if(this.input.value().length>=
|
14
14
|
this.options.minLength){this.timeout&&this.timeout.cancel();this.timeout=g(this.trigger).bind(this).delay(this.options.threshold)}else return this.hide()},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();if(this.cache[a])this.suggest(this.cache[a],a);else if(u(b.local))this.suggest(this.findLocal(a),a);else this.request=t.load(b.url.replace("%{search}",encodeURIComponent(a)),{method:b.method,spinner:this.getSpinner(),
|
15
15
|
onComplete:g(function(d){this.fire("load").suggest(d.text,a)}).bind(this)})},suggest:function(a,b){if(this.options.cache)this.cache[b]=a;if(a.blank())this.hide();else{this.update(a.replace(/<ul[^>]*>|<\/ul>/im,""));this.fire("update").showAt(this.input,"bottom","resize")}return this},findLocal:function(a){var b=new o("("+o.escape(a)+")","ig");return g(this.options.local).map(function(d){if(d.match(b))return"<li>"+d.replace(b,"<strong>$1</strong>")+"</li>"}).compact().join("")},getSpinner:function(){var a=
|
16
16
|
this.options,b=a.spinner;if(b=="native"){b=a.spinner=(new p(3)).insertTo(this);b.addClass("rui-autocompleter-spinner")}b instanceof p&&m.call(b,this.input,"right","resize");return b}});n(j).on({focus:function(a){if((a=a.target)&&a instanceof c.Element&&(a.autocompleter||a.match(k.Options.cssRule)))a.autocompleter||new k(a)},blur:function(a){(a=a.target?a.target.autocompleter:null)&&a.visible()&&a.hide()},keydown:function(a){var b=a.target?a.target.autocompleter:null;if(b&&b.visible()){var d={27:"hide",
|
@@ -49,13 +49,13 @@ var R = RightJS,
|
|
49
49
|
* @param String tag-name or Object methods
|
50
50
|
* @param Object methods
|
51
51
|
* @return Widget wrapper
|
52
|
-
*/
|
52
|
+
*/
|
53
53
|
function Widget(tag_name, methods) {
|
54
54
|
if (!methods) {
|
55
55
|
methods = tag_name;
|
56
56
|
tag_name = 'DIV';
|
57
57
|
}
|
58
|
-
|
58
|
+
|
59
59
|
/**
|
60
60
|
* An Abstract Widget Unit
|
61
61
|
*
|
@@ -72,17 +72,17 @@ function Widget(tag_name, methods) {
|
|
72
72
|
initialize: function(key, options) {
|
73
73
|
this.key = key;
|
74
74
|
var args = [{'class': 'rui-' + key}];
|
75
|
-
|
75
|
+
|
76
76
|
// those two have different constructors
|
77
77
|
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
78
78
|
args.unshift(tag_name);
|
79
79
|
}
|
80
80
|
this.$super.apply(this, args);
|
81
|
-
|
81
|
+
|
82
82
|
if (RightJS.isString(options)) {
|
83
83
|
options = RightJS.$(options);
|
84
84
|
}
|
85
|
-
|
85
|
+
|
86
86
|
// if the options is another element then
|
87
87
|
// try to dynamically rewrap it with our widget
|
88
88
|
if (options instanceof RightJS.Element) {
|
@@ -115,16 +115,16 @@ function Widget(tag_name, methods) {
|
|
115
115
|
return this;
|
116
116
|
}
|
117
117
|
});
|
118
|
-
|
118
|
+
|
119
119
|
/**
|
120
120
|
* Creating the actual widget class
|
121
121
|
*
|
122
122
|
*/
|
123
123
|
var Klass = new RightJS.Wrapper(AbstractWidget, methods);
|
124
|
-
|
124
|
+
|
125
125
|
// creating the widget related shortcuts
|
126
126
|
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
127
|
-
|
127
|
+
|
128
128
|
return Klass;
|
129
129
|
}
|
130
130
|
|
@@ -150,7 +150,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
150
150
|
this._.innerHTML = caption;
|
151
151
|
this.addClass('rui-button');
|
152
152
|
},
|
153
|
-
|
153
|
+
|
154
154
|
/**
|
155
155
|
* Disasbles the button
|
156
156
|
*
|
@@ -159,7 +159,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
159
159
|
disable: function() {
|
160
160
|
return this.addClass('rui-button-disabled');
|
161
161
|
},
|
162
|
-
|
162
|
+
|
163
163
|
/**
|
164
164
|
* Enables the button
|
165
165
|
*
|
@@ -168,7 +168,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
168
168
|
enable: function() {
|
169
169
|
return this.removeClass('rui-button-disabled');
|
170
170
|
},
|
171
|
-
|
171
|
+
|
172
172
|
/**
|
173
173
|
* Checks if the button is disabled
|
174
174
|
*
|
@@ -177,7 +177,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
177
177
|
disabled: function() {
|
178
178
|
return this.hasClass('rui-button-disabled');
|
179
179
|
},
|
180
|
-
|
180
|
+
|
181
181
|
/**
|
182
182
|
* Checks if the button is enabled
|
183
183
|
*
|
@@ -186,7 +186,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
186
186
|
enabled: function() {
|
187
187
|
return !this.disabled();
|
188
188
|
},
|
189
|
-
|
189
|
+
|
190
190
|
/**
|
191
191
|
* Overloading the method, so it fired the events
|
192
192
|
* only when the button is active
|
@@ -201,6 +201,7 @@ var Button = new RightJS.Wrapper(RightJS.Element, {
|
|
201
201
|
}
|
202
202
|
});
|
203
203
|
|
204
|
+
|
204
205
|
/**
|
205
206
|
* A shared module that toggles a widget visibility status
|
206
207
|
* in a uniformed way according to the options settings
|
@@ -224,7 +225,7 @@ function toggler(element, event, fx_name, fx_options) {
|
|
224
225
|
if (RightJS.Fx) {
|
225
226
|
if (fx_name === undefined) {
|
226
227
|
fx_name = this.options.fxName;
|
227
|
-
|
228
|
+
|
228
229
|
if (fx_options === undefined) {
|
229
230
|
fx_options = {
|
230
231
|
duration: this.options.fxDuration,
|
@@ -239,12 +240,12 @@ function toggler(element, event, fx_name, fx_options) {
|
|
239
240
|
}
|
240
241
|
}
|
241
242
|
}
|
242
|
-
|
243
|
+
|
243
244
|
RightJS.Element.prototype[event].call(element, fx_name, fx_options);
|
244
|
-
|
245
|
+
|
245
246
|
// manually trigger the event if no fx were specified
|
246
247
|
if (!RightJS.Fx || !fx_name) { this.fire(event); }
|
247
|
-
|
248
|
+
|
248
249
|
return this;
|
249
250
|
}
|
250
251
|
|
@@ -261,34 +262,34 @@ function toggler(element, event, fx_name, fx_options) {
|
|
261
262
|
* @return void
|
262
263
|
*/
|
263
264
|
function re_position(element, where, resize) {
|
264
|
-
var anchor = this.reAnchor || (this.reAnchor =
|
265
|
+
var anchor = this.reAnchor || (this.reAnchor =
|
265
266
|
new RightJS.Element('div', {'class': 'rui-re-anchor'}))
|
266
267
|
.insert(this),
|
267
|
-
|
268
|
+
|
268
269
|
pos = anchor.insertTo(element, 'after').position(),
|
269
270
|
dims = element.dimensions(), target = this,
|
270
|
-
|
271
|
+
|
271
272
|
border_top = parseInt(element.getStyle('borderTopWidth')),
|
272
273
|
border_left = parseInt(element.getStyle('borderLeftWidth')),
|
273
274
|
border_right = parseInt(element.getStyle('borderRightWidth')),
|
274
275
|
border_bottom = parseInt(element.getStyle('borderBottomWidth')),
|
275
|
-
|
276
|
+
|
276
277
|
top = dims.top - pos.y + border_top,
|
277
278
|
left = dims.left - pos.x + border_left,
|
278
279
|
width = dims.width - border_left - border_right,
|
279
280
|
height = dims.height - border_top - border_bottom;
|
280
|
-
|
281
|
+
|
281
282
|
// making the element to appear so we could read it's sizes
|
282
283
|
target.setStyle('visibility:hidden').show(null);
|
283
|
-
|
284
|
+
|
284
285
|
if (where === 'right') {
|
285
286
|
left += width - target.size().x;
|
286
287
|
} else { // bottom
|
287
288
|
top += height;
|
288
289
|
}
|
289
|
-
|
290
|
+
|
290
291
|
target.moveTo(left, top);
|
291
|
-
|
292
|
+
|
292
293
|
if (resize) {
|
293
294
|
if (['left', 'right'].include(where)) {
|
294
295
|
target.setHeight(height);
|
@@ -296,7 +297,7 @@ function re_position(element, where, resize) {
|
|
296
297
|
target.setWidth(width);
|
297
298
|
}
|
298
299
|
}
|
299
|
-
|
300
|
+
|
300
301
|
// rolling the invisibility back
|
301
302
|
target.setStyle('visibility:visible').hide(null);
|
302
303
|
}
|
@@ -318,7 +319,7 @@ var Toggler = {
|
|
318
319
|
this.constructor.current = this;
|
319
320
|
return toggler.call(this, this, 'show', fx_name, fx_options);
|
320
321
|
},
|
321
|
-
|
322
|
+
|
322
323
|
/**
|
323
324
|
* Hides the element
|
324
325
|
*
|
@@ -330,7 +331,7 @@ var Toggler = {
|
|
330
331
|
this.constructor.current = null;
|
331
332
|
return toggler.call(this, this, 'hide', fx_name, fx_options);
|
332
333
|
},
|
333
|
-
|
334
|
+
|
334
335
|
/**
|
335
336
|
* Toggles the widget at the given element
|
336
337
|
*
|
@@ -341,13 +342,13 @@ var Toggler = {
|
|
341
342
|
*/
|
342
343
|
showAt: function(element, where, resize) {
|
343
344
|
this.hide(null).shownAt = element = RightJS.$(element);
|
344
|
-
|
345
|
+
|
345
346
|
// moves this element at the given one
|
346
347
|
re_position.call(this, element, where, resize);
|
347
|
-
|
348
|
+
|
348
349
|
return this.show();
|
349
350
|
},
|
350
|
-
|
351
|
+
|
351
352
|
/**
|
352
353
|
* Toggles the widget at the given element
|
353
354
|
*
|
@@ -361,6 +362,7 @@ var Toggler = {
|
|
361
362
|
}
|
362
363
|
};
|
363
364
|
|
365
|
+
|
364
366
|
/**
|
365
367
|
* A shared module that provides for the widgets an ability
|
366
368
|
* to be assigned to an input element and work in pair with it
|
@@ -385,35 +387,36 @@ var Assignable = {
|
|
385
387
|
assignTo: function(input, trigger) {
|
386
388
|
input = RightJS.$(input);
|
387
389
|
trigger = RightJS.$(trigger);
|
388
|
-
|
390
|
+
|
389
391
|
if (trigger) {
|
390
392
|
trigger[this.key] = this;
|
391
393
|
trigger.assignedInput = input;
|
392
394
|
} else {
|
393
395
|
input[this.key] = this;
|
394
396
|
}
|
395
|
-
|
397
|
+
|
396
398
|
var on_change = RightJS(function() {
|
397
399
|
if (this.visible() && (!this.showAt || this.shownAt === input)) {
|
398
400
|
this.setValue(input.value());
|
399
401
|
}
|
400
402
|
}).bind(this);
|
401
|
-
|
403
|
+
|
402
404
|
input.on({
|
403
405
|
keyup: on_change,
|
404
406
|
change: on_change
|
405
407
|
});
|
406
|
-
|
408
|
+
|
407
409
|
this.onChange(function() {
|
408
410
|
if (!this.showAt || this.shownAt === input) {
|
409
411
|
input.setValue(this.getValue());
|
410
412
|
}
|
411
413
|
});
|
412
|
-
|
414
|
+
|
413
415
|
return this;
|
414
416
|
}
|
415
417
|
};
|
416
418
|
|
419
|
+
|
417
420
|
/**
|
418
421
|
* Converts a number into a string with leading zeros
|
419
422
|
*
|
@@ -424,6 +427,7 @@ function zerofy(number) {
|
|
424
427
|
return (number < 10 ? '0' : '') + number;
|
425
428
|
}
|
426
429
|
|
430
|
+
|
427
431
|
/**
|
428
432
|
* The calendar widget for RightJS
|
429
433
|
*
|
@@ -431,46 +435,46 @@ function zerofy(number) {
|
|
431
435
|
*/
|
432
436
|
var Calendar = new Widget({
|
433
437
|
include: [Toggler, Assignable],
|
434
|
-
|
438
|
+
|
435
439
|
extend: {
|
436
440
|
version: '2.0.0',
|
437
|
-
|
441
|
+
|
438
442
|
EVENTS: $w('show hide change done'),
|
439
|
-
|
443
|
+
|
440
444
|
Options: {
|
441
445
|
format: 'ISO', // a key out of the predefined formats or a format string
|
442
|
-
|
446
|
+
|
443
447
|
showTime: null, // null for automatic, or true|false to enforce
|
444
448
|
showButtons: false, // show the bottom buttons
|
445
|
-
|
449
|
+
|
446
450
|
minDate: false, // the minimal date available
|
447
451
|
maxDate: false, // the maximal date available
|
448
|
-
|
452
|
+
|
449
453
|
fxName: 'fade', // set to null if you don't wanna any fx
|
450
454
|
fxDuration: 'short', // the fx-duration
|
451
|
-
|
455
|
+
|
452
456
|
firstDay: 1, // 1 for Monday, 0 for Sunday
|
453
457
|
numberOfMonths: 1, // a number or [x, y] greed definition
|
454
458
|
timePeriod: 1, // the timepicker minimal periods (in minutes, might be bigger than 60)
|
455
|
-
|
459
|
+
|
456
460
|
twentyFourHour: null, // null for automatic, or true|false to enforce
|
457
461
|
listYears: false, // show/hide the years listing buttons
|
458
|
-
|
462
|
+
|
459
463
|
hideOnPick: false, // hides the popup when the user changes a day
|
460
|
-
|
464
|
+
|
461
465
|
update: null, // a reference to an input element to assign to
|
462
466
|
trigger: null, // a reference to a trigger element that would be paired too
|
463
|
-
|
467
|
+
|
464
468
|
cssRule: '*[data-calendar]' // css rule for calendar related elements
|
465
469
|
},
|
466
|
-
|
470
|
+
|
467
471
|
Formats: {
|
468
472
|
ISO: '%Y-%m-%d',
|
469
473
|
POSIX: '%Y/%m/%d',
|
470
474
|
EUR: '%d-%m-%Y',
|
471
475
|
US: '%m/%d/%Y'
|
472
476
|
},
|
473
|
-
|
477
|
+
|
474
478
|
i18n: {
|
475
479
|
Done: 'Done',
|
476
480
|
Now: 'Now',
|
@@ -478,16 +482,16 @@ var Calendar = new Widget({
|
|
478
482
|
PrevMonth: 'Previous Month',
|
479
483
|
NextYear: 'Next Year',
|
480
484
|
PrevYear: 'Previous Year',
|
481
|
-
|
485
|
+
|
482
486
|
dayNames: $w('Sunday Monday Tuesday Wednesday Thursday Friday Saturday'),
|
483
487
|
dayNamesShort: $w('Sun Mon Tue Wed Thu Fri Sat'),
|
484
488
|
dayNamesMin: $w('Su Mo Tu We Th Fr Sa'),
|
485
489
|
monthNames: $w('January February March April May June July August September October November December'),
|
486
490
|
monthNamesShort: $w('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')
|
487
491
|
},
|
488
|
-
|
492
|
+
|
489
493
|
current: null,
|
490
|
-
|
494
|
+
|
491
495
|
// hides all the popup calendars
|
492
496
|
hideAll: function(that_one) {
|
493
497
|
$$('div.rui-calendar').each(function(element) {
|
@@ -497,7 +501,7 @@ var Calendar = new Widget({
|
|
497
501
|
});
|
498
502
|
}
|
499
503
|
},
|
500
|
-
|
504
|
+
|
501
505
|
/**
|
502
506
|
* Basic constructor
|
503
507
|
*
|
@@ -506,25 +510,25 @@ var Calendar = new Widget({
|
|
506
510
|
initialize: function(options) {
|
507
511
|
this.$super('calendar', options);
|
508
512
|
this.addClass('rui-panel');
|
509
|
-
|
513
|
+
|
510
514
|
options = this.options;
|
511
|
-
|
515
|
+
|
512
516
|
this.insert([
|
513
517
|
this.swaps = new Swaps(options),
|
514
518
|
this.greed = new Greed(options)
|
515
519
|
]);
|
516
|
-
|
520
|
+
|
517
521
|
if (options.showTime) {
|
518
522
|
this.insert(this.timepicker = new Timepicker(options));
|
519
523
|
}
|
520
|
-
|
524
|
+
|
521
525
|
if (options.showButtons) {
|
522
526
|
this.insert(this.buttons = new Buttons(options));
|
523
527
|
}
|
524
|
-
|
528
|
+
|
525
529
|
this.setDate(new Date()).initEvents();
|
526
530
|
},
|
527
|
-
|
531
|
+
|
528
532
|
/**
|
529
533
|
* Sets the date on the calendar
|
530
534
|
*
|
@@ -563,13 +567,13 @@ var Calendar = new Widget({
|
|
563
567
|
}
|
564
568
|
|
565
569
|
if (date != this.date) {
|
566
|
-
this.fire('change', this.date = date);
|
570
|
+
this.fire('change', {date: this.date = date});
|
567
571
|
}
|
568
572
|
}
|
569
|
-
|
573
|
+
|
570
574
|
return this;
|
571
575
|
},
|
572
|
-
|
576
|
+
|
573
577
|
/**
|
574
578
|
* Returns the current date on the calendar
|
575
579
|
*
|
@@ -578,7 +582,7 @@ var Calendar = new Widget({
|
|
578
582
|
getDate: function() {
|
579
583
|
return this.date;
|
580
584
|
},
|
581
|
-
|
585
|
+
|
582
586
|
/**
|
583
587
|
* Sets the value as a string
|
584
588
|
*
|
@@ -588,7 +592,7 @@ var Calendar = new Widget({
|
|
588
592
|
setValue: function(value) {
|
589
593
|
return this.setDate(value);
|
590
594
|
},
|
591
|
-
|
595
|
+
|
592
596
|
/**
|
593
597
|
* Returns the value as a string
|
594
598
|
*
|
@@ -598,7 +602,7 @@ var Calendar = new Widget({
|
|
598
602
|
getValue: function(format) {
|
599
603
|
return this.format(format);
|
600
604
|
},
|
601
|
-
|
605
|
+
|
602
606
|
/**
|
603
607
|
* Inserts the calendar into the element making it inlined
|
604
608
|
*
|
@@ -610,7 +614,7 @@ var Calendar = new Widget({
|
|
610
614
|
this.addClass('rui-calendar-inline');
|
611
615
|
return this.$super(element, position);
|
612
616
|
},
|
613
|
-
|
617
|
+
|
614
618
|
/**
|
615
619
|
* Marks it done
|
616
620
|
*
|
@@ -620,10 +624,10 @@ var Calendar = new Widget({
|
|
620
624
|
if (!this.inlined()) {
|
621
625
|
this.hide();
|
622
626
|
}
|
623
|
-
|
624
|
-
this.fire('done', this.date);
|
627
|
+
|
628
|
+
this.fire('done', {date: this.date});
|
625
629
|
},
|
626
|
-
|
630
|
+
|
627
631
|
/**
|
628
632
|
* Checks if the calendar is inlined
|
629
633
|
*
|
@@ -632,9 +636,9 @@ var Calendar = new Widget({
|
|
632
636
|
inlined: function() {
|
633
637
|
return this.hasClass('rui-calendar-inline');
|
634
638
|
},
|
635
|
-
|
639
|
+
|
636
640
|
// protected
|
637
|
-
|
641
|
+
|
638
642
|
/**
|
639
643
|
* additional options processing
|
640
644
|
*
|
@@ -644,28 +648,28 @@ var Calendar = new Widget({
|
|
644
648
|
setOptions: function(user_options) {
|
645
649
|
user_options = user_options || {};
|
646
650
|
this.$super(user_options, $(user_options.trigger || user_options.update));
|
647
|
-
|
651
|
+
|
648
652
|
var klass = this.constructor, options = this.options;
|
649
|
-
|
653
|
+
|
650
654
|
// merging the i18n tables
|
651
655
|
options.i18n = {};
|
652
|
-
|
656
|
+
|
653
657
|
for (var key in klass.i18n) {
|
654
658
|
options.i18n[key] = isArray(klass.i18n[key]) ? klass.i18n[key].clone() : klass.i18n[key];
|
655
659
|
}
|
656
660
|
$ext(options.i18n, user_options.i18n);
|
657
|
-
|
661
|
+
|
658
662
|
// defining the current days sequence
|
659
663
|
options.dayNames = options.i18n.dayNamesMin;
|
660
664
|
if (options.firstDay) {
|
661
665
|
options.dayNames.push(options.dayNames.shift());
|
662
666
|
}
|
663
|
-
|
667
|
+
|
664
668
|
// the monthes table cleaning up
|
665
669
|
if (!isArray(options.numberOfMonths)) {
|
666
670
|
options.numberOfMonths = [options.numberOfMonths, 1];
|
667
671
|
}
|
668
|
-
|
672
|
+
|
669
673
|
// min/max dates preprocessing
|
670
674
|
if (options.minDate) {
|
671
675
|
options.minDate = this.parse(options.minDate);
|
@@ -674,32 +678,32 @@ var Calendar = new Widget({
|
|
674
678
|
options.maxDate = this.parse(options.maxDate);
|
675
679
|
options.maxDate.setDate(options.maxDate.getDate() + 1);
|
676
680
|
}
|
677
|
-
|
681
|
+
|
678
682
|
// format catching up
|
679
683
|
options.format = R(klass.Formats[options.format] || options.format).trim();
|
680
|
-
|
684
|
+
|
681
685
|
// setting up the showTime option
|
682
686
|
if (options.showTime === null) {
|
683
687
|
options.showTime = options.format.search(/%[HkIl]/) > -1;
|
684
688
|
}
|
685
|
-
|
689
|
+
|
686
690
|
// setting up the 24-hours format
|
687
691
|
if (options.twentyFourHour === null) {
|
688
692
|
options.twentyFourHour = options.format.search(/%[Il]/) < 0;
|
689
693
|
}
|
690
|
-
|
694
|
+
|
691
695
|
// enforcing the 24 hours format if the time threshold is some weird number
|
692
696
|
if (options.timePeriod > 60 && 12 % Math.ceil(options.timePeriod/60)) {
|
693
697
|
options.twentyFourHour = true;
|
694
698
|
}
|
695
|
-
|
699
|
+
|
696
700
|
if (options.update) {
|
697
701
|
this.assignTo(options.update, options.trigger);
|
698
702
|
}
|
699
703
|
|
700
704
|
return this;
|
701
705
|
},
|
702
|
-
|
706
|
+
|
703
707
|
/**
|
704
708
|
* hides all the other calendars on the page
|
705
709
|
*
|
@@ -727,26 +731,26 @@ var Swaps = new Wrapper(Element, {
|
|
727
731
|
initialize: function(options) {
|
728
732
|
this.$super('div', {'class': 'swaps'});
|
729
733
|
this.options = options;
|
730
|
-
|
734
|
+
|
731
735
|
var i18n = options.i18n;
|
732
|
-
|
736
|
+
|
733
737
|
this.insert([
|
734
738
|
this.prevMonth = new Button('‹', {title: i18n.PrevMonth, 'class': 'prev-month'}),
|
735
739
|
this.nextMonth = new Button('›', {title: i18n.NextMonth, 'class': 'next-month'})
|
736
740
|
]);
|
737
|
-
|
741
|
+
|
738
742
|
if (options.listYears) {
|
739
743
|
this.insert([
|
740
744
|
this.prevYear = new Button('«', {title: i18n.PrevYear, 'class': 'prev-year'}),
|
741
745
|
this.nextYear = new Button('»', {title: i18n.NextYear, 'class': 'next-year'})
|
742
746
|
]);
|
743
747
|
}
|
744
|
-
|
748
|
+
|
745
749
|
this.buttons = R([this.prevMonth, this.nextMonth, this.prevYear, this.nextYear]).compact();
|
746
|
-
|
750
|
+
|
747
751
|
this.onClick(this.clicked);
|
748
752
|
},
|
749
|
-
|
753
|
+
|
750
754
|
/**
|
751
755
|
* Changes the swapping buttons state depending on the options and the current date
|
752
756
|
*
|
@@ -756,19 +760,19 @@ var Swaps = new Wrapper(Element, {
|
|
756
760
|
setDate: function(date) {
|
757
761
|
var options = this.options, months_num = options.numberOfMonths[0] * options.numberOfMonths[1],
|
758
762
|
has_prev_year = true, has_next_year = true, has_prev_month = true, has_next_month = true;
|
759
|
-
|
763
|
+
|
760
764
|
if (options.minDate) {
|
761
765
|
var beginning = new Date(date.getFullYear(),0,1,0,0,0);
|
762
766
|
var min_date = new Date(options.minDate.getFullYear(),0,1,0,0,0);
|
763
|
-
|
767
|
+
|
764
768
|
has_prev_year = beginning > min_date;
|
765
|
-
|
769
|
+
|
766
770
|
beginning.setMonth(date.getMonth() - Math.ceil(months_num - months_num/2));
|
767
771
|
min_date.setMonth(options.minDate.getMonth());
|
768
|
-
|
772
|
+
|
769
773
|
has_prev_month = beginning >= min_date;
|
770
774
|
}
|
771
|
-
|
775
|
+
|
772
776
|
if (options.maxDate) {
|
773
777
|
var end = new Date(date);
|
774
778
|
var max_date = new Date(options.maxDate);
|
@@ -782,26 +786,26 @@ var Swaps = new Wrapper(Element, {
|
|
782
786
|
date.setSeconds(0);
|
783
787
|
date.setMilliseconds(0);
|
784
788
|
});
|
785
|
-
|
789
|
+
|
786
790
|
has_next_month = end < max_date;
|
787
|
-
|
791
|
+
|
788
792
|
// checking the next year
|
789
793
|
dates.each('setMonth', 0);
|
790
794
|
has_next_year = end < max_date;
|
791
795
|
}
|
792
|
-
|
796
|
+
|
793
797
|
this.nextMonth[has_next_month ? 'enable':'disable']();
|
794
798
|
this.prevMonth[has_prev_month ? 'enable':'disable']();
|
795
|
-
|
799
|
+
|
796
800
|
if (this.nextYear) {
|
797
801
|
this.nextYear[has_next_year ? 'enable':'disable']();
|
798
802
|
this.prevYear[has_prev_year ? 'enable':'disable']();
|
799
803
|
}
|
800
804
|
},
|
801
|
-
|
805
|
+
|
802
806
|
// protected
|
803
807
|
|
804
|
-
// handles the clicks on the
|
808
|
+
// handles the clicks on the
|
805
809
|
clicked: function(event) {
|
806
810
|
var target = event.target;
|
807
811
|
if (target && this.buttons.include(target)) {
|
@@ -812,6 +816,7 @@ var Swaps = new Wrapper(Element, {
|
|
812
816
|
}
|
813
817
|
});
|
814
818
|
|
819
|
+
|
815
820
|
/**
|
816
821
|
* Represents a single month block
|
817
822
|
*
|
@@ -827,30 +832,30 @@ var Month = new Wrapper(Element, {
|
|
827
832
|
initialize: function(options) {
|
828
833
|
this.$super('table', {'class': 'month'});
|
829
834
|
this.options = options;
|
830
|
-
|
835
|
+
|
831
836
|
// the caption (for the month name)
|
832
837
|
this.insert(this.caption = new Element('caption'));
|
833
|
-
|
838
|
+
|
834
839
|
// the headline for the day-names
|
835
840
|
this.insert('<thead><tr>'+
|
836
841
|
options.dayNames.map(function(name) {return '<th>'+ name +'</th>';}).join('') +
|
837
842
|
'</tr></thead>');
|
838
|
-
|
843
|
+
|
839
844
|
// the body with the day-cells
|
840
845
|
this.days = [];
|
841
|
-
|
846
|
+
|
842
847
|
var tbody = new Element('tbody').insertTo(this), x, y, row;
|
843
|
-
|
848
|
+
|
844
849
|
for (y=0; y < 6; y++) {
|
845
850
|
row = new Element('tr').insertTo(tbody);
|
846
851
|
for (x=0; x < 7; x++) {
|
847
852
|
this.days.push(new Element('td').insertTo(row));
|
848
853
|
}
|
849
854
|
}
|
850
|
-
|
855
|
+
|
851
856
|
this.onClick(this.clicked);
|
852
857
|
},
|
853
|
-
|
858
|
+
|
854
859
|
/**
|
855
860
|
* Initializes the month values by the date
|
856
861
|
*
|
@@ -862,56 +867,56 @@ var Month = new Wrapper(Element, {
|
|
862
867
|
date.setDate(32);
|
863
868
|
var days_number = 32 - date.getDate();
|
864
869
|
date.setMonth(date.getMonth()-1);
|
865
|
-
|
870
|
+
|
866
871
|
var cur_day = Math.ceil(current_date.getTime() / 86400000),
|
867
872
|
options = this.options, i18n = options.i18n, days = this.days;
|
868
|
-
|
873
|
+
|
869
874
|
// resetting the first and last two weeks cells
|
870
875
|
// because there will be some empty cells over there
|
871
876
|
for (var i=0, len = days.length-1, one, two, tre; i < 7; i++) {
|
872
877
|
one = days[i]._;
|
873
878
|
two = days[len - i]._;
|
874
879
|
tre = days[len - i - 7]._;
|
875
|
-
|
880
|
+
|
876
881
|
one.innerHTML = two.innerHTML = tre.innerHTML = '';
|
877
882
|
one.className = two.className = tre.className = 'blank';
|
878
883
|
}
|
879
|
-
|
884
|
+
|
880
885
|
// putting the actual day numbers in place
|
881
886
|
for (var i=1, row=0, week, cell; i <= days_number; i++) {
|
882
887
|
date.setDate(i);
|
883
888
|
var day_num = date.getDay();
|
884
|
-
|
889
|
+
|
885
890
|
if (options.firstDay === 1) { day_num = day_num > 0 ? day_num-1 : 6; }
|
886
891
|
if (i === 1 || day_num === 0) {
|
887
892
|
week = days.slice(row*7, row*7 + 7); row ++;
|
888
893
|
}
|
889
|
-
|
894
|
+
|
890
895
|
cell = week[day_num]._;
|
891
|
-
|
896
|
+
|
892
897
|
if (Browser.OLD) { // IE6 has a nasty glitch with that
|
893
898
|
cell.innerHTML = '';
|
894
899
|
cell.appendChild(document.createTextNode(i));
|
895
900
|
} else {
|
896
901
|
cell.innerHTML = ''+i;
|
897
902
|
}
|
898
|
-
|
903
|
+
|
899
904
|
cell.className = cur_day === Math.ceil(date.getTime() / 86400000) ? 'selected' : '';
|
900
|
-
|
905
|
+
|
901
906
|
if ((options.minDate && options.minDate > date) || (options.maxDate && options.maxDate < date)) {
|
902
907
|
cell.className = 'disabled';
|
903
908
|
}
|
904
|
-
|
909
|
+
|
905
910
|
week[day_num].date = new Date(date);
|
906
911
|
}
|
907
|
-
|
912
|
+
|
908
913
|
// setting up the caption with the month name
|
909
914
|
var caption = (options.listYears ?
|
910
915
|
i18n.monthNamesShort[date.getMonth()] + ',' :
|
911
916
|
i18n.monthNames[date.getMonth()])+
|
912
917
|
' '+date.getFullYear(),
|
913
918
|
element = this.caption._;
|
914
|
-
|
919
|
+
|
915
920
|
if (Browser.OLD) {
|
916
921
|
element.innerHTML = '';
|
917
922
|
element.appendChild(document.createTextNode(caption));
|
@@ -919,7 +924,7 @@ var Month = new Wrapper(Element, {
|
|
919
924
|
element.innerHTML = caption;
|
920
925
|
}
|
921
926
|
},
|
922
|
-
|
927
|
+
|
923
928
|
// protected
|
924
929
|
|
925
930
|
/**
|
@@ -930,10 +935,10 @@ var Month = new Wrapper(Element, {
|
|
930
935
|
*/
|
931
936
|
clicked: function(event) {
|
932
937
|
var target = event.target, date = target.date;
|
933
|
-
|
938
|
+
|
934
939
|
if (target && date && !target.hasClass('disabled') && !target.hasClass('blank')) {
|
935
940
|
target.addClass('selected');
|
936
|
-
|
941
|
+
|
937
942
|
this.fire('date-set', {
|
938
943
|
date: date.getDate(),
|
939
944
|
month: date.getMonth(),
|
@@ -943,6 +948,7 @@ var Month = new Wrapper(Element, {
|
|
943
948
|
}
|
944
949
|
});
|
945
950
|
|
951
|
+
|
946
952
|
/**
|
947
953
|
* The calendar months greed unit
|
948
954
|
*
|
@@ -957,11 +963,11 @@ var Greed = new Wrapper(Element, {
|
|
957
963
|
*/
|
958
964
|
initialize: function(options) {
|
959
965
|
this.$super('table', {'class': 'greed'});
|
960
|
-
|
966
|
+
|
961
967
|
this.months = [];
|
962
|
-
|
968
|
+
|
963
969
|
var tbody = new Element('tbody').insertTo(this), month;
|
964
|
-
|
970
|
+
|
965
971
|
for (var y=0; y < options.numberOfMonths[1]; y++) {
|
966
972
|
var row = new Element('tr').insertTo(tbody);
|
967
973
|
for (var x=0; x < options.numberOfMonths[0]; x++) {
|
@@ -970,7 +976,7 @@ var Greed = new Wrapper(Element, {
|
|
970
976
|
}
|
971
977
|
}
|
972
978
|
},
|
973
|
-
|
979
|
+
|
974
980
|
/**
|
975
981
|
* Sets the months to the date
|
976
982
|
*
|
@@ -980,9 +986,9 @@ var Greed = new Wrapper(Element, {
|
|
980
986
|
*/
|
981
987
|
setDate: function(date, current_date) {
|
982
988
|
var months = this.months, months_num = months.length;
|
983
|
-
|
989
|
+
|
984
990
|
current_date = current_date || date;
|
985
|
-
|
991
|
+
|
986
992
|
for (var i=-Math.ceil(months_num - months_num/2)+1,j=0; i < Math.floor(months_num - months_num/2)+1; i++,j++) {
|
987
993
|
var month_date = new Date(date);
|
988
994
|
month_date.setMonth(date.getMonth() + i);
|
@@ -991,6 +997,7 @@ var Greed = new Wrapper(Element, {
|
|
991
997
|
}
|
992
998
|
});
|
993
999
|
|
1000
|
+
|
994
1001
|
/**
|
995
1002
|
* The time-picker block unit
|
996
1003
|
*
|
@@ -1006,20 +1013,20 @@ var Timepicker = new Wrapper(Element, {
|
|
1006
1013
|
initialize: function(options) {
|
1007
1014
|
this.$super('div', {'class': 'timepicker'});
|
1008
1015
|
this.options = options;
|
1009
|
-
|
1016
|
+
|
1010
1017
|
var on_change = R(this.timeChanged).bind(this);
|
1011
|
-
|
1018
|
+
|
1012
1019
|
this.insert([
|
1013
1020
|
this.hours = new Element('select').onChange(on_change),
|
1014
1021
|
this.minutes = new Element('select').onChange(on_change)
|
1015
1022
|
]);
|
1016
|
-
|
1023
|
+
|
1017
1024
|
var minutes_threshold = options.timePeriod < 60 ? options.timePeriod : 60;
|
1018
1025
|
var hours_threshold = options.timePeriod < 60 ? 1 : Math.ceil(options.timePeriod / 60);
|
1019
|
-
|
1026
|
+
|
1020
1027
|
for (var i=0; i < 60; i++) {
|
1021
1028
|
var caption = zerofy(i);
|
1022
|
-
|
1029
|
+
|
1023
1030
|
if (i < 24 && i % hours_threshold == 0) {
|
1024
1031
|
if (options.twentyFourHour) {
|
1025
1032
|
this.hours.insert(new Element('option', {value: i, html: caption}));
|
@@ -1027,23 +1034,23 @@ var Timepicker = new Wrapper(Element, {
|
|
1027
1034
|
this.hours.insert(new Element('option', {value: i, html: i == 0 ? 12 : i}));
|
1028
1035
|
}
|
1029
1036
|
}
|
1030
|
-
|
1037
|
+
|
1031
1038
|
if (i % minutes_threshold == 0) {
|
1032
1039
|
this.minutes.insert(new Element('option', {value: i, html: caption}));
|
1033
1040
|
}
|
1034
1041
|
}
|
1035
|
-
|
1036
|
-
|
1042
|
+
|
1043
|
+
|
1037
1044
|
// adding the meridian picker if it's a 12 am|pm picker
|
1038
1045
|
if (!options.twentyFourHour) {
|
1039
1046
|
this.meridian = new Element('select').onChange(on_change).insertTo(this);
|
1040
|
-
|
1047
|
+
|
1041
1048
|
R(R(options.format).includes(/%P/) ? ['am', 'pm'] : ['AM', 'PM']).each(function(value) {
|
1042
1049
|
this.meridian.insert(new Element('option', {value: value.toLowerCase(), html: value}));
|
1043
1050
|
}, this);
|
1044
1051
|
}
|
1045
1052
|
},
|
1046
|
-
|
1053
|
+
|
1047
1054
|
/**
|
1048
1055
|
* Sets the time-picker values by the data
|
1049
1056
|
*
|
@@ -1055,18 +1062,18 @@ var Timepicker = new Wrapper(Element, {
|
|
1055
1062
|
var hour = options.timePeriod < 60 ? date.getHours() :
|
1056
1063
|
Math.round(date.getHours()/(options.timePeriod/60)) * (options.timePeriod/60);
|
1057
1064
|
var minute = Math.round(date.getMinutes() / (options.timePeriod % 60)) * options.timePeriod;
|
1058
|
-
|
1065
|
+
|
1059
1066
|
if (this.meridian) {
|
1060
1067
|
this.meridian.setValue(hour < 12 ? 'am' : 'pm');
|
1061
1068
|
hour = (hour == 0 || hour == 12) ? 12 : hour > 12 ? (hour - 12) : hour;
|
1062
1069
|
}
|
1063
|
-
|
1070
|
+
|
1064
1071
|
this.hours.setValue(hour);
|
1065
1072
|
this.minutes.setValue(minute);
|
1066
1073
|
},
|
1067
|
-
|
1074
|
+
|
1068
1075
|
// protected
|
1069
|
-
|
1076
|
+
|
1070
1077
|
/**
|
1071
1078
|
* Handles the time-picking events
|
1072
1079
|
*
|
@@ -1074,10 +1081,10 @@ var Timepicker = new Wrapper(Element, {
|
|
1074
1081
|
*/
|
1075
1082
|
timeChanged: function(event) {
|
1076
1083
|
event.stopPropagation();
|
1077
|
-
|
1084
|
+
|
1078
1085
|
var hours = parseInt(this.hours.value());
|
1079
1086
|
var minutes = parseInt(this.minutes.value());
|
1080
|
-
|
1087
|
+
|
1081
1088
|
if (this.meridian) {
|
1082
1089
|
if (hours == 12) {
|
1083
1090
|
hours = 0;
|
@@ -1086,11 +1093,12 @@ var Timepicker = new Wrapper(Element, {
|
|
1086
1093
|
hours += 12;
|
1087
1094
|
}
|
1088
1095
|
}
|
1089
|
-
|
1096
|
+
|
1090
1097
|
this.fire('time-set', {hours: hours, minutes: minutes});
|
1091
1098
|
}
|
1092
1099
|
});
|
1093
1100
|
|
1101
|
+
|
1094
1102
|
/**
|
1095
1103
|
* The bottom-buttons block unit
|
1096
1104
|
*
|
@@ -1105,7 +1113,7 @@ var Buttons = new Wrapper(Element, {
|
|
1105
1113
|
*/
|
1106
1114
|
initialize: function(options) {
|
1107
1115
|
this.$super('div', {'class': 'buttons'});
|
1108
|
-
|
1116
|
+
|
1109
1117
|
this.insert([
|
1110
1118
|
new Button(options.i18n.Now, {'class': 'now'}).onClick('fire', 'now-clicked'),
|
1111
1119
|
new Button(options.i18n.Done, {'class': 'done'}).onClick('fire', 'done-clicked')
|
@@ -1113,6 +1121,7 @@ var Buttons = new Wrapper(Element, {
|
|
1113
1121
|
}
|
1114
1122
|
});
|
1115
1123
|
|
1124
|
+
|
1116
1125
|
/**
|
1117
1126
|
* This module handles the dates parsing/formatting processes
|
1118
1127
|
*
|
@@ -1150,60 +1159,60 @@ Calendar.include({
|
|
1150
1159
|
*/
|
1151
1160
|
parse: function(string) {
|
1152
1161
|
var date;
|
1153
|
-
|
1162
|
+
|
1154
1163
|
if (isString(string) && string) {
|
1155
1164
|
var tpl = RegExp.escape(this.options.format);
|
1156
1165
|
var holders = R(tpl.match(/%[a-z]/ig)).map('match', /[a-z]$/i).map('first').without('%');
|
1157
1166
|
var re = new RegExp('^'+tpl.replace(/%p/i, '(pm|PM|am|AM)').replace(/(%[a-z])/ig, '(.+?)')+'$');
|
1158
|
-
|
1167
|
+
|
1159
1168
|
var match = R(string).trim().match(re);
|
1160
|
-
|
1169
|
+
|
1161
1170
|
if (match) {
|
1162
1171
|
match.shift();
|
1163
|
-
|
1172
|
+
|
1164
1173
|
var year = null, month = null, hour = null, minute = null, second = null, meridian;
|
1165
|
-
|
1174
|
+
|
1166
1175
|
while (match.length) {
|
1167
1176
|
var value = match.shift();
|
1168
1177
|
var key = holders.shift();
|
1169
|
-
|
1178
|
+
|
1170
1179
|
if (key.toLowerCase() == 'b') {
|
1171
1180
|
month = this.options.i18n[key=='b' ? 'monthNamesShort' : 'monthNames'].indexOf(value);
|
1172
1181
|
} else if (key.toLowerCase() == 'p') {
|
1173
1182
|
meridian = value.toLowerCase();
|
1174
1183
|
} else {
|
1175
|
-
value = parseInt(value);
|
1184
|
+
value = parseInt(value, 10);
|
1176
1185
|
switch(key) {
|
1177
|
-
case 'd':
|
1186
|
+
case 'd':
|
1178
1187
|
case 'e': date = value; break;
|
1179
1188
|
case 'm': month = value-1; break;
|
1180
|
-
case 'y':
|
1189
|
+
case 'y':
|
1181
1190
|
case 'Y': year = value; break;
|
1182
|
-
case 'H':
|
1183
|
-
case 'k':
|
1184
|
-
case 'I':
|
1191
|
+
case 'H':
|
1192
|
+
case 'k':
|
1193
|
+
case 'I':
|
1185
1194
|
case 'l': hour = value; break;
|
1186
1195
|
case 'M': minute = value; break;
|
1187
1196
|
case 'S': second = value; break;
|
1188
1197
|
}
|
1189
1198
|
}
|
1190
1199
|
}
|
1191
|
-
|
1200
|
+
|
1192
1201
|
// converting 1..12am|pm into 0..23 hours marker
|
1193
1202
|
if (meridian) {
|
1194
1203
|
hour = hour == 12 ? 0 : hour;
|
1195
1204
|
hour = (meridian == 'pm' ? hour + 12 : hour);
|
1196
1205
|
}
|
1197
|
-
|
1206
|
+
|
1198
1207
|
date = new Date(year, month, date, hour, minute, second);
|
1199
1208
|
}
|
1200
1209
|
} else if (string instanceof Date || Date.parse(string)) {
|
1201
1210
|
date = new Date(string);
|
1202
1211
|
}
|
1203
|
-
|
1212
|
+
|
1204
1213
|
return (!date || isNaN(date.getTime())) ? null : date;
|
1205
|
-
},
|
1206
|
-
|
1214
|
+
},
|
1215
|
+
|
1207
1216
|
/**
|
1208
1217
|
* Formats the current date into a string depend on the current or given format
|
1209
1218
|
*
|
@@ -1219,9 +1228,9 @@ Calendar.include({
|
|
1219
1228
|
var hour = this.date.getHours();
|
1220
1229
|
var minute = this.date.getMinutes();
|
1221
1230
|
var second = this.date.getSeconds();
|
1222
|
-
|
1231
|
+
|
1223
1232
|
var hour_ampm = (hour == 0 ? 12 : hour < 13 ? hour : hour - 12);
|
1224
|
-
|
1233
|
+
|
1225
1234
|
var values = {
|
1226
1235
|
a: i18n.dayNamesShort[day],
|
1227
1236
|
A: i18n.dayNames[day],
|
@@ -1242,29 +1251,30 @@ Calendar.include({
|
|
1242
1251
|
S: zerofy(second),
|
1243
1252
|
'%': '%'
|
1244
1253
|
};
|
1245
|
-
|
1254
|
+
|
1246
1255
|
var result = format || this.options.format;
|
1247
1256
|
for (var key in values) {
|
1248
1257
|
result = result.replace('%'+key, values[key]);
|
1249
1258
|
}
|
1250
|
-
|
1259
|
+
|
1251
1260
|
return result;
|
1252
1261
|
}
|
1253
1262
|
});
|
1254
1263
|
|
1264
|
+
|
1255
1265
|
/**
|
1256
1266
|
* This module handles the events connection
|
1257
1267
|
*
|
1258
1268
|
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
1259
|
-
*/
|
1269
|
+
*/
|
1260
1270
|
Calendar.include({
|
1261
|
-
|
1271
|
+
|
1262
1272
|
// protected
|
1263
|
-
|
1273
|
+
|
1264
1274
|
// connects the events with handlers
|
1265
1275
|
initEvents: function() {
|
1266
1276
|
var shift = '_shiftDate', terminate = this._terminate;
|
1267
|
-
|
1277
|
+
|
1268
1278
|
this.on({
|
1269
1279
|
// the dates/months/etc listing events
|
1270
1280
|
'prev-day': [shift, {Date: -1}],
|
@@ -1275,15 +1285,15 @@ Calendar.include({
|
|
1275
1285
|
'next-month': [shift, {Month: 1}],
|
1276
1286
|
'prev-year': [shift, {FullYear: -1}],
|
1277
1287
|
'next-year': [shift, {FullYear: 1}],
|
1278
|
-
|
1288
|
+
|
1279
1289
|
// the date/time picking events
|
1280
1290
|
'date-set': this._changeDate,
|
1281
1291
|
'time-set': this._changeTime,
|
1282
|
-
|
1292
|
+
|
1283
1293
|
// the bottom buttons events
|
1284
1294
|
'now-clicked': this._setNow,
|
1285
1295
|
'done-clicked': this.done,
|
1286
|
-
|
1296
|
+
|
1287
1297
|
// handling the clicks
|
1288
1298
|
'click': terminate,
|
1289
1299
|
'mousedown': terminate,
|
@@ -1291,49 +1301,49 @@ Calendar.include({
|
|
1291
1301
|
'blur': terminate
|
1292
1302
|
});
|
1293
1303
|
},
|
1294
|
-
|
1304
|
+
|
1295
1305
|
// shifts the date according to the params
|
1296
1306
|
_shiftDate: function(params) {
|
1297
1307
|
var date = new Date(this.date), options = this.options;
|
1298
|
-
|
1308
|
+
|
1299
1309
|
// shifting the date according to the params
|
1300
1310
|
for (var key in params) {
|
1301
1311
|
date['set'+key](date['get'+key]() + params[key]);
|
1302
1312
|
}
|
1303
|
-
|
1313
|
+
|
1304
1314
|
this.setDate(date);
|
1305
1315
|
},
|
1306
|
-
|
1316
|
+
|
1307
1317
|
// changes the current date (not the time)
|
1308
1318
|
_changeDate: function(event) {
|
1309
1319
|
var date = new Date(this.date);
|
1310
|
-
|
1320
|
+
|
1311
1321
|
date.setDate(event.date);
|
1312
1322
|
date.setMonth(event.month);
|
1313
1323
|
date.setFullYear(event.year);
|
1314
|
-
|
1324
|
+
|
1315
1325
|
this.setDate(date, true); // <- `true` means just change the date without shifting the list
|
1316
|
-
|
1326
|
+
|
1317
1327
|
if (this.options.hideOnPick) {
|
1318
1328
|
this.done();
|
1319
1329
|
}
|
1320
1330
|
},
|
1321
|
-
|
1331
|
+
|
1322
1332
|
// changes the current time (not the date)
|
1323
1333
|
_changeTime: function(event) {
|
1324
1334
|
var date = new Date(this.date);
|
1325
|
-
|
1335
|
+
|
1326
1336
|
date.setHours(event.hours);
|
1327
1337
|
date.setMinutes(event.minutes);
|
1328
|
-
|
1338
|
+
|
1329
1339
|
this.setDate(date);
|
1330
1340
|
},
|
1331
|
-
|
1341
|
+
|
1332
1342
|
// resets the calendar to the current time
|
1333
1343
|
_setNow: function() {
|
1334
1344
|
this.setDate(new Date());
|
1335
1345
|
},
|
1336
|
-
|
1346
|
+
|
1337
1347
|
/** simply stops the event so we didn't bother the things outside of the object
|
1338
1348
|
*
|
1339
1349
|
* @param {Event} event
|
@@ -1350,6 +1360,7 @@ Calendar.include({
|
|
1350
1360
|
}
|
1351
1361
|
});
|
1352
1362
|
|
1363
|
+
|
1353
1364
|
/**
|
1354
1365
|
* Document level event listeners for navigation and lazy initialization
|
1355
1366
|
*
|
@@ -1364,16 +1375,16 @@ $(document).on({
|
|
1364
1375
|
* @return void
|
1365
1376
|
*/
|
1366
1377
|
focus: function(event) {
|
1367
|
-
var target = event.target instanceof Input ? event.target : null;
|
1368
|
-
|
1378
|
+
var target = event.target instanceof Input && event.target.get('type') == 'text' ? event.target : null;
|
1379
|
+
|
1369
1380
|
Calendar.hideAll();
|
1370
|
-
|
1381
|
+
|
1371
1382
|
if (target && (target.calendar || target.match(Calendar.Options.cssRule))) {
|
1372
1383
|
(target.calendar || new Calendar({update: target}))
|
1373
1384
|
.setValue(target.value()).showAt(target);
|
1374
1385
|
}
|
1375
1386
|
},
|
1376
|
-
|
1387
|
+
|
1377
1388
|
/**
|
1378
1389
|
* Watches the input elements blur events
|
1379
1390
|
* and hides shown popups
|
@@ -1383,7 +1394,7 @@ $(document).on({
|
|
1383
1394
|
*/
|
1384
1395
|
blur: function(event) {
|
1385
1396
|
var target = event.target, calendar = target.calendar;
|
1386
|
-
|
1397
|
+
|
1387
1398
|
if (calendar) {
|
1388
1399
|
// we use the delay so it didn't get hidden when the user clicks the calendar itself
|
1389
1400
|
calendar._hide_delay = R(function() {
|
@@ -1391,7 +1402,7 @@ $(document).on({
|
|
1391
1402
|
}).delay(200);
|
1392
1403
|
}
|
1393
1404
|
},
|
1394
|
-
|
1405
|
+
|
1395
1406
|
/**
|
1396
1407
|
* Catches clicks on trigger elements
|
1397
1408
|
*
|
@@ -1400,9 +1411,9 @@ $(document).on({
|
|
1400
1411
|
*/
|
1401
1412
|
click: function(event) {
|
1402
1413
|
var target = (event.target instanceof Element) ? event.target : null;
|
1403
|
-
|
1414
|
+
|
1404
1415
|
if (target && (target.calendar || target.match(Calendar.Options.cssRule))) {
|
1405
|
-
if (!(target instanceof Input)) {
|
1416
|
+
if (!(target instanceof Input) || target.get('type') != 'text') {
|
1406
1417
|
event.stop();
|
1407
1418
|
(target.calendar || new Calendar({trigger: target}))
|
1408
1419
|
.hide(null).toggleAt(target.assignedInput);
|
@@ -1411,7 +1422,7 @@ $(document).on({
|
|
1411
1422
|
Calendar.hideAll();
|
1412
1423
|
}
|
1413
1424
|
},
|
1414
|
-
|
1425
|
+
|
1415
1426
|
/**
|
1416
1427
|
* Catching the key-downs to navigate in the currently
|
1417
1428
|
* opened Calendar hover
|
@@ -1430,7 +1441,7 @@ $(document).on({
|
|
1430
1441
|
34: 'next-month', // Page Down
|
1431
1442
|
13: 'done' // Enter
|
1432
1443
|
})[event.keyCode];
|
1433
|
-
|
1444
|
+
|
1434
1445
|
if (name && calendar && calendar.visible()) {
|
1435
1446
|
event.stop();
|
1436
1447
|
if (isFunction(calendar[name])) {
|
@@ -1442,7 +1453,8 @@ $(document).on({
|
|
1442
1453
|
}
|
1443
1454
|
});
|
1444
1455
|
|
1456
|
+
|
1445
1457
|
document.write("<style type=\"text/css\">.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}</style>");
|
1446
1458
|
|
1447
1459
|
return Calendar;
|
1448
|
-
})(document, parseInt, RightJS);
|
1460
|
+
})(document, parseInt, RightJS);
|