# # Marionette.js Item View Documentation # https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.itemview.md # @Character.Generic.ListHeaderView = Backbone.Marionette.ItemView.extend template: -> "
" ui: title: '#list_title' search: '#list_search' searchInput: '#list_search input' searchShow: '#list_search_show' newAction: '#new' events: 'click #list_search_hide': '_hideSearch' 'click #list_search_show': '_showSearch' 'keyup #list_search input': '_onKeyup' 'click #list_title': '_toggleScopesMenu' _toggleScopesMenu: -> if @ui.scopes @ui.scopes.toggleClass 'show' _onKeyup: (e) -> if @searchTypeTimeout clearTimeout(@searchTypeTimeout) return @toggleSearchBar() if e.keyCode == 27 query = @ui.searchInput.val() search = => @collection.setSearchQuery(query).fetchPage(1) if e.keyCode == 13 search() else @searchTypeTimeout = setTimeout(search, 800) _showSearch: -> @ui.search.addClass('active') @ui.searchInput.focus() false _hideSearch: -> @ui.search.removeClass('active') @ui.searchInput.val('') @collection.setSearchQuery() @collection.fetchPage(1) false _addScopesDropdown: -> if @scopes and _(@scopes).keys().length > 0 if not @ui.scopes @ui.scopes = $('