You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/04/24 18:23:36 UTC

svn commit: r1471510 - in /myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content: 30-object/object.js 30-object/object.xhtml 70-dataAttribute/dataAttribute.js

Author: lofwyr
Date: Wed Apr 24 16:23:35 2013
New Revision: 1471510

URL: http://svn.apache.org/r1471510
Log:
TOBAGO-1171: Support for the Content Security Policy (CSP)
TOBAGO-1219: Evaluate jQuery UI Widget Factory

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.js
      - copied, changed from r1471417, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml
Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/70-dataAttribute/dataAttribute.js

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.js (from r1471417, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.js?p2=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.js&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml&r1=1471417&r2=1471510&rev=1471510&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.js Wed Apr 24 16:23:35 2013
@@ -1,6 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
+/*
  * 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.
@@ -15,39 +13,52 @@
  * 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.
--->
+ */
+
+(function ($) {
+
+
+  $.widget("demo.maps", {
+
+    options: {
+      position: "11.249123,-60.687103", // tobago
+      zoom: 2 // global
+    },
+
+    _create: function () {
+      this._on({
+        click: function (event) {
+          var position = this.element.data("maps-position");
+          if (position == null) {
+            position = this.options.position;
+          }
+          var zoom = this.element.data("maps-zoom");
+          if (zoom == null) {
+            zoom = this.options.zoom;
+          }
+          var target = this.element.data("maps-target");
+          var url = 'http://maps.google.com/maps?'
+              + 'ie=UTF8&ll=' + position + '&t=h&z=' + zoom + '&output=embed&f=q&cd=1';
+          jQuery(Tobago.Utils.escapeClientId(target)).attr('src', url);
+        }
+      });
+    },
+
+    _setOption: function (key, value) {
+    },
+
+    _destroy: function () {
+    }
+
+  });
 
-<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
-                xmlns:tc="http://myfaces.apache.org/tobago/component"
-                xmlns:tx="http://myfaces.apache.org/tobago/extension"
-                xmlns:ui="http://java.sun.com/jsf/facelets"
-                xmlns:f="http://java.sun.com/jsf/core">
-  <ui:param name="title" value="Object - Show external content inside of an application"/>
-  <tc:panel>
-    <f:facet name="layout">
-      <tc:gridLayout rows="auto;*"/>
-    </f:facet>
-
-    <tc:panel>
-      <f:facet name="layout">
-        <tc:gridLayout columns="80px;80px;80px;*"/>
-      </f:facet>
-      <tc:link
-          label="Show Tobago"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;ll=11.249123,-60.687103&amp;t=h&amp;z=12&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
-      <tc:link
-          label="Show Plane"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;ll=50.053839,8.624933&amp;t=h&amp;z=17&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
-      <tc:link
-          label="Show World"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;t=h&amp;z=2&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
-      <tc:panel/>
-    </tc:panel>
+}(jQuery));
 
-    <tc:object id="map" src="http://maps.google.com/maps?ie=UTF8&amp;ll=11.249123,-60.687103&amp;t=h&amp;z=12&amp;output=embed&amp;f=q&amp;cd=1"/>
+var initMaps = function () {
+  jQuery("[data-maps-target]")
+      .maps()
+      .first()
+      .click();
+};
 
-  </tc:panel>
-</ui:composition>
+Tobago.registerListener(initMaps, Tobago.Phase.DOCUMENT_READY);

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml?rev=1471510&r1=1471509&r2=1471510&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-object/object.xhtml Wed Apr 24 16:23:35 2013
@@ -23,6 +23,9 @@
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core">
   <ui:param name="title" value="Object - Show external content inside of an application"/>
+
+  <tc:script file="content/30-object/object.js"/>
+
   <tc:panel>
     <f:facet name="layout">
       <tc:gridLayout rows="auto;*"/>
@@ -32,22 +35,23 @@
       <f:facet name="layout">
         <tc:gridLayout columns="80px;80px;80px;*"/>
       </f:facet>
-      <tc:link
-          label="Show Tobago"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;ll=11.249123,-60.687103&amp;t=h&amp;z=12&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
-      <tc:link
-          label="Show Plane"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;ll=50.053839,8.624933&amp;t=h&amp;z=17&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
-      <tc:link
-          label="Show World"
-          onclick="jQuery('iframe').attr('src', 'http://maps.google.com/maps?ie=UTF8&amp;t=h&amp;z=2&amp;output=embed&amp;f=q&amp;cd=1')"
-          target="page:map"/>
+      <tc:link label="Show Tobago" onclick="/* fixme */">
+          <tc:dataAttribute name="maps-position" value="11.249123,-60.687103"/>
+          <tc:dataAttribute name="maps-zoom" value="12"/>
+          <tc:dataAttribute name="maps-target" value="page:map"/>
+      </tc:link>
+      <tc:link label="Show Plane" onclick="/* fixme */">
+          <tc:dataAttribute name="maps-position" value="50.053839,8.624933"/>
+          <tc:dataAttribute name="maps-zoom" value="17"/>
+          <tc:dataAttribute name="maps-target" value="page:map"/>
+      </tc:link>
+      <tc:link label="Show World" onclick="/* fixme */">
+          <tc:dataAttribute name="maps-target" value="page:map"/>
+      </tc:link>
       <tc:panel/>
     </tc:panel>
 
-    <tc:object id="map" src="http://maps.google.com/maps?ie=UTF8&amp;ll=11.249123,-60.687103&amp;t=h&amp;z=12&amp;output=embed&amp;f=q&amp;cd=1"/>
+    <tc:object id="map"/>
 
   </tc:panel>
 </ui:composition>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/70-dataAttribute/dataAttribute.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/70-dataAttribute/dataAttribute.js?rev=1471510&r1=1471509&r2=1471510&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/70-dataAttribute/dataAttribute.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/70-dataAttribute/dataAttribute.js Wed Apr 24 16:23:35 2013
@@ -15,13 +15,55 @@
  * limitations under the License.
  */
 
-jQuery(document).ready(function () {
-  jQuery("[data-colored]")
-      .css("background-color", "#aaaaaa")
-      .click(function () {
-        jQuery(this).css("background-color", jQuery(this).data("colored"));
-      })
-      .dblclick(function () {
-        jQuery(this).css("background-color", "#aaaaaa");
-      });
-});
+/*
+ jQuery(document).ready(function () {
+ jQuery("[data-colored]")
+ .css("background-color", "#aaaaaa")
+ .click(function () {
+ jQuery(this).css("background-color", jQuery(this).data("colored"));
+ })
+ .dblclick(function () {
+ jQuery(this).css("background-color", "#aaaaaa");
+ });
+ });
+ */
+
+(function ($) {
+
+    $.widget("demo.colored", {
+
+        options: {
+            resetColor: "#aaaaaa"
+        },
+
+        _create: function () {
+            this.element.css("background-color", this.options.resetColor);
+            this._on({
+                click: function (event) {
+                    this.element.css("background-color", this.element.data("color"));
+                },
+                dblclick: function (event) {
+                    this.element.css("background-color", this.options.resetColor);
+                }
+            });
+        },
+
+        _setOption: function (key, value) {
+            switch (key) {
+                case "resetColor":
+                    this.options.resetColor = value;
+                    break;
+            }
+            this._super("_setOption", key, value);
+        },
+
+        _destroy: function () {
+        }
+
+    });
+
+}(jQuery));
+
+Tobago.registerListener(function() {
+    jQuery("[data-color]").colored({resetColor: "#333333"});
+}, Tobago.Phase.DOCUMENT_READY);