Author: erinnp
Date: Thu Sep 5 19:51:16 2013
New Revision: 1520402
URL: http://svn.apache.org/r1520402
Log:
Set up directives, support registering of views and navigating
Added:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/eventemitter.js
- copied unchanged from r1490040,
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/eventemitter.js
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/portal.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_opensocial.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_view_manager.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget_manager.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_wookie.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/portal.html
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/portal.html?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/portal.html
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/portal.html
Thu Sep 5 19:51:16 2013
@@ -96,6 +96,6 @@
</form>
</div>
<div class="widget" ng-hide="regionWidget.collapsed">
- <div rave-render-widget="regionWidget"></div>
+ <div render-iframe="regionWidget"></div>
</div>
</div>
\ No newline at end of file
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js
Thu Sep 5 19:51:16 2013
@@ -39,11 +39,7 @@ define(['rave'], function(rave){
var template = el.html();
el.remove();
- rave.registerView(viewName, {
- render: function () {
- return template;
- }
- });
+ rave.registerView(viewName, template);
}
}
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js
Thu Sep 5 19:51:16 2013
@@ -22,22 +22,22 @@
* and renders that regionWidget at the location of the directive.
*/
-define(['angular'], function(angular){
+define(['angular', 'rave'], function(angular, rave){
return [function(){
var directive = {
restrict: 'EA',
replace: true,
scope:{
- regionWidget: '='
+ regionWidget: '=renderIframe'
},
link: function (scope, element, attrs){
scope.$watch('regionWidget', function(){
+
if(scope.regionWidget){
- //Make clone so watch does not cycle too many times
- var regionWidgetClone =
angular.copy(scope.regionWidget);
+ var regionWidget =
rave.getWidget(scope.regionWidget.id);
//Render the widget
- regionWidgetClone.render(element[0]);
+ regionWidget.render(element[0]);
}
}, true);
}
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
Thu Sep 5 19:51:16 2013
@@ -22,25 +22,31 @@
* and renders that regionWidget at the location of the directive.
*/
-define(['rave'], function(rave){
- return ['$compile',
- function ($compile) {
+define(['rave'], function (rave) {
+ return ['$compile', '$rootScope',
+ function ($compile, $rootScope) {
var directive = {
restrict: 'A',
link: function (scope, el, attrs) {
var regionWidget = scope.$eval(attrs.renderRegionWidget);
+ regionWidget = rave.getWidget(regionWidget.id);
scope.$watch(function () {
return regionWidget._surface;
}, doRender)
+ regionWidget.on('navigate', function () {
+ //conditionally apply if not already in a digest cycle
+ if ($rootScope.$$phase != '$apply') {
+ scope.$apply();
+ }
+ });
+
function doRender() {
- var template = rave.renderView(regionWidget._surface);
+ var template = rave.getView(regionWidget._surface);
- if (template) {
- el.html(template);
- $compile(el.contents())(scope);
- }
+ el.html(template);
+ $compile(el.contents())(scope);
}
}
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
Thu Sep 5 19:51:16 2013
@@ -26,7 +26,7 @@ define(['underscore', 'rave'], function
region = page.regions[j] = new Regions(region);
_.each(region.regionWidgets, function (regionWidget, i) {
- regionWidget =
rave.registerWidget(regionWidget.regionId, regionWidget);
+ rave.registerWidget(regionWidget.regionId,
regionWidget);
region.regionWidgets[i] = new
RegionWidgets(regionWidget);
});
});
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_opensocial.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_opensocial.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_opensocial.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_opensocial.js
Thu Sep 5 19:51:16 2013
@@ -83,7 +83,7 @@ define(['underscore', 'core/rave_view_ma
"metadata": opt_gadgetInfo
},
height =
getHeightFromParams(gadget.metadata.modulePrefs),
- width =
getWidthFromParams(gadget.metadata.modulePrefs);
+ width =
getWidthFromParams(gadget.metadata.modulePrefs);
preloadMetadata(gadget);
@@ -115,11 +115,11 @@ define(['underscore', 'core/rave_view_ma
function requestNavigateTo(args, viewName, opt_params, opt_ownerId) {
var widget = args.gs._widget,
- viewSurface = viewName.split('.')[0],
- renderInto = viewManager.getView(viewSurface) ? viewSurface :
widget._el;
- //If the element has no ID then it was launched in some secondary
location. Destroy the view.
- if(widget._el.id === "") viewManager.destroyView(widget._view);
- widget.render(renderInto, {view: viewName, view_params:
opt_params, ownerId: opt_ownerId});
+ viewSurface = viewName || stateManager.getDefaultView();
+
+ viewSurface = viewSurface.split('.')[0];
+
+ widget.navigate(viewSurface, {view: viewName, view_params:
opt_params, ownerId: opt_ownerId});
}
function setPref(args, editToken, prefName, prefValue) {
@@ -161,10 +161,10 @@ define(['underscore', 'core/rave_view_ma
function getHeightFromParams(opts) {
var height;
- if(opts.height) {
+ if (opts.height) {
height = opts.height;
}
- else if(opts.preferredHeight) {
+ else if (opts.preferredHeight) {
height = opts.preferredHeight;
}
else {
@@ -175,10 +175,10 @@ define(['underscore', 'core/rave_view_ma
function getWidthFromParams(opts) {
var width;
- if(opts.width) {
+ if (opts.width) {
width = opts.width;
}
- else if(opts.preferredWidth) {
+ else if (opts.preferredWidth) {
width = opts.preferredWidth;
}
else {
@@ -187,26 +187,33 @@ define(['underscore', 'core/rave_view_ma
return width;
}
- exports.renderWidget = function (widget, el, opts) {
+ exports.renderWidget = function (widget, opts) {
if (widget.error) {
- widget.renderError(el, widget.error.message);
+ widget.renderError(widget.error.message);
return;
}
opts = opts || {};
- var site = container.newGadgetSite(el);
- site._widget = widget;
- widget._site = site;
+ if (!widget._site) {
+ widget._site = container.newGadgetSite(widget._el);
+ widget._site._widget = widget;
+ }
var renderParams = {};
- renderParams[osapi.container.RenderParam.VIEW] = opts.view ||
stateManager.getDefaultView();
+ renderParams[osapi.container.RenderParam.VIEW] = opts.view ||
widget.constructor.defaultView;
renderParams[osapi.container.RenderParam.ALLOW_DEFAULT_VIEW ] =
opts.allowDefaultView;
renderParams[osapi.container.RenderParam.DEBUG ] = opts.debug;
- renderParams[osapi.container.RenderParam.HEIGHT ] =
getHeightFromParams(opts);
+ renderParams[osapi.container.RenderParam.HEIGHT ] = opts.height ||
widget.constructor.defaultHeight;
renderParams[osapi.container.RenderParam.NO_CACHE ] = opts.noCache;
renderParams[osapi.container.RenderParam.TEST_MODE] =
opts.testMode;
- renderParams[osapi.container.RenderParam.WIDTH ] =
getWidthFromParams(opts);
+ renderParams[osapi.container.RenderParam.WIDTH ] = opts.width ||
widget.constructor.defaultWidth;
renderParams[osapi.container.RenderParam.USER_PREFS] =
getCompleteUserPrefSet(widget.userPrefs, widget.metadata.userPrefs);
- container.navigateGadget(site, widget.widgetUrl, opts.view_params,
renderParams, opts.callback);
+ container.navigateGadget(widget._site, widget.widgetUrl,
opts.view_params, renderParams, opts.callback);
+ }
+
+ exports.unrenderWidget = function (widget) {
+ if (widget._site) {
+ container.closeGadget(widget._site);
+ }
}
/**
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_view_manager.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_view_manager.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_view_manager.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_view_manager.js
Thu Sep 5 19:51:16 2013
@@ -110,7 +110,8 @@ define(['underscore'], function(_){
//TODO: this makes sure that the constructor gets a widget object,
but it's cheesy. Should clean it up.
view = new view(args[0]);
}
- view.render.apply(view, args);
+
+ return view.render.apply(view, args);
view._uid = _.uniqueId('rave_view_');
renderedViews[view._uid] = view;
return view;
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js
Thu Sep 5 19:51:16 2013
@@ -23,12 +23,25 @@
* @requires rave_view_manager
* @requires rave_providers
*/
-define(['underscore', 'core/rave_api', 'core/rave_view_manager',
'core/rave_providers'],
- function (_, api, viewManager, providers) {
+define(['underscore', './eventemitter', 'core/rave_api',
'core/rave_view_manager', 'core/rave_state_manager', 'core/rave_providers'],
+ function (_, EventEmitter, api, viewManager, stateManager, providers) {
- function getProvider(name) {
- return providers[name.toLowerCase()];
- }
+ /**
+ * Workaround for IE8 (HTMLElement is undefined)
+ * An item will have a nodeType of 1 if it is an HTMLElement
+ * Defaults to use instanceof if HTMLElement is defined
+ */
+ var isHTMLElement = (function () {
+ if (window.HTMLElement) {
+ return function (item) {
+ return item instanceof HTMLElement;
+ }
+ } else {
+ return function (item) {
+ return item.nodeType && item.nodeType == 1;
+ }
+ }
+ })();
/**
* Constructor for the rave RegionWidget object
@@ -46,7 +59,10 @@ define(['underscore', 'core/rave_api', '
_.extend(this, definition);
- this._provider = getProvider(provider);
+ this._provider = providers[provider.toLowerCase()];
+ this._el = document.createElement('div');
+ this._surface = stateManager.getDefaultView();
+ this._opts = {view: stateManager.getDefaultView()};
if (!this._provider) {
throw new Error('Cannot render widget ' + definition.widgetUrl
+ '. ' +
@@ -56,188 +72,99 @@ define(['underscore', 'core/rave_api', '
this._provider.initWidget(this);
}
- /**
- * Workaround for IE8 (HTMLElement is undefined)
- * An item will have a nodeType of 1 if it is an HTMLElement
- * Defaults to use instanceof if HTMLElement is defined
- */
- isHTMLElement = (function() {
- if (window.HTMLElement) {
- return function(item) {
- return item instanceof HTMLElement;
- }
- } else {
- return function(item) {
- return item.nodeType && item.nodeType == 1;
- }
- }
- })();
+ _.extend(Widget.prototype, EventEmitter.prototype);
/**
* Extends the RegionWidget's prototype. Convenience function for
adding functionality
- * to the RegionWidget interface
- * @param mixin {object}
- */
- Widget.extend = function (mixin) {
- _.extend(this.prototype, mixin);
- }
-
- /**
- * Renders the regionWidget onto the page into the given dom element.
This will delegate to
- * the regionWidget's provider.
- * @param [el] {(HTMLElement | string)} DOM element into which the
widget iframe will be rendered. If the
- * argument is an HTMLElement, the regionWidget will be rendered
directly into that element. If it is a
- * string, it will delegate to the rave_view_manager - rendering the
registered view, and rendering the
- * regionWidget into the return value of that views getWidgetSite
method.
- * A regionWidget keeps a handle on the dom element it was rendered
into, so after the first render
- * if this argument is omitted, the region will re-render into that
element.
- * @param [opts] {object} Render options which are passed to the
provider's renderWidget method.
- * Supported options are therefore provider-specific.
- * @return this
- * @see module:rave_view_manager
- */
- Widget.prototype.render = function (el, opts) {
-
-
-
- //if we receive only one argument, and the first arg is not a
string or dom element, assume it is an opts object
- //and el should default to the widgets current render element
- if (!opts && !(_.isString(el) || (isHTMLElement(el)))) {
- opts = el;
- el = this._el;
- }
- //if el is a string, go to rave's view system
- if (_.isString(el)) {
- //TODO: potential memory leak - rendering a widget into new
views does not force cleanup of current view
- var view = viewManager.renderView(el, this);
- el = view.getWidgetSite();
- this._view = view;
+ * to the RegionWidget interface. Extended functions will also trigger
events.
+ * @param key {string | object} If first argument is an object, it
will iterate over the keys invoke extend
+ * for each key / value pair.
+ * @param fn {function}
+ */
+ Widget.extend = function (key, fn) {
+ var self = this;
+ if (_.isObject(key)) {
+ return _.each(key, function (f, k) {
+ self.extend(k, f);
+ });
+ }
+ this.prototype[key] = function () {
+ var args = _.toArray(arguments);
+ fn.apply(this, args);
+ this.emitEvent(key, args);
}
- //at this point el must be a valid dom element. if not, throw an
error
- if (!(isHTMLElement(el))) {
- throw new Error('Cannot render widget. You must provide an el
to render the view into');
- }
- this._el = el;
- this._provider.renderWidget(this, el, opts);
- return this;
}
- /**
- * Prints error messages into the given dom element.
- * @param el {HTMLElement}
- * @param errors {string}
- */
- Widget.prototype.renderError = function (el, errors) {
- el.innerHTML = 'Error rendering widget.' + "<br /><br />" + errors;
- }
-
- /**
- * Sets the collapsed property of the regionWidget object to true, and
persists state to the server.
- * Does not cause any dom manipulation.
- */
- Widget.prototype.hide = function () {
- this.collapsed = true;
- api.rest.saveWidgetCollapsedState({
- regionWidgetId: this.regionWidgetId,
- collapsed: this.collapsed
- });
- }
+ Widget.extend({
+ /**
+ * Renders the regionWidget onto the page into the given dom
element. This will delegate to
+ * the regionWidget's provider.
+ * @param [el] {(HTMLElement | string)} DOM element into which the
widget iframe will be rendered. If the
+ * argument is an HTMLElement, the regionWidget will be rendered
directly into that element. If it is a
+ * string, it will delegate to the rave_view_manager - rendering
the registered view, and rendering the
+ * regionWidget into the return value of that views getWidgetSite
method.
+ * A regionWidget keeps a handle on the dom element it was
rendered into, so after the first render
+ * if this argument is omitted, the region will re-render into
that element.
+ * @param [opts] {object} Render options which are passed to the
provider's renderWidget method.
+ * Supported options are therefore provider-specific.
+ * @return this
+ * @see module:rave_view_manager
+ */
+ 'render': function (el) {
+ if (el) {
+ if (!(isHTMLElement(el))) {
+ throw new Error('Cannot render widget. You must
provide an el to render the view into');
+ }
- /**
- * Sets the collapsed property of the regionWidget object to false,
and persists state to the server.
- * Does not cause any dom manipulation.
- */
- Widget.prototype.show = function () {
- this.collapsed = false;
-
- api.rest.saveWidgetCollapsedState({
- regionWidgetId: this.regionWidgetId,
- collapsed: this.collapsed
- });
- }
-
- /**
- * Unrenders the regionWidget from the page, and persists state to the
server. If the regionWidget was
- * rendered into a view, also invokes
module:rave_view_manager.destroyView method on that view.
- * @param [opts] {object} options object that is passed to the
provider's close widget method.
- */
- Widget.prototype.close = function (opts) {
- this._provider.closeWidget(this, opts);
- if (this._view) {
- viewManager.destroyView(this._view);
- }
-
- api.rpc.removeWidget({
- regionWidgetId: this.regionWidgetId
- });
- }
-
- /**
- * A callback invoked after a successful call to the jsonRpc api.
- * @callback apiSuccessCallback
- * @param jsonRpcResult {object} - json rpc api result object.
- */
+ el.appendChild(this._el);
+ }
+ this._provider.renderWidget(this, this._opts);
- /**
- * Makes api calls to persists move state to the server. Moves
regionWidget object from one page to another.
- * Does not cause any dom manipulation.
- * @param toPageId {string}
- * @param [cb] {apiSuccessCallback} - callback function that will be
invoked only if the state is successfully
- * saved to the server.
- */
- Widget.prototype.moveToPage = function (toPageId, cb) {
- api.rpc.moveWidgetToPage({
- toPageId: toPageId,
- regionWidgetId: this.regionWidgetId,
- successCallback: cb
- });
- }
+ return this;
+ },
- /**
- * Makes api calls to persist move state to the server. Moves the
regionWidget object between regions on a page.
- * Does not cause any dom manipulation.
- * @param fromRegionId {string}
- * @param toRegionId {string}
- * @param toIndex {string}
- */
- Widget.prototype.moveToRegion = function (fromRegionId, toRegionId,
toIndex) {
- api.rpc.moveWidgetToRegion({
- regionWidgetId: this.regionWidgetId,
- fromRegionId: fromRegionId,
- toRegionId: toRegionId,
- toIndex: toIndex
- });
- }
-
- /**
- * Regionwidget userPref object
- * @typedef Pref
- * @property name {string} Preference name
- * @property value {*} Preference value
- */
+ 'navigate': function (surface, opts) {
+ opts = opts || {};
- /**
- * Updates the regionWidget's userPrefs object, updating a single
preference, and persists state to server.
- * Does not cause any dom manipulation.
- * @param name {string}
- * @param val {*} new preference value
- */
- Widget.prototype.savePreference = function (name, val) {
- this.userPrefs[name] = val;
- api.rest.saveWidgetPreference({regionWidgetId:
this.regionWidgetId, prefName: name, prefValue: val});
- }
+ this._opts = opts;
+ //if the new view surface is supported, change the widget's
surface
+ if (viewManager.getView(surface)) {
+ this._surface = surface;
+ }
+ this.render();
+ },
- /**
- * Updates the regionWidget's userPrefs property, overwriting the
entire object, and persists state to the
- * server. Does not cause any dom manipulation.
- * @param updatedPrefs {Array.<Pref>} Array of new preference objects
- */
- Widget.prototype.savePreferences = function (updatedPrefs) {
- this.userPrefs = updatedPrefs;
- api.rest.saveWidgetPreferences({regionWidgetId:
this.regionWidgetId, userPrefs: updatedPrefs});
- }
+ 'unrender': function () {
+ this._provider.unrenderWidget(this);
+ return this;
+ },
+
+ /**
+ * Prints error messages into the given dom element.
+ * @param errors {string}
+ */
+ 'renderError': function (errors) {
+ this._el.innerHTML = 'Error rendering widget.' + "<br /><br
/>" + errors;
+ },
+
+ /**
+ * Sets the collapsed property of the regionWidget object to true,
and persists state to the server.
+ * Does not cause any dom manipulation.
+ */
+ 'hide': function () {
+ this.collapsed = true;
+ },
+
+ /**
+ * Sets the collapsed property of the regionWidget object to
false, and persists state to the server.
+ * Does not cause any dom manipulation.
+ */
+ 'show': function () {
+ this.collapsed = false;
+ }
+ });
return Widget;
})
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget_manager.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget_manager.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget_manager.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget_manager.js
Thu Sep 5 19:51:16 2013
@@ -47,8 +47,8 @@ define(['underscore', 'core/rave_widget'
//TODO: until api can be updated, attach regionid as an attribute
on the widget so that we can filter on this
definition.regionId = regionId;
}
- regionWidgets[definition.regionWidgetId] = new regionWidget(definition)
- return regionWidgets[definition.regionWidgetId];
+ regionWidgets[definition.id] = new regionWidget(definition)
+ return regionWidgets[definition.id];
}
//uregister a regionwidget, identified by a RegionWidget object, a widget
definition, or just an id
@@ -58,7 +58,7 @@ define(['underscore', 'core/rave_widget'
* RegionWidget object, or a valid id of a registered regionWidget.
*/
exports.unregisterWidget = function (widget) {
- var regionWidgetId = widget.regionWidgetId || widget;
+ var regionWidgetId = widget.id || widget;
delete regionWidgets[regionWidgetId];
}
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_wookie.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_wookie.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_wookie.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_wookie.js
Thu Sep 5 19:51:16 2013
@@ -23,44 +23,54 @@
* @requires rave_openajax_hub
* @requires rave_state_manager
*/
-define(['core/rave_openajax_hub', 'core/rave_state_manager'],
function(managedHub, stateManager){
- var exports = {}
+define(['core/rave_openajax_hub', 'core/rave_state_manager'], function
(managedHub, stateManager) {
+ var exports = {}
- exports.initWidget = function(widget){}
- exports.renderWidget = function(widget, el, opts){
- var widgetBodyElement = document.getElementById(["widget-",
widget.regionWidgetId, "-body"].join(""));
- window["onWidget"+widget.regionWidgetId+"Load"] = function(){
-
window.document.getElementById(widget.regionWidgetId).style.visibility="visible";
- };
-
- new OpenAjax.hub.IframeContainer(managedHub ,
""+widget.regionWidgetId,
- {
- Container: {
- onSecurityAlert: onClientSecurityAlert,
- onConnect: onClientConnect,
- onDisconnect: onClientDisconnect
+ exports.initWidget = function (widget) {
+ }
+ exports.renderWidget = function (widget, opts) {
+ var widgetBodyElement = document.getElementById(["widget-",
widget.regionWidgetId, "-body"].join(""));
+ window["onWidget" + widget.regionWidgetId + "Load"] = function () {
+
window.document.getElementById(widget.regionWidgetId).style.visibility =
"visible";
+ };
+
+ new OpenAjax.hub.IframeContainer(managedHub, "" +
widget.regionWidgetId,
+ {
+ Container: {
+ onSecurityAlert: onClientSecurityAlert,
+ onConnect: onClientConnect,
+ onDisconnect: onClientDisconnect
+ },
+ IframeContainer: {
+ parent: widget._el,
+ iframeAttrs: {
+ height: widget.height ||
stateManager.getDefaultHeight(),
+ width: widget.width || stateManager.getDefaultWidth(),
+ frameborder: 0
},
- IframeContainer: {
- parent: el,
- iframeAttrs: {
- height: widget.height ||
stateManager.getDefaultHeight(),
- width: widget.width ||
stateManager.getDefaultWidth(),
- frameborder: 0
- },
- uri: widget.widgetUrl,
- onGadgetLoad: "onWidget"+widget.regionWidgetId+"Load"
- }
+ uri: widget.widgetUrl,
+ onGadgetLoad: "onWidget" + widget.regionWidgetId + "Load"
}
- );
- }
+ }
+ );
+ }
+
+ exports.unrenderWidget = function () {
+ //TODO...
+ }
+
+ function onClientSecurityAlert(source, alertType) { /* Handle client-side
security alerts */
+ }
+
+ function onClientConnect(container) { /* Called when client
connects */
+ }
+
+ function onClientDisconnect(container) { /* Called when client
disconnects */
+ }
- function onClientSecurityAlert(source, alertType) { /* Handle
client-side security alerts */ }
- function onClientConnect(container) { /* Called when client
connects */ }
- function onClientDisconnect(container) { /* Called when client
disconnects */ }
-
- exports.closeWidget = function(widget){
- //TODO...
- }
+ exports.closeWidget = function (widget) {
+ //TODO...
+ }
- return exports;
+ return exports;
})
\ No newline at end of file
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
URL:
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js?rev=1520402&r1=1520401&r2=1520402&view=diff
==============================================================================
---
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
(original)
+++
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/portal/portal.js
Thu Sep 5 19:51:16 2013
@@ -17,6 +17,9 @@
* under the License.
*/
-define(['angular', 'portal/routes', 'portal/controllers/index'], function
(angular) {
- return angular.module('portal', ['portal.routes', 'portal.controllers']);
+define(['angular', 'rave', 'portal/routes', 'portal/controllers/index'],
function (angular, rave) {
+ return angular.module('portal', ['portal.routes', 'portal.controllers'])
+ .config(function(){
+ rave.setDefaultView('home');
+ });
});
\ No newline at end of file