[3102] | 1 | (function() |
---|
| 2 | { |
---|
| 3 | var _xtools = null; |
---|
| 4 | var dragDrop = null; |
---|
| 5 | var path = path_jabberit; |
---|
| 6 | |
---|
| 7 | var _dialogs = [ ]; |
---|
| 8 | |
---|
| 9 | function build(pObj) |
---|
| 10 | { |
---|
| 11 | var _window = getElement( pObj.id_window + '__parent'); |
---|
| 12 | _xtools = new xtools(path); |
---|
| 13 | |
---|
| 14 | if( _window == null ) |
---|
| 15 | { |
---|
| 16 | pObj.width = ( ( pObj.width > 160 ) ? pObj.width : 160 ); |
---|
| 17 | pObj.height = ( ( pObj.height > 80 ) ? pObj.height : 80 ); |
---|
| 18 | pObj.onclick = "_winBuild('" + pObj.id_window + "', '" + pObj.closeAction + "')"; |
---|
| 19 | |
---|
| 20 | _window = document.createElement("div"); |
---|
| 21 | _window.id = pObj.id_window + "__parent"; |
---|
| 22 | _window.setAttribute("onselectstart" , "return false"); |
---|
| 23 | _window.style.width = pObj.width + "px"; |
---|
| 24 | _window.style.height = pObj.height + "px"; |
---|
| 25 | _window.style.top = pObj.top + "px"; |
---|
| 26 | _window.style.left = pObj.left + "px"; |
---|
| 27 | _window.style.position = "absolute"; |
---|
| 28 | _window.style.zIndex = pObj.zindex; |
---|
| 29 | _window.innerHTML = _xtools.parse( _xtools.xml('window_main'), 'window.xsl', pObj ); |
---|
| 30 | |
---|
| 31 | if( pObj.closeAction == "hidden" ) |
---|
| 32 | _window.setAttribute("leftOld", pObj.left + "px" ); |
---|
| 33 | |
---|
| 34 | if( pObj.leftOld ) |
---|
| 35 | _window.setAttribute("leftOld", pObj.leftOld + "px" ); |
---|
| 36 | |
---|
| 37 | window.document.body.insertBefore( _window, document.body.lastChild ); |
---|
| 38 | |
---|
| 39 | if ( pObj.content.constructor == String ) |
---|
| 40 | getElement(pObj.id_window + '__content').innerHTML = pObj.content; |
---|
| 41 | else |
---|
| 42 | getElement(pObj.id_window + '__content').appendChild( pObj.content ); |
---|
| 43 | |
---|
| 44 | _dialogs[ pObj.id_window ] = getElement(pObj.id_window + '__content').firstChild; |
---|
| 45 | |
---|
| 46 | if( pObj.draggable ) |
---|
| 47 | { |
---|
| 48 | dragDrop = new _drag_drop(); |
---|
| 49 | dragDrop.set( pObj.id_window ); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | { |
---|
| 54 | if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) ) |
---|
| 55 | return false; |
---|
| 56 | |
---|
| 57 | load(pObj.id_window, "display"); |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | function getElement(pElement) |
---|
| 62 | { |
---|
| 63 | return document.getElementById(pElement); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | function load( pId, pVisible ) |
---|
| 67 | { |
---|
| 68 | var _window = document.getElementById( pId + '__parent') |
---|
| 69 | |
---|
| 70 | if( _window != null ) |
---|
| 71 | { |
---|
| 72 | if ( pVisible == "display" ) |
---|
| 73 | { |
---|
| 74 | if( _window.style.left == "-1500px" ) |
---|
| 75 | _window.style.left = _window.getAttribute("leftOld"); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | if ( pVisible == "hidden") |
---|
| 79 | { |
---|
| 80 | _window.setAttribute("leftOld" , _window.style.left ); |
---|
| 81 | _window.style.left = "-1500px"; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | if( pVisible == "remove" ) |
---|
| 85 | { |
---|
| 86 | document.body.removeChild( _window ); |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function _window() |
---|
| 92 | { |
---|
| 93 | if( arguments.length > 0 ) |
---|
| 94 | { |
---|
| 95 | var pId = null; |
---|
| 96 | if( arguments.length == 1 ) |
---|
| 97 | { |
---|
| 98 | var obj = arguments[0]; |
---|
| 99 | pId = obj.id_window |
---|
| 100 | build(obj); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | if( arguments.length == 2 ) |
---|
| 104 | { |
---|
| 105 | load( ( pId = arguments[0] ), arguments[1]); |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | return ( new function( ) |
---|
| 110 | { |
---|
| 111 | this.content = function( ) |
---|
| 112 | { |
---|
| 113 | if ( arguments.length ) |
---|
| 114 | getElement( pId + '__content').appendChild( _dialogs[ pId ] ); |
---|
| 115 | |
---|
| 116 | return _dialogs[ obj.id_window ]; |
---|
| 117 | }; |
---|
| 118 | } ); |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | window.bWindow = _window; |
---|
| 122 | |
---|
| 123 | })(); |
---|
| 124 | |
---|
| 125 | function _winBuild() |
---|
| 126 | { |
---|
| 127 | if( arguments.length > 0 ) |
---|
| 128 | { |
---|
| 129 | if( arguments.length == 1 ) |
---|
| 130 | return bWindow( arguments[0] ); |
---|
| 131 | |
---|
| 132 | if( arguments.length == 2 ) |
---|
| 133 | return bWindow( arguments[0], arguments[1]); |
---|
| 134 | } |
---|
| 135 | return false; |
---|
| 136 | } |
---|