Commit 270a3837 authored by frjo's avatar frjo
Browse files

Issue #1161342: Patch to make it possibel to change any Colorbox plugin...

Issue #1161342: Patch to make it possibel to change any Colorbox plugin setting with an url argument.
parent 934e6842
......@@ -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(
......
......@@ -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%',
);
......
......@@ -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);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment