source: sandbox/jabberit_messenger/trophy/js/makeW.js @ 2271

Revision 2271, 2.3 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - Reimplementar interface mais leve para o IM, sem a necessidades de plugins adicionais.

  • Property svn:executable set to *
Line 
1(function()
2{
3        var _xtools             = null;
4        var dragDrop    = null;
5        var path                = "/teste_interno/trophyNew/";
6       
7        function build(pObj)
8        {
9                var _window = getElement( pObj.id_window + '__parent');
10                _xtools = new xtools(path);             
11               
12                if( _window == null )
13                {
14                        pObj.width              = ( ( pObj.width > 160 ) ? pObj.width : 160 );
15                        pObj.height             = ( ( pObj.height > 80 ) ? pObj.height : 80 );
16                        pObj.onclick    = "_winBuild('" + pObj.id_window + "', '" + pObj.closeAction + "')";
17                       
18                        _window = document.createElement("div");
19                        _window.id      = pObj.id_window + "__parent";
20                        _window.setAttribute("onselectstart" , "return false");
21                        _window.style.width             = pObj.width + "px";
22                        _window.style.height    = pObj.height + "px";
23                        _window.style.top               = pObj.top + "px";
24                        _window.style.left              = pObj.left + "px";
25                        _window.style.position  = "absolute";
26                        _window.style.zIndex    = pObj.zindex;
27                        _window.innerHTML               = _xtools.parse( _xtools.xml('window_main'), 'window.xsl', pObj );
28
29                        if( pObj.closeAction == "hidden" )
30                                _window.setAttribute("leftOld", pObj.left + "px" );
31                       
32                        window.document.body.insertBefore( _window, document.body.lastChild );
33                       
34                        getElement(pObj.id_window + '__content').innerHTML = pObj.content;
35                       
36                        if( pObj.draggable )
37                        {
38                                dragDrop = new _drag_drop();
39                                dragDrop.set( pObj.id_window );
40                        }
41                }
42                else
43                {
44                        load(pObj.id_window, "display");
45                }
46        }
47
48        function getElement(pElement)
49        {
50                return document.getElementById(pElement);
51        }
52       
53        function load( pId, pVisible )
54        {
55                var _window = document.getElementById( pId + '__parent')
56               
57                if( _window != null )
58                {
59                        if ( pVisible == "display" )
60                        {
61                                _window.style.left = _window.getAttribute("leftOld");
62                        }
63                       
64                        if ( pVisible == "hidden")
65                        {
66                                _window.setAttribute("leftOld" , _window.style.left );
67                                _window.style.left = "-1500px";
68                        }
69                       
70                        if( pVisible == "remove" )
71                        {
72                                document.body.removeChild( _window );
73                        }
74                }
75        }
76       
77        function _window()
78        {
79                if( arguments.length > 0 )
80                {
81                        if( arguments.length == 1 )
82                        {
83                                var obj = arguments[0];
84                                build(obj);
85                        }
86                       
87                        if( arguments.length == 2 )
88                        {
89                                load(arguments[0], arguments[1]);
90                        }       
91                }
92        }
93
94        window.bWindow  = _window;
95
96})();
97
98function _winBuild()
99{
100        if( arguments.length > 0 )
101        {       
102                if( arguments.length == 1 )
103                        _win = new bWindow( arguments[0] );
104               
105                if( arguments.length == 2 )
106                        _win = new bWindow( arguments[0], arguments[1]);       
107        }
108}
Note: See TracBrowser for help on using the repository browser.