2013-06-22 09:24:24 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Config'
|
|
|
|
], function (Marionette, Config) {
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
return Marionette.ItemView.extend({
|
|
|
|
template : 'Shared/Toolbar/ButtonTemplate',
|
|
|
|
className: 'btn',
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
events: {
|
|
|
|
'click': 'onClick'
|
|
|
|
},
|
2013-04-26 07:45:45 +03:00
|
|
|
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
initialize: function () {
|
2013-04-26 09:00:55 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
|
|
|
},
|
2013-04-26 09:00:55 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
onRender: function () {
|
|
|
|
if (this.model.get('active')) {
|
|
|
|
this.$el.addClass('active');
|
|
|
|
this.invokeCallback();
|
|
|
|
}
|
2013-06-29 02:19:00 +03:00
|
|
|
|
|
|
|
if(!this.model.get('title')){
|
|
|
|
this.$el.addClass('btn-icon-only');
|
|
|
|
}
|
2013-07-25 08:20:28 +03:00
|
|
|
|
|
|
|
if (this.model.get('tooltip')) {
|
2013-07-31 09:25:29 +03:00
|
|
|
this.$el.attr('title', this.model.get('tooltip'));
|
|
|
|
this.$el.attr('data-container', 'body');
|
2013-07-25 08:20:28 +03:00
|
|
|
}
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
onClick: function () {
|
2013-04-26 09:00:55 +03:00
|
|
|
|
2013-08-04 04:27:12 +03:00
|
|
|
Config.setValue(this.model.get('menuKey'), this.model.get('key'));
|
2013-06-25 02:41:59 +03:00
|
|
|
this.invokeCallback();
|
|
|
|
},
|
2013-04-26 09:00:55 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
invokeCallback: function () {
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
if (!this.model.ownerContext) {
|
|
|
|
throw 'ownerContext must be set.';
|
|
|
|
}
|
2013-04-26 07:45:45 +03:00
|
|
|
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
var callback = this.model.get('callback');
|
|
|
|
if (callback) {
|
|
|
|
callback.call(this.model.ownerContext);
|
|
|
|
}
|
2013-04-26 07:45:45 +03:00
|
|
|
}
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
});
|
2013-04-26 07:45:45 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|