diff --git a/colorbox.admin.inc b/colorbox.admin.inc index f8e9751851017ea7c9807612f97bb0726244ecad..7c39a8833a1005b859844b1547c2246a950749c0 100644 --- a/colorbox.admin.inc +++ b/colorbox.admin.inc @@ -194,7 +194,7 @@ function colorbox_admin_settings() { '#type' => 'select', '#title' => t('Opacity'), '#options' => drupal_map_assoc(array('0', '0.10', '0.15', '0.20', '0.25', '0.30', '0.35', '0.40', '0.45', '0.50', '0.55', '0.60', '0.65', '0.70', '0.75', '0.80', '0.85', '0.90', '0.95', '1')), - '#default_value' => variable_get('colorbox_opacity', '0.90'), + '#default_value' => variable_get('colorbox_opacity', '0.85'), '#description' => t('The overlay opacity level. Range: 0 to 1.'), ); $form['colorbox_custom_settings']['colorbox_text_current'] = array( diff --git a/colorbox.module b/colorbox.module index 2937378d5c468b8871768a697381069620ed7a52..c273f7243537e9bb72126a193b80f98fb970efe6 100644 --- a/colorbox.module +++ b/colorbox.module @@ -173,7 +173,7 @@ function _colorbox_doheader() { $js_settings = array( 'transition' => variable_get('colorbox_transition_type', 'elastic'), 'speed' => variable_get('colorbox_transition_speed', 350), - 'opacity' => variable_get('colorbox_opacity', '0.9'), + 'opacity' => variable_get('colorbox_opacity', '0.85'), 'slideshow' => variable_get('colorbox_slideshow', 0) ? TRUE : FALSE, 'slideshowAuto' => variable_get('colorbox_slideshowauto', 1) ? TRUE : FALSE, 'slideshowSpeed' => variable_get('colorbox_slideshowspeed', 2500), @@ -190,19 +190,11 @@ function _colorbox_doheader() { } else { $js_settings = array( - 'transition' => 'elastic', - 'speed' => 350, 'opacity' => '0.85', - 'slideshow' => FALSE, - 'slideshowAuto' => FALSE, - 'slideshowSpeed' => 2500, - 'slideshowStart' => '', - 'slideshowStop' => '', 'current' => t('{current} of {total}'), 'previous' => t('« Prev'), 'next' => t('Next »'), 'close' => t('Close'), - 'overlayClose' => TRUE, 'maxWidth' => '100%', 'maxHeight' => '100%', ); diff --git a/js/colorbox_load.js b/js/colorbox_load.js index d2300ab60c1258caa8760f50cee873c4a4eb0580..d1cf9aa18e48bdbc769b572f77d9c6b231553a69 100644 --- a/js/colorbox_load.js +++ b/js/colorbox_load.js @@ -5,40 +5,27 @@ Drupal.behaviors.initColorboxLoad = { if (!$.isFunction($.colorbox)) { return; } - $.urlParam = function(name, url){ - var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url); - if (!results) { return ''; } - return results[1] || ''; - }; - $('a, area, input', context).filter('.colorbox-load').once('init-colorbox-load-processed').colorbox({ - transition:settings.colorbox.transition, - speed:settings.colorbox.speed, - opacity:settings.colorbox.opacity, - slideshow:settings.colorbox.slideshow, - slideshowAuto:settings.colorbox.slideshowAuto, - slideshowSpeed:settings.colorbox.slideshowSpeed, - slideshowStart:settings.colorbox.slideshowStart, - slideshowStop:settings.colorbox.slideshowStop, - current:settings.colorbox.current, - previous:settings.colorbox.previous, - next:settings.colorbox.next, - close:settings.colorbox.close, - overlayClose:settings.colorbox.overlayClose, - maxWidth:settings.colorbox.maxWidth, - maxHeight:settings.colorbox.maxHeight, - innerWidth:function(){ - return $.urlParam('width', $(this).attr('href')); - }, - innerHeight:function(){ - return $.urlParam('height', $(this).attr('href')); - }, - iframe:function(){ - return $.urlParam('iframe', $(this).attr('href')); - }, - slideshow:function(){ - return $.urlParam('slideshow', $(this).attr('href')); + $.urlParams = function (url) { + var p = [], + e, + a = /\+/g, // Regex for replacing addition symbol with a space + r = /([^&=]+)=?([^&]*)/g, + d = function (s) { return decodeURIComponent(s.replace(a, ' ')); }, + q = url.split('?'); + while (e = r.exec(q[1])) { + if (e[1] == 'width') { e[1] = 'innerWidth'; } + if (e[1] == 'height') { e[1] = 'innerHeight'; } + p[d(e[1])] = d(e[2]); } - }); + return p; + }; + $('a, area, input', context) + .filter('.colorbox-load') + .once('init-colorbox-load-processed', function () { + var params = $.urlParams($(this).attr('href')); + $.extend(settings.colorbox, params); + }) + .colorbox(settings.colorbox); } };