Author: rgardler
Date: Wed Dec  5 15:22:02 2012
New Revision: 1417475

URL: http://svn.apache.org/viewvc?rev=1417475&view=rev
Log:
add a tile view to the base template that is displayed if the viewport is below 
a given size

Added:
    wookie/trunk/widgets/templates/base/content_tile.html
    wookie/trunk/widgets/templates/base/default.widget.properties
Modified:
    wookie/trunk/widgets/templates/base/index.html
    wookie/trunk/widgets/templates/base/scripts/controller.js
    wookie/trunk/widgets/templates/base/template_build.xml
    wookie/trunk/widgets/templates/readme.txt

Added: wookie/trunk/widgets/templates/base/content_tile.html
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/content_tile.html?rev=1417475&view=auto
==============================================================================
--- wookie/trunk/widgets/templates/base/content_tile.html (added)
+++ wookie/trunk/widgets/templates/base/content_tile.html Wed Dec  5 15:22:02 
2012
@@ -0,0 +1,20 @@
+<%
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+%>
+
+<h4>This is the tiled view of the Base Template</h4>
+
+<p>It comes from content_tile.html</p>

Added: wookie/trunk/widgets/templates/base/default.widget.properties
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/default.widget.properties?rev=1417475&view=auto
==============================================================================
--- wookie/trunk/widgets/templates/base/default.widget.properties (added)
+++ wookie/trunk/widgets/templates/base/default.widget.properties Wed Dec  5 
15:22:02 2012
@@ -0,0 +1,6 @@
+# The maximum size a widget viewport needs to be for the tile view.  A
+# viewport that is larger than this in both width and height will
+# display the home page, smaller or equal to these will display the
+# tile page
+widget.tile.max.height=310
+widget.tile.max.width=310
\ No newline at end of file

Modified: wookie/trunk/widgets/templates/base/index.html
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/index.html?rev=1417475&r1=1417474&r2=1417475&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/base/index.html (original)
+++ wookie/trunk/widgets/templates/base/index.html Wed Dec  5 15:22:02 2012
@@ -44,6 +44,10 @@
       </div> <!-- /footer -->
     </div> <!-- /page -->              
 
+    <div data-role="page" id="tile">
+      ${content.tile}
+    </div><!-- /page -->
+
     <div data-role="dialog" id="help">
       <div data-role="header">
        <h4>Help: ${widget.name}</h4>

Modified: wookie/trunk/widgets/templates/base/scripts/controller.js
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/scripts/controller.js?rev=1417475&r1=1417474&r2=1417475&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/base/scripts/controller.js (original)
+++ wookie/trunk/widgets/templates/base/scripts/controller.js Wed Dec  5 
15:22:02 2012
@@ -36,6 +36,13 @@ var ${widget.shortname}_controller = {
      * Update the display
      */
     update:function() { 
+        // Is the viewport large enough for the full view?
+        var viewport = ${widget.shortname}_controller.getViewport();
+        if (viewport.height <= ${widget.tile.max.height}  || viewport.width <= 
${widget.tile.max.width}) {
+            $.mobile.changePage($('#tile'));
+        } else {
+            $.mobile.changePage($('#home'));
+        }
     },
 
    /**
@@ -134,4 +141,4 @@ $('#home').live('pageshow',function(even
 
 $('body').bind('orientationchange',function(event){
     ${widget.shortname}_controller.update();
-})
\ No newline at end of file
+})

Modified: wookie/trunk/widgets/templates/base/template_build.xml
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/template_build.xml?rev=1417475&r1=1417474&r2=1417475&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/base/template_build.xml (original)
+++ wookie/trunk/widgets/templates/base/template_build.xml Wed Dec  5 15:22:02 
2012
@@ -81,6 +81,31 @@
         </filterchain>
     </loadfile>
 
+    <!-- load tile content-->
+    <loadfile property="content.tile"
+              srcFile="content_tile.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
+    <loadfile property="content.tile"
+              srcFile="../common/content_tile.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
+    <loadfile property="content.tile"
+              srcFile="${template.dir}/${template.name}/content_tile.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
     <!-- load content from widget definition -->
     <loadfile property="content.primary"
               srcFile="content_primary.html"

Modified: wookie/trunk/widgets/templates/readme.txt
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/readme.txt?rev=1417475&r1=1417474&r2=1417475&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/readme.txt (original)
+++ wookie/trunk/widgets/templates/readme.txt Wed Dec  5 15:22:02 2012
@@ -250,6 +250,24 @@ ${widget.shortname}_message_controller.s
     // message send code here
 }
 
+** Tiled Templates
+The Base Template provides functionality that allows it to provide a
+separate view that is used when the viewport is below a certain
+size. This view can provide reduced information and is designed for
+use in views that have multiple widgets on display at the same time.
+
+By default the maximum height and widget for a tiled viewport is 310
+pixels. That is, if the viewport is 311 or more pixels in both width
+and height it will display the content defined in the #home div of the
+page definition. If the viewport is 310 or less pixels in either
+height or width then the content in the #tile div will be displayed.
+
+To customise the tile content your widget should provide a
+content_tile.html file.
+
+To customise the maximum viewport size for the tile view set the
+properties "widget.tile.max.height" and "widget.tile.max.width" (both
+default to 310).
 ** Common Files
 When building a family of related widgets you are likely to provide a
 set of common files that will be reused by multiple widgets. These can
@@ -315,7 +333,6 @@ directories" above). In this file you wi
 
     <property name="widget.deploy.compressed" value="true"/>
 
-
 * Building templatised widgets
 
 To build and deploy the widgets run "ant generate-all-widgets" from


Reply via email to