mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-12 11:01:11 +00:00
51 lines
No EOL
1.1 KiB
JavaScript
51 lines
No EOL
1.1 KiB
JavaScript
define( [
|
|
'jquery',
|
|
'backbone',
|
|
'text!views/templates/menu.html',
|
|
'bus',
|
|
'models/menu-model'
|
|
],
|
|
function ( $, Backbone, template, bus, MenuModel ) {
|
|
"use strict";
|
|
|
|
return Backbone.View.extend( {
|
|
el : "#menu",
|
|
|
|
events : {
|
|
"click #btnSearch" : "updateSearch"
|
|
},
|
|
|
|
initialize : function () {
|
|
_.bindAll( this );
|
|
this.template = _.template( template );
|
|
this.model = new MenuModel();
|
|
this.model.bind( "change", this.updateView );
|
|
},
|
|
|
|
render : function () {
|
|
this.$el.html( this.template( this.model.toJSON() ) );
|
|
},
|
|
|
|
show : function ( data ) {
|
|
this.$el.show();
|
|
},
|
|
|
|
updateSearch : function () {
|
|
var searchTerm = this.$el.find( '#searchTerm' ).val();
|
|
if ( searchTerm ) {
|
|
bus.app.publish( {
|
|
topic : "search.new.request",
|
|
data : {
|
|
searchTerm : searchTerm
|
|
}
|
|
} );
|
|
}
|
|
},
|
|
|
|
updateView : function () {
|
|
this.$el.find( "#currentSearch" ).text( this.model.get( "searchTerm" ) );
|
|
this.$el.find( "#search-ownership" ).text( this.model.get( "searchOwnership" ) );
|
|
this.$el.find( "#request-indicator" ).text( this.model.get( "requests" ) ? " *" : "" );
|
|
}
|
|
} );
|
|
} ); |