1(function (name, definition) { 2 3 if (typeof module != 'undefined') { 4 module.exports = definition() 5 } else if (typeof define == 'function' && typeof define.amd == 'object') { 6 define(definition) 7 } else { 8 this[name] = definition() 9 } 10 11})('Colibri', 12 function () { 13 var $ = jQuery; 14 if (typeof jQuery === 'undefined') { 15 throw new Error('Colibri requires jQuery') 16 } 17 18 ;(function ($) { 19 var version = $.fn.jquery.split('.'); 20 if (version[0] === 1 && version[1] < 8) { 21 throw new Error('Colibri requires at least jQuery v1.8'); 22 } 23 })(jQuery); 24 25 var Colibri; 26 27 var lib_prefix = "colibri."; 28 29 ;(function () { 30 // Inherits 31 Function.prototype.inherits = function (parent) { 32 var F = function () { 33 }; 34 F.prototype = parent.prototype; 35 var f = new F(); 36 37 for (var prop in this.prototype) { 38 f[prop] = this.prototype[prop]; 39 } 40 this.prototype = f; 41 this.prototype.super = parent.prototype; 42 }; 43 44 // Core Class 45 Colibri = function (element, options) { 46 options = (typeof options === 'object') ? options : {}; 47 48 this.$element = $(element); 49 var instanceId = this.$element.data('colibri-id'); 50 51 var instanceData = Colibri.getData(instanceId); 52 this.instance = instanceId; 53 54 var elementData = this.$element.data(); 55 56 this.opts = $.extend(true, {}, this.defaults, $.fn[lib_prefix + this.namespace].options, elementData, instanceData, options); 57 this.$target = (typeof this.opts.target === 'string') ? $(this.opts.target) : null; 58 }; 59 60 Colibri.getData = function (id) { 61 if (window.colibriData && window.colibriData[id]) { 62 return window.colibriData[id]; 63 } 64 65 return {}; 66 }; 67 68 Colibri.isCustomizerPreview = function () { 69 return !!window.colibriCustomizerPreviewData; 70 } 71 // Core Functionality 72 Colibri.prototype = { 73 updateOpts: function (updatedData) { 74 var instanceId = this.instance; 75 var instanceData = $.extend(true, {}, this.defaults, Colibri.getData(instanceId)); 76 var updatedDataWithDefault = updatedData ? updatedData : {}; 77 this.opts = $.extend(true, this.opts, instanceData, updatedDataWithDefault); 78 }, 79 getInstance: function () { 80 return this.$element.data('fn.' + this.namespace); 81 }, 82 hasTarget: function () { 83 return !(this.$target === null); 84 }, 85 callback: function (type) { 86 var args = [].slice.call(arguments).splice(1); 87 88 // on element callback 89 if (this.$element) { 90 args = this._fireCallback($._data(this.$element[0], 'events'), type, this.namespace, args); 91 } 92 93 // on target callback 94 if (this.$target) { 95 args = this._fireCallback($._data(this.$target[0], 'events'), type, this.namespace, args); 96 } 97 98 // opts callback 99 if (this.opts && this.opts.callbacks && $.isFunction(this.opts.callbacks[type])) { 100 return this.opts.callbacks[type].apply(this, args); 101 } 102 103 return args; 104 }, 105 _fireCallback: function (events, type, eventNamespace, args) { 106 if (events && typeof events[type] !== 'undefined') { 107 var len = events[type].length; 108 for (var i = 0; i < len; i++) { 109 var namespace = events[type][i].namespace; 110 if (namespace === eventNamespace) { 111 var value = events[type][i].handler.apply(this, args); 112 } 113 } 114 } 115 116 return (typeof value === 'undefined') ? args : value; 117 } 118 }; 119 120 })(); 121 122 (function (Colibri) { 123 Colibri.Plugin = { 124 create: function (classname, pluginname) { 125 pluginname = (typeof pluginname === 'undefined') ? classname.toLowerCase() : pluginname; 126 pluginname = lib_prefix + pluginname; 127 128 $.fn[pluginname] = function (method, options) { 129 var args = Array.prototype.slice.call(arguments, 1); 130 var name = 'fn.' + pluginname; 131 var val = []; 132 133 this.each(function () { 134 var $this = $(this), data = $this.data(name); 135 options = (typeof method === 'object') ? method : options; 136 137 if (!data) { 138 // Initialization 139 $this.data(name, {}); 140 data = new Colibri[classname](this, options); 141 $this.data(name, data); 142 } 143 144 // Call methods 145 if (typeof method === 'string') { 146 if ($.isFunction(data[method])) { 147 var methodVal = data[method].apply(data, args); 148 if (methodVal !== undefined) { 149 val.push(methodVal); 150 } 151 } else { 152 $.error('No such method "' + method + '" for ' + classname); 153 } 154 } 155 156 }); 157 158 return (val.length === 0 || val.length === 1) ? ((val.length === 0) ? this
158: val[0]) : val; 159 }; 160 161 $.fn[pluginname].options = {}; 162 163 return this; 164 }, 165 autoload: function (pluginname) { 166 var arr = pluginname.split(','); 167 var len = arr.length; 168 169 for (var i = 0; i < len; i++) { 170 var name = arr[i].toLowerCase().split(',').map(function (s) { 171 return lib_prefix + s.trim(); 172 }).join(','); 173 this.autoloadQueue.push(name); 174 } 175 176 return this; 177 }, 178 autoloadQueue: [], 179 startAutoload: function () { 180 if (!window.MutationObserver || this.autoloadQueue.length === 0) { 181 return; 182 } 183 184 var self = this; 185 var observer = new MutationObserver(function (mutations) { 186 mutations.forEach(function (mutation) { 187 var newNodes = mutation.addedNodes; 188 if (newNodes.length === 0 || (newNodes.length === 1 && newNodes.nodeType === 3)) { 189 return; 190 } 191 192 self.startAutoloadOnce(); 193 }); 194 }); 195 196 // pass in the target node, as well as the observer options 197 observer.observe(document, { 198 subtree: true, 199 childList: true 200 }); 201 }, 202 203 startAutoloadOnce: function () { 204 var self = this; 205 var $nodes = $('[data-colibri-component]').not('[data-loaded]').not('[data-disabled]'); 206 $nodes.each(function () { 207 var $el = $(this); 208 var pluginname = lib_prefix + $el.data('colibri-component'); 209 210 if (self.autoloadQueue.indexOf(pluginname) !== -1) { 211 $el.attr('data-loaded', true); 212 try { 213 $el[pluginname](); 214 } catch (e) { 215 console.error(e) 216 } 217 } 218 }); 219 220 }, 221 watch: function () { 222 Colibri.Plugin.startAutoloadOnce(); 223 Colibri.Plugin.startAutoload(); 224 } 225 }; 226 227 $(window).on('load', function () { 228 Colibri.Plugin.watch(); 229 }); 230 231 }(Colibri)); 232 233 (function (Colibri) { 234 Colibri.Animation = function (element, effect, callback) { 235 this.namespace = 'animation'; 236 this.defaults = {}; 237 238 // Parent Constructor 239 Colibri.apply(this, arguments); 240 241 // Initialization 242 this.effect = effect; 243 this.completeCallback = (typeof callback === 'undefined') ? false : callback; 244 this.prefixes = ['', '-moz-', '-o-animation-', '-webkit-']; 245 this.queue = []; 246 247 this.start(); 248 }; 249 250 Colibri.Animation.prototype = { 251 start: function () { 252 if (this.isSlideEffect()) { 253 this.setElementHeight(); 254 } 255 256 this.addToQueue(); 257 this.clean(); 258 this.animate(); 259 }, 260 addToQueue: function () { 261 this.queue.push(this.effect); 262 }, 263 setElementHeight: function () { 264 this.$element.height(this.$element.outerHeight()); 265 }, 266 removeElementHeight: function () { 267 this.$element.css('height', ''); 268 }, 269 isSlideEffect: function () { 270 return (this.effect === 'slideDown' || this.effect === 'slideUp'); 271 }, 272 isHideableEffect: function () { 273 var effects = ['fadeOut', 'slideUp', 'flipOut', 'zoomOut', 'slideOutUp', 'slideOutRight', 'slideOutLeft']; 274 275 return ($.inArray(this.effect, effects) !== -1); 276 }, 277 isToggleEffect: function () { 278 return (this.effect === 'show' || this.effect === 'hide'); 279 }, 280 storeHideClasses: function () { 281 if (this.$element.hasClass('hide-sm')) { 282 this.$element.data('hide-sm-class', true); 283 } else if (this.$element.hasClass('hide-md')) { 284 this.$element.data('hide-md-class', true); 285 } 286 }, 287 revertHideClasses: function () { 288 if (this.$element.data('hide-sm-class')) { 289 this.$element.addClass('hide-sm').removeData('hide-sm-class'); 290 } else if (this.$element.data('hide-md-class')) { 291 this.$element.addClass('hide-md').removeData('hide-md-class'); 292 } else { 293 this.$element.addClass('hide'); 294 } 295 }, 296 removeHideClass: function () { 297 if (this.$element.data('hide-sm-class')) { 298 this.$element.removeClass('hide-sm'); 299 } else { 300 if (this.$element.data('hide-md-class')) { 301 this.$element.removeClass('hide-md'); 302 } else { 303 this.$element.removeClass('hide'); 304 this.$element.removeClass('force-hide'); 305 } 306 } 307 308 }, 309 animate: function () { 310 this.storeHideClasses(); 311 if (this.isToggleEffect()) { 312 return this.makeSimpleEffects(); 313 } 314 315 this.$element.addClass('colibri-animated'); 316 this.$element.addClass(this.queue[0]); 317 this.removeHideClass(); 318 319 var _callback = (this.queue.length > 1) ? null : this.completeCallback; 320 this.complete('AnimationEnd', $.proxy(this.makeComplete, this), _callback); 321 }, 322 makeSimpleEffects: function () { 323 if (this.effect === 'show') { 324 this.removeHideClass(); 325 } else if (this.effect === 'hide') { 326 this.revertHideClasses(); 327 } 328 329 if (typeof this.completeCallback === 'function') { 330 this.completeCallback(this); 331 } 332 }, 333 makeComplete: function () { 334 if (this.$element.hasClass(this.queue[0])) { 335 this.clean(); 336 this.queue.shift(); 337 338 if (this.queue.length) { 339 this.animate(); 340 } 341 } 342 }, 343 complete: function (type, make, callback) { 344 var events = type.split(' ').map(function (type) { 345 return type.toLowerCase() + ' webkit' + type + ' o' + type + ' MS' + type; 346 }); 347 348 this.$element.one(events.join(' '), $.proxy(function () { 349 if (typeof make === 'function') { 350 make(); 351 }
352 if (this.isHideableEffect()) { 353 this.revertHideClasses(); 354 } 355 if (this.isSlideEffect()) { 356 this.removeElementHeight(); 357 } 358 if (typeof callback === 'function') { 359 callback(this); 360 } 361 362 this.$element.off(event); 363 364 }, this)); 365 }, 366 clean: function () { 367 this.$element.removeClass('colibri-animated').removeClass(this.queue[0]); 368 } 369 }; 370 371 // Inheritance 372 Colibri.Animation.inherits(Colibri); 373 374 }(Colibri)); 375 376 (function ($) { 377 var animationName = lib_prefix + 'animation'; 378 $.fn[animationName] = function (effect, callback) { 379 var name = 'fn.animation'; 380 381 return this.each(function () { 382 var $this = $(this), data = $this.data(name); 383 384 $this.data(name, {}); 385 $this.data(name, (data = new Colibri.Animation(this, effect, callback))); 386 }); 387 }; 388 389 $.fn[animationName].options = {}; 390 391 Colibri.animate = function ($target, effect, callback) { 392 $target[animationName](effect, callback); 393 return $target; 394 } 395 396 })(jQuery); 397 398 (function (Colibri) { 399 Colibri.Detect = function () { 400 }; 401 402 Colibri.Detect.prototype = { 403 isMobile: function () { 404 return /(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent); 405 }, 406 isDesktop: function () { 407 return !/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent); 408 }, 409 isMobileScreen: function () { 410 return ($(window).width() <= 768); 411 }, 412 isTabletScreen: function () { 413 return ($(window).width() >= 768 && $(window).width() <= 1024); 414 }, 415 isDesktopScreen: function () { 416 return ($(window).width() > 1024); 417 } 418 }; 419 }(Colibri)); 420 421 (function (Colibri) { 422 Colibri.Utils = function () { 423 }; 424 425 Colibri.Utils.prototype = { 426 disableBodyScroll: function () { 427 var $body = $('html'); 428 var windowWidth = window.innerWidth; 429 430 if (!windowWidth) { 431 var documentElementRect = document.documentElement.getBoundingClientRect(); 432 windowWidth = documentElementRect.right - Math.abs(documentElementRect.left); 433 } 434 435 var isOverflowing = document.body.clientWidth < windowWidth; 436 var scrollbarWidth = this.measureScrollbar(); 437 438 $body.css('overflow', 'hidden'); 439 if (isOverflowing) { 440 $body.css('padding-right', scrollbarWidth); 441 } 442 }, 443 measureScrollbar: function () { 444 var $body = $('body'); 445 var scrollDiv = document.createElement('div'); 446 scrollDiv.className = 'scrollbar-measure'; 447 448 $body.append(scrollDiv); 449 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; 450 $body[0].removeChild(scrollDiv); 451 return scrollbarWidth; 452 }, 453 enableBodyScroll: function () { 454 $('html').css({'overflow': '', 'padding-right': ''}); 455 } 456 }; 457 458 459 }(Colibri)); 460 461 return Colibri; 462 } 463);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.