2011-08-08 20:48:59 -03:00
|
|
|
/*
|
2012-10-04 20:48:01 -03:00
|
|
|
* Copyright [2012] [wisemapping]
|
2011-08-08 20:48:59 -03:00
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mindplot.widget.ToolbarItem = new Class({
|
2014-03-16 22:00:04 -03:00
|
|
|
Implements: mindplot.Events, //FIXME: should be extends?
|
2011-10-04 01:16:29 -03:00
|
|
|
initialize : function(buttonId, fn, options) {
|
2011-08-08 20:48:59 -03:00
|
|
|
$assert(buttonId, "buttonId can not be null");
|
2011-10-04 01:16:29 -03:00
|
|
|
$assert(fn, "fn can not be null");
|
2011-08-08 20:48:59 -03:00
|
|
|
this._buttonId = buttonId;
|
2011-10-04 01:16:29 -03:00
|
|
|
this._fn = fn;
|
|
|
|
this._options = options;
|
2011-10-14 22:56:20 -03:00
|
|
|
this._enable = false;
|
2011-10-10 18:30:02 -03:00
|
|
|
this.enable();
|
2011-08-08 20:48:59 -03:00
|
|
|
},
|
|
|
|
|
|
|
|
getButtonElem : function() {
|
2014-03-04 23:09:39 -03:00
|
|
|
var elem = $('#'+this._buttonId);
|
2011-08-10 23:13:13 -03:00
|
|
|
$assert(elem, "Could not find element for " + this._buttonId);
|
2011-08-08 20:48:59 -03:00
|
|
|
return elem;
|
|
|
|
}.protect(),
|
|
|
|
|
2011-08-10 23:13:13 -03:00
|
|
|
show : function() {
|
2011-10-04 01:16:29 -03:00
|
|
|
this.fireEvent('show');
|
2011-08-08 20:48:59 -03:00
|
|
|
},
|
|
|
|
|
|
|
|
hide : function() {
|
2011-10-04 01:16:29 -03:00
|
|
|
this.fireEvent('hide');
|
2011-08-10 23:13:13 -03:00
|
|
|
},
|
|
|
|
|
2011-10-04 01:16:29 -03:00
|
|
|
isTopicAction : function() {
|
|
|
|
return this._options.topicAction;
|
2011-08-10 23:13:13 -03:00
|
|
|
},
|
|
|
|
|
2011-10-04 01:16:29 -03:00
|
|
|
isRelAction : function() {
|
|
|
|
return this._options.relAction;
|
|
|
|
},
|
2011-08-10 23:13:13 -03:00
|
|
|
|
2011-10-04 01:16:29 -03:00
|
|
|
disable : function() {
|
|
|
|
var elem = this.getButtonElem();
|
|
|
|
if (this._enable) {
|
2014-03-04 23:09:39 -03:00
|
|
|
elem.unbind('click', this._fn);
|
2011-10-04 01:16:29 -03:00
|
|
|
elem.removeClass('buttonOn');
|
|
|
|
elem.addClass('buttonOff');
|
|
|
|
this._enable = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
enable : function() {
|
|
|
|
var elem = this.getButtonElem();
|
|
|
|
if (!this._enable) {
|
2014-03-04 23:09:39 -03:00
|
|
|
elem.bind('click', this._fn);
|
2011-10-04 01:16:29 -03:00
|
|
|
elem.removeClass('buttonOff');
|
|
|
|
elem.addClass('buttonOn');
|
|
|
|
this._enable = true;
|
|
|
|
}
|
2011-10-10 18:30:02 -03:00
|
|
|
},
|
|
|
|
|
|
|
|
getTip : function() {
|
|
|
|
return this._tip;
|
|
|
|
}.protect()
|
2011-08-08 20:48:59 -03:00
|
|
|
});
|