Skip to content

Commit

Permalink
1.0.4
Browse files Browse the repository at this point in the history
* better console
* scrolling support
  • Loading branch information
Ryan Brewster committed Oct 28, 2014
1 parent ded2383 commit d8db606
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "atrackt",
"dependencies": {
"jquery": "~2.1.1"
"jquery": "~2.1.1",
"jquery.scrollTo": "~1.4.13"
},
"devDependencies": {
"chai": "~1.9.1",
Expand Down
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h2>3rd Set</h2>

<!-- Dependencies -->
<script type="text/javascript" src="../vendor/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../vendor/jquery.scrollTo/jquery.scrollTo.js"></script>

<!-- Footer Libraries -->
<script type="text/javascript" src="../lib/atrackt.js"></script>
Expand Down
5 changes: 3 additions & 2 deletions lib/atrackt.console.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ body.atrackt-console {
body.atrackt-console #atrackt-console table {
text-align: left;
width: 100%; }
body.atrackt-console #atrackt-console table tr.atrackt-console-active {
background-color: orange; }
body.atrackt-console #atrackt-console table tr.error {
color: white;
background-color: red; }
body.atrackt-console #atrackt-console table tr.atrackt-console-active {
background-color: orange;
border: none; }
64 changes: 59 additions & 5 deletions lib/atrackt.console.js

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

1 change: 1 addition & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<!-- Testing Dependencies -->
<script type="text/javascript" src="/vendor/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="/vendor/jquery.scrollTo/jquery.scrollTo.js"></script>
<script type="text/javascript" src="/vendor/mocha/mocha.js"></script>
<script type="text/javascript" src="/vendor/chai/chai.js"></script>
<script type="text/javascript" src="/vendor/sinon/lib/sinon.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### CHANGE LOG
###### 1.0.4
* console loads after document ready and collects all existing element
* console now has scrolling support on hover

###### 1.0.2
* require/amd fix for the console
* added support for binding arrays of objects
Expand Down
37 changes: 35 additions & 2 deletions src/atrackt.console.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ https://github.com/brewster1134/atrackt
define [
'jquery'
'atrackt'
'jquery.scrollTo'
], ($, Atrackt) ->
window.Atrackt = new(factory($, Atrackt.constructor))
$ ->
window.Atrackt = new(factory($, Atrackt.constructor))
else
window.Atrackt = new(factory($, Atrackt.constructor))
window.Atrackt = new(factory(window.jQuery, window.Atrackt.constructor))
) @, ($, Atrackt) ->

class AtracktConsole extends Atrackt
Expand Down Expand Up @@ -44,6 +46,8 @@ https://github.com/brewster1134/atrackt
$('#atrackt-location', @$console).text @_getLocation()
$('body').addClass('atrackt-console').prepend @$console

@_renderConsoleElements()

# Override the custom class to just log tracking data to the console
#
setPlugin: (pluginName, plugin) ->
Expand All @@ -55,6 +59,22 @@ https://github.com/brewster1134/atrackt
plugin.send = (data, options) ->
console.log plugin.name, data, options

# Re-render console elements
#
_renderConsoleElements: ->
$('tbody', @$console).empty()

# Render global elements
for eventType, elements of @_elements
for element in elements
@_renderConsoleElement 'ALL', element, eventType

# Render all plugin elements
for pluginName, plugin of @plugins
for eventType, elements of plugin._elements
for element in elements
@_renderConsoleElement pluginName, element, eventType

# Add console events to elements
#
_registerElement: (context, element, event) ->
Expand All @@ -70,6 +90,8 @@ https://github.com/brewster1134/atrackt
# Add a single element to the console
#
_renderConsoleElement: (contextName, element, eventType) ->
self = @

# Get element meta data
trackObject = @_getTrackObject element, eventType

Expand Down Expand Up @@ -99,6 +121,17 @@ https://github.com/brewster1134/atrackt
$rowEl.add($trackEl).hover ->
$rowEl.addClass 'atrackt-console-active'
$trackEl.addClass 'atrackt-console-active'

# scroll to hovered element
if $.scrollTo
if @ == $rowEl[0]
$.scrollTo $trackEl, 0,
offset:
top: -300
else if @ == $trackEl[0]
self.$console.scrollTo $rowEl, 0
offset:
top: -50
, ->
$rowEl.removeClass 'atrackt-console-active'
$trackEl.removeClass 'atrackt-console-active'
5 changes: 3 additions & 2 deletions src/atrackt.console.sass
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ body.atrackt-console
width: 100%

tr
&.atrackt-console-active
background-color: orange
&.error
color: white
background-color: red
&.atrackt-console-active
background-color: orange
border: none

0 comments on commit d8db606

Please sign in to comment.