summaryrefslogtreecommitdiff
path: root/sites/all/modules/colorbox/js/colorbox_load.js
diff options
context:
space:
mode:
Diffstat (limited to 'sites/all/modules/colorbox/js/colorbox_load.js')
-rw-r--r--sites/all/modules/colorbox/js/colorbox_load.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/sites/all/modules/colorbox/js/colorbox_load.js b/sites/all/modules/colorbox/js/colorbox_load.js
new file mode 100644
index 000000000..30e99a778
--- /dev/null
+++ b/sites/all/modules/colorbox/js/colorbox_load.js
@@ -0,0 +1,42 @@
+(function ($) {
+
+Drupal.behaviors.initColorboxLoad = {
+ attach: function (context, settings) {
+ if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
+ return;
+ }
+ $.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])) {
+ e[1] = d(e[1]);
+ e[2] = d(e[2]);
+ switch (e[2].toLowerCase()) {
+ case 'true':
+ case 'yes':
+ e[2] = true;
+ break;
+ case 'false':
+ case 'no':
+ e[2] = false;
+ break;
+ }
+ if (e[1] == 'width') { e[1] = 'innerWidth'; }
+ if (e[1] == 'height') { e[1] = 'innerHeight'; }
+ p[e[1]] = e[2];
+ }
+ return p;
+ };
+ $('.colorbox-load', context)
+ .once('init-colorbox-load', function () {
+ var params = $.urlParams($(this).attr('href'));
+ $(this).colorbox($.extend({}, settings.colorbox, params));
+ });
+ }
+};
+
+})(jQuery);