Skip to content
This repository
Browse code

Remove dist folder and point the download to the download page

  • Loading branch information...
commit a2075de7a8ed60a1b50d53cb0a504edeb975b127 1 parent 8ec4436
Eduardo Cereto Carvalho authored March 28, 2012
1  .gitignore
@@ -5,3 +5,4 @@ Icon?
5 5
 *~
6 6
 *.zip
7 7
 _site
  8
+dist/
4  README.md
Source Rendered
@@ -10,11 +10,11 @@ with Google.
10 10
 
11 11
 ## Installation
12 12
 
13  
-To install GAS download the script from [dist][] folder and put it somewhere on
  13
+To install GAS download the script from [download page][download] and put it somewhere on
14 14
 your website. Also install the basic snippet on every page of your website. Be
15 15
 sure to change the Account Number (UA) and the correct gas.js file location.
16 16
 
17  
-[dist]: https://github.com/CardinalPath/gas/tree/master/dist
  17
+[download]: https://github.com/CardinalPath/gas/downloads
18 18
 
19 19
 The basic snippet looks like this:
20 20
 
503  dist/gas.core.js
... ...
@@ -1,503 +0,0 @@
1  
-/**
2  
- * @preserve Copyright 2011, Cardinal Path and Direct Performance.
3  
- *
4  
- * GAS - Google Analytics on Steroids
5  
- * https://bitbucket.org/dpc/gas
6  
- *
7  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
8  
- * Licensed under the MIT license.
9  
- */
10  
-(function(window, undefined) {
11  
-/**
12  
- * GAS - Google Analytics on Steroids
13  
- *
14  
- * Helper Functions
15  
- *
16  
- * Copyright 2011, Cardinal Path and Direct Performance
17  
- * Licensed under the MIT license.
18  
- *
19  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
20  
- */
21  
-
22  
-/**
23  
- * GasHelper singleton class
24  
- *
25  
- * Should be called when ga.js is loaded to get the pageTracker.
26  
- *
27  
- * @constructor
28  
- */
29  
-var GasHelper = function() {
30  
-    this._setDummyTracker();
31  
-};
32  
-
33  
-GasHelper.prototype._setDummyTracker = function() {
34  
-    if (!this['tracker']) {
35  
-        var trackers = window['_gat']['_getTrackers']();
36  
-        if (trackers.length > 0) {
37  
-            this['tracker'] = trackers[0];
38  
-        }
39  
-    }
40  
-};
41  
-
42  
-/**
43  
- * Returns true if the element is found in the Array, false otherwise.
44  
- *
45  
- * @param {Array} obj Array to search at.
46  
- * @param {object} item Item to search form.
47  
- * @return {boolean} true if contains.
48  
- */
49  
-GasHelper.prototype.inArray = function(obj, item) {
50  
-    if (obj && obj.length) {
51  
-        for (var i = 0; i < obj.length; i++) {
52  
-            if (obj[i] === item) {
53  
-                return true;
54  
-            }
55  
-        }
56  
-    }
57  
-    return false;
58  
-};
59  
-
60  
-/**
61  
- * Checks if the object is an Array
62  
- *
63  
- * @param {object} obj Object to check.
64  
- * @return {boolean} true if the object is an Array.
65  
- */
66  
-GasHelper.prototype.isArray = function(obj) {
67  
-    return toString.call(obj) === '[object Array]';
68  
-};
69  
-
70  
-/**
71  
- * Removes special characters and Lowercase String
72  
- *
73  
- * @param {string} str to be sanitized.
74  
- * @param {boolean} strict_opt If we should remove any non ascii char.
75  
- * @return {string} Sanitized string.
76  
- */
77  
-GasHelper.prototype._sanitizeString = function(str, strict_opt) {
78  
-    str = str.toLowerCase()
79  
-        .replace(/^\ +/, '')
80  
-        .replace(/\ +$/, '')
81  
-        .replace(/\s+/g, '_')
82  
-        .replace(/[áàâãåäæª]/g, 'a')
83  
-        .replace(/[éèêëЄ€]/g, 'e')
84  
-        .replace(/[íìîï]/g, 'i')
85  
-        .replace(/[óòôõöøº]/g, 'o')
86  
-        .replace(/[úùûü]/g, 'u')
87  
-        .replace(/[碩]/g, 'c');
88  
-
89  
-    if (strict_opt) {
90  
-        str = str.replace(/[^a-z0-9_-]/g, '_');
91  
-    }
92  
-    return str.replace(/_+/g, '_');
93  
-};
94  
-
95  
-/**
96  
- * Cross Browser helper to addEventListener.
97  
- *
98  
- * ga_next.js currently have a _addEventListener directive. So _gas will
99  
- * allways prefer that if available, and will use this one only as a fallback
100  
- *
101  
- * @param {HTMLElement} obj The Element to attach event to.
102  
- * @param {string} evt The event that will trigger the binded function.
103  
- * @param {function(event)} ofnc The function to bind to the element.
104  
- * @param {boolean} bubble true if event should be fired at bubble phase.
105  
- * Defaults to false. Works only on W3C compliant browser. MSFT don't support
106  
- * it.
107  
- * @return {boolean} true if it was successfuly binded.
108  
- */
109  
-GasHelper.prototype._addEventListener = function(obj, evt, ofnc, bubble) {
110  
-    var fnc = function(event) {
111  
-        if (!event || !event.target) {
112  
-            event = window.event;
113  
-            event.target = event.srcElement;
114  
-        }
115  
-        return ofnc.call(obj, event);
116  
-    };
117  
-    // W3C model
118  
-    if (obj.addEventListener) {
119  
-        obj.addEventListener(evt, fnc, !!bubble);
120  
-        return true;
121  
-    }
122  
-    // M$ft model
123  
-    else if (obj.attachEvent) {
124  
-        return obj.attachEvent('on' + evt, fnc);
125  
-    }
126  
-    // Browser doesn't support W3C or M$ft model. Time to go old school
127  
-    else {
128  
-        evt = 'on' + evt;
129  
-        if (typeof obj[evt] === 'function') {
130  
-            // Object already has a function on traditional
131  
-            // Let's wrap it with our own function inside another function
132  
-            fnc = (function(f1, f2) {
133  
-                return function() {
134  
-                    f1.apply(this, arguments);
135  
-                    f2.apply(this, arguments);
136  
-                }
137  
-            })(obj[evt], fnc);
138  
-        }
139  
-        obj[evt] = fnc;
140  
-        return true;
141  
-    }
142  
-};
143  
-
144  
-/**
145  
- * Cross Browser Helper to emulate jQuery.live
146  
- *
147  
- * Binds to the document root. Listens to all events of the specific type.
148  
- * If event don't bubble it won't catch
149  
- */
150  
-GasHelper.prototype._liveEvent = function(tag, evt, ofunc) {
151  
-    var gh = this;
152  
-    tag = tag.toUpperCase();
153  
-    tag = tag.split(',');
154  
-
155  
-    gh._addEventListener(document, evt, function(me) {
156  
-        for (var el = me.target; el.nodeName !== 'HTML';
157  
-            el = el.parentNode)
158  
-        {
159  
-            if (gh.inArray(tag, el.nodeName) || el.parentNode === null) {
160  
-                break;
161  
-            }
162  
-        }
163  
-        if (el && gh.inArray(tag, el.nodeName)) {
164  
-            ofunc.call(el, me);
165  
-        }
166  
-
167  
-    }, true);
168  
-};
169  
-
170  
-/**
171  
- * Cross Browser DomReady function.
172  
- *
173  
- * Inspired by: http://dean.edwards.name/weblog/2006/06/again/#comment367184
174  
- *
175  
- * @param {function(Event)} callback DOMReady callback.
176  
- * @return {boolean} Ignore return value.
177  
- */
178  
-GasHelper.prototype._DOMReady = function(callback) {
179  
-    var scp = this;
180  
-    var cb = function() {
181  
-        if (arguments.callee.done) return;
182  
-        arguments.callee.done = true;
183  
-        callback.apply(scp, arguments);
184  
-    };
185  
-    if (/^(interactive|complete)/.test(document.readyState)) return cb();
186  
-    this._addEventListener(document, 'DOMContentLoaded', cb, false);
187  
-    this._addEventListener(window, 'load', cb, false);
188  
-};
189  
-
190  
-/**
191  
- * GAS - Google Analytics on Steroids
192  
- *
193  
- * Copyright 2011, Cardinal Path and Direct Performance
194  
- * Licensed under the MIT license.
195  
- *
196  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
197  
- */
198  
-
199  
-/**
200  
- * Google Analytics original _gaq.
201  
- *
202  
- * This never tries to do something that is not supposed to. So it won't break
203  
- * in the future.
204  
- */
205  
-window['_gaq'] = window['_gaq'] || [];
206  
-
207  
-var _prev_gas = window['_gas'] || [];
208  
-
209  
-// Avoid duplicate definition
210  
-if (_prev_gas._accounts_length >= 0) {
211  
-    return;
212  
-}
213  
-
214  
-//Shortcuts, these speed up and compress the code
215  
-var document = window.document,
216  
-    toString = Object.prototype.toString,
217  
-    hasOwn = Object.prototype.hasOwnProperty,
218  
-    push = Array.prototype.push,
219  
-    slice = Array.prototype.slice,
220  
-    trim = String.prototype.trim,
221  
-    sindexOf = String.prototype.indexOf,
222  
-    aindexOf = Array.prototype.indexOf,
223  
-    url = document.location.href,
224  
-    documentElement = document.documentElement;
225  
-
226  
-/**
227  
- * GAS Sigleton
228  
- * @constructor
229  
- */
230  
-function GAS() {
231  
-    var self = this;
232  
-    self['version'] = '1.4.1';
233  
-    self._accounts = {};
234  
-    self._accounts_length = 0;
235  
-    self._queue = _prev_gas;
236  
-    self._default_tracker = '_gas1';
237  
-    self.gh = {};
238  
-    self._hooks = {
239  
-        '_addHook': [self._addHook]
240  
-    };
241  
-    // Need to be pushed to make sure tracker is done
242  
-    // Sets up helpers, very first thing pushed into gas
243  
-    self.push(function() {
244  
-        self.gh = new GasHelper();
245  
-    });
246  
-}
247  
-
248  
-/**
249  
- * First standard Hook that is responsible to add next Hooks
250  
- *
251  
- * _addHook calls always reurn false so they don't get pushed to _gaq
252  
- * @param {string} fn The function you wish to add a Hook to.
253  
- * @param {function()} cb The callback function to be appended to hooks.
254  
- * @return {boolean} Always false.
255  
- */
256  
-GAS.prototype._addHook = function(fn, cb) {
257  
-    if (typeof fn === 'string' && typeof cb === 'function') {
258  
-        if (typeof _gas._hooks[fn] === 'undefined') {
259  
-            _gas._hooks[fn] = [];
260  
-        }
261  
-        _gas._hooks[fn].push(cb);
262  
-    }
263  
-    return false;
264  
-};
265  
-
266  
-/**
267  
- * Construct the correct account name to be used on _gaq calls.
268  
- *
269  
- * The account name for the first unamed account pushed to _gas is the standard
270  
- * account name. It's pushed without the account name to _gaq, so if someone
271  
- * calls directly _gaq it works as expected.
272  
- * @param {string} acct Account name.
273  
- * @return {string} Correct account name to be used already with trailling dot.
274  
- */
275  
-function _build_acct_name(acct) {
276  
-    return acct === _gas._default_tracker ? '' : acct + '.';
277  
-}
278  
-
279  
-function _gaq_push(arr) {
280  
-    if (_gas.debug_mode) {
281  
-        try {
282  
-            console.log(arr);
283  
-        }catch (e) {}
284  
-    }
285  
-    return window['_gaq'].push(arr);
286  
-}
287  
-
288  
-/**
289  
- * Everything pushed to _gas is executed by this call.
290  
- *
291  
- * This function should not be called directly. Instead use _gas.push
292  
- * @return {number} This is the same return as _gaq.push calls.
293  
- */
294  
-GAS.prototype._execute = function() {
295  
-    var args = slice.call(arguments),
296  
-        self = this,
297  
-        sub = args.shift(),
298  
-        gaq_execute = true,
299  
-        i, foo, hooks, acct_name, repl_sub, return_val = 0;
300  
-
301  
-    if (typeof sub === 'function') {
302  
-        // Pushed functions are executed right away
303  
-        return _gaq_push(
304  
-            (function(s, gh) {
305  
-                return function() {
306  
-                    // pushed functions receive helpers through this object
307  
-                    s.call(gh);
308  
-                };
309  
-            })(sub, self.gh)
310  
-        );
311  
-
312  
-    }else if (typeof sub === 'object' && sub.length > 0) {
313  
-        foo = sub.shift();
314  
-
315  
-        if (sindexOf.call(foo, '.') >= 0) {
316  
-            acct_name = foo.split('.')[0];
317  
-            foo = foo.split('.')[1];
318  
-        }else {
319  
-            acct_name = undefined;
320  
-        }
321  
-
322  
-        // Execute hooks
323  
-        hooks = self._hooks[foo];
324  
-        if (hooks && hooks.length > 0) {
325  
-            for (i = 0; i < hooks.length; i++) {
326  
-                try {
327  
-                    repl_sub = hooks[i].apply(self.gh, sub);
328  
-                    if (repl_sub === false) {
329  
-                        // Returning false from a hook cancel the call
330  
-                        gaq_execute = false;
331  
-                    }else {
332  
-                        if (repl_sub && repl_sub.length > 0) {
333  
-                            // Returning an array changes the call parameters
334  
-                            sub = repl_sub;
335  
-                        }
336  
-                    }
337  
-                }catch (e) {
338  
-                    if (foo !== '_trackException') {
339  
-                        self.push(['_trackException', e]);
340  
-                    }
341  
-                }
342  
-            }
343  
-        }
344  
-        // Cancel execution on _gaq if any hook returned false
345  
-        if (gaq_execute === false) {
346  
-            return 1;
347  
-        }
348  
-        // Intercept _setAccount calls
349  
-        if (foo === '_setAccount') {
350  
-
351  
-            for (i in self._accounts) {
352  
-                if (self._accounts[i] == sub[0]) {
353  
-                    // Repeated account
354  
-                    if (acct_name === undefined) {
355  
-                        return 1;
356  
-                    }
357  
-                }
358  
-            }
359  
-            acct_name = acct_name || '_gas' +
360  
-                String(self._accounts_length + 1);
361  
-            // Force that the first unamed account is _gas1
362  
-            if (typeof self._accounts['_gas1'] == 'undefined' &&
363  
-                sindexOf.call(acct_name, '_gas') != -1) {
364  
-                acct_name = '_gas1';
365  
-            }
366  
-            self._accounts[acct_name] = sub[0];
367  
-            self._accounts_length += 1;
368  
-            acct_name = _build_acct_name(acct_name);
369  
-            return_val = _gaq_push([acct_name + foo, sub[0]]);
370  
-            // Must try t get the tracker if it's a _setAccount
371  
-            self.gh._setDummyTracker();
372  
-            return return_val;
373  
-        }
374  
-
375  
-        // Intercept _linka and _linkByPost
376  
-        if (foo === '_link' || foo === '_linkByPost') {
377  
-            args = slice.call(sub);
378  
-            args.unshift(foo);
379  
-            return _gaq_push(args);
380  
-        }
381  
-
382  
-        // If user provides account than trigger event for just that account.
383  
-        var acc_foo;
384  
-        if (acct_name && self._accounts[acct_name]) {
385  
-            acc_foo = _build_acct_name(acct_name) + foo;
386  
-            args = slice.call(sub);
387  
-            args.unshift(acc_foo);
388  
-            return _gaq_push(args);
389  
-        }
390  
-
391  
-        // Call Original _gaq, for all accounts
392  
-        for (i in self._accounts) {
393  
-            if (hasOwn.call(self._accounts, i)) {
394  
-                acc_foo = _build_acct_name(i) + foo;
395  
-                args = slice.call(sub);
396  
-                args.unshift(acc_foo);
397  
-                return_val += _gaq_push(args);
398  
-            }
399  
-        }
400  
-        return return_val ? 1 : 0;
401  
-    }
402  
-};
403  
-
404  
-/**
405  
- * Standard method to execute GA commands.
406  
- *
407  
- * Everything pushed to _gas is in fact pushed back to _gaq. So Helpers are
408  
- * ready for hooks. This creates _gaq as a series of functions that call
409  
- * _gas._execute() with the same arguments.
410  
- */
411  
-GAS.prototype.push = function() {
412  
-    var self = this;
413  
-    var args = slice.call(arguments);
414  
-    for (var i = 0; i < args.length; i++) {
415  
-        (function(arr, self) {
416  
-            window['_gaq'].push(function() {
417  
-                self._execute.call(self, arr);
418  
-            });
419  
-        })(args[i], self);
420  
-    }
421  
-};
422  
-
423  
-/**
424  
- * _gas main object.
425  
- *
426  
- * It's supposed to be used just like _gaq but here we extend it. In it's core
427  
- * everything pushed to _gas is run through possible hooks and then pushed to
428  
- * _gaq
429  
- */
430  
-window['_gas'] = _gas = new GAS();
431  
-
432  
-
433  
-/**
434  
- * Hook for _trackException
435  
- *
436  
- * Watchout for circular calls
437  
- */
438  
-_gas.push(['_addHook', '_trackException', function(exception, message) {
439  
-    _gas.push(['_trackEvent',
440  
-        'Exception ' + (exception.name || 'Error'),
441  
-        message || exception.message || exception,
442  
-        url
443  
-    ]);
444  
-    return false;
445  
-}]);
446  
-
447  
-/**
448  
- * Hook to enable Debug Mode
449  
- */
450  
-_gas.push(['_addHook', '_setDebug', function(set_debug) {
451  
-    _gas.debug_mode = !!set_debug;
452  
-}]);
453  
-
454  
-/**
455  
- * Hook to Remove other Hooks
456  
- *
457  
- * It will remove the last inserted hook from a _gas function.
458  
- *
459  
- * @param {string} func _gas Function Name to remove Hooks from.
460  
- * @return {boolean} Always returns false.
461  
- */
462  
-_gas.push(['_addHook', '_popHook', function(func) {
463  
-    var arr = _gas._hooks[func];
464  
-    if (arr && arr.pop) {
465  
-        arr.pop();
466  
-    }
467  
-    return false;
468  
-}]);
469  
-
470  
-/**
471  
- * Hook to set the default tracker.
472  
- *
473  
- * The default tracker is the nameless tracker that is pushed into _gaq_push
474  
- */
475  
-_gas.push(['_addHook', '_setDefaultTracker', function(tname) {
476  
-    _gas._default_tracker = tname;
477  
-}]);
478  
-/**
479  
- * Wrap-up
480  
- */
481  
-// Execute previous functions
482  
-while (_gas._queue.length > 0) {
483  
-    _gas.push(_gas._queue.shift());
484  
-}
485  
-
486  
-// Import ga.js
487  
-if (_gaq && _gaq.length >= 0) {
488  
-    (function() {
489  
-        var ga = document.createElement('script');
490  
-        ga.type = 'text/javascript';
491  
-        ga.async = true;
492  
-        ga.src = (
493  
-            'https:' == document.location.protocol ?
494  
-                'https://ssl' :
495  
-                'http://www'
496  
-        ) +
497  
-            '.google-analytics.com/ga.js';
498  
-        var s = document.getElementsByTagName('script')[0];
499  
-        s.parentNode.insertBefore(ga, s);
500  
-    })();
501  
-}
502  
-
503  
-})(window);
9  dist/gas.core.min.js
... ...
@@ -1,9 +0,0 @@
1  
-/**
2  
- * @preserve Copyright 2011, Cardinal Path and Direct Performance.
3  
- *
4  
- * GAS - Google Analytics on Steroids
5  
- * https://bitbucket.org/dpc/gas
6  
- *
7  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
8  
- * Licensed under the MIT license.
9  
- */(function(a,b){function o(){var a=this;a.version="1.4.1",a._accounts={},a._accounts_length=0,a._queue=d,a._default_tracker="_gas1",a.gh={},a._hooks={_addHook:[a._addHook]},a.push(function(){a.gh=new c})}function p(a){return a===_gas._default_tracker?"":a+"."}function q(b){if(_gas.debug_mode)try{console.log(b)}catch(c){}return a._gaq.push(b)}var c=function(){this._setDummyTracker()};c.prototype._setDummyTracker=function(){if(!this.tracker){var b=a._gat._getTrackers();b.length>0&&(this.tracker=b[0])}},c.prototype.inArray=function(a,b){if(a&&a.length)for(var c=0;c<a.length;c++)if(a[c]===b)return!0;return!1},c.prototype.isArray=function(a){return f.call(a)==="[object Array]"},c.prototype._sanitizeString=function(a,b){return a=a.toLowerCase().replace(/^\ +/,"").replace(/\ +$/,"").replace(/\s+/g,"_").replace(/[áàâãåäæª]/g,"a").replace(/[éèêëЄ€]/g,"e").replace(/[íìîï]/g,"i").replace(/[óòôõöøº]/g,"o").replace(/[úùûü]/g,"u").replace(/[碩]/g,"c"),b&&(a=a.replace(/[^a-z0-9_-]/g,"_")),a.replace(/_+/g,"_")},c.prototype._addEventListener=function(b,c,d,e){var f=function(c){if(!c||!c.target)c=a.event,c.target=c.srcElement;return d.call(b,c)};return b.addEventListener?(b.addEventListener(c,f,!!e),!0):b.attachEvent?b.attachEvent("on"+c,f):(c="on"+c,typeof b[c]=="function"&&(f=function(a,b){return function(){a.apply(this,arguments),b.apply(this,arguments)}}(b[c],f)),b[c]=f,!0)},c.prototype._liveEvent=function(a,b,c){var d=this;a=a.toUpperCase(),a=a.split(","),d._addEventListener(e,b,function(b){for(var e=b.target;e.nodeName!=="HTML";e=e.parentNode)if(d.inArray(a,e.nodeName)||e.parentNode===null)break;e&&d.inArray(a,e.nodeName)&&c.call(e,b)},!0)},c.prototype._DOMReady=function(b){var c=this,d=function(){if(arguments.callee.done)return;arguments.callee.done=!0,b.apply(c,arguments)};if(/^(interactive|complete)/.test(e.readyState))return d();this._addEventListener(e,"DOMContentLoaded",d,!1),this._addEventListener(a,"load",d,!1)},a._gaq=a._gaq||[];var d=a._gas||[];if(d._accounts_length>=0)return;var e=a.document,f=Object.prototype.toString,g=Object.prototype.hasOwnProperty,h=Array.prototype.push,i=Array.prototype.slice,j=String.prototype.trim,k=String.prototype.indexOf,l=Array.prototype.indexOf,m=e.location.href,n=e.documentElement;o.prototype._addHook=function(a,b){return typeof a=="string"&&typeof b=="function"&&(typeof _gas._hooks[a]=="undefined"&&(_gas._hooks[a]=[]),_gas._hooks[a].push(b)),!1},o.prototype._execute=function(){var a=i.call(arguments),c=this,d=a.shift(),e=!0,f,h,j,l,m,n=0;if(typeof d=="function")return q(function(a,b){return function(){a.call(b)}}(d,c.gh));if(typeof d=="object"&&d.length>0){h=d.shift(),k.call(h,".")>=0?(l=h.split(".")[0],h=h.split(".")[1]):l=b,j=c._hooks[h];if(j&&j.length>0)for(f=0;f<j.length;f++)try{m=j[f].apply(c.gh,d),m===!1?e=!1:m&&m.length>0&&(d=m)}catch(o){h!=="_trackException"&&c.push(["_trackException",o])}if(e===!1)return 1;if(h==="_setAccount"){for(f in c._accounts)if(c._accounts[f]==d[0]&&l===b)return 1;return l=l||"_gas"+String(c._accounts_length+1),typeof c._accounts["_gas1"]=="undefined"&&k.call(l,"_gas")!=-1&&(l="_gas1"),c._accounts[l]=d[0],c._accounts_length+=1,l=p(l),n=q([l+h,d[0]]),c.gh._setDummyTracker(),n}if(h==="_link"||h==="_linkByPost")return a=i.call(d),a.unshift(h),q(a);var r;if(l&&c._accounts[l])return r=p(l)+h,a=i.call(d),a.unshift(r),q(a);for(f in c._accounts)g.call(c._accounts,f)&&(r=p(f)+h,a=i.call(d),a.unshift(r),n+=q(a));return n?1:0}},o.prototype.push=function(){var b=this,c=i.call(arguments);for(var d=0;d<c.length;d++)(function(b,c){a._gaq.push(function(){c._execute.call(c,b)})})(c[d],b)},a._gas=_gas=new o,_gas.push(["_addHook","_trackException",function(a,b){return _gas.push(["_trackEvent","Exception "+(a.name||"Error"),b||a.message||a,m]),!1}]),_gas.push(["_addHook","_setDebug",function(a){_gas.debug_mode=!!a}]),_gas.push(["_addHook","_popHook",function(a){var b=_gas._hooks[a];return b&&b.pop&&b.pop(),!1}]),_gas.push(["_addHook","_setDefaultTracker",function(a){_gas._default_tracker=a}]);while(_gas._queue.length>0)_gas.push(_gas._queue.shift());_gaq&&_gaq.length>=0&&function(){var a=e.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"==e.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var b=e.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)}()})(window);
1,574  dist/gas.js
... ...
@@ -1,1574 +0,0 @@
1  
-/**
2  
- * @preserve Copyright 2011, Cardinal Path and Direct Performance.
3  
- *
4  
- * GAS - Google Analytics on Steroids
5  
- * https://bitbucket.org/dpc/gas
6  
- *
7  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
8  
- * Licensed under the MIT license.
9  
- */
10  
-(function(window, undefined) {
11  
-/**
12  
- * GAS - Google Analytics on Steroids
13  
- *
14  
- * Helper Functions
15  
- *
16  
- * Copyright 2011, Cardinal Path and Direct Performance
17  
- * Licensed under the MIT license.
18  
- *
19  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
20  
- */
21  
-
22  
-/**
23  
- * GasHelper singleton class
24  
- *
25  
- * Should be called when ga.js is loaded to get the pageTracker.
26  
- *
27  
- * @constructor
28  
- */
29  
-var GasHelper = function() {
30  
-    this._setDummyTracker();
31  
-};
32  
-
33  
-GasHelper.prototype._setDummyTracker = function() {
34  
-    if (!this['tracker']) {
35  
-        var trackers = window['_gat']['_getTrackers']();
36  
-        if (trackers.length > 0) {
37  
-            this['tracker'] = trackers[0];
38  
-        }
39  
-    }
40  
-};
41  
-
42  
-/**
43  
- * Returns true if the element is found in the Array, false otherwise.
44  
- *
45  
- * @param {Array} obj Array to search at.
46  
- * @param {object} item Item to search form.
47  
- * @return {boolean} true if contains.
48  
- */
49  
-GasHelper.prototype.inArray = function(obj, item) {
50  
-    if (obj && obj.length) {
51  
-        for (var i = 0; i < obj.length; i++) {
52  
-            if (obj[i] === item) {
53  
-                return true;
54  
-            }
55  
-        }
56  
-    }
57  
-    return false;
58  
-};
59  
-
60  
-/**
61  
- * Checks if the object is an Array
62  
- *
63  
- * @param {object} obj Object to check.
64  
- * @return {boolean} true if the object is an Array.
65  
- */
66  
-GasHelper.prototype.isArray = function(obj) {
67  
-    return toString.call(obj) === '[object Array]';
68  
-};
69  
-
70  
-/**
71  
- * Removes special characters and Lowercase String
72  
- *
73  
- * @param {string} str to be sanitized.
74  
- * @param {boolean} strict_opt If we should remove any non ascii char.
75  
- * @return {string} Sanitized string.
76  
- */
77  
-GasHelper.prototype._sanitizeString = function(str, strict_opt) {
78  
-    str = str.toLowerCase()
79  
-        .replace(/^\ +/, '')
80  
-        .replace(/\ +$/, '')
81  
-        .replace(/\s+/g, '_')
82  
-        .replace(/[áàâãåäæª]/g, 'a')
83  
-        .replace(/[éèêëЄ€]/g, 'e')
84  
-        .replace(/[íìîï]/g, 'i')
85  
-        .replace(/[óòôõöøº]/g, 'o')
86  
-        .replace(/[úùûü]/g, 'u')
87  
-        .replace(/[碩]/g, 'c');
88  
-
89  
-    if (strict_opt) {
90  
-        str = str.replace(/[^a-z0-9_-]/g, '_');
91  
-    }
92  
-    return str.replace(/_+/g, '_');
93  
-};
94  
-
95  
-/**
96  
- * Cross Browser helper to addEventListener.
97  
- *
98  
- * ga_next.js currently have a _addEventListener directive. So _gas will
99  
- * allways prefer that if available, and will use this one only as a fallback
100  
- *
101  
- * @param {HTMLElement} obj The Element to attach event to.
102  
- * @param {string} evt The event that will trigger the binded function.
103  
- * @param {function(event)} ofnc The function to bind to the element.
104  
- * @param {boolean} bubble true if event should be fired at bubble phase.
105  
- * Defaults to false. Works only on W3C compliant browser. MSFT don't support
106  
- * it.
107  
- * @return {boolean} true if it was successfuly binded.
108  
- */
109  
-GasHelper.prototype._addEventListener = function(obj, evt, ofnc, bubble) {
110  
-    var fnc = function(event) {
111  
-        if (!event || !event.target) {
112  
-            event = window.event;
113  
-            event.target = event.srcElement;
114  
-        }
115  
-        return ofnc.call(obj, event);
116  
-    };
117  
-    // W3C model
118  
-    if (obj.addEventListener) {
119  
-        obj.addEventListener(evt, fnc, !!bubble);
120  
-        return true;
121  
-    }
122  
-    // M$ft model
123  
-    else if (obj.attachEvent) {
124  
-        return obj.attachEvent('on' + evt, fnc);
125  
-    }
126  
-    // Browser doesn't support W3C or M$ft model. Time to go old school
127  
-    else {
128  
-        evt = 'on' + evt;
129  
-        if (typeof obj[evt] === 'function') {
130  
-            // Object already has a function on traditional
131  
-            // Let's wrap it with our own function inside another function
132  
-            fnc = (function(f1, f2) {
133  
-                return function() {
134  
-                    f1.apply(this, arguments);
135  
-                    f2.apply(this, arguments);
136  
-                }
137  
-            })(obj[evt], fnc);
138  
-        }
139  
-        obj[evt] = fnc;
140  
-        return true;
141  
-    }
142  
-};
143  
-
144  
-/**
145  
- * Cross Browser Helper to emulate jQuery.live
146  
- *
147  
- * Binds to the document root. Listens to all events of the specific type.
148  
- * If event don't bubble it won't catch
149  
- */
150  
-GasHelper.prototype._liveEvent = function(tag, evt, ofunc) {
151  
-    var gh = this;
152  
-    tag = tag.toUpperCase();
153  
-    tag = tag.split(',');
154  
-
155  
-    gh._addEventListener(document, evt, function(me) {
156  
-        for (var el = me.target; el.nodeName !== 'HTML';
157  
-            el = el.parentNode)
158  
-        {
159  
-            if (gh.inArray(tag, el.nodeName) || el.parentNode === null) {
160  
-                break;
161  
-            }
162  
-        }
163  
-        if (el && gh.inArray(tag, el.nodeName)) {
164  
-            ofunc.call(el, me);
165  
-        }
166  
-
167  
-    }, true);
168  
-};
169  
-
170  
-/**
171  
- * Cross Browser DomReady function.
172  
- *
173  
- * Inspired by: http://dean.edwards.name/weblog/2006/06/again/#comment367184
174  
- *
175  
- * @param {function(Event)} callback DOMReady callback.
176  
- * @return {boolean} Ignore return value.
177  
- */
178  
-GasHelper.prototype._DOMReady = function(callback) {
179  
-    var scp = this;
180  
-    var cb = function() {
181  
-        if (arguments.callee.done) return;
182  
-        arguments.callee.done = true;
183  
-        callback.apply(scp, arguments);
184  
-    };
185  
-    if (/^(interactive|complete)/.test(document.readyState)) return cb();
186  
-    this._addEventListener(document, 'DOMContentLoaded', cb, false);
187  
-    this._addEventListener(window, 'load', cb, false);
188  
-};
189  
-
190  
-/**
191  
- * GAS - Google Analytics on Steroids
192  
- *
193  
- * Copyright 2011, Cardinal Path and Direct Performance
194  
- * Licensed under the MIT license.
195  
- *
196  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
197  
- */
198  
-
199  
-/**
200  
- * Google Analytics original _gaq.
201  
- *
202  
- * This never tries to do something that is not supposed to. So it won't break
203  
- * in the future.
204  
- */
205  
-window['_gaq'] = window['_gaq'] || [];
206  
-
207  
-var _prev_gas = window['_gas'] || [];
208  
-
209  
-// Avoid duplicate definition
210  
-if (_prev_gas._accounts_length >= 0) {
211  
-    return;
212  
-}
213  
-
214  
-//Shortcuts, these speed up and compress the code
215  
-var document = window.document,
216  
-    toString = Object.prototype.toString,
217  
-    hasOwn = Object.prototype.hasOwnProperty,
218  
-    push = Array.prototype.push,
219  
-    slice = Array.prototype.slice,
220  
-    trim = String.prototype.trim,
221  
-    sindexOf = String.prototype.indexOf,
222  
-    aindexOf = Array.prototype.indexOf,
223  
-    url = document.location.href,
224  
-    documentElement = document.documentElement;
225  
-
226  
-/**
227  
- * GAS Sigleton
228  
- * @constructor
229  
- */
230  
-function GAS() {
231  
-    var self = this;
232  
-    self['version'] = '1.4.1';
233  
-    self._accounts = {};
234  
-    self._accounts_length = 0;
235  
-    self._queue = _prev_gas;
236  
-    self._default_tracker = '_gas1';
237  
-    self.gh = {};
238  
-    self._hooks = {
239  
-        '_addHook': [self._addHook]
240  
-    };
241  
-    // Need to be pushed to make sure tracker is done
242  
-    // Sets up helpers, very first thing pushed into gas
243  
-    self.push(function() {
244  
-        self.gh = new GasHelper();
245  
-    });
246  
-}
247  
-
248  
-/**
249  
- * First standard Hook that is responsible to add next Hooks
250  
- *
251  
- * _addHook calls always reurn false so they don't get pushed to _gaq
252  
- * @param {string} fn The function you wish to add a Hook to.
253  
- * @param {function()} cb The callback function to be appended to hooks.
254  
- * @return {boolean} Always false.
255  
- */
256  
-GAS.prototype._addHook = function(fn, cb) {
257  
-    if (typeof fn === 'string' && typeof cb === 'function') {
258  
-        if (typeof _gas._hooks[fn] === 'undefined') {
259  
-            _gas._hooks[fn] = [];
260  
-        }
261  
-        _gas._hooks[fn].push(cb);
262  
-    }
263  
-    return false;
264  
-};
265  
-
266  
-/**
267  
- * Construct the correct account name to be used on _gaq calls.
268  
- *
269  
- * The account name for the first unamed account pushed to _gas is the standard
270  
- * account name. It's pushed without the account name to _gaq, so if someone
271  
- * calls directly _gaq it works as expected.
272  
- * @param {string} acct Account name.
273  
- * @return {string} Correct account name to be used already with trailling dot.
274  
- */
275  
-function _build_acct_name(acct) {
276  
-    return acct === _gas._default_tracker ? '' : acct + '.';
277  
-}
278  
-
279  
-function _gaq_push(arr) {
280  
-    if (_gas.debug_mode) {
281  
-        try {
282  
-            console.log(arr);
283  
-        }catch (e) {}
284  
-    }
285  
-    return window['_gaq'].push(arr);
286  
-}
287  
-
288  
-/**
289  
- * Everything pushed to _gas is executed by this call.
290  
- *
291  
- * This function should not be called directly. Instead use _gas.push
292  
- * @return {number} This is the same return as _gaq.push calls.
293  
- */
294  
-GAS.prototype._execute = function() {
295  
-    var args = slice.call(arguments),
296  
-        self = this,
297  
-        sub = args.shift(),
298  
-        gaq_execute = true,
299  
-        i, foo, hooks, acct_name, repl_sub, return_val = 0;
300  
-
301  
-    if (typeof sub === 'function') {
302  
-        // Pushed functions are executed right away
303  
-        return _gaq_push(
304  
-            (function(s, gh) {
305  
-                return function() {
306  
-                    // pushed functions receive helpers through this object
307  
-                    s.call(gh);
308  
-                };
309  
-            })(sub, self.gh)
310  
-        );
311  
-
312  
-    }else if (typeof sub === 'object' && sub.length > 0) {
313  
-        foo = sub.shift();
314  
-
315  
-        if (sindexOf.call(foo, '.') >= 0) {
316  
-            acct_name = foo.split('.')[0];
317  
-            foo = foo.split('.')[1];
318  
-        }else {
319  
-            acct_name = undefined;
320  
-        }
321  
-
322  
-        // Execute hooks
323  
-        hooks = self._hooks[foo];
324  
-        if (hooks && hooks.length > 0) {
325  
-            for (i = 0; i < hooks.length; i++) {
326  
-                try {
327  
-                    repl_sub = hooks[i].apply(self.gh, sub);
328  
-                    if (repl_sub === false) {
329  
-                        // Returning false from a hook cancel the call
330  
-                        gaq_execute = false;
331  
-                    }else {
332  
-                        if (repl_sub && repl_sub.length > 0) {
333  
-                            // Returning an array changes the call parameters
334  
-                            sub = repl_sub;
335  
-                        }
336  
-                    }
337  
-                }catch (e) {
338  
-                    if (foo !== '_trackException') {
339  
-                        self.push(['_trackException', e]);
340  
-                    }
341  
-                }
342  
-            }
343  
-        }
344  
-        // Cancel execution on _gaq if any hook returned false
345  
-        if (gaq_execute === false) {
346  
-            return 1;
347  
-        }
348  
-        // Intercept _setAccount calls
349  
-        if (foo === '_setAccount') {
350  
-
351  
-            for (i in self._accounts) {
352  
-                if (self._accounts[i] == sub[0]) {
353  
-                    // Repeated account
354  
-                    if (acct_name === undefined) {
355  
-                        return 1;
356  
-                    }
357  
-                }
358  
-            }
359  
-            acct_name = acct_name || '_gas' +
360  
-                String(self._accounts_length + 1);
361  
-            // Force that the first unamed account is _gas1
362  
-            if (typeof self._accounts['_gas1'] == 'undefined' &&
363  
-                sindexOf.call(acct_name, '_gas') != -1) {
364  
-                acct_name = '_gas1';
365  
-            }
366  
-            self._accounts[acct_name] = sub[0];
367  
-            self._accounts_length += 1;
368  
-            acct_name = _build_acct_name(acct_name);
369  
-            return_val = _gaq_push([acct_name + foo, sub[0]]);
370  
-            // Must try t get the tracker if it's a _setAccount
371  
-            self.gh._setDummyTracker();
372  
-            return return_val;
373  
-        }
374  
-
375  
-        // Intercept _linka and _linkByPost
376  
-        if (foo === '_link' || foo === '_linkByPost') {
377  
-            args = slice.call(sub);
378  
-            args.unshift(foo);
379  
-            return _gaq_push(args);
380  
-        }
381  
-
382  
-        // If user provides account than trigger event for just that account.
383  
-        var acc_foo;
384  
-        if (acct_name && self._accounts[acct_name]) {
385  
-            acc_foo = _build_acct_name(acct_name) + foo;
386  
-            args = slice.call(sub);
387  
-            args.unshift(acc_foo);
388  
-            return _gaq_push(args);
389  
-        }
390  
-
391  
-        // Call Original _gaq, for all accounts
392  
-        for (i in self._accounts) {
393  
-            if (hasOwn.call(self._accounts, i)) {
394  
-                acc_foo = _build_acct_name(i) + foo;
395  
-                args = slice.call(sub);
396  
-                args.unshift(acc_foo);
397  
-                return_val += _gaq_push(args);
398  
-            }
399  
-        }
400  
-        return return_val ? 1 : 0;
401  
-    }
402  
-};
403  
-
404  
-/**
405  
- * Standard method to execute GA commands.
406  
- *
407  
- * Everything pushed to _gas is in fact pushed back to _gaq. So Helpers are
408  
- * ready for hooks. This creates _gaq as a series of functions that call
409  
- * _gas._execute() with the same arguments.
410  
- */
411  
-GAS.prototype.push = function() {
412  
-    var self = this;
413  
-    var args = slice.call(arguments);
414  
-    for (var i = 0; i < args.length; i++) {
415  
-        (function(arr, self) {
416  
-            window['_gaq'].push(function() {
417  
-                self._execute.call(self, arr);
418  
-            });
419  
-        })(args[i], self);
420  
-    }
421  
-};
422  
-
423  
-/**
424  
- * _gas main object.
425  
- *
426  
- * It's supposed to be used just like _gaq but here we extend it. In it's core
427  
- * everything pushed to _gas is run through possible hooks and then pushed to
428  
- * _gaq
429  
- */
430  
-window['_gas'] = _gas = new GAS();
431  
-
432  
-
433  
-/**
434  
- * Hook for _trackException
435  
- *
436  
- * Watchout for circular calls
437  
- */
438  
-_gas.push(['_addHook', '_trackException', function(exception, message) {
439  
-    _gas.push(['_trackEvent',
440  
-        'Exception ' + (exception.name || 'Error'),
441  
-        message || exception.message || exception,
442  
-        url
443  
-    ]);
444  
-    return false;
445  
-}]);
446  
-
447  
-/**
448  
- * Hook to enable Debug Mode
449  
- */
450  
-_gas.push(['_addHook', '_setDebug', function(set_debug) {
451  
-    _gas.debug_mode = !!set_debug;
452  
-}]);
453  
-
454  
-/**
455  
- * Hook to Remove other Hooks
456  
- *
457  
- * It will remove the last inserted hook from a _gas function.
458  
- *
459  
- * @param {string} func _gas Function Name to remove Hooks from.
460  
- * @return {boolean} Always returns false.
461  
- */
462  
-_gas.push(['_addHook', '_popHook', function(func) {
463  
-    var arr = _gas._hooks[func];
464  
-    if (arr && arr.pop) {
465  
-        arr.pop();
466  
-    }
467  
-    return false;
468  
-}]);
469  
-
470  
-/**
471  
- * Hook to set the default tracker.
472  
- *
473  
- * The default tracker is the nameless tracker that is pushed into _gaq_push
474  
- */
475  
-_gas.push(['_addHook', '_setDefaultTracker', function(tname) {
476  
-    _gas._default_tracker = tname;
477  
-}]);
478  
-/**
479  
- * This is kept just for backward compatibility since it's now supported
480  
- * natively in _gaq.
481  
- */
482  
-_gas.push(['_addHook', '_trackPageview', function() {
483  
-    var args = slice.call(arguments);
484  
-    if (args.length >= 2 &&
485  
-        typeof args[0] === 'string' && typeof args[1] === 'string')
486  
-    {
487  
-        return [{
488  
-            'page': args[0],
489  
-            'title': args[1]
490  
-        }];
491  
-    }
492  
-    return args;
493  
-}]);
494  
-
495  
-/**
496  
- * GAS - Google Analytics on Steroids
497  
- *
498  
- * Download Tracking Plugin
499  
- *
500  
- * Copyright 2011, Cardinal Path and Direct Performance
501  
- * Licensed under the MIT license.
502  
- *
503  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
504  
- */
505  
-
506  
-/**
507  
- * Extracts the file extension and check it against a list
508  
- *
509  
- * Will extract the extensions from a url and check if it matches one of
510  
- * possible options. Used to verify if a url corresponds to a download link.
511  
- *
512  
- * @this {GasHelper} GA Helper object.
513  
- * @param {string} src The url to check.
514  
- * @param {Array} extensions an Array with strings containing the possible
515  
- * extensions.
516  
- * @return {boolean|string} the file extension or false.
517  
- */
518  
-function _checkFile(src, extensions) {
519  
-    if (typeof src !== 'string') {
520  
-        return false;
521  
-    }
522  
-    var ext = src.split('?')[0];
523  
-    ext = ext.split('.');
524  
-    ext = ext[ext.length - 1];
525  
-    if (ext && this.inArray(extensions, ext)) {
526  
-        return ext;
527  
-    }
528  
-    return false;
529  
-}
530  
-
531  
-/**
532  
- * Register the event to listen to downloads
533  
- *
534  
- * @this {GasHelper} GA Helper object.
535  
- * @param {Array|object} opts List of possible extensions for download
536  
- * links.
537  
- */
538  
-var _trackDownloads = function(opts) {
539  
-    var gh = this;
540  
-
541  
-    if (!gh._downloadTracked) {
542  
-        gh._downloadTracked = true;
543  
-    }else {
544  
-        //Oops double tracking detected.
545  
-        return;
546  
-    }
547  
-    if (!opts) {
548  
-        opts = {'extensions': []};
549  
-    } else if (typeof opts === 'string') {
550  
-        // support legacy opts as String of extensions
551  
-        opts = {'extensions': opts.split(',')};
552  
-    } else if (opts.length >= 1) {
553  
-        // support legacy opts Array of extensions
554  
-        opts = {'extensions': opts};
555  
-    }
556  
-    opts['category'] = opts['category'] || 'Download';
557  
-
558  
-    var ext = 'xls,xlsx,doc,docx,ppt,pptx,pdf,txt,zip';
559  
-    ext += ',rar,7z,exe,wma,mov,avi,wmv,mp3,csv,tsv';
560  
-    ext = ext.split(',');
561  
-    opts['extensions'] = opts['extensions'].concat(ext);
562  
-
563  
-    gh._liveEvent('a', 'mousedown', function(e) {
564  
-        var el = this;
565  
-        if (el.href) {
566  
-            var ext = _checkFile.call(gh,
567  
-                el.href, opts['extensions']
568  
-            );
569  
-            if (ext) {
570  
-                _gas.push(['_trackEvent',
571  
-                    opts['category'], ext, el.href
572  
-                ]);
573  
-            }
574  
-        }
575  
-    });
576  
-    return false;
577  
-};
578  
-
579  
-/**
580  
- * GAA Hook, receive the extensions to extend default extensions. And trigger
581  
- * the binding of the events.
582  
- *
583  
- * @param {string|Array|object} opts GAs Options. Also backward compatible
584  
- * with array or string of extensions.
585  
- */
586  
-_gas.push(['_addHook', '_gasTrackDownloads', _trackDownloads]);
587  
-
588  
-// Old API to be deprecated on v2.0
589  
-_gas.push(['_addHook', '_trackDownloads', _trackDownloads]);
590  
-
591  
-/**
592  
- * Hook to sanity check trackEvents
593  
- *
594  
- * The value is rounded and parsed to integer.
595  
- * Negative values are sent as zero.
596  
- * If val is NaN than it is sent as zero.
597  
- */
598  
-_gas.push(['_addHook', '_trackEvent', function() {
599  
-    var args = slice.call(arguments);
600  
-    if (args[3]) {
601  
-        args[3] = (args[3] < 0 ? 0 : Math.round(args[3])) || 0;
602  
-    }
603  
-    return args;
604  
-}]);
605  
-
606  
-/**
607  
- * GAS - Google Analytics on Steroids
608  
- *
609  
- * Form Tracking Plugin
610  
- *
611  
- * Copyright 2011, Cardinal Path and Direct Performance
612  
- * Licensed under the MIT license.
613  
- *
614  
- * @author Eduardo Cereto <eduardocereto@gmail.com>
615  
- */
616  
-
617  
-/**
618  
- * get the form name for a specific elemet
619  
- *
620  
- * @param {DOMElemet} el Dom Element.
621  
- * @return {String} Form Name or Id.
622  
- */