wisemapping-open-source/mindplot/src/main/javascript/widget/ToolbarItem.js

70 lines
2.1 KiB
JavaScript
Raw Normal View History

2011-08-09 01:48:59 +02:00
/*
* Copyright [2011] [wisemapping]
*
* 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({
Implements:[Events],
2011-10-04 06:16:29 +02:00
initialize : function(buttonId, fn, options) {
2011-08-09 01:48:59 +02:00
$assert(buttonId, "buttonId can not be null");
2011-10-04 06:16:29 +02:00
$assert(fn, "fn can not be null");
2011-08-09 01:48:59 +02:00
this._buttonId = buttonId;
2011-10-04 06:16:29 +02:00
this._fn = fn;
this._options = options;
2011-08-09 01:48:59 +02:00
},
getButtonElem : function() {
var elem = $(this._buttonId);
2011-08-11 04:13:13 +02:00
$assert(elem, "Could not find element for " + this._buttonId);
2011-08-09 01:48:59 +02:00
return elem;
}.protect(),
2011-08-11 04:13:13 +02:00
show : function() {
2011-10-04 06:16:29 +02:00
this.fireEvent('show');
2011-08-09 01:48:59 +02:00
},
hide : function() {
2011-10-04 06:16:29 +02:00
this.fireEvent('hide');
2011-08-11 04:13:13 +02:00
},
2011-10-04 06:16:29 +02:00
isTopicAction : function() {
return this._options.topicAction;
2011-08-11 04:13:13 +02:00
},
2011-10-04 06:16:29 +02:00
isRelAction : function() {
return this._options.relAction;
},
2011-08-11 04:13:13 +02:00
2011-10-04 06:16:29 +02:00
disable : function() {
var elem = this.getButtonElem();
if (this._enable) {
elem.removeEvent('click', this._fn);
elem.removeClass('buttonOn');
elem.addClass('buttonOff');
this._enable = false;
}
},
enable : function() {
var elem = this.getButtonElem();
if (!this._enable) {
elem.addEvent('click', this._fn);
elem.removeClass('buttonOff');
elem.addClass('buttonOn');
this._enable = true;
}
}
2011-08-09 01:48:59 +02:00
});