source: trunk/jabberit_messenger/js/makeW.js @ 2925

Revision 2925, 3.0 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - modificacoes dentro do modulo jabberit_messenger para permitir o funcionamento do modulo sem java

  • Property svn:executable set to *
  • Property svn:mime-type set to text/plain
RevLine 
[1530]1(function()
2{
3        var Xtools              = null;
4        var dragDrop    = null;
5        var path                = path_jabberit;
6       
[2925]7        var _dialogs = [ ];
8       
[1530]9        function build(pObj)
10        {
[2226]11                var _window = getElement( pObj.id_window + '__parent');
[2925]12                Xtools = new JITXtools(path);   
[1530]13               
14                if( _window == null )
15                {
16                        pObj.width              = ( ( pObj.width > 160 ) ? pObj.width : 160 );
17                        pObj.height             = ( ( pObj.height > 80 ) ? pObj.height : 80 );
[2226]18                        pObj.onclick    = "winBuild('" + pObj.id_window + "', '" + pObj.closeAction + "')";
[1530]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 );
[1579]30
[2226]31                        if( pObj.closeAction == "hidden" )
32                                _window.setAttribute("leftOld", pObj.left + "px" );
33                       
[2925]34                        if( pObj.leftOld )
35                                _window.setAttribute("leftOld", pObj.leftOld + "px" );
36                       
[1579]37                        window.document.body.insertBefore( _window, document.body.lastChild );
[1530]38                       
[2925]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 );
[2226]43                       
[2925]44                        _dialogs[ pObj.id_window ] = getElement(pObj.id_window + '__content').firstChild;
45
[1530]46                        if( pObj.draggable )
47                        {
48                                dragDrop = new dragdrop();
49                                dragDrop.set( pObj.id_window );
50                        }
[2925]51                       
[1530]52                }
53                else
[2226]54                {
[2925]55                if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) )
56                        return false;
57
58                load(pObj.id_window, "display");
[2226]59                }
[1530]60        }
61
[2226]62        function getElement(pElement)
[1530]63        {
[2226]64                return document.getElementById(pElement);
[1530]65        }
66       
[2226]67        function load( pId, pVisible )
[1530]68        {
[2925]69                var _window = document.getElementById( pId + '__parent')
[1530]70               
[2925]71                if( _window != null )
[1530]72                {
73                        if ( pVisible == "display" )
[2226]74                        {
[2925]75                                if( _window.style.left == "-1500px" )
76                                        _window.style.left = _window.getAttribute("leftOld");
77                        }
[1530]78                       
79                        if ( pVisible == "hidden")
[2226]80                        {
[2925]81                                _window.setAttribute("leftOld" , _window.style.left );
82                                _window.style.left = "-1500px";
[2226]83                        }
[1530]84                       
85                        if( pVisible == "remove" )
[2226]86                        {
[2925]87                                document.body.removeChild( _window );
[2226]88                        }
[1530]89                }
90        }
91       
92        function _window()
93        {
[2226]94                if( arguments.length > 0 )
[1530]95                {
[2925]96                        var pId = null;
[2226]97                        if( arguments.length == 1 )
98                        {
99                                var obj = arguments[0];
[2925]100                                pId = obj.id_window
101                                build(obj);
[2226]102                        }
[2925]103                       
[2226]104                        if( arguments.length == 2 )
105                        {
[2925]106                                load( ( pId = arguments[0] ), arguments[1]);
[2226]107                        }       
[2925]108                }
109
110                return ( new function( )
111                {
112                        this.content = function( )
113                        {
114                                if ( arguments.length )
115                                        getElement( pId + '__content').appendChild( _dialogs[ pId ] );
116
117                                return _dialogs[ obj.id_window ];
118                        };
119                } );
[1530]120        }
121
122        window.bWindow  = _window;
123
124})();
125
126function winBuild()
127{
[2226]128        if( arguments.length > 0 )
129        {       
130                if( arguments.length == 1 )
[2925]131                        return bWindow( arguments[0] );
[2226]132               
133                if( arguments.length == 2 )
[2925]134                        return bWindow( arguments[0], arguments[1]);   
[2226]135        }
[2925]136        return false;
[1530]137}
Note: See TracBrowser for help on using the repository browser.