From 14f993f248ec3c7306ee6c16f50f9b4510fb2471 Mon Sep 17 00:00:00 2001 From: viniciuscb Date: Sat, 18 Jun 2005 22:09:31 +0000 Subject: [PATCH] Addition of some javascript files, for functionalities explained earlier. --- phpgwapi/js/connector/connector.js | 334 +++++++ phpgwapi/js/dynapi/api/dyndocument.js | 288 +++++++ phpgwapi/js/dynapi/api/dynlayer_base.js | 397 +++++++++ phpgwapi/js/dynapi/api/dynlayer_dom.js | 151 ++++ phpgwapi/js/dynapi/api/dynlayer_ie.js | 193 +++++ phpgwapi/js/dynapi/api/dynlayer_ns4.js | 310 +++++++ phpgwapi/js/dynapi/api/dynlayer_opera.js | 147 ++++ phpgwapi/js/dynapi/api/event.js | 369 ++++++++ phpgwapi/js/dynapi/api/mouse_dom.js | 148 ++++ phpgwapi/js/dynapi/api/mouse_ie.js | 124 +++ phpgwapi/js/dynapi/api/mouse_ns4.js | 214 +++++ phpgwapi/js/dynapi/dynapi.js | 440 ++++++++++ phpgwapi/js/dynapi/ext/blueprint.html | 27 + phpgwapi/js/dynapi/ext/debug.html | 136 +++ phpgwapi/js/dynapi/ext/debug.js | 256 ++++++ phpgwapi/js/dynapi/ext/functions.color.js | 94 ++ phpgwapi/js/dynapi/ext/functions.date.js | 126 +++ phpgwapi/js/dynapi/ext/functions.image.js | 124 +++ phpgwapi/js/dynapi/ext/functions.math.js | 85 ++ phpgwapi/js/dynapi/ext/functions.numeric.js | 83 ++ phpgwapi/js/dynapi/ext/functions.string.js | 115 +++ phpgwapi/js/dynapi/ext/functions.system.js | 87 ++ phpgwapi/js/dynapi/ext/library.html | 3 + phpgwapi/js/dynapi/ext/library.js | 232 +++++ phpgwapi/js/dynapi/ext/packages.js | 126 +++ phpgwapi/js/dynapi/fx/bezier.js | 75 ++ phpgwapi/js/dynapi/fx/circleanim.js | 91 ++ phpgwapi/js/dynapi/fx/fader.js | 69 ++ phpgwapi/js/dynapi/fx/fsound.js | 300 +++++++ phpgwapi/js/dynapi/fx/glideanim.js | 82 ++ phpgwapi/js/dynapi/fx/hoveranim.js | 63 ++ phpgwapi/js/dynapi/fx/imganim.js | 102 +++ phpgwapi/js/dynapi/fx/motionx.js | 113 +++ phpgwapi/js/dynapi/fx/pathanim.js | 96 +++ phpgwapi/js/dynapi/fx/slideanim.js | 42 + phpgwapi/js/dynapi/fx/snapx.js | 780 +++++++++++++++++ phpgwapi/js/dynapi/fx/swiper.js | 182 ++++ phpgwapi/js/dynapi/fx/textanim.js | 293 +++++++ phpgwapi/js/dynapi/fx/thread.js | 64 ++ phpgwapi/js/dynapi/fx/timerx.js | 44 + phpgwapi/js/dynapi/version.xml | 5 + phpgwapi/js/jsapi/egwCategories-plugin.js | 164 ++++ phpgwapi/js/jsapi/ie/jsapi.js | 151 ++++ phpgwapi/js/jsapi/jsapi.js | 907 ++++++++++++++++++++ phpgwapi/js/jsolait/copying.txt | 504 +++++++++++ phpgwapi/js/jsolait/doc/codecs.xhtml | 67 ++ phpgwapi/js/jsolait/doc/crypto.xhtml | 72 ++ phpgwapi/js/jsolait/doc/highlight.css | 88 ++ phpgwapi/js/jsolait/doc/html.css | 293 +++++++ phpgwapi/js/jsolait/doc/index.xhtml | 93 ++ phpgwapi/js/jsolait/doc/jsolait.xhtml | 139 +++ phpgwapi/js/jsolait/doc/jsonrpc.xhtml | 58 ++ phpgwapi/js/jsolait/doc/lang.xhtml | 98 +++ phpgwapi/js/jsolait/doc/stringformat.xhtml | 95 ++ phpgwapi/js/jsolait/doc/tutorial.xhtml | 295 +++++++ phpgwapi/js/jsolait/doc/urllib.xhtml | 101 +++ phpgwapi/js/jsolait/doc/xml.xhtml | 60 ++ phpgwapi/js/jsolait/doc/xmlrpc.xhtml | 175 ++++ phpgwapi/js/jsolait/init.js | 719 ++++++++++++++++ phpgwapi/js/jsolait/lib/codecs.js | 168 ++++ phpgwapi/js/jsolait/lib/crypto.js | 149 ++++ phpgwapi/js/jsolait/lib/jsonrpc.js | 383 +++++++++ phpgwapi/js/jsolait/lib/lang.js | 461 ++++++++++ phpgwapi/js/jsolait/lib/urllib.js | 306 +++++++ phpgwapi/js/jsolait/lib/xml.js | 247 ++++++ phpgwapi/js/jsolait/lib/xmlrpc.js | 828 ++++++++++++++++++ phpgwapi/js/jsolait/missingmixin.js | 151 ++++ phpgwapi/js/xmlrpcMsgCreator/index.html | 306 +++++++ phpgwapi/js/xmlrpcMsgCreator/xmlrpc.js | 177 ++++ 69 files changed, 14265 insertions(+) create mode 100644 phpgwapi/js/connector/connector.js create mode 100644 phpgwapi/js/dynapi/api/dyndocument.js create mode 100644 phpgwapi/js/dynapi/api/dynlayer_base.js create mode 100644 phpgwapi/js/dynapi/api/dynlayer_dom.js create mode 100644 phpgwapi/js/dynapi/api/dynlayer_ie.js create mode 100644 phpgwapi/js/dynapi/api/dynlayer_ns4.js create mode 100644 phpgwapi/js/dynapi/api/dynlayer_opera.js create mode 100644 phpgwapi/js/dynapi/api/event.js create mode 100644 phpgwapi/js/dynapi/api/mouse_dom.js create mode 100644 phpgwapi/js/dynapi/api/mouse_ie.js create mode 100644 phpgwapi/js/dynapi/api/mouse_ns4.js create mode 100644 phpgwapi/js/dynapi/dynapi.js create mode 100644 phpgwapi/js/dynapi/ext/blueprint.html create mode 100644 phpgwapi/js/dynapi/ext/debug.html create mode 100644 phpgwapi/js/dynapi/ext/debug.js create mode 100644 phpgwapi/js/dynapi/ext/functions.color.js create mode 100644 phpgwapi/js/dynapi/ext/functions.date.js create mode 100644 phpgwapi/js/dynapi/ext/functions.image.js create mode 100644 phpgwapi/js/dynapi/ext/functions.math.js create mode 100644 phpgwapi/js/dynapi/ext/functions.numeric.js create mode 100644 phpgwapi/js/dynapi/ext/functions.string.js create mode 100644 phpgwapi/js/dynapi/ext/functions.system.js create mode 100644 phpgwapi/js/dynapi/ext/library.html create mode 100644 phpgwapi/js/dynapi/ext/library.js create mode 100644 phpgwapi/js/dynapi/ext/packages.js create mode 100644 phpgwapi/js/dynapi/fx/bezier.js create mode 100644 phpgwapi/js/dynapi/fx/circleanim.js create mode 100644 phpgwapi/js/dynapi/fx/fader.js create mode 100644 phpgwapi/js/dynapi/fx/fsound.js create mode 100644 phpgwapi/js/dynapi/fx/glideanim.js create mode 100644 phpgwapi/js/dynapi/fx/hoveranim.js create mode 100644 phpgwapi/js/dynapi/fx/imganim.js create mode 100644 phpgwapi/js/dynapi/fx/motionx.js create mode 100644 phpgwapi/js/dynapi/fx/pathanim.js create mode 100644 phpgwapi/js/dynapi/fx/slideanim.js create mode 100644 phpgwapi/js/dynapi/fx/snapx.js create mode 100644 phpgwapi/js/dynapi/fx/swiper.js create mode 100644 phpgwapi/js/dynapi/fx/textanim.js create mode 100644 phpgwapi/js/dynapi/fx/thread.js create mode 100644 phpgwapi/js/dynapi/fx/timerx.js create mode 100644 phpgwapi/js/dynapi/version.xml create mode 100644 phpgwapi/js/jsapi/egwCategories-plugin.js create mode 100644 phpgwapi/js/jsapi/ie/jsapi.js create mode 100644 phpgwapi/js/jsapi/jsapi.js create mode 100644 phpgwapi/js/jsolait/copying.txt create mode 100644 phpgwapi/js/jsolait/doc/codecs.xhtml create mode 100644 phpgwapi/js/jsolait/doc/crypto.xhtml create mode 100644 phpgwapi/js/jsolait/doc/highlight.css create mode 100644 phpgwapi/js/jsolait/doc/html.css create mode 100644 phpgwapi/js/jsolait/doc/index.xhtml create mode 100644 phpgwapi/js/jsolait/doc/jsolait.xhtml create mode 100644 phpgwapi/js/jsolait/doc/jsonrpc.xhtml create mode 100644 phpgwapi/js/jsolait/doc/lang.xhtml create mode 100644 phpgwapi/js/jsolait/doc/stringformat.xhtml create mode 100644 phpgwapi/js/jsolait/doc/tutorial.xhtml create mode 100644 phpgwapi/js/jsolait/doc/urllib.xhtml create mode 100644 phpgwapi/js/jsolait/doc/xml.xhtml create mode 100644 phpgwapi/js/jsolait/doc/xmlrpc.xhtml create mode 100644 phpgwapi/js/jsolait/init.js create mode 100644 phpgwapi/js/jsolait/lib/codecs.js create mode 100644 phpgwapi/js/jsolait/lib/crypto.js create mode 100644 phpgwapi/js/jsolait/lib/jsonrpc.js create mode 100644 phpgwapi/js/jsolait/lib/lang.js create mode 100644 phpgwapi/js/jsolait/lib/urllib.js create mode 100644 phpgwapi/js/jsolait/lib/xml.js create mode 100644 phpgwapi/js/jsolait/lib/xmlrpc.js create mode 100644 phpgwapi/js/jsolait/missingmixin.js create mode 100644 phpgwapi/js/xmlrpcMsgCreator/index.html create mode 100644 phpgwapi/js/xmlrpcMsgCreator/xmlrpc.js diff --git a/phpgwapi/js/connector/connector.js b/phpgwapi/js/connector/connector.js new file mode 100644 index 0000000000..98da0d9e10 --- /dev/null +++ b/phpgwapi/js/connector/connector.js @@ -0,0 +1,334 @@ + /***************************************************************************\ + * eGroupWare - API * + * http://www.egroupware.org * + * Written by: * + * - Raphael Derosso Pereira * + * sponsored by Thyamad - http://www.thyamad.com * + * ------------------------------------------------------------------------- * + * Javascript connector (XMLHTTP object interfacing) * + * ------------------------------------------------------------------------- * + * 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. * + \***************************************************************************/ + + function cConnector() + { + /* Public Attributes */ + this.requests = new Array(); + this.progressContents = new Array(); + this.visible = false; + + var _this = this; + this.nReqs = 0; + + /* Private Attributes */ + this._progressBox = null; + this._progressHolder = document.createElement('span'); + + /* Removed display of connecting status + this.setProgressBox('loading_box',true); + this.setProgressContent(1,GLOBALS['messages']['jsapi']['connector_1']); + this.setProgressContent(2,GLOBALS['messages']['jsapi']['connector_2']); + this.setProgressContent(3,GLOBALS['messages']['jsapi']['connector_3']);*/ + + this._progressHolder.style.visibility = 'hidden'; +// this._progressHolder.style.backgroundColor = '#db7e22'; + } + + cConnector.prototype.newRequest = function (id, target, method, handler, data) + { + var _this = this; + + if (this.requests[id] && this.requests[id] != null) + { + // TODO: Study better ways to do this... + return; + + this.requests[id].abort(); + delete this.requests[id]; + + setTimeout(function() { _this.newRequest(id, target, method, handler, data); }, 100); + + return; + } + + this.nReqs++; + document.body.style.cursor = 'progress'; + + var oxmlhttp = null; + + try + { + oxmlhttp = new XMLHttpRequest(); + oxmlhttp.overrideMimeType('text/xml'); + } + catch (e) + { + try + { + oxmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); + } + catch (e1) + { + try + { + oxmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); + } + catch (e2) + { + oxmlhttp = null; + } + } + } + + if (!oxmlhttp) + { + return false; + } + + this.requests[id] = oxmlhttp; + + var _this = this; + + var sub_handler = function () + { + try + { + _this._setProgressState(oxmlhttp.readyState); + + if (oxmlhttp.readyState == 4 )//&& oxmlhttp.channel.status == 0) + { + if (!oxmlhttp || !oxmlhttp.status) + { + return; + } + + if (dynapi.debug) + { + dynapi.debug.print('\nServer Message Arrived:\n\n'+oxmlhttp.responseText+'\n\n'); + } + switch (oxmlhttp.status) + { + case 200: + if (typeof(handler) == 'function') + { + handler(oxmlhttp.responseText); + } + delete _this.requests[id]; + _this.nReqs--; + if (!_this.nReqs) document.body.style.cursor = ''; + break; + + case 404: + alert('Page Not Found!'); + break; + + default: + //alert('Some problem while accessing the server. The status is '+oxmlhttp.status); + } + } + } + catch (e) + { + _this.nReqs--; + if (!_this.nReqs) document.body.style.cursor = ''; + delete _this.requests[id]; + + // TODO: Handle of special exceptions must be made by API + + // Exception 0x80040111 => trying to access a component without permission to do so + if (e && typeof(e) == 'object' && e.result && e.result == 0x80040111) + { + return; + } + + showMessage(e); + } + } + + try + { + if (method == '' || method == 'GET') + { + if (typeof(handler) == 'function') + { + oxmlhttp.onreadystatechange = sub_handler; + } + oxmlhttp.open("GET",target,true); + oxmlhttp.send(null); + } + else if (method == 'POST') + { + if (typeof(handler) == 'function') + { + oxmlhttp.onreadystatechange = sub_handler; + } + oxmlhttp.open("POST",target, true); +// oxmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); +// viniciuscb commented here, messages should be in xmlrpc + oxmlhttp.setRequestHeader('Content-Type','text/xml'); + oxmlhttp.send(data); + //oxmlhttp.setRequestHeader('Content-Type','multipart/form-data; boundary=-----------------------------1156053686807595044986274307'); + //oxmlhttp.setRequestHeader('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'); + } + } + catch(e) + { + showMessage(e); + } + + return true; + } + + cConnector.prototype.cancelRequest = function (id) + { + if (!this.requests[id]) + { + return false; + } + + this.requests[id].abort(); + } + + cConnector.prototype.setProgressContent = function (state, content) + { + switch (state) + { + case 0: + case 'UNINITIALIZED': + this.progressContents[0] = content; + break; + + case 1: + case 'LOADING': + this.progressContents[1] = content; + break; + + case 2: + case 'LOADED': + this.progressContents[2] = content; + break; + + case 3: + case 'INTERACTIVE': + this.progressContents[3] = content; + break; + + case 4: + case 'COMPLETED': + this.progressContents[4] = content; + break; + + default: + throw('INVALID STATE!'); + } + } + + cConnector.prototype.setProgressHolder = function (holder) + { + var objHolder; + + if (typeof(holder) == 'string') + { + objHolder = Element(holder); + } + else if (typeof(holder) == 'object') + { + objHolder = holder; + } + else + { + return false; + } + + objHolder.appendChild(this._progressHolder); + } + + cConnector.prototype.setProgressBox = function (box, auto) + { + var objBox; + + if (typeof(box) == 'string') + { + objBox = Element(box); + } + else if (typeof(box) == 'object') + { + objBox = box; + } + else + { + return false; + } + + this._progressBox = objBox; + this._progressBoxAuto = auto ? true : false; + objBox.appendChild(this._progressHolder); + } + + cConnector.prototype.setVisible = function (visible) + { + this.visible = visible; + if (!visible) + { + this._progressHolder.style.visibility = 'hidden'; + } + } + + /****************************************************************************\ + * Private Methods * + \****************************************************************************/ + + cConnector.prototype._setProgressState = function (state) + { + switch (state) + { + case 0: + case 4: + if (this._progressBox != null) + { + this._progressBox.style.visibility = 'hidden'; + this._progressBox.style.zIndex = '-1'; + } + + this._progressHolder.style.visibility = 'hidden'; + this._progressHolder.style.zIndex = '-1'; + break; + + default: + if (this.visible) + { + if (this._progressBox != null) + { + if (this._progressBoxAuto) + { + if (is_ie) + { + this._progressBox.style.top = parseInt(document.body.offsetHeight)/2 + 'px'; + this._progressBox.style.left = parseInt(document.body.offsetWidth)/2 + 'px'; + } + else + { + this._progressBox.style.top = parseInt(window.innerHeight)/2 + parseInt(window.pageYOffset) - this._progressBox.style.height/2 + 'px'; + this._progressBox.style.left = parseInt(window.innerWidth)/2 + parseInt(window.pageXOffset) - this._progressBox.style.width/2 + 'px'; + } + } + this._progressBox.style.visibility = 'inherit'; + this._progressBox.style.zIndex = 1000000; + } + + this._progressHolder.style.visibility = 'inherit'; + this._progressHolder.style.zIndex = '100'; + + this._progressHolder.innerHTML = this.progressContents[state] ? this.progressContents[state] : ''; + } + } + } + + var Connector; + dynapi.onLoad(function(){ + Connector = new cConnector(); + Connector.setVisible(true); + }); diff --git a/phpgwapi/js/dynapi/api/dyndocument.js b/phpgwapi/js/dynapi/api/dyndocument.js new file mode 100644 index 0000000000..95b91ff3f2 --- /dev/null +++ b/phpgwapi/js/dynapi/api/dyndocument.js @@ -0,0 +1,288 @@ +/* + DynAPI Distribution + DynDocument Class + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynElement +*/ + +function DynDocument(frame) { + this.DynElement = DynElement; + this.DynElement(); + this.frame = frame; + this.doc = this.frame.document; + this._dyndoc = this; + this.x = 0; + this.y = 0; + this.w = 0; + this.h = 0; + this._topZIndex = 10000; + var o = this; + this.frame.onresize = function() {o._handleResize()}; + this.onResizeNS4 = "reload"; // or "redraw" + this._created = false; +}; +var p = dynapi.setPrototype('DynDocument','DynElement'); +p._remove = function() { + this.elm=null; + this.doc=null; + this.frame=null; +}; +p.getBgColor = function() { + return this.bgColor; +}; +p.getX = p.getY = p.getPageX = p.getPageY = dynapi.functions.Zero; +p.getWidth = function() { + if (!this.w) this.findDimensions(); + return this.w; +}; +p.getHeight = function() { + if (!this.h) this.findDimensions(); + return this.h; +}; +p.getXScroll = function () +{ + return (dynapi.ua.ns)? this.frame.pageXOffset : this.elm.scrollLeft; +} +p.getYScroll = function () +{ + return (dynapi.ua.ns)? this.frame.pageYOffset : this.elm.scrollTop; +} +p.findDimensions = function() { + this.w=(dynapi.ua.ns||dynapi.ua.opera)? this.frame.innerWidth : (dynapi.ua.ie6) ? + this.doc.documentElement.clientWidth : this.elm.clientWidth; + this.h=(dynapi.ua.ns||dynapi.ua.opera)? this.frame.innerHeight : (dynapi.ua.ie6) ? + this.doc.documentElement.clientHeight : this.elm.clientHeight; +}; +p.setBgColor = function(color) { + if (color == null) color=''; + if (dynapi.ua.ns4 && color == '') color = '#ffffff'; + this.bgColor = color; + this.doc.bgColor = color; +}; +p.setFgColor = function(color) { + if (color == null) color=''; + if (dynapi.ua.ns4 && color == '') color='#ffffff'; + this.fgColor = color; + this.doc.fgColor = color; +}; +p.insertChild = function(c,pos,usebp) { // Blueprint Enabled + if (c && !c.isInline && c.parent == this) { + if(pos) c.setPosition(pos); + DynElement._flagPreCreate(c); + if(usebp) + c.isInline=c._noInlineValues=true; + else { + this.doc.write(c.getOuterHTML()); + c._inserted = true; + } + } +}; +p.insertAllChildren = function(usebp,bpSrc) { // Blueprint Enabled + var i,c,str =['']; + var ch=this.children; + for(i=0;i<\/script>'); + } + else { + this.doc.write(str.join('\n')); + this.doc.close(); + } +}; + +p._create = function() { + var ua=dynapi.ua; + this._created = true; + if (ua.ns4) { + this.css = this.doc; + this.elm = this.doc; + } + else { + this.elm = this.frame.document.body; + this.css = this.frame.document.body.style; + if (ua.ie) { + this._overflow = this.css.overflow || ''; + } + if (this._cursor) this.css.cursor = this._cursor; + } + this.elm._dynobj = this; + this.doc._dynobj = this; // DynKeyEvent needs this! + this.findDimensions(); + + this.fgColor = this.doc.fgColor||''; + this.bgColor = this.doc.bgColor||''; + + var divs; + // create divs object - speeds up DOM browsers on Win32. Linux & Mac? + if (ua.ie||ua.dom) { + divs={}; + var dv,all=(ua.ie||ua.opera)? document.all.tags('div') : document.getElementsByTagName('div'); + var i=0,l=all.length; // very important! + while (i'; + if(!this._created) hbuf[cnt]=html; + else { + elm=new Layer(0,this.frame); + elm.left=elm.top=0; + var doc=elm.document; + elm.clip.width=dynapi.document.w; + elm.clip.height=dynapi.document.h; + doc.open();doc.write(html);doc.close(); + elm.visibility = 'inherit'; + } + } + else { + var pelm=this.elm; + if(!this._created) hbuf[cnt]=html; + else { + if(ua.ie){ + pelm.insertAdjacentHTML("beforeEnd",html); + elm = pelm.children[pelm.children.length-1]; + } + else{ + var r = pelm.ownerDocument.createRange(); + r.setStartBefore(pelm); + var ptxt = r.createContextualFragment(html); + pelm.appendChild(ptxt); + elm = pelm.lastChild; + } + } + } +}; + +function main() { + if (dynapi.document==null) { + dynapi.document = new DynDocument(dynapi.frame); + if (dynapi.loaded) dynapi.document._create(); + else dynapi.onLoad(function() { + dynapi.document._create(); + }); + } +}; +if (!dynapi.loaded) main(); + diff --git a/phpgwapi/js/dynapi/api/dynlayer_base.js b/phpgwapi/js/dynapi/api/dynlayer_base.js new file mode 100644 index 0000000000..34cda4d4d9 --- /dev/null +++ b/phpgwapi/js/dynapi/api/dynlayer_base.js @@ -0,0 +1,397 @@ +/* + DynAPI Distribution + DynLayer Base/Common Class + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynDocument +*/ + +var DynLayerBase = {}; // used by library +function DynLayer(html,x,y,w,h,color,image) { + this.DynElement = DynElement; + this.DynElement(); + + if (html && typeof(html)=='object'){ // typeof more stable than constructor when creating layers from another frame + var args=html; // dictionary input + html=args.html; + x = args.x; + y = args.y; + w = args.w; + h = args.h; + color = args.color; + image = args.image; + this.z = (args.zIndex||1); + this._saveAnchor = args.anchor; + this.visible = (args.visible==false)? false:true; + this._textSelectable = (args.textSelectable==false)?false:true; + if (args.id) + this.setID(args.id,true); + } + else { + this.visible = true; + this.z = 1; + this._saveAnchor = false; + this._textSelectable = true; + } + + this.x = x||0; + this.y = y||0; + this.w = w; + this.h = h; + this.bgColor = color; + this.bgImage = image; + this.html = (html!=null)? html+'':null; // convert html to string + this.elm = null; + this.doc = null; + this.css = null; +}; +var p = dynapi.setPrototype('DynLayer','DynElement'); +p._cssBorder = ''; +p._fixBw = 0; +p._fixBh = 0; +p._adjustSize=function(){ + var aw=this._aSzW; + var ah=this._aSzH; + if(this._created && (aw||ah)) { + var i,c,w=0,h=0; + // get furthest child + for (i=0;i'+this.getInnerHTML()+''; + else { + var s,clip='',bgimage=' background-image:none;'; + if(this.bgImage!=null) bgimage=' background-image:url('+this.bgImage+');'; + if (this.clip) clip=' clip:rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px);'; + else if (this.w!=null && this.h!=null) clip=' clip:rect(0px '+(this.w+fixBw)+'px '+(this.h+fixBh)+'px 0px);'; + // modify box fix values + if (!dynapi.ua.ie && !dynapi.ua.opera) fixBw = 0; + if (!dynapi.ua.ie) fixBh = 0; + return [ + '\n
', + this.getInnerHTML(), + '
' + ].join(''); + } +}; +p.getInnerHTML=function() { //! Overwritten by NS4 + var s = ''; + var i,ch=this.children; + if (this.html!=null) s+=this.html; + if (this._blkBoardElm) s=('
'+s+'
'); + if (ch.length<50) for (i=0;ithis._maxW) w=this._maxW; + if (this._maxH && h>this._maxH) h=this._maxH; + } + var cw = (w!=null && w!=this.w); + var ch = (h!=null && h!=this.h); + if (cw) this.w = w<0? 0 : w; + if (ch) this.h = h<0? 0 : h; + if (cw||ch) { + if (this._hasAnchor) this.updateAnchor(); // update this anchor + if (this._hasChildAnchors) this._updateAnchors(); // update child anchors + if (this.css) { + if (cw) this.css.width = this.w||0; + if (ch) this.css.height = this.h||0; + if (cw || ch) { + if(this._needBoxFix) BorderManager.FixBoxModel(this,true); + else this.css.clip = 'rect(0px '+(this.w||0)+'px '+(this.h||0)+'px 0px)'; + // adjust parent size after being sized + if(this.parent._aSz) this.parent._adjustSize(); + } + if (this.updateLayout) this.updateLayout(); // what's this? + } + } + if(this._hasResizeEvents) this.invokeEvent('resize'); + return (cw||ch); +}; +p.setMaximumSize = function(w,h){ + this._maxW=w; this._maxH=h; + this._useMaxSize=(w!=h!=null); + w=(this.w>w)?w:this.w; + h=(this.h>h)? h:this.h; + this.setSize(this.w,this.h); +}; +p.setMinimumSize = function(w,h){ + this._minW=w; this._minH=h; + this._useMinSize=(w!=h!=null); + this.setSize(this.w,this.h); +}; + +p._position = 'absolute'; +p._cssPosition = ' position:absolute'; +p.setPosition = function(p){ + if(p!='static' && p!='relative' && p!='fixed' && p!='absolute') p='absolute'; + this._position=p; + if (this.css) this.css.position=p; + else this._cssPosition = ' position:'+p; +}; + +p._overflow='hidden'; +p._cssOverflow =' overflow:hidden;'; +p.getOverflow = function(){return this._overflow}; +p.setOverflow = function(s){ +// if(!s) s='default'; + this._overflow=s; + if(this.css) this.css.overflow=s; + else this._cssOverflow=' overflow:'+s+';'; +}; + +p.getAnchor = function(){ + if(!this.parent) return this._saveAnchors; + else if (this.parent._childAnchors) { + return this.parent._childAnchors[this.id]; + } +}; +p.setAnchor = function(anchor) { + if (anchor == null) { + delete this._saveAnchor; + if (this.parent && this.parent._childAnchors && this.parent._childAnchors[this.id]) delete this.parent._childAnchors[this.id]; + this._hasAnchor = false; + } + else if (this.parent) { + if (!this.parent._childAnchors) this.parent._childAnchors = {}; + var a = this.parent._childAnchors; + a[this.id] = anchor; + this.parent._updateAnchor(this.id); + this._hasAnchor = this.parent._hasChildAnchors = true; + } + else this._saveAnchor = anchor; +}; +p.setX=function(x) {this.setLocation(x,null)}; +p.setY=function(y) {this.setLocation(null,y)}; +p.getX=function() {return this.x||0}; +p.getY=function() {return this.y||0}; +p.setPageX = function(x) {this.setPageLocation(x,null)}; +p.setPageY = function(y) {this.setPageLocation(null,y)}; +p.getVisible=function() {return this.visible}; +p.getZIndex=function() {return this.z}; +p.setZIndex=function(z) { + if (typeof(z)=="object") { + if (z.above) this.z = z.above.z + 1; + else if (z.below) this.z = z.below.z - 1; + else if (z.topmost && !this.parent) this.z = (DynLayer._z)? (DynLayer._z++):(DynLayer._z=1000); + else if (z.topmost) { + var topZ=10000,ch=this.parent.children; + for(var i=0;itopZ) topZ=ch[i].z; + this.parent._topZ = topZ+2; + this.z = this.parent._topZ; + } + } + else this.z = z; + if (this.css) this.css.zIndex = this.z; +}; +p.getHTML = function() {return this.html}; +p.setWidth=function(w) {this.setSize(w,null)}; +p.setHeight=function(h) {this.setSize(null,h)}; +p.getWidth=function() {return this.w||0}; +p.getHeight=function() {return this.h||0}; +p.getBgImage=function() {return this.bgImage}; +p.getBgColor=function() {return this.bgColor}; +p.setBgColor=function(c) { //! Overwritten by NS4 + if (c==null) c = 'transparent'; + this.bgColor = c; + if (this.css) this.css.backgroundColor = c; +}; +p.setBgImage=function(path) { //! Overwritten by NS4 + this.bgImage=path; + if (this.css) this.css.backgroundImage='url('+path+')'; +}; +p.setClip=function(clip) { //! Overwritten by NS4 + var cc=this.getClip(); + for (var i=0;i-1) { + c=c.split("rect(")[1].split(")")[0]; + c=c.replace(/(\D+)/g,',').split(","); + for (var i=0;i + if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) { + var cw = (dlyr.w==null)? dlyr.getContentWidth() : null; + var ch = (dlyr.h==null)? dlyr.getContentHeight() : null; + //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null; + //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null; + dlyr.setSize(cw,ch); + } + + var i,ch=dlyr.children; + for (i=0;i'+h+''); + elm.appendChild(ptxt); + this._blkBoardElm = elm.lastChild; + } +}; +p.setLocation=function(x,y) { + var cx = (x!=null && x!=this.x); + var cy = (y!=null && y!=this.y); + if (cx) this.x = x||0; + if (cy) this.y = y||0; + if (this.css!=null) { + if (cx) this.css.left = this.x+"px"; + if (cy) this.css.top = this.y+"px"; + // adjust parent size after being moved + if((cx||cy) && this.parent._aSz) this.parent._adjustSize(); + } + if(this._hasLocationEvents) this.invokeEvent('locationchange'); + return (cx||cy); +}; +p.setPageLocation = function(x,y) { + if (this.isChild) { + if (x!=null) x = x - this.parent.getPageX(); + if (y!=null) y = y - this.parent.getPageY(); + } + return this.setLocation(x,y); +}; +p.setHTML = function(html) { + if (html!=this.html) { + this.html = html; + if (this.css) { + var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm; + elm.innerHTML = html; + var sTmp=(this.w==null)?''+this.html+'':this.html; + while (elm.hasChildNodes()) elm.removeChild(elm.firstChild); + var r=elm.ownerDocument.createRange(); + r.selectNodeContents(elm); + r.collapse(true); + var df=r.createContextualFragment(sTmp); + elm.appendChild(df); + this._adjustSize(); + } + } + if(this._hasContentEvents) this.invokeEvent('contentchange'); +}; +p.setTextSelectable=function(b) { + this._textSelectable = b; + if(!this._hasMouseEvents) this.captureMouseEvents(); + if (!b) this.setCursor('default'); +}; +p.getCursor = function() {return (this._cursor=='pointer')? 'hand':this._cursor}; +p.setCursor = function(c) { + if (!c) c = 'default'; + else c=(c+'').toLowerCase(); + if (c=='hand') c='pointer'; + if (this._cursor!=c) { + this._cursor = c; + if (this.css) this.css.cursor = c; + } +}; +p.getContentWidth=function() { + if (this.elm==null) return 0; + else { + var p = this.parent; + var tw = this.elm.style.width; + this.css.width = "auto"; + var w = this.elm.offsetWidth; + this.css.width = tw; + return w; + }; +}; +p.getContentHeight=function() { + if (this.elm==null) return 0; + else { + var th = this.css.height; + this.elm.style.height = "auto"; + var h = this.elm.offsetHeight; + this.css.height = th; + return h; + } +}; diff --git a/phpgwapi/js/dynapi/api/dynlayer_ie.js b/phpgwapi/js/dynapi/api/dynlayer_ie.js new file mode 100644 index 0000000000..0dfe3fd0a2 --- /dev/null +++ b/phpgwapi/js/dynapi/api/dynlayer_ie.js @@ -0,0 +1,193 @@ +/* + DynAPI Distribution + DynLayer IE Specific Functions + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynLayerBase +*/ + +p = DynLayer.prototype; +p._create = function() { + if (this.parent && !this.elm) { + DynElement._flagPreCreate(this); + var elm, parentElement; + parentElement = this.parent.elm; +// if(dynapi.ua.v<5){ + parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); + elm = parentElement.children[parentElement.children.length-1]; +/* } + else { + // this method is more efficient for ie5+. any comment? + //elm=document.createElement('DIV'); + elm=this._getDOMObject(); + elm.id=this.id; + if(this._className) elm.className=this._class; + if(!this._noStyle) { + var css = elm.style; + css.position=(this._position||'absolute'); + if (this.x) css.pixelLeft = this.x; + if (this.y) css.pixelTop = this.y; + if (this.w) css.width = this.w; + if (this.h) css.height = this.h; + if (this.bgColor) css.backgroundColor = this.bgColor; + if (this.z) css.zIndex = this.z; + if (this._cursor) css.cursor = this._cursor; + if (this._overflow) css.overflow = this._overflow; + if (this.bgImage!=null) css.backgroundImage='url('+this.bgImage+')'; + //if (this.bgImage==null && this.html==null) css.backgroundImage=''; + if (this.clip) css.clip='rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px)'; + else if (this.w!=null && this.h!=null) css.clip='rect(0px '+this.w+'px '+this.h+'px 0px)'; + css.visibility=(this.visible==false)? 'hidden':'inherit'; + // border - set by BorderManager + if(this._cssBorTop){ + css.borderTop = this._cssBorTop||''; + css.borderRight = this._cssBorRight||''; + css.borderBottom = this._cssBorBottom||''; + css.borderLeft = this._cssBorLeft||''; + } + } + try { + elm.innerHTML = this.getInnerHTML(); + } + catch (e) + { + } + //alert(elm.outerHTML); + parentElement.appendChild(elm); + } +*/ DynLayer._assignElement(this,elm); + DynElement._flagCreate(this); + } +}; +p._getDOMObject = function() +{ + return document.createElement('DIV'); +} + +DynLayer._assignElement = function(dlyr,elm,divs) { + if (!elm ) { + elm = (divs)? divs[dlyr.id] : dlyr.parent.elm.all[dlyr.id]; + if (!elm){ + if(dlyr.isInline) dlyr._create(); // force create() for missing inline layer + return; + } + } + dlyr.elm = elm; + dlyr.css = elm.style; + dlyr.doc = dlyr.parent.doc; + dlyr.elm._dynobj = dlyr; + dlyr._dyndoc = dlyr.parent._dyndoc; + if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.elm.all[dlyr.id+'_blkboard']; + + // COMMENTED OUT TO PERMIT CSS PRIORITY + // by Raphael Pereira + if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) { + var cw = (dlyr.w==null)? dlyr.getContentWidth() : null; + var ch = (dlyr.h==null)? dlyr.getContentHeight() : null; + dlyr.setSize(cw,ch); + } + + var i,ch=dlyr.children; + for (i=0;i'+h+''); + this._blkBoardElm = elm.children[elm.children.length-1]; + } +}; +p.setLocation=function(x,y) { + var cx = (x!=null && x!=this.x); + var cy = (y!=null && y!=this.y); + if (cx) this.x = x||0; + if (cy) this.y = y||0; + if (this.css!=null) { + if (cx) this.css.pixelLeft = this.x; + if (cy) this.css.pixelTop = this.y; + // adjust parent size after being moved + if((cx||cy) && this.parent._aSz) this.parent._adjustSize(); + } + if(this._hasLocationEvents) this.invokeEvent('locationchange'); + return (cx||cy); +}; +p.setPageLocation = function(x,y) { + if (this.isChild) { + if (dynapi.ua.v>=5) { + if (cx) this.css.pixelLeft = this.x; + if (cy) this.css.pixelTop = this.y; + } + else { + if (cx) this.css.left = this.x+"px"; + if (cy) this.css.top = this.y+"px"; + } + } + return this.setLocation(x,y); +}; +p.setHTML = function(html) { + if (html!=this.html) { + this.html = html; + if (this.css) { + var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm; + elm.innerHTML = html; + this._adjustSize(); + } + } + if(this._hasContentEvents) this.invokeEvent('contentchange'); +}; +p.setTextSelectable=function(b) { + this._textSelectable = b; + if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny; + if (!b) this.setCursor('default'); + // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents(); +}; +p.getCursor = function() {return this._cursor}; +p.setCursor = function(c) { + if (!c) c = 'default'; + else c=(c+'').toLowerCase(); + if (this._cursor!=c) { + this._cursor = c; + if (this.css) this.css.cursor = c; + } +}; +p.getContentWidth=function() { + if (this.elm==null) return 0; + else { + var w,tw = this.css.width; + this.css.width='auto'; // force ie to get width + if (dynapi.ua.platform=="mac") w = this.elm.offsetWidth; + else w = parseInt(this.elm.scrollWidth); + this.css.width=tw; + return w; + }; +}; +p.getContentHeight=function() { + if (this.elm==null) return 0; + else { + if (dynapi.ua.platform=="mac") return this.elm.offsetHeight; + return parseInt(this.elm.scrollHeight); + + } +}; +p.setOverflow = function(s) +{ + if(!s) s=''; + this._overflow=s; + if(this.css) this.css.overflow=s; + else this._cssOverflow=' overflow:'+s+';'; +} diff --git a/phpgwapi/js/dynapi/api/dynlayer_ns4.js b/phpgwapi/js/dynapi/api/dynlayer_ns4.js new file mode 100644 index 0000000000..1bb8eb5cde --- /dev/null +++ b/phpgwapi/js/dynapi/api/dynlayer_ns4.js @@ -0,0 +1,310 @@ +/* + DynAPI Distribution + DynLayer NS4 Specific Functions + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynLayerBase +*/ + +p = DynLayer.prototype; +p._ns4IPad = ''; // used with blackboard +p._remove = function() { + if (this.elm) { + var p = this.parent; + if (p && this._alias) p[this._alias]=null; + if (!p.doc.recycled) p.doc.recycled=[]; + p.doc.recycled[p.doc.recycled.length]=this.elm; + this.elm.visibility="hide"; + this.elm = null; + if (this.releaseMouseEvents) this.releaseMouseEvents(); + if (this.releaseKeyEvents) this.releaseKeyEvents(); + } + /*this.frame = null; + this.bgImage = null; + this.bgColor = null; + this.html = null; + this.z = null; + this.w = null; + this.h = null; + this.elm = null; + this.doc = null; + this.css = null;*/ +}; +p._create = function() { + if (this.parent && !this.elm) { + DynElement._flagPreCreate(this); + var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame; + var elm = new Layer(this.w||0, parentElement); + if(this._className) elm.className=this._className; // does this work in ns4? + if(!this._noStyle) { + if (this.w) elm.clip.width = this.w+this._fixBw; + if (this.h) elm.clip.height = this.h+this._fixBh; + if (this.x && this.y) elm.moveTo(this.x,this.y); + else if (this.x) elm.left = this.x; + else if (this.y) elm.top = this.y; + if (this.bgColor!=null) elm.document.bgColor = this.bgColor; + if (this.clip) { + var c = elm.clip, cl = this.clip; + c.top=cl[0], c.right=cl[1], c.bottom=cl[2], c.left=cl[3]; + } + if (this.z) elm.zIndex = this.z; + if (this.visible) elm.visibility = 'inherit'; + } + if (this.children.length || (this.html!=null && this.html!='')) { + elm.document.write(this.getInnerHTML()); + elm.document.close(); + } + DynLayer._assignElement(this,elm); + DynElement._flagCreate(this); + } +}; +DynLayer._getLayerById = function(id,pElm){ + var i,lyrs,elm; + pElm = (pElm)? pElm:document; + lyrs = pElm.layers; + for (i=0;i, images, links, etc + } + dlyr.elm._dynobj = dlyr.doc._dynobj = dlyr; + dlyr._dyndoc = dlyr.parent._dyndoc; + + // COMMENTED OUT TO PERMIT CSS PRIORITY + // by Raphael Pereira + if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) { + var cw = (dlyr.w==null)? dlyr.getContentWidth() : null; + var ch = (dlyr.h==null)? dlyr.getContentHeight() : null; + //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null; + //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null; + dlyr.setSize(cw,ch); + } + if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage); + + var i,ch=dlyr.children; + for (i=0;i'+this.getInnerHTML()+''; + else { + if (this.clip) clip=' clip="'+this.clip[3]+','+this.clip[0]+','+this.clip[1]+','+this.clip[2]+'"'; + else clip=' clip="0,0,'+((this.w>=0)? this.w+fixBw:0)+','+((this.h>=0)? this.h+fixBh:0)+'"'; + return [ + '\n<'+tag+' ',this._cssClass,' id="'+this.id+'"', + ' left=',(this.x!=null? this.x : 0), + ' top=',(this.y!=null? this.y : 0), + ((this.visible)? ' visibility="inherit"':' visibility="hide"'), + ((this.w!=null)? ' width='+(this.w+fixBw):''), + ((this.h!=null)? ' height='+(this.h+fixBw):''), + ((this.z)? ' zindex='+this.z:''), + ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':''), + ((this.bgImage!=null)? ' background="'+this.bgImage+'"':''), + clip,'>',this.getInnerHTML(),'' + ].join(''); + } +}; +p.getInnerHTML = function() { + var i,s = '',ch=this.children; + if (this.html!=null) { + if (this.w==null) s += ''+this.html+''; + else s+=this.html; + } + if (this._blkBoardElm) s=''+this._ns4IPad+s+''; + if(ch.length<50) for (i=0;ithis._maxW) w=this._maxW; + if (this._maxH && h>this._maxH) h=this._maxH; + } + var cw = (w!=null && w!=this.w); + var ch = (h!=null && h!=this.h); + if (cw) this.w = w<0? 0 : w; + if (ch) this.h = h<0? 0 : h; + if (cw||ch) { + if (this._hasAnchor) this.updateAnchor(); // update this anchor + if (this._hasChildAnchors) this._updateAnchors(); // update child anchors + if (this.css) { + if (cw) this.css.clip.width = (this.w || 0)+this._fixBw; + if (ch) this.css.clip.height = (this.h || 0)+this._fixBh; + // adjust parent size after being sized + if((cw||ch) && this.parent._aSz) this.parent._adjustSize(); + if (this.updateLayout) this.updateLayout(); + } + } + if(this._hasResizeEvents) this.invokeEvent('resize'); + return (cw||ch); +}; +p.setHTML=function(html) { + var ch = (html!=null && html!=this.html); + if (ch) { + this.html = html; + if (this.css) { + var i, doc = this.doc; + var html=(!this._blkBoardElm)? this.html:this._ns4IPad+this.html; // don't ask why! See HTMLContainer + doc.open(); doc.write(html); doc.close(); + for (i=0;i + if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) { + var cw = (dlyr.w==null)? dlyr.getContentWidth() : null; + var ch = (dlyr.h==null)? dlyr.getContentHeight() : null; + //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null; + //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null; + dlyr.setSize(cw,ch); + } + + var i,ch=dlyr.children; + for (i=0;i'+h+''); + this._blkBoardElm = elm.children[elm.children.length-1]; + } +}; +p.setLocation=function(x,y) { + var cx = (x!=null && x!=this.x); + var cy = (y!=null && y!=this.y); + if (cx) this.x = x||0; + if (cy) this.y = y||0; + if (this.css!=null) { + if (cx) this.css.pixelLeft = this.x; + if (cy) this.css.pixelTop = this.y; + // adjust parent size after being sized + if((cx||cy) && this.parent._aSz) this.parent._adjustSize(); + } + if(this._hasLocationEvents) this.invokeEvent('locationchange'); + return (cx||cy); +}; +p.setPageLocation = function(x,y) { + if (this.isChild) { + if (dynapi.ua.v>=5) { + if (cx) this.css.pixelLeft = this.x; + if (cy) this.css.pixelTop = this.y; + } + else { + if (cx) this.css.left = this.x+"px"; + if (cy) this.css.top = this.y+"px"; + } + } + return this.setLocation(x,y); +}; +p.setHTML = function(html) { + if (html!=this.html) { + this.html = html; + if (this.css) { + var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm; + elm.innerHTML = html; + this._adjustSize(); + } + } + if(this._hasContentEvents) this.invokeEvent('contentchange'); +}; +p.setTextSelectable=function(b) { + this._textSelectable = b; + if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny; + if (!b) this.setCursor('default'); + // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents(); +}; +p.getCursor = function() {return this._cursor}; +p.setCursor = function(c) { + if (!c) c = 'default'; + else c=(c+'').toLowerCase(); + if (this._cursor!=c) { + this._cursor = c; + if (this.css) this.css.cursor = c; + } +}; +p.getContentWidth=function() { + if (this.elm==null) return 0; + else { + var tw=this.css.width; + var w,to = this.css.overflow; + this.css.width='auto'; + this.css.overflow='auto'; + w = parseInt(this.elm.scrollWidth); + this.css.width=tw; + this.css.overflow=to; + return w; + + }; +}; +p.getContentHeight=function() { + if (this.elm==null) return 0; + else { + if (dynapi.ua.platform=="mac") return this.elm.offsetHeight; + return parseInt(this.elm.scrollHeight); + } +}; diff --git a/phpgwapi/js/dynapi/api/event.js b/phpgwapi/js/dynapi/api/event.js new file mode 100644 index 0000000000..36cd9b5828 --- /dev/null +++ b/phpgwapi/js/dynapi/api/event.js @@ -0,0 +1,369 @@ +/* + DynAPI Distribution + DynEvent, EventObject, DynElement Classes + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. +*/ + +function DynEvent(type,src) { + this.type = type; + this.src = src; + this.origin = src; + this.propagate = true; + this.bubble = false; + this.bubbleChild = null; + this.defaultValue = true; +}; +var p = DynEvent.prototype; +p.getType = function() {return this.type}; +p.getSource = function() {return this.src}; +p.getOrigin=function() {return this.origin}; +p.stopPropagation = function() {this.propagate = false}; +p.preventBubble = function() {this.bubble = false}; +p.preventDefault = function() {this.defaultValue = false}; +p.getBubbleChild = function() {return this.bubbleChild}; + +function EventObject() { + this.DynObject = DynObject; + this.DynObject(); + this._listeners = []; +}; +EventObject._SubClass={}; + +p = dynapi.setPrototype('EventObject','DynObject'); +p.addEventListener = function(el) { + if (el) { + for (var i=0;i=ch.length) break; + } + }; + ch.length = 0; + this._aSz = aSz; + if(this._aSz) this._adjustSize(); // adjust size if necessary +}; +p.deleteChild = function(c) { // removes & destroy child + var l = this.children.length; + for (var i=0;i0 && a.left && typeof(a.left)=='string')? tw*(parseInt(a.left)/100):a.left; + var aright=(tw>0 && a.right && typeof(a.right)=='string')? tw*(parseInt(a.right)/100):a.right; + var atop=(th>0 && a.top && typeof(a.top)=='string')? th*(parseInt(a.top)/100):a.top; + var abottom=(th>0 && a.bottom && typeof(a.bottom)=='string')? th*(parseInt(a.bottom)/100):a.bottom; + var x = aleft; + var y = atop; + + + var w = null; + var h = null; + var dlyrWidth=dlyr.getWidth(); + var dlyrHeight=dlyr.getHeight(); + if (a.stretchH!=null) { + if(typeof(a.stretchH)!='string') w=a.stretchH; + else { + if(a.stretchH=='*') w = tw - ((aleft!=null)? aleft:0); + else w = tw*(parseInt(a.stretchH)/100); + } + dlyrWidth=w; + } + if (a.centerH!=null) { + x = Math.ceil(tw/2 - dlyrWidth/2 + a.centerH); + }else if (aright!=null) { + if (aleft!=null) w = (tw - aright) - aleft; + else x = (tw - dlyrWidth) - aright; + if(tw<=0 && x<0) x=null; // ns4 needs x>=0 + } + if (a.stretchV!=null) { + if(typeof(a.stretchV)!='string') h=a.stretchV; + else { + if(a.stretchV=='*') h = th - ((atop!=null)? atop:0); + else h = th*(parseInt(a.stretchV)/100); + } + dlyrHeight=h; + } + if (a.centerV!=null) { + y = Math.ceil(th/2 - dlyrHeight/2 + a.centerV); + }else if (abottom!=null) { + if (atop!=null) h = (th - abottom) - atop; + else y = (th - dlyrHeight) - abottom; + if(th<=0 && y<0) y=null; // ns4 needs y>=0 + } + if(padX) {x=(x)? x:0;x+=padX} + if(padY) {y=(y)? y:0;y+=padY} + + // IE seems to be getting wrong position + if (dynapi.ua.ie) + { +/* aleft += 10; + aright += 10; + atop += 10; + abottom += 10;*/ + x += 7; + y += 14; + } + var tmp=dlyr._hasAnchor; + dlyr._hasAnchor=false; // ignore anchor updates of this layer + if(x!=null||y!=null) dlyr.setLocation(x,y); + if(w!=null||h!=null) dlyr.setSize(w,h); + dlyr._hasAnchor = tmp; // useful for preventing stack overflow +}; +p._updateAnchors = function() { + var tw = this.w; + var th = this.h; + if (tw==null && th==null) return; + for (id in this._childAnchors) this._updateAnchor(id); +}; + + +// Bandwidth timer stop +var ua=dynapi.ua; ua._bwe=new Date; +ua.broadband=((ua._bwe-ua._bws)<=1500)? true:false; diff --git a/phpgwapi/js/dynapi/api/mouse_dom.js b/phpgwapi/js/dynapi/api/mouse_dom.js new file mode 100644 index 0000000000..3023f65345 --- /dev/null +++ b/phpgwapi/js/dynapi/api/mouse_dom.js @@ -0,0 +1,148 @@ +/* + DynAPI Distribution + MouseEvent Class + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynDocument +*/ + +function MouseEvent(dyndoc) { + this.DynEvent = DynEvent; + this.DynEvent(); + this.bubble = true; + this._mouseEvent = null; + this._relative = null; + this._dyndoc = dyndoc; +}; +var p = dynapi.setPrototype('MouseEvent','DynEvent'); +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.trapMouseUp = dynapi.functions.Null; +p.getRelative = function() {return this._relative}; +p.preventBubble = function() { + this.bubble = false; +}; +p.getButton = function() { + if (!this._mouseEvent) return "left"; + var b = this._mouseEvent.which; + if (b==2) return "middle"; + if (b==3) return "right"; + else return "left"; +}; +p._init = function(type,e,src) { + this.type = type; + this._mouseEvent = e; + this.origin = src; + this.bubbleChild = null; + this.defaultValue = true; + this.bubble = true; +}; +p._invoke = function() { + var o = this.origin; + o.invokeEvent(this.type,this); +}; +MouseEvent._getContainerLayerOf = function(element) { + try{ + if (!element) return null; + while (!element._dynobj && element.parentNode && element.parentNode!=element) { + element = element.parentNode; + } + return element._dynobj; + } + catch(e) + { + //FIXME: For some wierd reason, a InputElement is parent of a DIV + // and then it falls here. For now, the error is ignored + } +}; +MouseEvent._eventHandler = function(e) { + var dynobj = this._dynobj; + if (!dynobj) return true; + var dyndoc = dynobj._dyndoc; + var target = e.target; + + var me = dyndoc._mouseEvent; + var src = MouseEvent._getContainerLayerOf(target); + me._init(e.type,e,src); + var rel = e.relatedTarget; + var r = me._relative = MouseEvent._getContainerLayerOf(rel); + if (e.type=="mouseout" || e.type=="mouseover") { + if(!r && dynapi.ua.opera) return; //fix for #15 + if (r && (r==src||src.isParentOf(r))) return; // fix for #15 + if (r && (r==src.parent||r.isChildOf(src.parent))) me.bubble=false; + } + me.pageX = e.clientX; + me.pageY = e.clientY; + if(!src) return; + me.x = (me.pageX+(window.pageXOffset||0)) - src.getPageX(); //offsetX; + me.y = (me.pageY+(window.pageYOffset||0)) - src.getPageY(); //offsetY; + + // NOTE: This is done because in Mozilla, when adding event listeners + // to document element, 'title' properties doesn't work anymore... + // raphaelpereira@users.sourceforge.net + if (src.getClassName() != 'DynDocument') e.cancelBubble = true; + + me._invoke(); + + var tn=(target.tagName+'').toLowerCase(); + + // fix for form elements inside drag-enabled layer #08 + if(e.type=='mousedown' && tn=='input'||tn=='textarea'||tn=='button') { + var de=dynapi.frame.DragEvent; + de=(de && de.dragevent)? de.dragevent:null; + if(de && de.isDragging) de.cancelDrag(); + } + + // prevent image dragging + if(tn=='img' && typeof(target.onmousedown)!="function") { + target.onmousedown=dynapi.functions.False; + } + + // disable text select + if (e.type=='mousedown' && src._textSelectable==false) { + e.preventDefault(); + return false; + } + +}; + +DynElement.prototype.disableContextMenu = function(){ + this._noContextMenu = true; + if(this.elm) this.elm.addEventListener("contextmenu",MouseEvent._eventHandler,false); +}; +DynElement.prototype.captureMouseEvents = function() { + this._hasMouseEvents = true; + var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm; + + if(elm) { + elm.addEventListener("mousemove",MouseEvent._eventHandler,false); + elm.addEventListener("mousedown",MouseEvent._eventHandler,false); + elm.addEventListener("mouseup",MouseEvent._eventHandler,false); + elm.addEventListener("mouseover",MouseEvent._eventHandler,false); + elm.addEventListener("mouseout",MouseEvent._eventHandler,false); + elm.addEventListener("click",MouseEvent._eventHandler,false); + elm.addEventListener("dblclick",MouseEvent._eventHandler,false); + if(this._noContextMenu) elm.addEventListener("contextmenu",MouseEvent._eventHandler,false); + } +}; +DynElement.prototype.releaseMouseEvents=function() { + this._hasMouseEvents = false; + var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm; + if (typeof(elm)=='object') { + /* elm.removeEventListener("mousemove",MouseEvent._eventHandler,false); + elm.removeEventListener("mousedown",MouseEvent._eventHandler,false); + elm.removeEventListener("mouseup",MouseEvent._eventHandler,false); + elm.removeEventListener("mouseover",MouseEvent._eventHandler,false); + elm.removeEventListener("mouseout",MouseEvent._eventHandler,false); + elm.removeEventListener("click",MouseEvent._eventHandler,false); + elm.removeEventListener("dblclick",MouseEvent._eventHandler,false);*/ + } +}; + +function main_mouse_dom() { + dynapi.document._mouseEvent = new MouseEvent(dynapi.document); +}; +if (!dynapi.loaded) main_mouse_dom(); diff --git a/phpgwapi/js/dynapi/api/mouse_ie.js b/phpgwapi/js/dynapi/api/mouse_ie.js new file mode 100644 index 0000000000..a738a3a611 --- /dev/null +++ b/phpgwapi/js/dynapi/api/mouse_ie.js @@ -0,0 +1,124 @@ +/* + DynAPI Distribution + MouseEvent Class + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynDocument +*/ + +function MouseEvent(dyndoc) { + this.DynEvent = DynEvent; + this.DynEvent(); + this.bubble = true; + this._mouseEvent = null; + this._relative = null; + this._dyndoc = dyndoc; +}; +var p = dynapi.setPrototype('MouseEvent','DynEvent'); +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.getRelative = function() {return this._relative}; +p.preventBubble = function() {this.bubble = false;}; +p.getButton = function() { + if (!this._mouseEvent) return "left"; + var b = this._mouseEvent.button; + if (b==4) return "middle"; + if (b==2) return "right"; + else return "left"; +}; +p._init = function(type,e,src) { + this.type = type; + this._mouseEvent = e; + this.origin = src; + this.bubbleChild = null; + this.defaultValue = true; + this.bubble = true; +}; +p._invoke = function() { + var o = this.origin; + o.invokeEvent(this.type,this); +}; + +MouseEvent._getContainerLayerOf = function(element) { + if (!element) return null; + while (!element._dynobj && element.parentElement && element.parentElement!=element) { + element = element.parentElement; + } + return element._dynobj; +}; +//MouseEvent.trapMouseUp = dynapi.functions.False; // or MouseEvent.trapMouseUp=null + +MouseEvent._eventHandler = function() { + var e = dynapi.frame.event; + var dynobj; + if (this._dynobj) dynobj = this._dynobj; + else if (e.srcElement._dynobj) dynobj = e.srcElement._dynobj; + else dynobj = dynapi.document; + + var dyndoc = dynobj._dyndoc; + var target = e.srcElement; + + var me = dyndoc._mouseEvent; + var src = MouseEvent._getContainerLayerOf(target); + me._init(e.type,e,src); + + var rel = e.type=="mouseout"? e.toElement : e.fromElement; + var r = me._relative = MouseEvent._getContainerLayerOf(rel); + if (e.type=="mouseout" || e.type=="mouseover") { + if (r && src && (r==src||src.isParentOf(r))) return; //fix for #15 (ie only) + if (r && src && (r==src.parent||r.isChildOf(src.parent))) me.bubble=false; + } + me.pageX = e.clientX; + me.pageY = e.clientY; + if(!src) return; + me.x = (me.pageX + (document.body.scrollLeft||0)) - src.getPageX(); //offsetX; + me.y = (me.pageY + (document.body.scrollTop||0)) - src.getPageY(); //offsetY; + e.cancelBubble = true; + me._invoke(); + + var tt=target.type; + var tn=(target.tagName+'').toLowerCase(); + + // fix for form elements inside drag-enabled layer #08 + if(tt=='textarea'||tt=='text' && target.onselectstart==null) target.onselectstart = dynapi.functions.Allow; + if(e.type=='mousedown' && tn=='input'||tn=='textarea'||tn=='button') { + var de=dynapi.frame.DragEvent; + de=(de && de.dragevent)? de.dragevent:null; + if(de && de.isDragging) de.cancelDrag(); + } + + // prevent image dragging + if(target.tagName=='IMG' && typeof(target.ondragstart)!="function") { + target.ondragstart=dynapi.functions.False; + } + +}; + +DynElement.prototype.disableContextMenu = function(){ + this._noContextMenu = true; + if(this.elm) this.elm.oncontextmenu = dynapi.functions.False; +}; +DynElement.prototype.captureMouseEvents = function() { + this._hasMouseEvents = true; + if (this.elm) { + var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm; + elm.onmouseover = elm.onmouseout = elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = elm.onmousemove = MouseEvent._eventHandler; + if(this._noContextMenu) elm.oncontextmenu = dynapi.functions.False; + } +}; +DynElement.prototype.releaseMouseEvents = function() { + this._hasMouseEvents = false; + if (this.elm) { + var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm; + elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = null; + elm.oncontextmenu = null; + } +}; + +function main_mouse_ie() { + dynapi.document._mouseEvent = new MouseEvent(dynapi.document); +}; +if (!dynapi.loaded) main_mouse_ie(); diff --git a/phpgwapi/js/dynapi/api/mouse_ns4.js b/phpgwapi/js/dynapi/api/mouse_ns4.js new file mode 100644 index 0000000000..510182aa83 --- /dev/null +++ b/phpgwapi/js/dynapi/api/mouse_ns4.js @@ -0,0 +1,214 @@ +/* + DynAPI Distribution + MouseEvent Class + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. + + requires: dynapi.api.DynDocument +*/ +function MouseEvent(dyndoc) { + this.DynEvent = DynEvent; + this.DynEvent(); + this.bubble = true; + this._browserEvent = null; + this._relative = null; + this._dyndoc = dyndoc; +}; +var p = dynapi.setPrototype('MouseEvent','DynEvent'); +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.trapMouseUp = dynapi.functions.Null; +p.getRelative = function() {return this._relative}; +p.getButton = function() { + if (!this._browserEvent) return "left"; + var b = this._browserEvent.which; + if (b==2) return "middle"; + if (b==3) return "right"; + else return "left"; +}; +p._init = function(type,e,src) { + this.type = type; + this._browserEvent = e; + this.origin = src; + this.bubbleChild = null; + this.pageX = e.pageX-this._dyndoc.frame.pageXOffset; + this.pageY = e.pageY-this._dyndoc.frame.pageYOffset; + if (e.target._dynobj == src) { + this.x = e.layerX; + this.y = e.layerY; + } + else { + this.x = e.pageX - (src.pageX||0); + this.y = e.pageY - (src.pageY||0); + } + this.defaultValue = true; + this.bubble = true; +}; +p._invoke = function() { + var o = this.origin; + o.invokeEvent(this.type,this); + // synthetic click event + if (this.type=='mouseup') { + this._init('click',this._browserEvent,o); + this._invoke(); + + // synthetic dblclick event + if (dynapi.ua.other); + } +}; +function main() { + dynapi.document._mouseEvent = new MouseEvent(dynapi.document); +}; +if (!dynapi.loaded) main(); +MouseEvent._docMoveHandler = function(e) { + var dyndoc = this._dynobj; + var src = e.target; + var dynobj = src._dynobj || src._dynobji; + + if (!dynobj || !dynobj._hasMouseEvents) { + var rel=dyndoc._moveOver; + if(rel && dynobj && !dynobj.isChildOf(rel)) { + var me = dyndoc._mouseEvent; + me._init('mouseout',e,rel); + me._invoke(); + dyndoc._moveOver = null; + } + if(dynobj){ + dynobj=dynobj.parent; + while (dynobj && !dynobj._hasMouseEvents){ + dynobj=dynobj.parent; + } + } + if(!dynobj) return true; + } + + var me = dyndoc._mouseEvent; + //dynapi.debug.status('move '+dynobj.name+' '+e.layerX+' '+e.layerY); + me._init('mousemove',e,dynobj); + me._invoke(); + var defaultVal = me.defaultValue; + + // synthetic mouseover/out events + if (dyndoc._moveOver!=dynobj) { + var rel = dyndoc._moveOver; + //var bubble = true; + // mouse out + if (rel && !dynobj.isChildOf(rel)) { // && !rel.isChildOf(dynobj) + // during mouseout e.getRelated() is which elm it is moving to + //bubble = !dynobj.isChildOf(rel); + me._init('mouseout',e,rel); + //prevent bubbling from child to parent for mouseout + if (rel.isChildOf(dynobj)) me.bubble=false; + me._relative = dynobj; + me._invoke(); + //MouseEvent._generateEvent('mouseout',e,me,rel,dynobj,bubble); // out occurs before over + } + // mouse over + dyndoc._moveOver = dynobj; + //if (rel) var bubble = !rel.isChildOf(dynobj); + //var bubble = !dynobj.isChildOf(rel); + // during mouseover e.getRelated() is which elm it is moving to + if(!rel || !rel.isChildOf(dynobj)){ + me._init('mouseover',e,dynobj); + //prevent bubbling from child to parent for mouseover + if(dynobj.isChildOf(rel)) me.bubble=false; + me._relative = rel; + me._invoke(); + } + //MouseEvent._generateEvent('mouseover',e,me,dynobj,rel); + } + // prevent image dragging + if (e.type=="mousemove" && (e.target+'')=='[object Image]') { + me.defaultValue = defaultVal = false; + } + + return defaultVal; +}; +MouseEvent._eventHandler = function(e) { + var src = e.target; + var dynobj = this._dynobj; + if (!dynobj) return true; + + var dyndoc = dynobj._dyndoc; + var me = dyndoc._mouseEvent; + me._wasHandled = false; + var r = routeEvent(e); + if (!me._wasHandled) { + //if (src._dynobji) { // src._dynobji == dynlayer.doc.images[x]._dynobji + // me._init(e.type,e,src._dynobji); + // if (e.type=='mousedown') me.defaultValue = false; + // me._invoke(); + //} + // else + if (src._dynobj) { // src._dynobj == dynlayer.doc._dynobj,dynlayer.doc.images[x]._dynobj,dynlayer.doc.links[x]._dynobj + me._init(e.type,e,src._dynobj); + me._invoke(); + } + else { // dynobj == dynlayer.elm._dynobj + me._init(e.type,e,dynobj); + me._invoke(); + } + me._wasHandled = true; + } + dynobj = (src._dynobj)? src._dynobj:dynobj; + if (e.type=='mousedown'){ + // disable text select + if(dynobj._textSelectable==false) { + // ns4 will disable hyperlinks. this is my workaround + me.defaultValue =(e.target.href)? null:false; + } + + // allow images () to be clicked + if ((e.target+'')=='[object Image]') { + me.defaultValue = true; + } + + // allow form elements to be selected + var t = (e.target.type+'').toLowerCase(); + if (t=='button'||t=='checkbox'||t=='radio') { + me.defaultValue=true; + } + } + + return me.defaultValue; +}; +DynElement.prototype.disableContextMenu = function(){ + this._noContextMenu = true; + // can this be done in ns? +}; +DynElement.prototype.captureMouseEvents = function() { + this._hasMouseEvents = true; + var elm = this.elm; + if (elm) { + elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.DBLCLICK); + elm.onmousedown = elm.onmouseup = elm.ondblclick = MouseEvent._eventHandler; + + if (this.getClassName()=='DynDocument') { // move/over/out events are generated from the document + this.doc.captureEvents(Event.MOUSEMOVE); + elm.onmousemove = MouseEvent._docMoveHandler; + } + elm._dynobj = this; + this.doc._dynobj = this; + if(this._blkBoardElm) this.elm.document._dynobj = this; + for (var i=0;i-1; // always check for safari & opera + this.opera = ua.indexOf("opera")>-1; // before ns or ie + this.ns = !this.opera && !this.safari && (b=="Netscape"); + this.ie = !this.opera && (b=="Microsoft Internet Explorer"); + this.gecko = ua.indexOf('gecko')>-1; // check for gecko engine + if (this.ns) { + this.ns4 = (this.v==4); + this.ns6 = (this.v>=5); + this.b = "Netscape"; + }else if (this.ie) { + this.ie4 = this.ie5 = this.ie55 = this.ie6 = false; + if (v.indexOf('MSIE 4')>0) {this.ie4 = true; this.v = 4;} + else if (v.indexOf('MSIE 5')>0) {this.ie5 = true; this.v = 5;} + else if (v.indexOf('MSIE 5.5')>0) {this.ie55 = true; this.v = 5.5;} + else if (v.indexOf('MSIE 6')>0) {this.ie6 = true; this.v = 6;} + this.b = "MSIE"; + }else if (this.opera) { + this.v=parseInt(ua.substr(ua.indexOf("opera")+6,1)); // set opera version + this.opera6=(this.v>=6); + this.opera7=(this.v>=7); + this.b = "Opera"; + }else if (this.safari) { + this.ns6 = (this.v>=5); // ns6 compatible correct? + this.b = "Safari"; + } + this.dom = (document.createElement && document.appendChild && document.getElementsByTagName)? true : false; + this.def = (this.ie||this.dom); + this.win32 = ua.indexOf("win")>-1; + this.mac = ua.indexOf("mac")>-1; + this.other = (!this.win32 && !this.mac); + this.supported = (this.def||this.ns4||this.ns6||this.opera)? true:false; + this.broadband=false; + this._bws=new Date; // bandwidth timer start + + // Extended by Raphael Derosso Pereira + this.ua = this.safari ? 'safari' : this.opera ? 'opera' : this.ie ? 'ie' : this.gecko ? 'gecko' : this.ns ? 'ns' : 'unknown'; +}; + +function DynAPIObject() { + this.DynObject = DynObject; + this.DynObject(); + + this.version = '3.0.0 Beta 1'; + this.loaded = false; + + this.ua = new _UserAgent(); + + this._loadfn = []; + this._unloadfn = []; + var f = this.frame = window; + + var url = f.document.location.href; + url = url.substring(0,url.lastIndexOf('/')+1); + this.documentPath = url; + + var o = this; + + this.library = {}; + this.library.setPath = function(p) {o.library.path = p}; + + f.onload = function() { + o.loaded = true; + if (!o.ua.supported) return alert('Unsupported Browser. Exiting.'); + if (o.library._create) o.library._create(); // calls dynapi._onLoad() after loading necessary files + else setTimeout(o+'._onLoad()',1); + }; + f.onunload = function() { + for (var i=0;i'; + return t; +}; + +dynapi.functions = { + removeFromArray : function(array, index, id) { + // This seems to be wrong! + // Commented out by Raphael Derosso Pereira + //var which=(typeof(index)=="object")?index:array[index]; + var which = index; + if (id) delete array[which.id]; + else for (var i=0; i<\/script>'; + document.write(s); +}; + +// adds package(s) to the library +p.addPackage = function(pkg, path) { + var ps; + if (pkg.indexOf('.')) ps = pkg.split('.'); + else ps = [pkg]; + + var p = dynapi.frame; + for (var i=0;i tag for the object +p.include = function() { + var a = arguments; + if (a[0]==true) a=a[1]; // arguments used ONLY by packages.js + // buffer includes until packages(.js) are loaded + if (!this._pakLoaded) { + if(!this._buffer) this._buffer=[]; + this._buffer[this._buffer.length]=a; + return; + } + if (dynapi.loaded) this.load(a); + else { + var list = this._queue(a); + var src; + for (var i=0;i<\/script>'); + } + } +}; +p.load = p.reload = p.loadScript = p.reloadScript = function(n) { + dynapi.debug.print('Warning: dynapi.library load extensions not included'); +}; +dynapi.library = new DynAPILibrary(); + +// deprecated +var DynAPI = dynapi; diff --git a/phpgwapi/js/dynapi/ext/blueprint.html b/phpgwapi/js/dynapi/ext/blueprint.html new file mode 100644 index 0000000000..005a416bfe --- /dev/null +++ b/phpgwapi/js/dynapi/ext/blueprint.html @@ -0,0 +1,27 @@ + + +Blueprint Output + + + +
+
+
+ + + + + + + + + + +
DynAPI + Blueprint
+
+
+
+ + + diff --git a/phpgwapi/js/dynapi/ext/debug.html b/phpgwapi/js/dynapi/ext/debug.html new file mode 100644 index 0000000000..0aa5387cb2 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/debug.html @@ -0,0 +1,136 @@ + +DynAPI Debugger + + + + + + + + + diff --git a/phpgwapi/js/dynapi/ext/debug.js b/phpgwapi/js/dynapi/ext/debug.js new file mode 100644 index 0000000000..cc65c59cc1 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/debug.js @@ -0,0 +1,256 @@ +/* + DynAPI Distribution + Debugger + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. +*/ +// Note: Debugger does not have to be a DynObject - very important for blueprinted layers +function Debugger() { + this._mode='normal'; + this.win = null; + this._watch={}; + this._evalBuffer=''; + this._buffer = dynapi._debugBuffer; + dynapi._debugBuffer = ''; + // close the debug window on unload + this.closeOnUnLoad = false; + dynapi.onUnload(function() { + if (dynapi.debug.closeOnUnLoad) dynapi.debug.close(); + }); + this.open(); +} +var p = Debugger.prototype; //dynapi.setPrototype('Debugger','DynObject'); +p.close = function() { + if (this.isLoaded()) { + this.win.close(); + this.win = null; + } +}; +// error - output a browser generated error to the debug window +p.error = function(msg, url, lno) { + if (url && url.indexOf(dynapi.documentPath)==0) { + url = url.substring(dynapi.documentPath.length); + } + this.print('Error:'+ (lno? ' Line '+lno : '') +' ['+url+']\n '+msg); +}; +// evaluates an expression in the scope of the main dynapi window +p.evaluate = function(str) { + dynapi.frame.eval(str); + this.setEvalHistory(str); +}; +// get evaluation history +p.getEvalHistory=function(n){ + if(!this.isLoaded()) return; + var t,f=this.win.document.debugform; + if(n>=1) { + var lim=this.win.evalHistory.length-1; + this.win.evalIndex++; + if (this.win.evalIndex>lim) this.win.evalIndex=(lim<0)?0:lim; + t=this.win.evalHistory[this.win.evalIndex]; + if(t)f.eval.value=t; + }else if(n<=0){ + this.win.evalIndex--; + if(this.win.evalIndex<0) this.win.evalIndex=0; + t=this.win.evalHistory[this.win.evalIndex]; + if(t)f.eval.value=t; + } +}; +// lists all known properties of an object +p.inspect = function(obj,showFunctions) { + this.print('Inspecting:'); + var v; + if (typeof(obj)=='string') obj=eval(obj); + if (typeof(obj)=='object') { + for (var i in obj) { + if (obj[i]==null) v = 'null' + else if (typeof(obj[i])=='undefined') v = 'null'; + else if (typeof(obj[i])=='function') { + if (showFunctions==false) continue; + else v = '[Function]'; + } + else if (typeof(obj[i])=='object' && typeof(obj[i].length)!='undefined') v = 'Array';// ['+obj[i]+']'; + else if (typeof(obj[i])=='object') v = '[Object]'; + else v = obj[i]; + this.print(' '+i+' = '+v); + } + } + else this.print(' undefined'); +}; +p.isLoaded = function() { + return (this.win!=null && this.win.document && typeof(this.win.document.debugform)=="object"); +}; +// opens the debugger window +p.open = function() { + var p = dynapi.library.path; + if (!this.isLoaded() && p) { + // Modified by Raphael Pereira + //var url = dynapi.documentPath+p+'ext/debug.html#'; + var url = p+'ext/debug.html#'; + var w = (dynapi.ua.def||dynapi.ua.dom)? 350:355 //dynapi.ua.mac? (dynapi.ua.ie?330:300) : 350; + var h = (dynapi.ua.def||dynapi.ua.dom)? 432:485 //dynapi.ua.mac? (dynapi.ua.ie?405:365) : (dynapi.ua.def||dynapi.ua.dom)? 420:476; + this.win = window.open(url,'debugwin','width='+w+',height='+h+',scrollbars=no,status=no,toolbar=no'); //,resizable=no + this.win.opener=window; + this.win.evalHistory=[]; + this.win.evalIndex=0; + this.print(); + /* dynapi.frame.onerror = function(msg, url, lno) { + dynapi.debug.error(msg, url, lno); + }; + */ + } +}; +// output text to the debug window +p.print = function(s) { + if (s==null) s = ''; + else s = s + '\n'; + if (this.isLoaded()) { + this.switchMode('normal'); + if (this._buffer != '') { // dump buffer + s = this._buffer + s; + this._buffer = ''; + } + this.win.document.debugform.print.value += s; + this._normalModeData = this.win.document.debugform.print.value; + + // Does mozilla has something like this? + if (dynapi.ua.ie) { + var po = this.win.document.debugform.print; + po.scrollTop = po.scrollHeight; + var range = po.createTextRange(); + range.collapse(false); + range.select(); + } + } + else this._buffer += s; +}; +// reloads selected javascripts, packages or html pages +p.reload=function(t){ + if (!this.isLoaded) return; + t=t+''; + if(t.substr(0,3).toLowerCase()=='go:') { + t=t.substr(3).replace(/\\/g,'/'); + dynapi.frame.location.href=t; + return; + } + var i,f=t.split(';'); + for(i=0;i1) this._watch[name]=value; + else if(dynapi.frame.eval(name)) this._watch[name]='_watch object_'; + else this._watch[name]='_watch object_'; +}; +p._disableWatch = function(){ + this._oldWatchSrc=''; + if(this._timerWatch) { + window.clearTimeout(this._timerWatch); + this._timerWatch=0; + } +}; +p._enableWatch = function(){ + if(this._mode!='watch') return; + var src,row,v; + src='Name\t \t \t Value\n---------------------------------------\n'; + for(i in this._watch){ + if(this._watch[i]=='_watch object_') v=dynapi.frame.eval(i); + else v=this._watch[i]; + if(v==null) v='null'; + if(typeof(v)=='string') v=v.replace(/\n/g,' '); + src+=(i+' ').substr(0,22)+'\t '+v+'\n'; + } + if(src!=this._oldWatchSrc){ + this.win.document.debugform.print.value=this._oldWatchSrc=src; + } + if(this._timerWatch) window.clearTimeout(this._timerWatch); + this._timerWatch=window.setTimeout(this+'._enableWatch()',200); +}; +dynapi.debug = new Debugger(); +var t='------------------------------\n' ++'Click "?" for help\n' ++'------------------------------\n'; +dynapi.debug.print(t); diff --git a/phpgwapi/js/dynapi/ext/functions.color.js b/phpgwapi/js/dynapi/ext/functions.color.js new file mode 100644 index 0000000000..15926d6336 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/functions.color.js @@ -0,0 +1,94 @@ +/* + DynAPI Distribution + dynapi.functions.Color extension +*/ + +var f = dynapi.functions; +f.Color = Color = {}; // used by dynapi.library + +// Color Functions --------------------------- + +f.DecToHex = function(val){ + lo=val%16; + val-=lo; + lo+=48; + if (lo>57) lo+=7; + hi=val/16; + hi+=48; + if (hi>57) hi+=7; + return String.fromCharCode(hi,lo); +}; +f.getColor = function(r,g,b) { + return '#'+dynapi.functions.DecToHex(r)+dynapi.functions.DecToHex(g)+dynapi.functions.DecToHex(b); +}; +f.getRandomColor = function() { + var s = ''; + for (var i=0;i<3;i++) s += dynapi.functions.DecToHex(Math.floor(255*Math.random())); + return s; +}; +f.createRedPal = function(pal) { + var r=g=b=0; + for (var i=0; i<256; i++){ + pal[i]=dynapi.functions.getColor(r,g,b); + r+=8; + if (r>255) { r=255; g+=6; b+=2; } + if (g>255) { g=255; b+=2; } + if (b>255) { b=255; } + } +}; +f.createGrayPal = function(pal) { + var r=0; + for (var i=0; i<256; i++){ + pal[i]=dynapi.functions.getColor(r,r,r); + r+=4; + if (r>255) { r=255; } + } +}; +f.createBluePal = function(pal){ + var r=g=b=0; + for (var i=0; i<256; i++){ + pal[i]=dynapi.functions.getColor(r,g,b); + b+=6; + if (b>255) { b=255; g+=2; } + if (g>255) { g=255; r+=2; } + } +}; +f.createGreenPal = function(pal) { + var r=g=b=0; + for (var i=0; i<256; i++){ + pal[i]=dynapi.functions.getColor(r,g,b); + g+=6; + if (g>255) { g=255; b+=2; } + if (b>255) { b=255; r+=2; } + } +}; +f.fadeColor = function(from, to, percent){ + if(!from || !to) return; + if(percent<0) return from; + else if(percent>100) to; + + if(from.substring(0,1)!='#') from='#'+from; + if(to.substring(0,1)!='#') to='#'+to; + + from = { + red:parseInt(from.substring(1,3),16), + green:parseInt(from.substring(3,5),16), + blue:parseInt(from.substring(5,7),16) + } + + to = { + red:parseInt(to.substring(1,3),16), + green:parseInt(to.substring(3,5),16), + blue:parseInt(to.substring(5,7),16) + } + + var r=from.red+Math.round((percent/100)*(to.red-from.red)); + var g=from.green+Math.round((percent/100)*(to.green-from.green)); + var b=from.blue+Math.round((percent/100)*(to.blue-from.blue)); + + r = (r < 16 ? '0' : '') + r.toString(16); + g = (g < 16 ? '0' : '') + g.toString(16); + b = (b < 16 ? '0' : '') + b.toString(16); + + return '#' + r + g + b; +}; diff --git a/phpgwapi/js/dynapi/ext/functions.date.js b/phpgwapi/js/dynapi/ext/functions.date.js new file mode 100644 index 0000000000..7a25a4537a --- /dev/null +++ b/phpgwapi/js/dynapi/ext/functions.date.js @@ -0,0 +1,126 @@ +/* + DynAPI Distribution + dynapi.functions.Date extension +*/ + +var f = dynapi.functions; +f.Date = {}; // used by dynapi.library + +// Date Functions -------------------------------------- + +f.dateAdd = function(interval,n,dt){ + if(!interval||!n||!dt) return; + var s=1,m=1,h=1,dd=1,i=interval; + if(i=='month'||i=='year'){ + dt=new Date(dt); + if(i=='month') dt.setMonth(dt.getMonth()+n); + if(i=='year') dt.setFullYear(dt.getFullYear()+n); + }else if (i=='second'||i=='minute'||i=='hour'||i=='day'){ + dt=Date.parse(dt); + if(isNaN(dt)) return; + if(i=='second') s=n; + if(i=='minute'){s=60;m=n} + if(i=='hour'){s=60;m=60;h=n}; + if(i=='day'){s=60;m=60;h=24;dd=n}; + dt+=((((1000*s)*m)*h)*dd); + dt=new Date(dt); + } + return dt; +}; +f.dateDiff=function(interval,dt1,dt2){ + if(!interval||!dt1||!dt2) return; + var v,s=1,m=1,h=1,dd=1,i=interval; + if(i=='month'||i=='year'){ + dt1=new Date(dt1); + dt2=new Date(dt2); + years=dt2.getFullYear()-dt1.getFullYear(); + if (i=='year') v=years; + else if(i=='month') { + v=(dt2.getMonth()+1)-(dt1.getMonth()+1); + if(years!=0) v+=(years*12); + } + }else if (i=='second'||i=='minute'||i=='hour'||i=='day'){ + dt1=Date.parse(dt1); + dt2=Date.parse(dt2); + if(isNaN(dt1)||isNaN(dt2)) return; + v=dt2-dt1; + if(i=='second') s=1000; + if(i=='minute') s=60000; + if(i=='hour'){s=60000;m=60}; + if(i=='day'){s=60000;m=60;h=24;}; + v=((((v/s)/m)/h)/dd); + } + return v; +}; +f.formatDate = function(date,format){ + if(!date) return ''; + var dt=new Date(date); + var mm=dt.getMonth(); + var dd=dt.getDate(); + var day=dt.getDay(); + var yyyy=dt.getFullYear(); + var hh=dt.getHours(); + var nn=dt.getMinutes(); + var ss=dt.getSeconds(); + var ampm; + + var days=['Sunday','Monday','Teusday','Wednesday','Thursday','Friday','Saturday']; + var months=['January','February','March','April','May','June','July','August','September','October','November','December']; + + format=(format)? (format+'').toLowerCase():'dddd, mmmm dd, yyyy hh:nn:ss ampm'; + format=format.replace('mmmm',months[mm]); + format=format.replace('mmm',months[mm].substr(0,3)); + format=format.replace('mm',mm+1); + format=format.replace('dddd',days[day]); + format=format.replace('ddd',days[day].substr(0,3)); + format=format.replace('dd',dd); + format=format.replace('yyyy',yyyy); + if(format.indexOf('ampm')>0){ + if(hh>12) hh=hh-12; + if(hh<12) ampm='AM'; + else ampm='PM'; + format=format.replace('ampm',ampm); + } + format=format.replace('hh',hh); + format=format.replace('nn',nn); + format=format.replace('ss',ss); + + return format; +}; +f.getDayOfYear = function(dt){ + dt = new Date(dt); + if(isNaN(dt)) dt = new Date(); + var yr = new Date(dt.getFullYear(),0,1); + yr = yr.getTime() - (yr.getDay()-1)*(24*60*60*1000); + return(Math.ceil((dt.getTime() - yr)/(24*60*60*1000))); +}; +f.isDate = function(dt,format){ + if (!dt) return false; + var dd,mm,yyyy; + var isLeapYear,st=true,delim='/'; + dt+='';format=(format)? format+'':''; + if(dt.indexOf('/')>=0) delim='/'; + else if(dt.indexOf('-')>=0) delim='-'; + else if(dt.indexOf(' ')>=0) delim=' '; + dt=dt.split(delim); + if(format) format=format.replace(/\W/g,'/'); + else { + if (dt[0]>=1000) format='yyyy/mm/dd'; + else if (dt[0]>=12 && dt[1]<=12) format='dd/mm/yyyy'; + else if (dt[0]<=12 && dt[1]>=12) format='mm/dd/yyyy'; + }; + if(format=='yyyy/mm/dd'){yyyy=dt[0];mm=dt[1];dd=dt[2];} + else if(format=='mm/dd/yyyy'){mm=dt[0];dd=dt[1];yyyy=dt[2];} + else if(format=='dd/mm/yyyy'){dd=dt[0];mm=dt[1];yyyy=dt[2];} + if(isNaN(dd)||isNaN(mm)||isNaN(yyyy)) st=false; + else if(dd<1 || dd>31) st=false; + else if(yyyy>9999) st=false; + else if (mm < 1 || mm > 12) st=false; + else if((mm==4 || mm==6 || mm==9 || mm==11) && dd==31) st=false; + else if(mm==2) { // check for leap year and february 29th + isLeapYear = (yyyy % 4 == 0 && (yyyy % 100 != 0 || yyyy % 400 == 0)); + if (dd > 29 || (dd==29 && !isLeapYear)) st=false; + } + return st; +}; + diff --git a/phpgwapi/js/dynapi/ext/functions.image.js b/phpgwapi/js/dynapi/ext/functions.image.js new file mode 100644 index 0000000000..9eece6080d --- /dev/null +++ b/phpgwapi/js/dynapi/ext/functions.image.js @@ -0,0 +1,124 @@ +/* + DynAPI Distribution + dynapi.functions.Image extension +*/ + +var f = dynapi.functions; +f.Image = {}; // used by dynapi.library + +// Image Functions --------------------------- + +f._imgTTL = 30000; // Image Time To Load (ms) +f.getImage = function(src,w,h,params) { + var img,name,p=params; + if(!p) name=src; + else name=(!p.alias)? src:p.alias; + img = dynapi.ximages[name]; + if(!img || (img && img.params!=params)){ // if user enters a new set of params then create a new image object + img=dynapi.ximages[name] = (w!=null&&h!=null)? new Image(w,h) : new Image(); + img.w=w||null; + img.h=h||null; + img.src=src;img.params=p; + img.getHTML=dynapi._imageGetHTML; + img.reload=dynapi._imageReload; + img.dtStart=new Date(); + if(p) { + var f=dynapi.functions; + if(p.oversrc) f.getImage(p.oversrc); + if(p.downsrc) f.getImage(p.downsrc); + } + if(!this._imgTmr && this._imgProgFn) this._imageProgress(); + } + return img; +}; +f.getFailedImages = function(){ + var ar=[]; + for(i in dynapi.ximages){ + img=dynapi.ximages[i]; + if(img && img.failed) ar[ar.length]=img; + } + return ar; +}; +f.captureImageProgress=function(fn){ //fn = fn(completed,failed,total); + this._imgProgFn=fn; + this._imageProgress(); +}; +f._imageProgress = function(){ + var i,c=0,f=0,t=0; + var img,dtEnd = new Date; + var fn=this._imgProgFn; + for(i in dynapi.ximages){ + img=dynapi.ximages[i]; + if(img && img.complete!=null){ + t++; + img.failed=(!img.complete && (dtEnd-img.dtStart)>this._imgTTL)? true:false; + if (img.complete) c++; + else if(img.failed) f++; + } + } + if(fn) fn(c,f,t); + if(c+f'+t; + else if (dir=='S') t=t+'
'+text; + else if (dir=='E') t=t+text; + else if (dir=='W') t=text+t; + } + if(p.link) t=''+t+''; + if(xtags && p.name) dynapi._imageHookArray[p.name]=p; + return t; +}; diff --git a/phpgwapi/js/dynapi/ext/functions.math.js b/phpgwapi/js/dynapi/ext/functions.math.js new file mode 100644 index 0000000000..a58cd9f4b8 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/functions.math.js @@ -0,0 +1,85 @@ +/* + DynAPI Distribution + dynapi.functions.Math extension + + Math and Path functions +*/ + +var f = dynapi.functions; +f.Math = {}; // used by dynapi.library + +// Math Functions -------------------------- + +f.radianToDegree = function(radian) { + return radian*180/Math.PI; +}; +f.degreeToRadian = function(degree) { + return degree*Math.PI/180; +}; +f.sintable = function(lsin) { + for (var i=0; i<361; i+=1) lsin[i]=Math.sin((i/180)*Math.PI); +}; +f.costable = function(lcos) { + for (var i=0; i<361; i+=1) lcos[i]=Math.cos((i/180)*Math.PI); +}; +f.getRandomNumber = function(n) { + var t=new Date(); + n=(n)? n: parseInt(Math.random()*10000); + return Math.round((Math.abs(Math.sin(t.getTime()))*(Math.random()*1000)))%n+1; +}; +f.getGUID = function() { // Globally Unique ID + var n1,n2,n3,n4; + var l,r,m,c=Math.random()+''; + c=c.substr(c.indexOf('.')+1); + m=(c.length-1)/2; + l=c.substr(0,m); r=c.substr(m); + n1=this.getRandomNumber(1000); + n2=this.getRandomNumber(255);n3=this.getRandomNumber(255);n4=this.getRandomNumber(255); + n2 = (n2 < 16 ? '0' : '') + n2.toString(16); + n3 = (n3 < 16 ? '0' : '') + n3.toString(16); + n4 = (n4 < 16 ? '0' : '') + n4.toString(16); + return (n1+n2+'-'+l+'-'+n3+n4+'-'+r).toUpperCase(); +}; + +// Path Functions ------------------------ + +// Combines separate [x1,x2],[y1,y2] arrays into a path array [x1,y1,x2,y2] +f.interlacePaths = function (x,y) { + var l = Math.max(x.length,y.length); + var a = new Array(l*2); + for (var i=0; i=0) comma=','; + if(format.indexOf('$')>=0) symbol='$'; + else if(format.indexOf('%')>=0) symbol='%'; + s=format.split('.'); + fInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]); + fInt=fInt.split('').reverse().join(''); + fDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1]; + s=n.split('.'); + nInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]); + nInt=nInt.split('').reverse().join('');; + nDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1]; + if (nInt) len=nInt.length; + if (fInt.length>len) len=fInt.length; + for(i=0;i=0) return true; + else return false; +}; +f.isInteger=function(n){ + if(typeof(n)=='number' && (n+'').indexOf('.')<0) return true; + else return false;; +}; +f.toInteger=function(dt){ + var vl; + if(!dt) return 0; + if(isNaN(dt)) vl=parseInt((dt+'').replace(/\,/g,'')); + else vl= parseInt(dt); + if (isNaN(vl)) vl = 0; + return vl; +}; +f.toFloat=function(dt){ + var vl; + if(!dt) return 0; + if(isNaN(dt)) vl=parseFloat((dt+'').replace(/\,/g,'')); + else vl = parseFloat(dt); + if (isNaN(vl)) vl = 0; + return vl; +}; +f.toBoolean = function(dt) { + return (dt=='true'||dt>=1)? true:false; +}; + +f.isNumeric = function (n) +{ + var nReg = new RegExp('[-][[:digit:]]'); +} diff --git a/phpgwapi/js/dynapi/ext/functions.string.js b/phpgwapi/js/dynapi/ext/functions.string.js new file mode 100644 index 0000000000..b95d233bf2 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/functions.string.js @@ -0,0 +1,115 @@ +/* + DynAPI Distribution + dynapi.functions.String extension +*/ + +var f = dynapi.functions; +f.String = {}; // used by dynapi.library + + +// String Functions -------------------------------- + +f.sprintf = function(t){ + var ar = arguments; + var i=1,inx = t.indexOf("%s"); + while(inx>=0){ + t = t.substr(0, inx) + ar[i++] + t.substr(inx+2); + inx = t.indexOf("%s"); + } + return t; +}; +f.strRepeat = function(s,n) { + if(!s) return ''; + var i,a=[]; + for(i=1;i<=n;i++){ + a[a.length]=s; + } + return a.join(''); +}; +f.strReverse = function(s) { + if(!s) return ''; + var a=(s+'').split(''); + a.reverse(); + return a.join(''); +}; +f.strStuff = function(s,v,index) { + if(!s) return ''; + if (index==null) s=s+v+''; + else { + var t1=t2=s+''; + s=t1.substr(0,index)+v+t2.substr(index,t2.length-index); + } + return s; +}; +f.trim = function(s,dir){ + if(!s) return; + else s+=''; // make sure s is a string + dir=(dir)? dir:'<>'; + if(dir=='<'||dir=='<>') s=s.replace(/^(\s+)/g,''); + if(dir=='>'||dir=='<>') s=s.replace(/(\s+)$/g,''); + return s; +}; +f.limitString = function (s,max) +{ + if (!s) return s; + else s+=''; + + // Do not process HTML tags \\ + var tag = new RegExp(/[<][^>]*[>]/g); + var special = new RegExp(/[&][^;]*;/g); + var m, count=0; + var tags = new Array(); + var specials = new Array(); + + var r_s = s.replace(/[<][^>]*[>]/g,'\xFE').replace(/[&][^;]*;/g,'\xFF'); + + while (m = tag.exec(s)) + { + tags[tags.length] = m[0]; + max++; + } + + while (m = special.exec(s)) + { + specials[specials.length] = m[0]; + max += 2; + } + + var i; + var count = 0; + var r_final = ''; + for (i=0; i max) + { + r_final += '...'; + } + + for (i=0; iindex) return arguments[index+1]; +}; +f.cloneObject = function(src) { + if(!src) return; + var i,tar; + if(typeof(src)!='object') return src; + else { + if((src.constructor+'')==(Array+'')) tar=[]; + else if((src.constructor+'')==(Date+'')) return src; + else tar={}; + }; + for(i in src) { + if(typeof(src[i])!='object') tar[i]=src[i]; + else tar[i]=this.cloneObject(src[i]); + } + return tar; +}; +f.copyObject = function(from,to,noclone) { + var i; + if (to && !noclone) to=this.cloneObject(to); + else if(to && noclone) to=to; + else { + if(typeof(from)=='object') { + if((from.constructor+'')==(Array+'')) to=[]; + else if((from.constructor+'')==(Date+'')) return from; + else to={}; + }; + } + for(i in from) { + if(typeof(from[i])!='object') to[i]=from[i]; + else to[i]=this.copyObject(from[i],to[i],true); + } + return to; +}; +f.getElementById = function(id,parentLyr){ + if (document.all) return document.all[id]; + else if(document.getElementById) return document.getElementById(id); + else if(document.layers){ + var i,nLayers,layer; + parentLyr = (parentLyr)? parentLyr:document; + nLayers = parentLyr.layers; + for (i=0;i +dynapi.library._handleLoad(this); + \ No newline at end of file diff --git a/phpgwapi/js/dynapi/ext/library.js b/phpgwapi/js/dynapi/ext/library.js new file mode 100644 index 0000000000..36217d3d40 --- /dev/null +++ b/phpgwapi/js/dynapi/ext/library.js @@ -0,0 +1,232 @@ +/* + DynAPI Distribution + Dynamic Loading extension to dynapi.library + + The DynAPI Distribution is distributed under the terms of the GNU LGPL license. +*/ + +// begin loading the object +DynAPILibrary.prototype.load = function(n,fn) { + var list = this._queue(n,null,arguments[2]); + //return dynapi.debug.print('going to load: '+list); + if (list.length) { + var s,src; + for (var i=0;i<\/script>'); + this._export(src); + } + else { + var elm = s.elm = dynapi.frame.document.createElement('script'); + elm.src = rsrc; + elm.type = 'text/javascript'; + elm.defer = true; + if (dynapi.ua.ie) { + elm.C = 0; + var o = this; + elm.onreadystatechange = function() { + elm.C++; + if (elm.C==2 || elm.readyState=="complete") { // use 2nd statechange for onload + o._export(src); + } + } + } + dynapi.frame.document.getElementsByTagName('head')[0].appendChild(elm); + + // I could not find way to know when the script is complete in Moz v0.9.3 + if (dynapi.ua.ns6) setTimeout(this+'._export("'+src+'")',100); + } + } + } +}; + +// executed after a script is finished loading, run main() functions +DynAPILibrary.prototype._export = function(src) { + var src = this.loadList[this.loadIndex]; + var s = this.scripts[src]; + if (s) { + this._register(s); + + // run elm.main)() before global main() + if (dynapi.ua.ns4 && typeof(this.elm.main)=="function") { + this.elm.main(); + this.elm.main = null; + } + + // run global main() if available + if (typeof(main)=="function") { + main(); + main = null; + } + + // clear out all functions in the layer's scope + if (dynapi.ua.ns4) { + for (var i in this.elm) { + if (typeof(this.elm[i])=="function") delete this.elm[i]; + } + } + this.busy = false; + + // load next file + this._load(); + } + //else return alert('Library Error: unknown script '+src); +}; + +// registers the script as loaded, exports the objects +DynAPILibrary.prototype._register = function(s) { + //dynapi.debug.print('loaded "'+s.src+'"'); + s.loaded = true; + s.queued = false; + if (!s.unnamed) { + var n,found; + // loop through each object that the script contains + for (var i=0;i0) { + var ns = n.split('.'), o = dynapi.frame, b = false; + for (var j=0;j, NS4 only +DynAPILibrary.prototype._handleLoad = function(elm) { + var args = dynapi.functions.getURLArguments(elm.src); + var js = args["js"]; + if (js) { + js=js.replace(/\+/g,'/'); // convert + to / + if (js.indexOf('http')!=0) { + var l = dynapi.frame.document.location; + if (js.substr(0,1)=='/') js = l.port+'//'+host+src; + else js = dynapi.documentPath+js; + } + elm.document.write('