2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-24 23:41:59 +00:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Config'
|
|
|
|
], function (Marionette, Config) {
|
2013-04-26 04:45:45 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
return Marionette.ItemView.extend({
|
|
|
|
template : 'Shared/Toolbar/ButtonTemplate',
|
|
|
|
className: 'btn',
|
2013-04-26 04:45:45 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
events: {
|
|
|
|
'click': 'onClick'
|
|
|
|
},
|
2013-04-26 04:45:45 +00:00
|
|
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
initialize: function () {
|
2013-04-26 06:00:55 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
|
|
|
},
|
2013-04-26 06:00:55 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
onRender: function () {
|
|
|
|
if (this.model.get('active')) {
|
|
|
|
this.$el.addClass('active');
|
|
|
|
this.invokeCallback();
|
|
|
|
}
|
2013-06-28 23:19:00 +00:00
|
|
|
|
|
|
|
if(!this.model.get('title')){
|
|
|
|
this.$el.addClass('btn-icon-only');
|
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
},
|
2013-04-26 04:45:45 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
onClick: function () {
|
2013-04-26 06:00:55 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
|
|
|
this.invokeCallback();
|
|
|
|
},
|
2013-04-26 06:00:55 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
invokeCallback: function () {
|
2013-04-26 04:45:45 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (!this.model.ownerContext) {
|
|
|
|
throw 'ownerContext must be set.';
|
|
|
|
}
|
2013-04-26 04:45:45 +00:00
|
|
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
var callback = this.model.get('callback');
|
|
|
|
if (callback) {
|
|
|
|
callback.call(this.model.ownerContext);
|
|
|
|
}
|
2013-04-26 04:45:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
});
|
2013-04-26 04:45:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|