ecm_pictures 0.0.5 → 0.0.8

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.
@@ -7,12 +7,25 @@ if defined?(ActiveAdmin)
7
7
  config.sort_order = 'position'
8
8
  sortable_member_actions
9
9
 
10
- form do |f|
10
+ form :html => { :enctype => "multipart/form-data" } do |f|
11
11
  f.inputs do
12
12
  f.input :name
13
13
  f.input :description
14
+ f.input :link_images
14
15
  end
15
16
 
17
+ f.inputs do
18
+ f.has_many :pictures do |p|
19
+ p.input :name
20
+ #if !p.object.id.nil?
21
+ if p.object.persisted?
22
+ p.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
23
+ end
24
+ p.input :image, :as => :file, :hint => p.template.image_tag(p.object.image.url(:thumb))
25
+ p.input :description
26
+ end
27
+ end
28
+
16
29
  f.buttons
17
30
  end
18
31
 
@@ -20,6 +33,9 @@ if defined?(ActiveAdmin)
20
33
  sortable_columns
21
34
  column :name
22
35
  column :pictures_count
36
+ column :link_images do |picture_gallery|
37
+ I18n.t(picture_gallery.link_images)
38
+ end
23
39
  column :created_at
24
40
  column :updated_at
25
41
  default_actions
@@ -29,6 +45,9 @@ if defined?(ActiveAdmin)
29
45
  attributes_table do
30
46
  row :name
31
47
  row :pictures_count
48
+ row :link_images do |picture_gallery|
49
+ I18n.t(picture_gallery.link_images)
50
+ end
32
51
  row :created_at
33
52
  row :updated_at
34
53
  end
@@ -45,7 +64,6 @@ if defined?(ActiveAdmin)
45
64
  column :thumbnail do |picture|
46
65
  link_to(image_tag(picture.image.url(:thumb)), admin_ecm_pictures_picture_path(picture))
47
66
  end
48
- column :picture_gallery
49
67
  column :name
50
68
  column :image_file_size, :sortable => :image_file_size do |picture|
51
69
  number_to_human_size(picture.image_file_size)
