right-rails 0.3.0
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/MIT-LICENSE +20 -0
- data/README.textile +50 -0
- data/Rakefile +23 -0
- data/generators/right_rails/right_rails_generator.rb +41 -0
- data/generators/right_rails/templates/iframed.html.erb +10 -0
- data/generators/right_scaffold/right_scaffold_generator.rb +53 -0
- data/generators/right_scaffold/templates/controller.rb +99 -0
- data/generators/right_scaffold/templates/helper.rb +2 -0
- data/generators/right_scaffold/templates/layout.html.erb +18 -0
- data/generators/right_scaffold/templates/style.css +54 -0
- data/generators/right_scaffold/templates/view__form.html.erb +16 -0
- data/generators/right_scaffold/templates/view__item.html.erb +13 -0
- data/generators/right_scaffold/templates/view_edit.html.erb +6 -0
- data/generators/right_scaffold/templates/view_index.html.erb +9 -0
- data/generators/right_scaffold/templates/view_new.html.erb +5 -0
- data/generators/right_scaffold/templates/view_show.html.erb +10 -0
- data/init.rb +12 -0
- data/javascripts/right-autocompleter-src.js +303 -0
- data/javascripts/right-autocompleter.js +9 -0
- data/javascripts/right-behavior-src.js +240 -0
- data/javascripts/right-behavior.js +8 -0
- data/javascripts/right-calendar-src.js +855 -0
- data/javascripts/right-calendar.js +9 -0
- data/javascripts/right-dnd-src.js +555 -0
- data/javascripts/right-dnd.js +9 -0
- data/javascripts/right-effects-src.js +425 -0
- data/javascripts/right-effects.js +6 -0
- data/javascripts/right-events-src.js +369 -0
- data/javascripts/right-events.js +6 -0
- data/javascripts/right-json-src.js +176 -0
- data/javascripts/right-json.js +6 -0
- data/javascripts/right-lightbox-src.js +597 -0
- data/javascripts/right-lightbox.js +9 -0
- data/javascripts/right-rails-src.js +269 -0
- data/javascripts/right-rails.js +9 -0
- data/javascripts/right-rater-src.js +248 -0
- data/javascripts/right-rater.js +9 -0
- data/javascripts/right-selectable-src.js +507 -0
- data/javascripts/right-selectable.js +7 -0
- data/javascripts/right-slider-src.js +291 -0
- data/javascripts/right-slider.js +7 -0
- data/javascripts/right-sortable-src.js +221 -0
- data/javascripts/right-sortable.js +9 -0
- data/javascripts/right-src.js +4939 -0
- data/javascripts/right-tabs-src.js +776 -0
- data/javascripts/right-tabs.js +6 -0
- data/javascripts/right-tooltips-src.js +130 -0
- data/javascripts/right-tooltips.js +9 -0
- data/javascripts/right-ui-i18n-de.js +29 -0
- data/javascripts/right-ui-i18n-en-us.js +11 -0
- data/javascripts/right-ui-i18n-es.js +29 -0
- data/javascripts/right-ui-i18n-fr.js +29 -0
- data/javascripts/right-ui-i18n-jp.js +33 -0
- data/javascripts/right-ui-i18n-ru.js +29 -0
- data/javascripts/right-ui-i18n-uk.js +29 -0
- data/javascripts/right.js +10 -0
- data/lib/right-rails.rb +11 -0
- data/lib/right_rails/controller_extensions.rb +85 -0
- data/lib/right_rails/helpers/basic.rb +111 -0
- data/lib/right_rails/helpers/forms.rb +239 -0
- data/lib/right_rails/helpers/misc.rb +164 -0
- data/lib/right_rails/helpers/rails.rb +166 -0
- data/lib/right_rails/helpers.rb +5 -0
- data/lib/right_rails/java_script_generator.rb +313 -0
- data/lib/right_rails.rb +6 -0
- data/spec/lib/right_rails/controller_extensions_spec.rb +60 -0
- data/spec/lib/right_rails/helpers/basic_spec.rb +74 -0
- data/spec/lib/right_rails/helpers/forms_spec.rb +51 -0
- data/spec/lib/right_rails/helpers/misc_spec.rb +120 -0
- data/spec/lib/right_rails/helpers/rails_spec.rb +149 -0
- data/spec/lib/right_rails/java_script_generator_spec.rb +317 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +15 -0
- metadata +128 -0
@@ -0,0 +1,597 @@
|
|
1
|
+
/**
|
2
|
+
* The lightbox widget implemented with RightJS
|
3
|
+
*
|
4
|
+
* Home page: http://rightjs.org/ui/lightbox
|
5
|
+
*
|
6
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
7
|
+
*/
|
8
|
+
if (!RightJS || !Fx) { throw "Gimme RightJS with Fx. Please." };
|
9
|
+
|
10
|
+
/**
|
11
|
+
* The lightbox widget
|
12
|
+
*
|
13
|
+
* Credits:
|
14
|
+
* Inspired by and monkeys the Lightbox 2 project
|
15
|
+
* -- http://www.huddletogether.com/projects/lightbox2/
|
16
|
+
* Copyright (C) Lokesh Dhakar
|
17
|
+
*
|
18
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
19
|
+
*/
|
20
|
+
Browser.IE6 = navigator.userAgent.indexOf("MSIE 6") != -1;
|
21
|
+
var Lightbox = new Class({
|
22
|
+
include: Options,
|
23
|
+
|
24
|
+
extend: {
|
25
|
+
Version: "1.0.0",
|
26
|
+
|
27
|
+
Options: {
|
28
|
+
endOpacity: 0.8,
|
29
|
+
fxDuration: 200,
|
30
|
+
hideOnEsc: true,
|
31
|
+
hideOnOutClick: true,
|
32
|
+
showCloseButton: true,
|
33
|
+
blockContent: false,
|
34
|
+
relName: 'lightbox'
|
35
|
+
},
|
36
|
+
|
37
|
+
i18n: {
|
38
|
+
CloseText: '×',
|
39
|
+
CloseTitle: 'Close',
|
40
|
+
PrevText: '‹‹‹',
|
41
|
+
PrevTitle: 'Previous Image',
|
42
|
+
NextText: '›››',
|
43
|
+
NextTitle: 'Next Image'
|
44
|
+
},
|
45
|
+
|
46
|
+
boxes: [],
|
47
|
+
|
48
|
+
// scans the page for auto-discoverable lighbox links
|
49
|
+
rescan: function() {
|
50
|
+
var key = Lightbox.Options.relName;
|
51
|
+
var get_options = function(element) {
|
52
|
+
var data = element.get('data-'+key+'-options');
|
53
|
+
return eval('('+data+')') || {};
|
54
|
+
};
|
55
|
+
|
56
|
+
// grabbing the singles
|
57
|
+
$$('a[rel='+key+']').each(function(a) {
|
58
|
+
if (!a.showLightbox) {
|
59
|
+
var options = get_options(a);
|
60
|
+
a.showLightbox = function(event) {
|
61
|
+
event.stop();
|
62
|
+
new Lightbox(options).show(this);
|
63
|
+
};
|
64
|
+
a.onClick('showLightbox');
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
// grabbing the roadtrip
|
69
|
+
var roadtrip = $$('a[rel="'+key+'[roadtrip]"]');
|
70
|
+
roadtrip.each(function(a) {
|
71
|
+
// removing the listener case the roadmap might get changed
|
72
|
+
if (a.showLightbox) {
|
73
|
+
a.stopObserving(a.showLightbox);
|
74
|
+
}
|
75
|
+
|
76
|
+
var options = get_options(a);
|
77
|
+
|
78
|
+
a.roadtrip = roadtrip;
|
79
|
+
a.showLightbox = function(event) {
|
80
|
+
event.stop();
|
81
|
+
new Lightbox(options).show(this);
|
82
|
+
};
|
83
|
+
a.onClick(a.showLightbox);
|
84
|
+
});
|
85
|
+
}
|
86
|
+
},
|
87
|
+
|
88
|
+
/**
|
89
|
+
* basic constructor
|
90
|
+
*
|
91
|
+
* @param Object options override
|
92
|
+
*/
|
93
|
+
initialize: function(options) {
|
94
|
+
this.setOptions(options).build().connectEvents();
|
95
|
+
|
96
|
+
Lightbox.boxes.push(this);
|
97
|
+
},
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Sets the popup's title
|
101
|
+
*
|
102
|
+
* @param mixed string or element or somethin'
|
103
|
+
* @return Lighbox self
|
104
|
+
*/
|
105
|
+
setTitle: function(txt) {
|
106
|
+
this.caption.fade('out', {
|
107
|
+
duration: this.options.fxDuration/2,
|
108
|
+
onFinish: function() {
|
109
|
+
this.caption.update(txt).fade('in', {duration: this.options.fxDuration/2});
|
110
|
+
}.bind(this)
|
111
|
+
});
|
112
|
+
|
113
|
+
return this;
|
114
|
+
},
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Hides the box
|
118
|
+
*
|
119
|
+
* @return Lightbox self
|
120
|
+
*/
|
121
|
+
hide: function() {
|
122
|
+
this.element.hide('fade', {
|
123
|
+
duration: this.options.fxDuration/2,
|
124
|
+
onFinish: this.element.remove.bind(this.element)
|
125
|
+
});
|
126
|
+
return this;
|
127
|
+
},
|
128
|
+
|
129
|
+
/**
|
130
|
+
* shows the lightbox with the content
|
131
|
+
*
|
132
|
+
* @param mixed content String, Element, Array, NodeList, ....
|
133
|
+
* @return Lightbox self
|
134
|
+
*/
|
135
|
+
show: function(content, size) {
|
136
|
+
return this.showingSelf(function() {
|
137
|
+
this.lock();
|
138
|
+
this.content.update(content || '');
|
139
|
+
this.resize(size);
|
140
|
+
}.bind(this));
|
141
|
+
},
|
142
|
+
|
143
|
+
/**
|
144
|
+
* resizes the dialogue to fit the content
|
145
|
+
*
|
146
|
+
* @param Object {x:.., y:..} optional end size definition
|
147
|
+
* @return Lightbox self
|
148
|
+
*/
|
149
|
+
resize: function(size, no_fx) {
|
150
|
+
this.dialog.style.top = (window.sizes().y - this.dialog.sizes().y) / 2 + 'px';
|
151
|
+
|
152
|
+
var body_style = this.contentSize(size);
|
153
|
+
var height_diff = this.dialog.sizes().y - this.body.sizes().y;
|
154
|
+
var body_height = body_style.height.toInt() || this.minBodyHeight();
|
155
|
+
var dialog_style = {
|
156
|
+
top: (this.element.sizes().y - body_height - height_diff)/2 + 'px'
|
157
|
+
};
|
158
|
+
|
159
|
+
// IE6 screws with the dialog width
|
160
|
+
if (Browser.IE6) {
|
161
|
+
var padding = this.bodyWrap.getStyle('padding').toInt() > 0 ? 15 : 0;
|
162
|
+
this.bodyWrap.setStyle('padding: '+padding+'px');
|
163
|
+
|
164
|
+
dialog_style.width = (body_style.width.toInt() + padding * 2) + 'px';
|
165
|
+
}
|
166
|
+
|
167
|
+
if (no_fx === true) {
|
168
|
+
this.body.setStyle(body_style);
|
169
|
+
this.dialog.setStyle(dialog_style);
|
170
|
+
this.loading = false;
|
171
|
+
} else {
|
172
|
+
this.resizeFx(body_style, dialog_style);
|
173
|
+
}
|
174
|
+
|
175
|
+
return this;
|
176
|
+
},
|
177
|
+
|
178
|
+
// protected
|
179
|
+
|
180
|
+
// locks the body
|
181
|
+
lock: function() {
|
182
|
+
this.bodyLock.removeClass('lightbox-body-lock-transparent').removeClass('lightbox-body-lock-loading').show();
|
183
|
+
if (Browser.OLD) this.bodyLock.setStyle("opacity: 1");
|
184
|
+
return this;
|
185
|
+
},
|
186
|
+
|
187
|
+
// unlocks the body
|
188
|
+
unlock: function() {
|
189
|
+
if (this.options.blockContent) {
|
190
|
+
this.bodyLock.addClass('lightbox-body-lock-transparent');
|
191
|
+
} else {
|
192
|
+
this.bodyLock.hide();
|
193
|
+
}
|
194
|
+
return this;
|
195
|
+
},
|
196
|
+
|
197
|
+
// resize specific lock
|
198
|
+
resizeLock: function() {
|
199
|
+
this.lock().content.hide();
|
200
|
+
},
|
201
|
+
|
202
|
+
// resize specific unlock
|
203
|
+
resizeUnlock: function() {
|
204
|
+
this.unlock().content.show('fade', {
|
205
|
+
duration: this.options.fxDuration/2
|
206
|
+
});
|
207
|
+
this.loading = false;
|
208
|
+
},
|
209
|
+
|
210
|
+
// returns the content size hash
|
211
|
+
contentSize: function(size) {
|
212
|
+
var size = size === this.$listeners ? null : size,
|
213
|
+
max_width = this.element.offsetWidth * 0.8,
|
214
|
+
max_height = this.element.offsetHeight * 0.8;
|
215
|
+
|
216
|
+
if (size) this.content.setStyle(size);
|
217
|
+
|
218
|
+
size = this.content.sizes();
|
219
|
+
|
220
|
+
return {
|
221
|
+
width: (size.x > max_width ? max_width : size.x)+"px",
|
222
|
+
height: (size.y > max_height ? max_height : size.y)+"px"
|
223
|
+
};
|
224
|
+
},
|
225
|
+
|
226
|
+
// adjusts the box size so that it closed the whole window
|
227
|
+
boxResize: function(resize) {
|
228
|
+
this.element.resize(window.sizes());
|
229
|
+
|
230
|
+
// IE6 needs to handle the locker position and size manually
|
231
|
+
if (Browser.IE6) {
|
232
|
+
this.locker.resize(window.sizes());
|
233
|
+
|
234
|
+
this.element.style.position = 'absolute';
|
235
|
+
this.element.style.top = document.documentElement.scrollTop + 'px';
|
236
|
+
}
|
237
|
+
|
238
|
+
return this.resize(false, true);
|
239
|
+
},
|
240
|
+
|
241
|
+
// performs an action showing the lighbox
|
242
|
+
showingSelf: function(callback) {
|
243
|
+
Lightbox.boxes.without(this).each('hide');
|
244
|
+
|
245
|
+
if (this.element.hidden()) {
|
246
|
+
this.locker.setStyle('opacity:0');
|
247
|
+
this.dialog.setStyle('opacity:0');
|
248
|
+
|
249
|
+
this.element.insertTo(document.body).show();
|
250
|
+
|
251
|
+
this.boxResize();
|
252
|
+
|
253
|
+
this.locker.morph({opacity: this.options.endOpacity}, {duration: this.options.fxDuration});
|
254
|
+
this.dialog.morph({opacity: 1}, {duration: this.options.fxDuration});
|
255
|
+
|
256
|
+
callback.delay(this.options.fxDuration);
|
257
|
+
} else {
|
258
|
+
callback();
|
259
|
+
}
|
260
|
+
return this;
|
261
|
+
},
|
262
|
+
|
263
|
+
// builds the basic structure
|
264
|
+
build: function() {
|
265
|
+
this.element = this.E('lightbox').setStyle('display: none');
|
266
|
+
this.locker = this.E('lightbox-locker', this.element);
|
267
|
+
this.dialog = this.E('lightbox-dialog', this.element);
|
268
|
+
this.caption = this.E('lightbox-caption', this.dialog);
|
269
|
+
this.bodyWrap = this.E('lightbox-body-wrap', this.dialog);
|
270
|
+
this.body = this.E('lightbox-body', this.bodyWrap);
|
271
|
+
this.content = this.E('lightbox-content', this.body);
|
272
|
+
this.bodyLock = this.E('lightbox-body-lock', this.body).hide();
|
273
|
+
|
274
|
+
// the close button if asked
|
275
|
+
if (this.options.showCloseButton) {
|
276
|
+
this.closeButton = this.E('lightbox-close-button', this.dialog)
|
277
|
+
.onClick(this.hide.bind(this)).update(Lightbox.i18n.CloseText).set('title', Lightbox.i18n.CloseTitle);
|
278
|
+
}
|
279
|
+
|
280
|
+
if (this.options.hideOnOutClick) {
|
281
|
+
this.locker.onClick(this.hide.bind(this));
|
282
|
+
}
|
283
|
+
|
284
|
+
document.on('mousewheel', function(e) {
|
285
|
+
if (this.element.visible()) {
|
286
|
+
e.stop();
|
287
|
+
this[(e.detail || -e.wheelDelta) < 0 ? 'showPrev' : 'showNext']();
|
288
|
+
}
|
289
|
+
}.bind(this));
|
290
|
+
|
291
|
+
return this;
|
292
|
+
},
|
293
|
+
|
294
|
+
// connects the events handling for the box
|
295
|
+
connectEvents: function() {
|
296
|
+
if (this.options.hideOnEsc) {
|
297
|
+
document.onKeydown(function(event) {
|
298
|
+
if (event.keyCode == 27) {
|
299
|
+
event.stop();
|
300
|
+
this.hide();
|
301
|
+
}
|
302
|
+
}.bindAsEventListener(this));
|
303
|
+
}
|
304
|
+
|
305
|
+
window.on('resize', this.boxResize.bind(this));
|
306
|
+
|
307
|
+
return this;
|
308
|
+
},
|
309
|
+
|
310
|
+
// calculates the minimal body height
|
311
|
+
minBodyHeight: function() {
|
312
|
+
var element = $E('div', {'class': 'lightbox-body', style: 'background: none; position: absolute'}).insertTo(document.body),
|
313
|
+
height = element.sizes().y;
|
314
|
+
element.remove();
|
315
|
+
return height;
|
316
|
+
},
|
317
|
+
|
318
|
+
// processes the resizing visual effect
|
319
|
+
resizeFx: function(body_style, dialog_style) {
|
320
|
+
this.resizeLock();
|
321
|
+
|
322
|
+
// processing everything in a single visual effect so it looked smooth
|
323
|
+
var body_start_width = this.body.sizes().x;
|
324
|
+
var body_end_width = body_style.width.toInt();
|
325
|
+
var body_start_height = this.body.sizes().y;
|
326
|
+
var body_end_height = body_style.height.toInt();
|
327
|
+
var dialog_start_top = this.dialog.style.top.toInt();
|
328
|
+
var dialog_end_top = dialog_style.top.toInt();
|
329
|
+
var dialog_start_width = this.dialog.sizes().x;
|
330
|
+
var dialog_end_width = (dialog_style.width || '0').toInt();
|
331
|
+
var body = this.body;
|
332
|
+
var dialog = this.dialog;
|
333
|
+
|
334
|
+
$ext(new Fx(this.dialog, {duration: this.options.fxDuration}), {
|
335
|
+
render: function(delta) {
|
336
|
+
body.style.width = (body_start_width + (body_end_width - body_start_width) * delta) + 'px';
|
337
|
+
body.style.height = (body_start_height + (body_end_height - body_start_height) * delta) + 'px';
|
338
|
+
dialog.style.top = (dialog_start_top + (dialog_end_top - dialog_start_top) * delta) + 'px';
|
339
|
+
|
340
|
+
if (Browser.IE6) {
|
341
|
+
dialog.style.width = (dialog_start_width + (dialog_end_width - dialog_start_width) * delta) + 'px';
|
342
|
+
}
|
343
|
+
}
|
344
|
+
}).onFinish(this.resizeUnlock.bind(this)).start();
|
345
|
+
},
|
346
|
+
|
347
|
+
// private
|
348
|
+
// elements building shortcut
|
349
|
+
E: function(klass, parent) {
|
350
|
+
var e = $E('div', {'class': klass});
|
351
|
+
if (parent) e.insertTo(parent);
|
352
|
+
return e;
|
353
|
+
}
|
354
|
+
|
355
|
+
});
|
356
|
+
|
357
|
+
/**
|
358
|
+
* Ajax loading support module
|
359
|
+
*
|
360
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
361
|
+
*/
|
362
|
+
Lightbox.include((function() {
|
363
|
+
var old_show = Lightbox.prototype.show;
|
364
|
+
var old_build = Lightbox.prototype.build;
|
365
|
+
|
366
|
+
return {
|
367
|
+
// hightjacking the links
|
368
|
+
show: function(content) {
|
369
|
+
if (content && content.href) {
|
370
|
+
return this.load(content.href, {
|
371
|
+
onComplete: function(request) {
|
372
|
+
this.setTitle(content.title).content.update(request.responseText);
|
373
|
+
}.bind(this)
|
374
|
+
});
|
375
|
+
} else {
|
376
|
+
return old_show.apply(this, arguments);
|
377
|
+
}
|
378
|
+
},
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Loads the url via an ajax request and assigns the box content wiht the response result
|
382
|
+
*
|
383
|
+
* NOTE: will perform a GET request by default
|
384
|
+
*
|
385
|
+
* NOTE: will just update the body content with
|
386
|
+
* the response text if no onComplete or
|
387
|
+
* onSuccess callbacks were set
|
388
|
+
*
|
389
|
+
* @param String url address
|
390
|
+
* @param Object Xhr options
|
391
|
+
* @return Lightbox self
|
392
|
+
*/
|
393
|
+
load: function(url, options) {
|
394
|
+
var options = options || {};
|
395
|
+
|
396
|
+
$w('onCreate onComplete').each(function(name) {
|
397
|
+
options[name] = options[name] ? isArray(options[name]) ? options[name] : [options[name]] : [];
|
398
|
+
});
|
399
|
+
|
400
|
+
// adding the selfupdate callback as default
|
401
|
+
if (options.onComplete.empty() && !options.onSuccess) {
|
402
|
+
options.onComplete.push(function(request) {
|
403
|
+
this.content.update(request.responseText);
|
404
|
+
}.bind(this));
|
405
|
+
}
|
406
|
+
|
407
|
+
options.onCreate.unshift(this.loadLock.bind(this));
|
408
|
+
options.onComplete.push(this.resize.bind(this));
|
409
|
+
|
410
|
+
options.method = options.method || 'get';
|
411
|
+
|
412
|
+
return this.showingSelf(Xhr.load.bind(Xhr, url, options));
|
413
|
+
},
|
414
|
+
|
415
|
+
// protected
|
416
|
+
|
417
|
+
// xhr requests loading specific lock
|
418
|
+
loadLock: function() {
|
419
|
+
this.loading = true;
|
420
|
+
this.lock().bodyLock.addClass('lightbox-body-lock-loading');
|
421
|
+
return this;
|
422
|
+
},
|
423
|
+
|
424
|
+
build: function() {
|
425
|
+
var res = old_build.apply(this, arguments);
|
426
|
+
|
427
|
+
// building a textual spinner
|
428
|
+
var spinner = this.E('lightbox-body-lock-spinner', this.bodyLock);
|
429
|
+
var dots = '1234'.split('').map(function(i) {
|
430
|
+
return $E('div', {'class': i == 1 ? 'glow':null}).insertTo(spinner);
|
431
|
+
});
|
432
|
+
(function() {
|
433
|
+
var dot = dots.pop(); dot.insertTo(spinner, 'top'); dots.unshift(dot);
|
434
|
+
}).periodical(400);
|
435
|
+
|
436
|
+
return res;
|
437
|
+
}
|
438
|
+
};
|
439
|
+
})());
|
440
|
+
|
441
|
+
/**
|
442
|
+
* Roadtrips support module for the lightbox
|
443
|
+
*
|
444
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
445
|
+
*/
|
446
|
+
Lightbox.include((function() {
|
447
|
+
var old_show = Lightbox.prototype.show;
|
448
|
+
var old_build = Lightbox.prototype.build;
|
449
|
+
var old_event = Lightbox.prototype.connectEvents;
|
450
|
+
|
451
|
+
return {
|
452
|
+
// highjacking a roadtrip content
|
453
|
+
show: function(content) {
|
454
|
+
this.roadLink = (content && content.roadtrip) ? content : null;
|
455
|
+
return old_show.apply(this, arguments);
|
456
|
+
},
|
457
|
+
|
458
|
+
// the building process overlaping
|
459
|
+
build: function() {
|
460
|
+
var res = old_build.apply(this, arguments);
|
461
|
+
|
462
|
+
this.prevLink = this.E('lightbox-prev-link', this.dialog).onClick(this.showPrev.bind(this))
|
463
|
+
.update(Lightbox.i18n.PrevText).set('title', Lightbox.i18n.PrevTitle).hide();
|
464
|
+
this.nextLink = this.E('lightbox-next-link', this.dialog).onClick(this.showNext.bind(this))
|
465
|
+
.update(Lightbox.i18n.NextText).set('title', Lightbox.i18n.NextTitle).hide();
|
466
|
+
|
467
|
+
return res;
|
468
|
+
},
|
469
|
+
|
470
|
+
// connecting the left/right arrow buttons
|
471
|
+
connectEvents: function() {
|
472
|
+
var res = old_event.apply(this, arguments);
|
473
|
+
|
474
|
+
document.onKeydown(function(event) {
|
475
|
+
if (event.keyCode == 37) { event.stop(); this.showPrev(); }
|
476
|
+
if (event.keyCode == 39) { event.stop(); this.showNext(); }
|
477
|
+
}.bind(this));
|
478
|
+
|
479
|
+
return res;
|
480
|
+
},
|
481
|
+
|
482
|
+
// tries to show the previous item on the roadtrip
|
483
|
+
showPrev: function() {
|
484
|
+
if (this.hasPrev() && this.element.visible() && !this.loading) {
|
485
|
+
this.show(this.roadLink.roadtrip[this.roadLink.roadtrip.indexOf(this.roadLink) - 1]);
|
486
|
+
}
|
487
|
+
return this;
|
488
|
+
},
|
489
|
+
|
490
|
+
// tries to show the next item on the roadtrip
|
491
|
+
showNext: function() {
|
492
|
+
if (this.hasNext() && this.element.visible() && !this.loading) {
|
493
|
+
this.show(this.roadLink.roadtrip[this.roadLink.roadtrip.indexOf(this.roadLink) + 1]);
|
494
|
+
}
|
495
|
+
return this;
|
496
|
+
},
|
497
|
+
|
498
|
+
// checks the roadtrip state and shows/hides the next/prev links
|
499
|
+
checkRoadtrip: function() {
|
500
|
+
this.prevLink[this.hasPrev() ? 'show' : 'hide']();
|
501
|
+
this.nextLink[this.hasNext() ? 'show' : 'hide']();
|
502
|
+
return this;
|
503
|
+
},
|
504
|
+
|
505
|
+
// checks if there is a previous image link
|
506
|
+
hasPrev: function() {
|
507
|
+
return this.roadLink && this.roadLink.roadtrip && this.roadLink.roadtrip.first() != this.roadLink;
|
508
|
+
},
|
509
|
+
|
510
|
+
// checks if there is a next image link
|
511
|
+
hasNext: function() {
|
512
|
+
return this.roadLink && this.roadLink.roadtrip && this.roadLink.roadtrip.last() != this.roadLink;
|
513
|
+
}
|
514
|
+
};
|
515
|
+
})());
|
516
|
+
|
517
|
+
/**
|
518
|
+
* The images displaying functionality module
|
519
|
+
*
|
520
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
521
|
+
*/
|
522
|
+
Lightbox.include((function() {
|
523
|
+
var old_show = Lightbox.prototype.show;
|
524
|
+
|
525
|
+
return {
|
526
|
+
IMAGE_FORMATS: $w('jpg jpeg gif png bmp'),
|
527
|
+
|
528
|
+
// hightjacking the links to images and image elements
|
529
|
+
show: function(content) {
|
530
|
+
// adjusting the element class-name
|
531
|
+
this.element[(content && (content.tagName == 'IMG' || this.isImageUrl(content.href))) ?
|
532
|
+
'addClass' : 'removeClass']('lightbox-image');
|
533
|
+
|
534
|
+
if (content && content.href && this.isImageUrl(content.href)) {
|
535
|
+
return this.showingSelf(function() {
|
536
|
+
this.loadLock().roadLink = content;
|
537
|
+
|
538
|
+
// using the iframed request to make the browser cache work
|
539
|
+
var image = new Image();
|
540
|
+
image.onload = this.updateImage.bind(this, image, content);
|
541
|
+
image.src = content.href;
|
542
|
+
|
543
|
+
}.bind(this));
|
544
|
+
} else {
|
545
|
+
return old_show.apply(this, arguments);
|
546
|
+
}
|
547
|
+
},
|
548
|
+
|
549
|
+
// protected
|
550
|
+
|
551
|
+
// inserts the image
|
552
|
+
updateImage: function(image, link) {
|
553
|
+
this.content.update(image);
|
554
|
+
this.checkRoadtrip().setTitle(link.title).resize();
|
555
|
+
},
|
556
|
+
|
557
|
+
// checks if the given url is an url to an image
|
558
|
+
isImageUrl: function(url) {
|
559
|
+
return this.IMAGE_FORMATS.include(String(url).toLowerCase().split('?').first().split('.').last());
|
560
|
+
}
|
561
|
+
};
|
562
|
+
})());
|
563
|
+
|
564
|
+
/**
|
565
|
+
* The class level interface
|
566
|
+
*
|
567
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
568
|
+
*/
|
569
|
+
Lightbox.extend({
|
570
|
+
hide: function() {
|
571
|
+
this.boxes.each('hide');
|
572
|
+
},
|
573
|
+
|
574
|
+
show: function() {
|
575
|
+
return this.inst('show', arguments);
|
576
|
+
},
|
577
|
+
|
578
|
+
load: function() {
|
579
|
+
return this.inst('load', arguments);
|
580
|
+
},
|
581
|
+
|
582
|
+
// private
|
583
|
+
|
584
|
+
inst: function(name, args) {
|
585
|
+
var inst = new Lightbox();
|
586
|
+
return inst[name].apply(inst, args);
|
587
|
+
}
|
588
|
+
});
|
589
|
+
|
590
|
+
/**
|
591
|
+
* document on-load rescan
|
592
|
+
*
|
593
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
594
|
+
*/
|
595
|
+
document.onReady(Lightbox.rescan);
|
596
|
+
|
597
|
+
document.write("<style type=\"text/css\">div.lightbox{position:fixed;top:0px;left:0px;width:100%;text-align:center}div.lightbox div{line-height:normal}div.lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:black}div.lightbox-dialog{display:inline-block;*display:inline;*zoom:1;position:relative;text-align:left;padding-bottom:1.6em}div.lightbox-body-wrap{background-color:white;padding:1em;border-radius:.6em;-moz-border-radius:.6em;-webkit-border-radius:.6em}div.lightbox-body{position:relative;height:10em;width:10em;min-height:10em;min-width:10em;overflow:hidden;*background-color:white}div.lightbox-content{position:absolute;*background-color:white}div.lightbox-body-lock{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;text-align:center}div.lightbox-body-lock-spinner{display:none;position:absolute;bottom:0;right:0}div.lightbox-body-lock-spinner div{float:left;width:.5em;height:.9em;background:#AAA;margin-left:.1em;-moz-border-radius:.15em;-webkit-border-radius:.15em}div.lightbox-body-lock-spinner div.glow{background:#666;height:1em;margin-top:-0.05em}div.lightbox-body-lock-loading div.lightbox-body-lock-spinner{display:inline-block;*display:inline;*zoom:1}div.lightbox-body-lock-transparent{background:none}div.lightbox-caption{height:1.2em;margin:0 .7em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica;text-shadow:black 2px 2px 2px}div.lightbox-close-button,div.lightbox-prev-link,div.lightbox-next-link{position:absolute;bottom:0;color:#888;cursor:pointer;font-size:150%;font-weight:bold}div.lightbox-close-button:hover,div.lightbox-prev-link:hover,div.lightbox-next-link:hover{color:white}div.lightbox-close-button{right:.5em}div.lightbox-prev-link,div.lightbox-next-link{padding:0 .2em;font-size:180%}div.lightbox-prev-link{left:.3em}div.lightbox-next-link{left:2em}div.lightbox-image div.lightbox-body-wrap{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.lightbox-image div.lightbox-content img{vertical-align:middle}div.lightbox-image div.lightbox-caption{margin-left:.2em}div.lightbox-image div.lightbox-body-wrap,div.lightbox-image div.lightbox-body-lock{background-color:#DDD}div.lightbox-image div.lightbox-body-lock-spinner{bottom:1em;right:1em}div.lightbox-image div.lightbox-close-button{right:.2em}div.lightbox-image div.lightbox-prev-link{left:0}</style>");
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* The lightbox widget implemented with RightJS
|
3
|
+
*
|
4
|
+
* Home page: http://rightjs.org/ui/lightbox
|
5
|
+
*
|
6
|
+
* @copyright (C) 2009 Nikolay V. Nemshilov aka St.
|
7
|
+
*/
|
8
|
+
if (!RightJS || !Fx) { throw "Gimme RightJS with Fx. Please." };
|
9
|
+
eval((function(s,d){for(var i=d.length-1;i>-1;i--)if(d[i])s=s.replace(new RegExp(i,'g'),d[i]);return s})("83.IE6=navigator.userAgent.130(\"MSIE 6\")!=-1;21 17=135 Class({79:128,extend:{Version:\"1.0.0\",128:{142:0.8,30:200,45OnEsc:105,45OnOutClick:105,38179174:105,b33Content:131,relName:'13'},96:{155:'×',141:'179',164:'&144;&144;&144;',159:'175ious 161',163:'&145;&145;&145;',153:'173 161'},137:[],rescan:14(){21 k=17.128.relName;21 g=14(e){21 d=e.get('data-'+k+'-28');16 eval('('+d+')')||{}};$$('a[rel='+k+']').126(14(b){if(!b.3817){21 o=g(b);b.3817=14(e){e.s76();135 17(o).38(11)};b.69('3817')}});21 r=$$('a[rel=\"'+k+'[31]\"]');r.126(14(b){if(b.3817)b.s76Observing(b.3817);21 o=g(b);b.31=r;b.3817=14(e){e.s76();135 17(o).38(11)};b.69(b.3817)})}},initialize:14(o){11.set128(o).90().59();17.137.push(11)},116:14(t){11.73.158('out',{55:11.28.30/2,115:14(){11.73.58(t).158('in',{55:11.28.30/2})}.36(11)});16 11},45:14(){11.25.45('158',{55:11.28.30/2,115:11.25.remove.36(11.25)});16 11},38:14(c,s){16 11.38ing176(14(){11.33();11.32.58(c||'');11.60(s)}.36(11))},60:14(s,n){11.26.49.76=(110.46().y-11.26.46().y)/2+'px';21 a=11.32Size(s);21 h=11.26.46().y-11.22.46().y;21 b=a.42.74()||11.109();21 d={76:(11.25.46().y-b-h)/2+'px'};if(83.IE6){21 p=11.22177.getStyle('71').74()>0?15:0;11.22177.48('71: '+p+'px');d.44=(a.44.74()+p*2)+'px'}if(n===105){11.22.48(a);11.26.48(d);11.51=131}124 11.60Fx(a,d);16 11},33:14(){11.22172.92('13-22-33-87').92('13-22-33-51').38();if(83.OLD)11.22172.48(\"82: 1\");16 11},un33:14(){if(11.28.b33Content)11.22172.117('13-22-33-87');124 11.22172.45();16 11},60172:14(){11.33().32.45()},60Un33:14(){11.un33().32.38('158',{55:11.28.30/2});11.51=131},32Size:14(s){21 s=s===11.$listeners?null:s,a=11.25.offsetWidth*0.8,m=11.25.offsetHeight*0.8;if(s)11.32.48(s);s=11.32.46();16{44:(s.x>a?a:s.x)+\"px\",42:(s.y>m?m:s.y)+\"px\"}},101:14(r){11.25.60(110.46());if(83.IE6){11.33er.60(110.46());11.25.49.41='53';11.25.49.76=47.47Element.scrollTop+'px'}16 11.60(131,105)},38ing176:14(c){17.137.without(11).126('45');if(11.25.hidden()){11.33er.48('82:0');11.26.48('82:0');11.25.75(47.22).38();11.101();11.33er.morph({82:11.28.142},{55:11.28.30});11.26.morph({82:1},{55:11.28.30});c.delay(11.28.30)}124 c();16 11},90:14(){11.25=11.E('13').48('68: 147');11.33er=11.E('13-33er',11.25);11.26=11.E('13-26',11.25);11.73=11.E('13-73',11.26);11.22177=11.E('13-22-157',11.26);11.22=11.E('13-22',11.22177);11.32=11.E('13-32',11.22);11.22172=11.E('13-22-33',11.22).45();if(11.28.38179174)11.108174=11.E('13-108-94',11.26).69(11.45.36(11)).58(17.96.155).set('99',17.96.141);if(11.28.45OnOutClick)11.33er.69(11.45.36(11));47.on('mousewheel',14(a){if(11.25.136()){a.s76();11[(a.detail||-a.wheelDelta)<0?'38175':'38173']()}}.36(11));16 11},59:14(){if(11.28.45OnEsc)47.151(14(e){if(e.129==27){e.s76();11.45()}}.36AsEventListener(11));110.on('60',11.101.36(11));16 11},109:14(){21 e=$E('19',{'170':'13-22',49:'29: 147; 41: 53'}).75(47.22),h=e.46().y;e.remove();16 h},60Fx:14(g,m){11.60172();21 f=11.22.46().x;21 c=g.44.74();21 e=11.22.46().y;21 a=g.42.74();21 k=11.26.49.76.74();21 i=m.76.74();21 l=11.26.46().x;21 j=(m.44||'0').74();21 b=11.22;21 h=11.26;$ext(135 Fx(11.26,{55:11.28.30}),{render:14(d){b.49.44=(f+(c-f)*d)+'px';b.49.42=(e+(a-e)*d)+'px';h.49.76=(k+(i-k)*d)+'px';if(83.IE6)h.49.44=(l+(j-l)*d)+'px'}}).115(11.60Un33.36(11)).start()},E:14(k,p){21 e=$E('19',{'170':k});if(p)e.75(p);16 e}});17.79((14(){21 f=17.56.38;21 e=17.56.90;16{38:14(c){if(c&&c.103)16 11.125(c.103,{61:14(r){11.116(c.99).32.58(r.119)}.36(11)});124 16 f.78(11,43)},125:14(u,o){21 o=o||{};$w('166 61').126(14(n){o[n]=o[n]?isArray(o[n])?o[n]:[o[n]]:[]});if(o.61.empty()&&!o.onSuccess)o.61.push(14(r){11.32.58(r.119)}.36(11));o.166.171(11.114.36(11));o.61.push(11.60.36(11));o.method=o.method||'get';16 11.38ing176(Xhr.125.36(Xhr,u,o))},114:14(){11.51=105;11.33().22172.117('13-22-33-51');16 11},90:14(){21 r=e.78(11,43);21 s=11.E('13-22-33-70',11.22172);21 b='1234'.165('').map(14(a){16 $E('19',{'170':a==1?'glow':null}).75(s)});(14(){21 d=b.pop();d.75(s,'76');b.171(d)}).periodical(400);16 r}}})());17.79((14(){21 b=17.56.38;21 o=17.56.90;21 a=17.56.59;16{38:14(c){11.24=(c&&c.31)?c:null;16 b.78(11,43)},90:14(){21 r=o.78(11,43);11.102178=11.E('13-102-62',11.26).69(11.38175.36(11)).58(17.96.164).set('99',17.96.159).45();11.121178=11.E('13-121-62',11.26).69(11.38173.36(11)).58(17.96.163).set('99',17.96.153).45();16 r},59:14(){21 r=a.78(11,43);47.151(14(e){if(e.129==37){e.s76();11.38175()}if(e.129==39){e.s76();11.38173()}}.36(11));16 r},38175:14(){if(11.138()&&11.25.136()&&!11.51)11.38(11.24.31[11.24.31.130(11.24)-1]);16 11},38173:14(){if(11.132()&&11.25.136()&&!11.51)11.38(11.24.31[11.24.31.130(11.24)+1]);16 11},113:14(){11.102178[11.138()?'38':'45']();11.121178[11.132()?'38':'45']();16 11},138:14(){16 11.24&&11.24.31&&11.24.31.first()!=11.24},132:14(){16 11.24&&11.24.31&&11.24.31.last()!=11.24}}})());17.79((14(){21 o=17.56.38;16{111:$w('jpg jpeg gif png bmp'),38:14(c){11.25[(c&&(c.tagName=='IMG'||11.97(c.103)))?'117':'92']('13-64');if(c&&c.103&&11.97(c.103))16 11.38ing176(14(){11.114().24=c;21 i=135 161();i.on125=11.58161.36(11,i,c);i.src=c.103}.36(11));124 16 o.78(11,43)},58161:14(i,l){11.32.58(i);11.113().116(l.99).60()},97:14(u){16 11.111.79(String(u).toLowerCase().165('?').first().165('.').last())}}})());17.extend({45:14(){11.137.126('45')},38:14(){16 11.inst('38',43)},125:14(){16 11.inst('125',43)},inst:14(n,a){21 i=135 17();16 i[n].78(i,a)}});47.onReady(17.rescan);47.write(\"<49 type=\\\"122/css\\\">19.13{41:fixed;76:85;65:85;44:154%;122-133:center}19.13 19{line-42:normal}19.13-33er{41:53;76:85;65:85;44:154%;42:154%;29-63:black}19.13-26{68:112-b33;*68:112;*zoom:1;41:168;122-133:65;71-93:1.156}19.13-22-157{29-63:91;71:139;52-57:.156;-moz-52-57:.156;-146-52-57:.156}19.13-22{41:168;42:152;44:152;min-42:152;min-44:152;overflow:hidden;*29-63:91}19.13-32{41:53;*29-63:91}19.13-22-33{29-63:91;41:53;65:85;76:85;44:154%;42:154%;122-133:center}19.13-22-33-70{68:147;41:53;93:0;140:0}19.13-22-33-70 19{float:65;44:.5em;42:.9em;29:#AAA;95-65:.139;-moz-52-57:.15em;-146-52-57:.15em}19.13-22-33-70 19.glow{29:#666;42:139;95-76:-0.05em}19.13-22-33-51 19.13-22-33-70{68:112-b33;*68:112;*zoom:1}19.13-22-33-87{29:147}19.13-73{42:1.148;95:0 .7em;95-93:.139;91-space:no157;63:#DDD;106-weight:bold;106-size:1.156;106-family:Helvetica;122-shadow:black 2px 2px 2px}19.13-108-94,19.13-102-62,19.13-121-62{41:53;93:0;63:#888;cursor:pointer;106-size:150%;106-weight:bold}19.13-108-94:160,19.13-102-62:160,19.13-121-62:160{63:91}19.13-108-94{140:.5em}19.13-102-62,19.13-121-62{71:0 .148;106-size:180%}19.13-102-62{65:.3em}19.13-121-62{65:148}19.13-64 19.13-22-157{71:0;52:1px solid #777;52-57:85;-moz-52-57:85;-146-52-57:85}19.13-64 19.13-32 img{vertical-133:middle}19.13-64 19.13-73{95-65:.148}19.13-64 19.13-22-157,19.13-64 19.13-22-33{29-63:#DDD}19.13-64 19.13-22-33-70{93:139;140:139}19.13-64 19.13-108-94{140:.148}19.13-64 19.13-102-62{65:0}</49>\");",",,,,,,,,,,,this,,lightbox,function,,return,Lightbox,,div,,var,body,,roadLink,element,dialog,,options,background,fxDuration,roadtrip,content,lock,,showLightbox,bind,,show,,,position,height,arguments,width,hide,sizes,document,setStyle,style,,loading,border,absolute,bodyLock,duration,prototype,radius,update,connectEvents,resize,onComplete,link,color,image,left,,locker,display,onClick,spinner,padding,showingSelf,caption,toInt,insertTo,top,,apply,include,,,opacity,Browser,showPrev,0px,showNext,transparent,,bodyWrap,build,white,removeClass,bottom,button,margin,i18n,isImageUrl,showCloseButton,title,,boxResize,prev,href,hideOnOutClick,true,font,stop,close,minBodyHeight,window,IMAGE_FORMATS,inline,checkRoadtrip,loadLock,onFinish,setTitle,addClass,resizeUnlock,responseText,blockContent,next,text,,else,load,each,updateImage,Options,keyCode,indexOf,false,hasNext,align,contentSize,new,visible,boxes,hasPrev,1em,right,CloseTitle,endOpacity,resizeLock,lsaquo,rsaquo,webkit,none,2em,hideOnEsc,,onKeydown,10em,NextTitle,100,CloseText,6em,wrap,fade,PrevTitle,hover,Image,resizeFx,NextText,PrevText,split,onCreate,prevLink,relative,nextLink,class,unshift,Lock,Next,Button,Prev,Self,Wrap,Link,Close".split(",")));
|