You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by rb...@apache.org on 2011/08/12 20:41:05 UTC
svn commit: r1157210 - in
/shindig/trunk/features/src/main/javascript/features: ./ container/
dynamic-height.height/ dynamic-height.util/ dynamic-height/
dynamic-size.util/ dynamic-width.width/ dynamic-width/
Author: rbaxter85
Date: Fri Aug 12 18:41:04 2011
New Revision: 1157210
URL: http://svn.apache.org/viewvc?rev=1157210&view=rev
Log:
SHINDIG-1567
Committing For Chris Heelan
Added dynamic width and dynamic size APIs for gadgets
Added:
shindig/trunk/features/src/main/javascript/features/dynamic-size.util/ (with props)
shindig/trunk/features/src/main/javascript/features/dynamic-size.util/dynamic-size-util.js
shindig/trunk/features/src/main/javascript/features/dynamic-size.util/feature.xml
shindig/trunk/features/src/main/javascript/features/dynamic-size.util/taming.js
shindig/trunk/features/src/main/javascript/features/dynamic-width/ (with props)
shindig/trunk/features/src/main/javascript/features/dynamic-width.width/
shindig/trunk/features/src/main/javascript/features/dynamic-width.width/dynamic-width-width.js
shindig/trunk/features/src/main/javascript/features/dynamic-width.width/feature.xml
shindig/trunk/features/src/main/javascript/features/dynamic-width.width/taming.js
shindig/trunk/features/src/main/javascript/features/dynamic-width/dynamic-width.js
shindig/trunk/features/src/main/javascript/features/dynamic-width/feature.xml
shindig/trunk/features/src/main/javascript/features/dynamic-width/taming.js
Removed:
shindig/trunk/features/src/main/javascript/features/dynamic-height.util/
Modified:
shindig/trunk/features/src/main/javascript/features/container/container.js
shindig/trunk/features/src/main/javascript/features/dynamic-height.height/feature.xml
shindig/trunk/features/src/main/javascript/features/dynamic-height/feature.xml
shindig/trunk/features/src/main/javascript/features/features.txt
Modified: shindig/trunk/features/src/main/javascript/features/container/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/container.js?rev=1157210&r1=1157209&r2=1157210&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Fri Aug 12 18:41:04 2011
@@ -625,6 +625,14 @@ osapi.container.Container.prototype.regi
}
});
+ this.rpcRegister('resize_iframe_width', function(rpcArgs, newWidth) {
+ var site = rpcArgs[osapi.container.GadgetSite.RPC_ARG_KEY];
+ if (site) { // Check if site is not already closed.
+ site.setWidth(newWidth);
+ }
+ return true;
+ });
+
/**
* @see setprefs.js setprefs feature.
*/
Modified: shindig/trunk/features/src/main/javascript/features/dynamic-height.height/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height.height/feature.xml?rev=1157210&r1=1157209&r2=1157210&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-height.height/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-height.height/feature.xml Fri Aug 12 18:41:04 2011
@@ -20,7 +20,7 @@ specific language governing permissions
<name>dynamic-height.height</name>
<dependency>globals</dependency>
<dependency>taming</dependency>
- <dependency>dynamic-height.util</dependency>
+ <dependency>dynamic-size.util</dependency>
<all>
<script src="dynamic-height-height.js"/>
<script src="taming.js" caja="1"/>
Modified: shindig/trunk/features/src/main/javascript/features/dynamic-height/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height/feature.xml?rev=1157210&r1=1157209&r2=1157210&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-height/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-height/feature.xml Fri Aug 12 18:41:04 2011
@@ -21,7 +21,7 @@ specific language governing permissions
<dependency>globals</dependency>
<dependency>taming</dependency>
<dependency>dynamic-height.height</dependency>
- <dependency>dynamic-height.util</dependency>
+ <dependency>dynamic-size.util</dependency>
<dependency>rpc</dependency>
<gadget>
<script src="dynamic-height.js"/>
Propchange: shindig/trunk/features/src/main/javascript/features/dynamic-size.util/
------------------------------------------------------------------------------
bugtraq:number = true
Added: shindig/trunk/features/src/main/javascript/features/dynamic-size.util/dynamic-size-util.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-size.util/dynamic-size-util.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-size.util/dynamic-size-util.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-size.util/dynamic-size-util.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/**
+ * @fileoverview This library augments gadgets.window with functionality to get the frame's viewport
+ * dimensions.
+ */
+
+gadgets.window = gadgets.window || {};
+
+// we wrap these in an anonymous function to avoid storing private data
+// as members of gadgets.window.
+(function() {
+ /**
+ * Detects the inner dimensions of a frame. See:
+ * http://www.quirksmode.org/viewport/compatibility.html for more information.
+ *
+ * @return {Object} An object with width and height properties.
+ * @member gadgets.window
+ */
+ gadgets.window.getViewportDimensions = function() {
+ var x = 0;
+ var y = 0;
+ if (self.innerHeight) {
+ // all except Explorer
+ x = self.innerWidth;
+ y = self.innerHeight;
+ } else if (document.documentElement && document.documentElement.clientHeight) {
+ // Explorer 6 Strict Mode
+ x = document.documentElement.clientWidth;
+ y = document.documentElement.clientHeight;
+ } else if (document.body) {
+ // other Explorers
+ x = document.body.clientWidth;
+ y = document.body.clientHeight;
+ }
+ return {
+ width : x,
+ height : y
+ };
+ };
+})();
Added: shindig/trunk/features/src/main/javascript/features/dynamic-size.util/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-size.util/feature.xml?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-size.util/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-size.util/feature.xml Fri Aug 12 18:41:04 2011
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+
+<!-- TODO: rename to dynamic-height.viewport -->
+<feature>
+ <name>dynamic-size.util</name>
+ <dependency>globals</dependency>
+ <dependency>taming</dependency>
+ <all>
+ <script src="dynamic-size-util.js"/>
+ <script src="taming.js" caja="1"/>
+ <api>
+ <exports type="js">gadgets.window.getViewportDimensions</exports>
+ </api>
+ </all>
+</feature>
Added: shindig/trunk/features/src/main/javascript/features/dynamic-size.util/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-size.util/taming.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-size.util/taming.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-size.util/taming.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * @class
+ * Tame and expose core gadgets.window.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+ caja___.whitelistFuncs([
+ [gadgets.window, 'getViewportDimensions']
+ ]);
+});
Propchange: shindig/trunk/features/src/main/javascript/features/dynamic-width/
------------------------------------------------------------------------------
bugtraq:number = true
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width.width/dynamic-width-width.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width.width/dynamic-width-width.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width.width/dynamic-width-width.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width.width/dynamic-width-width.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/**
+ * @fileoverview This library augments gadgets.window with functionality
+ * to change the width of a gadget dynamically.
+ */
+
+/**
+ * @static
+ * @class Provides operations for getting information about the window the gadget is placed in.
+ * @name gadgets.window
+ */
+gadgets.window = gadgets.window || {};
+
+(function() {
+
+ /**
+ * Calculate inner content width is hard and different between browsers rendering in Strict vs.
+ * Quirks mode. We use a combination of three properties within document.body and
+ * document.documentElement: - scrollWidth - offsetWidth - clientWidth These values differ
+ * significantly between browsers and rendering modes. But there are patterns. It just takes a lot
+ * of time and persistence to figure out.
+ *
+ * @return The width of the content within the iframe
+ */
+ gadgets.window.getWidth = function() {
+ var viewportWidth = gadgets.window.getViewportDimensions().width;
+ var body = document.body;
+ var docEl = document.documentElement;
+ if (document.compatMode === 'CSS1Compat' && docEl && docEl.scrollWidth) {
+ // In Strict mode:
+ // The inner content width is contained in either:
+ // document.documentElement.scrollWidth
+ // document.documentElement.offsetWidth
+ // Based on studying the values output by different browsers,
+ // use the value that's NOT equal to the viewport width found above.
+ return docEl.scrollWidth !== vw ? docEl.scrollWidth : docEl.offsetWidth;
+
+ } else if (body) {
+ var scrollWidth = body.scrollWidth;
+ var offsetWidth = body.offsetWidth;
+
+ // Detect whether the inner content width is bigger or smaller
+ // than the bounding box (viewport). If bigger, take the larger
+ // value. If smaller, take the smaller value.
+ if ((scrollWidth > viewportWidth) && (scrollWidth > offsetWidth)) {
+ return scrollWidth;
+ }
+ return offsetWidth;
+ }
+ };
+
+}());
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width.width/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width.width/feature.xml?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width.width/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width.width/feature.xml Fri Aug 12 18:41:04 2011
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<feature>
+ <name>dynamic-width.width</name>
+ <dependency>globals</dependency>
+ <dependency>taming</dependency>
+ <dependency>dynamic-size.util</dependency>
+ <all>
+ <script src="dynamic-width-width.js"/>
+ <script src="taming.js" caja="1"/>
+ <api>
+ <exports type="js">gadgets.window.getWidth</exports>
+ </api>
+ </all>
+</feature>
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width.width/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width.width/taming.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width.width/taming.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width.width/taming.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * @class
+ * Tame and expose core gadgets.window.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+ caja___.whitelistFuncs([
+ [gadgets.window, 'getWidth']
+ ]);
+});
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width/dynamic-width.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width/dynamic-width.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width/dynamic-width.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width/dynamic-width.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/**
+ * @fileoverview This library augments gadgets.window with functionality
+ * to change the width of a gadget dynamically.
+ */
+
+/**
+ * @static
+ * @class Provides operations for getting information about and modifying the window the gadget is
+ * placed in.
+ * @name gadgets.window
+ */
+gadgets.window = gadgets.window || {};
+
+// we wrap these in an anonymous function to avoid storing private data
+// as members of gadgets.window.
+(function() {
+
+ /**
+ * Adjusts the gadget width
+ *
+ * @param {number=}
+ * opt_width An optional preferred width in pixels. If not specified, will attempt to fit
+ * the gadget to its content.
+ * @member gadgets.window
+ */
+ gadgets.window.adjustWidth = function(opt_width) {
+ opt_width = parseInt(opt_width, 10);
+ var widthAutoCalculated = false;
+ var viewportWidth = gadgets.window.getViewportDimensions().width;
+ var newWidth = opt_width || gadgets.window.getWidth();
+ if (navigator.userAgent.indexOf('AppleWebKit') >= 0) {
+ viewportWidth++; // Adjust for 1px inaccuracy in Webkit browsers
+ }
+ var callback = null;
+ if (isNaN(opt_width) && viewportWidth >= newWidth) {
+ // Due to quirks in the width property, the auto-calculated width will
+ // never be smaller than the size of the viewport. In order to decrease
+ // the width to a fit size, we must first make the viewport too small (1px),
+ // then callback a function that increases the frame to the right width.
+ callback = function() {
+ gadgets.window.adjustWidth();
+ };
+ newWidth = 1;
+ }
+ gadgets.rpc.call(null, 'resize_iframe_width', callback, newWidth);
+ };
+}());
+
+/**
+ * @see gadgets.window#adjustWidth
+ */
+var _IG_AdjustIFrameWidth = gadgets.window.adjustWidth;
+
+// TODO Attach gadgets.window.adjustWidth to the onresize event
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width/feature.xml?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width/feature.xml Fri Aug 12 18:41:04 2011
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<feature>
+ <name>dynamic-width</name>
+ <dependency>globals</dependency>
+ <dependency>taming</dependency>
+ <dependency>dynamic-width.width</dependency>
+ <dependency>dynamic-size.util</dependency>
+ <dependency>rpc</dependency>
+ <gadget>
+ <script src="dynamic-width.js"/>
+ <script src="taming.js" caja="1"/>
+ <api>
+ <exports type="js">gadgets.window.adjustWidth</exports>
+ </api>
+ </gadget>
+</feature>
Added: shindig/trunk/features/src/main/javascript/features/dynamic-width/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-width/taming.js?rev=1157210&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-width/taming.js (added)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-width/taming.js Fri Aug 12 18:41:04 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * @class
+ * Tame and expose core gadgets.window.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+ caja___.whitelistFuncs([
+ [gadgets.window, 'adjustWidth']
+ ]);
+});
Modified: shindig/trunk/features/src/main/javascript/features/features.txt
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/features.txt?rev=1157210&r1=1157209&r2=1157210&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Fri Aug 12 18:41:04 2011
@@ -50,8 +50,10 @@ features/core/feature.xml
features/defer.test/feature.xml
features/deferjs/feature.xml
features/dynamic-height.height/feature.xml
-features/dynamic-height.util/feature.xml
features/dynamic-height/feature.xml
+features/dynamic-size.util/feature.xml
+features/dynamic-width.width/feature.xml
+features/dynamic-width/feature.xml
features/embeddedexperiences/feature.xml
features/exportjs/feature.xml
features/flash/feature.xml