You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by dd...@apache.org on 2012/04/12 15:52:14 UTC
svn commit: r1325259 - in /shindig/trunk/features: ./
src/main/javascript/features/ src/main/javascript/features/container/
src/main/javascript/features/open-views.common/
src/main/javascript/features/open-views.ee/
src/main/javascript/features/open-vi...
Author: ddumont
Date: Thu Apr 12 13:52:13 2012
New Revision: 1325259
URL: http://svn.apache.org/viewvc?rev=1325259&view=rev
Log:
SHINDIG-1721: Separate out the different open* APIs into their own features so they can easily be enabled/disabled
Added:
shindig/trunk/features/src/main/javascript/features/open-views.common/
shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml (with props)
shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.ee/
shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml (with props)
shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.gadget/
shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml (with props)
shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.results/
shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml (with props)
shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.url/
shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml (with props)
shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js (with props)
shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js (with props)
Removed:
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js
Modified:
shindig/trunk/features/pom.xml
shindig/trunk/features/src/main/javascript/features/container/container.js
shindig/trunk/features/src/main/javascript/features/features.txt
shindig/trunk/features/src/main/javascript/features/open-views/feature.xml
Modified: shindig/trunk/features/pom.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/pom.xml?rev=1325259&r1=1325258&r2=1325259&view=diff
==============================================================================
--- shindig/trunk/features/pom.xml (original)
+++ shindig/trunk/features/pom.xml Thu Apr 12 13:52:13 2012
@@ -179,9 +179,17 @@
<source>opensearch/opensearch.js</source>
<source>embeddedexperiences/constant.js</source>
<source>embeddedexperiences/embedded_experiences_container.js</source>
- <source>open-views/viewenhancements-container.js</source>
- <source>open-views/viewenhancements.js</source>
<source>proxied-form-post/post.js</source>
+ <source>open-views.common/open-views-common-container.js</source>
+ <source>open-views.common/open-views-common-gadget.js</source>
+ <source>open-views.url/open-views-url-container.js</source>
+ <source>open-views.url/open-views-url-gadget.js</source>
+ <source>open-views.gadget/open-views-gadget-container.js</source>
+ <source>open-views.gadget/open-views-gadget-gadget.js</source>
+ <source>open-views.ee/open-views-ee-container.js</source>
+ <source>open-views.ee/open-views-ee-gadget.js</source>
+ <source>open-views.results/open-views-results-container.js</source>
+ <source>open-views.results/open-views-results-gadget.js</source>
</sources>
<testSourceDirectory>${basedir}/src/test/javascript/features</testSourceDirectory>
<testSuites>
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=1325259&r1=1325258&r2=1325259&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Thu Apr 12 13:52:13 2012
@@ -392,7 +392,17 @@ osapi.container.Container.prototype.onCo
* @param {function} func to call when creating the namespace.
*/
osapi.container.Container.addMixin = function(namespace, func) {
- osapi.container.Container.prototype.mixins_[namespace] = func;
+ var mixins = osapi.container.Container.prototype.mixins_;
+
+ if (mixins[namespace]) {
+ var orig = mixins[namespace];
+ mixins[namespace] = function(container) {
+ orig.call(this, container);
+ return func.call(this, container);
+ };
+ } else {
+ mixins[namespace] = func;
+ }
};
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=1325259&r1=1325258&r2=1325259&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Thu Apr 12 13:52:13 2012
@@ -77,6 +77,11 @@ features/opensocial-jsonrpc/feature.xml
features/opensocial-reference/feature.xml
features/opensocial-templates/feature.xml
features/open-views/feature.xml
+features/open-views.common/feature.xml
+features/open-views.ee/feature.xml
+features/open-views.gadget/feature.xml
+features/open-views.results/feature.xml
+features/open-views.url/feature.xml
features/osapi.base/feature.xml
features/osapi/feature.xml
features/osml/feature.xml
Added: shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml Thu Apr 12 13:52:13 2012
@@ -0,0 +1,41 @@
+<?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>open-views.common</name>
+ <dependency>globals</dependency>
+ <dependency>rpc</dependency>
+ <dependency>container</dependency>
+ <dependency>views</dependency>
+ <gadget>
+ <script src="open-views-common-gadget.js"/>
+ <api>
+ <exports type="js">gadgets.views.close</exports>
+ <exports type="js">gadgets.window.getContainerDimensions</exports>
+ <uses type="rpc">gadgets.views.close</uses>
+ <uses type="rpc">gadgets.window.getContainerDimensions</uses>
+ </api>
+ </gadget>
+ <container>
+ <script src="open-views-common-container.js"/>
+ <api>
+ <exports type="rpc">gadgets.views.close</exports>
+ <exports type="rpc">gadgets.window.getContainerDimensions</exports>
+ </api>
+ </container>
+</feature>
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/feature.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,67 @@
+/*
+ * 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 Container-side common script.
+ */
+
+osapi.container.Container.addMixin('views', function(container) {
+ var self = this;
+
+ /**
+ * Closes an opened site. If the opt_id parameter is null the container will
+ * close the calling site.
+ *
+ * @param {Object=}
+ * opt_site: Optional parameter which specifies what site to close.
+ * If not provided or null, it will close the current gadget site.
+ */
+ container.rpcRegister('gadgets.views.close', function(rpcArgs, opt_site) {
+ // opt_site may be 0, do not do a truthy test on the value.
+ var orig_site = container.getGadgetSiteByIframeId_(rpcArgs.f),
+ site = typeof(opt_site) != 'undefined' && opt_site != null ?
+ container.getSiteById(opt_site) : orig_site;
+
+ if (site && (site == orig_site || site.ownerId_ == rpcArgs.f)) {
+ // The provided method must ultimately call container.closeGadget(site);
+ self.destroyElement(site);
+ }
+ });
+
+ /**
+ * Gets the dimensions of the container displaying the gadget.
+ */
+ container.rpcRegister('gadgets.window.getContainerDimensions', function(rpcArgs) {
+ var el = document.documentElement; // Container element
+ return {
+ width : el ? el.clientWidth : -1,
+ height: el ? el.clientHeight : -1
+ };
+ });
+
+ /**
+ * Method will be called when a gadget wants to close itself or the
+ * parent gadget wants to close a gadget or url site it has opened.
+ *
+ * @param {Object}
+ * site: The site to close.
+ */
+ this.destroyElement = function(site) {
+ console.log('container needs to define destroyElement function');
+ };
+});
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-container.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,51 @@
+/*
+ * 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 view enhancement library for gadgets.
+ */
+
+gadgets['window'] = gadgets['window'] || {};
+gadgets.views = gadgets.views || {};
+
+/**
+ * Closes an opened site. If the opt_id parameter is null the container will
+ * close the calling site.
+ *
+ * @param {Object=}
+ * opt_site: Optional parameter which specifies what site to close.
+ * If null it will close the current gadget site.
+ */
+gadgets.views.close = function(opt_site) {
+ gadgets.rpc.call('..', 'gadgets.views.close', null,
+ opt_site
+ );
+};
+
+/**
+ * Gets the dimensions of the container displaying this gadget through
+ * callback function which will be called with the return value as a
+ * parameter.
+ *
+ * @param {function}
+ * resultCallback: Callback function will be called with the return
+ * value as a parameter.
+ */
+gadgets.window.getContainerDimensions = function(resultCallback) {
+ gadgets.rpc.call('..', 'gadgets.window.getContainerDimensions', resultCallback);
+};
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.common/open-views-common-gadget.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml Thu Apr 12 13:52:13 2012
@@ -0,0 +1,39 @@
+<?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>open-views.ee</name>
+ <dependency>open-views.common</dependency>
+ <dependency>open-views.results</dependency>
+ <dependency>container.site.gadget</dependency>
+ <dependency>container.site.url</dependency>
+ <dependency>embedded-experiences</dependency>
+ <gadget>
+ <script src="open-views-ee-gadget.js"/>
+ <api>
+ <exports type="js">gadgets.views.openEmbeddedExperience</exports>
+ <uses type="rpc">gadgets.views.openEmbeddedExperience</uses>
+ </api>
+ </gadget>
+ <container>
+ <script src="open-views-ee-container.js"/>
+ <api>
+ <exports type="rpc">gadgets.views.openEmbeddedExperience</exports>
+ </api>
+ </container>
+</feature>
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/feature.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,160 @@
+/*
+ * 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 Container-side url script.
+ */
+
+osapi.container.Container.addMixin('views', function(container) {
+ var self = this;
+
+ /**
+ * Opens an embedded experience in the container UI. The location of the site
+ * in the container will be determined by the view target passed in. The
+ * container would open the embedded experience in a dialog, if view target is
+ * dialog or the embedded experience view in a tab for view target is tab.
+ *
+ * @param {number}
+ * resultCallback: Callback function id to be called when the embedded
+ * experience closes. The function will be called with the return
+ * value as a parameter.
+ * @param {Object}
+ * dataModel: The embedded experiences data model.
+ * @param {Object}
+ * opt_params: These are optional parameters which can be used to
+ * open gadgets. The following parameters may be included in this
+ * object.
+ * {string} viewTarget: The view that indicates where to open
+ * the gadget. For example, tab, dialog or modaldialog
+ * {Object} viewParams: View parameters for the view being
+ * rendered.
+ * {Object} coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * Do not specify top AND bottom or left AND right parameters to
+ * indirectly define height and width. Use viewParams for that.
+ * The result of doing so here is undefined.
+ * It is expected that coordinates will only be used with
+ * viewTargets of FLOAT. Containers may implement the behavior
+ * for other viewTargets, and custom viewTargets at their
+ * discretion.
+ */
+ container.rpcRegister('gadgets.views.openEmbeddedExperience', function (rpcArgs, resultCallback, dataModel, opt_params) {
+ var navigateCallback = rpcArgs.callback,
+ siteOwnerId = rpcArgs.f,
+ gadgetUrl = dataModel.gadget;
+
+ var navigateEE = function(opt_metadata) {
+ var viewTarget = '',
+ viewParams = {},
+ coordinates;
+ if (opt_params) {
+ if (opt_params.viewTarget)
+ viewTarget = opt_params.viewTarget;
+ if (opt_params.viewParams)
+ viewParams = opt_params.viewParams;
+ if (opt_params.coordinates) {
+ coordinates = opt_params.coordinates;
+ }
+ }
+ var orig_site = container.getGadgetSiteByIframeId_(siteOwnerId),
+ rel = orig_site.getActiveSiteHolder().getIframeElement();
+
+ var element = self.createElementForEmbeddedExperience(
+ rel, opt_metadata, viewTarget, coordinates, orig_site
+ );
+
+ var gadgetRenderParams = {};
+ gadgetRenderParams[osapi.container.RenderParam.VIEW] =
+ osapi.container.ee.RenderParam.EMBEDDED;
+ gadgetRenderParams[osapi.container.RenderParam.WIDTH] = '100%';
+ gadgetRenderParams[osapi.container.RenderParam.HEIGHT] = '100%';
+
+ var urlRenderParams = {};
+ urlRenderParams[osapi.container.RenderParam.WIDTH] = '100%';
+ urlRenderParams[osapi.container.RenderParam.HEIGHT] = '100%';
+
+ var eeRenderParams = {};
+ eeRenderParams[osapi.container.ee.RenderParam.GADGET_RENDER_PARAMS] =
+ gadgetRenderParams;
+ eeRenderParams[osapi.container.ee.RenderParam.URL_RENDER_PARAMS] =
+ urlRenderParams;
+ eeRenderParams[osapi.container.ee.RenderParam.GADGET_VIEW_PARAMS] =
+ viewParams;
+
+ container.ee.navigate(element, dataModel, eeRenderParams, function(site, result) {
+ site.ownerId_ = siteOwnerId;
+ if (result) {
+ self.resultCallbacks_[site.getId()] = resultCallback;
+ }
+ if (navigateCallback) {
+ navigateCallback([site.getId(), result]);
+ }
+ });
+ };
+
+ if(gadgetUrl) {
+ //Check to make sure we can actually reach the gadget we are going to try
+ //to render before we do anything else
+ container.preloadGadget(gadgetUrl, function(result) {
+ if (!result[gadgetUrl] || result[gadgetUrl].error) {
+ //There was an error, check to see if there is still the option to
+ //render the url, else just call the navigateCallback
+ if (!dataModel.url) {
+ if (navigateCallback != null) {
+ navigateCallback([null, result[gadgetUrl] || {"error" : result}]);
+ }
+ return;
+ }
+ }
+ navigateEE(result[gadgetUrl]);
+ });
+ } else {
+ navigateEE();
+ }
+ });
+
+
+ /**
+ * Method will be called to create the DOM element to place the embedded
+ * experience in.
+ *
+ *@param {Element}
+ * rel: The element to which opt_coordinates values are
+ * relative.
+ * @param {Object}
+ * opt_gadgetInfo: Info for the gadget embedded experience,
+ * if the data model contains a gadget URL.
+ * @param {string=}
+ * opt_viewTarget: Optional parameter, the view target indicates
+ * where to open.
+ * @param {Object=}
+ * opt_coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * @param {osapi.container.Site} parentSite
+ * The site opening the EE.
+ * @return {Object} The DOM element to place the embedded experience in.
+ */
+ this.createElementForEmbeddedExperience = function(rel, opt_gadgetInfo, opt_viewTarget,
+ opt_coordinates, parentSite) {
+ console.log('container needs to define createElementForEmbeddedExperience function');
+ };
+});
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-container.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,62 @@
+/*
+ * 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 view enhancement library for gadgets.
+ */
+
+gadgets.views = gadgets.views || {};
+
+/**
+ * Opens an embedded experience in the container UI. The location of the
+ * gadget site in the container will be determined by the view target passed
+ * in. The container would open the view in a dialog, if view target is dialog
+ * or the gadgets view in a tab for view target is tab.
+ *
+ * @param {function}
+ * resultCallback: Callback function to be called when the gadget
+ * closes. The function will be called with the return value as a
+ * parameter.
+ * @param {function}
+ * navigateCallback: Callback function to be called with the site and
+ * gadget metadata.
+ * @param {function}
+ * dataModel: The embedded experiences data model.
+ * @param {Object}
+ * opt_params: These are optional parameters which can be used to
+ * open gadgets. The following parameters may be included in this
+ * object.
+ * {string} viewTarget: The view that indicates where to open the
+ * gadget. For example, tab, dialog or modaldialog
+ * {Object} viewParams: View parameters for the view being
+ * rendered.
+ * {Object} coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * Do not specify top AND bottom or left AND right parameters to
+ * indirectly define height and width. Use viewParams for that.
+ * The result of doing so here is undefined.
+ */
+gadgets.views.openEmbeddedExperience = function(resultCallback,
+ navigateCallback, dataModel, opt_params) {
+ gadgets.rpc.call('..', 'gadgets.views.openEmbeddedExperience', function(result) {
+ navigateCallback.apply(this, result);
+ }, gadgets.views.registerCallback_(resultCallback), dataModel, opt_params
+ );
+};
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.ee/open-views-ee-gadget.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml Thu Apr 12 13:52:13 2012
@@ -0,0 +1,37 @@
+<?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>open-views.gadget</name>
+ <dependency>open-views.common</dependency>
+ <dependency>open-views.results</dependency>
+ <dependency>container.site.gadget</dependency>
+ <gadget>
+ <script src="open-views-gadget-gadget.js"/>
+ <api>
+ <exports type="js">gadgets.views.openGadget</exports>
+ <uses type="rpc">gadgets.views.openGadget</uses>
+ </api>
+ </gadget>
+ <container>
+ <script src="open-views-gadget-container.js"/>
+ <api>
+ <exports type="rpc">gadgets.views.openGadget</exports>
+ </api>
+ </container>
+</feature>
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/feature.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,161 @@
+/*
+ * 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 Container-side url script.
+ */
+
+osapi.container.Container.addMixin('views', function(container) {
+ var self = this;
+
+ /**
+ * Opens a gadget in the container UI. The location of the gadget site in the
+ * container will be determined by the view target passed in. The container
+ * would open the view in a dialog, if view target is dialog or the gadgets
+ * view in a tab for view target is tab.
+ *
+ * @param {number}
+ * resultCallback: Callback id of function to be called when the gadget
+ * closes. The function will be called with the return value as a
+ * parameter.
+ * @param {Object.<string, string|Object>=}
+ * opt_params: These are optional parameters which can be used to
+ * open gadgets. The following parameters may be included in this
+ * object.
+ * {string} view: The view to render. Should be one of the
+ * views returned by calling gadgets.views.getSupportedViews. If
+ * the view is not included the default view will be rendered.
+ * {string} viewTarget: The view that indicates where to open the
+ * gadget. For example, tab, dialog or modaldialog
+ * {Object} viewParams: View parameters for the view being
+ * rendered.
+ * {Object} coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * Do not specify top AND bottom or left AND right parameters to
+ * indirectly define height and width, use viewParams for that.
+ * The result of doing so here is undefined.
+ * It is expected that coordinates will only be used with
+ * viewTargets of FLOAT. Containers may implement the behavior
+ * for other viewTargets, and custom viewTargets at their
+ * discretion.
+ */
+ container.rpcRegister('gadgets.views.openGadget', function (rpcArgs, resultCallback, opt_params) {
+ var navigateCallback = rpcArgs.callback,
+ siteOwnerId = rpcArgs.f,
+ gadgetUrl = '',
+ orig_site = container.getGadgetSiteByIframeId_(rpcArgs.f);
+
+ if ((typeof orig_site != 'undefined') &&
+ (typeof orig_site.getActiveSiteHolder() != 'undefined')) {
+ // get url through gadget holder
+ gadgetUrl = orig_site.getActiveSiteHolder().getUrl();
+ }
+
+ var view = '',
+ viewTarget = '',
+ viewParams = {},
+ coordinates;
+ if (opt_params) {
+ if (opt_params.view)
+ view = opt_params.view;
+ if (opt_params.viewTarget)
+ viewTarget = opt_params.viewTarget;
+ if (opt_params.viewParams)
+ viewParams = opt_params.viewParams;
+ if(opt_params.coordinates) {
+ coordinates = opt_params.coordinates;
+ }
+ }
+
+ var rel = container.getGadgetSiteByIframeId_(rpcArgs.f).getActiveSiteHolder()
+ .getIframeElement();
+
+ container.preloadGadget(gadgetUrl, function(result) {
+ /*
+ * result[gadgetUrl] : metadata
+ */
+ var metadata = {};
+ if ((typeof result != 'undefined') && (typeof result[gadgetUrl] != 'undefined')) {
+ if (result[gadgetUrl].error) {
+ gadgets.error('Failed to preload gadget : ' + gadgetUrl);
+ if (navigateCallback != null) {
+ navigateCallback([null, result[gadgetUrl]]);
+ }
+ return;
+ } else {
+ metadata = result[gadgetUrl];
+ }
+ }
+
+ var renderParams = {},
+ elem = self.createElementForGadget(
+ metadata, rel, view, viewTarget, coordinates, orig_site
+ ),
+ site = container.newGadgetSite(elem);
+
+ site.ownerId_ = siteOwnerId;
+
+ if ((typeof view != 'undefined') && view !== '') {
+ renderParams[osapi.container.RenderParam.VIEW] = view;
+ }
+ renderParams[osapi.container.RenderParam.WIDTH] = '100%';
+ renderParams[osapi.container.RenderParam.HEIGHT] = '100%';
+
+ container.navigateGadget(site, gadgetUrl, viewParams, renderParams, function(metadata) {
+ if (metadata) {
+ self.resultCallbacks_[site.getId()] = resultCallback;
+ }
+ if (navigateCallback) {
+ navigateCallback([site.getId(), metadata]);
+ }
+ });
+ });
+ });
+
+ /**
+ * Method will be called to create the DOM element to place the Gadget
+ * Site in.
+ *
+ * @param {Object}
+ * metadata: Gadget meta data for the gadget being opened in
+ * this GadgetSite.
+ * @param {Element}
+ * rel: The element to which opt_coordinates values are
+ * relative.
+ * @param {string=}
+ * opt_view: Optional parameter, the view that indicates the
+ * type of GadgetSite.
+ * @param {string=}
+ * opt_viewTarget: Optional parameter, the view target indicates
+ * where to open the gadget.
+ * @param {Object=}
+ * opt_coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * @param {osapi.container.Site} parentSite
+ * The site opening the gadget view.
+ * @return {Object} The DOM element to place the GadgetSite in.
+ */
+ this.createElementForGadget = function(metadata, rel, opt_view, opt_viewTarget,
+ opt_coordinates, parentSite) {
+ console.log('container needs to define createElementForGadget function');
+ };
+});
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-container.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,64 @@
+/*
+ * 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 view enhancement library for gadgets.
+ */
+
+gadgets.views = gadgets.views || {};
+
+/**
+ * Opens a gadget in the container UI. The location of the gadget site in the
+ * container will be determined by the view target passed in. The container
+ * would open the view in a dialog, if view target is dialog or the gadgets
+ * view in a tab for view target is tab
+ *
+ * @param {function}
+ * resultCallback: Callback function to be called when the gadget
+ * closes. The function will be called with the return value as a
+ * parameter.
+ * @param {function}
+ * navigateCallback: Callback function to be called with the
+ * site and gadget metadata.
+ * @param {Object}
+ * opt_params: These are optional parameters which can be used to
+ * open gadgets. The following parameters may be included in this
+ * object.
+ * {string} view: The view to render. Should be one of the views
+ * returned by calling gadgets.views.getSupportedViews. If the
+ * view is not included the default view will be rendered.
+ * {string} viewTarget: The view that indicates where to open the
+ * gadget. For example, tab, dialog or modaldialog
+ * {Object} viewParams: View parameters for the view being
+ * rendered.
+ * {Object} coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * Do not specify top AND bottom or left AND right parameters to
+ * indirectly define height and width. Use viewParams for that.
+ * The result of doing so here is undefined.
+ */
+
+gadgets.views.openGadget = function(resultCallback, navigateCallback,
+ opt_params) {
+ gadgets.rpc.call('..', 'gadgets.views.openGadget', function(result) {
+ navigateCallback.apply(this, result);
+ }, gadgets.views.registerCallback_(resultCallback), opt_params
+ );
+};
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.gadget/open-views-gadget-gadget.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml Thu Apr 12 13:52:13 2012
@@ -0,0 +1,37 @@
+<?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>open-views.results</name>
+ <dependency>open-views.common</dependency>
+ <gadget>
+ <script src="open-views-results-gadget.js"/>
+ <api>
+ <exports type="js">gadgets.views.setReturnValue</exports>
+ <exports type="rpc">gadgets.views.deliverResult</exports>
+ <uses type="rpc">gadgets.views.setReturnValue</uses>
+ </api>
+ </gadget>
+ <container>
+ <script src="open-views-results-container.js"/>
+ <api>
+ <exports type="rpc">gadgets.views.setReturnValue</exports>
+ <uses type="rpc">gadgets.views.deliverResult</uses>
+ </api>
+ </container>
+</feature>
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/feature.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,63 @@
+/*
+ * 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 Container-side common script.
+ */
+
+osapi.container.Container.addMixin('views', function(container) {
+ this.resultCallbacks_ = {}; // Mapping between id and callback function
+ this.returnValues_ = {}; // Mapping between id and return value
+
+ var self = this,
+ lifecyclecb = {};
+ lifecyclecb[osapi.container.CallbackType.ON_BEFORE_CLOSE] = function(site) {
+ var id = site.getId(),
+ returnValue = self.returnValues_[id],
+ resultCallback = self.resultCallbacks_[id];
+
+ // Checking the truthiness of resultCallback is bad because 0 is a valid value.
+ // Check whether it is undefined
+ if (typeof resultCallback !== 'undefined') {
+ if (site.ownerId_) {
+ gadgets.rpc.call(site.ownerId_, 'gadgets.views.deliverResult', null,
+ resultCallback, returnValue
+ );
+ }
+ }
+
+ delete self.returnValues_[id];
+ delete self.resultCallbacks_[id];
+ };
+ container.addGadgetLifecycleCallback("open-views", lifecyclecb);
+
+ /**
+ * Sets the return value for the current window. This method should only be
+ * called inside those secondary view types defined in gadgets.views.ViewType.
+ * For example, DIALOG or MODALDIALOG
+ *
+ * @param {object}
+ * returnValue: Return value for this window.
+ */
+ container.rpcRegister('gadgets.views.setReturnValue', function (rpcArgs, returnValue) {
+ var site = container.getGadgetSiteByIframeId_(rpcArgs.f);
+ if (site) {
+ self.returnValues_[site.getId()] = returnValue;
+ }
+ });
+});
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-container.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js Thu Apr 12 13:52:13 2012
@@ -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 view enhancement library for gadgets.
+ */
+
+gadgets.views = gadgets.views || {};
+
+(function() {
+ var resultCallbackMap = {},
+ rcbnum = 0;
+
+ gadgets.util.registerOnLoadHandler(function() {
+ gadgets.rpc.register('gadgets.views.deliverResult', function(rcbnum, result) {
+ var resultCallback;
+ if (resultCallback = resultCallbackMap[rcbnum]) {
+ delete resultCallbackMap[rcbnum];
+ resultCallback(result);
+ }
+ });
+ });
+
+ gadgets.views.registerCallback_ = function(cb) {
+ resultCallbackMap[rcbnum] = cb;
+ return rcbnum++;
+ };
+
+ /**
+ * Sets the return value for the current window. This method should only be
+ * called inside those secondary view types defined in gadgets.views.ViewType.
+ * For example, DIALOG or MODALDIALOG
+ *
+ * @param {object}
+ * returnValue: Return value for this window.
+ */
+ gadgets.views.setReturnValue = function(returnValue) {
+ gadgets.rpc.call('..', 'gadgets.views.setReturnValue', null,
+ returnValue
+ );
+ };
+})();
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.results/open-views-results-gadget.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml Thu Apr 12 13:52:13 2012
@@ -0,0 +1,36 @@
+<?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>open-views.url</name>
+ <dependency>open-views.common</dependency>
+ <dependency>container.site.url</dependency>
+ <gadget>
+ <script src="open-views-url-gadget.js"/>
+ <api>
+ <exports type="js">gadgets.views.openUrl</exports>
+ <uses type="rpc">gadgets.views.openUrl</uses>
+ </api>
+ </gadget>
+ <container>
+ <script src="open-views-url-container.js"/>
+ <api>
+ <exports type="rpc">gadgets.views.openUrl</exports>
+ </api>
+ </container>
+</feature>
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/feature.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,91 @@
+/*
+ * 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 Container-side url script.
+ */
+
+osapi.container.Container.addMixin('views', function(container) {
+ var self = this;
+
+ /**
+ * Opens a URL in the container UI. The location of the URL site will be
+ * determined by the container based on the target view. The container would
+ * open the view in a dialog, if opt_viewTarget=dialog or the gadgets view in
+ * a tab for opt_viewTarget=tab
+ *
+ * @param {string}
+ * url: URL to a web page to open in a URL site in the container.
+ * (Note this should not be a URL to a gadget definition.).
+ * @param {string=}
+ * opt_viewTarget: Optional parameter, the view that indicates where
+ * to open the URL.
+ * @param {Object=} opt_coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * You may specify top AND bottom or left AND right parameters to
+ * indirectly define height and width.
+ * It is expected that coordinates will only be used with
+ * viewTargets of FLOAT. Containers may implement the behavior
+ * for other viewTargets, and custom viewTargets at their
+ * discretion.
+ * @returns {string} The ID of the site created, if a callback was registered.
+ */
+ container.rpcRegister('gadgets.views.openUrl', function (rpcArgs, url, opt_viewTarget, opt_coordinates) {
+ var orig_site = context.getGadgetSiteByIframeId_(rpcArgs.f),
+ rel = orig_site.getActiveSiteHolder().getIframeElement();
+
+ var content_div = self.createElementForUrl(rel, opt_viewTarget, opt_coordinates, orig_site);
+ var site = container.newUrlSite(content_div);
+
+ var renderParams = {}; // (height, width, class,userPrefsObject)
+ renderParams[osapi.container.RenderParam.WIDTH] = '100%';
+ renderParams[osapi.container.RenderParam.HEIGHT] = '100%';
+
+ container.navigateUrl(site, url, renderParams);
+
+ // record who opened this site, so that if they use the siteId to close it later,
+ // we don't inadvertently allow other gadgets to guess the id and close the site.
+ site.ownerId_ = rpcArgs.f;
+ return site.getId();
+ });
+
+ /**
+ * Method will be called to create the DOM element to place the UrlSite
+ * in.
+ *
+ * @param {Element}
+ * rel: The element to which opt_coordinates values are
+ * relative.
+ * @param {string=}
+ * opt_view: Optional parameter, the view to open. If not
+ * included the container should use its default view.
+ * @param {Object=}
+ * opt_coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * @param {osapi.container.Site} parentSite
+ * The site opening the url.
+ * @return {Object} The DOM element to place the UrlSite object in.
+ */
+ this.createElementForUrl = function(rel, opt_viewTarget, opt_coordinates, parentSite) {
+ console.log('container needs to define createElementForUrl function');
+ };
+});
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-container.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js?rev=1325259&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js (added)
+++ shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js Thu Apr 12 13:52:13 2012
@@ -0,0 +1,51 @@
+/*
+ * 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 view enhancement library for gadgets.
+ */
+
+gadgets.views = gadgets.views || {};
+
+/**
+ * Opens a URL in the container UI. The location of the URL site will be
+ * determined by the container based on the target view. The container would
+ * open the view in a dialog, if opt_viewTarget=dialog or the gadgets view in
+ * a tab for opt_viewTarget=tab
+ *
+ * @param {string}
+ * url: URL to a web page to open in a URL site in the container.
+ * (Note this should not be a URL to a gadget definition.).
+ * @param {function}
+ * navigateCallback: Callback function to be called with the
+ * site which has been opened.
+ * @param {string=}
+ * opt_viewTarget: Optional parameter, the view that indicates where
+ * to open the URL.
+ * @param {Object=} opt_coordinates: Object containing the desired absolute
+ * positioning css parameters (top|bottom|left|right) with
+ * appropriate values. All values are relative to the calling
+ * gadget.
+ * You may specify top AND bottom or left AND right parameters to
+ * indirectly define height and width
+ */
+gadgets.views.openUrl = function(url, navigateCallback, opt_viewTarget, opt_coordinates) {
+ gadgets.rpc.call('..', 'gadgets.views.openUrl', function(result) {
+ navigateCallback.call(this, result);
+ }, url, opt_viewTarget, opt_coordinates);
+};
\ No newline at end of file
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: shindig/trunk/features/src/main/javascript/features/open-views.url/open-views-url-gadget.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: shindig/trunk/features/src/main/javascript/features/open-views/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views/feature.xml?rev=1325259&r1=1325258&r2=1325259&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/open-views/feature.xml Thu Apr 12 13:52:13 2012
@@ -17,48 +17,8 @@ KIND, either express or implied. See the
specific language governing permissions and limitations under the License.
-->
<feature>
-<!--
-Required configuration:
-A map of view names to view attributes. Examples:
-
-
--->
<name>open-views</name>
- <dependency>globals</dependency>
- <dependency>rpc</dependency>
- <dependency>container</dependency>
- <dependency>container.site.url</dependency>
- <dependency>container.site.gadget</dependency>
- <dependency>views</dependency>
- <dependency>embedded-experiences</dependency>
- <gadget>
- <script src="viewenhancements.js"/>
- <api>
- <exports type="js">gadgets.views.openEmbeddedExperience</exports>
- <exports type="js">gadgets.views.openGadget</exports>
- <exports type="js">gadgets.views.openUrl</exports>
- <exports type="js">gadgets.views.close</exports>
- <exports type="js">gadgets.views.setReturnValue</exports>
- <exports type="js">gadgets.window.getContainerDimensions</exports>
- <exports type="rpc">gadgets.views.deliverResult</exports>
- <uses type="rpc">gadgets.views.openGadget</uses>
- <uses type="rpc">gadgets.views.openEmbeddedExperience</uses>
- <uses type="rpc">gadgets.views.openUrl</uses>
- <uses type="rpc">gadgets.views.close</uses>
- <uses type="rpc">gadgets.views.setReturnValue</uses>
- <uses type="rpc">gadgets.window.getContainerDimensions</uses>
- </api>
- </gadget>
- <container>
- <script src="viewenhancements-container.js"/>
- <api>
- <exports type="rpc">gadgets.views.openGadget</exports>
- <exports type="rpc">gadgets.views.openEmbeddedExperience</exports>
- <exports type="rpc">gadgets.views.openUrl</exports>
- <exports type="rpc">gadgets.views.close</exports>
- <exports type="rpc">gadgets.views.setReturnValue</exports>
- <exports type="rpc">gadgets.window.getContainerDimensions</exports>
- <uses type="rpc">gadgets.views.deliverResult</uses>
- </api>
- </container>
+ <dependency>open-views.ee</dependency>
+ <dependency>open-views.gadget</dependency>
+ <dependency>open-views.url</dependency>
</feature>