puffer_pages 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -11
- data/README.md +63 -0
- data/VERSION +1 -1
- data/app/controllers/pages_controller.rb +2 -2
- data/app/controllers/puffer_pages/layouts_controller.rb +5 -1
- data/app/controllers/puffer_pages/pages_controller.rb +15 -13
- data/app/controllers/puffer_pages/snippets_controller.rb +5 -1
- data/app/helpers/puffer_pages_helper.rb +8 -0
- data/app/helpers/puffer_tree_helper.rb +11 -0
- data/app/models/page.rb +8 -9
- data/app/models/page_part.rb +1 -1
- data/app/views/puffer_pages/_page_part_builder.html.erb +3 -0
- data/app/views/puffer_pages/_page_parts.html.erb +26 -0
- data/app/views/puffer_pages/_tree_page.html.erb +2 -0
- data/app/views/puffer_tree/tree.html.erb +55 -0
- data/lib/generators/puffer_pages/install/install_generator.rb +8 -0
- data/lib/generators/puffer_pages/install/templates/puffer/javascripts/puffer_pages.js +35 -0
- data/lib/generators/puffer_pages/install/templates/puffer/javascripts/right-dialog.js +764 -0
- data/{spec/dummy/public/puffer/javascripts/right-tabs-src.js → lib/generators/puffer_pages/install/templates/puffer/javascripts/right-tabs.js} +1 -2
- data/lib/generators/puffer_pages/install/templates/puffer/stylesheets/puffer_pages.css +4 -0
- data/lib/generators/puffer_pages/install/templates/puffer/stylesheets/puffer_tree.css +51 -0
- data/lib/generators/puffer_pages/install/templates/puffer_pages.rb +16 -0
- data/lib/puffer/inputs/page_parts.rb +12 -0
- data/lib/puffer/inputs/page_parts_body.rb +13 -0
- data/lib/puffer/tree_base.rb +31 -0
- data/lib/puffer_pages/extensions/mapper.rb +2 -2
- data/lib/puffer_pages/liquid/tags/yield.rb +1 -1
- data/lib/puffer_pages.rb +15 -1
- data/puffer_pages.gemspec +31 -29
- data/spec/dummy/config/initializers/puffer.rb +12 -0
- data/spec/dummy/config/initializers/puffer_pages.rb +16 -0
- data/spec/dummy/db/migrate/20090422092419_create_pages.rb +0 -1
- data/spec/dummy/db/schema.rb +0 -1
- data/spec/dummy/public/puffer/javascripts/{application.js → puffer.js} +0 -0
- data/spec/dummy/public/puffer/javascripts/puffer_pages.js +35 -0
- data/spec/dummy/public/puffer/javascripts/{rails-src.js → rails.js} +0 -0
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js +615 -12
- data/spec/dummy/public/puffer/javascripts/right-calendar.js +1454 -29
- data/spec/dummy/public/puffer/javascripts/right-dialog.js +764 -0
- data/spec/dummy/public/puffer/javascripts/right-tabs.js +1139 -24
- data/spec/dummy/public/puffer/javascripts/right.js +5886 -89
- data/spec/dummy/public/puffer/stylesheets/puffer.css +1 -12
- data/spec/dummy/public/puffer/stylesheets/puffer_pages.css +4 -0
- data/spec/dummy/public/puffer/stylesheets/puffer_tree.css +51 -0
- data/spec/fabricators/pages_fabricator.rb +1 -1
- data/spec/models/page_spec.rb +15 -15
- metadata +33 -31
- data/README.rdoc +0 -3
- data/lib/puffer_pages/base.rb +0 -10
- data/spec/dummy/config/puffer.rb +0 -0
- data/spec/dummy/public/puffer/javascripts/right-autocompleter-src.js +0 -621
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-calendar-src.js +0 -1461
- data/spec/dummy/public/puffer/javascripts/right-calendar.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-in-edit-src.js +0 -369
- data/spec/dummy/public/puffer/javascripts/right-in-edit.js +0 -13
- data/spec/dummy/public/puffer/javascripts/right-in-edit.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-lightbox-src.js +0 -905
- data/spec/dummy/public/puffer/javascripts/right-lightbox.js +0 -24
- data/spec/dummy/public/puffer/javascripts/right-lightbox.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-sortable-src.js +0 -428
- data/spec/dummy/public/puffer/javascripts/right-sortable.js +0 -17
- data/spec/dummy/public/puffer/javascripts/right-sortable.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-src.js +0 -5892
- data/spec/dummy/public/puffer/javascripts/right-tabs.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right.js.gz +0 -0
@@ -1,905 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Lightbox feature for RightJS
|
3
|
-
* http://rightjs.org/ui/lightbox
|
4
|
-
*
|
5
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Lightbox = RightJS.Lightbox = (function(document, 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
|
-
* The filenames to include
|
18
|
-
*
|
19
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
20
|
-
*/
|
21
|
-
var R = RightJS,
|
22
|
-
$ = RightJS.$,
|
23
|
-
$$ = RightJS.$$,
|
24
|
-
$w = RightJS.$w,
|
25
|
-
$E = RightJS.$E,
|
26
|
-
$ext = RightJS.$ext,
|
27
|
-
Xhr = RightJS.Xhr,
|
28
|
-
Class = RightJS.Class,
|
29
|
-
Object = RightJS.Object,
|
30
|
-
Element = RightJS.Element,
|
31
|
-
Browser = RightJS.Browser;
|
32
|
-
|
33
|
-
// IE6 doesn't support position:fixed so it needs a crunch
|
34
|
-
Browser.IE6 = Browser.OLD && navigator.userAgent.indexOf("MSIE 6") > 0;
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
/**
|
44
|
-
* The widget units constructor
|
45
|
-
*
|
46
|
-
* @param String tag-name or Object methods
|
47
|
-
* @param Object methods
|
48
|
-
* @return Widget wrapper
|
49
|
-
*/
|
50
|
-
function Widget(tag_name, methods) {
|
51
|
-
if (!methods) {
|
52
|
-
methods = tag_name;
|
53
|
-
tag_name = 'DIV';
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* An Abstract Widget Unit
|
58
|
-
*
|
59
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
60
|
-
*/
|
61
|
-
var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
62
|
-
/**
|
63
|
-
* The common constructor
|
64
|
-
*
|
65
|
-
* @param Object options
|
66
|
-
* @param String optional tag name
|
67
|
-
* @return void
|
68
|
-
*/
|
69
|
-
initialize: function(key, options) {
|
70
|
-
this.key = key;
|
71
|
-
var args = [{'class': 'rui-' + key}];
|
72
|
-
|
73
|
-
// those two have different constructors
|
74
|
-
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
75
|
-
args.unshift(tag_name);
|
76
|
-
}
|
77
|
-
this.$super.apply(this, args);
|
78
|
-
|
79
|
-
if (RightJS.isString(options)) {
|
80
|
-
options = RightJS.$(options);
|
81
|
-
}
|
82
|
-
|
83
|
-
// if the options is another element then
|
84
|
-
// try to dynamically rewrap it with our widget
|
85
|
-
if (options instanceof RightJS.Element) {
|
86
|
-
this._ = options._;
|
87
|
-
if ('$listeners' in options) {
|
88
|
-
options.$listeners = options.$listeners;
|
89
|
-
}
|
90
|
-
options = {};
|
91
|
-
}
|
92
|
-
this.setOptions(options, this);
|
93
|
-
|
94
|
-
return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
|
95
|
-
},
|
96
|
-
|
97
|
-
// protected
|
98
|
-
|
99
|
-
/**
|
100
|
-
* Catches the options
|
101
|
-
*
|
102
|
-
* @param Object user-options
|
103
|
-
* @param Element element with contextual options
|
104
|
-
* @return void
|
105
|
-
*/
|
106
|
-
setOptions: function(options, element) {
|
107
|
-
element = element || this;
|
108
|
-
RightJS.Options.setOptions.call(this,
|
109
|
-
RightJS.Object.merge(options, eval("("+(
|
110
|
-
element.get('data-'+ this.key) || '{}'
|
111
|
-
)+")"))
|
112
|
-
);
|
113
|
-
return this;
|
114
|
-
}
|
115
|
-
});
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Creating the actual widget class
|
119
|
-
*
|
120
|
-
*/
|
121
|
-
var Klass = new RightJS.Class(AbstractWidget, methods);
|
122
|
-
|
123
|
-
// creating the widget related shortcuts
|
124
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
125
|
-
|
126
|
-
return Klass;
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
/**
|
131
|
-
* A shared module to create textual spinners
|
132
|
-
*
|
133
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
134
|
-
*/
|
135
|
-
var Spinner = new RightJS.Class(RightJS.Element, {
|
136
|
-
/**
|
137
|
-
* Constructor
|
138
|
-
*
|
139
|
-
* @param Number optional spinner size (4 by default)
|
140
|
-
* @return void
|
141
|
-
*/
|
142
|
-
initialize: function(size) {
|
143
|
-
this.$super('div', {'class': 'rui-spinner'});
|
144
|
-
this.dots = [];
|
145
|
-
|
146
|
-
for (var i=0; i < (size || 4); i++) {
|
147
|
-
this.dots.push(new RightJS.Element('div'));
|
148
|
-
}
|
149
|
-
|
150
|
-
this.dots[0].addClass('glowing');
|
151
|
-
this.insert(this.dots);
|
152
|
-
RightJS(this.shift).bind(this).periodical(300);
|
153
|
-
},
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Shifts the spinner elements
|
157
|
-
*
|
158
|
-
* @return void
|
159
|
-
*/
|
160
|
-
shift: function() {
|
161
|
-
if (this.visible()) {
|
162
|
-
var dot = this.dots.pop();
|
163
|
-
this.dots.unshift(dot);
|
164
|
-
this.insert(dot, 'top');
|
165
|
-
}
|
166
|
-
}
|
167
|
-
});
|
168
|
-
|
169
|
-
|
170
|
-
/**
|
171
|
-
* The lightbox widget
|
172
|
-
*
|
173
|
-
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
174
|
-
*/
|
175
|
-
var Lightbox = new Widget({
|
176
|
-
|
177
|
-
extend: {
|
178
|
-
version: '2.2.0',
|
179
|
-
|
180
|
-
EVENTS: $w('show hide load'),
|
181
|
-
|
182
|
-
Options: {
|
183
|
-
fxName: 'fade',
|
184
|
-
fxDuration: 300,
|
185
|
-
|
186
|
-
group: null, // a group marker
|
187
|
-
|
188
|
-
hideOnEsc: true,
|
189
|
-
hideOnOutClick: true,
|
190
|
-
showCloseButton: true,
|
191
|
-
|
192
|
-
cssRule: "a[data-lightbox]", // all lightbox links css-rule
|
193
|
-
|
194
|
-
// video links default size
|
195
|
-
mediaWidth: 425,
|
196
|
-
mediaHeight: 350
|
197
|
-
},
|
198
|
-
|
199
|
-
i18n: {
|
200
|
-
Close: 'Close',
|
201
|
-
Prev: 'Previous Image',
|
202
|
-
Next: 'Next Image'
|
203
|
-
},
|
204
|
-
|
205
|
-
// the supported image-urls regexp
|
206
|
-
Images: /\.(jpg|jpeg|gif|png|bmp)/,
|
207
|
-
|
208
|
-
// media content sources
|
209
|
-
Medias: [
|
210
|
-
[/(http:\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)/, '$1/v/$2', 'swf'],
|
211
|
-
[/(http:\/\/video.google.com)\/videoplay\?docid=([^&]+)/, '$1/googleplayer.swf?docId=$2', 'swf'],
|
212
|
-
[/(http:\/\/vimeo\.[a-z]+)\/([0-9]+).*?/, '$1/moogaloop.swf?clip_id=$2', 'swf']
|
213
|
-
]
|
214
|
-
},
|
215
|
-
|
216
|
-
/**
|
217
|
-
* basic constructor
|
218
|
-
*
|
219
|
-
* @param Object options override
|
220
|
-
* @param Element optional options holder
|
221
|
-
* @return void
|
222
|
-
*/
|
223
|
-
initialize: function(options, context) {
|
224
|
-
this
|
225
|
-
.$super('lightbox', {})
|
226
|
-
.setOptions(options, context)
|
227
|
-
.insert([
|
228
|
-
this.locker = new Locker(this.options),
|
229
|
-
this.dialog = new Dialog(this.options)
|
230
|
-
])
|
231
|
-
.on({
|
232
|
-
close: this._close,
|
233
|
-
next: this._next,
|
234
|
-
prev: this._prev
|
235
|
-
});
|
236
|
-
},
|
237
|
-
|
238
|
-
/**
|
239
|
-
* Extracting the rel="lightboux[groupname]" attributes
|
240
|
-
*
|
241
|
-
* @param Object options
|
242
|
-
* @param Element link with options
|
243
|
-
* @return Dialog this
|
244
|
-
*/
|
245
|
-
setOptions: function(options, context) {
|
246
|
-
this.$super(options, context);
|
247
|
-
|
248
|
-
if (context) {
|
249
|
-
var rel = context.get('rel');
|
250
|
-
if (rel && (rel = rel.match(/lightbox\[(.+?)\]/))) {
|
251
|
-
this.options.group = rel[1];
|
252
|
-
}
|
253
|
-
}
|
254
|
-
|
255
|
-
return this;
|
256
|
-
},
|
257
|
-
|
258
|
-
/**
|
259
|
-
* Sets the popup's title
|
260
|
-
*
|
261
|
-
* @param mixed string or element or somethin'
|
262
|
-
* @return Lighbox self
|
263
|
-
*/
|
264
|
-
setTitle: function(text) {
|
265
|
-
this.dialog.setTitle(text);
|
266
|
-
|
267
|
-
return this;
|
268
|
-
},
|
269
|
-
|
270
|
-
/**
|
271
|
-
* Shows the lightbox
|
272
|
-
*
|
273
|
-
* @param String/Array... content
|
274
|
-
* @return Lightbox this
|
275
|
-
*/
|
276
|
-
show: function(content) {
|
277
|
-
return this._showAnd(function() {
|
278
|
-
this.dialog.show(content, !content);
|
279
|
-
});
|
280
|
-
},
|
281
|
-
|
282
|
-
/**
|
283
|
-
* Hides the lightbox
|
284
|
-
*
|
285
|
-
* @return Lightbox this
|
286
|
-
*/
|
287
|
-
hide: function() {
|
288
|
-
Lightbox.current = null;
|
289
|
-
|
290
|
-
return this.$super(this.options.fxName, {
|
291
|
-
duration: this.options.fxDuration/3,
|
292
|
-
onFinish: R(function() {
|
293
|
-
this.fire('hide');
|
294
|
-
this.remove();
|
295
|
-
}).bind(this)
|
296
|
-
});
|
297
|
-
},
|
298
|
-
|
299
|
-
/**
|
300
|
-
* Loads up the data from url or a link
|
301
|
-
*
|
302
|
-
* @param String address or a link element
|
303
|
-
* @param Object Xhr options
|
304
|
-
* @return Lightbox this
|
305
|
-
*/
|
306
|
-
load: function(link, options) {
|
307
|
-
return this._showAnd(function() {
|
308
|
-
this.dialog.load(link, options);
|
309
|
-
});
|
310
|
-
},
|
311
|
-
|
312
|
-
/**
|
313
|
-
* Resizes the content block to the given size
|
314
|
-
*
|
315
|
-
* @param Hash size
|
316
|
-
* @return Lightbox this
|
317
|
-
*/
|
318
|
-
resize: function(size) {
|
319
|
-
this.dialog.resize(size);
|
320
|
-
return this;
|
321
|
-
},
|
322
|
-
|
323
|
-
// protected
|
324
|
-
|
325
|
-
// handles the 'close' event
|
326
|
-
_close: function(event) {
|
327
|
-
event.stop();
|
328
|
-
this.hide();
|
329
|
-
},
|
330
|
-
|
331
|
-
// handles the 'prev' event
|
332
|
-
_prev: function(event) {
|
333
|
-
event.stop();
|
334
|
-
Pager.prev();
|
335
|
-
},
|
336
|
-
|
337
|
-
// handles the 'next' event
|
338
|
-
_next: function(event) {
|
339
|
-
event.stop();
|
340
|
-
Pager.next();
|
341
|
-
},
|
342
|
-
|
343
|
-
// shows the lightbox element and then calls back
|
344
|
-
_showAnd: function(callback) {
|
345
|
-
if (Lightbox.current !== this) {
|
346
|
-
Lightbox.current = this;
|
347
|
-
|
348
|
-
// hidding all the hanging around lightboxes
|
349
|
-
$$('div.rui-lightbox').each('remove');
|
350
|
-
|
351
|
-
this.insertTo(document.body);
|
352
|
-
this.dialog.show('', true);
|
353
|
-
|
354
|
-
if (Browser.OLD) { // IE's get screwed by the transparency tricks
|
355
|
-
this.reposition();
|
356
|
-
Element.prototype.show.call(this);
|
357
|
-
callback.call(this);
|
358
|
-
} else {
|
359
|
-
this.setStyle('display:none');
|
360
|
-
Element.prototype.show.call(this, this.options.fxName, {
|
361
|
-
duration: this.options.fxDuration/2,
|
362
|
-
onFinish: R(function() {
|
363
|
-
callback.call(this);
|
364
|
-
this.fire('show');
|
365
|
-
}).bind(this)
|
366
|
-
});
|
367
|
-
}
|
368
|
-
} else {
|
369
|
-
callback.call(this);
|
370
|
-
}
|
371
|
-
|
372
|
-
return this;
|
373
|
-
},
|
374
|
-
|
375
|
-
// manually repositioning under IE6 browser
|
376
|
-
reposition: function() {
|
377
|
-
if (Browser.IE6) {
|
378
|
-
var win = $(window);
|
379
|
-
|
380
|
-
this.setStyle({
|
381
|
-
top: win.scrolls().y + 'px',
|
382
|
-
width: win.size().x + 'px',
|
383
|
-
height: win.size().y + 'px',
|
384
|
-
position: "absolute"
|
385
|
-
});
|
386
|
-
}
|
387
|
-
}
|
388
|
-
});
|
389
|
-
|
390
|
-
|
391
|
-
/**
|
392
|
-
* The class level interface
|
393
|
-
*
|
394
|
-
* @copyright (C) 2009 Nikolay Nemshilov
|
395
|
-
*/
|
396
|
-
Lightbox.extend({
|
397
|
-
hide: function() {
|
398
|
-
if (Lightbox.current) {
|
399
|
-
Lightbox.current.hide();
|
400
|
-
}
|
401
|
-
},
|
402
|
-
|
403
|
-
show: function() {
|
404
|
-
return this.inst('show', arguments);
|
405
|
-
},
|
406
|
-
|
407
|
-
load: function() {
|
408
|
-
return this.inst('load', arguments);
|
409
|
-
},
|
410
|
-
|
411
|
-
// private
|
412
|
-
|
413
|
-
inst: function(name, args) {
|
414
|
-
var inst = new Lightbox();
|
415
|
-
return inst[name].apply(inst, args);
|
416
|
-
}
|
417
|
-
});
|
418
|
-
|
419
|
-
|
420
|
-
/**
|
421
|
-
* Lightbox background locker element
|
422
|
-
*
|
423
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
424
|
-
*/
|
425
|
-
var Locker = new Class(Element, {
|
426
|
-
initialize: function(options) {
|
427
|
-
this.$super('div', {'class': 'rui-lightbox-locker'});
|
428
|
-
|
429
|
-
if (options.hideOnOutClick) {
|
430
|
-
this.onClick('fire', 'close');
|
431
|
-
}
|
432
|
-
}
|
433
|
-
});
|
434
|
-
|
435
|
-
|
436
|
-
/**
|
437
|
-
* The dialog element wrapper
|
438
|
-
*
|
439
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
440
|
-
*/
|
441
|
-
var Dialog = new Class(Element, {
|
442
|
-
/**
|
443
|
-
* Constructor
|
444
|
-
*
|
445
|
-
* @param Object options
|
446
|
-
* @return void
|
447
|
-
*/
|
448
|
-
initialize: function(options) {
|
449
|
-
var i18n = Lightbox.i18n;
|
450
|
-
|
451
|
-
this.options = options;
|
452
|
-
this.$super('div', {'class': 'rui-lightbox-dialog'});
|
453
|
-
|
454
|
-
// building up the
|
455
|
-
this.insert([
|
456
|
-
this.title = $E('div', {'class': 'rui-lightbox-title'}),
|
457
|
-
|
458
|
-
$E('div', {'class': 'rui-lightbox-body'}).insert(
|
459
|
-
$E('div', {'class': 'rui-lightbox-body-inner'}).insert([
|
460
|
-
this.locker = $E('div', {'class': 'rui-lightbox-body-locker'}).insert(new Spinner(4)),
|
461
|
-
this.scroller = $E('div', {'class': 'rui-lightbox-scroller'}).insert(
|
462
|
-
this.content = $E('div', {'class': 'rui-lightbox-content'})
|
463
|
-
)
|
464
|
-
])
|
465
|
-
),
|
466
|
-
|
467
|
-
$E('div', {'class': 'rui-lightbox-navigation'}).insert([
|
468
|
-
this.closeButton = $E('div', {'class': 'close', html: '×', title: i18n.Close}).onClick('fire', 'close'),
|
469
|
-
this.prevLink = $E('div', {'class': 'prev', html: '←', title: i18n.Prev}).onClick('fire', 'prev'),
|
470
|
-
this.nextLink = $E('div', {'class': 'next', html: '→', title: i18n.Next}).onClick('fire', 'next')
|
471
|
-
])
|
472
|
-
]);
|
473
|
-
|
474
|
-
// presetting the navigation state
|
475
|
-
this.prevLink.hide();
|
476
|
-
this.nextLink.hide();
|
477
|
-
|
478
|
-
if (!options.showCloseButton) {
|
479
|
-
this.closeButton.hide();
|
480
|
-
}
|
481
|
-
},
|
482
|
-
|
483
|
-
/**
|
484
|
-
* Sets the dialogue caption
|
485
|
-
*
|
486
|
-
* @param String title
|
487
|
-
* @return Dialog this
|
488
|
-
*/
|
489
|
-
setTitle: function(title) {
|
490
|
-
this.title.update(title||'');
|
491
|
-
},
|
492
|
-
|
493
|
-
/**
|
494
|
-
* Nicely resize the dialog box
|
495
|
-
*
|
496
|
-
* @param Object the end size
|
497
|
-
* @param Boolean use fx (false by default)
|
498
|
-
* @return Dialog this
|
499
|
-
*/
|
500
|
-
resize: function(end_size, with_fx) {
|
501
|
-
var win_size = this.parent().size(),
|
502
|
-
cur_size = this.scroller.size(),
|
503
|
-
cur_top = (win_size.y - this.size().y)/2,
|
504
|
-
dlg_diff = this.size().x - cur_size.x; // <- use for IE6 fixes
|
505
|
-
|
506
|
-
if (end_size) {
|
507
|
-
// getting the actual end-size
|
508
|
-
end_size = this.scroller.setStyle(end_size).size();
|
509
|
-
|
510
|
-
this.scroller.setStyle({
|
511
|
-
width: cur_size.x + 'px',
|
512
|
-
height: cur_size.y + 'px'
|
513
|
-
});
|
514
|
-
} else {
|
515
|
-
// using the content block size
|
516
|
-
end_size = this.content.size();
|
517
|
-
}
|
518
|
-
|
519
|
-
// checking the constraints
|
520
|
-
var threshold = 100; // px
|
521
|
-
if ((end_size.x + threshold) > win_size.x) { end_size.x = win_size.x - threshold; }
|
522
|
-
if ((end_size.y + threshold) > win_size.y) { end_size.y = win_size.y - threshold; }
|
523
|
-
|
524
|
-
// the actual resize and reposition
|
525
|
-
var end_top = (cur_top * 2 + cur_size.y - end_size.y) / 2;
|
526
|
-
var dialog = this._.style, content = this.scroller._.style;
|
527
|
-
|
528
|
-
if (RightJS.Fx && with_fx && (end_size.x != cur_size.x || end_size.y != cur_size.y)) {
|
529
|
-
|
530
|
-
$ext(new RightJS.Fx(this, {duration: this.options.fxDuration}), {
|
531
|
-
render: function(delta) {
|
532
|
-
content.width = (cur_size.x + (end_size.x - cur_size.x) * delta) + 'px';
|
533
|
-
content.height = (cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
|
534
|
-
dialog.top = (cur_top + (end_top - cur_top) * delta) + 'px';
|
535
|
-
|
536
|
-
if (Browser.IE6) {
|
537
|
-
dialog.width = (dlg_diff + cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
|
538
|
-
}
|
539
|
-
}
|
540
|
-
}).onFinish(R(this.unlock).bind(this)).start();
|
541
|
-
|
542
|
-
} else {
|
543
|
-
// no-fx direct assignment
|
544
|
-
content.width = end_size.x + 'px';
|
545
|
-
content.height = end_size.y + 'px';
|
546
|
-
dialog.top = end_top + 'px';
|
547
|
-
|
548
|
-
if (Browser.IE6) {
|
549
|
-
dialog.width = (dlg_diff + end_size.x) + 'px';
|
550
|
-
}
|
551
|
-
|
552
|
-
if (!this.request) { this.unlock(); }
|
553
|
-
}
|
554
|
-
|
555
|
-
return this;
|
556
|
-
},
|
557
|
-
|
558
|
-
/**
|
559
|
-
* Shows the content
|
560
|
-
*
|
561
|
-
* @param mixed content String/Element/Array and so one
|
562
|
-
* @return Dialog this
|
563
|
-
*/
|
564
|
-
show: function(content, no_fx) {
|
565
|
-
this.content.update(content || '');
|
566
|
-
this.resize(null, !no_fx);
|
567
|
-
},
|
568
|
-
|
569
|
-
/**
|
570
|
-
* Loads up the data from the link
|
571
|
-
*
|
572
|
-
* @param mixed String url address or a link element
|
573
|
-
* @param Object xhr-options
|
574
|
-
* @return void
|
575
|
-
*/
|
576
|
-
load: function(url, options) {
|
577
|
-
if (url instanceof Element) {
|
578
|
-
this.setTitle(url.get('title'));
|
579
|
-
url = url.get('href');
|
580
|
-
}
|
581
|
-
|
582
|
-
Pager.show(this, url);
|
583
|
-
this.lock().cancel();
|
584
|
-
|
585
|
-
// defined in the loader.js file
|
586
|
-
this.request = new Loader(url, options, R(function(content, no_fx) {
|
587
|
-
this.request = null;
|
588
|
-
this.show(content, no_fx);
|
589
|
-
}).bind(this));
|
590
|
-
|
591
|
-
return this.resize(); // the look might be changed for a media-type
|
592
|
-
},
|
593
|
-
|
594
|
-
/**
|
595
|
-
* Cancels a currently loading request
|
596
|
-
*
|
597
|
-
* @return Dialog this
|
598
|
-
*/
|
599
|
-
cancel: function() {
|
600
|
-
if (this.request) {
|
601
|
-
this.request.cancel();
|
602
|
-
}
|
603
|
-
|
604
|
-
return this;
|
605
|
-
},
|
606
|
-
|
607
|
-
/**
|
608
|
-
* Shows the loading lock
|
609
|
-
*
|
610
|
-
* @return Dialog this
|
611
|
-
*/
|
612
|
-
lock: function() {
|
613
|
-
this.locker.setStyle('opacity:1;display:block').insertTo(this.scroller, 'before');
|
614
|
-
return this;
|
615
|
-
},
|
616
|
-
|
617
|
-
/**
|
618
|
-
* Hides the loading lock
|
619
|
-
*
|
620
|
-
* @return Dialog this
|
621
|
-
*/
|
622
|
-
unlock: function() {
|
623
|
-
this.locker.remove(R(this.content.html()).blank() ? null : 'fade', {
|
624
|
-
duration: this.options.fxDuration * 2/3
|
625
|
-
});
|
626
|
-
|
627
|
-
return this;
|
628
|
-
}
|
629
|
-
});
|
630
|
-
|
631
|
-
|
632
|
-
/**
|
633
|
-
* Xhr/images/medias loading module
|
634
|
-
*
|
635
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
636
|
-
*/
|
637
|
-
var Loader = new Class({
|
638
|
-
/**
|
639
|
-
* Constructor
|
640
|
-
*
|
641
|
-
* @param String url address
|
642
|
-
* @param Object Xhr options
|
643
|
-
* @param Function on-finish callback
|
644
|
-
*/
|
645
|
-
initialize: function(url, options, on_finish) {
|
646
|
-
// adjusting the dialog look for different media-types
|
647
|
-
if (this.isImage(url, on_finish)) {
|
648
|
-
Lightbox.current.addClass('rui-lightbox-image');
|
649
|
-
} else if (this.isMedia(url, on_finish)) {
|
650
|
-
Lightbox.current.addClass('rui-lightbox-media');
|
651
|
-
} else {
|
652
|
-
this.xhr = new Xhr(url,
|
653
|
-
Object.merge({method: 'get'}, options)
|
654
|
-
).onComplete(function() {
|
655
|
-
on_finish(this.text);
|
656
|
-
}).send();
|
657
|
-
}
|
658
|
-
},
|
659
|
-
|
660
|
-
/**
|
661
|
-
* Cancels the request
|
662
|
-
*
|
663
|
-
* @return Loader this
|
664
|
-
*/
|
665
|
-
cancel: function() {
|
666
|
-
if (this.xhr) {
|
667
|
-
this.xhr.cancel();
|
668
|
-
} else if (this.img) {
|
669
|
-
this.img.onload = function() {};
|
670
|
-
}
|
671
|
-
},
|
672
|
-
|
673
|
-
// protected
|
674
|
-
|
675
|
-
// tries to initialize it as an image loading
|
676
|
-
isImage: function(url, on_finish) {
|
677
|
-
if (url.match(Lightbox.Images)) {
|
678
|
-
var img = this.img = $E('img')._;
|
679
|
-
img.onload = function() {
|
680
|
-
on_finish(img);
|
681
|
-
};
|
682
|
-
img.src = url;
|
683
|
-
return true;
|
684
|
-
}
|
685
|
-
},
|
686
|
-
|
687
|
-
// tries to initialize it as a flash-element
|
688
|
-
isMedia: function(url, on_finish) {
|
689
|
-
var media = R(Lightbox.Medias).map(function(desc) {
|
690
|
-
return url.match(desc[0]) ? this.buildEmbed(
|
691
|
-
url.replace(desc[0], desc[1]), desc[2]) : null;
|
692
|
-
}, this).compact()[0];
|
693
|
-
|
694
|
-
if (media) {
|
695
|
-
on_finish(media, true);
|
696
|
-
return true;
|
697
|
-
}
|
698
|
-
},
|
699
|
-
|
700
|
-
// builds an embedded media block
|
701
|
-
buildEmbed: function(url, type) {
|
702
|
-
var media_types = {
|
703
|
-
swf: [
|
704
|
-
'D27CDB6E-AE6D-11cf-96B8-444553540000',
|
705
|
-
'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
|
706
|
-
'application/x-shockwave-flash'
|
707
|
-
]
|
708
|
-
},
|
709
|
-
options = Lightbox.current ? Lightbox.current.options : Lightbox.Options,
|
710
|
-
sizes = ' width="'+ options.mediaWidth + '" height="'+ options.mediaHeight + '"';
|
711
|
-
|
712
|
-
return '<object classid="clsid:' + media_types[type][0] +
|
713
|
-
'" codebase="' + media_types[type][1] + '"'+ sizes + '>' +
|
714
|
-
'<param name="src" value="'+ url +'" />'+
|
715
|
-
'<embed src="'+ url +'" type="'+ media_types[type][2]+'"'+ sizes + ' />' +
|
716
|
-
'</object>';
|
717
|
-
}
|
718
|
-
|
719
|
-
});
|
720
|
-
|
721
|
-
|
722
|
-
/**
|
723
|
-
* Processes the link-groups showing things in a single Lightbox
|
724
|
-
*
|
725
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
726
|
-
*/
|
727
|
-
var Pager = {
|
728
|
-
/**
|
729
|
-
* Checks and shows the pager links on the dialog
|
730
|
-
*
|
731
|
-
* @param Dialog dialog
|
732
|
-
* @param String url-address
|
733
|
-
* @return void
|
734
|
-
*/
|
735
|
-
show: function(dialog, url) {
|
736
|
-
if (dialog.options.group) {
|
737
|
-
this.dialog = dialog;
|
738
|
-
this.links = this.find(dialog.options.group);
|
739
|
-
this.link = this.links.first(function(link) {
|
740
|
-
return link.get('href') === url;
|
741
|
-
});
|
742
|
-
|
743
|
-
var index = this.links.indexOf(this.link), size = this.links.length;
|
744
|
-
|
745
|
-
dialog.prevLink[size && index > 0 ? 'show' : 'hide']();
|
746
|
-
dialog.nextLink[size && index < size - 1 ? 'show' : 'hide']();
|
747
|
-
} else {
|
748
|
-
this.dialog = null;
|
749
|
-
}
|
750
|
-
},
|
751
|
-
|
752
|
-
/**
|
753
|
-
* Shows the prev link
|
754
|
-
*
|
755
|
-
* @return void
|
756
|
-
*/
|
757
|
-
prev: function() {
|
758
|
-
if (this.dialog && !this.timer) {
|
759
|
-
var id = this.links.indexOf(this.link),
|
760
|
-
link = this.links[id - 1];
|
761
|
-
|
762
|
-
if (link) {
|
763
|
-
this.dialog.load(link);
|
764
|
-
this.timeout();
|
765
|
-
}
|
766
|
-
}
|
767
|
-
},
|
768
|
-
|
769
|
-
/**
|
770
|
-
* Shows the next link
|
771
|
-
*
|
772
|
-
* @return void
|
773
|
-
*/
|
774
|
-
next: function() {
|
775
|
-
if (this.dialog && !this.timer) {
|
776
|
-
var id = this.links.indexOf(this.link),
|
777
|
-
link = this.links[id + 1];
|
778
|
-
|
779
|
-
if (link) {
|
780
|
-
this.dialog.load(link);
|
781
|
-
this.timeout();
|
782
|
-
}
|
783
|
-
}
|
784
|
-
},
|
785
|
-
|
786
|
-
// private
|
787
|
-
|
788
|
-
// finding the links list
|
789
|
-
find: function(group) {
|
790
|
-
return $$('a').filter(function(link) {
|
791
|
-
var data = link.get('data-lightbox');
|
792
|
-
var rel = link.get('rel');
|
793
|
-
|
794
|
-
return (data && eval("("+ data + ")").group === group) ||
|
795
|
-
(rel && rel.indexOf('lightbox['+ group + ']') > -1);
|
796
|
-
});
|
797
|
-
},
|
798
|
-
|
799
|
-
// having a little nap to prevent ugly quick scrolling
|
800
|
-
timeout: function() {
|
801
|
-
this.timer = R(function() {
|
802
|
-
Pager.timer = null;
|
803
|
-
}).delay(300);
|
804
|
-
}
|
805
|
-
};
|
806
|
-
|
807
|
-
|
808
|
-
/**
|
809
|
-
* document level hooks
|
810
|
-
*
|
811
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
812
|
-
*/
|
813
|
-
|
814
|
-
$(document).on({
|
815
|
-
/**
|
816
|
-
* Catches clicks on the target links
|
817
|
-
*
|
818
|
-
* @param Event click
|
819
|
-
* @return void
|
820
|
-
*/
|
821
|
-
click: function(event) {
|
822
|
-
var target = event.find(Lightbox.Options.cssRule) || event.find('a[rel^=lightbox]');
|
823
|
-
|
824
|
-
if (target) {
|
825
|
-
event.stop();
|
826
|
-
new Lightbox({}, target).load(target);
|
827
|
-
}
|
828
|
-
},
|
829
|
-
|
830
|
-
/**
|
831
|
-
* Catches the mousewheel event and tries to scroll
|
832
|
-
* the list of objects on the lightbox
|
833
|
-
*
|
834
|
-
* @param Event mousewheel
|
835
|
-
* @return void
|
836
|
-
*/
|
837
|
-
mousewheel: function(event) {
|
838
|
-
if (Lightbox.current) {
|
839
|
-
var target = event.target, box = target.parent('div.rui-lightbox-content');
|
840
|
-
|
841
|
-
if (!box || target.getStyle('overflow') === 'visible') {
|
842
|
-
event.stop();
|
843
|
-
}
|
844
|
-
|
845
|
-
Lightbox.current.fire((event._.detail || -event._.wheelDelta) < 0 ? 'prev' : 'next');
|
846
|
-
}
|
847
|
-
},
|
848
|
-
|
849
|
-
/**
|
850
|
-
* Handles the navigation form a keyboard
|
851
|
-
*
|
852
|
-
* @param Event keydown
|
853
|
-
* @return void
|
854
|
-
*/
|
855
|
-
keydown: function(event) {
|
856
|
-
var lightbox = Lightbox.current, name = ({
|
857
|
-
27: 'close', // Esc
|
858
|
-
33: 'prev', // PageUp
|
859
|
-
37: 'prev', // Left
|
860
|
-
38: 'prev', // Up
|
861
|
-
39: 'next', // Right
|
862
|
-
40: 'next', // Down
|
863
|
-
34: 'next' // PageDown
|
864
|
-
})[event.keyCode];
|
865
|
-
|
866
|
-
if (lightbox && name) {
|
867
|
-
if (name !== 'close' || lightbox.options.hideOnEsc) {
|
868
|
-
event.stop();
|
869
|
-
lightbox.fire(name);
|
870
|
-
}
|
871
|
-
}
|
872
|
-
}
|
873
|
-
});
|
874
|
-
|
875
|
-
$(window).on({
|
876
|
-
resize: function() {
|
877
|
-
if (Lightbox.current) {
|
878
|
-
Lightbox.current.reposition();
|
879
|
-
Lightbox.current.dialog.resize();
|
880
|
-
}
|
881
|
-
},
|
882
|
-
|
883
|
-
scroll: function(event) {
|
884
|
-
if (Lightbox.current && Browser.IE6) {
|
885
|
-
Lightbox.current.reposition();
|
886
|
-
}
|
887
|
-
}
|
888
|
-
});
|
889
|
-
(function() {
|
890
|
-
var style = document.createElement('style'),
|
891
|
-
rules = document.createTextNode("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-lightbox{position:fixed;top:0;left:0;float:none;width:100%;height:100%;margin:0;padding:0;background:none;border:none;text-align:center;z-index:9999;z-index/*\\**/:auto\\9;}div.rui-lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);cursor:default;z-index/*\\**/:9990\\9;}div.rui-lightbox-dialog{display:inline-block; *display:inline; *zoom:1;position:relative;text-align:left;z-index/*\\**/:9999\\9;}div.rui-lightbox-title{height:1.2em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica}div.rui-lightbox-body{background-color:#FFF;padding:1em;border-radius:.5em;-moz-border-radius:.5em;-webkit-border-radius:.5em}div.rui-lightbox-body-inner{position:relative}div.rui-lightbox-scroller{overflow:hidden}div.rui-lightbox-content{display:inline-block; *display:inline; *zoom:1;min-height:10em;min-width:10em;_height:10em;_width:10em}div.rui-lightbox-body-locker{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;opacity:0;filter:alpha(opacity=0)}div.rui-lightbox-body-locker div.rui-spinner{position:absolute;right:0;bottom:0;border:none;background:none;font-size:150%}div.rui-lightbox-navigation{color:#888;font-size:160%;font-family:Arial;height:1em;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-lightbox-navigation div{cursor:pointer;position:absolute}div.rui-lightbox-navigation div:hover{color:white}div.rui-lightbox-navigation div.next{left:2em}div.rui-lightbox-navigation div.close{right:0}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.rui-lightbox-image div.rui-lightbox-content,div.rui-lightbox-media div.rui-lightbox-content{min-height:12em;min-width:12em;_height:12em;_width:12em}div.rui-lightbox-image div.rui-lightbox-content img{vertical-align:middle}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-image div.rui-lightbox-body-locker,div.rui-lightbox-media div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body-locker{background-color:#D8D8D8}div.rui-lightbox-image div.rui-lightbox-body-locker div.rui-spinner,div.rui-lightbox-media div.rui-lightbox-body-locker div.rui-spinner{bottom:.5em;right:.5em}");
|
892
|
-
|
893
|
-
style.type = 'text/css';
|
894
|
-
|
895
|
-
if(style.styleSheet) {
|
896
|
-
style.styleSheet.cssText = rules.nodeValue;
|
897
|
-
} else {
|
898
|
-
style.appendChild(rules);
|
899
|
-
}
|
900
|
-
|
901
|
-
document.getElementsByTagName('head')[0].appendChild(style);
|
902
|
-
})();
|
903
|
-
|
904
|
-
return Lightbox;
|
905
|
-
})(document, RightJS);
|