ecm_pictures 0.0.21 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.rdoc +20 -4
  2. data/app/helpers/ecm/pictures_helper.rb +41 -38
  3. data/app/helpers/markup_helper.rb +7 -0
  4. data/app/models/ecm/pictures/picture.rb +22 -1
  5. data/app/models/ecm/pictures/picture_gallery.rb +12 -1
  6. data/app/views/ecm/pictures/picture_galleries/_picture_gallery.html.erb +12 -0
  7. data/app/views/ecm/pictures/picture_galleries/_picture_gallery_for_index.html.erb +12 -0
  8. data/app/views/ecm/pictures/pictures/_picture.html.erb +7 -0
  9. data/app/views/ecm/pictures/pictures/_picture_for_gallery.html.erb +9 -0
  10. data/config/locales/ecm.pictures.de.yml +11 -3
  11. data/config/locales/ecm.pictures.en.yml +15 -0
  12. data/config/locales/ecm.pictures.picture.de.yml +3 -1
  13. data/config/locales/ecm.pictures.picture.en.yml +23 -0
  14. data/config/locales/ecm.pictures.picture_gallery.de.yml +3 -2
  15. data/config/locales/ecm.pictures.picture_gallery.en.yml +19 -0
  16. data/db/migrate/001_create_ecm_pictures_picture_galleries.rb +6 -1
  17. data/db/migrate/002_create_ecm_pictures_pictures.rb +6 -3
  18. data/lib/ecm/pictures/active_admin/ecm_pictures_picture_galleries.rb +11 -3
  19. data/lib/ecm/pictures/active_admin/ecm_pictures_pictures.rb +12 -2
  20. data/lib/ecm/pictures/configuration.rb +11 -0
  21. data/lib/ecm/pictures/engine.rb +1 -15
  22. data/lib/ecm/pictures/version.rb +1 -1
  23. data/lib/ecm_pictures.rb +1 -7
  24. data/lib/generators/ecm/pictures/install/templates/ecm_pictures.rb +16 -1
  25. data/lib/generators/ecm/pictures/locales/locales_generator.rb +3 -3
  26. data/lib/tasks/ecm_pictures_tasks.rake +2 -0
  27. metadata +84 -52
  28. data/app/assets/images/orangebox/buttons.png +0 -0
  29. data/app/assets/images/orangebox/loading.gif +0 -0
  30. data/app/assets/javascripts/ecm_pictures.js +0 -1
  31. data/app/assets/javascripts/orangebox/orangebox.js +0 -719
  32. data/app/assets/javascripts/orangebox/orangebox.min.js +0 -8
  33. data/app/assets/stylesheets/ecm_pictures.css.scss +0 -1
  34. data/app/assets/stylesheets/orangebox/orangebox.css.erb +0 -160
