Skip to content

Commit

Permalink
Merge branch 'release/1.11.0'
Browse files Browse the repository at this point in the history
* release/1.11.0:
  1.11.0 version bump and changelog
  jshinting + rm _sanitizeString
  dc.js support
  import/configure editorconfig
  Change build from make to Grunt -- [squashed]
  Outbound events are non-interactive now
  Allow negative event values
  Don't push GAS functions inside _gaq.
  Extra checks on the live handler, fixes issue with ie8
  • Loading branch information
tomfuertes committed Nov 24, 2013
2 parents 077da0c + 1232362 commit 0a4e181
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 111 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = tab

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Icon?
*.zip
_site
dist/
node_modules
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
GAS Changelog
=============

1.11.0
------
- Display Advertising (dc.js) support (9d4bb3e)
- Build system moved to Grunt (f3921fc)
- Removed _sanitizeString helper function (e042350)
- Outbound events are non-interactive now (9585c4e)
- Allow negative event values (ce4515c)
- Don't push GAS functions inside _gaq. (18c5e79)
- Extra checks on the live handler, fixes issue with ie8 (ae1d554)

1.10.1
------
- Experimental Support for `_gasMeta`, `_gasMetaEcommerce` and
Expand Down
97 changes: 97 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*global module,require*/
module.exports = function (grunt) {
'use strict';

require('matchdep')
.filterDev('grunt-*')
.forEach(grunt.loadNpmTasks);

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: [
'/**',
' * @preserve Copyright 2011, Cardinal Path and DigitalInc.',
' *',
' * GAS - Google Analytics on Steroids',
' * https://github.com/CardinalPath/gas',
' *',
' * @author Eduardo Cereto <[email protected]>',
' * Licensed under the GPLv3 license.',
' */',
'',
].join('\n'),
// Task configuration.
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
src: {
src: ['src/**/*.js', '!src/wrappers/*.js']
},
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src', 'nodeunit']
},
},
concat: {
options: {
banner: '<%= banner %>'
},
gas: {
src: [
'src/wrappers/intro.js',
'src/helpers.js',
'src/core.js',
'src/plugins/*.js',
'src/wrapup.js',
'src/wrappers/outro.js'
],
dest: 'dist/gas.js',
},
core: {
src: [
'src/wrappers/intro.js',
'src/helpers.js',
'src/core.js',
'src/wrapup.js',
'src/wrappers/outro.js'
],
dest: 'dist/gas.core.js',
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
all: {
files: {
'dist/gas.min.js': 'dist/gas.js',
'dist/gas.core.min.js': 'dist/gas.core.js'
}
},
},
clean: ['dist']
});

