Author: rgardler
Date: Thu Aug 9 13:46:24 2012
New Revision: 1371212
URL: http://svn.apache.org/viewvc?rev=1371212&view=rev
Log:
demonstrate using a data- attribute rather than a class for identifying the
elements to scan over
Added:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
(with props)
Removed:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/maavisImages_controller.js
Modified:
incubator/wookie/trunk/widgets/templates/assetPlayer/content_secondary.html
incubator/wookie/trunk/widgets/templates/scanning/readme.txt
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/widget.properties
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/content_primary.html
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/scripts/scanningBaseTest_controller.js
Modified:
incubator/wookie/trunk/widgets/templates/assetPlayer/content_secondary.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/assetPlayer/content_secondary.html?rev=1371212&r1=1371211&r2=1371212&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/assetPlayer/content_secondary.html
(original)
+++ incubator/wookie/trunk/widgets/templates/assetPlayer/content_secondary.html
Thu Aug 9 13:46:24 2012
@@ -1,17 +1,17 @@
<div>
- <div class="scan" id="gotoAlbum" data-role="button">
+ <div data-scanOrder="4" id="gotoAlbum" data-role="button">
Change Photos
</div>
- <div class="scan" id="playPause" data-role="button">
+ <div data-scanOrder="1" id="playPause" data-role="button">
Play
</div>
- <div class="scan" id="prev" data-role="button">
+ <div data-scanOrder="2" id="prev" data-role="button">
Previous Photo
</div>
- <div class="scan" id="next" data-role="button">
+ <div data-scanOrder="3" id="next" data-role="button">
Next Photo
</div>
</div>
Modified: incubator/wookie/trunk/widgets/templates/scanning/readme.txt
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/scanning/readme.txt?rev=1371212&r1=1371211&r2=1371212&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/scanning/readme.txt (original)
+++ incubator/wookie/trunk/widgets/templates/scanning/readme.txt Thu Aug 9
13:46:24 2012
@@ -1,6 +1,5 @@
The Scanning Template adds basic switch control functionality to a
-widget. It extends the base template. By default it will scan through
-all elements that have a "scan" CSS class assigned to them.
+widget. It extends the base template.
Using
=====
@@ -8,7 +7,25 @@ Using
To use this template you must provide the elements over which we should scan
by setting
${widget.shortname}_scanning_controller.scanElements, e.g.
-${widget.shortname}_scanning_controller.scanElements = $('.scan');
+HTML5 data attributes are a good way to identify elements that chould
+be included in the scanning.
+
+<div data-scanOrder="3">...</div>
+<div data-scanOrder="1">...</div>
+<div data-scanOrder="2">...</div>
+
+We can then use a selector like the following to tell the scanning
+code which elements to iterate over:
+
+${widget.shortname}_scanning_controller.scanElements = $('[data-scanOrder]');
+
+Sorting the elements based on the value of this attribute will allow
+us to change the scanning order. This might be performed using a
+technique such as
+http://james.padolsey.com/javascript/sorting-elements-with-jquery/
+
+Configuration
+=============
You can also change various aspects of the scanning functionality by
setting the following variables in ${widget.shortname}_scanning_controller:
@@ -17,4 +34,3 @@ setting the following variables in ${wid
These can also be set in the widget.properties file using:
-
Added:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js?rev=1371212&view=auto
==============================================================================
---
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
(added)
+++
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
Thu Aug 9 13:46:24 2012
@@ -0,0 +1,19 @@
+var ${widget.shortname}_images_controller = {
+ init:function() {
+ // FIXME: album should be created by reading a directory
+ var assets = [];
+ assets[0] = {
+ "src":"images/Places/Scottish Highlands.bmp"
+ };
+ assets[1] = {
+ "src":"images/Places/Tower Bridge.bmp"
+ };
+ ${widget.shortname}_asset_controller.setCollection(assets);
+ ${widget.shortname}_scanning_controller.scanElements =
$('[data-scanOrder]');
+ },
+
+};
+
+$('#home').live('pageshow',function(event) {
+ ${widget.shortname}_images_controller.init();
+});
Propchange:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/scripts/assetPlayerTestWidget_controller.js
------------------------------------------------------------------------------
svn:executable = *
Modified:
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/widget.properties
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/widget.properties?rev=1371212&r1=1371211&r2=1371212&view=diff
==============================================================================
---
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/widget.properties
(original)
+++
incubator/wookie/trunk/widgets/templates/testWidgets/assetPlayerTestWidget/widget.properties
Thu Aug 9 13:46:24 2012
@@ -4,4 +4,4 @@ widget.name=Asset Player Test Widget
widget.description=Simple image player as a test of the Asset Player template.
twoColumn.primary.position=left
twoColumn.secondary.position=right
-
+scanning.delay=1000
Modified:
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/content_primary.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/content_primary.html?rev=1371212&r1=1371211&r2=1371212&view=diff
==============================================================================
---
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/content_primary.html
(original)
+++
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/content_primary.html
Thu Aug 9 13:46:24 2012
@@ -16,24 +16,24 @@
-->
<p>Primary content.</p>
<div>
- <div class="scan" id="button1" data-role="button">
+ <div data-scanOrder="1" id="button1" data-role="button">
Button 1
</div>
- <div class="scan" id="button2" data-role="button">
+ <div data-scanOrder="2" id="button2" data-role="button">
Button 2
</div>
- <div class="scan" id="button3" data-role="button">
+ <div data-scanOrder="3" id="button3" data-role="button">
Button 3
</div>
</div>
<div>
- <div class="scan" id="button4" data-role="button">
+ <div data-scanOrder="4" id="button4" data-role="button">
Button 4
</div>
- <div class="scan" id="button5" data-role="button">
+ <div data-scanOrder="5" id="button5" data-role="button">
Button 5
</div>
- <div class="scan" id="button6" data-role="button">
+ <div data-scanOrder="6" id="button6" data-role="button">
Button 6
</div>
</div>
Modified:
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/scripts/scanningBaseTest_controller.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/scripts/scanningBaseTest_controller.js?rev=1371212&r1=1371211&r2=1371212&view=diff
==============================================================================
---
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/scripts/scanningBaseTest_controller.js
(original)
+++
incubator/wookie/trunk/widgets/templates/testWidgets/scanningBaseTestWidget/scripts/scanningBaseTest_controller.js
Thu Aug 9 13:46:24 2012
@@ -43,7 +43,7 @@ var ${widget.shortname}_scanningBaseTest
alert("Button 6 clicked");
});
- ${widget.shortname}_scanning_controller.scanElements = $('.scan');
+ ${widget.shortname}_scanning_controller.scanElements =
$('[data-scanOrder]');
},
};