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/09/04 17:02:09 UTC
svn commit: r1520044 - in
/rave/branches/angular/rave-portal-resources/src/main/webapp/static:
html/common/partials/ html/portal/ script/common/directives/
Author: erinnp
Date: Wed Sep 4 15:02:09 2013
New Revision: 1520044
URL: http://svn.apache.org/r1520044
Log:
Adding new directives
Added:
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
Modified:
rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/common/partials/region.html
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/RenderRegionWidget.js
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/common/partials/region.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/common/partials/region.html?rev=1520044&r1=1520043&r2=1520044&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/common/partials/region.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/common/partials/region.html Wed Sep 4 15:02:09 2013
@@ -3,6 +3,6 @@
class="region {{page.pageLayoutCode}}_{{page.regions.indexOf(region)+1}}"
ui-sortable="sortingOpts" ng-model="region.regionWidgets">
<div ng-repeat="regionWidget in region.regionWidgets">
- <div render-region-widget region-widget="regionWidget"></div>
+ <div render-region-widget="regionWidget"></div>
</div>
</div>
\ No newline at end of file
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=1520044&r1=1520043&r2=1520044&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 Wed Sep 4 15:02:09 2013
@@ -2,4 +2,100 @@
<div class="row-fluid" id="pageContent">
<div ng-include="hostedPath+'/static/html/portal/tabs.html'"></div>
+</div>
+
+<div class="widget-wrapper" register-view="home">
+ <div class="widget-title-bar widget-title-bar-draggable" ng-controller="WidgetController">
+ <div class="widget-toolbar-toggle-collapse" title="Collapse/Restore Widget">
+ <i ng-class="{'icon-chevron-down':!regionWidget.collapsed, 'icon-chevron-up':regionWidget.collapsed}"
+ ng-click="toggleCollapse()"></i>
+ </div>
+ <div class="widget-title">
+ {{regionWidget.widgetUrl}}
+ </div>
+ <div class="widget-toolbar ">
+ <div class="dropdown widget-menu-wrapper" style="">
+ <a class="dropdown-toggle" data-toggle="dropdown">
+ <i class="icon-cog"></i>
+ </a>
+ <ul class="dropdown-menu widget-menu">
+ <li ng-class="{'menu-item-disabled':menu.editPrefs.disable}">
+ <a ng-click="togglePrefs()">
+ Edit Preferences
+ </a>
+ </li>
+ <li>
+ <a ng-click="maximize()">
+ Maximize
+ </a>
+ </li>
+ <li ng-class="{'menu-item-disabled':menu.move.disable}">
+ <a ng-click="moveToPage()">
+ Move to Page
+ </a>
+ </li>
+ <li>
+ <a ng-click="delete()">
+ Delete Widget
+ </a>
+ </li>
+ <li class="divider"></li>
+ <li>
+ <a>
+ About this Widget
+ </a>
+ </li>
+ <li>
+ <a>
+ Comment on this Widget
+ </a>
+ </li>
+ <li>
+ <a>
+ Rate this Widget
+ </a>
+ </li>
+ </ul>
+ </div>
+<span class="widget-toolbar-btn widget-toolbar-btn-min">
+<i class="icon-resize-small"></i>
+</span>
+ </div>
+ </div>
+
+ <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"></div>
+ </div>
</div>
\ No newline at end of file
Added: 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=1520044&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RegisterView.js Wed Sep 4 15:02:09 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+define(['rave'], function(rave){
+ return [function () {
+ var directive = {
+ restrict: 'AE',
+ scope: {},
+ terminal: true,
+ priority: -1,
+ controller: ['$scope', '$element',
+ function ($scope, $element) {
+ this.customRender = function () {
+ };
+ this.customDestroy = function () {
+ };
+ }
+ ],
+ link: function (scope, el, attrs, controller) {
+
+ var viewName = attrs.registerView;
+
+ var template = el.html();
+ el.remove();
+
+ rave.registerView(viewName, {
+ render: function () {
+ return template;
+ }
+ });
+ }
+ }
+
+ return directive;
+ }
+ ]
+})
\ No newline at end of file
Added: 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=1520044&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderIframe.js Wed Sep 4 15:02:09 2013
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * registerView
+ * 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.
+ */
+
+/**
+ * The RenderRegionWidget directive takes a regionWidget to be rendered in the region-widget="" attribute
+ * and renders that regionWidget at the location of the directive.
+ */
+
+define(['angular'], function(angular){
+ return [function(){
+ var directive = {
+ restrict: 'EA',
+ replace: true,
+ scope:{
+ regionWidget: '='
+ },
+ 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);
+
+ //Render the widget
+ regionWidgetClone.render(element[0]);
+ }
+ }, true);
+ }
+ }
+ return directive;
+ }]
+})
+
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=1520044&r1=1520043&r2=1520044&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 Wed Sep 4 15:02:09 2013
@@ -22,27 +22,32 @@
* and renders that regionWidget at the location of the directive.
*/
-define(['angular'], function(angular){
- return [ 'constants', function(constants){
- var renderRegionWidgetDirectiveDefinition = {
- restrict: 'EA',
- replace: true,
- scope:{
- regionWidget: '='
- },
- 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);
+define(['rave'], function(rave){
+ return ['$compile',
+ function ($compile) {
+ var directive = {
+ restrict: 'A',
+ link: function (scope, el, attrs) {
+ var regionWidget = scope.$eval(attrs.renderRegionWidget);
- //Render the widget
- regionWidgetClone.render(element[0]);
+ scope.$watch(function () {
+ return regionWidget._surface;
+ }, doRender)
+
+ function doRender() {
+ var template = rave.renderView(regionWidget._surface);
+
+ if (template) {
+ el.html(template);
+ $compile(el.contents())(scope);
+ }
}
- }, true);
+
+ }
}
+
+ return directive;
}
- return renderRegionWidgetDirectiveDefinition;
- }]
+ ]
})
Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js?rev=1520044&r1=1520043&r2=1520044&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js Wed Sep 4 15:02:09 2013
@@ -17,12 +17,14 @@
* under the License.
*/
-define(['angular', './Base', './RenderRegionWidget'],
- function (angular, base, renderRegionWidget) {
+define(['angular', './Base', './RenderRegionWidget', './RenderIframe', './RegisterView'],
+ function (angular, base, renderRegionWidget, renderIframe, registerView) {
var directives = angular.module('common.directives', []);
directives.directive('base', base);
+ directives.directive('registerView', registerView);
directives.directive('renderRegionWidget', renderRegionWidget);
+ directives.directive('renderIframe', renderIframe);
return directives;
}