1Namespace.register('mira.Analytics').AnalyticsTrack = (function () { 2 3 var _parent = mira.core.BehaviourBase; 4 5 var AnalyticsTrack = function (element, tracker, options) { 6 7 _parent.call(this, element); 8 9 this._options = options || {}; 10 this._tracker = tracker; 11 12 this._initialize(); 13 14 }; 15 16 var p = AnalyticsTrack.prototype = Object.create(_parent.prototype); 17 18 p._initialize = function () { 19 20 var url = this._element.getAttribute('href'); 21 22 if (url != null && url != '' && !(this._startsWith(url, '#') || this._startsWith(url, "javascript:")) && url.indexOf('#') == -1) { 23 24 this._trackingUrl = new mira.Analytics.AnalyticsTrackUrl(url); 25 26 // external url. 27 if (this._trackingUrl.isExternal()) { 28 this._options.category = 'external'; 29 this._options.action = url; 30 this._options.label = this._element.innerHTML; 31 this._element.addEventListener('mousedown', this._doEventTrack.bind(this)); 32 this._binded = true; 33 } 34 // download link 35 else if (this._trackingUrl.isDownload()) { 36 this._options.category = 'download'; 37 this._options.action = url; 38 this._options.label = this._element.innerHTML; 39 this._element.addEventListener('mousedown', this._doEventTrack.bind(this)); 40 this._binded = true; 41 } 42 // mailto link 43 else if (this._trackingUrl.isMailto()) { 44 this._options.category = 'e-mail'; 45 this._options.action = url.replace('mailto:', ''); 46 this._options.label = this._element.innerHTML; 47 this._element.addEventListener('mousedown', this._doEventTrack.bind(this)); 48 this._binded = true; 49 } 50 51 } else { 52 var trackdata = this._element.getAttribute('data-track'); 53 if (trackdata != null) { 54 var attributes = trackdata.split(';'); 55 56 if (attributes[0] != null && attributes[0] != '') { 57 this._options.category = attributes[0]; 58 } 59 if (attributes[1] != null && attributes[1] != '') { 60 this._options.action = attributes[1]; 61 } 62 if (attributes[2] != null && attributes[2] != '') { 63 this._options.label = attributes[2]; 64 } 65 } 66 67 this._type = this._element.getAttribute('type'); 68 this._element.addEventListener('mousedown', this._doEventTrack.bind(this)); 69 this._binded = true; 70 } 71 }; 72 73 p._startsWith = function (tekst, substring) { 74 return !tekst.toLowerCase().indexOf(substring.toLowerCase()); 75 }; 76 77 p._doEventTrack = function (e) { 78 if (this._binded) { 79 this._tracker.trackEvent(this); 80 } 81 }; 82 83 p.trackEvent = function (){ 84 85 if (this._options.category != null && this._options.action == null) { 86 this._options.action = this._trackingElement.innerHTML; 87 } 88 89 if (this._options.category != null && this._options.action != null) { 90 if (this._options.label != null) { 91 // console.log('_trackEvent', this._options.category, this._options.action, this._options.label); 92 _gaq.push(['_trackEvent', this._options.category, this._options.action, this._options.label], 93 ['b._trackEvent', this._options.category, this._options.action, this._options.label]); 94 } else { 95 // console.log('_trackEvent', this._options.category, this._options.action); 96 _gaq.push(['_trackEvent', this._options.category, this._options.action], 97 ['b._trackEvent', this._options.category, this._options.action]); 98 } 99 } 100 101 if (this._type == 'submit') { 102 this.tracked = true; 103 } 104 105 }; 106 107 // Register 108 return AnalyticsTrack; 109 110} ());
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.