source: trunk/phpgwapi/js/tools/xstyle.js @ 2903

Revision 2903, 1.9 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Corrigindo problemas na inclusão de folhas de estilo.

Line 
1//****c* XTools/XEvents
2// NAME
3//    XStyle
4//
5// DESCRIPTION
6//    Manipula folhas de estilo
7//
8// AUTHOR
9//    Rodrigo Souza dos Santos
10//    |html <br /><a href="mailto:%72%6f%64%72%69%67%6f%2e%73%6f%75%7a%61%40%63%65%6c%65%70%61%72%2e%70%72%2e%67%6f%76%2e%62%72">&#114;&#111;&#100;&#114;&#105;&#103;&#111;&#46;&#115;&#111;&#117;&#122;&#97;&#64;&#99;&#101;&#108;&#101;&#112;&#97;&#114;&#46;&#112;&#114;&#46;&#103;&#111;&#118;&#46;&#98;&#114;</a>
11//    |html <br /><a href="mailto:%72%6f%64%72%69%67%6f%73%6f%75%7a%61%64%6f%73%73%61%6e%74%6f%73%40%67%6d%61%69%6c%2e%63%6f%6d">&#114;&#111;&#100;&#114;&#105;&#103;&#111;&#115;&#111;&#117;&#122;&#97;&#100;&#111;&#115;&#115;&#97;&#110;&#116;&#111;&#115;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;</a>
12//
13//******
14// You can use this space for remarks that should not be included
15// in the documentation.
16//
17( function( )
18{
19        var _head = null;
20        var _new = [ ];
21        var _loaded = [ ];
22
23        function _add( )
24        {
25                if ( ! ( arguments.length && arguments[ 0 ] && arguments[ 0 ].constructor == String ) )
26                        return false;
27
28                for ( var i = 0; i < _loaded; i++ )
29                        if ( _loaded[ i ] == arguments[ 0 ] )
30                                return false;
31
32                if ( _head )
33                        _style( arguments[ 0 ] );
34                else
35                        _new[ _new.length ] = arguments[ 0 ];
36        }
37
38        function _style( )
39        {
40                if ( ! ( arguments.length && arguments[ 0 ] && arguments[ 0 ].constructor == String ) )
41                        return false;
42
43                var _sheet = document.createElement( 'link' );
44                _sheet.setAttribute( 'href', arguments[ 0 ] );
45                _sheet.setAttribute( 'rel', 'StyleSheet' );
46                _sheet.setAttribute( 'type', 'text/css' );
47
48                _head.appendChild( _sheet );
49
50                return true;
51        }
52
53        function Style( )
54        {
55        }
56
57        Style.prototype.add = _add;
58
59        window.XStyle = new Style;
60
61        XEvents.add( window, 'onload', function( )
62        {
63                _head = document.getElementsByTagName( 'head' ).item( 0 );
64
65                for ( var i = 0; i < _new.length; i++ )
66                        _style( _new[ i ] );
67        } );
68} )( );
Note: See TracBrowser for help on using the repository browser.