Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2012 IBM |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | window.HeaderView = Backbone.View.extend({ |
| 18 | |
| 19 | initialize:function () { |
| 20 | this.template = _.template(tpl.get('header')); |
| 21 | // this.searchResults = new HostCollection(); |
| 22 | // this.searchresultsView = new SearchListView({model:this.searchResults, className:'dropdown-menu'}); |
| 23 | }, |
| 24 | |
| 25 | render:function (eventName) { |
| 26 | $(this.el).html(this.template()); |
| 27 | // $('.navbar-search', this.el).append(this.searchresultsView.render().el); |
| 28 | return this; |
| 29 | }, |
| 30 | |
| 31 | events:{ |
| 32 | "keyup .search-query":"search" |
| 33 | }, |
| 34 | |
| 35 | search:function (event) { |
| 36 | // var key = event.target.value; |
| 37 | var key = $('#searchText').val(); |
| 38 | console.log('search ' + key); |
| 39 | // TODO search the host and switch lists |
| 40 | this.searchResults.findByName(key); |
| 41 | setTimeout(function () { |
| 42 | $('#searchForm').addClass('open'); |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | }); |