diff --git a/phpgwapi/js/dJSWin/dJSWin.css b/phpgwapi/js/dJSWin/dJSWin.css new file mode 100644 index 0000000000..e61dd419a4 --- /dev/null +++ b/phpgwapi/js/dJSWin/dJSWin.css @@ -0,0 +1,26 @@ +.dJSWin_main +{ + background-color: #e3e3e3; +} + +.dJSWin_title_text +{ + background-color: #3978d6; + color: white; + font-weight: bold; +} + +.dJSWin_title +{ + background-color: #3978d6; +} + +.dJSWin_high +{ + background-color: #e3e3e3; +} + +.dJSWin_low +{ + background-color: #c9c9c9; +} diff --git a/phpgwapi/js/dJSWin/ie/dJSWin.js b/phpgwapi/js/dJSWin/ie/dJSWin.js new file mode 100644 index 0000000000..ed50aeca3c --- /dev/null +++ b/phpgwapi/js/dJSWin/ie/dJSWin.js @@ -0,0 +1,321 @@ + /****************************************************************************\ + * Dynamic JS Win - Javascript Object * + * * + * Written by: * + * - Raphael Derosso Pereira * + * ------------------------------------------------------------------------ * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \****************************************************************************/ + + dJSWin.prototype.init = function(params) + { + if (!params || typeof(params) != 'object' || !params.id || !params.width || !params.height || !params.content_id) + { + throw("Can't create empty window or window without width, height or ID"); + } + + /* Internal Variables */ + this.winContainer = document.createElement('iframe'); + this.clientArea = document.createElement('div'); + this.title = document.createElement('div'); + this.title_text = null; //document.createElement(''); + this.buttons = new Array(); + this.shadows = new Array(); + this.border = new Array(); + this.content_id = params.content_id; + this.includedContents = params['include_contents']; + var pixelTABLE, pixelTBODY, pixelTR, pixelTD; + var _this = this; + var style; + + /* Create 1 pixel table to be able to create freely + * sizeble DIVs on IE + */ + pixelTABLE = document.createElement('table'); + pixelTBODY = document.createElement('tbody'); + pixelTR = document.createElement('tR'); + pixelTD = document.createElement('td'); + + pixelTABLE.appendChild(pixelTBODY); + pixelTBODY.appendChild(pixelTR); + pixelTR.appendChild(pixelTD); + + this.title_text_cont = pixelTABLE.cloneNode(true); + this.title_text = this.title_text_cont.firstChild.firstChild.firstChild; + + pixelTABLE.style.width = '1px'; + pixelTABLE.style.height = '1px'; + + pixelTD.style.width = '1px'; + pixelTD.style.height = '1px'; + + this.border['t'] = document.createElement('div'); + this.border['b'] = document.createElement('div'); + this.border['l'] = document.createElement('div'); + this.border['r'] = document.createElement('div'); + + this.shadows['r'] = document.createElement('div'); + this.shadows['b'] = document.createElement('div'); + + this.buttons['xDIV'] = document.createElement('div'); + + if (params['button_x_img']) + { + this.buttons['xIMG'] = document.createElement('IMG'); + this.buttons['xIMG'].src = params['button_x_img']; + this.buttons['xIMG'].style.cursor = 'hand'; + this.buttons['xDIV'].appendChild(this.buttons['xIMG']); + } + else + { + this.buttons.xDIV.innerHTML = 'X'; + } + + /* Inicialization */ + this.title.id = params['id']; + this.title.style.position = 'absolute'; + this.title.style.visibility = 'hidden'; + this.title.style.width = parseInt(params['width']) + 2 + 'px'; + this.title.style.height = params['title_height'] ? params['title_height'] : '18px'; + this.title.style.backgroundColor = '#3978d6'; + // this.title.className = 'dJSWin_title'; + this.title.style.top = '0px'; + this.title.style.left = '0px'; + this.title.style.zIndex = '1'; + + this.title_text_cont.id = params['id'] + '_text'; + this.title_text_cont.style.position = 'relative'; +// this.title_text_cont.border = '0'; + this.title_text_cont.style.width = '100%'; + this.title_text_cont.style.height = '100%'; + this.title_text.style.cursor = 'move'; + this.title_text_cont.className = 'dJSWin_title_text'; + this.title_text.className = 'dJSWin_title_text'; +// this.title_text.style.cursor = 'move'; + this.title_text.innerHTML = params['title']; + this.title_text_cont.style.zIndex = '1'; + + this.winContainer.id = params['id']+'_winContainer'; + this.winContainer.style.position = 'absolute'; + this.winContainer.style.visibility = 'hidden'; + this.winContainer.style.width = params['width']; + this.winContainer.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; +// this.winContainer.style.top = '0px'; + this.winContainer.style.top = '0px'; //this.title.style.height; + this.winContainer.style.left = '0px'; + this.winContainer.style.zIndex = '-1'; +// this.winContainer.style.backgroundColor = params['bg_color']; +// this.winContainer.className = params['win_class']; + this.winContainer.src = ''; + + this.clientArea.id = params['id']+'_clientArea'; + this.clientArea.style.position = 'absolute'; + this.clientArea.style.visibility = 'hidden'; + this.clientArea.style.width = parseInt(params['width']) + 2 + 'px'; + this.clientArea.style.height = params['height']; + this.clientArea.style.top = parseInt(this.title.style.height) + 'px'; + this.clientArea.style.left = '0px'; + // this.clientArea.style.backgroundColor = params['bg_color']; +// this.clientArea.style.overflow = 'auto'; + this.clientArea.className = 'dJSWin_main'; + + this.buttons.xDIV.id = params['id']+'_button'; + this.buttons.xDIV.style.position = 'absolute'; + this.buttons.xDIV.style.visibility = 'hidden'; + this.buttons.xDIV.style.cursor = 'hand'; + this.buttons.xDIV.style.top = '1px'; + this.buttons.xDIV.style.left = parseInt(params['width']) - 13 + 'px'; + this.buttons.xDIV.style.zIndex = '1'; + this.buttons.xDIV.onclick = function() {_this.close();}; + + this.shadows.b.id = params['id']+'_shadowb'; + this.shadows.b.style.position = 'absolute'; + this.shadows.b.style.visibility = 'hidden'; + this.shadows.b.style.backgroundColor = '#666'; + this.shadows.b.style.width = params['width']; + this.shadows.b.style.height = '4px'; + this.shadows.b.style.top = parseInt(this.title.style.height) + parseInt(params['height']) + 2 + 'px'; + this.shadows.b.style.left = '4px'; + this.shadows.b.appendChild(pixelTABLE.cloneNode(true)); + + this.shadows.r.id = params['id']+'_shadowr'; + this.shadows.r.style.position = 'absolute'; + this.shadows.r.style.visibility = 'hidden'; + this.shadows.r.style.backgroundColor = '#666'; + this.shadows.r.style.width = '4px'; + this.shadows.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; + this.shadows.r.style.top = '4px'; + this.shadows.r.style.left = params['width']; + + this.border.t.id = params['id']+'_border_t'; + this.border.b.id = params['id']+'_border_b'; + this.border.l.id = params['id']+'_border_l'; + this.border.r.id = params['id']+'_border_r'; + + this.border.t.style.position = 'absolute'; + this.border.b.style.position = 'absolute'; + this.border.l.style.position = 'absolute'; + this.border.r.style.position = 'absolute'; + + this.border.t.style.visibility = 'hidden'; + this.border.b.style.visibility = 'hidden'; + this.border.l.style.visibility = 'hidden'; + this.border.r.style.visibility = 'hidden'; + + this.border.t.className = 'dJSWin_title'; + this.border.b.className = 'dJSWin_title'; + this.border.l.className = 'dJSWin_title'; + this.border.r.className = 'dJSWin_title'; + + this.border.t.style.border = '0px'; + this.border.b.style.border = '0px'; + this.border.l.style.border = '0px'; + this.border.r.style.border = '0px'; + + this.border.t.appendChild(pixelTABLE.cloneNode(true)); + this.border.b.appendChild(pixelTABLE.cloneNode(true)); + + if (params['border']) + { + this.border.t.style.width = parseInt(params['width']) + 2 + 'px'; + this.border.b.style.width = parseInt(params['width']) + 4 + 'px'; + this.border.l.style.width = '2px'; + this.border.r.style.width = '2px'; + + this.border.t.style.height = '2px'; + this.border.b.style.height = '2px'; + this.border.l.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; + this.border.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; + + this.border.t.style.top = '-2px'; + this.border.b.style.top = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; + this.border.l.style.top = '-2px'; + this.border.r.style.top = '-2px'; + + this.border.t.style.left = '-2px'; + this.border.b.style.left = '-2px'; + this.border.l.style.left = '-2px'; + this.border.r.style.left = params['width']; + + this.shadows.b.style.top = parseInt(this.shadows.b.style.top) + 2 + 'px'; + this.shadows.r.style.top = parseInt(this.shadows.r.style.top) + 2 + 'px'; + this.shadows.b.style.left = parseInt(this.shadows.b.style.left) + 2 + 'px'; + this.shadows.r.style.left = parseInt(this.shadows.r.style.left) + 2 + 'px'; + + this.winContainer.style.top = '-3px'; + this.winContainer.style.left = '-2px'; + this.winContainer.style.width = parseInt(this.winContainer.style.width) + 8 + 'px'; + this.winContainer.style.height = parseInt(this.winContainer.style.height) + 10 + 'px'; + } + else + { + this.border.t.style.width = '0px'; + this.border.b.style.width = '0px'; + this.border.l.style.width = '0px'; + this.border.r.style.width = '0px'; + } + + //JsLib.postponeFunction(function(){_this._createWin();}); + this._createWin(); + } + + dJSWin.prototype.open = function() + { + this.moveTo(document.body.offsetWidth/2 + document.body.scrollLeft - dd.elements[this.title.id].w/2, + document.body.offsetHeight/2 + document.body.scrollTop - dd.elements[this.winContainer.id].h/2); + + dd.elements[this.title.id].maximizeZ(); + dd.elements[this.title.id].show(); + } + + dJSWin.prototype.draw = function() + { + if (this.drawn) + { + return; + } + + this.drawn = true; + + if (dd.elements && dd.elements[this.title.id]) + { + return; + } + + ADD_DHTML(this.title.id+CURSOR_MOVE); + ADD_DHTML(this.title_text_cont.id+NO_DRAG); + ADD_DHTML(this.winContainer.id+NO_DRAG); + ADD_DHTML(this.clientArea.id+NO_DRAG); + ADD_DHTML(this.buttons.xDIV.id+NO_DRAG); + ADD_DHTML(this.content.id+NO_DRAG); + ADD_DHTML(this.shadows.r.id+NO_DRAG); + ADD_DHTML(this.shadows.b.id+NO_DRAG); + ADD_DHTML(this.border.t.id+NO_DRAG); + ADD_DHTML(this.border.b.id+NO_DRAG); + ADD_DHTML(this.border.l.id+NO_DRAG); + ADD_DHTML(this.border.r.id+NO_DRAG); + + + dd.elements[this.winContainer.id].setZ(-1); + dd.elements[this.title.id].setZ(0); + dd.elements[this.title.id].addChild(dd.elements[this.title_text_cont.id]); + dd.elements[this.title.id].addChild(dd.elements[this.winContainer.id]); + dd.elements[this.title.id].addChild(dd.elements[this.clientArea.id]); + dd.elements[this.title.id].addChild(dd.elements[this.buttons.xDIV.id]); + dd.elements[this.title.id].addChild(dd.elements[this.content.id]); + dd.elements[this.title.id].addChild(dd.elements[this.shadows.r.id]); + dd.elements[this.title.id].addChild(dd.elements[this.shadows.b.id]); + dd.elements[this.title.id].addChild(dd.elements[this.border.t.id]); + dd.elements[this.title.id].addChild(dd.elements[this.border.b.id]); + dd.elements[this.title.id].addChild(dd.elements[this.border.l.id]); + dd.elements[this.title.id].addChild(dd.elements[this.border.r.id]); + + + if (typeof(this.includedContents) == 'object') + { + for (var i in this.includedContents) + { + ADD_DHTML(this.includedContents[i]+NO_DRAG); + dd.elements[this.title.id].addChild(dd.elements[this.includedContents[i]]); + } + } + + dd.elements[this.title.id].moveTo(document.body.offsetWidth/2 - dd.elements[this.winContainer.id].w/2, + document.body.offsetHeight/2 - dd.elements[this.winContainer.id].h/2) + + dd.elements[this.title.id].hide(); + } + + dJSWin.prototype._createWin = function() + { + style = document.createElement('link'); + style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dJSWin/dJSWin.css"; + style.rel = "stylesheet"; + style.type = "text/css"; + document.body.appendChild(style); + + this.content = Element(this.content_id); + this.content.style.visibility = 'hidden'; + //this.content.style.top = parseInt(this.title.style.height) + 'px'; + this.content.style.top = '0px'; + this.content.style.left = '0px'; + + this.title.appendChild(this.title_text_cont); + this.title.appendChild(this.winContainer); + this.title.appendChild(this.clientArea); + this.title.appendChild(this.buttons.xDIV); + this.title.appendChild(this.border.t); + this.title.appendChild(this.border.b); + this.title.appendChild(this.border.l); + this.title.appendChild(this.border.r); + this.title.appendChild(this.shadows.r); + this.title.appendChild(this.shadows.b); + this.clientArea.appendChild(this.content); + + document.body.appendChild(this.title); + + this.draw(); + } diff --git a/phpgwapi/js/dTabs/dTabs.css b/phpgwapi/js/dTabs/dTabs.css new file mode 100644 index 0000000000..5eba21848e --- /dev/null +++ b/phpgwapi/js/dTabs/dTabs.css @@ -0,0 +1,54 @@ +.dTabs_noTabs +{ + background-color: #a3a3a3; + width: '100%'; +} + +.dTabs_selected +{ + background-color: #e3e3e3; + color: black; + font-weight: bold; + text-align: center; + width: 2px; + cursor: pointer; +} + +.dTabs_unselected +{ + background-color: #c9c9c9; + color: black; + font-weight: 0; + text-align: center; + width: 2px; + cursor: pointer; + cursor: hand; +} + +.dTabs_unselected:hover +{ + background-color: #c9c9c9; + color: red; + font-weight: 0; + text-align: center; + width: 2px; + cursor: pointer; + cursor: hand; +} + +.dTabs_disabled +{ + background-color: #c9c9c9; + color: #a3a3a3; + font-weight: 0; + text-align: center; + width: 2px; + cursor: hand; + cursor: pointer; +} + +.dTabs_tr_index +{ + border-spacing: 0px; + padding: 5px; +} diff --git a/phpgwapi/js/dTabs/ie/dTabs.js b/phpgwapi/js/dTabs/ie/dTabs.js new file mode 100644 index 0000000000..4bf4e6f083 --- /dev/null +++ b/phpgwapi/js/dTabs/ie/dTabs.js @@ -0,0 +1,234 @@ + /****************************************************************************\ + * Dynamic Tabs - Javascript Object * + * * + * Written by: * + * - Raphael Derosso Pereira * + * ------------------------------------------------------------------------ * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \****************************************************************************/ + + /* + * Dynamic Tabs - On-The-Fly Tabs in Javascript + * + * Usage: + * var tabs = new dTabsManager({'id':
, 'width': '498px'}); + * + * tabs.addTab({'id': , + * 'name': , + * 'selectedClass': , + * 'unselectedClass': }); + */ + + dTabsManager.prototype.init = function(params) + { + /* Attributes definition */ + this._Tabs = new Array(); + this._Tabs['root'] = null; + this._Tabs['tabIndexTR'] = null; + this._Tabs['tabIndexTDs'] = new Array(); + this._Tabs['contents'] = null; + this._Tabs['contentsDIV'] = null; + this._selectedIndex = null; + + this._nTabs = params['nTabs'] ? params['nTabs'] : 0; + this._maxTabs = params['maxTabs'] ? params['maxTabs'] : 0; + + + /* Create and insert the container */ + var table, tbody, tr, td, style; + var _this = this; + + style = document.createElement('link'); + style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dTabs/dTabs.css"; + style.rel = "stylesheet"; + style.type = "text/css"; + + this._Tabs['root'] = document.createElement('div'); + this._Tabs['root'].id = params['id']; + this._Tabs['root'].style.position = 'absolute'; + //this._Tabs['root'].style.visibility = 'hidden'; + this._Tabs['root'].style.top = '150px'; + this._Tabs['root'].style.left = '0px'; + this._Tabs['root'].style.width = params['width'] ? params['width'] : 0; + + table = document.createElement('table'); + tbody = document.createElement('tbody'); + table.style.border = '0px solid black'; + table.style.width = '100%'; + table.style.height = '100%'; + table.cellpadding = '10px'; + + this._Tabs['tabIndexTR'] = document.createElement('tr'); + this._Tabs['tabIndexTR'].style.height = '30px'; + this._Tabs['tabIndexTR'].className = 'dTabs_tr_index'; + //this._Tabs['tabIndexTR'].style.width = '100%'; + + this._Tabs['emptyTab'] = document.createElement('td'); + this._Tabs['emptyTab'].className = 'dTabs_noTabs'; + this._Tabs['emptyTab'].innerHTML = ' '; + this._Tabs['tabIndexTR'].appendChild(this._Tabs['emptyTab']); + + tr = document.createElement('tr'); + td = document.createElement('td'); + + tr.style.width = '100%'; + tr.style.height = '100%'; + + //this._Tabs['contentsDIV'] = document.createElement('div'); + //this._Tabs['contentsDIV'].style.position = 'relative'; + this._Tabs['contentsDIV'] = td; + + this._Tabs['root'].appendChild(table); + table.appendChild(tbody); + tbody.appendChild(this._Tabs['tabIndexTR']); + tbody.appendChild(tr); + tr.appendChild(td); + //td.appendChild(this._Tabs['contentsDIV']); + tr.appendChild(this._Tabs['contentsDIV']); + + this._Tabs['contents'] = new Array(); + + var create = function () + { + document.body.appendChild(style); + document.body.appendChild(_this._Tabs['root']); + _this.created = true; + } + + this.created = false; + //JsLib.postponeFunction(create); + create(); + } + + /* + @method addTab + @abstract Inserts a tab + */ + dTabsManager.prototype.addTab = function (params) + { + var _this = this; + + if (this.created) + { + return this.addTabIE(params); + } + + //JsLib.postponeFunction(function(){ _this.addTabIE(params);}); + } + + dTabsManager.prototype.addTabIE = function (params) + { + if (typeof(params) != 'object') + { + return false; + } + + if (!params['id'] || !Element(params['id']) || + Element(params['id']).tagName.toLowerCase() != 'div' || + Element(params['id']).style.position.toLowerCase() != 'absolute') + { + return false; + } + + if (this._Tabs['contents'][params['id']]) + { + this.replaceTab(params); + return; + } + + //var contents, tdIndex; + var element = Element(params['id']); + + // element.parentNode.removeChild(element); + element.style.top = parseInt(this._Tabs['tabIndexTR'].style.height) + 5 + 'px'; + element.style.left = this._Tabs['root'].style.left; + element.style.zIndex = '-1'; + + this._Tabs['contents'][params['id']] = element; + + this._Tabs.tabIndexTDs[params['id']] = document.createElement('td'); + + var _this = this; + this._Tabs.tabIndexTDs[params['id']].innerHTML = '  '+(params['name'] ? params['name'] : 'undefined')+'  '; + this._Tabs.tabIndexTDs[params['id']].selectedClassName = 'dTabs_selected'; + this._Tabs.tabIndexTDs[params['id']].unselectedClassName = 'dTabs_unselected'; + this._Tabs.tabIndexTDs[params['id']].className = 'dTabs_unselected'; + this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);}; + + /* Old Version + this._Tabs.tabIndexTDs[params['id']].innerHTML = params['name'] ? params['name'] : 'undefined'; + this._Tabs.tabIndexTDs[params['id']].selectedClassName = params['selectedClass']; + this._Tabs.tabIndexTDs[params['id']].unselectedClassName = params['unselectedClass']; + this._Tabs.tabIndexTDs[params['id']].className = params['unselectedClass']; + this._Tabs.tabIndexTDs[params['id']].onclick = function() {_this._showTab(params['id']);}; + */ + + this._Tabs.tabIndexTR.removeChild(this._Tabs['emptyTab']); + this._Tabs.tabIndexTR.appendChild(this._Tabs.tabIndexTDs[params['id']]); + this._Tabs.tabIndexTR.appendChild(this._Tabs['emptyTab']); + + this._Tabs.contentsDIV.appendChild(this._Tabs['contents'][params['id']]); + + this._nTabs++; + + if (this._nTabs == 1) + { + this._showTab(params['id']); + } + + return; + } + + dTabsManager.prototype.enableTab = function(id) + { + var _this = this; + + var enable = function() + { + if (_this._Tabs.contents[id]) + { + _this._Tabs.tabIndexTDs[id].className = 'dTabs_unselected'; + _this._Tabs.tabIndexTDs[id].onclick = function() {_this._showTab(id);}; + } + } + + if (!this.created) + { + JsLib.postponeFunction(enable); + } + else + { + enable(); + } + } + + dTabsManager.prototype.disableTab = function(id) + { + var _this = this; + + var disable = function () + { + if (_this._Tabs.contents[id]) + { + _this._Tabs.tabIndexTDs[id].className = 'dTabs_disabled'; + _this._Tabs.tabIndexTDs[id].onclick = null; + } + } + + if (!this.created) + { + JsLib.postponeFunction(disable); + } + else + { + disable(); + } + } + + /****************************************************************************\ + * Private Methods * + \****************************************************************************/ + diff --git a/phpgwapi/js/dynapi/api/ext/dragevent.js b/phpgwapi/js/dynapi/api/ext/dragevent.js new file mode 100644 index 0000000000..7f3f2cb14e --- /dev/null +++ b/phpgwapi/js/dynapi/api/ext/dragevent.js @@ -0,0 +1,306 @@ +/* + DynAPI Distribution + DragEvent Class + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. +*/ + +// DragEvent object +function DragEvent(type,src) { + this.MouseEvent = MouseEvent; + this.MouseEvent(); + this.DynEvent(); + this.isDragging = false; +}; +var p = dynapi.setPrototype('DragEvent','MouseEvent'); +p.getX=function() {return this.x}; +p.getY=function() {return this.y}; +p.getPageX=function() {return this.pageX}; +p.getPageY=function() {return this.pageY}; +p.cancelDrag=function() {this.isDragging=false}; + +//DragEvent.dragPlay=0; + +DragEvent.dragevent = new DragEvent(); + +DragEvent.lyrListener = { + onmousedown : function(e) { + var ic,o = e.getSource(); + //setup drag icon + if(o._useDragIcon && o._dragIcon) { + ic=o._dragIcon; + ic._dragOrg = o; + ic.setLocation(o.getPageX(),o.getPageY()); + ic.setSize(o.w,o.h); + // if icon is fixed width then center at pointer + if(ic.w!=o.w||ic.h!=o.h) ic.setLocation(e.getPageX()-(ic.w/2),e.getPageY()-(ic.h/2)); + } + DragEvent.startDrag(e,ic); + //e.preventDefault(); + } +}; + +DragEvent.startDrag = function(e,dlyr) { + var origdlyr = dlyr; + if (!dlyr) dlyr = e.getSource(); + + if (dynapi.ua.dom) { + dlyr.elm.ondragstart = function() { return false; }; + dlyr.elm.onselectstart = function() { return false; }; + } + + // Initialize dragEvent object + var de=DragEvent.dragevent; + //de.bubble = true; + de.src = dlyr; + de.origin = (origdlyr)? e.origin : dlyr; + de.x = e.getPageX()-dlyr.getPageX(); + de.y = e.getPageY()-dlyr.getPageY(); + de.pageX = e.getPageX(); + de.pageY = e.getPageY(); + de.parentPageX = dlyr.parent.getPageX(); + de.parentPageY = dlyr.parent.getPageY(); + de._mouseEvent = e._mouseEvent; + de._browserEvent = e._browserEvent; // ns4 only + + de.isDragging = true; + + e.preventDefault(); + e.preventBubble(); + + //dlyr._dyndoc.addEventListener(DragEvent.docListener); + + dlyr.invokeEvent("dragstart",de); + if(dlyr._dragOrg) { + dlyr.setVisible(true); + dlyr._dragOrg.invokeEvent("dragstart",e); + } +}; + +DragEvent.docListener = { + onmousemove : function(e) { + //var x = e.getPageX(); + //var y = e.getPageY(); + //dynapi.debug.status('drag move '+e.x+' '+e.y); + + var de = DragEvent.dragevent; + if (de && de.isDragging) { + + + var lyr = de.src; + if (!lyr) return; + + // DS: what is this? + // Detect if we should start the drag + /*if(DragEvent.dragPlay==0 || (Math.abs(de.pageX-e.getPageX())-DragEvent.dragPlay>0) || (Math.abs(de.pageY-e.getPageY())-DragEvent.dragPlay>0)) { + de.isDragging=true; + de.src.invokeEvent("dragstart",de); + e.setBubble(de.bubble); + } + */ + /*else if (!de.dragEnabled) { + // This allows 'cancelDrag' method to fire the mouseUp as if had been released by the user + lyr.invokeEvent("mouseup"); + return; + }*/ + + // Properties + de.type="dragmove"; + de.pageX=e.getPageX(); + de.pageY=e.getPageY(); + de._mouseEvent = e._mouseEvent; + de._browserEvent = e._browserEvent; // ns4 only + + /*if (DragEvent.stopAtDocumentEdge) { + if (de.pageX<0) de.pageX = 0; + if (de.pageY<0) de.pageY = 0; + if (de.pageX>DynAPI.document.w) de.pageX = DynAPI.document.w; + if (de.pageY>DynAPI.document.h) de.pageY = DynAPI.document.h; + }*/ + + var x=de.pageX-de.parentPageX-de.x; + var y=de.pageY-de.parentPageY-de.y; + + // Respect boundary, if any + if (lyr._dragBoundary) { + var dB = lyr._dragBoundary; + var t = dB.top; + var r = dB.right; + var b = dB.bottom; + var l = dB.left; + // prevent choppy dragging if child is greater than parent + var pw = (lyr.parent.w>lyr.w)? lyr.parent.w-lyr.w:lyr.x; + var ph = (lyr.parent.h>lyr.h)? lyr.parent.h-lyr.h:lyr.y; + if (xpw-r) x = pw-r; + if (yph-b) y = ph-b; + } + else if (lyr._dragBoundaryA) { + var dB = lyr._dragBoundaryA; + var b=dB[2]; + var r=dB[1]; + var l=dB[3]; + var t=dB[0]; + var w=lyr.w; + var h=lyr.h; + if (xr) x=r-w; + if (yb) y=b-h; + } + // Move dragged layer + lyr.setLocation(x,y); + lyr.invokeEvent("dragmove",de); + // drag icon + if(lyr._dragOrg) { + lyr._dragOrg.invokeEvent("dragmove",e); + } + + + if (lyr._dragStealth==false && lyr.parent.DragOver) { + lyr.parent.DragOver(lyr,e.getPageX(),e.getPageY()); + } + + e.preventDefault(); + e.preventBubble(); + } + }, + onmouseup : function(e) { + // Get, if any, the currently drag in process and the layer. If none, return + var de=DragEvent.dragevent; + //de.bubble = true; + if (!de) return; + var lyr=de.src; + if (!lyr) return; + + if (!de.isDragging) { + de.type="dragend"; + de.src=null; + //e.setBubble(true); + return; + } + if (dynapi.ua.ie) lyr.doc.body.onselectstart = null; + + // Avoid click for the dragged layer ( with MouseEvent addition ) + if (dynapi.ua.def) dynapi.wasDragging=true; + if (lyr.parent.DragDrop) lyr.parent.DragDrop(lyr,e.getPageX(),e.getPageY()); + + // Properties for the event + de.type="dragend"; + de.isDragging=false; + lyr.invokeEvent("dragend",de); + // drag icon + if(lyr._dragOrg) { + lyr.setVisible(false); + lyr._dragOrg.invokeEvent("dragend",de); + } + + + // Clean drag stuff + de.src=null; + //e.preventDefault(); + e.preventBubble(); + + //lyr._dyndoc.removeEventListener(DragEvent.docListener); + } +}; +DragEvent.stopAtDocumentEdge = true; +DragEvent.setDragBoundary=function(lyr,t,r,b,l) { + if (!lyr) {dynapi.debug.print("Error: no object passed to DragEvent.setDragBoundary()"); return;} + var a=arguments; + if (a.length==0) return; + if (a.length==1) { + lyr._dragBoundary = {left:0,right:0,top:0,bottom:0}; + } + if (a.length==2) { + lyr._dragBoundary = arguments[1]; + } + else if (a.length==5) lyr._dragBoundaryA = [t,r,b,l]; +}; +DragEvent.enableDragEvents=function() { + for (var i=0;isX+s.w && chYsY+s.h) { + if ((mX>=chX && mX<=chX+ch.w) && (mY>=chY && mY<=chY+ch.h)) { + if (ch.DragDrop(s,mX,mY)) return true; + ch.invokeEvent("drop",null,s); + return true; + } + } + } + return false; +}; + +// Enable ondragover event +DynElement.prototype.DragOver=function(s,mX,mY){ + if (!this.children.length) return false; + var ch,chX,sX,sY; + for (var i in this.children) { + ch=this.children[i]; + if (!ch._hasDragEvents) ch.DragOver(s,mX,mY); + else { + chX=ch.getPageX(); + chY=ch.getPageY(); + if ((mX>=chX && mX<=chX+ch.w) && (mY>=chY && mY<=chY+ch.h)) { + if (ch.DragOver(s,mX,mY)) return true; + ch._isDragOver=true; + ch.invokeEvent("dragover",null,s); + return true; + }else if (ch._isDragOver) { + ch._isDragOver=false; + ch.invokeEvent("dragout",null,s); + } + } + } + return false; +}; + diff --git a/phpgwapi/js/dynapi/api/ext/dynkeyevent.js b/phpgwapi/js/dynapi/api/ext/dynkeyevent.js new file mode 100644 index 0000000000..3a7161b1cc --- /dev/null +++ b/phpgwapi/js/dynapi/api/ext/dynkeyevent.js @@ -0,0 +1,248 @@ +/* + DynAPI Distribution + DynKeyEvent Extensions + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + Requirements: + dynapi.api +*/ +function DynKeyEvent(type,src) { + this.DynEvent = DynEvent; + this.DynEvent(type,src); + this.charKey=null; +}; +var p=dynapi.setPrototype('DynKeyEvent','DynEvent'); +p.getKey=function() { + return this.charKey; +}; +DynKeyEvent._keyEventListener=function(e) { + var dynobj=this._dynobj; + if(!dynobj) + return true; + var dyndoc=dynobj.doc._dynobj; + if(!dyndoc) return true; + if(!e) var e=dyndoc.frame.event; + + var evt=new DynKeyEvent(e.type,dynobj); + evt.which=(e.keyCode)?e.keyCode:e.which; + var key=String.fromCharCode(evt.which).toLowerCase(); + if((key>='a'&&key<='z')||(key>='0'&&key<='9')) evt.charKey=key; + evt.spaceKey=(evt.which==32); + evt.enterKey=(evt.which==13); + evt.tabKey=(evt.which==9||evt.which==65289); + evt.leftKey=(evt.which==37||evt.which==52||evt.which==100||evt.which==65460); + evt.rightKey=(evt.which==39||evt.which==54||evt.which==102||evt.which==65462); + evt.upKey=(evt.which==38||evt.which==56||evt.which==104||evt.which==65464); + evt.downKey=(evt.which==40||evt.which==50||evt.which==98||evt.which==65458); + evt.altKey=(e.modifiers)?false:(e.altKey||e.altLeft||evt.which==18||evt.which==57388); + evt.ctrlKey=(e.modifiers)?(e.modifiers&Event.CONTROL_MASK):(e.ctrlKey||e.ctrlLeft||evt.which==17||evt.which==57391); + evt.shiftKey=(e.modifiers)?(e.modifiers&Event.SHIFT_MASK):(e.shiftKey||e.shiftLeft||evt.which==16||evt.which==57390); + + dynobj.invokeEvent(evt.type,evt); + if(evt.defaultValue==false) { + if(e.cancelBubble) e.cancelBubble=true; + if(e.stopPropagation) e.stopPropagation(); + } + return evt.defaultValue; +}; + +TabManager={}; +TabManager._c=0; // Current tab manager index. +TabManager._all=[]; +TabManager._active=false; +TabManager._activeTimeout=function() { // Prevent duplcate keydown events in NS4. + TabManager._active=true; + setTimeout('TabManager._active=false;',25); +}; +TabManager._getForm=null; +TabManager.getForm=function(p) { // Prevent default tab focus in Mozilla. + if(TabManager._getForm) return; + TabManager._getForm=p; + var html='
'; + return p.addChild(new DynLayer(html),'__lyr'); +}; +TabManager._grabFocus=function() { + var form=TabManager._getForm.__lyr; + setTimeout(form+'.doc.forms.__frm.__tab.focus();',0); +}; +TabManager._el={}; +TabManager._el.onkeydown=function(e) { + if(TabManager._getForm) { // User must have inserted TabManager form. + if(TabManager._active) return; + TabManager._activeTimeout(); + } + var i1,o1,l1,i2,o2,l2; + var nextKey=(e.tabKey||e.rightKey); + var prevKey=((e.shiftKey&&e.tabKey)||e.leftKey); + var submitKey=(e.enterKey||e.spaceKey); + i1=TabManager._c; o1=TabManager._all[i1]; l1=TabManager._all.length; + i2=o1._tabGroup._c; o2=o1._tabGroup._all[i2]; l2=o1._tabGroup._all.length; + if(nextKey||prevKey) { // Cycle group. + if(o2._hasFocusEvents) o2.setFocus(false,o2._focusBubble); + else o2.invokeEvent('blur'); + if(prevKey) i2=(i2==0)?l2-1:i2-1; + else i2=(i2==l2-1)?0:i2+1; + o2=o1._tabGroup._all[i2]; o1._tabGroup._c=i2; + if(o2._hasFocusEvents) o2.setFocus(true,o2._focusBubble); + else o2.invokeEvent('focus'); + } + else if(e.upKey||e.downKey) { // Cycle manager. + if(o2._hasFocusEvents) o2.setFocus(false,o2._focusBubble); + else o2.invokeEvent('blur'); + if(e.upKey) i1=(i1==0)?l1-1:i1-1; + else i1=(i1==l1-1)?0:i1+1; + o1=TabManager._all[i1]; TabManager._c=i1; + i2=o1._tabGroup._c; + o2=o1._tabGroup._all[i2]; + if(o2._hasFocusEvents) o2.setFocus(true,o2._focusBubble); + else o2.invokeEvent('focus'); + } else if(submitKey) { + o2.invokeEvent('submit'); + } + e.preventDefault(); + if(TabManager._getForm) TabManager._grabFocus(); +}; +DynElement.prototype.createTabManager=function() { + var p=this, c=p.children; if(!c) return; + var args=(arguments.length)?arguments:c; + var l=args.length, s; if(!l) return; + if(p._tabGroup) delete p._tabGroup; + p._tabGroup={ _c:0, _all:[] }; + for(var i=0;i