right-rails 1.0.9 → 1.0.10
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 +13 -0
- data/public/javascripts/right/billboard-src.js +544 -0
- data/public/javascripts/right/billboard.js +17 -0
- data/public/javascripts/right/dialog-src.js +738 -0
- data/public/javascripts/right/dialog.js +21 -0
- data/public/javascripts/right/i18n/de.js +16 -0
- data/public/javascripts/right/i18n/es.js +16 -0
- data/public/javascripts/right/i18n/fi.js +16 -0
- data/public/javascripts/right/i18n/fr.js +16 -0
- data/public/javascripts/right/i18n/hu.js +16 -0
- data/public/javascripts/right/i18n/it.js +16 -0
- data/public/javascripts/right/i18n/jp.js +15 -0
- data/public/javascripts/right/i18n/nl.js +14 -0
- data/public/javascripts/right/i18n/pt-br.js +14 -0
- data/public/javascripts/right/i18n/ru.js +14 -0
- data/public/javascripts/right/i18n/ua.js +14 -1
- data/public/javascripts/right/lightbox-src.js +2 -2
- data/public/javascripts/right/lightbox.js +2 -2
- data/public/javascripts/right/sortable-src.js +52 -30
- data/public/javascripts/right/sortable.js +8 -8
- data/public/javascripts/right/table-src.js +167 -0
- data/public/javascripts/right/table.js +9 -0
- data/public/javascripts/right-src.js +3 -1
- metadata +10 -4
@@ -0,0 +1,738 @@
|
|
1
|
+
/**
|
2
|
+
* Standard dialog widget for RightJS
|
3
|
+
* http://rightjs.org/ui/dialog
|
4
|
+
*
|
5
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
6
|
+
*/
|
7
|
+
var Dialog = RightJS.Dialog = (function(RightJS) {
|
8
|
+
/**
|
9
|
+
* This module defines the basic widgets constructor
|
10
|
+
* it creates an abstract proxy with the common functionality
|
11
|
+
* which then we reuse and override in the actual widgets
|
12
|
+
*
|
13
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
14
|
+
*/
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Dialog widget initialization script
|
18
|
+
*
|
19
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
20
|
+
*/
|
21
|
+
var R = RightJS,
|
22
|
+
$ = RightJS.$,
|
23
|
+
$w = RightJS.$w,
|
24
|
+
$E = RightJS.$E,
|
25
|
+
Class = RightJS.Class,
|
26
|
+
Object = RightJS.Object;
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
/**
|
35
|
+
* The widget units constructor
|
36
|
+
*
|
37
|
+
* @param String tag-name or Object methods
|
38
|
+
* @param Object methods
|
39
|
+
* @return Widget wrapper
|
40
|
+
*/
|
41
|
+
function Widget(tag_name, methods) {
|
42
|
+
if (!methods) {
|
43
|
+
methods = tag_name;
|
44
|
+
tag_name = 'DIV';
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* An Abstract Widget Unit
|
49
|
+
*
|
50
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
51
|
+
*/
|
52
|
+
var AbstractWidget = new RightJS.Wrapper(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
53
|
+
/**
|
54
|
+
* The common constructor
|
55
|
+
*
|
56
|
+
* @param Object options
|
57
|
+
* @param String optional tag name
|
58
|
+
* @return void
|
59
|
+
*/
|
60
|
+
initialize: function(key, options) {
|
61
|
+
this.key = key;
|
62
|
+
var args = [{'class': 'rui-' + key}];
|
63
|
+
|
64
|
+
// those two have different constructors
|
65
|
+
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
66
|
+
args.unshift(tag_name);
|
67
|
+
}
|
68
|
+
this.$super.apply(this, args);
|
69
|
+
|
70
|
+
if (RightJS.isString(options)) {
|
71
|
+
options = RightJS.$(options);
|
72
|
+
}
|
73
|
+
|
74
|
+
// if the options is another element then
|
75
|
+
// try to dynamically rewrap it with our widget
|
76
|
+
if (options instanceof RightJS.Element) {
|
77
|
+
this._ = options._;
|
78
|
+
if ('$listeners' in options) {
|
79
|
+
options.$listeners = options.$listeners;
|
80
|
+
}
|
81
|
+
options = {};
|
82
|
+
}
|
83
|
+
this.setOptions(options, this);
|
84
|
+
return this;
|
85
|
+
},
|
86
|
+
|
87
|
+
// protected
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Catches the options
|
91
|
+
*
|
92
|
+
* @param Object user-options
|
93
|
+
* @param Element element with contextual options
|
94
|
+
* @return void
|
95
|
+
*/
|
96
|
+
setOptions: function(options, element) {
|
97
|
+
element = element || this;
|
98
|
+
RightJS.Options.setOptions.call(this,
|
99
|
+
RightJS.Object.merge(options, eval("("+(
|
100
|
+
element.get('data-'+ this.key) || '{}'
|
101
|
+
)+")"))
|
102
|
+
);
|
103
|
+
return this;
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Creating the actual widget class
|
109
|
+
*
|
110
|
+
*/
|
111
|
+
var Klass = new RightJS.Wrapper(AbstractWidget, methods);
|
112
|
+
|
113
|
+
// creating the widget related shortcuts
|
114
|
+
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
115
|
+
|
116
|
+
return Klass;
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
/**
|
121
|
+
* A shared button unit.
|
122
|
+
* NOTE: we use the DIV units instead of INPUTS
|
123
|
+
* so those buttons didn't interfere with
|
124
|
+
* the user's tab-index on his page
|
125
|
+
*
|
126
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
127
|
+
*/
|
128
|
+
var Button = new RightJS.Wrapper(RightJS.Element, {
|
129
|
+
/**
|
130
|
+
* Constructor
|
131
|
+
*
|
132
|
+
* @param String caption
|
133
|
+
* @param Object options
|
134
|
+
* @return void
|
135
|
+
*/
|
136
|
+
initialize: function(caption, options) {
|
137
|
+
this.$super('div', options);
|
138
|
+
this._.innerHTML = caption;
|
139
|
+
this.addClass('rui-button');
|
140
|
+
this.on('selectstart', 'stopEvent');
|
141
|
+
},
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Disasbles the button
|
145
|
+
*
|
146
|
+
* @return Button this
|
147
|
+
*/
|
148
|
+
disable: function() {
|
149
|
+
return this.addClass('rui-button-disabled');
|
150
|
+
},
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Enables the button
|
154
|
+
*
|
155
|
+
* @return Button this
|
156
|
+
*/
|
157
|
+
enable: function() {
|
158
|
+
return this.removeClass('rui-button-disabled');
|
159
|
+
},
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Checks if the button is disabled
|
163
|
+
*
|
164
|
+
* @return Button this
|
165
|
+
*/
|
166
|
+
disabled: function() {
|
167
|
+
return this.hasClass('rui-button-disabled');
|
168
|
+
},
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Checks if the button is enabled
|
172
|
+
*
|
173
|
+
* @return Button this
|
174
|
+
*/
|
175
|
+
enabled: function() {
|
176
|
+
return !this.disabled();
|
177
|
+
},
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Overloading the method, so it fired the events
|
181
|
+
* only when the button is active
|
182
|
+
*
|
183
|
+
* @return Button this
|
184
|
+
*/
|
185
|
+
fire: function() {
|
186
|
+
if (this.enabled()) {
|
187
|
+
this.$super.apply(this, arguments);
|
188
|
+
}
|
189
|
+
return this;
|
190
|
+
}
|
191
|
+
});
|
192
|
+
|
193
|
+
|
194
|
+
/**
|
195
|
+
* A shared module to create textual spinners
|
196
|
+
*
|
197
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
198
|
+
*/
|
199
|
+
var Spinner = new RightJS.Wrapper(RightJS.Element, {
|
200
|
+
/**
|
201
|
+
* Constructor
|
202
|
+
*
|
203
|
+
* @param Number optional spinner size (4 by default)
|
204
|
+
* @return void
|
205
|
+
*/
|
206
|
+
initialize: function(size) {
|
207
|
+
this.$super('div', {'class': 'rui-spinner'});
|
208
|
+
this.dots = [];
|
209
|
+
|
210
|
+
for (var i=0; i < (size || 4); i++) {
|
211
|
+
this.dots.push(new RightJS.Element('div'));
|
212
|
+
}
|
213
|
+
|
214
|
+
this.dots[0].addClass('glowing');
|
215
|
+
this.insert(this.dots);
|
216
|
+
RightJS(this.shift).bind(this).periodical(300);
|
217
|
+
},
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Shifts the spinner elements
|
221
|
+
*
|
222
|
+
* @return void
|
223
|
+
*/
|
224
|
+
shift: function() {
|
225
|
+
if (this.visible()) {
|
226
|
+
var dot = this.dots.pop();
|
227
|
+
this.dots.unshift(dot);
|
228
|
+
this.insert(dot, 'top');
|
229
|
+
}
|
230
|
+
}
|
231
|
+
});
|
232
|
+
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Basic dialog class
|
236
|
+
*
|
237
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
238
|
+
*/
|
239
|
+
var Dialog = new Widget({
|
240
|
+
extend: {
|
241
|
+
version: '2.0.0',
|
242
|
+
|
243
|
+
EVENTS: $w('ok cancel help expand collapse resize load'),
|
244
|
+
|
245
|
+
Options: {
|
246
|
+
lockScreen: true, // if you need to lock the scrreen
|
247
|
+
|
248
|
+
draggable: true, // sets if the user should be able to drag the dialog around
|
249
|
+
closeable: true, // allow the user to close the dialog
|
250
|
+
expandable: false, // show the user to expand/collapse the dialog window width
|
251
|
+
|
252
|
+
showHelp: false, // show the 'Help' button
|
253
|
+
showIcon: null, // null or some text to be show in the dialog body icon
|
254
|
+
|
255
|
+
title: null, // default title to preset
|
256
|
+
html: null, // html content to set on instance
|
257
|
+
url: null // url address that should be loaded on instance
|
258
|
+
},
|
259
|
+
|
260
|
+
i18n: {
|
261
|
+
Ok: 'Ok',
|
262
|
+
Close: 'Close',
|
263
|
+
Cancel: 'Cancel',
|
264
|
+
Help: 'Help',
|
265
|
+
Expand: 'Expand',
|
266
|
+
Collapse: 'Collapse',
|
267
|
+
|
268
|
+
Alert: 'Warning!',
|
269
|
+
Confirm: 'Confirm',
|
270
|
+
Prompt: 'Enter'
|
271
|
+
},
|
272
|
+
|
273
|
+
current: false, // the current dialog reference
|
274
|
+
dragged: false // currently dragged dialog reference
|
275
|
+
},
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Basic constructor
|
279
|
+
*
|
280
|
+
* @param Object options
|
281
|
+
* @return void
|
282
|
+
*/
|
283
|
+
initialize: function(options) {
|
284
|
+
this
|
285
|
+
.$super('dialog', options)
|
286
|
+
.append(
|
287
|
+
this.head = new Dialog.Head(this),
|
288
|
+
this.body = new Dialog.Body(this),
|
289
|
+
this.foot = new Dialog.Foot(this)
|
290
|
+
)
|
291
|
+
.onCancel(this.hide);
|
292
|
+
|
293
|
+
this.locker = $E('div', {'class': 'rui-screen-locker'});
|
294
|
+
|
295
|
+
if (this.options.title) {
|
296
|
+
this.title(this.options.title);
|
297
|
+
}
|
298
|
+
|
299
|
+
if (this.options.html) {
|
300
|
+
this.html(this.options.html);
|
301
|
+
}
|
302
|
+
|
303
|
+
if (this.options.url) {
|
304
|
+
this.load(this.options.url);
|
305
|
+
}
|
306
|
+
},
|
307
|
+
|
308
|
+
/**
|
309
|
+
* Shows the dialog
|
310
|
+
*
|
311
|
+
* @return Dialog this
|
312
|
+
*/
|
313
|
+
show: function() {
|
314
|
+
if (this.options.lockScreen) {
|
315
|
+
this.locker.insertTo(document.body);
|
316
|
+
}
|
317
|
+
|
318
|
+
this.insertTo(document.body).resize();
|
319
|
+
|
320
|
+
return (Dialog.current = this);
|
321
|
+
},
|
322
|
+
|
323
|
+
/**
|
324
|
+
* Hides the dialog
|
325
|
+
*
|
326
|
+
* @return Dialog this
|
327
|
+
*/
|
328
|
+
hide: function() {
|
329
|
+
this.locker.remove();
|
330
|
+
this.remove();
|
331
|
+
|
332
|
+
Dialog.current = false;
|
333
|
+
|
334
|
+
return this;
|
335
|
+
},
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Repositions the dialog to the middle of the screen
|
339
|
+
*
|
340
|
+
* @param normal arguments
|
341
|
+
* @return Dialog this
|
342
|
+
*/
|
343
|
+
resize: function() {
|
344
|
+
if (arguments.length) {
|
345
|
+
this.$super.apply(this, arguments);
|
346
|
+
}
|
347
|
+
|
348
|
+
var size = this.size(), win_size = $(window).size();
|
349
|
+
|
350
|
+
if (this.expanded) {
|
351
|
+
size.x = win_size.x - 20;
|
352
|
+
size.y = win_size.y - 10;
|
353
|
+
this.$super.call(this, size);
|
354
|
+
}
|
355
|
+
|
356
|
+
this.setStyle({
|
357
|
+
top: (win_size.y - size.y)/2 + $(window).scrolls().y + 'px',
|
358
|
+
left: (win_size.x - size.x - 16)/2 + 'px'
|
359
|
+
});
|
360
|
+
|
361
|
+
return this.fire('resize');
|
362
|
+
},
|
363
|
+
|
364
|
+
/**
|
365
|
+
* Bidirectional method to work with titles
|
366
|
+
*
|
367
|
+
* @param String title to set
|
368
|
+
* @return String title or Dialog this
|
369
|
+
*/
|
370
|
+
title: function(text) {
|
371
|
+
if (arguments.length) {
|
372
|
+
this.head.title.html(text);
|
373
|
+
return this;
|
374
|
+
} else {
|
375
|
+
return this.head.title.html();
|
376
|
+
}
|
377
|
+
},
|
378
|
+
|
379
|
+
/**
|
380
|
+
* Overloading the standard method, so that
|
381
|
+
* all the content updates were going into the body element
|
382
|
+
*
|
383
|
+
* @param mixed content
|
384
|
+
* @return Dialog this
|
385
|
+
*/
|
386
|
+
update: function(content) {
|
387
|
+
this.body.update(content);
|
388
|
+
return this.resize();
|
389
|
+
},
|
390
|
+
|
391
|
+
/**
|
392
|
+
* Redirecting the `html` method to work wiht the body html
|
393
|
+
*
|
394
|
+
* @param mixed content
|
395
|
+
* @return Dialog this or html content of the body
|
396
|
+
*/
|
397
|
+
html: function() {
|
398
|
+
return arguments.length ?
|
399
|
+
this.$super.apply(this, arguments) :
|
400
|
+
this.body.html();
|
401
|
+
},
|
402
|
+
|
403
|
+
/**
|
404
|
+
* Overloading the original method to bypass things into the body object
|
405
|
+
*
|
406
|
+
* @param String url
|
407
|
+
* @param Object options
|
408
|
+
* @return Dialog this
|
409
|
+
*/
|
410
|
+
load: function(url, options) {
|
411
|
+
this.show();
|
412
|
+
this.body.load(url, options);
|
413
|
+
return this;
|
414
|
+
},
|
415
|
+
|
416
|
+
/**
|
417
|
+
* Expands a dialog screen-wide
|
418
|
+
*
|
419
|
+
* @return Dialog this
|
420
|
+
*/
|
421
|
+
expand: function() {
|
422
|
+
if (!this.expanded) {
|
423
|
+
this._prevSize = this.size();
|
424
|
+
this.resize({
|
425
|
+
x: $(window).size().x - 20,
|
426
|
+
y: $(window).size().y - 10
|
427
|
+
});
|
428
|
+
|
429
|
+
this.expanded = true;
|
430
|
+
this.fire('expand');
|
431
|
+
}
|
432
|
+
|
433
|
+
return this;
|
434
|
+
},
|
435
|
+
|
436
|
+
/**
|
437
|
+
* Collapses an expanded dialog to it's previous size
|
438
|
+
*
|
439
|
+
* @return Dialog this
|
440
|
+
*/
|
441
|
+
collapse: function() {
|
442
|
+
if (this.expanded) {
|
443
|
+
this.expanded = false;
|
444
|
+
this.resize(this._prevSize);
|
445
|
+
this.fire('collapse');
|
446
|
+
}
|
447
|
+
|
448
|
+
return this;
|
449
|
+
}
|
450
|
+
});
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Dialog header line element
|
454
|
+
*
|
455
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
456
|
+
*/
|
457
|
+
Dialog.Head = new Class(Element, {
|
458
|
+
|
459
|
+
initialize: function(dialog) {
|
460
|
+
this.dialog = dialog;
|
461
|
+
this.options = dialog.options;
|
462
|
+
|
463
|
+
this.$super('div', {'class': 'rui-dialog-head'});
|
464
|
+
|
465
|
+
this.append(
|
466
|
+
this.icon = $E('div', {'class': 'icon'}),
|
467
|
+
this.title = $E('div', {'class': 'title', 'html': ' '}),
|
468
|
+
this.tools = $E('div', {'class': 'tools'})
|
469
|
+
);
|
470
|
+
|
471
|
+
this.fsButton = $E('div', {
|
472
|
+
'class': 'expand', 'html': '≡', 'title': Dialog.i18n.Expand
|
473
|
+
}).onClick(function() {
|
474
|
+
if (dialog.expanded) {
|
475
|
+
dialog.collapse();
|
476
|
+
this.html('≡').set('title', Dialog.i18n.Expand);
|
477
|
+
} else {
|
478
|
+
dialog.expand();
|
479
|
+
this.html('_').set('title', Dialog.i18n.Collapse);
|
480
|
+
}
|
481
|
+
});
|
482
|
+
|
483
|
+
this.closeButton = $E('div', {
|
484
|
+
'class': 'close', 'html': '×', 'title': Dialog.i18n.Close
|
485
|
+
}).onClick(function() { dialog.fire('cancel'); });
|
486
|
+
|
487
|
+
if (this.options.expandable) {
|
488
|
+
this.tools.insert(this.fsButton);
|
489
|
+
}
|
490
|
+
|
491
|
+
if (this.options.closeable) {
|
492
|
+
this.tools.insert(this.closeButton);
|
493
|
+
}
|
494
|
+
|
495
|
+
this.on({
|
496
|
+
selectstart: function(e) { e.stop(); },
|
497
|
+
mousedown: this.dragStart
|
498
|
+
});
|
499
|
+
|
500
|
+
if (!this.options.draggable) {
|
501
|
+
this.dialog.addClass('rui-dialog-nodrag');
|
502
|
+
}
|
503
|
+
},
|
504
|
+
|
505
|
+
// protected
|
506
|
+
|
507
|
+
dragStart: function(event) {
|
508
|
+
if (this.options.draggable && !event.find('div.tools div')) {
|
509
|
+
var dim = this.dialog.dimensions(),
|
510
|
+
ev_pos = event.position();
|
511
|
+
|
512
|
+
this.xDiff = dim.left - ev_pos.x;
|
513
|
+
this.yDiff = dim.top - ev_pos.y;
|
514
|
+
this.maxX = $(window).size().x - dim.width - 20;
|
515
|
+
this.dlgStyle = this.dialog.get('style');
|
516
|
+
|
517
|
+
Dialog.dragged = this.dialog;
|
518
|
+
|
519
|
+
event.stop();
|
520
|
+
}
|
521
|
+
},
|
522
|
+
|
523
|
+
dragMove: function(event) {
|
524
|
+
var event_pos = event.position(),
|
525
|
+
pos_x = event_pos.x + this.xDiff,
|
526
|
+
pos_y = event_pos.y + this.yDiff;
|
527
|
+
|
528
|
+
if (pos_x < 0) { pos_x = 0; }
|
529
|
+
else if (pos_x > this.maxX) { pos_x = this.maxX; }
|
530
|
+
if (pos_y < 0) { pos_y = 0; }
|
531
|
+
|
532
|
+
this.dlgStyle.top = pos_y + 'px';
|
533
|
+
this.dlgStyle.left = pos_x + 'px';
|
534
|
+
},
|
535
|
+
|
536
|
+
dragStop: function(event) {
|
537
|
+
Dialog.dragged = false;
|
538
|
+
}
|
539
|
+
});
|
540
|
+
|
541
|
+
/**
|
542
|
+
* Dialog body element
|
543
|
+
*
|
544
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
545
|
+
*/
|
546
|
+
Dialog.Body = new Class(Element, {
|
547
|
+
|
548
|
+
initialize: function(dialog) {
|
549
|
+
this.dialog = dialog;
|
550
|
+
this.options = dialog.options;
|
551
|
+
|
552
|
+
this.$super('div', {'class': 'rui-dialog-body'});
|
553
|
+
this.locker = $E('div', {'class': 'rui-dialog-body-locker'})
|
554
|
+
.insert(new Spinner());
|
555
|
+
},
|
556
|
+
|
557
|
+
load: function(url, options) {
|
558
|
+
this.insert(this.locker, 'top');
|
559
|
+
|
560
|
+
this.xhr = new Xhr(url, Object.merge({method:'get'}, options))
|
561
|
+
.onComplete(R(function(r) {
|
562
|
+
this.update(r.text);
|
563
|
+
this.dialog.resize().fire('load');
|
564
|
+
}).bind(this))
|
565
|
+
.send();
|
566
|
+
|
567
|
+
return this;
|
568
|
+
},
|
569
|
+
|
570
|
+
update: function(content) {
|
571
|
+
this.$super(content);
|
572
|
+
|
573
|
+
if (this.options.showIcon) {
|
574
|
+
this.insert('<div class="rui-dialog-body-icon">'+ this.options.showIcon + '</div>', 'top');
|
575
|
+
}
|
576
|
+
|
577
|
+
return this;
|
578
|
+
}
|
579
|
+
|
580
|
+
});
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Dialog footer line element
|
584
|
+
*
|
585
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
586
|
+
*/
|
587
|
+
Dialog.Foot = new Class(Element, {
|
588
|
+
|
589
|
+
initialize: function(dialog) {
|
590
|
+
this.$super('div', {'class': 'rui-dialog-foot'});
|
591
|
+
|
592
|
+
this.dialog = dialog;
|
593
|
+
|
594
|
+
dialog.okButton = new Button(Dialog.i18n.Ok, {'class': 'ok'}).onClick(function() { dialog.fire('ok'); });
|
595
|
+
dialog.helpButton = new Button(Dialog.i18n.Help, {'class': 'help'}).onClick(function() { dialog.fire('help'); });
|
596
|
+
dialog.cancelButton = new Button(Dialog.i18n.Cancel, {'class': 'cancel'}).onClick(function() { dialog.fire('cancel'); });
|
597
|
+
|
598
|
+
if (dialog.options.showHelp) {
|
599
|
+
this.insert(dialog.helpButton);
|
600
|
+
}
|
601
|
+
|
602
|
+
if (dialog.options.closeable) {
|
603
|
+
this.insert(dialog.cancelButton);
|
604
|
+
}
|
605
|
+
|
606
|
+
this.insert(dialog.okButton);
|
607
|
+
}
|
608
|
+
|
609
|
+
});
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Alert specific dialog
|
613
|
+
*
|
614
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
615
|
+
*/
|
616
|
+
Dialog.Alert = new Class(Dialog, {
|
617
|
+
|
618
|
+
initialize: function(options) {
|
619
|
+
options = Object.merge({
|
620
|
+
showIcon: '!',
|
621
|
+
title: Dialog.i18n.Alert
|
622
|
+
}, options);
|
623
|
+
|
624
|
+
this.$super(options);
|
625
|
+
this.addClass('rui-dialog-alert');
|
626
|
+
this.on('ok', 'hide');
|
627
|
+
}
|
628
|
+
});
|
629
|
+
|
630
|
+
/**
|
631
|
+
* Confirm specific dialog
|
632
|
+
*
|
633
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
634
|
+
*/
|
635
|
+
Dialog.Confirm = new Class(Dialog, {
|
636
|
+
|
637
|
+
initialize: function(options) {
|
638
|
+
options = Object.merge({
|
639
|
+
showIcon: '?',
|
640
|
+
title: Dialog.i18n.Confirm
|
641
|
+
}, options);
|
642
|
+
|
643
|
+
this.$super(options);
|
644
|
+
this.addClass('rui-dialog-confirm');
|
645
|
+
this.on('ok', 'hide');
|
646
|
+
}
|
647
|
+
|
648
|
+
});
|
649
|
+
|
650
|
+
/**
|
651
|
+
* The prompt dialog class
|
652
|
+
*
|
653
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
654
|
+
*/
|
655
|
+
Dialog.Prompt = new Class(Dialog, {
|
656
|
+
/**
|
657
|
+
* prompts constructor, you can use additional options with this one
|
658
|
+
*
|
659
|
+
* * `label` - the text for the input field label
|
660
|
+
* * `input` - the input field options (standard for Input unit)
|
661
|
+
*
|
662
|
+
* @param Object options
|
663
|
+
* @return void
|
664
|
+
*/
|
665
|
+
initialize: function(options) {
|
666
|
+
options = Object.merge({
|
667
|
+
showIcon: '➥',
|
668
|
+
title: Dialog.i18n.Prompt,
|
669
|
+
label: Dialog.i18n.Prompt
|
670
|
+
}, options);
|
671
|
+
|
672
|
+
this.$super(options);
|
673
|
+
this.addClass('rui-dialog-prompt');
|
674
|
+
|
675
|
+
this.html([
|
676
|
+
$E('label', {html: this.options.label}),
|
677
|
+
this.input = new RightJS.Input(this.options.input || {})
|
678
|
+
]);
|
679
|
+
|
680
|
+
if (this.input.get('type') !== 'textarea') {
|
681
|
+
this.input.onKeydown(R(function(event) {
|
682
|
+
if (event.keyCode === 13) {
|
683
|
+
this.fire('ok');
|
684
|
+
}
|
685
|
+
}).bind(this));
|
686
|
+
}
|
687
|
+
},
|
688
|
+
|
689
|
+
show: function() {
|
690
|
+
this.$super.apply(this, arguments);
|
691
|
+
this.input.select();
|
692
|
+
return this;
|
693
|
+
}
|
694
|
+
|
695
|
+
});
|
696
|
+
|
697
|
+
/**
|
698
|
+
* Document level hooks for the dialogs
|
699
|
+
*
|
700
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
701
|
+
*/
|
702
|
+
$(document).on({
|
703
|
+
keydown: function(event) {
|
704
|
+
if (event.keyCode === 27 && Dialog.current) {
|
705
|
+
if (Dialog.current.options.closeable) {
|
706
|
+
Dialog.current.fire('cancel');
|
707
|
+
}
|
708
|
+
} else if (event.keyCode === 13 && Dialog.current) {
|
709
|
+
if (!(Dialog.current instanceof Dialog.Prompt)) {
|
710
|
+
event.stop();
|
711
|
+
Dialog.current.fire('ok');
|
712
|
+
}
|
713
|
+
}
|
714
|
+
},
|
715
|
+
|
716
|
+
mousemove: function(event) {
|
717
|
+
if (Dialog.dragged) {
|
718
|
+
Dialog.dragged.head.dragMove(event);
|
719
|
+
}
|
720
|
+
},
|
721
|
+
|
722
|
+
mouseup: function(event) {
|
723
|
+
if (Dialog.dragged) {
|
724
|
+
Dialog.dragged.head.dragStop(event);
|
725
|
+
}
|
726
|
+
}
|
727
|
+
});
|
728
|
+
|
729
|
+
$(window).onResize(function() {
|
730
|
+
if (Dialog.current) {
|
731
|
+
Dialog.current.resize();
|
732
|
+
}
|
733
|
+
});
|
734
|
+
|
735
|
+
document.write("<style type=\"text/css\"> *.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-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-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}</style>");
|
736
|
+
|
737
|
+
return Dialog;
|
738
|
+
})(RightJS);
|