123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- if (!dojo._hasResource["dijit._tree.dndContainer"]) { // _hasResource checks
- // added by build. Do
- // not use _hasResource
- // directly in your
- // code.
- dojo._hasResource["dijit._tree.dndContainer"] = true;
- dojo.provide("dijit._tree.dndContainer");
- dojo.require("dojo.dnd.common");
- dojo.require("dojo.dnd.Container");
- dojo.declare("dijit._tree.dndContainer", null, {
- constructor : function(tree, params) {
- // summary: a constructor of the Container
- // tree: Node: node or node's id to build the container on
- // params: Object: a dict of parameters, which gets mixed into the
- // object
- this.tree = tree;
- this.node = tree.domNode;
- dojo.mixin(this, params);
- // class-specific variables
- this.map = {};
- this.current = null;
- // states
- this.ContainerState = "";
- dojo.addClass(this.node, "dojoDndContainer");
- // mark up children
- if (!(params && params._skipStartup)) {
- this.startup();
- }
- // set up events
- this.events = [
- dojo.connect(this.node, "onmouseover", this, "onMouseOver"),
- dojo.connect(this.node, "onmouseout", this, "onMouseOut"),
- // cancel text selection and text dragging
- dojo.connect(this.node, "ondragstart", dojo, "stopEvent"),
- dojo.connect(this.node, "onselectstart", dojo, "stopEvent")];
- },
- // abstract access to the map
- getItem : function(/* String */key) {
- // summary: returns a data item by its key (id)
- // console.log("Container getItem()", arguments,this.map,
- // this.map[key], this.selection[key]);
- return this.selection[key];
- // return this.map[key]; // Object
- },
- // mouse events
- onMouseOver : function(e) {
- // summary: event processor for onmouseover
- // e: Event: mouse event
- var n = e.relatedTarget;
- while (n) {
- if (n == this.node) {
- break;
- }
- try {
- n = n.parentNode;
- } catch (x) {
- n = null;
- }
- }
- if (!n) {
- this._changeState("Container", "Over");
- this.onOverEvent();
- }
- n = this._getChildByEvent(e);
- if (this.current == n) {
- return;
- }
- if (this.current) {
- this._removeItemClass(this.current, "Over");
- }
- if (n) {
- this._addItemClass(n, "Over");
- }
- this.current = n;
- },
- onMouseOut : function(e) {
- // summary: event processor for onmouseout
- // e: Event: mouse event
- for (var n = e.relatedTarget; n;) {
- if (n == this.node) {
- return;
- }
- try {
- n = n.parentNode;
- } catch (x) {
- n = null;
- }
- }
- if (this.current) {
- this._removeItemClass(this.current, "Over");
- this.current = null;
- }
- this._changeState("Container", "");
- this.onOutEvent();
- },
- _changeState : function(type, newState) {
- // summary: changes a named state to new state value
- // type: String: a name of the state to change
- // newState: String: new state
- var prefix = "dojoDnd" + type;
- var state = type.toLowerCase() + "State";
- // dojo.replaceClass(this.node, prefix + newState, prefix +
- // this[state]);
- dojo.removeClass(this.node, prefix + this[state]);
- dojo.addClass(this.node, prefix + newState);
- this[state] = newState;
- },
- _getChildByEvent : function(e) {
- // summary: gets a child, which is under the mouse at the moment, or
- // null
- // e: Event: a mouse event
- var node = e.target;
- if (node && dojo.hasClass(node, "dijitTreeLabel")) {
- return node;
- }
- return null;
- },
- markupFactory : function(tree, params) {
- params._skipStartup = true;
- return new dijit._tree.dndContainer(tree, params);
- },
- _addItemClass : function(node, type) {
- // summary: adds a class with prefix "dojoDndItem"
- // node: Node: a node
- // type: String: a variable suffix for a class name
- dojo.addClass(node, "dojoDndItem" + type);
- },
- _removeItemClass : function(node, type) {
- // summary: removes a class with prefix "dojoDndItem"
- // node: Node: a node
- // type: String: a variable suffix for a class name
- dojo.removeClass(node, "dojoDndItem" + type);
- },
- onOverEvent : function() {
- // summary: this function is called once, when mouse is over our
- // container
- console.log("onOverEvent parent");
- },
- onOutEvent : function() {
- // summary: this function is called once, when mouse is out of our
- // container
- }
- });
- }
|