@@ -1,719 +0,0 @@
1
- /*
2
- * version: 2.0.3
3
- * package: OrangeBox
4
- * author: David Paul Hamilton - http://orangebox.davidpaulhamilton.net
5
- * copyright: Copyright (c) 2011 David Hamilton / DavidPaulHamilton.net All rights reserved.
6
- * license: GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
7
- */
8
- if (typeof(oB) !== 'undefined') { $.error( 'OrangeBox: Variable "oB", used by OrangeBox, is already defined'); }
9
- else {
10
- var oB;
11
- (function($) {
12
- oB = {
13
- progress: '',
14
- playing: '',
15
- slideshowTimer: '',
16
- slideshow: '',
17
- docHeight: '',
18
- docWidth: '',
19
- controlTimer: '',
20
- settings: {
21
- autoplay : false,
22
- fadeControls: false,
23
- fadeCaption: true,
24
- keyboardNavigation: true,
25
- orangeControls: false,
26
- showClose: true,
27
- showDots: false,
28
- showNav: true,
29
- addThis: true,
30
- notFound: 'Not Found',
31
- overlayOpacity: 0.95,
32
- contentBorderWidth: 4,
33
- contentMinWidth: 200,
34
- contentMinHeight: 100,
35
- iframeWidth: 0.75,
36
- iframeHeight: 0.75,
37
- inlineWidth: 0.5,
38
- inlineHeight: 0,
39
- maxImageWidth: 0.75,
40
- maxImageHeight: 0.75,
41
- maxVideoWidth: 640,
42
- maxVideoHeight: 390,
43
- fadeTime: 200,
44
- slideshowTimer: 3000
45
- },
46
- methods: {
47
- init : function( options ) {
48
- if (!$('#ob_window').length) {
49
- if ( options ) { $.extend( oB.settings, options ); }
50
- if ( oB.settings.addThis ) { $.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4dd42f2b5b9fc332'); }
51
- return this.each(function() {
52
- $(this).click(function(e) {
53
- e.preventDefault();
54
- oB.methods.create(this);
55
- });
56
- });
57
- }
58
- return false;
59
- },
60
- create : function( obj, options ) {
61
- if ( options ) { $.extend( oB.settings, options ); }
62
- if (!obj) { obj = this; }
63
- var dotnav = $('<ul id="ob_dots"></ul>');
64
- var mainObject;
65
- var rel = $(obj).attr('rel');
66
- var gallery;
67
- oB.galleryArray=new Array();
68
- oB.slideshow = true;
69
- oB.docHeight = $(document).height();
70
- oB.docWidth = $(document).width();
71
- if(!jQuery().orangeControls) { oB.settings.orangeControls = false; }
72
- //Check for unique elements
73
- function uniqueCheck(z, h) {
74
- var i;
75
- for (i=0; i < oB.galleryArray.length; i++) {
76
- var x = oB.galleryArray[i].data('ob_data').ob_href;
77
- if (h && x === z.attr('id')) { return false; }
78
- else if(x === z.attr('href')){ return false; }
79
- }
80
- return true;
81
- }
82
-
83
- //Gallery
84
- if (rel && rel.indexOf("[")) { gallery = rel.substring(rel.indexOf("[") + 1, rel.indexOf("]")); }
85
- if (gallery) {
86
- var a = 0;
87
- var objectMatch = 'a[rel*=\'lightbox[' + gallery + ']\']';
88
- $(objectMatch).each(function(){
89
- var x = uniqueCheck($(this), false);
90
- oB.methods.setupData($(this), false, a);
91
- var z = $(this).data('ob_data').ob_contentType;
92
- if (x && z !== false) {
93
- oB.galleryArray[a] = $(this);
94
- if(oB.settings.showDots) { dotnav.append('<li id="ob_dot' + a + '"></li>'); }
95
- if(z !== "image") { oB.slideshow = false; }
96
- a++;
97
- }
98
- });
99
- if ($('#ob_gallery').length > 0) {
100
- $('#ob_gallery li.' + gallery).each(function() {
101
- var x = uniqueCheck($(this), true);
102
- oB.methods.setupData($(this), true, a);
103
- var z = $(this).data('ob_data').ob_contentType;
104
- if (x && z !== false) {
105
- oB.galleryArray[a] = $(this);
106
- if(oB.settings.showDots) { dotnav.append('<li id="ob_dot' + a + '"></li>'); }
107
- if(z !== "image") { oB.slideshow = false; }
108
- a++;
109
- }
110
- });
111
- }
112
- }
113
-
114
- //Set Main Object
115
- if ($(obj).attr('href') === "ob_hidden_set") {
116
- mainObject = oB.galleryArray[0];
117
- oB.methods.setupData(mainObject, true, 0);
118
- }
119
- else {
120
- mainObject = $(obj);
121
- oB.methods.setupData(mainObject, false, false);
122
- }
123
- if(!mainObject.data('ob_data').ob_contentType) { mainObject = oB.galleryArray[0]; }
124
-
125
- //Check for Content Type
126
- if(mainObject.data('ob_data').ob_contentType) {
127
-
128
- //Set Vars
129
- var overlay = $('<div id="ob_overlay"></div>');
130
- var container = $('<div id="ob_container"></div>');
131
- var floater = $('<div id="ob_float"></div>');
132
- var window = $('<div id="ob_window"></div>').click(function(e) { e.stopPropagation(); });
133
- var close = $('<div title="close" class="ob_controls ob_cs" id="ob_close"></div>').click(function() {
134
- oB.methods.destroy(oB.settings);
135
- });
136
- var title = $('<div id="ob_title"></div>');
137
- var navRight = $('<a class="ob_nav ob_controls ob_cs" id="ob_right"><span class="ob_cs" id="ob_right-ico"></span></a>');
138
- var navLeft = $('<a class="ob_nav ob_controls ob_cs" id="ob_left"><span class="ob_cs" id="ob_left-ico"></span></a>');
139
- var content = $('<div id="ob_content"></div>').css({
140
- "border-width": oB.settings.contentBorderWidth,
141
- "min-height": oB.settings.contentMinHeight,
142
- "min-width": oB.settings.contentMinWidth
143
- });
144
- oB.playing = oB.settings.autoplay;
145
- oB.progress = null;
146
-
147
- //Set overlay CSS
148
- overlay.css({
149
- "opacity" : oB.settings.overlayOpacity,
150
- "min-height": $(document).height(),
151
- "min-width": $(document).width()
152
- });
153
-
154
- //if IE 6
155
- if (typeof document.body.style.maxHeight === "undefined") {
156
- $("body","html").css({height: "100%", width: "100%"});
157
- }
158
-
159
- //Click to Hide Modal
160
- $("body").append(overlay.click(function() { oB.methods.destroy(oB.settings); }));
161
- $("body").append(container.click(function() { oB.methods.destroy(oB.settings); }));
162
- if(oB.settings.showClose) { window.append(close); }
163
- window.append(content).append(title);
164
- $("#ob_container").append(floater).append(window);
165
-
166
- //Show Overlay
167
- overlay.show(oB.settings.fadeTime);
168
-
169
- //Listens for Escape
170
- function handleEscape(e) {
171
- if (oB.progress === null) {
172
- if (e.keyCode === 27) {
173
- oB.methods.destroy(oB.settings);
174
- }
175
- else if (e.keyCode === 37) {
176
- oB.methods.slideshowPause();
177
- oB.methods.navigate(-1);
178
- }
179
- else if (e.keyCode === 39) {
180
- oB.methods.slideshowPause();
181
- oB.methods.navigate(1);
182
- }
183
- }
184
- }
185
- if(oB.settings.keyboardNavigation) {
186
- $(document).keydown(handleEscape);
187
- }
188
-
189
- //Initiate Navigation
190
- if(oB.galleryArray.length > 0) {
191
-
192
- //Initiate OrangeControls
193
- if(oB.settings.orangeControls && oB.galleryArray.length > 1) {
194
- $(document).orangeControls();
195
- $(document).bind('oc_right',function(){
196
- if(oB.progress === null){
197
- oB.methods.slideshowPause();
198
- oB.methods.navigate(1);
199
- }
200
- });
201
- $(document).bind('oc_left',function(){
202
- if(oB.progress === null){
203
- oB.methods.slideshowPause();
204
- oB.methods.navigate(-1);
205
- }
206
- });
207
- $(document).bind('oc_pause',function(){
208
- $(document).orangeControls('update', {'play':true});
209
- oB.methods.slideshowPause();
210
- });
211
- $(document).bind('oc_play', function(){
212
- $(document).orangeControls('update', {'play':false});
213
- oB.methods.slideshowPlay();
214
- });
215
- }
216
-
217
- //Initiate Nav Arrows
218
- if(oB.settings.showNav && oB.galleryArray.length > 1) {
219
- window.append(navRight).append(navLeft);
220
- navLeft.click( function (e) {
221
- if(oB.progress === null) {
222
- oB.methods.slideshowPause();
223
- e.stopPropagation();
224
- oB.methods.navigate(-1);
225
- }
226
- });
227
- navRight.click(function (e) {
228
- if(oB.progress === null) {
229
- oB.methods.slideshowPause();
230
- e.stopPropagation();
231
- oB.methods.navigate(1);
232
- }
233
- });
234
- }
235
-
236
- //Initiate Nav Dots
237
- if(oB.settings.showDots && oB.galleryArray.length > 1) {
238
- window.append(dotnav);
239
- dotnav.find("li").click(function() {
240
- if(!$(this).hasClass('current') && oB.progress === null) {
241
- oB.methods.slideshowPause();
242
- var x = $(this).attr('id').substr(6);
243
- dotnav.find("li").removeClass('current');
244
- $(this).addClass('current');
245
- oB.methods.navigate("", x);
246
- }
247
- });
248
- }
249
- }
250
-
251
- //Fire in the Hole
252
- oB.methods.showContent(mainObject, true);
253
- }
254
- },
255
- setupData : function( o, v, x ) {
256
- var z;
257
- var c = false;
258
- var w = 0;
259
- var h = 0;
260
- var i;
261
- var t = "";
262
- if(typeof o.attr('title') !== "undefined") {t = o.attr('title');}
263
- if(v) { z = o.attr('id'); }
264
- else { z = o.attr('href'); }
265
- if(z) {
266
- if (z.match(/(width\=)|(height\=)/)) {
267
- var heightIndex = z.indexOf("height=") + 7;
268
- var widthIndex = z.indexOf("width=") + 6;
269
- var heightString = z.substr(heightIndex);
270
- var widthString = z.substr(widthIndex);
271
- if(heightString.indexOf("&") > 0) { heightString = heightString.substr(0,heightString.indexOf("&")); }
272
- if(widthString.indexOf("&") > 0) { widthString = widthString.substr(0,widthString.indexOf("&")); }
273
- w = widthString;
274
- h = heightString;
275
- }
276
- if (z.match(/\?iframe/)) { c = "iframe"; }
277
- else if (z.match(/\.(?:jpg|jpeg|bmp|png|gif)$/)) { c = "image"; }
278
- else if (z.match(/\.(?:mov|mp4|m4v)(\?.{6,}\&.{6,})?$/)) { c = "quicktime"; }
279
- else if (z.match(/\.swf(\?.{6,}\&.{6,})?$/)) { c = "flash"; }
280
- else if (z.match(/^http:\/\/\w{0,3}\.?youtube\.\w{2,3}\/watch\?v=[\w\-]{11}/)) { c = "youtube"; }
281
- else if (z.match(/^http:\/\/\w{0,3}\.?vimeo\.com\/\d{1,10}/)) { c = "vimeo"; }
282
- else if (z.match(/^#\w{1,}/)) { c = "inline"; }
283
- else if (!z.match(/ob_hidden_set/)){ $.error( 'OrangeBox: Unsupported Media'); }
284
- if (x === false) {
285
- for (i=0; i < oB.galleryArray.length; i++) {
286
- if (oB.galleryArray[i].data('ob_data').ob_href === z) {
287
- x = i;
288
- }
289
- }
290
- }
291
- }
292
- o.data('ob_data', {
293
- ob_height: h,
294
- ob_width: w,
295
- ob_index: x,
296
- ob_contentType: c,
297
- ob_href: z,
298
- ob_title: t,
299
- ob_linkText: o.attr('data-ob_linkText'),
300
- ob_link: o.attr('data-ob_link'),
301
- ob_caption: o.attr('data-ob_caption'),
302
- ob_linkTarget: o.attr('data-ob_linkTarget'),
303
- ob_share: o.attr('data-ob_share'),
304
- ob_shareLink: o.attr('data-ob_shareLink')
305
- });
306
- },
307
- destroy : function( options, x ) {
308
- $(document).trigger('oB_closing');
309
- if ( options ) { $.extend( oB.settings, options ); }
310
- oB.methods.showLoad("stop");
311
- clearTimeout(oB.controlTimer);
312
- clearTimeout(oB.slideshowTimer);
313
- clearTimeout(oB.scrollTimer);
314
- if(oB.settings.orangeControls) { $(document).orangeControls('destroy', oB.settings.fadeTime); }
315
- $(document).unbind("keydown").unbind("mousemove");
316
- $('#ob_overlay').fadeOut(oB.settings.fadeTime, function() { $(this).remove().empty(); });
317
- $('#ob_container').fadeOut(oB.settings.fadeTime, function() {
318
- $(this).remove().empty();
319
- $(document).trigger('oB_closed');
320
- if(x && jQuery.isFunction(x)) { x(); }
321
- });
322
- },
323
- showContent : function ( obj, initial ) {
324
- var href = obj.data('ob_data').ob_href;
325
- var title = obj.data('ob_data').ob_title;
326
- var contentType = obj.data('ob_data').ob_contentType;
327
- var content;
328
- var currentIndex = obj.data('ob_data').ob_index;
329
- var ob_caption = $('<div id="ob_caption"></div>').css({
330
- "opacity" : 0.95
331
- });
332
- if(oB.settings.fadeCaption) {
333
- ob_caption.hide();
334
- $('#ob_content').hover(function(){
335
- $('#ob_caption').stop().fadeTo(oB.settings.fadeTime, 0.95);
336
- },function(){
337
- $('#ob_caption').stop().fadeOut(oB.settings.fadeTime);
338
- });
339
- }
340
- var isError = false;
341
- $('#ob_overlay').css({ "height": oB.docHeight });
342
- $('#ob_content').removeClass().addClass('content'+currentIndex);
343
-
344
- //Start Preloader
345
- oB.methods.showLoad();
346
-
347
- //Set Modal Properties
348
- function setModalProperties() {
349
- var oH = content.outerHeight();
350
- var oW = content.outerWidth();
351
- var wH = oH + (oB.settings.contentBorderWidth*2);
352
- var wW = oW + (oB.settings.contentBorderWidth*2);
353
- var p = $(window).scrollTop();
354
- var target = "";
355
- var rel = "";
356
- if(p === 0) { p = $(document).scrollTop(); }
357
- if(p === 0) { p = window.pageYOffset; }
358
- if(obj.data('ob_data').ob_linkText) {
359
- if(obj.data('ob_data').ob_link){
360
- if(obj.data('ob_data').ob_linkTarget === "_self") { target = 'target="_self"'; }
361
- else { target = 'target="_blank"'; }
362
- title = title+' <a href="'+obj.data('ob_data').ob_link+'" '+target+' '+rel+' >'+obj.data('ob_data').ob_linkText+'</a>';
363
- }
364
- else { title = title+' '+obj.data('ob_data').ob_linkText; }
365
- }
366
- $('#ob_title').append('<h3>' + title + '</h3>');
367
- if(obj.data('ob_data').ob_caption) {
368
- ob_caption.append('<p>'+obj.data('ob_data').ob_caption+'</p>');
369
- $('#ob_content').append(ob_caption);
370
- }
371
- //Check for Mins
372
- if(wH < oB.settings.contentMinHeight) { wH = oB.settings.contentMinHeight + (oB.settings.contentBorderWidth*2); }
373
- if(wW < oB.settings.contentMinWidth) { wW = oB.settings.contentMinWidth + (oB.settings.contentBorderWidth*2); }
374
- $("#ob_container").css({ "margin-top" : p });
375
- $("#ob_window").css({ "height": wH, "width": wW });
376
- $('#ob_float').css({ "margin-bottom": -($("#ob_window").outerHeight(true)) / 2 });
377
- if (isError){ $('#ob_content').css({ "height": oH, "width": oW, "min-height": 0 }); }
378
- else { $('#ob_content').css({ "height": wH - (oB.settings.contentBorderWidth*2), "width": wW - (oB.settings.contentBorderWidth*2), "min-height": oB.settings.contentMinHeight });
379
- }
380
- }
381
-
382
- //Update Navigation
383
- function setControls() {
384
- if(oB.settings.showDots) {
385
- $('#ob_dots').find('li').each(function(){
386
- var i = 'ob_dot' + obj.data('ob_data').ob_index;
387
- if($(this).attr('id') === i) { $(this).addClass('current'); }
388
- else { $(this).removeClass('current'); }
389
- });
390
- }
391
- clearTimeout(oB.controlTimer);
392
- if(oB.settings.orangeControls) {
393
- var oc_settings = { 'play' : true, 'play_active' : false, 'left_active' : false, 'right_active' : false };
394
- if(oB.playing && oB.galleryArray[currentIndex + 1] && oB.galleryArray.length > 1) { oc_settings.play = false; }
395
- if(oB.galleryArray[currentIndex + 1] && oB.galleryArray.length > 1) { oc_settings.right_active = true; }
396
- if(oB.galleryArray[currentIndex - 1] && oB.galleryArray.length > 1) { oc_settings.left_active = true; }
397
- if(oB.slideshow) { oc_settings.play_active = true; }
398
- $(document).orangeControls('update', oc_settings);
399
- }
400
- function showControls() {
401
- if(oB.galleryArray.length > 1) {
402
- if(oB.settings.orangeControls) {
403
- $(document).orangeControls('toggle', {'time' : oB.settings.fadeTime, 'fade' : "in"});
404
- }
405
- if(oB.galleryArray[currentIndex + 1]) {
406
- $('#ob_right').fadeIn(oB.settings.fadeTime);
407
- $('#ob_right-ico').fadeIn(oB.settings.fadeTime);
408
- }
409
- else { $('#ob_right').hide(); }
410
- if(oB.galleryArray[currentIndex - 1]) {
411
- $('#ob_left').fadeIn(oB.settings.fadeTime);
412
- $('#ob_left-ico').fadeIn(oB.settings.fadeTime);
413
- }
414
- else { $('#ob_left').hide(); }
415
- }
416
- $('#ob_close').fadeIn(oB.settings.fadeTime);
417
- }
418
- if(oB.settings.fadeControls) {
419
- if(!oB.galleryArray[currentIndex + 1] || !oB.galleryArray[currentIndex - 1] || initial) {
420
- showControls();
421
- oB.controlTimer = setTimeout(function() {
422
- $('.ob_controls').fadeOut(oB.settings.fadeTime);
423
- if(oB.settings.orangeControls) {
424
- $(document).orangeControls('toggle', {'time' : oB.settings.fadeTime, 'fade' : "out"});
425
- }
426
- }, 1200);
427
- }
428
- $(document).mousemove(function(event) {
429
- clearTimeout(oB.controlTimer);
430
- oB.controlTimer = setTimeout(function() {
431
- showControls();
432
- if (!$(event.target).hasClass('ob_cs') && !$(event.target).hasClass('oc_class')) {
433
- oB.controlTimer = setTimeout(function() {
434
- $('.ob_controls').fadeOut(oB.settings.fadeTime);
435
- if(oB.settings.orangeControls) {
436
- $(document).orangeControls('toggle', {'time' : oB.settings.fadeTime, 'fade' : "out"});
437
- }
438
- }, 1200);
439
- }
440
- },20);
441
- });
442
- }
443
- else {
444
- showControls();
445
- }
446
- }
447
-
448
- //Build the Window
449
- function buildit() {
450
- oB.methods.showLoad("stop");
451
- $('#ob_content').append(content);
452
- if ( oB.settings.addThis && contentType !== "iframe" && contentType !== "inline" && obj.data('ob_data').ob_share !== "false") {
453
- $('#ob_share').empty().remove();
454
- var addThis = $('<a id="ob_share" class="addthis_button_compact"></a>');
455
- var shareClass = "ob_share-"+title;
456
- var link = href;
457
- if ( obj.data('ob_data').ob_shareLink ) { link = obj.data('ob_data').ob_shareLink; }
458
- addThis.addClass(shareClass);
459
- $('#ob_window').append(addThis);
460
- $('#ob_title').css('margin-right', 24);
461
- addThis.button('.'+shareClass, { services_compact: 'twitter,facebook,digg,delicious,more', ui_offset_left: -244, ui_offset_top: 4 }, { url: link, title: title });
462
- $('#ob_share').html('').append('<span class="at300bs at15nc at15t_compact"></span>');
463
- if ( title === "" ) { title = "share" }
464
- }
465
- $('#ob_window').fadeIn(oB.settings.fadeTime, function(){
466
- if(initial){ $(document).trigger('oB_init'); }
467
- $('#ob_overlay').css({ "height": $(document).height() });
468
- });
469
- setModalProperties();
470
- setControls();
471
- oB.progress = null;
472
- }
473
-
474
- //Error Content
475
- function throwError() {
476
- content = $('<div id="ob_error">' + oB.settings.notFound + '</div>');
477
- oB.methods.showLoad("stop");
478
- $('#ob_content').empty().append(content);
479
- $('#ob_window').fadeIn(oB.settings.fadeTime, function(){
480
- $('#ob_overlay').css({ "height": $(document).height() });
481
- });
482
- $('#ob_title').hide();
483
- $('#ob_right').hide();
484
- $('#ob_left').hide();
485
- $('#ob_dots').hide();
486
- $(document).unbind('mousemove');
487
- isError = true;
488
- setModalProperties();
489
- }
490
-
491
- //Set Width or Height Value
492
- function setValue(i, x) {
493
- var w = oB.docWidth;
494
- var h = oB.docHeight;
495
- if(oB.docWidth > $(window).width()) { w = $(window).width(); }
496
- if(oB.docHeight > $(window).height()) { h = $(window).height(); }
497
- if(i > 1) { return i; }
498
- else if(i > 0) {
499
- if(x === "width") { return w * i; }
500
- else if(x === "height") { return h * i; }
501
- }
502
- return false;
503
- }
504
-
505
- //iFrame Content
506
- function showiFrame() {
507
- var newhref = href.replace(/\?iframe$/, '');
508
- content = $('<iframe id="ob_iframe" frameborder="0" hspace="0" scrolling="auto" src="' + newhref + '"></iframe>').css({
509
- "height": setValue(oB.settings.iframeHeight, "height"),
510
- "width": setValue(oB.settings.iframeWidth, "width")
511
- });
512
- buildit();
513
- }
514
-
515
- //Inline Content
516
- function showInline() {
517
- if($(href).length && $(href).html() !== ""){
518
- content = $('<div id="ob_inline">' + $(href).html() + '</div>').css({
519
- "height": setValue(oB.settings.inlineHeight, "height"),
520
- "width": setValue(oB.settings.inlineWidth, "width")
521
- });
522
- buildit();
523
- }
524
- else { throwError(); }
525
- }
526
-
527
- //Video Content
528
- function showVideo() {
529
- var i;
530
- var mH = setValue(oB.settings.maxVideoHeight, "height");
531
- var mW = setValue(oB.settings.maxVideoWidth, "width");
532
- var a = 'height="100%" width="100%" type="text/html" frameborder="0" hspace="0" scrolling="auto"';
533
- var h;
534
- var w;
535
- var iI;
536
- if (obj.data('ob_data').ob_height && obj.data('ob_data').ob_width) {
537
- h = obj.data('ob_data').ob_height;
538
- w = obj.data('ob_data').ob_width;
539
- if(h > mH){
540
- w = w * mH / h;
541
- h = mH;
542
- }
543
- if(w > mW){
544
- h = h * mW / w;
545
- w = mW;
546
- }
547
- }
548
- else {
549
- w = mW;
550
- h = mH;
551
- }
552
-
553
- //If YouTube
554
- if (contentType === "youtube") {
555
- iI = href.indexOf("?v=") + 3;
556
- if (href.indexOf("&") > iI) { i = href.substring(iI, href.indexOf("&")); }
557
- else { i = href.substring(iI); }
558
- content = $('<iframe id="ob_video" '+a+' src="http://www.youtube.com/embed/'+i+'?fs=1&hl=en_US&rel=0&autoplay=1&autohide=1&wmode=transparent&enablejsapi=1"></iframe>');
559
- }
560
-
561
- //If Vimeo
562
- else if (contentType === "vimeo") {
563
- iI = href.indexOf("vimeo.com/") + 10;
564
- if (href.indexOf("?") > iI) { i = href.substring(iI, href.indexOf("?")); }
565
- else { i = href.substring(iI); }
566
- content = $('<iframe id="ob_video" '+a+' src="http://player.vimeo.com/video/'+i+'?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent"></iframe>');
567
- }
568
-
569
- //If Quicktime
570
- else if (contentType === "quicktime") {
571
- content = $('<div id="ob_video"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="' + h + '" width="' + w + '"><param name="src" value="' + href + '"><param name="wmode" value="transparent" /><param name="type" value="video/quicktime"><param name="autoplay" value="true"><embed src="' + href + '" height="' + h + '" width="' + w + '" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect"></embed></object></div>');
572
- }
573
-
574
- //If Flash
575
- else if (contentType === "flash") {
576
- content = $('<div id="ob_video"><embed flashVars="playerVars=autoPlay=yes" src="' + href + '" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true" allowScriptAccess="always" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash"></embed></div>');
577
- }
578
- content.css({ "width": w, "height": h });
579
- buildit();
580
- }
581
-
582
- //Image Content
583
- function showImage() {
584
- var img = new Image();
585
- content = $(img);
586
- content.load(function () {
587
- var mH = 0;
588
- var mW = 0;
589
- var w = img.width;
590
- var h = img.height;
591
- if(oB.slideshow && oB.playing) {
592
- oB.slideshowTimer = setTimeout(function(){
593
- oB.methods.navigate(1);
594
- },oB.settings.slideshowTimer);
595
- }
596
- mH = setValue(oB.settings.maxImageHeight, "height");
597
- mW = setValue(oB.settings.maxImageWidth, "width");
598
- if(h > mH){
599
- w = w * mH / h;
600
- h = mH ;
601
- }
602
- if(w > mW){
603
- h = h * mW / w;
604
- w = mW ;
605
- }
606
- if(h < oB.settings.contentMinHeight){
607
- content.css({
608
- "margin-top": (oB.settings.contentMinHeight / 2) - (h / 2)
609
- });
610
- }
611
- if(w < oB.settings.contentMinWidth){
612
- content.css({
613
- "margin-left": (oB.settings.contentMinWidth / 2) - (w / 2)
614
- });
615
- }
616
- content.css({
617
- "height": parseInt(h, 10),
618
- "width": parseInt(w, 10)
619
- });
620
- buildit();
621
- })
622
- .error(function () {
623
- throwError();
624
- })
625
- .attr({ src: href, id: 'ob_image' });
626
- }
627
-
628
- switch (contentType) {
629
- case "iframe":
630
- showiFrame();
631
- break;
632
- case "image":
633
- showImage();
634
- break;
635
- case "inline":
636
- showInline();
637
- break;
638
- case "quicktime":
639
- case "youtube":
640
- case "vimeo":
641
- case "flash":
642
- showVideo();
643
- break;
644
- default:
645
- $.error( 'OrangeBox: Unsupported Media');
646
- }
647
- },
648
- navigate : function( d, i, options ) {
649
- if ( options ) { $.extend( oB.settings, options ); }
650
- if(!i) {
651
- var c = parseInt($('#ob_content').attr('class').substr(7), 10);
652
- if(d === 1) { i = c + 1; }
653
- else if(d === -1) { i = c - 1; }
654
- }
655
- if(oB.galleryArray[i]) {
656
- oB.progress = true;
657
- $(document).trigger('oB_navigate', [i]);
658
- $('#ob_window').fadeOut(oB.settings.fadeTime, function () {
659
- $('#ob_title').empty();
660
- $('#ob_content').empty();
661
- oB.methods.showContent(oB.galleryArray[i], false );
662
- });
663
- }
664
- else { oB.progress = null; }
665
- if(!oB.galleryArray[i + 1]) { oB.methods.slideshowPause(); }
666
- },
667
- slideshowPlay : function() {
668
- $(document).trigger('oB_play');
669
- var c = parseInt($('#ob_content').attr('class').substr(7), 10);
670
- oB.playing = true;
671
- if(oB.galleryArray[c + 1]){ oB.methods.navigate(1); }
672
- else { oB.methods.navigate(0, 0); }
673
- },
674
- slideshowPause : function() {
675
- if(oB.playing) {
676
- $(document).trigger('oB_pause');
677
- oB.playing = false;
678
- clearTimeout(oB.slideshowTimer);
679
- }
680
- },
681
- showLoad : function( x ) {
682
- var loadTimer;
683
- var ob_load = $('<div id="ob_load"></div>').hide();
684
- if(x === "stop") {
685
- clearTimeout(loadTimer);
686
- $('#ob_load').remove();
687
- }
688
- else {
689
- clearTimeout(loadTimer);
690
- $("body").append(ob_load);
691
- loadTimer=setTimeout(function() { $('#ob_load').fadeIn(); }, 600);
692
- }
693
- }
694
- }
695
- };
696
-
697
- $.fn.orangeBox = function( method ) {
698
- if ( method === "showContent" || method === "setupData" ) {
699
- $.error( 'OrangeBox: ' + method + ' cannot be called externally' );
700
- return false;
701
- }
702
- else if ( oB.methods[method] ) {
703
- return oB.methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
704
- }
705
- else if ( typeof method === 'object' || ! method ) {
706
- return oB.methods.init.apply( this, arguments );
707
- }
708
- else {
709
- $.error( 'OrangeBox: Method ' + method + ' does not exist in OrangeBox' );
710
- return false;
711
- }
712
-
713
- };
714
- })(jQuery);
715
- }
716
- jQuery(document).ready(function($) {
717
- if (typeof orangebox_vars !== "undefined") { $('a[rel*=lightbox]').orangeBox(orangebox_vars); }
718
- else { $('a[rel*=lightbox]').orangeBox(); }
719
- });