source: branches/2.2.0.1/jabberir_messenger/js/makeW.js @ 4453

Revision 4453, 3.0 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1726 - Adicionando jabberit_messenger da comunidade.

  • Property svn:executable set to *
Line 
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 dragdrop();
49                                dragDrop.set( pObj.id_window );
50                        }
51                       
52                }
53                else
54                {
55                if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) )
56                        return false;
57
58                load(pObj.id_window, "display");
59                }
60        }
61
62        function getElement(pElement)
63        {
64                return document.getElementById(pElement);
65        }
66       
67        function load( pId, pVisible )
68        {
69                var _window = document.getElementById( pId + '__parent')
70               
71                if( _window != null )
72                {
73                        if ( pVisible == "display" )
74                        {
75                                if( _window.style.left == "-1500px" )
76                                        _window.style.left = _window.getAttribute("leftOld");
77                        }
78                       
79                        if ( pVisible == "hidden")
80                        {
81                                _window.setAttribute("leftOld" , _window.style.left );
82                                _window.style.left = "-1500px";
83                        }
84                       
85                        if( pVisible == "remove" )
86                        {
87                                document.body.removeChild( _window );
88                        }
89                }
90        }
91       
92        function _window()
93        {
94                if( arguments.length > 0 )
95                {
96                        var pId = null;
97                        if( arguments.length == 1 )
98                        {
99                                var obj = arguments[0];
100                                pId = obj.id_window
101                                build(obj);
102                        }
103                       
104                        if( arguments.length == 2 )
105                        {
106                                load( ( pId = arguments[0] ), arguments[1]);
107                        }       
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                } );
120        }
121
122        window.bWindow  = _window;
123
124})();
125
126function winBuild()
127{
128        if( arguments.length > 0 )
129        {       
130                if( arguments.length == 1 )
131                        return bWindow( arguments[0] );
132               
133                if( arguments.length == 2 )
134                        return bWindow( arguments[0], arguments[1]);   
135        }
136        return false;
137}
Note: See TracBrowser for help on using the repository browser.