puffer_pages 0.0.14 → 0.0.15

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