diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 0000000..dc3894e --- /dev/null +++ b/.hound.yml @@ -0,0 +1,2 @@ +jshint: + enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ba11b..f66e710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +###### 1.0.10 +* form element values take precedence over other attributes + ###### 1.0.9 * support for a delay option diff --git a/Gemfile.lock b/Gemfile.lock index eb9a29f..8829e60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,13 @@ GEM remote: https://rubygems.org/ specs: - sass (3.4.13) + sass (3.4.22) PLATFORMS ruby DEPENDENCIES sass (~> 3.4) + +BUNDLED WITH + 1.12.5 diff --git a/README.md b/README.md index 9a6ac41..d5d1a76 100644 --- a/README.md +++ b/README.md @@ -125,10 +125,10 @@ It will track the first value it finds from the following: --- #### `_value` * `data-atrackt-value` A custom value to explicitly set + * `val` The value (if a form element) * `title` The value of the title attribute * `name` The value of the name attribute * `text` The text value of the element. This contains only text and will not include any HTML. - * `val` The value (if a form element) * `id` The value of the id attribute * `class` The value of the class attribute diff --git a/bower.json b/bower.json index 32f7073..20844e2 100644 --- a/bower.json +++ b/bower.json @@ -1,15 +1,15 @@ { "name": "atrackt", "dependencies": { - "jquery": "~2", - "jquery.scrollTo": "~1" + "jquery": "*", + "jquery.scrollTo": "*" }, "devDependencies": { - "chai": "~1", - "chai-as-promised": "~4", - "mocha": "~1", - "sinon": "~1", - "sinon-chai": "~2", - "lolex": "sinonjs/lolex#~1" + "chai": "*", + "chai-as-promised": "*", + "mocha": "*", + "sinon": "*", + "sinon-chai": "*", + "lolex": "sinonjs/lolex" } } diff --git a/demo/atrackt_demo.js b/demo/atrackt_demo.js index 7be9e86..8568c68 100644 --- a/demo/atrackt_demo.js +++ b/demo/atrackt_demo.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.10.0 (function() { $(function() { Atrackt.setPlugin('Demo Plugin', { diff --git a/lib/atrackt.console.js b/lib/atrackt.console.js index f240aae..9d02f1e 100644 --- a/lib/atrackt.console.js +++ b/lib/atrackt.console.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.10.0 /* Atrackt Tracking Library @@ -8,8 +8,8 @@ https://github.com/brewster1134/atrackt */ (function() { - var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; (function(root, factory) { if (typeof define === 'function' && define.amd) { @@ -27,8 +27,8 @@ https://github.com/brewster1134/atrackt } })(this, function($, Atrackt) { var AtracktConsole; - return AtracktConsole = (function(_super) { - __extends(AtracktConsole, _super); + return AtracktConsole = (function(superClass) { + extend(AtracktConsole, superClass); function AtracktConsole() { var consoleHtml; @@ -51,55 +51,55 @@ https://github.com/brewster1134/atrackt }; AtracktConsole.prototype._setPlugins = function() { - var plugin, pluginName, _ref, _results; - _ref = this.plugins; - _results = []; - for (pluginName in _ref) { - plugin = _ref[pluginName]; + var plugin, pluginName, ref, results; + ref = this.plugins; + results = []; + for (pluginName in ref) { + plugin = ref[pluginName]; if (!plugin._send) { - _results.push(this.setPlugin(pluginName, plugin)); + results.push(this.setPlugin(pluginName, plugin)); } else { - _results.push(void 0); + results.push(void 0); } } - return _results; + return results; }; AtracktConsole.prototype._renderConsoleElements = function() { - var element, elements, eventType, plugin, pluginName, _i, _len, _ref, _ref1, _results; + var element, elements, eventType, i, len, plugin, pluginName, ref, ref1, results; $('tbody', this.$console).empty(); - _ref = this._elements; - for (eventType in _ref) { - elements = _ref[eventType]; - for (_i = 0, _len = elements.length; _i < _len; _i++) { - element = elements[_i]; + ref = this._elements; + for (eventType in ref) { + elements = ref[eventType]; + for (i = 0, len = elements.length; i < len; i++) { + element = elements[i]; this._renderConsoleElement('ALL', element, eventType); } } - _ref1 = this.plugins; - _results = []; - for (pluginName in _ref1) { - plugin = _ref1[pluginName]; - _results.push((function() { - var _ref2, _results1; - _ref2 = plugin._elements; - _results1 = []; - for (eventType in _ref2) { - elements = _ref2[eventType]; - _results1.push((function() { - var _j, _len1, _results2; - _results2 = []; - for (_j = 0, _len1 = elements.length; _j < _len1; _j++) { - element = elements[_j]; - _results2.push(this._renderConsoleElement(pluginName, element, eventType)); + ref1 = this.plugins; + results = []; + for (pluginName in ref1) { + plugin = ref1[pluginName]; + results.push((function() { + var ref2, results1; + ref2 = plugin._elements; + results1 = []; + for (eventType in ref2) { + elements = ref2[eventType]; + results1.push((function() { + var j, len1, results2; + results2 = []; + for (j = 0, len1 = elements.length; j < len1; j++) { + element = elements[j]; + results2.push(this._renderConsoleElement(pluginName, element, eventType)); } - return _results2; + return results2; }).call(this)); } - return _results1; + return results1; }).call(this)); } - return _results; + return results; }; AtracktConsole.prototype._registerElement = function(context, element, event) { diff --git a/lib/atrackt.js b/lib/atrackt.js index 084c5dd..8810bfc 100644 --- a/lib/atrackt.js +++ b/lib/atrackt.js @@ -1,8 +1,9 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.10.0 /* Atrackt Tracking Library https://github.com/brewster1134/atrackt +@version 1.0.10 @author Ryan Brewster */ @@ -72,14 +73,14 @@ https://github.com/brewster1134/atrackt }; Atrackt.prototype.setEvent = function(eventsObject, context) { - var eventType, globalEvent, object, objects, pluginEvent, _results; + var eventType, globalEvent, object, objects, pluginEvent, results; if (context == null) { context = this; } if (!eventsObject) { throw new Error('ATRACKT ERROR: `setEvent` - You must pass a valid event object.'); } - _results = []; + results = []; for (eventType in eventsObject) { objects = eventsObject[eventType]; globalEvent = [eventType, 'atrackt']; @@ -90,45 +91,45 @@ https://github.com/brewster1134/atrackt if (!(objects instanceof Array)) { objects = [objects]; } - _results.push((function() { - var _i, _len, _results1; - _results1 = []; - for (_i = 0, _len = objects.length; _i < _len; _i++) { - object = objects[_i]; - _results1.push($(object).each((function(_this) { + results.push((function() { + var i, len, results1; + results1 = []; + for (i = 0, len = objects.length; i < len; i++) { + object = objects[i]; + results1.push($(object).each((function(_this) { return function(index, element) { - var globalIndex, pluginData, pluginIndex, pluginName, _base, _base1, _ref, _ref1, _ref2, _results2; - (_base = _this._elements)[eventType] || (_base[eventType] = []); + var base, base1, globalIndex, pluginData, pluginIndex, pluginName, ref, ref1, ref2, results2; + (base = _this._elements)[eventType] || (base[eventType] = []); if (context.name) { globalIndex = _this._elements[eventType].indexOf(element); if (globalIndex === -1) { - (_base1 = context._elements)[eventType] || (_base1[eventType] = []); + (base1 = context._elements)[eventType] || (base1[eventType] = []); if (context._elements[eventType].indexOf(element) === -1) { return _this._registerElement(context, element, eventType); } } } else if (_this._elements[eventType].indexOf(element) === -1) { _this._registerElement(context, element, eventType); - _ref = _this.plugins; - _results2 = []; - for (pluginName in _ref) { - pluginData = _ref[pluginName]; - pluginIndex = (_ref1 = pluginData._elements[eventType]) != null ? _ref1.indexOf(element) : void 0; + ref = _this.plugins; + results2 = []; + for (pluginName in ref) { + pluginData = ref[pluginName]; + pluginIndex = (ref1 = pluginData._elements[eventType]) != null ? ref1.indexOf(element) : void 0; if (pluginIndex !== -1) { - _results2.push((_ref2 = pluginData._elements[eventType]) != null ? _ref2.splice(pluginIndex, 1) : void 0); + results2.push((ref2 = pluginData._elements[eventType]) != null ? ref2.splice(pluginIndex, 1) : void 0); } else { - _results2.push(void 0); + results2.push(void 0); } } - return _results2; + return results2; } }; })(this))); } - return _results1; + return results1; }).call(this)); } - return _results; + return results; }; Atrackt.prototype.setData = function(data, context) { @@ -146,7 +147,7 @@ https://github.com/brewster1134/atrackt }; Atrackt.prototype.setCallback = function(name, callback, context) { - var allowedCallbacks, _base; + var allowedCallbacks, base; if (context == null) { context = this; } @@ -154,7 +155,7 @@ https://github.com/brewster1134/atrackt if (allowedCallbacks.indexOf(name) === -1) { throw new Error("ATRACKT ERROR: `setCallback` - `" + name + "` is not a valid callback. Only callbacks allowed are: " + (allowedCallbacks.join(', '))); } - (_base = context._callbacks)[name] || (_base[name] = []); + (base = context._callbacks)[name] || (base[name] = []); return context._callbacks[name].push(callback); }; @@ -168,30 +169,30 @@ https://github.com/brewster1134/atrackt } trackPlugins = (function(_this) { return function() { - var eventNamespace, pluginData, pluginName, _ref, _ref1, _results; - _ref = _this.plugins; - _results = []; - for (pluginName in _ref) { - pluginData = _ref[pluginName]; - if (eventNamespace = event != null ? (_ref1 = event.handleObj) != null ? _ref1.namespace : void 0 : void 0) { + var eventNamespace, pluginData, pluginName, ref, ref1, results; + ref = _this.plugins; + results = []; + for (pluginName in ref) { + pluginData = ref[pluginName]; + if (eventNamespace = event != null ? (ref1 = event.handleObj) != null ? ref1.namespace : void 0 : void 0) { if (eventNamespace === 'atrackt' || eventNamespace === ("atrackt." + pluginName)) { - _results.push(_this._trackJqueryObject(pluginData, data, options, event)); + results.push(_this._trackJqueryObject(pluginData, data, options, event)); } else { - _results.push(void 0); + results.push(void 0); } } else { if (!options['_plugin'] || options['_plugin'] === pluginName) { if (data instanceof jQuery) { - _results.push(_this._trackJqueryObject(pluginData, data, options, event)); + results.push(_this._trackJqueryObject(pluginData, data, options, event)); } else { - _results.push(_this._track(pluginData, data, options, event)); + results.push(_this._track(pluginData, data, options, event)); } } else { - _results.push(void 0); + results.push(void 0); } } } - return _results; + return results; }; })(this); delay = options['delay']; @@ -231,7 +232,7 @@ https://github.com/brewster1134/atrackt }; Atrackt.prototype._track = function(plugin, data, options, event) { - var callback, metaData, optionsCopy, trackingData, trackingOptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _results; + var callback, i, j, k, l, len, len1, len2, len3, metaData, optionsCopy, ref, ref1, ref2, ref3, results, trackingData, trackingOptions; metaData = this._getTrackObject(data, event); if (!metaData) { throw new Error('ATRACKT ERROR: `track` - Only valid selectors, jquery objects, or html nodes are supported.'); @@ -241,16 +242,16 @@ https://github.com/brewster1134/atrackt delete optionsCopy['_data']; delete optionsCopy[plugin.name]; trackingOptions = $.extend(true, {}, this._options, plugin._options, optionsCopy); - _ref = this._callbacks['before'] || []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - callback = _ref[_i]; + ref = this._callbacks['before'] || []; + for (i = 0, len = ref.length; i < len; i++) { + callback = ref[i]; if (typeof callback === "function") { callback(trackingData, trackingOptions); } } - _ref1 = plugin._callbacks['before'] || []; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - callback = _ref1[_j]; + ref1 = plugin._callbacks['before'] || []; + for (j = 0, len1 = ref1.length; j < len1; j++) { + callback = ref1[j]; if (typeof callback === "function") { callback(trackingData, trackingOptions); } @@ -261,20 +262,20 @@ https://github.com/brewster1134/atrackt } } plugin.send(trackingData, trackingOptions); - _ref2 = plugin._callbacks['after'] || []; - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - callback = _ref2[_k]; + ref2 = plugin._callbacks['after'] || []; + for (k = 0, len2 = ref2.length; k < len2; k++) { + callback = ref2[k]; if (typeof callback === "function") { callback(trackingData, trackingOptions); } } - _ref3 = this._callbacks['after'] || []; - _results = []; - for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { - callback = _ref3[_l]; - _results.push(typeof callback === "function" ? callback(trackingData, trackingOptions) : void 0); + ref3 = this._callbacks['after'] || []; + results = []; + for (l = 0, len3 = ref3.length; l < len3; l++) { + callback = ref3[l]; + results.push(typeof callback === "function" ? callback(trackingData, trackingOptions) : void 0); } - return _results; + return results; }; Atrackt.prototype._getTrackObject = function(data, event) { @@ -310,7 +311,7 @@ https://github.com/brewster1134/atrackt }; Atrackt.prototype._getValue = function($el) { - return $el.data('atrackt-value') || $el.attr('title') || $el.attr('name') || $el.text().trim() || $el.val() || $el.attr('id') || $el.attr('class'); + return $el.data('atrackt-value') || $el.val() || $el.attr('title') || $el.attr('name') || $el.text().trim() || $el.attr('id') || $el.attr('class'); }; return Atrackt; diff --git a/lib/plugins/atrackt.localytics.js b/lib/plugins/atrackt.localytics.js index 4a02d53..ea6549e 100644 --- a/lib/plugins/atrackt.localytics.js +++ b/lib/plugins/atrackt.localytics.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.10.0 /* Atrackt Localytics Plugin diff --git a/lib/plugins/atrackt.omniture.js b/lib/plugins/atrackt.omniture.js index 3a93e58..175ce0d 100644 --- a/lib/plugins/atrackt.omniture.js +++ b/lib/plugins/atrackt.omniture.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.10.0 /* Atrackt Omniture Plugin @@ -35,18 +35,18 @@ https://github.com/brewster1134/atrackt } }, send: function(data, options) { - var arg, _ref, _ref1; + var arg, ref, ref1; if (typeof s === "undefined" || s === null) { return; } $.extend(true, this.options, options); - data._categories = (_ref = data._categories) != null ? _ref.join(this.options.delimiters.category) : void 0; + data._categories = (ref = data._categories) != null ? ref.join(this.options.delimiters.category) : void 0; data = this._translatePropMap(data); this._buildSObject(data); if (this.options.page && (s.t != null)) { s.t(); } else if (s.tl != null) { - arg = ((_ref1 = this.options.el) != null ? _ref1.attr('href') : void 0) ? this.options.el[0] : true; + arg = ((ref1 = this.options.el) != null ? ref1.attr('href') : void 0) ? this.options.el[0] : true; s.tl(arg, this.options['trackingType'], this._buildLinkName(data)); } return data; @@ -81,8 +81,8 @@ https://github.com/brewster1134/atrackt _globalData = {}; $.each(obj, (function(_this) { return function(k, v) { - var _base; - return _globalData[_this._keyLookup(k)] = v != null ? typeof (_base = v.toString()).replace === "function" ? _base.replace(_this.options.charReplaceRegex, '') : void 0 : void 0; + var base; + return _globalData[_this._keyLookup(k)] = v != null ? typeof (base = v.toString()).replace === "function" ? base.replace(_this.options.charReplaceRegex, '') : void 0 : void 0; }; })(this)); return _globalData; diff --git a/src/atrackt.coffee b/src/atrackt.coffee index 2d32dc8..d48c3d3 100644 --- a/src/atrackt.coffee +++ b/src/atrackt.coffee @@ -1,6 +1,7 @@ ### Atrackt Tracking Library https://github.com/brewster1134/atrackt +@version 1.0.10 @author Ryan Brewster ### @@ -271,9 +272,9 @@ https://github.com/brewster1134/atrackt # _getValue: ($el) -> $el.data('atrackt-value') || + $el.val() || $el.attr('title') || $el.attr('name') || $el.text().trim() || - $el.val() || $el.attr('id') || $el.attr('class')