@@ -0,0 +1 @@
1
+ //= require ./orangebox/orangebox
@@ -0,0 +1,719 @@
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
+ });
@@ -0,0 +1,8 @@
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');}else{var oB;(function($){oB={progress:'',playing:'',slideshowTimer:'',slideshow:'',docHeight:'',docWidth:'',controlTimer:'',settings:{autoplay:false,fadeControls:false,fadeCaption:true,keyboardNavigation:true,orangeControls:false,showClose:true,showDots:false,showNav:true,addThis:true,notFound:'Not Found',overlayOpacity:0.95,contentBorderWidth:4,contentMinWidth:200,contentMinHeight:100,iframeWidth:0.75,iframeHeight:0.75,inlineWidth:0.5,inlineHeight:0,maxImageWidth:0.75,maxImageHeight:0.75,maxVideoWidth:640,maxVideoHeight:390,fadeTime:200,slideshowTimer:3000},methods:{init:function(options){if(!$('#ob_window').length){if(options){$.extend(oB.settings,options);}if(oB.settings.addThis){$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4dd42f2b5b9fc332');}return this.each(function(){$(this).click(function(e){e.preventDefault();oB.methods.create(this);});});}return false;},create:function(obj,options){if(options){$.extend(oB.settings,options);}if(!obj){obj=this;}var dotnav=$('<ul id="ob_dots"></ul>');var mainObject;var rel=$(obj).attr('rel');var gallery;oB.galleryArray=new Array();oB.slideshow=true;oB.docHeight=$(document).height();oB.docWidth=$(document).width();if(!jQuery().orangeControls){oB.settings.orangeControls=false;}function uniqueCheck(z,h){var i;for(i=0;i<oB.galleryArray.length;i++){var x=oB.galleryArray[i].data('ob_data').ob_href;if(h&&x===z.attr('id')){return false;}else if(x===z.attr('href')){return false;}}return true;}if(rel&&rel.indexOf("[")){gallery=rel.substring(rel.indexOf("[")+1,rel.indexOf("]"));}if(gallery){var a=0;var objectMatch='a[rel*=\'lightbox['+gallery+']\']';$(objectMatch).each(function(){var x=uniqueCheck($(this),false);oB.methods.setupData($(this),false,a);var z=$(this).data('ob_data').ob_contentType;if(x&&z!==false){oB.galleryArray[a]=$(this);if(oB.settings.showDots){dotnav.append('<li id="ob_dot'+a+'"></li>');}if(z!=="image"){oB.slideshow=false;}a++;}});if($('#ob_gallery').length>0){$('#ob_gallery li.'+gallery).each(function(){var x=uniqueCheck($(this),true);oB.methods.setupData($(this),true,a);var z=$(this).data('ob_data').ob_contentType;if(x&&z!==false){oB.galleryArray[a]=$(this);if(oB.settings.showDots){dotnav.append('<li id="ob_dot'+a+'"></li>');}if(z!=="image"){oB.slideshow=false;}a++;}});}}if($(obj).attr('href')==="ob_hidden_set"){mainObject=oB.galleryArray[0];oB.methods.setupData(mainObject,true,0);}else{mainObject=$(obj);oB.methods.setupData(mainObject,false,false);}if(!mainObject.data('ob_data').ob_contentType){mainObject=oB.galleryArray[0];}if(mainObject.data('ob_data').ob_contentType){var overlay=$('<div id="ob_overlay"></div>');var container=$('<div id="ob_container"></div>');var floater=$('<div id="ob_float"></div>');var window=$('<div id="ob_window"></div>').click(function(e){e.stopPropagation();});var close=$('<div title="close" class="ob_controls ob_cs" id="ob_close"></div>').click(function(){oB.methods.destroy(oB.settings);});var title=$('<div id="ob_title"></div>');var navRight=$('<a class="ob_nav ob_controls ob_cs" id="ob_right"><span class="ob_cs" id="ob_right-ico"></span></a>');var navLeft=$('<a class="ob_nav ob_controls ob_cs" id="ob_left"><span class="ob_cs" id="ob_left-ico"></span></a>');var content=$('<div id="ob_content"></div>').css({"border-width":oB.settings.contentBorderWidth,"min-height":oB.settings.contentMinHeight,"min-width":oB.settings.contentMinWidth});oB.playing=oB.settings.autoplay;oB.progress=null;overlay.css({"opacity":oB.settings.overlayOpacity,"min-height":$(document).height(),"min-width":$(document).width()});if(typeof document.body.style.maxHeight==="undefined"){$("body","html").css({height:"100%",width:"100%"});}$("body").append(overlay.click(function(){oB.methods.destroy(oB.settings);}));$("body").append(container.click(function(){oB.methods.destroy(oB.settings);}));if(oB.settings.showClose){window.append(close);}window.append(content).append(title);$("#ob_container").append(floater).append(window);overlay.show(oB.settings.fadeTime);function handleEscape(e){if(oB.progress===null){if(e.keyCode===27){oB.methods.destroy(oB.settings);}else if(e.keyCode===37){oB.methods.slideshowPause();oB.methods.navigate(-1);}else if(e.keyCode===39){oB.methods.slideshowPause();oB.methods.navigate(1);}}}if(oB.settings.keyboardNavigation){$(document).keydown(handleEscape);}if(oB.galleryArray.length>0){if(oB.settings.orangeControls&&oB.galleryArray.length>1){$(document).orangeControls();$(document).bind('oc_right',function(){if(oB.progress===null){oB.methods.slideshowPause();oB.methods.navigate(1);}});$(document).bind('oc_left',function(){if(oB.progress===null){oB.methods.slideshowPause();oB.methods.navigate(-1);}});$(document).bind('oc_pause',function(){$(document).orangeControls('update',{'play':true});oB.methods.slideshowPause();});$(document).bind('oc_play',function(){$(document).orangeControls('update',{'play':false});oB.methods.slideshowPlay();});}if(oB.settings.showNav&&oB.galleryArray.length>1){window.append(navRight).append(navLeft);navLeft.click(function(e){if(oB.progress===null){oB.methods.slideshowPause();e.stopPropagation();oB.methods.navigate(-1);}});navRight.click(function(e){if(oB.progress===null){oB.methods.slideshowPause();e.stopPropagation();oB.methods.navigate(1);}});}if(oB.settings.showDots&&oB.galleryArray.length>1){window.append(dotnav);dotnav.find("li").click(function(){if(!$(this).hasClass('current')&&oB.progress===null){oB.methods.slideshowPause();var x=$(this).attr('id').substr(6);dotnav.find("li").removeClass('current');$(this).addClass('current');oB.methods.navigate("",x);}});}}oB.methods.showContent(mainObject,true);}},setupData:function(o,v,x){var z;var c=false;var w=0;var h=0;var i;var t="";if(typeof o.attr('title')!=="undefined"){t=o.attr('title');}if(v){z=o.attr('id');}else{z=o.attr('href');}if(z){if(z.match(/(width\=)|(height\=)/)){var heightIndex=z.indexOf("height=")+7;var widthIndex=z.indexOf("width=")+6;var heightString=z.substr(heightIndex);var widthString=z.substr(widthIndex);if(heightString.indexOf("&")>0){heightString=heightString.substr(0,heightString.indexOf("&"));}if(widthString.indexOf("&")>0){widthString=widthString.substr(0,widthString.indexOf("&"));}w=widthString;h=heightString;}if(z.match(/\?iframe/)){c="iframe";}else if(z.match(/\.(?:jpg|jpeg|bmp|png|gif)$/)){c="image";}else if(z.match(/\.(?:mov|mp4|m4v)(\?.{6,}\&.{6,})?$/)){c="quicktime";}else if(z.match(/\.swf(\?.{6,}\&.{6,})?$/)){c="flash";}else if(z.match(/^http:\/\/\w{0,3}\.?youtube\.\w{2,3}\/watch\?v=[\w\-]{11}/)){c="youtube";}else if(z.match(/^http:\/\/\w{0,3}\.?vimeo\.com\/\d{1,10}/)){c="vimeo";}else if(z.match(/^#\w{1,}/)){c="inline";}else if(!z.match(/ob_hidden_set/)){$.error('OrangeBox: Unsupported Media');}if(x===false){for(i=0;i<oB.galleryArray.length;i++){if(oB.galleryArray[i].data('ob_data').ob_href===z){x=i;}}}}o.data('ob_data',{ob_height:h,ob_width:w,ob_index:x,ob_contentType:c,ob_href:z,ob_title:t,ob_linkText:o.attr('data-ob_linkText'),ob_link:o.attr('data-ob_link'),ob_caption:o.attr('data-ob_caption'),ob_linkTarget:o.attr('data-ob_linkTarget'),ob_share:o.attr('data-ob_share'),ob_shareLink:o.attr('data-ob_shareLink')});},destroy:function(options,x){$(document).trigger('oB_closing');if(options){$.extend(oB.settings,options);}oB.methods.showLoad("stop");clearTimeout(oB.controlTimer);clearTimeout(oB.slideshowTimer);clearTimeout(oB.scrollTimer);if(oB.settings.orangeControls){$(document).orangeControls('destroy',oB.settings.fadeTime);}$(document).unbind("keydown").unbind("mousemove");$('#ob_overlay').fadeOut(oB.settings.fadeTime,function(){$(this).remove().empty();});$('#ob_container').fadeOut(oB.settings.fadeTime,function(){$(this).remove().empty();$(document).trigger('oB_closed');if(x&&jQuery.isFunction(x)){x();}});},showContent:function(obj,initial){var href=obj.data('ob_data').ob_href;var title=obj.data('ob_data').ob_title;var contentType=obj.data('ob_data').ob_contentType;var content;var currentIndex=obj.data('ob_data').ob_index;var ob_caption=$('<div id="ob_caption"></div>').css({"opacity":0.95});if(oB.settings.fadeCaption){ob_caption.hide();$('#ob_content').hover(function(){$('#ob_caption').stop().fadeTo(oB.settings.fadeTime,0.95);},function(){$('#ob_caption').stop().fadeOut(oB.settings.fadeTime);});}var isError=false;$('#ob_overlay').css({"height":oB.docHeight});$('#ob_content').removeClass().addClass('content'+currentIndex);oB.methods.showLoad();function setModalProperties(){var oH=content.outerHeight();var oW=content.outerWidth();var wH=oH+(oB.settings.contentBorderWidth*2);var wW=oW+(oB.settings.contentBorderWidth*2);var p=$(window).scrollTop();var target="";var rel="";if(p===0){p=$(document).scrollTop();}if(p===0){p=window.pageYOffset;}if(obj.data('ob_data').ob_linkText){if(obj.data('ob_data').ob_link){if(obj.data('ob_data').ob_linkTarget==="_self"){target='target="_self"';}else{target='target="_blank"';}title=title+' <a href="'+obj.data('ob_data').ob_link+'" '+target+' '+rel+' >'+obj.data('ob_data').ob_linkText+'</a>';}else{title=title+' '+obj.data('ob_data').ob_linkText;}}$('#ob_title').append('<h3>'+title+'</h3>');if(obj.data('ob_data').ob_caption){ob_caption.append('<p>'+obj.data('ob_data').ob_caption+'</p>');$('#ob_content').append(ob_caption);}if(wH<oB.settings.contentMinHeight){wH=oB.settings.contentMinHeight+(oB.settings.contentBorderWidth*2);}if(wW<oB.settings.contentMinWidth){wW=oB.settings.contentMinWidth+(oB.settings.contentBorderWidth*2);}$("#ob_container").css({"margin-top":p});$("#ob_window").css({"height":wH,"width":wW});$('#ob_float').css({"margin-bottom":-($("#ob_window").outerHeight(true))/2});if(isError){$('#ob_content').css({"height":oH,"width":oW,"min-height":0});}else{$('#ob_content').css({"height":wH-(oB.settings.contentBorderWidth*2),"width":wW-(oB.settings.contentBorderWidth*2),"min-height":oB.settings.contentMinHeight});}}function setControls(){if(oB.settings.showDots){$('#ob_dots').find('li').each(function(){var i='ob_dot'+obj.data('ob_data').ob_index;if($(this).attr('id')===i){$(this).addClass('current');}else{$(this).removeClass('current');}});}clearTimeout(oB.controlTimer);if(oB.settings.orangeControls){var oc_settings={'play':true,'play_active':false,'left_active':false,'right_active':false};if(oB.playing&&oB.galleryArray[currentIndex+1]&&oB.galleryArray.length>1){oc_settings.play=false;}if(oB.galleryArray[currentIndex+1]&&oB.galleryArray.length>1){oc_settings.right_active=true;}if(oB.galleryArray[currentIndex-1]&&oB.galleryArray.length>1){oc_settings.left_active=true;}if(oB.slideshow){oc_settings.play_active=true;}$(document).orangeControls('update',oc_settings);}function showControls(){if(oB.galleryArray.length>1){if(oB.settings.orangeControls){$(document).orangeControls('toggle',{'time':oB.settings.fadeTime,'fade':"in"});}if(oB.galleryArray[currentIndex+1]){$('#ob_right').fadeIn(oB.settings.fadeTime);$('#ob_right-ico').fadeIn(oB.settings.fadeTime);}else{$('#ob_right').hide();}if(oB.galleryArray[currentIndex-1]){$('#ob_left').fadeIn(oB.settings.fadeTime);$('#ob_left-ico').fadeIn(oB.settings.fadeTime);}else{$('#ob_left').hide();}}$('#ob_close').fadeIn(oB.settings.fadeTime);}if(oB.settings.fadeControls){if(!oB.galleryArray[currentIndex+1]||!oB.galleryArray[currentIndex-1]||initial){showControls();oB.controlTimer=setTimeout(function(){$('.ob_controls').fadeOut(oB.settings.fadeTime);if(oB.settings.orangeControls){$(document).orangeControls('toggle',{'time':oB.settings.fadeTime,'fade':"out"});}},1200);}$(document).mousemove(function(event){clearTimeout(oB.controlTimer);oB.controlTimer=setTimeout(function(){showControls();if(!$(event.target).hasClass('ob_cs')&&!$(event.target).hasClass('oc_class')){oB.controlTimer=setTimeout(function(){$('.ob_controls').fadeOut(oB.settings.fadeTime);if(oB.settings.orangeControls){$(document).orangeControls('toggle',{'time':oB.settings.fadeTime,'fade':"out"});}},1200);}},20);});}else{showControls();}}function buildit(){oB.methods.showLoad("stop");$('#ob_content').append(content);if(oB.settings.addThis&&contentType!=="iframe"&&contentType!=="inline"&&obj.data('ob_data').ob_share!=="false"){$('#ob_share').empty().remove();var addThis=$('<a id="ob_share" class="addthis_button_compact"></a>');var shareClass="ob_share-"+title;var link=href;if(obj.data('ob_data').ob_shareLink){link=obj.data('ob_data').ob_shareLink;}addThis.addClass(shareClass);$('#ob_window').append(addThis);$('#ob_title').css('margin-right',24);addthis.button('.'+shareClass,{services_compact:'twitter,facebook,digg,delicious,more',ui_offset_left:-244,ui_offset_top:4},{url:link,title:title});$('#ob_share').html('').append('<span class="at300bs at15nc at15t_compact"></span>');if(title===""){title="share"}}$('#ob_window').fadeIn(oB.settings.fadeTime,function(){if(initial){$(document).trigger('oB_init');}$('#ob_overlay').css({"height":$(document).height()});});setModalProperties();setControls();oB.progress=null;}function throwError(){content=$('<div id="ob_error">'+oB.settings.notFound+'</div>');oB.methods.showLoad("stop");$('#ob_content').empty().append(content);$('#ob_window').fadeIn(oB.settings.fadeTime,function(){$('#ob_overlay').css({"height":$(document).height()});});$('#ob_title').hide();$('#ob_right').hide();$('#ob_left').hide();$('#ob_dots').hide();$(document).unbind('mousemove');isError=true;setModalProperties();}function setValue(i,x){var w=oB.docWidth;var h=oB.docHeight;if(oB.docWidth>$(window).width()){w=$(window).width();}if(oB.docHeight>$(window).height()){h=$(window).height();}if(i>1){return i;}else if(i>0){if(x==="width"){return w*i;}else if(x==="height"){return h*i;}}return false;}function showiFrame(){var newhref=href.replace(/\?iframe$/,'');content=$('<iframe id="ob_iframe" frameborder="0" hspace="0" scrolling="auto" src="'+newhref+'"></iframe>').css({"height":setValue(oB.settings.iframeHeight,"height"),"width":setValue(oB.settings.iframeWidth,"width")});buildit();}function showInline(){if($(href).length&&$(href).html()!==""){content=$('<div id="ob_inline">'+$(href).html()+'</div>').css({"height":setValue(oB.settings.inlineHeight,"height"),"width":setValue(oB.settings.inlineWidth,"width")});buildit();}else{throwError();}}function showVideo(){var i;var mH=setValue(oB.settings.maxVideoHeight,"height");var mW=setValue(oB.settings.maxVideoWidth,"width");var a='height="100%" width="100%" type="text/html" frameborder="0" hspace="0" scrolling="auto"';var h;var w;var iI;if(obj.data('ob_data').ob_height&&obj.data('ob_data').ob_width){h=obj.data('ob_data').ob_height;w=obj.data('ob_data').ob_width;if(h>mH){w=w*mH/h;h=mH;}if(w>mW){h=h*mW/w;w=mW;}}else{w=mW;h=mH;}if(contentType==="youtube"){iI=href.indexOf("?v=")+3;if(href.indexOf("&")>iI){i=href.substring(iI,href.indexOf("&"));}else{i=href.substring(iI);}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>');}else if(contentType==="vimeo"){iI=href.indexOf("vimeo.com/")+10;if(href.indexOf("?")>iI){i=href.substring(iI,href.indexOf("?"));}else{i=href.substring(iI);}content=$('<iframe id="ob_video" '+a+' src="http://player.vimeo.com/video/'+i+'?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent"></iframe>');}else if(contentType==="quicktime"){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>');}else if(contentType==="flash"){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>');}content.css({"width":w,"height":h});buildit();}function showImage(){var img=new Image();content=$(img);content.load(function(){var mH=0;var mW=0;var w=img.width;var h=img.height;if(oB.slideshow&&oB.playing){oB.slideshowTimer=setTimeout(function(){oB.methods.navigate(1);},oB.settings.slideshowTimer);}mH=setValue(oB.settings.maxImageHeight,"height");mW=setValue(oB.settings.maxImageWidth,"width");if(h>mH){w=w*mH/h;h=mH;}if(w>mW){h=h*mW/w;w=mW;}if(h<oB.settings.contentMinHeight){content.css({"margin-top":(oB.settings.contentMinHeight/2)-(h/2)});}if(w<oB.settings.contentMinWidth){content.css({"margin-left":(oB.settings.contentMinWidth/2)-(w/2)});}content.css({"height":parseInt(h,10),"width":parseInt(w,10)});buildit();}).error(function(){throwError();}).attr({src:href,id:'ob_image'});}switch(contentType){case"iframe":showiFrame();break;case"image":showImage();break;case"inline":showInline();break;case"quicktime":case"youtube":case"vimeo":case"flash":showVideo();break;default:$.error('OrangeBox: Unsupported Media');}},navigate:function(d,i,options){if(options){$.extend(oB.settings,options);}if(!i){var c=parseInt($('#ob_content').attr('class').substr(7),10);if(d===1){i=c+1;}else if(d===-1){i=c-1;}}if(oB.galleryArray[i]){oB.progress=true;$(document).trigger('oB_navigate',[i]);$('#ob_window').fadeOut(oB.settings.fadeTime,function(){$('#ob_title').empty();$('#ob_content').empty();oB.methods.showContent(oB.galleryArray[i],false);});}else{oB.progress=null;}if(!oB.galleryArray[i+1]){oB.methods.slideshowPause();}},slideshowPlay:function(){$(document).trigger('oB_play');var c=parseInt($('#ob_content').attr('class').substr(7),10);oB.playing=true;if(oB.galleryArray[c+1]){oB.methods.navigate(1);}else{oB.methods.navigate(0,0);}},slideshowPause:function(){if(oB.playing){$(document).trigger('oB_pause');oB.playing=false;clearTimeout(oB.slideshowTimer);}},showLoad:function(x){var loadTimer;var ob_load=$('<div id="ob_load"></div>').hide();if(x==="stop"){clearTimeout(loadTimer);$('#ob_load').remove();}else{clearTimeout(loadTimer);$("body").append(ob_load);loadTimer=setTimeout(function(){$('#ob_load').fadeIn();},600);}}}};$.fn.orangeBox=function(method){if(method==="showContent"||method==="setupData"){$.error('OrangeBox: '+method+' cannot be called externally');return false;}else if(oB.methods[method]){return oB.methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return oB.methods.init.apply(this,arguments);}else{$.error('OrangeBox: Method '+method+' does not exist in OrangeBox');return false;}};})(jQuery);}jQuery(document).ready(function($){if(typeof orangebox_vars!=="undefined"){$('a[rel*=lightbox]').orangeBox(orangebox_vars);}else{$('a[rel*=lightbox]').orangeBox();}});
@@ -0,0 +1 @@
1
+ //= require_tree ./orangebox
@@ -0,0 +1,160 @@
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
+ #ob_overlay {
9
+ background-color:#333;
10
+ display:none;
11
+ height:100%;
12
+ left:0;
13
+ position:fixed;
14
+ top:0;
15
+ width:100%;
16
+ z-index:100;
17
+ }
18
+ #ob_container {
19
+ height:100%;
20
+ left:0;
21
+ position:absolute;
22
+ top:0;
23
+ width:100%;
24
+ z-index:101;
25
+ }
26
+ #ob_float {
27
+ float:left;
28
+ height:50%;
29
+ min-width:100%;
30
+ }
31
+ #ob_window {
32
+ clear:both;
33
+ cursor:default;
34
+ display:none;
35
+ position:relative;
36
+ z-index:102;
37
+ margin:0 auto;
38
+ padding:22px;
39
+ }
40
+ #ob_content {
41
+ background-color:#fff;
42
+ border:0 solid #fff;
43
+ }
44
+ #ob_caption {
45
+ color:#333;
46
+ background-color:#fff;
47
+ position:absolute;
48
+ bottom:15%;
49
+ font-size:small;
50
+ max-width:75%;
51
+ }
52
+ #ob_caption p {
53
+ padding:0;
54
+ margin:10px;
55
+ cursor:text;
56
+ }
57
+ #ob_window img {
58
+ display:block;
59
+ }
60
+ #ob_inline {
61
+ padding:20px;
62
+ overflow:auto;
63
+ }
64
+ #ob_load {
65
+ -moz-border-radius:5px;
66
+ background:url(<%= asset_path "orangebox/loading.gif" %>) no-repeat center;
67
+ background-color:#fff;
68
+ border-radius:5px;
69
+ height:40px;
70
+ left:50%;
71
+ position:fixed;
72
+ top:50%;
73
+ width:40px;
74
+ z-index:103;
75
+ margin:-25px 0 0 -25px;
76
+ padding:5px;
77
+ }
78
+ #ob_error {
79
+ text-align:center;
80
+ width:250px;
81
+ padding:10px;
82
+ }
83
+ #ob_close {
84
+ background:url(<%= asset_path "orangebox/buttons.png" %>);
85
+ cursor:pointer;
86
+ height:30px;
87
+ left:0;
88
+ position:absolute;
89
+ top:0;
90
+ width:30px;
91
+ z-index:1103;
92
+ }
93
+ #ob_title {
94
+ color:#fff;
95
+ left:auto;
96
+ position:absolute;
97
+ right:22px;
98
+ top:-2px;
99
+ z-index:1103;
100
+ }
101
+ #ob_title h3 {
102
+ margin:0;
103
+ padding:0;
104
+ }
105
+ #ob_left,#ob_right {
106
+ bottom:8px;
107
+ cursor:pointer;
108
+ height:100%;
109
+ position:absolute;
110
+ width:75px;
111
+ z-index:1102;
112
+ }
113
+ #ob_left { left:-53px; }
114
+ #ob_right { right:-53px; }
115
+ #ob_left-ico,#ob_right-ico {
116
+ cursor:pointer;
117
+ display:block;
118
+ height:30px;
119
+ margin-top:-9px;
120
+ position:absolute;
121
+ top:50%;
122
+ width:30px;
123
+ z-index:1102;
124
+ }
125
+ #ob_left-ico {
126
+ background:url(<%= asset_path "orangebox/buttons.png" %>) center;
127
+ right:10px;
128
+ }
129
+ #ob_right-ico {
130
+ background:url(<%= asset_path "orangebox/buttons.png" %>) right;
131
+ left:10px;
132
+ }
133
+ #ob_left:hover,#ob_right:hover { visibility:visible; }
134
+ #ob_dots {
135
+ list-style:none;
136
+ text-align:center;
137
+ margin:0;
138
+ padding:0;
139
+ width:100%;
140
+ }
141
+ #ob_dots li {
142
+ height:8px;
143
+ list-style:none;
144
+ width:8px;
145
+ margin:3px;
146
+ -moz-border-radius:4px;
147
+ background-color:#666;
148
+ border-radius:4px;
149
+ cursor:pointer;
150
+ display: -moz-inline-stack;
151
+ display: inline-block;
152
+ zoom:1;
153
+ *display:inline;
154
+ }
155
+ #ob_dots .current { background-color:#CCC!important; }
156
+ #ob_share {
157
+ position:absolute;
158
+ right:24px;
159
+ top:3px;
160
+ }
@@ -17,7 +17,13 @@ module Ecm::PicturesHelper
17
17
  gallery.pictures.collect do |picture|
