1/** 2 * @file 3 * rezFusion Collection namespace and object. 4 */ 5(function ($, Drupal) { 6 "use strict"; 7 8 window.VRWeb = window.VRWeb || {}; 9 // Init rezFusion namespace. 10 11 window.VRWeb.cookieCollection = function(namespace) { 12 // rezFusion Cookie Collection object. 13 // Private vars. 14 var _namespace = namespace, 15 _items = [], 16 cookie; 17 18 // Private update method. This is used to refresh the objects with cookie 19 // data so that collections on multiple open tabs will work properly. 20 var refresh = function() { 21 // Load cookie values. 22 cookie = $.cookie('vrweb_' + _namespace); 23 // Populate items from cookie. 24 _items[_namespace] = cookie ? $.parseJSON(cookie) : []; 25 } // Don't auto-execute so we lazy-load fetching cookie data. 26 27 // Private save method. 28 var save = function () { 29 $.cookie('vrweb_' + _namespace, JSON.stringify(_items[_namespace]), {path: '/'}); 30 }; 31 32 // Public get methd. 33 this.get = function () { 34 refresh(); 35 return _items[_namespace]; 36 }; 37 38 // Public add method. 39 this.add = function (val) { 40 refresh(); 41 // Don't add duplicate items. 42 if (_items[_namespace].indexOf(val) === -1) { 43 _items[_namespace].push(val); 44 save(); 45 } 46 if(typeof ga !== 'undefined') { 47 ga('send', { 48 'hitType': 'event', 49 'eventCategory': 'Fusion Collection', 50 'eventAction': 'Add '+ _namespace, 51 'eventLabel': val, 52 'nonInteraction': 1 53 }); 54 } 55 else if (typeof _gaq !== 'undefined') { 56 _gaq.push(['_trackEvent', 'Fusion Collection', 'Add '+ _namespace, val, 0, true]); 57 } 58 59 if(typeof ga4 !== 'undefined') { 60 ga4.event({ 61 'event': 'Fusion Collection', 62 'eventCategory': 'Fusion Collection', 63 'eventAction': 'Add '+ _namespace, 64 'nonInteraction': 1, 65 'eventLabel': val 66 }); 67 } 68 }; 69 70 // Public remove method. 71 this.remove = function (val) { 72 refresh(); 73 // We can't use this.has() here because we need the index. 74 var index = _items[_namespace].indexOf(val); 75 76 if (index !== -1) { 77 _items[_namespace].splice(index, 1); 78 save(); 79 } 80 if(typeof ga !== 'undefined') { 81 ga('send', { 82 'hitType': 'event', 83 'eventCategory': 'Fusion Collection', 84 'eventAction': 'Remove '+ _namespace, 85 'eventLabel': val, 86 'nonInteraction': 1 87 }); 88 } 89 else if (typeof _gaq !== 'undefined') { 90 _gaq.push(['_trackEvent', 'Fusion Collection', 'Remove '+ _namespace, val, 0, true]); 91 } 92 93 if(typeof ga4 !== 'undefined') { 94 ga4.event({ 95 'event': 'Fusion Collection', 96 'eventCategory': 'Fusion Collection', 97 'eventAction': 'Remove '+ _namespace, 98 'nonInteraction': 1, 99 'eventLabel': val 100 }); 101 } 102 }; 103 104 // Public reset method. 105 this.reset = function () { 106 _items[_namespace] = []; 107 save(); 108 }; 109 110 // Public lookup method. 111 this.has = function (val) { 112 refresh(); 113 // IE 8 and below do not have the Array.prototype.indexOf method. 114 return this.indexOf.call(_items[_namespace], val) !== -1; 115 }; 116 117 // Shim for IE8 and below not supporting indexOf natively. 118 // Public so others can use it. 119 this.indexOf = function(needle) { 120 var indexOf; 121 122 if(typeof Array.prototype.indexOf === 'function') { 123 indexOf = Array.prototype.indexOf; 124 } else { 125 indexOf = function(needle) { 126 var i = -1, index = -1; 127 128 for(i = 0; i < this.length; i++) { 129 if(this[i] === needle) { 130 index = i; 131 break; 132 } 133 } 134 135 return index; 136 }; 137 } 138 139 return indexOf.call(this, needle); 140 }; 141 }; 142})(jQuery, Drupal);
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.