mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
adding Events mootool class
This commit is contained in:
parent
1da6082906
commit
3309777327
@ -124,6 +124,7 @@
|
|||||||
<inputDir>${basedir}/target/compress</inputDir>
|
<inputDir>${basedir}/target/compress</inputDir>
|
||||||
<includes>
|
<includes>
|
||||||
<include>header.js</include>
|
<include>header.js</include>
|
||||||
|
<include>Events.js</include>
|
||||||
<include>${basedir}/../web2d/target/classes/web2d.svg-min.js</include>
|
<include>${basedir}/../web2d/target/classes/web2d.svg-min.js</include>
|
||||||
<include>Messages.js</include>
|
<include>Messages.js</include>
|
||||||
<include>TopicEventDispatcher.js</include>
|
<include>TopicEventDispatcher.js</include>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.Designer = new Class({
|
mindplot.Designer = new Class({
|
||||||
Extends:Events,
|
Extends: mindplot.Events,
|
||||||
initialize:function (options, divElement) {
|
initialize:function (options, divElement) {
|
||||||
$assert(options, "options must be defined");
|
$assert(options, "options must be defined");
|
||||||
$assert(options.zoom, "zoom must be defined");
|
$assert(options.zoom, "zoom must be defined");
|
||||||
|
63
mindplot/src/main/javascript/Events.js
Normal file
63
mindplot/src/main/javascript/Events.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
mindplot.Events = new Class({
|
||||||
|
|
||||||
|
$events: {},
|
||||||
|
|
||||||
|
_removeOn: function(string){
|
||||||
|
return string.replace(/^on([A-Z])/, function(full, first){
|
||||||
|
return first.toLowerCase();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
addEvent: function(type, fn, internal){
|
||||||
|
type = this._removeOn(type);
|
||||||
|
|
||||||
|
this.$events[type] = (this.$events[type] || []).include(fn);
|
||||||
|
if (internal) fn.internal = true;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
addEvents: function(events){
|
||||||
|
for (var type in events) this.addEvent(type, events[type]);
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
fireEvent: function(type, args, delay){
|
||||||
|
type = this._removeOn(type);
|
||||||
|
var events = this.$events[type];
|
||||||
|
if (!events) return this;
|
||||||
|
args = Array.from(args);
|
||||||
|
events.each(function(fn){
|
||||||
|
if (delay) fn.delay(delay, this, args);
|
||||||
|
else fn.apply(this, args);
|
||||||
|
}, this);
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeEvent: function(type, fn){
|
||||||
|
type = this._removeOn(type);
|
||||||
|
var events = this.$events[type];
|
||||||
|
if (events && !fn.internal){
|
||||||
|
var index = events.indexOf(fn);
|
||||||
|
if (index != -1) delete events[index];
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeEvents: function(events){
|
||||||
|
var type;
|
||||||
|
if (typeOf(events) == 'object'){
|
||||||
|
for (type in events) this.removeEvent(type, events[type]);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if (events) events = removeOn(events);
|
||||||
|
for (type in this.$events){
|
||||||
|
if (events && events != type) continue;
|
||||||
|
var fns = this.$events[type];
|
||||||
|
for (var i = fns.length; i--;) if (i in fns){
|
||||||
|
this.removeEvent(type, fns[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.MultilineTextEditor = new Class({
|
mindplot.MultilineTextEditor = new Class({
|
||||||
Extends:Events,
|
Extends: mindplot.Events,
|
||||||
initialize:function () {
|
initialize:function () {
|
||||||
this._topic = null;
|
this._topic = null;
|
||||||
this._timeoutId = -1;
|
this._timeoutId = -1;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.TopicEventDispatcher = new Class({
|
mindplot.TopicEventDispatcher = new Class({
|
||||||
Extends: Events,
|
Extends: mindplot.Events,
|
||||||
Static: {
|
Static: {
|
||||||
_instance: null,
|
_instance: null,
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.layout.LayoutManager = new Class({
|
mindplot.layout.LayoutManager = new Class({
|
||||||
Extends: Events,
|
Extends: mindplot.Events,
|
||||||
initialize: function(rootNodeId, rootSize) {
|
initialize: function(rootNodeId, rootSize) {
|
||||||
$assert($defined(rootNodeId), "rootNodeId can not be null");
|
$assert($defined(rootNodeId), "rootNodeId can not be null");
|
||||||
$assert(rootSize, "rootSize can not be null");
|
$assert(rootSize, "rootSize can not be null");
|
||||||
|
Loading…
Reference in New Issue
Block a user