18
18
  content_tag(:li, {:class => 'picture', :id => "picture-#{picture.to_param}"}) do
19
19
  concat(content_tag(:h2, picture.name, :class => 'picture-name')) unless picture.name.blank?
20
- concat(link_to(image_tag(picture.image.url(options[:preview_style]), :alt => picture.description), picture.image.url, {:rel => "lightbox[#{gallery_identifier}]"}))
20
+
21
+ # Check if we should link images or not.
22
+ if gallery.link_images
23
+ concat(link_to(image_tag(picture.image.url(options[:preview_style]), :alt => picture.description), "#{picture.image.url}#{File.extname(picture.image_file_name)}", {:rel => "lightbox[#{gallery_identifier}]"}))
24
+ else
25
+ concat(image_tag(picture.image.url(options[:preview_style]), :alt => picture.description))
26
+ end
21
27
  concat(content_tag(:div, picture.description, :class => 'picture-description'))
22
28
  end
23
29
  end.join.html_safe
@@ -3,18 +3,29 @@ class Ecm::Pictures::PictureGallery < ActiveRecord::Base
3
3
 
4
4
  # associations
5
5
  has_many :pictures
6
+ accepts_nested_attributes_for :pictures, :allow_destroy => true
6
7
 
7
8
  # acts as list
