Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
* require/amd fix for the console
* added support for binding arrays of objects
  • Loading branch information
Ryan Brewster committed Oct 28, 2014
1 parent 8565583 commit 00ae97c
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 76 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md

This file was deleted.

2 changes: 0 additions & 2 deletions demo/atrackt_demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ a {
padding: 30px;
border: 1px solid lightgrey;
margin-bottom: 30px; }

/*# sourceMappingURL=atrackt_demo.css.map */
2 changes: 0 additions & 2 deletions lib/atrackt.console.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ body.atrackt-console {
body.atrackt-console #atrackt-console table tr.error {
color: white;
background-color: red; }

/*# sourceMappingURL=atrackt.console.css.map */
4 changes: 2 additions & 2 deletions lib/atrackt.console.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 41 additions & 30 deletions lib/atrackt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/plugins/atrackt.localytics.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/plugins/atrackt.omniture.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions spec/atrackt_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ describe 'Atrackt', ->

expect($._data($fooEl[0]).events.click[0].namespace).to.equal 'atrackt'

it 'should bind an array of all types of objects', ->
$selectorOneEl = $('<div class="array-selector-one"></div>')
$selectorTwoEl = $('<div class="array-selector-two"></div>')
$jqueryEl = $('<div class="array-jquery"></div>')
$htmlNodeEl = $('<div class="array-html-node"></div>')
$('body').append $selectorOneEl, $selectorTwoEl, $jqueryEl, $htmlNodeEl

Atrackt.setEvent
click: [ '.array-selector-one, .array-selector-two', $('.array-jquery'), $('.array-html-node')[0]]

expect($._data($selectorOneEl[0]).events.click[0].namespace).to.equal 'atrackt'
expect($._data($selectorTwoEl[0]).events.click[0].namespace).to.equal 'atrackt'
expect($._data($jqueryEl[0]).events.click[0].namespace).to.equal 'atrackt'
expect($._data($htmlNodeEl[0]).events.click[0].namespace).to.equal 'atrackt'

describe '#setOptions', ->
before ->
Atrackt.setOptions
Expand Down
7 changes: 7 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
### CHANGE LOG
###### 1.0.2
* require/amd fix for the console
* added support for binding arrays of objects

###### 1.0.0
* refactor and api updates

###### 0.1.2
* Improved compatibility with <IE8

Expand Down
61 changes: 33 additions & 28 deletions src/atrackt.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###
Atrackt Tracking Library
https://github.com/brewster1134/atrackt
@version 1.0.0
@version 1.0.2
@author Ryan Brewster
###

Expand Down Expand Up @@ -70,33 +70,38 @@ https://github.com/brewster1134/atrackt
pluginEvent = globalEvent.slice(0)
pluginEvent.push context.name if context.name

$(objects).each (index, element) =>
@_elements[eventType] ||= []

# if binding on a plugin
# ...and the element has not already been bound globally
# ...and the element has not already been bound to the plugin
if context.name
globalIndex = @_elements[eventType].indexOf(element)

# if element is not in global array...
if globalIndex == -1
context._elements[eventType] ||= []

# if element is not in plugin array...
if context._elements[eventType].indexOf(element) == -1
@_registerElement context, element, eventType

# if binding globally
# ...and the element has not already been bound globally
else if @_elements[eventType].indexOf(element) == -1
@_registerElement context, element, eventType

# loop through plugins and remove global element if it exists
for pluginName, pluginData of @plugins
pluginIndex = pluginData._elements[eventType]?.indexOf(element)
if pluginIndex != -1
pluginData._elements[eventType]?.splice pluginIndex, 1
# typecast objects into an array
unless objects instanceof Array
objects = [objects]

for object in objects
$(object).each (index, element) =>
@_elements[eventType] ||= []

# if binding on a plugin
# ...and the element has not already been bound globally
# ...and the element has not already been bound to the plugin
if context.name
globalIndex = @_elements[eventType].indexOf(element)

# if element is not in global array...
if globalIndex == -1
context._elements[eventType] ||= []

# if element is not in plugin array...
if context._elements[eventType].indexOf(element) == -1
@_registerElement context, element, eventType

# if binding globally
# ...and the element has not already been bound globally
else if @_elements[eventType].indexOf(element) == -1
@_registerElement context, element, eventType

# loop through plugins and remove global element if it exists
for pluginName, pluginData of @plugins
pluginIndex = pluginData._elements[eventType]?.indexOf(element)
if pluginIndex != -1
pluginData._elements[eventType]?.splice pluginIndex, 1

# Set data that will always be tracked
#
Expand Down
4 changes: 2 additions & 2 deletions src/atrackt.console.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###
Atrackt Tracking Library
https://github.com/brewster1134/atrackt
@version 1.0.0
@version 1.0.2
@author Ryan Brewster
###

Expand All @@ -12,7 +12,7 @@ https://github.com/brewster1134/atrackt
'jquery'
'atrackt'
], ($, Atrackt) ->
window.Atrackt = new(factory($, Atrackt))
window.Atrackt = new(factory($, Atrackt.constructor))
else
window.Atrackt = new(factory($, Atrackt.constructor))
) @, ($, Atrackt) ->
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### CHANGE LOG
##### Localytics Plugin
###### 1.0.0
* updated to new api

###### 0.0.2
* supports detecting when in UIWebView
* redirects to a `localytics://` style url for UIWebView
Expand All @@ -11,6 +14,9 @@
* Just a simple send method!

##### Omniture Plugin
###### 1.0.0
* updated to new api

###### 0.0.7
* Supports multiple types for tracked values

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/atrackt.localytics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Atrackt Localytics Plugin
https://github.com/brewster1134/atrackt
@author Ryan Brewster
@version 1.0.0
@version 1.0.2
###

((root, factory) ->
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/atrackt.omniture.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Atrackt Omniture Plugin
https://github.com/brewster1134/atrackt
@author Ryan Brewster
@version 1.0.0
@version 1.0.2
###

((root, factory) ->
Expand Down

0 comments on commit 00ae97c

Please sign in to comment.