Author: rgardler
Date: Sat Dec 29 22:53:31 2012
New Revision: 1426853

URL: http://svn.apache.org/viewvc?rev=1426853&view=rev
Log:
move the widget shim to a separate JS file so that we can provide platofrm 
specific implementations at build time if we desire (also document this)

Added:
    wookie/trunk/widgets/templates/base/scripts/widget_api.js
Modified:
    wookie/trunk/widgets/templates/assetPlayer/content_scripts.html
    wookie/trunk/widgets/templates/base/content_scripts.html
    wookie/trunk/widgets/templates/base/scripts/controller.js
    wookie/trunk/widgets/templates/readme.txt

Modified: wookie/trunk/widgets/templates/assetPlayer/content_scripts.html
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/assetPlayer/content_scripts.html?rev=1426853&r1=1426852&r2=1426853&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/assetPlayer/content_scripts.html (original)
+++ wookie/trunk/widgets/templates/assetPlayer/content_scripts.html Sat Dec 29 
22:53:31 2012
@@ -16,4 +16,5 @@
 -->
 <script type="text/javascript" src="lib/jquery-1.8.2.js"></script>
 <script type="text/javascript" src="lib/jquery.mobile-1.2.0.js"></script>
+<script type="text/javascript" src="scripts/widget_api.js"></script>
 <script type="text/javascript" src="scripts/controller.js"></script>

Modified: wookie/trunk/widgets/templates/base/content_scripts.html
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/content_scripts.html?rev=1426853&r1=1426852&r2=1426853&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/base/content_scripts.html (original)
+++ wookie/trunk/widgets/templates/base/content_scripts.html Sat Dec 29 
22:53:31 2012
@@ -16,4 +16,5 @@
 %>
 <script type="text/javascript" 
src="http://code.jquery.com/jquery-1.6.4.min.js";></script>
 <script type="text/javascript" 
src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js";></script>
+<script type="text/javascript" src="scripts/widget_api.js"></script>
 <script type="text/javascript" src="scripts/controller.js"></script>

Modified: wookie/trunk/widgets/templates/base/scripts/controller.js
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/scripts/controller.js?rev=1426853&r1=1426852&r2=1426853&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/base/scripts/controller.js (original)
+++ wookie/trunk/widgets/templates/base/scripts/controller.js Sat Dec 29 
22:53:31 2012
@@ -120,21 +120,6 @@ var ${widget.shortname}_controller = {
     }
 };
 
-/**
- * Provides a basic shim for opening the widget without a widget object (e.g. 
directly in browsers)
- */
-if (!window.widget){
-    window.widget = {};
-}
-
-/**
- * Adds in the "proxify" method if it isn't in the widget object, e.g. as 
we're opening the widget
- * directly in a browser, or using a widget runtime other than Wookie e.g. 
Opera, PhoneGap etc
- */
-if (!window.widget.proxify){
-    window.widget.proxify = function(url){ return url };
-}
-
 $('#home').live('pageshow',function(event) {
    ${widget.shortname}_controller.init(); 
 });

Added: wookie/trunk/widgets/templates/base/scripts/widget_api.js
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/base/scripts/widget_api.js?rev=1426853&view=auto
==============================================================================
--- wookie/trunk/widgets/templates/base/scripts/widget_api.js (added)
+++ wookie/trunk/widgets/templates/base/scripts/widget_api.js Sat Dec 29 
22:53:31 2012
@@ -0,0 +1,37 @@
+<%
+/*
+ * 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.
+ */
+%>
+
+/**
+ * Provides a basic shim for opening the widget without a widget
+ * object (e.g. directly in browsers)
+ */
+if (!window.widget){
+    window.widget = {
+        /**
+         * Adds in the "proxify" method if it isn't in the widget
+         * object, e.g. as we're opening the widget directly in a
+         * browser, or using a widget runtime other than Wookie
+         * e.g. Opera, PhoneGap etc
+         */
+        proxify:function(url) {
+            return url;
+        }
+    };
+}
+

Modified: wookie/trunk/widgets/templates/readme.txt
URL: 
http://svn.apache.org/viewvc/wookie/trunk/widgets/templates/readme.txt?rev=1426853&r1=1426852&r2=1426853&view=diff
==============================================================================
--- wookie/trunk/widgets/templates/readme.txt (original)
+++ wookie/trunk/widgets/templates/readme.txt Sat Dec 29 22:53:31 2012
@@ -570,3 +570,13 @@ In order to make the build faster in a d
 define which templates are to be built using the "widget.include"
 property discussed in the next section.
 
+* Widget API
+The base template provides a shim implementation of the widget API
+used in Wookie (window.widget.*). This shim is only loaded if an api
+object has not been injected by the host enviroment, a happens when
+the widget is deployed by Wookie.
+
+If you want to build a custom version of the widget for a given
+platform you can provide your own implementation of the widget API by
+injecting your own window.widget object at runtime or by providing
+your own implementation in widget_api.js at build time.


Reply via email to