summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/ajax.js194
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/context-menu.js444
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/drag-drop-folder-tree.js1059
3 files changed, 1697 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/ajax.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/ajax.js
new file mode 100644
index 00000000..a727447d
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/ajax.js
@@ -0,0 +1,194 @@
+/* Simple AJAX Code-Kit (SACK) v1.6.1 */
+/* ©2005 Gregory Wild-Smith */
+/* www.twilightuniverse.com */
+/* Software licenced under a modified X11 licence,
+ see documentation or authors website for more details */
+
+function sack(file) {
+ this.xmlhttp = null;
+ this.resetData = function() {
+ this.method = "POST";
+ this.queryStringSeparator = "?";
+ this.argumentSeparator = "&";
+ this.URLString = "";
+ this.encodeURIString = true;
+ this.execute = false;
+ this.element = null;
+ this.elementObj = null;
+ this.requestFile = file;
+ this.vars = new Object();
+ this.responseStatus = new Array(2);
+ };
+
+ this.resetFunctions = function() {
+ this.onLoading = function() { };
+ this.onLoaded = function() { };
+ this.onInteractive = function() { };
+ this.onCompletion = function() { };
+ this.onError = function() { };
+ this.onFail = function() { };
+ };
+
+ this.reset = function() {
+ this.resetFunctions();
+ this.resetData();
+ };
+
+ this.createAJAX = function() {
+ try {
+ this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e1) {
+ try {
+ this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e2) {
+ this.xmlhttp = null;
+ }
+ }
+
+ if (! this.xmlhttp) {
+ if (typeof XMLHttpRequest != "undefined") {
+ this.xmlhttp = new XMLHttpRequest();
+ } else {
+ this.failed = true;
+ }
+ }
+ };
+
+ this.setVar = function(name, value){
+ this.vars[name] = Array(value, false);
+ };
+
+ this.encVar = function(name, value, returnvars) {
+ if (true == returnvars) {
+ return Array(encodeURIComponent(name), encodeURIComponent(value));
+ } else {
+ this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
+ }
+ }
+
+ this.processURLString = function(string, encode) {
+ encoded = encodeURIComponent(this.argumentSeparator);
+ regexp = new RegExp(this.argumentSeparator + "|" + encoded);
+ varArray = string.split(regexp);
+ for (i = 0; i < varArray.length; i++){
+ urlVars = varArray[i].split("=");
+ if (true == encode){
+ this.encVar(urlVars[0], urlVars[1]);
+ } else {
+ this.setVar(urlVars[0], urlVars[1]);
+ }
+ }
+ }
+
+ this.createURLString = function(urlstring) {
+ if (this.encodeURIString && this.URLString.length) {
+ this.processURLString(this.URLString, true);
+ }
+ if (urlstring) {
+ if (this.URLString.length) {
+ this.URLString += this.argumentSeparator + urlstring;
+ } else {
+ this.URLString = urlstring;
+ }
+ }
+
+ // prevents caching of URLString
+ this.setVar("rndval", new Date().getTime());
+
+ urlstringtemp = new Array();
+ for (key in this.vars) {
+ if (false == this.vars[key][1] && true == this.encodeURIString) {
+ encoded = this.encVar(key, this.vars[key][0], true);
+ delete this.vars[key];
+ this.vars[encoded[0]] = Array(encoded[1], true);
+ key = encoded[0];
+ }
+
+ urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
+ }
+ if (urlstring){
+ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
+ } else {
+ this.URLString += urlstringtemp.join(this.argumentSeparator);
+ }
+ }
+
+ this.runResponse = function() {
+ eval(this.response);
+ }
+
+ this.runAJAX = function(urlstring) {
+ if (this.failed) {
+ this.onFail();
+ } else {
+ this.createURLString(urlstring);
+
+ if (this.element) {
+ this.elementObj = document.getElementById(this.element);
+ }
+
+ if (this.xmlhttp) {
+ var self = this;
+ if (this.method == "GET") {
+ totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
+ this.xmlhttp.open(this.method, totalurlstring, true);
+ } else {
+ this.xmlhttp.open(this.method, this.requestFile, true);
+ try {
+ this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ } catch (e) { }
+ }
+ //document.myForm.action=urlstring;
+ //document.myForm.submit();
+ this.xmlhttp.onreadystatechange = function() {
+ switch (self.xmlhttp.readyState) {
+ case 1:
+ self.onLoading();
+ break;
+ case 2:
+ self.onLoaded();
+ break;
+ case 3:
+ self.onInteractive();
+ break;
+ case 4:
+ self.response = self.xmlhttp.responseText;
+ self.responseXML = self.xmlhttp.responseXML;
+ self.responseStatus[0] = self.xmlhttp.status;
+ self.responseStatus[1] = self.xmlhttp.statusText;
+
+ if (self.execute) {
+ self.runResponse();
+ }
+
+ if (self.elementObj) {
+ elemNodeName = self.elementObj.nodeName;
+ elemNodeName.toLowerCase();
+ if (elemNodeName == "input"
+ || elemNodeName == "select"
+ || elemNodeName == "option"
+ || elemNodeName == "textarea") {
+ self.elementObj.value = self.response;
+ } else {
+ self.elementObj.innerHTML = self.response;
+ }
+ }
+ if (self.responseStatus[0] == "200") {
+ self.onCompletion();
+ } else {
+ self.onError();
+ }
+
+ self.URLString = "";
+ break;
+ }
+ };
+ this.xmlhttp.send(this.URLString);
+
+ }
+ }
+ };
+
+ this.reset() ;
+ this.createAJAX();
+}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/context-menu.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/context-menu.js
new file mode 100644
index 00000000..70fb7096
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/context-menu.js
@@ -0,0 +1,444 @@
+/************************************************************************************************************
+Context menu
+Copyright (C) 2006 DTHMLGoodies.com, Alf Magne Kalleland
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
+written by Alf Magne Kalleland.
+
+Alf Magne Kalleland, 2006
+Owner of DHTMLgoodies.com
+
+
+************************************************************************************************************/
+
+DHTMLGoodies_menuModel = function()
+{
+ var menuItems;
+ this.menuItems = new Array();
+
+
+}
+
+/************************************************************************************************************
+* DHTML menu model class
+*
+* Created: October, 30th, 2006
+* @class Purpose of class: Saves menu item data
+*
+*
+* Demos of this class: demo-menu-strip.html
+*
+* Update log:
+*
+************************************************************************************************************/
+
+
+/**
+* @constructor
+* @class Purpose of class: Organize menu items for different menu widgets. demos of menus: (<a href="../../demos/demo-menu-strip.html" target="_blank">Demo</a>)
+* @version 1.0
+* @author Alf Magne Kalleland(www.dhtmlgoodies.com)
+*/
+
+
+DHTMLGoodies_menuModel.prototype = {
+ // {{{ addItem()
+ /**
+ * Add separator (special type of menu item)
+ *
+ * @param int id of menu item
+ * @param string itemText = text of menu item
+ * @param string itemIcon = file name of menu icon(in front of menu text. Path will be imagePath for the DHTMLSuite + file name)
+ * @param string url = Url of menu item
+ * @param int parent id of menu item
+ * @param String jsFunction Name of javascript function to execute. It will replace the url param. The function with this name will be called and the element triggering the action will be
+ * sent as argument. Name of the element which triggered the menu action may also be sent as a second argument. That depends on the widget. The context menu is an example where
+ * the element triggering the context menu is sent as second argument to this function.
+ *
+ * @public
+ */
+ addItem : function(id,itemText,itemIcon,url,parentId,jsFunction)
+ {
+ this.menuItems[id] = new Array();
+ this.menuItems[id]['id'] = id;
+ this.menuItems[id]['itemText'] = itemText;
+ this.menuItems[id]['itemIcon'] = itemIcon;
+ this.menuItems[id]['url'] = url;
+ this.menuItems[id]['parentId'] = parentId;
+ this.menuItems[id]['separator'] = false;
+ this.menuItems[id]['jsFunction'] = jsFunction;
+
+ }
+ ,
+ // {{{ addSeparator()
+ /**
+ * Add separator (special type of menu item)
+ *
+ * @param int id of menu item
+ * @param int parent id of menu item
+ * @public
+ */
+ addSeparator : function(id,parentId)
+ {
+ this.menuItems[id] = new Array();
+ this.menuItems[id]['parentId'] = parentId;
+ this.menuItems[id]['separator'] = true;
+ }
+ ,
+ // {{{ init()
+ /**
+ * Initilizes the menu model. This method should be called when all items has been added to the model.
+ *
+ *
+ * @public
+ */
+ init : function()
+ {
+ this.__getDepths();
+
+ }
+ // }}}
+ ,
+ // {{{ __getDepths()
+ /**
+ * Create variable for the depth of each menu item.
+ *
+ *
+ * @private
+ */
+ getItems : function()
+ {
+ return this.menuItems;
+ }
+
+ ,
+ // {{{ __getDepths()
+ /**
+ * Create variable for the depth of each menu item.
+ *
+ *
+ * @private
+ */
+ __getDepths : function()
+ {
+ for(var no in this.menuItems){
+ this.menuItems[no]['depth'] = 1;
+ if(this.menuItems[no]['parentId']){
+ this.menuItems[no]['depth'] = this.menuItems[this.menuItems[no]['parentId']]['depth']+1;
+ }
+ }
+ }
+ ,
+ // {{{ __hasSubs()
+ /**
+ * Does a menu item have sub elements ?
+ *
+ *
+ * @private
+ */
+ // }}}
+ __hasSubs : function(id)
+ {
+ for(var no in this.menuItems){ // Looping through menu items
+ if(this.menuItems[no]['parentId']==id)return true;
+ }
+ return false;
+ }
+
+
+}
+
+
+
+var referenceToDHTMLSuiteContextMenu;
+
+
+DHTMLGoodies_contextMenu = function()
+{
+ var menuModels;
+ var menuItems;
+ var menuObject; // Reference to context menu div
+ var layoutCSS;
+ var menuUls; // Array of <ul> elements
+ var width; // Width of context menu
+ var srcElement; // Reference to the element which triggered the context menu, i.e. the element which caused the context menu to be displayed.
+ var indexCurrentlyDisplayedMenuModel; // Index of currently displayed menu model.
+ var imagePath;
+
+ this.menuModels = new Array();
+ this.menuObject = false;
+ this.menuUls = new Array();
+ this.width = 100;
+ this.srcElement = false;
+ this.indexCurrentlyDisplayedMenuModel = false;
+ this.imagePath = imgFolder+'tree/';
+
+}
+
+DHTMLGoodies_contextMenu.prototype =
+{
+
+ setWidth : function(newWidth)
+ {
+ this.width = newWidth;
+ }
+ // }}}
+ ,
+ // {{{ setLayoutCss()
+ /**
+ * Add menu items
+ *
+ * @param String cssFileName Name of css file
+ *
+ * @public
+ */
+ setLayoutCss : function(cssFileName)
+ {
+ this.layoutCSS = cssFileName;
+ }
+ // }}}
+ ,
+ // {{{ attachToElement()
+ /**
+ * Add menu items
+ *
+ * @param Object HTML Element = Reference to html element
+ * @param String elementId = String id of element(optional). An alternative to HTML Element
+ *
+ * @public
+ */
+ attachToElement : function(element,elementId,menuModel)
+ {
+ window.refToThisContextMenu = this;
+ if(!element && elementId)element = document.getElementById(elementId);
+ if(!element.id){
+ element.id = 'context_menu' + Math.random();
+ element.id = element.id.replace('.','');
+ }
+ this.menuModels[element.id] = menuModel;
+ element.oncontextmenu = this.__displayContextMenu;
+ //element.onmousedown = function() { window.refToThisContextMenu.__setReference(window.refToThisContextMenu); };
+ document.documentElement.onclick = this.__hideContextMenu;
+
+ }
+ // }}}
+ ,
+ // {{{ __setReference()
+ /**
+ * Creates a reference to current context menu object. (Note: This method should be deprecated as only one context menu object is needed)
+ *
+ * @param Object context menu object = Reference to context menu object
+ *
+ * @private
+ */
+ __setReference : function(obj)
+ {
+ referenceToDHTMLSuiteContextMenu = obj;
+ }
+ ,
+ // {{{ __displayContextMenu()
+ /**
+ * Displays the context menu
+ *
+ * @param Event e
+ *
+ * @private
+ */
+ __displayContextMenu : function(e)
+ {
+ if(document.all)e = event;
+ var ref = referenceToDHTMLSuiteContextMenu;
+ ref.srcElement = ref.getSrcElement(e);
+
+ if(!ref.indexCurrentlyDisplayedMenuModel || ref.indexCurrentlyDisplayedMenuModel!=this.id){
+ if(ref.indexCurrentlyDisplayedMenuModel){
+ ref.menuObject.innerHTML = '';
+ }else{
+ ref.__createDivs();
+ }
+ ref.menuItems = ref.menuModels[this.id].getItems();
+ ref.__createMenuItems();
+ }
+ ref.indexCurrentlyDisplayedMenuModel=this.id;
+
+ ref.menuObject.style.left = (e.clientX + Math.max(document.body.scrollLeft,document.documentElement.scrollLeft)) + 'px';
+ ref.menuObject.style.top = (e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop)) + 'px';
+ ref.menuObject.style.display='block';
+ return false;
+
+ }
+ // }}}
+ ,
+ // {{{ __displayContextMenu()
+ /**
+ * Add menu items
+ *
+ * @param Event e
+ *
+ * @private
+ */
+ __hideContextMenu : function()
+ {
+ var ref = referenceToDHTMLSuiteContextMenu;
+ if(ref.menuObject)ref.menuObject.style.display = 'none';
+
+
+ }
+ // }}}
+ ,
+ // {{{ __createDivs()
+ /**
+ * Creates general divs for the menu
+ *
+ *
+ * @private
+ */
+ __createDivs : function()
+ {
+ this.menuObject = document.createElement('DIV');
+ this.menuObject.className = 'DHTMLSuite_contextMenu';
+ this.menuObject.style.backgroundImage = 'url(\'' + this.imagePath + 'context-menu-gradient.gif' + '\')';
+ this.menuObject.style.backgroundRepeat = 'repeat-y';
+ if(this.width)this.menuObject.style.width = this.width + 'px';
+ document.body.appendChild(this.menuObject);
+ }
+ // }}}
+ ,
+
+ // {{{ __mouseOver()
+ /**
+ * Display mouse over effect when moving the mouse over a menu item
+ *
+ *
+ * @private
+ */
+ __mouseOver : function()
+ {
+ this.className = 'DHTMLSuite_item_mouseover';
+ if(!document.all){
+ this.style.backgroundPosition = 'left center';
+ }
+
+ }
+ // }}}
+ ,
+ // {{{ __mouseOut()
+ /**
+ * Remove mouse over effect when moving the mouse away from a menu item
+ *
+ *
+ * @private
+ */
+ __mouseOut : function()
+ {
+ this.className = '';
+ if(!document.all){
+ this.style.backgroundPosition = '1px center';
+ }
+ }
+ // }}}
+ ,
+ // {{{ __createMenuItems()
+ /**
+ * Create menu items
+ *
+ *
+ * @private
+ */
+ __evalUrl : function()
+ {
+ var js = this.getAttribute('jsFunction');
+ if(!js)js = this.jsFunction;
+ if(js)eval(js);
+
+ }
+ // }}}
+ ,
+ // {{{ __createMenuItems()
+ /**
+ * Create menu items
+ *
+ *
+ * @private
+ */
+ __createMenuItems : function()
+ {
+ window.refToContextMenu = this; // Reference to menu strip object
+ this.menuUls = new Array();
+ for(var no in this.menuItems){ // Looping through menu items
+ if(!this.menuUls[0]){ // Create main ul element
+ this.menuUls[0] = document.createElement('UL');
+ this.menuObject.appendChild(this.menuUls[0]);
+ }
+
+ if(this.menuItems[no]['depth']==1){
+
+ if(this.menuItems[no]['separator']){
+ var li = document.createElement('DIV');
+ li.className = 'DHTMLSuite_contextMenu_separator';
+ }else{
+ var li = document.createElement('LI');
+ if(this.menuItems[no]['jsFunction']){
+ this.menuItems[no]['url'] = this.menuItems[no]['jsFunction'] + '(this,referenceToDHTMLSuiteContextMenu.srcElement)';
+ }
+ if(this.menuItems[no]['itemIcon']){
+ li.style.backgroundImage = 'url(\'' + this.menuItems[no]['itemIcon'] + '\')';
+ if(!document.all)li.style.backgroundPosition = '1px center';
+
+ }
+
+ if(this.menuItems[no]['url']){
+ var url = this.menuItems[no]['url'] + '';
+ var tmpUrl = url + '';
+ li.setAttribute('jsFunction',url);
+ li.jsFunction = url;
+ li.onclick = this.__evalUrl;
+
+ }
+
+ li.innerHTML = '<a href="#" onclick="return false">' + this.menuItems[no]['itemText'] + '</a>';
+ li.onmouseover = this.__mouseOver;
+ li.onmouseout = this.__mouseOut;
+ }
+ this.menuUls[0].appendChild(li);
+ }
+ }
+ }
+
+ ,
+
+ // {{{ getSrcElement()
+ /**
+ *
+ * Returns a reference to the element which triggered an event.
+ * @param Event e = Event object
+ *
+ *
+ * @private
+ */
+ getSrcElement : function(e)
+ {
+ var el;
+ // Dropped on which element
+ if (e.target) el = e.target;
+ else if (e.srcElement) el = e.srcElement;
+ if (el.nodeType == 3) // defeat Safari bug
+ el = el.parentNode;
+ return el;
+ }
+
+} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/drag-drop-folder-tree.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/drag-drop-folder-tree.js
new file mode 100644
index 00000000..165306f2
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/static/fusion/raptor/js/tree/drag-drop-folder-tree.js
@@ -0,0 +1,1059 @@
+ /************************************************************************************************************
+Drag and drop folder tree
+Copyright (C) 2006 DTHMLGoodies.com, Alf Magne Kalleland
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
+written by Alf Magne Kalleland.
+
+Alf Magne Kalleland, 2006
+Owner of DHTMLgoodies.com
+
+
+************************************************************************************************************/
+
+ var JSTreeObj;
+ var treeUlCounter = 0;
+ var nodeId = 1;
+
+ /* Constructor */
+ function JSDragDropTree()
+ {
+ var idOfTree;
+ var imageFolder;
+ var folderImage;
+ var plusImage;
+ var minusImage;
+ var maximumDepth;
+ var dragNode_source;
+ var dragNode_parent;
+ var dragNode_sourceNextSib;
+ var dragNode_noSiblings;
+ var ajaxObjects;
+
+ var dragNode_destination;
+ var floatingContainer;
+ var dragDropTimer;
+ var dropTargetIndicator;
+ var insertAsSub;
+ var indicator_offsetX;
+ var indicator_offsetX_sub;
+ var indicator_offsetY;
+
+ this.imageFolder = imgFolder+'tree/';
+ this.folderImage = 'dhtmlgoodies_folder.gif';
+ this.plusImage = 'dhtmlgoodies_plus.gif';
+ this.minusImage = 'dhtmlgoodies_minus.gif';
+ this.maximumDepth = 6;
+ var messageMaximumDepthReached;
+ var messageNoRightsOnFolder;
+ var filePathRenameItem;
+ var filePathDeleteItem;
+ var additionalRenameRequestParameters = {};
+ var additionalDeleteRequestParameters = {};
+
+ var renameAllowed;
+ var deleteAllowed;
+ var addAllowed;
+ var currentlyActiveItem;
+ var contextMenu;
+ var currentItemToEdit; // Reference to item currently being edited(example: renamed)
+ var selectedItem; // ADDED BY FARHAN
+ var helpObj;
+
+ this.contextMenu = false;
+ this.floatingContainer = document.createElement('UL');
+ this.floatingContainer.style.position = 'absolute';
+ this.floatingContainer.style.display='none';
+ this.floatingContainer.id = 'floatingContainer';
+ this.insertAsSub = false;
+ document.body.appendChild(this.floatingContainer);
+ this.dragDropTimer = -1;
+ this.dragNode_noSiblings = false;
+ this.currentItemToEdit = false;
+
+ if(document.all){
+ this.indicator_offsetX = 2; // Offset position of small black lines indicating where nodes would be dropped.
+ this.indicator_offsetX_sub = 4;
+ this.indicator_offsetY = 2;
+ }else{
+ this.indicator_offsetX = 1; // Offset position of small black lines indicating where nodes would be dropped.
+ this.indicator_offsetX_sub = 3;
+ this.indicator_offsetY = 2;
+ }
+ if(navigator.userAgent.indexOf('Opera')>=0){
+ this.indicator_offsetX = 2; // Offset position of small black lines indicating where nodes would be dropped.
+ this.indicator_offsetX_sub = 3;
+ this.indicator_offsetY = -7;
+ }
+
+ this.messageMaximumDepthReached = ''; // Use '' if you don't want to display a message
+ this.messageNoRightsOnFolder = 'You do not have access to this folder';
+
+ this.renameAllowed = true;
+ this.deleteAllowed = true;
+ this.addAllowed = true;
+ this.currentlyActiveItem = false;
+ this.filePathRenameItem = 'folderTree_updateItem.php';
+ this.filePathDeleteItem = 'tree';
+ this.ajaxObjects = new Array();
+ this.helpObj = false;
+
+ this.RENAME_STATE_BEGIN = 1;
+ this.RENAME_STATE_CANCELED = 2;
+ this.RENAME_STATE_REQUEST_SENDED = 3;
+ this.renameState = null;
+ }
+
+
+ /* JSDragDropTree class */
+ JSDragDropTree.prototype = {
+ // {{{ addEvent()
+ /**
+ *
+ * This function adds an event listener to an element on the page.
+ *
+ * @param Object whichObject = Reference to HTML element(Which object to assigne the event)
+ * @param String eventType = Which type of event, example "mousemove" or "mouseup"
+ * @param functionName = Name of function to execute.
+ *
+ * @public
+ */
+ addEvent : function(whichObject,eventType,functionName)
+ {
+ if(whichObject.attachEvent){
+ whichObject['e'+eventType+functionName] = functionName;
+ whichObject[eventType+functionName] = function(){whichObject['e'+eventType+functionName]( window.event );}
+ whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName] );
+ } else
+ whichObject.addEventListener(eventType,functionName,false);
+ }
+ // }}}
+ ,
+ // {{{ removeEvent()
+ /**
+ *
+ * This function removes an event listener from an element on the page.
+ *
+ * @param Object whichObject = Reference to HTML element(Which object to assigne the event)
+ * @param String eventType = Which type of event, example "mousemove" or "mouseup"
+ * @param functionName = Name of function to execute.
+ *
+ * @public
+ */
+ removeEvent : function(whichObject,eventType,functionName)
+ {
+ if(whichObject.detachEvent){
+ whichObject.detachEvent('on'+eventType, whichObject[eventType+functionName]);
+ whichObject[eventType+functionName] = null;
+ } else
+ whichObject.removeEventListener(eventType,functionName,false);
+ }
+ ,
+ Get_Cookie : function(name) {
+ var start = document.cookie.indexOf(name+"=");
+ var len = start+name.length+1;
+ if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
+ if (start == -1) return null;
+ var end = document.cookie.indexOf(";",len);
+ if (end == -1) end = document.cookie.length;
+ return unescape(document.cookie.substring(len,end));
+ }
+ ,
+ // This function has been slightly modified
+ Set_Cookie : function(name,value,expires,path,domain,secure) {
+ expires = expires * 60*60*24*1000;
+ var today = new Date();
+ var expires_date = new Date( today.getTime() + (expires) );
+ var cookieString = name + "=" +escape(value) +
+ ( (expires) ? ";expires=" + expires_date.toGMTString() : "") +
+ ( (path) ? ";path=" + path : "") +
+ ( (domain) ? ";domain=" + domain : "") +
+ ( (secure) ? ";secure" : "");
+ document.cookie = cookieString;
+ }
+ ,
+ setFileNameRename : function(newFileName)
+ {
+ this.filePathRenameItem = newFileName;
+ }
+ ,
+ setFileNameDelete : function(newFileName)
+ {
+ this.filePathDeleteItem = newFileName;
+ }
+ ,
+ setAdditionalRenameRequestParameters : function(requestParameters)
+ {
+ this.additionalRenameRequestParameters = requestParameters;
+ }
+ ,
+ setAdditionalDeleteRequestParameters : function(requestParameters)
+ {
+ this.additionalDeleteRequestParameters = requestParameters;
+ }
+ ,setRenameAllowed : function(renameAllowed)
+ {
+ this.renameAllowed = renameAllowed;
+ }
+ ,
+ setDeleteAllowed : function(deleteAllowed)
+ {
+ this.deleteAllowed = deleteAllowed;
+ }
+ ,
+ setAddAllowed : function(addAllowed)
+ {
+ this.addAllowed = addAllowed;
+ }
+ ,setMaximumDepth : function(maxDepth)
+ {
+ this.maximumDepth = maxDepth;
+ }
+ ,setMessageMaximumDepthReached : function(newMessage)
+ {
+ this.messageMaximumDepthReached = newMessage;
+ }
+ ,
+ setImageFolder : function(path)
+ {
+ this.imageFolder = path;
+ }
+ ,
+ setFolderImage : function(imagePath)
+ {
+ this.folderImage = imagePath;
+ }
+ ,
+ setPlusImage : function(imagePath)
+ {
+ this.plusImage = imagePath;
+ }
+ ,
+ setMinusImage : function(imagePath)
+ {
+ this.minusImage = imagePath;
+ }
+ ,
+ setTreeId : function(idOfTree)
+ {
+ this.idOfTree = idOfTree;
+ }
+ ,
+ expandAll : function()
+ {
+ var menuItems = document.getElementById(this.idOfTree).getElementsByTagName('LI');
+ for(var no=0;no<menuItems.length;no++){
+ var subItems = menuItems[no].getElementsByTagName('UL');
+ if(subItems.length>0 && subItems[0].style.display!='block'){
+ JSTreeObj.showHideNode(false,menuItems[no].id);
+ }
+ }
+ }
+ ,
+ collapseAll : function()
+ {
+ var menuItems = document.getElementById(this.idOfTree).getElementsByTagName('LI');
+ for(var no=0;no<menuItems.length;no++){
+ var subItems = menuItems[no].getElementsByTagName('UL');
+ if(subItems.length>0 && subItems[0].style.display=='block'){
+ JSTreeObj.showHideNode(false,menuItems[no].id);
+ }
+ }
+ JSTreeObj.showHideNode(false,menuItems[0].id);
+ }
+ ,
+ /*
+ Find top pos of a tree node
+ */
+ getTopPos : function(obj){
+ var top = obj.offsetTop/1;
+ while((obj = obj.offsetParent) != null){
+ if(obj.tagName!='HTML')top += obj.offsetTop;
+ }
+ if(document.all)top = top/1 + 13; else top = top/1 + 4;
+ return top;
+ }
+ ,
+ /*
+ Find left pos of a tree node
+ */
+ getLeftPos : function(obj){
+ var left = obj.offsetLeft/1 + 1;
+ while((obj = obj.offsetParent) != null){
+ if(obj.tagName!='HTML')left += obj.offsetLeft;
+ }
+
+ if(document.all)left = left/1 - 2;
+ return left;
+ }
+
+ ,
+ showHideNode : function(e,inputId)
+ {
+ if(inputId){
+ if(!document.getElementById(inputId))return;
+ thisNode = document.getElementById(inputId).getElementsByTagName('IMG')[0];
+ }else {
+ thisNode = this;
+ if(this.tagName=='A')thisNode = this.parentNode.getElementsByTagName('IMG')[0];
+
+ }
+ if(thisNode.style.visibility=='hidden')return;
+ var parentNode = thisNode.parentNode;
+ inputId = parentNode.id.replace(/[^0-9]/g,'');
+ if(thisNode.src.indexOf(JSTreeObj.plusImage)>=0){
+ thisNode.src = thisNode.src.replace(JSTreeObj.plusImage,JSTreeObj.minusImage);
+ var ul = parentNode.getElementsByTagName('UL')[0];
+ ul.style.display='block';
+ if(!initExpandedNodes)initExpandedNodes = ',';
+ if(initExpandedNodes.indexOf(',' + inputId + ',')<0) initExpandedNodes = initExpandedNodes + inputId + ',';
+ }else{
+ thisNode.src = thisNode.src.replace(JSTreeObj.minusImage,JSTreeObj.plusImage);
+ parentNode.getElementsByTagName('UL')[0].style.display='none';
+ initExpandedNodes = initExpandedNodes.replace(',' + inputId,'');
+ }
+ JSTreeObj.Set_Cookie('dhtmlgoodies_expandedNodes',initExpandedNodes,500);
+ return false;
+ }
+ ,
+ /*expand only the selected node*/
+ showSelectedNode : function(selectedItemId)
+ {
+ var menuItems = document.getElementById(this.idOfTree).getElementsByTagName('LI'); // Get an array of all menu items
+
+ var selectedNode ;
+ for(var no=0;no<menuItems.length;no++){
+ if (selectedItemId != null && selectedItemId == menuItems[no].id.replace(/[^0-9]/gi,'')){
+ selectedNode = menuItems[no];
+ break;
+ }
+ }
+ do{
+ if (selectedNode != null){
+ var subItems = selectedNode.getElementsByTagName('UL');
+ if(subItems && subItems.length>0 && subItems[0].style.display!='block'){
+ JSTreeObj.showHideNode(false,selectedNode.id);
+ }
+ selectedNode = selectedNode.parentNode;
+ }
+ }while (selectedNode && selectedNode.id.replace(/[^0-9]/gi,'') != '0');
+ return false;
+ }
+ ,
+ isDeleteAllowed : function(selectedItemId)
+ {
+ var menuItems = document.getElementById(this.idOfTree).getElementsByTagName('LI'); // Get an array of all menu items
+
+ var selectedNode ;
+ for(var no=0;no<menuItems.length;no++){
+ if (selectedItemId != null && selectedItemId == menuItems[no].id.replace(/[^0-9]/gi,'')){
+ selectedNode = menuItems[no];
+ break;
+ }
+ }
+ if (selectedNode && selectedNode.getAttribute('noDelete') && selectedNode.getAttribute('noDelete') == 'true')
+ return false;
+ else
+ return true;
+
+ }
+ ,
+ isAddAllowed : function(selectedItemId)
+ {
+ var menuItems = document.getElementById(this.idOfTree).getElementsByTagName('LI'); // Get an array of all menu items
+
+ var selectedNode ;
+ for(var no=0;no<menuItems.length;no++){
+ if (selectedItemId != null && selectedItemId == menuItems[no].id.replace(/[^0-9]/gi,'')){
+ selectedNode = menuItems[no];
+ break;
+ }
+ }
+ if (selectedNode && selectedNode.getAttribute('noChild') && selectedNode.getAttribute('noChild') == 'true')
+ return false;
+ else
+ return true;
+
+ }
+ ,
+ /* Initialize drag */
+ initDrag : function(e)
+ {
+ if(document.all)e = event;
+
+ var subs = JSTreeObj.floatingContainer.getElementsByTagName('LI');
+ if(subs.length>0){
+ if(JSTreeObj.dragNode_sourceNextSib){
+ JSTreeObj.dragNode_parent.insertBefore(JSTreeObj.dragNode_source,JSTreeObj.dragNode_sourceNextSib);
+ }else{
+ JSTreeObj.dragNode_parent.appendChild(JSTreeObj.dragNode_source);
+ }
+ }
+
+ JSTreeObj.dragNode_source = this.parentNode;
+ JSTreeObj.dragNode_parent = this.parentNode.parentNode;
+ JSTreeObj.dragNode_sourceNextSib = false;
+
+
+ if(JSTreeObj.dragNode_source.nextSibling)JSTreeObj.dragNode_sourceNextSib = JSTreeObj.dragNode_source.nextSibling;
+ JSTreeObj.dragNode_destination = false;
+ JSTreeObj.dragDropTimer = 0;
+ JSTreeObj.timerDrag();
+ return false;
+ }
+ ,
+ timerDrag : function()
+ {
+ if(this.dragDropTimer>=0 && this.dragDropTimer<10){
+ this.dragDropTimer = this.dragDropTimer + 1;
+ setTimeout('JSTreeObj.timerDrag()',20);
+ return;
+ }
+ if(this.dragDropTimer==10)
+ {
+ JSTreeObj.floatingContainer.style.display='block';
+ JSTreeObj.floatingContainer.appendChild(JSTreeObj.dragNode_source);
+ }
+ }
+ ,
+ moveDragableNodes : function(e)
+ {
+ if(JSTreeObj.dragDropTimer<10)return;
+ if(document.all)e = event;
+ dragDrop_x = e.clientX/1 + 5 + document.body.scrollLeft;
+ dragDrop_y = e.clientY/1 + 5 + document.documentElement.scrollTop;
+
+ JSTreeObj.floatingContainer.style.left = dragDrop_x + 'px';
+ JSTreeObj.floatingContainer.style.top = dragDrop_y + 'px';
+
+ var thisObj = this;
+ if(thisObj.tagName=='A' || thisObj.tagName=='IMG')thisObj = thisObj.parentNode;
+
+ JSTreeObj.dragNode_noSiblings = false;
+ var tmpVar = thisObj.getAttribute('noSiblings');
+ if(!tmpVar)tmpVar = thisObj.noSiblings;
+ if(tmpVar=='true')JSTreeObj.dragNode_noSiblings=true;
+
+ if(thisObj && thisObj.id)
+ {
+ JSTreeObj.dragNode_destination = thisObj;
+ var img = thisObj.getElementsByTagName('IMG')[1];
+ var tmpObj= JSTreeObj.dropTargetIndicator;
+ tmpObj.style.display='block';
+
+ var eventSourceObj = this;
+ if(JSTreeObj.dragNode_noSiblings && eventSourceObj.tagName=='IMG')eventSourceObj = eventSourceObj.nextSibling;
+
+ var tmpImg = tmpObj.getElementsByTagName('IMG')[0];
+ if(this.tagName=='A' || JSTreeObj.dragNode_noSiblings){
+ tmpImg.src = tmpImg.src.replace('ind1','ind2');
+ JSTreeObj.insertAsSub = true;
+ tmpObj.style.left = (JSTreeObj.getLeftPos(eventSourceObj) + JSTreeObj.indicator_offsetX_sub) + 'px';
+ }else{
+ tmpImg.src = tmpImg.src.replace('ind2','ind1');
+ JSTreeObj.insertAsSub = false;
+ tmpObj.style.left = (JSTreeObj.getLeftPos(eventSourceObj) + JSTreeObj.indicator_offsetX) + 'px';
+ }
+
+ tmpObj.style.top = (JSTreeObj.getTopPos(thisObj) + JSTreeObj.indicator_offsetY) - document.getElementById("scrollableTable").scrollTop + 'px' ;
+
+
+ }
+ var divHeight = document.getElementById("scrollableTable").style.height;
+ divHeight = divHeight.substring(0, divHeight.indexOf("px"));
+ if (dragDrop_y - JSTreeObj.getTopPos(document.getElementById("scrollableTable"))< 50)
+ document.getElementById("scrollableTable").scrollTop = document.getElementById("scrollableTable").scrollTop - 5;
+ else if (dragDrop_y - JSTreeObj.getTopPos(document.getElementById("scrollableTable")) > divHeight - 50)
+ document.getElementById("scrollableTable").scrollTop = document.getElementById("scrollableTable").scrollTop + 5;
+
+ return false;
+
+ }
+ ,
+ dropDragableNodes:function()
+ {
+ if(JSTreeObj.dragDropTimer<10){
+ JSTreeObj.dragDropTimer = -1;
+ return;
+ }
+ var showMessage = false;
+ var message = '';
+ if(JSTreeObj.dragNode_destination){ // Check depth
+ var countUp = JSTreeObj.dragDropCountLevels(JSTreeObj.dragNode_destination,'up');
+ var countDown = JSTreeObj.dragDropCountLevels(JSTreeObj.dragNode_source,'down');
+ var countLevels = countUp/1 + countDown/1 + (JSTreeObj.insertAsSub?1:0);
+
+ if(countLevels>JSTreeObj.maximumDepth){
+ JSTreeObj.dragNode_destination = false;
+ showMessage = true; // Used later down in this function
+ message = JSTreeObj.messageMaximumDepthReachedl
+ }
+ }
+ if (JSTreeObj.dragNode_destination && JSTreeObj.dragNode_destination.getAttribute('noDrop') == 'true'){
+ JSTreeObj.dragNode_destination = false;
+ showMessage = true; // Used later down in this function
+ message = JSTreeObj.messageNoRightsOnFolder;
+ }
+
+
+ if(JSTreeObj.dragNode_destination){
+
+ if(JSTreeObj.insertAsSub){
+ var uls = JSTreeObj.dragNode_destination.getElementsByTagName('UL');
+ if(uls.length>0){
+ ul = uls[0];
+ ul.style.display='block';
+
+ var lis = ul.getElementsByTagName('LI');
+
+ if(lis.length>0){ // Sub elements exists - drop dragable node before the first one
+ ul.insertBefore(JSTreeObj.dragNode_source,lis[0]);
+ }else { // No sub exists - use the appendChild method - This line should not be executed unless there's something wrong in the HTML, i.e empty <ul>
+ ul.appendChild(JSTreeObj.dragNode_source);
+ }
+ }else{
+ var ul = document.createElement('UL');
+ ul.style.display='block';
+ JSTreeObj.dragNode_destination.appendChild(ul);
+ ul.appendChild(JSTreeObj.dragNode_source);
+ }
+ var img = JSTreeObj.dragNode_destination.getElementsByTagName('IMG')[0];
+ img.style.visibility='visible';
+ img.src = img.src.replace(JSTreeObj.plusImage,JSTreeObj.minusImage);
+
+
+ }else{
+ if(JSTreeObj.dragNode_destination.nextSibling){
+ var nextSib = JSTreeObj.dragNode_destination.nextSibling;
+ nextSib.parentNode.insertBefore(JSTreeObj.dragNode_source,nextSib);
+ }else{
+ JSTreeObj.dragNode_destination.parentNode.appendChild(JSTreeObj.dragNode_source);
+ }
+ }
+ /* Clear parent object */
+ var tmpObj = JSTreeObj.dragNode_parent;
+ var lis = tmpObj.getElementsByTagName('LI');
+ if(lis.length==0){
+ var img = tmpObj.parentNode.getElementsByTagName('IMG')[0];
+ img.style.visibility='hidden'; // Hide [+],[-] icon
+ tmpObj.parentNode.removeChild(tmpObj);
+ }
+
+ }else{
+ // Putting the item back to it's original location
+
+ if(JSTreeObj.dragNode_sourceNextSib){
+ JSTreeObj.dragNode_parent.insertBefore(JSTreeObj.dragNode_source,JSTreeObj.dragNode_sourceNextSib);
+ }else{
+ JSTreeObj.dragNode_parent.appendChild(JSTreeObj.dragNode_source);
+ }
+
+ }
+ JSTreeObj.dropTargetIndicator.style.display='none';
+ JSTreeObj.dragDropTimer = -1;
+ if(showMessage && message){ alert(message); return;}
+ //save tree structure
+ saveMyTree_byForm();
+ }
+ ,
+ createDropIndicator : function()
+ {
+ this.dropTargetIndicator = document.createElement('DIV');
+ this.dropTargetIndicator.style.position = 'absolute';
+ this.dropTargetIndicator.style.display='none';
+ var img = document.createElement('IMG');
+ img.src = this.imageFolder + 'dragDrop_ind1.gif';
+ img.id = 'dragDropIndicatorImage';
+ this.dropTargetIndicator.appendChild(img);
+ document.body.appendChild(this.dropTargetIndicator);
+
+ }
+ ,
+ dragDropCountLevels : function(obj,direction,stopAtObject){
+ var countLevels = 0;
+ if(direction=='up'){
+ while(obj.parentNode && obj.parentNode!=stopAtObject){
+ obj = obj.parentNode;
+ if(obj.tagName=='UL')countLevels = countLevels/1 +1;
+ }
+ return countLevels;
+ }
+
+ if(direction=='down'){
+ var subObjects = obj.getElementsByTagName('LI');
+ for(var no=0;no<subObjects.length;no++){
+ countLevels = Math.max(countLevels,JSTreeObj.dragDropCountLevels(subObjects[no],"up",obj));
+ }
+ return countLevels;
+
+ }
+ }
+ ,
+ cancelEvent : function()
+ {
+ return false;
+ }
+ ,
+ cancelSelectionEvent : function()
+ {
+
+ if(JSTreeObj.dragDropTimer<10)return true;
+ return false;
+ }
+ ,getNodeOrders : function(initObj,saveString)
+ {
+
+ if(!saveString)var saveString = '';
+ if(!initObj){
+ initObj = document.getElementById(this.idOfTree);
+
+ }
+ var lis = initObj.getElementsByTagName('LI');
+
+ if(lis.length>0){
+ var li = lis[0];
+ while(li){
+ if(li.id){
+ if(saveString.length>0)saveString = saveString + ',';
+ var numericID = li.id.replace(/[^0-9]/gi,'');
+ if(numericID.length==0)numericID='A';
+ var numericParentID = li.parentNode.parentNode.id.replace(/[^0-9]/gi,'');
+ if(numericID!='0'){
+ saveString = saveString + numericID;
+ saveString = saveString + '-';
+
+
+ if(li.parentNode.id!=this.idOfTree)saveString = saveString + numericParentID; else saveString = saveString + '0';
+ }
+ var ul = li.getElementsByTagName('UL');
+ if(ul.length>0){
+ saveString = this.getNodeOrders(ul[0],saveString);
+ }
+ }
+ li = li.nextSibling;
+ }
+ }
+
+ if(initObj.id == this.idOfTree){
+ return saveString;
+
+ }
+ return saveString;
+ }
+ ,highlightItem : function(inputObj,e)
+ {
+ if(JSTreeObj.currentlyActiveItem)JSTreeObj.currentlyActiveItem.className = '';
+ this.className = 'highlightedNodeItem';
+ JSTreeObj.currentlyActiveItem = this;
+ }
+ ,clickItem : function(inputObj,e)
+ {
+ if(JSTreeObj.currentlyActiveItem) JSTreeObj.currentlyActiveItem.className = '';
+ this.className = 'highlightedNodeItem';
+ JSTreeObj.currentlyActiveItem = this;
+ JSTreeObj.selectedItem = this;
+ },
+ removeHighlight : function()
+ {
+ //if(JSTreeObj.currentlyActiveItem)JSTreeObj.currentlyActiveItem.className = '';
+ //JSTreeObj.currentlyActiveItem = false;
+ }
+ ,
+ hasSubNodes : function(obj)
+ {
+ var subs = obj.getElementsByTagName('LI');
+ if(subs.length>0)return true;
+ return false;
+ }
+ ,
+ deleteItem : function(obj1,obj2)
+ {
+ var message = 'Click OK to delete item ' + obj2.innerHTML;
+ if(this.hasSubNodes(obj2.parentNode)) message = message + ' and it\'s sub nodes';
+ if(confirm(message)){
+ this.__deleteItem_step2(obj2.parentNode); // Sending <LI> tag to the __deleteItem_step2 method
+ //deleteItem();
+ }else{
+ return false;
+ }
+
+
+ }
+ ,
+ addItem : function(obj1,obj2)
+ {
+ var message = 'Click OK to Add item ' + obj2.innerHTML;
+ return this.__addItem_step2(obj2.parentNode); // Sending <LI> tag to the __addItem_step2 method
+ }
+ ,
+ createMenuReport : function(obj1,obj2)
+ {
+ JSTreeObj.selectedItem = obj2;
+ createReport();
+ }
+ ,
+ runMenuReport : function(obj1,obj2)
+ {
+ JSTreeObj.selectedItem = obj2;
+ runReport();
+
+ }
+ ,
+ editMenuReport : function(obj1,obj2)
+ {
+ JSTreeObj.selectedItem = obj2;
+ editReport();
+ }
+ ,
+ deleteMenuReport : function(obj1,obj2)
+ {
+ JSTreeObj.selectedItem = obj2;
+ if (confirm("Do you want to delete this report?")){
+ deleteReport();
+ }
+
+ }
+ ,
+ __refreshDisplay : function(obj)
+ {
+ if(this.hasSubNodes(obj))return;
+
+ var img = obj.getElementsByTagName('IMG')[0];
+ img.style.visibility = 'hidden';
+ }
+ ,
+ __deleteItem_step2 : function(obj)
+ {
+
+ var saveString = obj.id.replace(/[^0-9]/gi,'');
+
+ var lis = obj.getElementsByTagName('LI');
+ for(var no=0;no<lis.length;no++){
+ saveString = saveString + ',' + lis[no].id.replace(/[^0-9]/gi,'');
+ }
+
+ // Creating ajax object and send items
+ var ajaxIndex = JSTreeObj.ajaxObjects.length;
+ JSTreeObj.ajaxObjects[ajaxIndex] = new sack();
+ JSTreeObj.ajaxObjects[ajaxIndex].method = "GET";
+ JSTreeObj.ajaxObjects[ajaxIndex].setVar("deleteIds", saveString);
+ document.all.deleteIds.value=saveString;
+ JSTreeObj.__addAdditionalRequestParameters(JSTreeObj.ajaxObjects[ajaxIndex], JSTreeObj.additionalDeleteRequestParameters);
+ JSTreeObj.ajaxObjects[ajaxIndex].requestFile = JSTreeObj.filePathDeleteItem; // Specifying which file to get
+ JSTreeObj.ajaxObjects[ajaxIndex].onCompletion = function() { JSTreeObj.__deleteComplete(ajaxIndex,obj); } ; // Specify function that will be executed after file has been found
+ //JSTreeObj.ajaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function
+ deleteMyTree_byForm();
+
+
+ }
+ ,
+ __addItem_step2 : function(obj)
+ {
+ var parentId = obj.id.replace(/[^0-9]/gi,'');
+ document.all.newName.value="";
+ document.all.saveString.value=parentId;
+ if (selectedFolderId)
+ selectedFolderId = parentId;
+
+ addMyTree_byForm();
+
+ }
+ ,
+ __deleteComplete : function(ajaxIndex,obj)
+ {
+ if(this.ajaxObjects[ajaxIndex].response!='OK'){
+ alert('ERROR WHEN TRYING TO DELETE NODE: ' + this.ajaxObjects[ajaxIndex].response); // Rename failed
+ }else{
+ var parentRef = obj.parentNode.parentNode;
+ obj.parentNode.removeChild(obj);
+ this.__refreshDisplay(parentRef);
+
+ }
+
+ }
+ ,
+ __renameComplete : function(ajaxIndex)
+ {
+ if(this.ajaxObjects[ajaxIndex].response!='OK'){
+ alert('ERROR WHEN TRYING TO RENAME NODE: ' + this.ajaxObjects[ajaxIndex].response); // Rename failed
+ }
+ }
+ ,
+ __saveTextBoxChanges : function(e,inputObj)
+ {
+ if(!inputObj && this)inputObj = this;
+ if(document.all)e = event;
+ if(e.keyCode && e.keyCode==27){
+ JSTreeObj.__cancelRename(e,inputObj);
+ return;
+ }
+ inputObj.style.display='none';
+ inputObj.nextSibling.style.visibility='visible';
+ if(inputObj.value.length>0){
+ inputObj.nextSibling.innerHTML = inputObj.value;
+ // Send changes to the server.
+ if (JSTreeObj.renameState != JSTreeObj.RENAME_STATE_BEGIN) {
+ return;
+ }
+ JSTreeObj.renameState = JSTreeObj.RENAME_STATE_REQUEST_SENDED;
+ var ajaxIndex = JSTreeObj.ajaxObjects.length;
+ JSTreeObj.ajaxObjects[ajaxIndex] = new sack();
+ JSTreeObj.ajaxObjects[ajaxIndex].method = "GET";
+ JSTreeObj.ajaxObjects[ajaxIndex].setVar("renameId", inputObj.parentNode.id.replace(/[^0-9]/gi,''));
+ JSTreeObj.ajaxObjects[ajaxIndex].setVar("newName", inputObj.value);
+ JSTreeObj.__addAdditionalRequestParameters(JSTreeObj.ajaxObjects[ajaxIndex], JSTreeObj.additionalRenameRequestParameters);
+ JSTreeObj.ajaxObjects[ajaxIndex].requestFile = JSTreeObj.filePathRenameItem; // Specifying which file to get
+ JSTreeObj.ajaxObjects[ajaxIndex].onCompletion = function() { JSTreeObj.__renameComplete(ajaxIndex); } ; // Specify function that will be executed after file has been found
+ JSTreeObj.ajaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function
+
+ document.all.renameId.value=inputObj.parentNode.id.replace(/[^0-9]/gi,'');
+ document.all.newName.value= inputObj.value;
+ renameMyTree_byForm();
+
+ }
+ }
+ ,
+ __cancelRename : function(e,inputObj)
+ {
+ JSTreeObj.renameState = JSTreeObj.RENAME_STATE_CANCELD;
+ if(!inputObj && this)inputObj = this;
+ inputObj.value = JSTreeObj.helpObj.innerHTML;
+ inputObj.nextSibling.innerHTML = JSTreeObj.helpObj.innerHTML;
+ inputObj.style.display = 'none';
+ inputObj.nextSibling.style.visibility = 'visible';
+ }
+ ,
+ __renameCheckKeyCode : function(e)
+ {
+ if(document.all)e = event;
+ if(e.keyCode==13){ // Enter pressed
+ JSTreeObj.__saveTextBoxChanges(false,this);
+ }
+ if(e.keyCode==27){ // ESC pressed
+ JSTreeObj.__cancelRename(false,this);
+ }
+ }
+ ,
+ __createTextBox : function(obj)
+ {
+ var textBox = document.createElement('INPUT');
+ textBox.className = 'folderTreeTextBox';
+ textBox.value = obj.innerHTML;
+ obj.parentNode.insertBefore(textBox,obj);
+ textBox.id = 'textBox' + obj.parentNode.id.replace(/[^0-9]/gi,'');
+ textBox.onblur = this.__saveTextBoxChanges;
+ textBox.onkeydown = this.__renameCheckKeyCode;
+ textBox.style.height="16px";
+ this.__renameEnableTextBox(obj);
+ }
+ ,
+ __renameEnableTextBox : function(obj)
+ {
+ JSTreeObj.renameState = JSTreeObj.RENAME_STATE_BEGIN;
+ obj.style.visibility = 'hidden';
+ obj.previousSibling.value = obj.innerHTML;
+ obj.previousSibling.style.display = 'inline';
+ obj.previousSibling.select();
+ }
+ ,
+ renameItem : function(obj1,obj2)
+ {
+ currentItemToEdit = obj2.parentNode; // Reference to the <li> tag.
+ if(!obj2.previousSibling || obj2.previousSibling.tagName.toLowerCase()!='input'){
+ this.__createTextBox(obj2);
+ }else{
+ this.__renameEnableTextBox(obj2);
+ }
+ this.helpObj.innerHTML = obj2.innerHTML;
+
+ }
+ ,
+ initTree : function(selectedItemId)
+ {
+ JSTreeObj = this;
+ JSTreeObj.createDropIndicator();
+ document.documentElement.onselectstart = JSTreeObj.cancelSelectionEvent;
+ document.documentElement.ondragstart = JSTreeObj.cancelEvent;
+ document.documentElement.onmousedown = JSTreeObj.removeHighlight;
+
+ /* Creating help object for storage of values */
+ this.helpObj = document.createElement('DIV');
+ this.helpObj.style.display = 'none';
+ document.body.appendChild(this.helpObj);
+ /* Create context menu */
+ if(this.deleteAllowed || this.renameAllowed || this.addAllowed){
+ try{
+ /* Creating menu model for the context menu, i.e. the datasource */
+ var menuModel = new DHTMLGoodies_menuModel();
+ if(this.deleteAllowed)menuModel.addItem(1,'Delete Folder','','',false,'JSTreeObj.deleteItem');
+ if(this.deleteAllowed)menuModel.addItem(2,'Rename Folder','','',false,'JSTreeObj.renameItem');
+ if(this.addAllowed)menuModel.addItem(3,'New Folder','','',false,'JSTreeObj.addItem');
+ menuModel.addItem(4,'Create Report','','',false,'JSTreeObj.createMenuReport');
+ menuModel.init();
+
+ /*For Reports*/
+ var menuReportNoRights = new DHTMLGoodies_menuModel();
+ menuReportNoRights.addItem(3,'Run','','',false,'JSTreeObj.runItem');
+ menuReportNoRights.init();
+
+ var menuReportWithRights = new DHTMLGoodies_menuModel();
+ menuReportWithRights.addItem(1,'Run','','',false,'JSTreeObj.runMenuReport');
+ menuReportWithRights.addItem(2,'Edit','','',false,'JSTreeObj.editMenuReport');
+ menuReportWithRights.addItem(3,'Delete','','',false,'JSTreeObj.deleteMenuReport');
+ menuReportWithRights.init();
+
+
+ var menuModelRenameOnly = new DHTMLGoodies_menuModel();
+ if(this.renameAllowed)menuModelRenameOnly.addItem(3,'Rename Folder','','',false,'JSTreeObj.renameItem');
+ menuModelRenameOnly.init();
+
+ var menuModelDeleteOnly = new DHTMLGoodies_menuModel();
+ if(this.deleteAllowed)menuModelDeleteOnly.addItem(4,'Delete Folder','','',false,'JSTreeObj.deleteItem');
+ menuModelDeleteOnly.init();
+
+ var menuModelAddOnly = new DHTMLGoodies_menuModel();
+ menuModelAddOnly.addItem(1,'New Folder','','',false,'JSTreeObj.addItem');
+ menuModelAddOnly.init();
+
+ window.refToDragDropTree = this;
+
+ this.contextMenu = new DHTMLGoodies_contextMenu();
+ this.contextMenu.setWidth(120);
+ referenceToDHTMLSuiteContextMenu = this.contextMenu;
+ }catch(e){
+
+ }
+ }
+
+
+ var nodeId = 0;
+ var dhtmlgoodies_tree = document.getElementById(this.idOfTree);
+ var menuItems = dhtmlgoodies_tree.getElementsByTagName('LI'); // Get an array of all menu items
+ for(var no=0;no<menuItems.length;no++){
+ // No children var set ?
+ var noChildren = false;
+ var tmpVar = menuItems[no].getAttribute('noChildren');
+ if(!tmpVar)tmpVar = menuItems[no].noChildren;
+ if(tmpVar=='true')noChildren=true;
+ // No drag var set ?
+ var noDrag = false;
+ var tmpVar = menuItems[no].getAttribute('noDrag');
+ if(!tmpVar)tmpVar = menuItems[no].noDrag;
+ if(tmpVar=='true')noDrag=true;
+
+ nodeId++;
+ var subItems = menuItems[no].getElementsByTagName('UL');
+ var img = document.createElement('IMG');
+ img.src = this.imageFolder + this.plusImage;
+ img.onclick = JSTreeObj.showHideNode;
+
+ if(subItems.length==0)img.style.visibility='hidden';else{
+ subItems[0].id = 'tree_ul_' + treeUlCounter;
+ treeUlCounter++;
+ }
+ var aTag = menuItems[no].getElementsByTagName('A')[0];
+ aTag.id = 'nodeATag' + menuItems[no].id.replace(/[^0-9]/gi,'');
+ //aTag.onclick = JSTreeObj.showHideNode;
+ if(!noDrag)aTag.onmousedown = JSTreeObj.initDrag;
+ if(!noChildren)aTag.onmousemove = JSTreeObj.moveDragableNodes;
+ menuItems[no].insertBefore(img,aTag);
+ //menuItems[no].id = 'dhtmlgoodies_treeNode' + nodeId;
+ var folderImg = document.createElement('IMG');
+ if(!noDrag)folderImg.onmousedown = JSTreeObj.initDrag;
+ folderImg.onmousemove = JSTreeObj.moveDragableNodes;
+ if(menuItems[no].className){
+ folderImg.src = this.imageFolder + menuItems[no].className;
+ } else if (menuItems[no].getAttribute('imgFile')){
+ folderImg.src = this.imageFolder + menuItems[no].getAttribute('imgFile');
+ } else{
+ folderImg.src = this.imageFolder + this.folderImage;
+ }
+ menuItems[no].insertBefore(folderImg,aTag);
+
+ if(this.contextMenu){
+ var noDelete = menuItems[no].getAttribute('noDelete');
+ if(!noDelete)noDelete = menuItems[no].noDelete;
+ var noRename = menuItems[no].getAttribute('noRename');
+ if(!noRename)noRename = menuItems[no].noRename;
+ var noAdd = menuItems[no].getAttribute('noChild');
+ if(!noAdd)noAdd = menuItems[no].noChild;
+
+
+ if (menuItems[no].id.replace(/[^0-9]/gi,'').substr(0,3) != '000' ){//for folders
+ if(noRename=='true' && noDelete=='true'){
+ if (noAdd != 'true'){
+ this.contextMenu.attachToElement(aTag,false,menuModelAddOnly);
+ }
+ }else{
+ if(noDelete == 'true')this.contextMenu.attachToElement(aTag,false,menuModelRenameOnly);
+ else if(noRename == 'true')this.contextMenu.attachToElement(aTag,false,menuModelDeleteOnly);
+ else this.contextMenu.attachToElement(aTag,false,menuModel);
+
+ }
+ }else{//for reports
+ var noRights = menuItems[no].getAttribute('noReportRights');
+ if(!noRights)noRights = menuItems[no].noRights;
+ if(noRights=='true'){
+ this.contextMenu.attachToElement(aTag,false,menuReportNoRights);
+ }else{
+ this.contextMenu.attachToElement(aTag,false,menuReportWithRights);
+ }
+
+
+ }
+ }
+ //highlighting the selected item
+ if (selectedItemId != null && selectedItemId == menuItems[no].id.replace(/[^0-9]/gi,'')){
+ if(JSTreeObj.currentlyActiveItem) JSTreeObj.currentlyActiveItem.className = '';
+ aTag.className = 'highlightedNodeItem';
+ JSTreeObj.currentlyActiveItem = aTag;
+ JSTreeObj.selectedItem = aTag;
+ folderImg.tabindex="1";
+ //alert(1);
+ //folderImg.focus();
+ }
+ this.addEvent(aTag,'contextmenu',this.highlightItem);
+ this.addEvent(aTag,'click',this.clickItem);
+
+
+
+ }
+
+
+
+ initExpandedNodes = this.Get_Cookie('dhtmlgoodies_expandedNodes');
+ if(initExpandedNodes){
+ var nodes = initExpandedNodes.split(',');
+ for(var no=0;no<nodes.length;no++){
+ if(nodes[no])this.showHideNode(false,nodes[no]);
+ }
+ }
+
+
+
+
+ document.documentElement.onmousemove = JSTreeObj.moveDragableNodes;
+ document.documentElement.onmouseup = JSTreeObj.dropDragableNodes;
+ }
+ ,
+ __addAdditionalRequestParameters : function(ajax, parameters)
+ {
+ for (var parameter in parameters) {
+ ajax.setVar(parameter, parameters[parameter]);
+ }
+ }
+ } \ No newline at end of file