diff --git a/assets/scripts/app/app.coffee b/assets/scripts/app/app.coffee index 3f5adc8e..4e16be6f 100644 --- a/assets/scripts/app/app.coffee +++ b/assets/scripts/app/app.coffee @@ -33,7 +33,7 @@ unless window.TravisApplication @slider = new Travis.Slider() @pusher = new Travis.Pusher(Travis.config.pusher_key) if Travis.config.pusher_key - @tailing = new Travis.Tailing($(window), '#tail', '#log') + @tailing = new Travis.Tailing() @set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint)) diff --git a/assets/scripts/app/components.coffee b/assets/scripts/app/components.coffee new file mode 100644 index 00000000..da423edd --- /dev/null +++ b/assets/scripts/app/components.coffee @@ -0,0 +1,9 @@ +Travis.TravisSwitchComponent = Ember.Component.extend + tagName: 'a' + classNames: ['travis-switch'] + classNameBindings: ['active'] + + activeBinding: 'target.active' + + click: -> + @sendAction('action', @get('target')) diff --git a/assets/scripts/app/tailing.coffee b/assets/scripts/app/tailing.coffee index 3df8c872..fab3fec8 100644 --- a/assets/scripts/app/tailing.coffee +++ b/assets/scripts/app/tailing.coffee @@ -1,17 +1,12 @@ -class @Travis.Tailing +@Travis.Tailing = -> + @position = $(window).scrollTop() + $(window).scroll( $.throttle( 200, @onScroll.bind(this) ) ) + this + +$.extend Travis.Tailing.prototype, options: timeout: 200 - tail: -> - $(@tail_selector) - log: -> - $(@log_selector) - - constructor: (@window, @tail_selector, @log_selector) -> - @position = @window.scrollTop() - @window.scroll( $.throttle( 200, @onScroll.bind(this) ) ) - this - run: -> @autoScroll() @positionButton() @@ -21,43 +16,37 @@ class @Travis.Tailing if @active() then @stop() else @start() active: -> - @tail().hasClass('active') + $('#tail').hasClass('active') start: -> - @tail().addClass('active') + $('#tail').addClass('active') @run() stop: -> - @tail().removeClass('active') + $('#tail').removeClass('active') autoScroll: -> - return false unless @active() - logBottom = @log().offset().top + @log().outerHeight() + 40 - winBottom = @window.scrollTop() + @window.height() - - if logBottom - winBottom > 0 - @window.scrollTop(logBottom - @window.height()) - true - else - false + return unless @active() + win = $(window) + log = $('#log') + logBottom = log.offset().top + log.outerHeight() + 40 + winBottom = win.scrollTop() + win.height() + win.scrollTop(logBottom - win.height()) if logBottom - winBottom > 0 onScroll: -> @positionButton() - position = @window.scrollTop() + position = $(window).scrollTop() @stop() if position < @position @position = position positionButton: -> - return if @tail().length is 0 - offset = @window.scrollTop() - @log().offset().top - max = @log().height() - @tail().height() + 5 - - if offset > 0 && offset <= max - @tail().removeClass('bottom') - @tail().addClass('scrolling') + tail = $('#tail') + return if tail.length is 0 + offset = $(window).scrollTop() - $('#log').offset().top + max = $('#log').height() - $('#tail').height() + 5 + offset = max if offset > max + if offset > 0 + tail.css(top: offset - 2) else - if offset > max - @tail().addClass('bottom') - else - @tail().removeClass('bottom') - @tail().removeClass('scrolling') + tail.css(top: 0) + diff --git a/assets/scripts/app/templates/components/travis-switch.hbs b/assets/scripts/app/templates/components/travis-switch.hbs new file mode 100644 index 00000000..e7b20837 --- /dev/null +++ b/assets/scripts/app/templates/components/travis-switch.hbs @@ -0,0 +1,5 @@ +{{#if active}} + ON +{{else}} + OFF +{{/if}} diff --git a/assets/scripts/app/templates/jobs/pre.hbs b/assets/scripts/app/templates/jobs/pre.hbs index c3aee48e..b8259c2c 100644 --- a/assets/scripts/app/templates/jobs/pre.hbs +++ b/assets/scripts/app/templates/jobs/pre.hbs @@ -1,14 +1,7 @@
- - +

 
diff --git a/assets/scripts/app/templates/layouts/top.hbs b/assets/scripts/app/templates/layouts/top.hbs
index 0f583cf6..fef5be50 100644
--- a/assets/scripts/app/templates/layouts/top.hbs
+++ b/assets/scripts/app/templates/layouts/top.hbs
@@ -7,7 +7,7 @@
     {{#link-to "index.current"}}{{t layouts.top.home}}{{/link-to}}
   
   
  • - {{t layouts.top.blog}} + {{t layouts.top.blog}}
  • {{t layouts.top.status}} @@ -17,8 +17,8 @@ Help