// Default task.
grunt.registerTask('default', [
'jshint'
]);
grunt.registerTask('build', [
'default',
'clean',
'concat',
'uglify'
]);

};
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ _gas.push(['_gasTrackMailto']);
(function() {
var ga = document.createElement('script');
ga.id = 'gas-script';
ga.setAttribute('data-use-dcjs', 'false');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '//cdnjs.cloudflare.com/ajax/libs/gas/1.10.1/gas.min.js';
ga.src = '//cdnjs.cloudflare.com/ajax/libs/gas/1.11.0/gas.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
Expand Down Expand Up @@ -388,3 +390,11 @@ _gas.push(['_addHook', '_setVar', function(val){
The above Hook will intercept and cancel any call to the, now deprecated,
`_setVar`. It will then trigger a call to `_setCustomVar` with an
equivalent value.

### Display Advertising Support

Available in versions 1.11.0+, you can include dc.js instead of ga.js through gas by changing the setAttribute line of the default snippet to

```
ga.setAttribute('data-use-dcjs', 'true');
```
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "gas",
"version": "1.11.0",
"description": "Google Analytics on Steroids",
"main": "Gruntfile.js",
"directories": {
"test": "test"
},
"dependencies": {
"matchdep": "~0.3.0"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-clean": "~0.5.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/CardinalPath/gas.git"
},
"author": "",
"license": "GPLv3",
"bugs": {
"url": "https://github.com/CardinalPath/gas/issues"
},
"homepage": "https://github.com/CardinalPath/gas"
}
7 changes: 5 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (_prev_gas._accounts_length >= 0) {
}

//Shortcuts, these speed up and compress the code
/*jshint -W079*/
var document = window.document,
toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty,
Expand All @@ -33,14 +34,14 @@ var document = window.document,
sindexOf = String.prototype.indexOf,
url = document.location.href,
documentElement = document.documentElement;

/*jshint +W079*/
/**
* GAS Sigleton
* @constructor
*/
function GAS() {
var self = this;
self['version'] = '1.10.1';
self['version'] = '1.11.0';
self._accounts = {};
self._accounts_length = 0;
self._queue = _prev_gas;
Expand Down Expand Up @@ -247,7 +248,9 @@ GAS.prototype.push = function () {
* everything pushed to _gas is run through possible hooks and then pushed to
* _gaq
*/
/*global _gas:true*/
window['_gas'] = _gas = new GAS();
/*global _gas:false*/


/**
Expand Down
39 changes: 8 additions & 31 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
*
* @constructor
*/
/*jshint -W079*/
var GasHelper = function () {
this._setDummyTracker();
};
/*jshint +W079*/

GasHelper.prototype._setDummyTracker = function () {
if (!this['tracker']) {
Expand Down Expand Up @@ -47,31 +49,6 @@ GasHelper.prototype.inArray = function (obj, item) {
return false;
};

/**
* Removes special characters and Lowercase String
*
* @param {string} str to be sanitized.
* @param {boolean} strict_opt If we should remove any non ascii char.
* @return {string} Sanitized string.
*/
GasHelper.prototype._sanitizeString = function (str, strict_opt) {
str = str.toLowerCase()
.replace(/^\ +/, '')
.replace(/\ +$/, '')
.replace(/\s+/g, '_')
.replace(/[áàâãåäæª]/g, 'a')
.replace(/[éèêëЄ€]/g, 'e')
.replace(/[íìîï]/g, 'i')
.replace(/[óòôõöøº]/g, 'o')
.replace(/[úùûü]/g, 'u')
.replace(/[碩]/g, 'c');

if (strict_opt) {
str = str.replace(/[^a-z0-9_\-]/g, '_');
}
return str.replace(/_+/g, '_');
};

/**
* Cross Browser helper to addEventListener.
*
Expand Down Expand Up @@ -133,15 +110,15 @@ GasHelper.prototype._liveEvent = function (tag, evt, ofunc) {
tag = tag.split(',');

gh._addEventListener(document, evt, function (me) {
for (var el = me.target; el.nodeName !== 'HTML';
el = el.parentNode)
var el = me.target;

while (el && el.nodeName && el.nodeName.toUpperCase() !== 'HTML')
{
if (gh.inArray(tag, el.nodeName) || el.parentNode === null) {
if (gh.inArray(tag, el.nodeName)) {
ofunc.call(el, me);
break;
}
}
if (el && gh.inArray(tag, el.nodeName)) {
ofunc.call(el, me);
el = el.parentNode;
}

}, true);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _trackDownloads = function (opts) {
gh._downloadTracked = true;
} else {
//Oops double tracking detected.
return;
return false;
}
if (!opts) {
opts = {'extensions': []};
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ecommerce_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function _gasMetaEcommerce() {
_gas.push(['_trackTrans']);
//_gas.push(['_clearTrans']);
}
return false;
}

_gas.push(['_addHook', '_gasMetaEcommerce', _gasMetaEcommerce]);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/fix_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_gas.push(['_addHook', '_trackEvent', function () {
var args = slice.call(arguments);
if (args[3]) {
args[3] = (args[3] < 0 ? 0 : Math.round(args[3])) || 0;
args[3] = Math.round(args[3]);
}
return args;
}]);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/form_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _gasTrackForms = function (opts) {
this._formTracked = true;
} else {
//Oops double tracking detected.
return;
return false;
}
var scp = this;
if (typeof opts !== 'object') {
Expand Down Expand Up @@ -70,6 +70,7 @@ var _gasTrackForms = function (opts) {
}
}
});
return false;
};

_gas.push(['_addHook', '_gasTrackForms', _gasTrackForms]);
Expand Down
Loading

0 comments on commit 0a4e181

Please sign in to comment.