8
9
  acts_as_list
9
10
  default_scope :order => 'position ASC'
10
11
 
12
+ # defaults
13
+ after_initialize :set_defaults
14
+
11
15
  # friendly id
12
16
  extend FriendlyId
13
17
  friendly_id :name, :use => :slugged
14
18
 
15
19
  # attributes
16
- attr_accessible :description, :name
20
+ attr_accessible :description, :link_images, :name , :pictures_attributes
17
21
 
18
22
  # validations
19
23
  validates :name, :presence => true
24
+
25
+
26
+ def set_defaults
27
+ if new_record?
28
+ self.link_images = true if self.link_images.nil?
29
+ end
30
+ end
20
31
  end
@@ -4,6 +4,7 @@ de:
4
4
  ecm/pictures/picture_gallery:
5
5
  created_at: "Erstellt am"
6
6
  description: "Beschreibung"
7
+ link_images: "Bilder verlinken"
7
8
  name: "Name"
8
9
  pictures: "Bilder"
9
10
  pictures_count: "Bilder"
@@ -3,6 +3,7 @@ class CreateEcmPicturesPictureGalleries < ActiveRecord::Migration
3
3
  create_table :ecm_pictures_picture_galleries do |t|
4
4
  t.string :name
5
5
  t.text :description
6
+ t.boolean :link_images
6
7
  t.integer :pictures_count
7
8
 
8
9
  # acts as list
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Pictures
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ecm_pictures
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Roberto Vasquez Angel
@@ -192,6 +192,13 @@ files:
192
192
  - app/models/ecm/pictures/picture.rb
193
193
  - app/admin/ecm/pictures/pictures.rb
194
194
  - app/admin/ecm/pictures/picture_galleries.rb
195
+ - app/assets/images/orangebox/buttons.png
196
+ - app/assets/images/orangebox/loading.gif
197
+ - app/assets/stylesheets/ecm_pictures.css.scss
198
+ - app/assets/stylesheets/orangebox/orangebox.css.erb
199
+ - app/assets/javascripts/ecm_pictures.js
200
+ - app/assets/javascripts/orangebox/orangebox.min.js
201
+ - app/assets/javascripts/orangebox/orangebox.js
195
202
  - config/locales/ecm.pictures.picture_gallery.de.yml
196
203
  - config/locales/ecm.pictures.de.yml
197
204
  - config/locales/ecm.pictures.picture.de.yml