You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by er...@apache.org on 2013/05/15 18:45:47 UTC
svn commit: r1482948 - in
/rave/branches/angular/rave-portal-resources/src/main/webapp:
WEB-INF/jsp/views/ static/html/ static/html/portal/
static/html/portal/partials/ static/script/angular-portal/
static/script/core/
Author: erinnp
Date: Wed May 15 16:45:47 2013
New Revision: 1482948
URL: http://svn.apache.org/r1482948
Log:
implement popups
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/core/rave_widget.js
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp Wed May 15 16:45:47 2013
@@ -19,7 +19,7 @@
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>
-<script src="https://raw.github.com/angular-ui/bootstrap/gh-pages/ui-bootstrap-0.2.0.min.js"></script>
+<script src="https://raw.github.com/angular-ui/bootstrap/gh-pages/ui-bootstrap-0.3.0.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.3/bootstrap.min.js"></script>
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal.html?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal.html Wed May 15 16:45:47 2013
@@ -1,4 +1,3 @@
-
<div class="navbar">
<div class="navbar-inner">
<div class="container">
@@ -18,3 +17,55 @@
<div id="pageContent" class="container-fluid" ng-include="templateUrl">
</div>
+<div rave-modal>
+ <div class="popup modal_dialog modal fade">
+ <a href="#" class="close" data-dismiss="modal">×</a>
+
+ <div class="site"></div>
+ </div>
+</div>
+
+<div rave-dialog>
+ <div class="popup dialog modal fade">
+ <a href="#" class="close" data-dismiss="modal">×</a>
+
+ <div class="site"></div>
+ </div>
+</div>
+
+<div rave-sidebar>
+ <div class="popup slideout">
+ <a href="#" class="close">×</a>
+
+ <div class="slideout-content site">
+ </div>
+ </div>
+</div>
+
+<div rave-canvas>
+ <div class="widget-wrapper-canvas" id="widget-4-wrapper">
+ <div class="widget-title-bar">
+
+ <div class="widget-title">
+
+
+ Gadget View Type
+
+
+ </div>
+
+
+ <div class="widget-toolbar ">
+ <div class="dropdown widget-menu-wrapper" style="display: none;">
+
+ <span id="widget-4-min" class="widget-toolbar-btn widget-toolbar-btn-min" style="display: inline;">
+ <i class="icon-resize-small"></i>
+ </span>
+ </div>
+
+
+ </div>
+ <div class="site"></div>
+ </div>
+ </div>
+</div>
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html Wed May 15 16:45:47 2013
@@ -18,39 +18,39 @@
<i class="icon-cog"></i>
</a>
<ul class="dropdown-menu widget-menu">
- <li class="">
- <a ng-click="showPrefs=true">
+ <li ng-class="{'menu-item-disabled':menu.editPrefs.disable}">
+ <a ng-click="togglePrefs()">
Edit Preferences
</a>
</li>
<li>
- <a href="#">
+ <a ng-click="maximize()">
Maximize
</a>
</li>
- <li>
- <a href="#">
+ <li ng-class="{'menu-item-disabled':menu.move.disable}">
+ <a ng-click="moveToPage()">
Move to Page
</a>
</li>
<li>
- <a href="#">
+ <a >
Delete Widget
</a>
</li>
<li class="divider"></li>
<li>
- <a href="#">
+ <a >
About this Widget
</a>
</li>
<li>
- <a href="#">
+ <a >
Comment on this Widget
</a>
</li>
<li>
- <a href="#">
+ <a >
Rate this Widget
</a>
</li>
@@ -62,9 +62,40 @@
</div>
</div>
- <div class="widget-prefs" ng-show="showPrefs">Edit Prefs Pane</div>
- <div class="widget" render-widget="regionWidget.id" ng-hide="regionWidget.collapsed">
+ <div class="widget-prefs" ng-show="showPrefs">
+ <form class="form-horizontal" ng-submit="savePrefs()">
+ <div class="control-group" ng-repeat="pref in regionWidgetPrefs" ng-hide="pref.dataType=='HIDDEN'">
+ <label class="control-label"
+ for="{{regionWidget.id}}-{{pref.name}}">{{pref.displayName}}</label>
+ <div class="controls" ng-switch="pref.dataType">
+ <div ng-switch-when="STRING">
+ <input type="text" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
+ </div>
+ <div ng-switch-when="BOOL">
+ <input type="checkbox" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
+ </div>
+ <div ng-switch-when="ENUM">
+ <select id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value"
+ ng-options="o.value as o.displayValue for o in pref.orderedEnumValues"></select>
+ </div>
+ <div ng-switch-when="LIST">
+ <textarea type="text" id="{{regionWidget.id}}-{{pref.name}}" ng-model="pref.value">
+ </textarea>
+ </div>
+ <div ng-switch-when="hidden">
+ <input type="hidden" ng-model="pref.value">
+ </div>
+ </div>
+ </div>
+ <div class="form-actions">
+ <button type="button" ng-click="togglePrefs()" class="btn">Cancel</button>
+ <button type="submit" class="btn btn-primary">Save changes</button>
+ </div>
+ </form>
+ </div>
+ <div class="widget" ng-hide="regionWidget.collapsed">
+ <div rave-render-widget="regionWidget" rave-render-opts="{view:'home'}"></div>
</div>
</div>
</div>
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html Wed May 15 16:45:47 2013
@@ -1,4 +1,4 @@
-<div ng-controller="PortalController">
+<div ng-controller="PortalController" ng-show="pages">
<nav>
<ul class="nav nav-tabs">
<li ng-repeat="page in pages"
@@ -101,12 +101,4 @@
<a id="pageMenuCloseButton" class="btn" ng-click="close()">Cancel</a>
<a id="pageMenuUpdateButton" class="btn btn-primary" ng-click="movePage()">Move Page</a>
</div>
-</script>
-
-
-<div class="popup slideout">
- <a href="#" class="close">×</a>
-
- <div class="slideout-content">
- </div>
-</div>
\ No newline at end of file
+</script>
\ No newline at end of file
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js Wed May 15 16:45:47 2013
@@ -64,10 +64,10 @@ angular.module('rave.controller', ['ui.b
});
}
+ //TODO: this might not be the best way to handle moving widgets
function watchForMove(pages) {
$scope.$watch(function () {
return _.chain(pages)
- .where({id: $scope.selectedPageId})
.pluck('regions').flatten()
.map(function (region, regionIndex) {
return _.map(region.regionWidgets, function (widget, index) {
@@ -93,7 +93,7 @@ angular.module('rave.controller', ['ui.b
}
});
- if(movedWidget) {
+ if (movedWidget) {
oldRegion = _.findWhere(oldValue, {id: movedWidget.id}).regionId;
rave.getWidget(movedWidget.id).moveToRegion(oldRegion, movedWidget.regionId, movedWidget.index);
}
@@ -164,9 +164,24 @@ angular.module('rave.controller', ['ui.b
.controller('WidgetController', ['$scope', 'rave',
function ($scope, rave) {
//Grab a handle on rave's registered regionWidget object to get that functionality in scope.
- $scope.regionWidget = rave.getWidget($scope.regionWidget.id);
+ var regionWidget = $scope.regionWidget = rave.getWidget($scope.regionWidget.id);
$scope.showPrefs = false;
+ $scope.regionWidgetPrefs = $scope.regionWidget.getPrefs();
+ $scope.menu = {
+ editPrefs: {
+ disable: _.isUndefined(regionWidget.getPrefs() )
+ },
+ maximize: {
+ },
+ move: {
+ disable: $scope.pages.length < 2
+ },
+ del: {},
+ about: {},
+ comment: {},
+ rate: {}
+ }
$scope.toggleCollapse = function () {
if ($scope.regionWidget.collapsed) {
$scope.regionWidget.show();
@@ -174,6 +189,15 @@ angular.module('rave.controller', ['ui.b
$scope.regionWidget.hide();
}
}
+
+ $scope.togglePrefs = function () {
+ $scope.showPrefs = !$scope.showPrefs
+ }
+
+ $scope.savePrefs = function () {
+ $scope.regionWidget.setPrefs($scope.regionWidgetPrefs);
+ $scope.togglePrefs();
+ }
}
])
.controller('EditPageController', ['$scope', 'Pages', 'dialog', 'page', '$location',
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js Wed May 15 16:45:47 2013
@@ -1,23 +1,125 @@
angular.module('rave.directive', [])
- .directive('renderWidget', ['rave', '$parse',
- function (rave, $parse) {
- return function postLink(scope, el, attrs) {
- var fn = $parse(attrs.renderWidget);
- var renderWidgetId = fn(scope);
- if (!_.isUndefined(renderWidgetId)) {
- rave.getWidget(renderWidgetId).render(el[0]);
+ .directive('raveRenderWidget', [
+ function () {
+ var directive = {
+ restrict: 'A',
+ scope: {
+ raveRenderWidget: '&',
+ raveRenderOpts: '&'
+ },
+ link: function postLink(scope, el, attrs) {
+ var regionWidget = scope.raveRenderWidget(),
+ opts = scope.raveRenderOpts();
+
+ scope.$watch(function(){
+ return regionWidget.userPrefs;
+ }, doRender);
+
+ function doRender() {
+ regionWidget.render(el[0], opts);
+ }
+ }
+ }
+
+ return directive;
+ }
+ ])
+ //TODO: these are hacky - think of a better more declarative approach for register
+ .directive('raveModal', [
+ function(){
+ var directive = {
+ limit: 'A',
+ replace: true,
+ transclude: true,
+ template: '<div ng-transclude></div>',
+ link: function(scope, el, attrs) {
+ var modal = el.find('.popup');
+ rave.registerView('modal_dialog', {
+ render: function(){
+ var cfg = {
+ keyboard: false,
+ backdrop: 'static',
+ show: true
+ };
+ modal.modal(cfg);
+ },
+ getWidgetSite: function(){
+ return el.find('.site')[0];
+ },
+ destroy: function(){
+ modal.modal('hide');
+ }
+ });
+
+ }
+ }
+ return directive;
+ }
+ ])
+ .directive('raveDialog', [
+ function(){
+ var directive = {
+ limit: 'A',
+ replace: true,
+ transclude: true,
+ template: '<div ng-transclude></div>',
+ link: function(scope, el, attrs) {
+ var modal = el.find('.popup');
+ rave.registerView('dialog', {
+ render: function(){
+ modal.modal();
+ },
+ getWidgetSite: function(){
+ return el.find('.site')[0];
+ },
+ destroy: function(){
+ modal.modal('hide');
+ }
+ });
+
}
}
+ return directive;
}
])
- .directive('sortable', [
+ .directive('raveSidebar', [
function(){
- return {
- link: function(scope, element, attrs, ngModel) {
- var opts = scope.$eval(attrs.sortable);
+ var directive = {
+ limit: 'A',
+ replace: true,
+ transclude: true,
+ template: '<div ng-transclude></div>',
+ link: function(scope, el, attrs) {
+ var popup = el.find('.popup');
+
+ rave.registerView('sidebar', {
+ render: function(){
+ var self =this;
+ popup.find('.close').click(function () {
+ self.destroy();
+ });
+ popup.show("slide", { direction: "right" }, 'fast');
+ $('body').addClass('modal-open');
+ $('body').append('<div class="modal-backdrop fade in"></div>');
+ // hide the main browser window's scrollbar to prevent possible "double scrollbar" rendering
+ // between it and an iframe vertical scrollbar
+ $('body').addClass('no-scroll');
+ },
+ getWidgetSite: function(){
+ return popup.find('.site')[0];
+ },
+ destroy: function(){
+ popup.hide("slide", { direction: "right" }, 'fast', function () {
+ $('body').removeClass('modal-open');
+ $('.modal-backdrop').remove();
+ // restore the main browser window's scrollbar
+ $('body').removeClass('no-scroll');
+ });
+ }
+ });
- element.sortable(opts);
}
}
+ return directive;
}
- ]);
\ No newline at end of file
+ ]);
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js?rev=1482948&r1=1482947&r2=1482948&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js Wed May 15 16:45:47 2013
@@ -128,7 +128,11 @@ angular.module('rave.service', [])
return deferred.promise;
}
])
- .service('users', [function(){}])
+ .service('Users', [
+ function(){
+
+ }
+ ])
.service('settings', [
function () {
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=1482948&r1=1482947&r2=1482948&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 Wed May 15 16:45:47 2013
@@ -127,17 +127,31 @@ rave.RegionWidget = (function () {
});
}
- Widget.prototype.savePreference = function (name, val) {
- this.userPrefs[name] = val;
- rave.api.rest.saveWidgetPreference({regionWidgetId: this.id, prefName: name, prefValue: val});
+ Widget.prototype.getPrefs = function () {
+ var self = this;
+ var combined = [];
+ //TODO: I think this is opensocial specific - need to investigate wookie and possibly delegate to providers
+ _.each(self.metadata.userPrefs, function (data) {
+ var value = self.userPrefs[data.name];
+ data = _.clone(data);
+ data.value = value || data.defaultValue;
+ data.displayName = data.displayName || data.name;
+ combined.push(data);
+ });
+ return _.isEmpty(combined)?undefined:combined;
}
- Widget.prototype.savePreferences = function (updatedPrefs) {
- this.userPrefs = updatedPrefs;
- rave.api.rest.saveWidgetPreferences({regionWidgetId: this.id, userPrefs: updatedPrefs});
+ Widget.prototype.setPrefs = function (name, val) {
+ if (_.isObject(name)) {
+ var updatedPrefs = name;
+ this.userPrefs = _.object(_.pluck(updatedPrefs,'name'), _.pluck(updatedPrefs, 'value'));
+ rave.api.rest.saveWidgetPreferences({regionWidgetId: this.id, userPrefs: this.userPrefs});
+ } else {
+ this.userPrefs[name] = val;
+ rave.api.rest.saveWidgetPreference({regionWidgetId: this.id, prefName: name, prefValue: val});
+ }
}
-
return Widget;
})();
\ No newline at end of file