Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Set skin on load

    Using:
    SmartGWT 3.1p-2012-11-23
    SmartClient Version: v8.3p_2012-11-23/LGPL Development Only (built 2012-11-23)
    GWT 2.5
    FF 19

    As a reference I looked at all posts I could find on the topic, and the showcase project itself.
    I am trying to set the skin when the app loads to:
    1. "Mobile" for mobiles
    2. "Enterprise" otherwise
    For now, I am setting the skin via the "skin" url parameter, such as "http://127.0.0.1:8888/?skin=Enterprise" so that I can test quickly

    Here is the code:

    Portal.gwt.xml
    Code:
      <inherits name="com.smartgwt.SmartGwtNoTheme"/>
      <inherits name="com.smartgwt.tools.SmartGwtTools"/>
      <inherits name="com.smartclient.theme.enterprise.EnterpriseResources"/>
      <inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlueResources"/>
      <!--<inherits name="com.smartclient.theme.mobile.Mobile"/>-->
      <inherits name="com.smartclient.theme.simplicity.SimplicityResources"/>
    Portal.hml:
    Code:
        <!-- add a loading indicator -->
        <div id="loadingWrapper">
          <div id="loading">
            <div class="loadingIndicator">
            <img src="images/portal/icon/statusCodeAll.gif" width="36" height="36" style="margin-right:8px;float:left;vertical-align:top;"/>DoctorMeow<br/>
            <span id="loadingMsg">Loading...</span></div>
          </div>
        </div>
        
        <!-- load the skin, from smartgwt showcase/index.html -->
        <script type="text/javascript">
          
        // from http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter
        // changed to return null instead of "" if a value is not set
        function gup(name, defaultValue){
          name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
          var regexS = "[\\?&]"+name+"=([^&#]*)";  
          var regex = new RegExp( regexS );  
          var results = regex.exec( window.location.href ); 
          if( results == null )    return defaultValue;  
          else    return results[1];
        }
    
        // url-specific processing
        var skin = gup ("skin", "Enterprise");
        var mobileFlag = gup ("mobile", "false");
        if (mobileFlag == "true") {
          skin = "Mobile";
        }
        alert ('skin: ' + skin)
        loadJavascriptFile ("portal/sc/skins/" + skin + "/load_skin.js?isc_version=8.3.js");
        </script>
        
        <!-- load the app -->
        <script type="text/javascript" language="javascript" src="portal/portal.nocache.js"></script>
      </body>
    </html>
    However, I ran into the following:
    1. Visit "http://127.0.0.1:8888/?skin=Enterprise"
    2. The code below shows a popup that says skin = Enterprise
    3. The browser dev console shows that the following resource is not found - note that the skin is "standard" instead of "enterprise"
    Code:
    /portal/sc/skins/standard/images/DynamicForm/SelectItem_PickButton_icon.gif
    4. I looked for the following, just in case, and it does not exist, so even if the skin name if Enterprise, it would not work
    Code:
    /portal/sc/skins/standard/images/DynamicForm/SelectItem_PickButton_icon.gif
    I also ran into the following:
    1. Add <inherits name="com.smartclient.theme.mobile.Mobile"/> to Portal.gwt.xml
    2. Visit "http://127.0.0.1:8888/"
    3. No matter how I set the skin, the skin used to render the app is Mobile
    4. So I looked at portal/portal.nocache.js, and it includes this:
    Code:
    <\/script>',ic='sc/modules/ISC_RichTextEditor.js',jc='sc/modules/ISC_RichTextEditor.js"><\/script>',oc='sc/skins/Mobile/load_skin.js',pc='sc/skins/Mobile/load_skin.js"><\/script>',db='script',Pb='selectingPermutation',
    5. It seems that when the Mobile skin is included, it wins over load_skin.js

    Any ideas?
Working...
X