listView: @, app: @options.app
+ initialize: ->
+ openRule = (el) -> el.click()
+ @openRule = _.debounce openRule, 300
+ key.setScope 'list'
+
+
+ onRender: ->
+ key 'up', 'list', => @selectPrev()
+ key 'down', 'list', => @selectNext()
+
+
+ selectIssue: (el, open) ->
+ @$('.active').removeClass 'active'
+ el.addClass 'active'
+ @openRule el if open
+
+
selectFirst: ->
- @$el.find('*:first').click()
+ @selected = -1
+ @selectNext()
+
+
+ selectNext: ->
+ if @selected < @collection.length - 1
+ @selected++
+ child = @$el.children().eq @selected
+ container = jQuery('.navigator-results')
+ containerHeight = container.height()
+ bottom = child.position().top + child.outerHeight()
+ if bottom > containerHeight
+ container.scrollTop(container.scrollTop() - containerHeight + bottom)
+ @selectIssue child, true
+
+
+ selectPrev: ->
+ if @selected > 0
+ @selected--
+ child = @$el.children().eq @selected
+ container = jQuery('.navigator-results')
+ top = child.position().top
+ if top < 0
+ container.scrollTop(container.scrollTop() + top)
+ @selectIssue child, true
\ No newline at end of file
initialize: function() {
var openIssue = function(el) { el.click(); };
- this.openIssue = _.debounce(openIssue, 300);
+ this.openRule = _.debounce(openIssue, 300);
},
this.$('.active').removeClass('active');
el.addClass('active');
if (open) {
- this.openIssue(el);
+ this.openRule(el);
}
},