Pman.Tab.BuilderTree.bjs
authorAlan Knowles <alan@akbkhome.com>
Tue, 25 Oct 2011 07:34:15 +0000 (15:34 +0800)
committerAlan Knowles <alan@akbkhome.com>
Tue, 25 Oct 2011 07:34:15 +0000 (15:34 +0800)
Pman.Tab.BuilderTree.bjs
Pman.Tab.BuilderTree.js
Pman.Tab.BuilderTree.js

Pman.Tab.BuilderTree.bjs
Pman.Tab.BuilderTree.js

index 5af7f17..0928381 100644 (file)
@@ -37,7 +37,7 @@
                             "items": [
                                 {
                                     "listeners": {
-                                        "beforenodedrop": "function (e)\n{\n    // nodedragover handles the allow/disallow..\n    \n    /*\n    tree - The TreePanel\n    target - The node being targeted for the drop\n    data - The drag data from the drag source\n    point - The point of the drop - append, above or below\n    source - The drag source\n    rawEvent - Raw mouse event\n    dropNode - Drop node(s) provided by the source OR you can supply node(s) to be inserted by setting them on this object.\n    cancel - Set this to true to cancel the drop.\n    */\n    var np = e.point == 'append' ? e.target : e.target.parentNode ; // new parent\n      \n    if (!e.tree || !e.dropNode) {\n    \n        // form palete...\n        var data  = e.source.dragData.selections[0].data;\n\n        var xar = data.name.split('.');\n\n        var cfg = {\n            'xtype' : xar.pop(),\n            '|xns' : xar.join('.')\n            \n        };\n        if (_this.dragProp.length > 1) {\n            cfg['*prop'] = _this.dragProp;\n        }\n        // at this point it should of a set of options...\n         var cls = cfg['|ns'] + '.' + cfg['xtype'];\n            \n\n        if (typeof(Pman.Builder[cls]) != 'undefined') {\n            Pman.Dialog.BuilderAdd.show( cfg , function(fdata ) {\n\n            \n                this.appendNode(e.target, fdata , e.point);\n\n             })\n             return;\n         }\n         this.appendNode(e.target, cfg, e.point);\n          Pman.Tab.BuilderView.panel.redraw();\n         \n        return; // fixme drop of elements from palete..\n    }\n\n    // always drop onto own parent\n    if (np == e.dropNode.parentNode) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = this.dupeNode(e.dropNode);\n        }\n        return true;\n    }\n    // can append has to use palete...\n    // this code should be in nodedragover.\n    \n    Roo.log(\"move checks need moving\");\n    return;\n    \n    if (_this.canAppend(np, e.dropNode.elConfig)) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = _this.dupeNode(e.dropNode);\n              \n            if (np.elConfig.xtype == 'GridEditor') {\n                e.dropNode.elConfig['*prop'] = 'field';\n            }\n            \n        }\n        return true;\n    }  \n    Roo.log('can not drop ' + e.dropNode.elConfig.xtype + ' ontop of ' + np.elConfig.xtype);\n    \n    \n    \n    return false;\n                        \n\n}",
+                                        "beforenodedrop": "function (e)\n{\n    // nodedragover handles the allow/disallow..\n    \n    /*\n    tree - The TreePanel\n    target - The node being targeted for the drop\n    data - The drag data from the drag source\n    point - The point of the drop - append, above or below\n    source - The drag source\n    rawEvent - Raw mouse event\n    dropNode - Drop node(s) provided by the source OR you can supply node(s) to be inserted by setting them on this object.\n    cancel - Set this to true to cancel the drop.\n    */\n    var np = e.point == 'append' ? e.target : e.target.parentNode ; // new parent\n      \n    if (!e.tree || !e.dropNode) {\n    \n        // form palete...\n        var data  = e.source.dragData.selections[0].data;\n\n        var xar = data.name.split('.');\n\n        var cfg = {\n            'xtype' : xar.pop(),\n            '|xns' : xar.join('.')\n            \n        };\n        if (_this.dragProp.length > 1) {\n            cfg['*prop'] = _this.dragProp;\n        }\n        // at this point it should of a set of options...\n         var cls = cfg['|ns'] + '.' + cfg['xtype'];\n            \n\n        if (typeof(Pman.Builder[cls]) != 'undefined') {\n            Pman.Dialog.BuilderAdd.show( cfg , function(fdata ) {\n\n            \n                this.appendNode(e.target, fdata , e.point);\n\n             });\n             return;\n         }\n         this.appendNode(e.target, cfg, e.point);\n          Pman.Tab.BuilderView.panel.redraw();\n         \n        return; // fixme drop of elements from palete..\n    }\n\n    // always drop onto own parent\n    if (np == e.dropNode.parentNode) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = this.dupeNode(e.dropNode);\n        }\n        return true;\n    }\n    // can append has to use palete...\n    // this code should be in nodedragover.\n    \n    Roo.log(\"move checks need moving\");\n    return;\n    \n    if (_this.canAppend(np, e.dropNode.elConfig)) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = _this.dupeNode(e.dropNode);\n              \n            if (np.elConfig.xtype == 'GridEditor') {\n                e.dropNode.elConfig['*prop'] = 'field';\n            }\n            \n        }\n        return true;\n    }  \n    Roo.log('can not drop ' + e.dropNode.elConfig.xtype + ' ontop of ' + np.elConfig.xtype);\n    \n    \n    \n    return false;\n                        \n\n}",
                                         "click": "function (node, e)\n{\n      e.preventDefault();\n                       // console.log(e.button);\n        this.setCurrentNode(node);\n        \n    \n        \n\n}",
                                         "contextmenu": "function (node, e)\n{\n    e.stopEvent();\n        \n        this.getSelectionModel().select(node);\n         this.setCurrentNode(node);\n         \n              _this.menu = Roo.factory(_this.menu);\n    \n            _this.menu.show(node.ui.textNode, 'tr');\n         return;\n        var xt = node.elConfig.xtype;\n        var altx= false;\n        if (typeof(node.elConfig['*prop']) != 'undefined') {\n            altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];\n        }\n        var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);\n        \n        \n        if (mn) {\n            mn.show(e.getTarget());\n        }\n        \n\n\n}",
                                         "nodedragover": "function (e)\n{\n    Roo.log('nodedragover');\n     Roo.log(e);\n     // e.cancel..\n     // if we have within the same tree:\n       // dropNode (the node being dragged !!important!!) \n       // point: below, append\n       // target - node \n    // for palete\n        // dropNode = false;\n        // grid = the grid...\n        // source.dragData.selections[..] \n   \n    \n    // we can only check parents... (we in theory can check dupe properties.. but let's ignore that for the time being.)\n    \n    // ok off we go.\n    \n    if (!e.dropNode) {\n        // drag from palete..\n        if (!e.source.dragData.selections.length) {\n            e.cancel = true;\n            return;\n        }\n        var drop_rec = e.source.dragData.selections[0];\n        var drop_xtype = drop_rec.data.name;\n        var ok_parents = drop_rec.json.parents;\n        \n        Roo.log(\"TEST PARENTS: \" + ok_parents.join(', '));\n        var new_parent = this.nodeXtype((e.point == 'append') ? e.target :  e.target.parentNode);\n        Roo.log(\"NEW PARENT: \" + e.point + \" = \" + new_parent);\n        \n        // see if the new_parent is actually in the list of ok_parents\n        e.cancel = true;\n        _this.dragProp = '';\n        \n        Roo.each(ok_parents, function(n) {\n            if (n == new_parent || n.split(':').shift() == new_parent) {\n                Roo.log(\"got match!\");\n                e.cancel = false;\n                _this.dragProp = (n == new_parent) ?  '' : n.split(':').pop();\n                return true;\n            }\n        });\n\n        // done all the checks...\n        return;\n        \n    }\n     \n   \n}   \n    "
index cb653cf..a7f0e96 100644 (file)
@@ -105,7 +105,7 @@ Pman.Tab.BuilderTree = new Roo.util.Observable({
                                             
                                                 this.appendNode(e.target, fdata , e.point);
                                 
-                                             })
+                                             });
                                              return;
                                          }
                                          this.appendNode(e.target, cfg, e.point);