summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Jonsson2011-07-01 07:13:57 (GMT)
committer Fredrik Jonsson2011-07-01 07:13:57 (GMT)
commit270a3837f1888c6be9b7ddf00b8198217e272127 (patch)
treeb8f1b5594b3e0490e975d8f0b7302beb79b45872
parent934e68429eb974bc20e583932a3f89103f147837 (diff)
Issue #1161342: Patch to make it possibel to change any Colorbox plugin setting with an url argument.
-rw-r--r--colorbox.admin.inc2
-rw-r--r--colorbox.module10
-rw-r--r--js/colorbox_load.js53
3 files changed, 22 insertions, 43 deletions
diff --git a/colorbox.admin.inc b/colorbox.admin.inc
index f8e9751..7c39a88 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 2937378..c273f72 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 d2300ab..d1cf9aa 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);
}
};