loader: Skip loading theme CSS with a custom css code
authorYoumin Ha <youmin.ha@samsung.com>
Thu, 3 Jan 2013 10:08:22 +0000 (19:08 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Fri, 4 Jan 2013 11:30:38 +0000 (20:30 +0900)
  If applications have <link rel="stylesheet" href="[theme CSS path]">,
loader skips putting new <link> tag for the theme.
  This option only works with proper theme CSS path: if the <script> tag
loads "<path>/<version>/js/tizen-web-ui-fw.js", then the theme CSS path must
be "<path>/<version>/themes/<theme>/tizen-web-ui-fw-theme.css",
having exactly same path to the script path. Otherwise, the link tag will be
ignored, and the new <link> tag will be added automatically.

Change-Id: I9910eb3049f5a73fdc386c40b73409f166dfa1c3

src/loader/loader.js

index 96cc6aa..d26fb5e 100644 (file)
@@ -106,13 +106,21 @@ If developers do not give a viewport meta tag, Tizen Web UI Framework automatica
                                        l = null;
                                // Find css link element
                                for ( idx = 0; idx < cssLinks.length; idx++ ) {
-                                       if( cssLinks[idx].getAttribute( 'name' ) == "tizen-theme" ) {
+                                       if( cssLinks[idx].getAttribute( 'rel' ) != "stylesheet" ) {
+                                               continue;
+                                       }
+                                       if( cssLinks[idx].getAttribute( 'name' ) == "tizen-theme" 
+                                                       || cssLinks[idx].getAttribute( 'href' ) == path ) {
                                                l = cssLinks[idx];
                                                break;
                                        }
                                }
                                if ( l ) {      // Found the link element!
-                                       l.setAttribute( 'href', path );
+                                       if ( l.getAttribute( 'href' ) == path ) {
+                                               console.log( "Theme is already loaded. Skip theme loading in the framework." );
+                                       } else {
+                                               l.setAttribute( 'href', path );
+                                       }
                                } else {
                                        this.addElementToHead( this.makeLink( path ) );
                                }