rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlu...@apache.org
Subject svn commit: r1182021 - in /incubator/rave/trunk/rave-portal-resources/src: main/resources/ main/webapp/WEB-INF/views/ main/webapp/css/ main/webapp/script/ test/javascript/
Date Tue, 11 Oct 2011 18:48:52 GMT
Author: carlucci
Date: Tue Oct 11 18:48:51 2011
New Revision: 1182021

URL: http://svn.apache.org/viewvc?rev=1182021&view=rev
Log:
RAVE-116: Create widget menu in titlebar chrome

All widget actions are now consolidated under a single widget menu

Modified:
    incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/views/home.jsp
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_layout.js
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_opensocial.js
    incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js

Modified: incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties Tue
Oct 11 18:48:51 2011
@@ -70,6 +70,8 @@ page.general.addpage.selectlayout=Select
 
 page.home.welcome=Hello {0}, welcome to Rave!
 
+page.menu.title=Page Actions Menu
+
 page.login.title=Login
 page.login.createaccount=New User
 page.login.createaccount.label=Register:
@@ -144,5 +146,11 @@ widget.url.required=URL is required
 widget.widgetStatus.PREVIEW=This widget is waiting for approval by the site administrator.
 widget.widgetStatus.PUBLISHED=
 
-widget.general.movewidget=Move widget
-widget.general.movethiswidget=Move this widget to page:
\ No newline at end of file
+widget.chrome.toggle=Collapse/Restore Widget
+
+widget.menu.delete=Delete Widget
+widget.menu.editprefs=Edit Preferences
+widget.menu.maximize=Maximize
+widget.menu.movethiswidget=Move this widget to page:
+widget.menu.movetopage=Move to Page
+widget.menu.title=Widget Actions

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/views/home.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/views/home.jsp?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/views/home.jsp (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/views/home.jsp Tue
Oct 11 18:48:51 2011
@@ -66,7 +66,7 @@
                     <div id="pageTitle-${userPage.entityId}" class="page-title" onclick="rave.viewPage(${userPage.entityId});"><c:out
value="${userPage.name}"/></div>
                     <c:if test="${isCurrentPage}">
                         <div id="pageMenuWrapper">
-                            <span id="pageMenuButton" class="ui-icon ui-icon-circle-triangle-s"
title="Page Actions Menu"></span>
+                            <span id="pageMenuButton" class="ui-icon ui-icon-circle-triangle-s"
title="<fmt:message key="page.menu.title"/>"></span>
                             <div id="pageMenu" class="page-menu">
                                 <div id="pageMenuEdit" class="page-menu-item"><fmt:message
key="page.general.editpage"/></div>
                                 <div id="pageMenuDelete" class="page-menu-item<c:if
test='${hasOnlyOnePage}'> page-menu-item-disabled</c:if>">
@@ -90,7 +90,7 @@
                 <c:forEach var="regionWidget" items="${region.regionWidgets}">
                    <div class="widget-wrapper" id="widget-${regionWidget.entityId}-wrapper">
                         <div class="widget-title-bar">
-                            <span id="widget-${regionWidget.entityId}-collapse" class="widget-toolbar-toggle-collapse"
title="Collapse/Restore Widget"></span>
+                            <span id="widget-${regionWidget.entityId}-collapse" class="widget-toolbar-toggle-collapse"
title="<fmt:message key="widget.chrome.toggle"/>"></span>
                             <div id="widget-${regionWidget.entityId}-title" class="widget-title">
                             <c:choose>
                                 <c:when test="${not empty regionWidget.widget.titleUrl}">
@@ -101,25 +101,33 @@
                                 </c:otherwise>
                             </c:choose>
                             </div>
-                            <!-- These are toolbar buttons -->
+                            <%-- These are toolbar buttons --%>
                             <div id="widget-${regionWidget.entityId}-toolbar" style="float:right;">
                                 <div id="widget-${regionWidget.entityId}-widget-menu-wrapper"
class="widget-menu-wrapper">
-                                    <span id="widget-${regionWidget.entityId}-menu-button"
class="widget-menu-button ui-icon ui-icon-circle-triangle-s" title="Widget Actions Menu"></span>
  
+                                    <span id="widget-${regionWidget.entityId}-menu-button"
class="widget-menu-button ui-icon ui-icon-gear" title="<fmt:message key="widget.menu.title"/>"></span>
  
                                     <div id="widget-${regionWidget.entityId}-menu" class="widget-menu">
 
+                                        <%-- 
+                                            By default the edit prefs item is disabled.
+                                            Each provider's widget initialization will be
responsible for enabling this item
+                                            if the widget has preferences to be edited
+                                        --%> 
+                                        <div id="widget-${regionWidget.entityId}-menu-editprefs-item"
class="widget-menu-item widget-menu-item-disabled">
+                                            <fmt:message key="widget.menu.editprefs"/>
+                                        </div>   
+                                        <div id="widget-${regionWidget.entityId}-menu-maximize-item"
class="widget-menu-item">
+                                            <fmt:message key="widget.menu.maximize"/>
+                                        </div>    
                                         <div id="widget-${regionWidget.entityId}-menu-move-item"
class="widget-menu-item<c:if test='${hasOnlyOnePage}'> widget-menu-item-disabled</c:if>">
-                                            <fmt:message key="widget.general.movewidget"/>
+                                            <fmt:message key="widget.menu.movetopage"/>
                                         </div>   
-                                    </div>       
-                                </div>                                            
                   
-                                <button id="widget-${regionWidget.entityId}-prefs"
-                                        class="widget-toolbar-btn widget-toolbar-btn-prefs">
-                                </button>
-                                <button id="widget-${regionWidget.entityId}-max"
-                                        class="widget-toolbar-btn">
-                                </button>
-                                <button id="widget-${regionWidget.entityId}-remove"
-                                        class="widget-toolbar-btn">
-                                </button>
+                                        <div id="widget-${regionWidget.entityId}-menu-delete-item"
class="widget-menu-item">
+                                            <fmt:message key="widget.menu.delete"/>
+                                        </div>                                    
  
+                                    </div>                                        
  
+                                </div>           
+                                <%-- the minimize widget button, which is hidden by default
and only displays in maximized view --%>    
+                                <button id="widget-${regionWidget.entityId}-min" 
+                                        class="widget-toolbar-btn widget-toolbar-btn-min"></button>
                             </div>
                         </div>
                         <div class="widget-prefs" id="widget-${regionWidget.entityId}-prefs-content"></div>
@@ -173,9 +181,9 @@
             </select>
         </form>
     </div>
-    <fmt:message key="widget.general.movewidget" var="moveWidgetToPageTitle"/>
+    <fmt:message key="widget.menu.movetopage" var="moveWidgetToPageTitle"/>
     <div id="moveWidgetDialog" title="${moveWidgetToPageTitle}" class="dialog">
-        <div><fmt:message key="widget.general.movethiswidget"/></div>
+        <div><fmt:message key="widget.menu.movethiswidget"/></div>
         <form id="moveWidgetForm">
             <select id="moveToPageId">
                 <c:forEach var="userPage" items="${pages}">

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css Tue Oct 11
18:48:51 2011
@@ -407,6 +407,10 @@ button.widget-toolbar-btn-prefs {
     display: none;
 }
 
+button.widget-toolbar-btn-min {
+    display: none;
+}
+
 .widget-toolbar-toggle-collapse {
     display: inline-block;
     vertical-align: middle;
@@ -575,7 +579,7 @@ span.error, label.error {
     display: none;
     left: 18px;
     top: 0;
-    width: 80px;
+    width: 100px;
     background-color: #FFFFFF;
     z-index: 1000;
     cursor: pointer;

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js Tue Oct 11 18:48:51
2011
@@ -55,11 +55,8 @@ var rave = rave || (function() {
         var WIDGET_PREFS_INPUT_REQUIRED_CLASS = "widget-prefs-input-required";
         var WIDGET_PREFS_INPUT_FAILED_VALIDATION = "widget-prefs-input-failed-validation";
         
-        var WIDGET_ICON_BASE_CLASS = "ui-icon";
-        var WIDGET_BTN_MAXIMIZE_CLASS = "ui-icon-arrow-4-diag";
+        var WIDGET_ICON_BASE_CLASS = "ui-icon";        
         var WIDGET_BTN_MINIMIZE_CLASS = "ui-icon-arrowthick-1-sw";
-        var WIDGET_BTN_DELETE_CLASS = "ui-icon-close";
-        var WIDGET_BTN_EDIT_PREFS_CLASS = "ui-icon-pencil";
         var WIDGET_TOGGLE_DISPLAY_COLLAPSED = "ui-icon-triangle-1-e";
         var WIDGET_TOGGLE_DISPLAY_NORMAL = "ui-icon-triangle-1-s";             
 
@@ -145,42 +142,36 @@ var rave = rave || (function() {
         }
 
         function maximizeAction(args) {
+            var regionWidgetId = args.data.id;            
+            // display the widget in maximized view
             addOverlay($("#pageContent"));
             $(".region" ).sortable( "option", "disabled", true );
-            $("#widget-" + args.data.id + "-wrapper").removeClass("widget-wrapper").addClass("widget-wrapper-canvas");
-            
-            // changes to 'max' button:
-            // 1) clear out the previous max button click event and attach a new one
-            // 2) change the image
-            var $maxButton =  $("#widget-" + args.data.id + "-max");
-            $maxButton.unbind("click");
-            $maxButton.click({id:args.data.id}, minimizeAction);
-            $maxButton.button("option", "icons", {primary:WIDGET_BTN_MINIMIZE_CLASS});
-            
+            $("#widget-" + regionWidgetId + "-wrapper").removeClass("widget-wrapper").addClass("widget-wrapper-canvas");
           
+            // hide the widget menu
+            $("#widget-" + regionWidgetId + "-widget-menu-wrapper").hide();            
+            // display the widget minimize button
+            $("#widget-" + regionWidgetId + "-min").show();                             
      
             // hide the collapse/restore toggle icon in canvas mode
-            $("#widget-" + args.data.id + "-collapse").hide();
-            var widget = rave.getWidgetById(args.data.id);
+            $("#widget-" + regionWidgetId + "-collapse").hide();
+            var widget = rave.getWidgetById(regionWidgetId);
             if(typeof widget != "undefined" && isFunction(widget.maximize)) {
                 widget.maximize();
             }
         }
 
         function minimizeAction(args) {
+            var regionWidgetId = args.data.id;     
             $(".dnd-overlay").remove();
             $(".region" ).sortable( "option", "disabled", false );
-            $("#widget-" + args.data.id + "-wrapper").removeClass("widget-wrapper-canvas").addClass("widget-wrapper");
-            
-            // changes to 'max' button:
-            // 1) clear out the previous max button click event and attach a new one
-            // 2) change the image
-            var $maxButton =  $("#widget-" + args.data.id + "-max");
-            $maxButton.unbind("click");
-            $maxButton.click({id:args.data.id}, maximizeAction);            
-            $maxButton.button("option", "icons", {primary:WIDGET_BTN_MAXIMIZE_CLASS});
-                                              
-            // re-show the collapse/restore toggle icon
-            $("#widget-" + args.data.id + "-collapse").show();
-            var widget = rave.getWidgetById(args.data.id);
+            // display the widget in normal view
+            $("#widget-" + regionWidgetId + "-wrapper").removeClass("widget-wrapper-canvas").addClass("widget-wrapper");
+            // hide the widget minimize button
+            $("#widget-" + regionWidgetId + "-min").hide(); 
+            // show the widget menu
+            $("#widget-" + regionWidgetId + "-widget-menu-wrapper").show();             
                                                                              
+            // show the collapse/restore toggle icon
+            $("#widget-" + regionWidgetId + "-collapse").show();
+            var widget = rave.getWidgetById(regionWidgetId);
             // if the widget is collapsed execute the collapse function
             // otherwise execute the minimize function
             if(typeof widget != "undefined"){
@@ -216,17 +207,7 @@ var rave = rave || (function() {
             
             rave.api.rest.saveWidgetCollapsedState(functionArgs);           
         }      
-
-        function deleteAction(args) {
-            if (confirm("Are you sure you want to remove this widget from your page")) {
-                rave.api.rpc.removeWidget({
-                    regionWidgetId: args.data.id,
-                    successCallback: function() {
-                        $("#widget-" + args.data.id + "-wrapper").remove();
-                    }
-                });
-            }
-        }
+        
         /**
          * Utility function to generate the html label for a userPref
          * based on if it is required or not
@@ -274,8 +255,8 @@ var rave = rave || (function() {
             return isValid;            
         }
 
-        function editPrefsAction(args) {
-            var regionWidget = getWidgetById(args.data.id);
+        function editPrefsAction(regionWidgetId) {
+            var regionWidget = getWidgetById(regionWidgetId);
             var userPrefs = regionWidget.metadata.userPrefs;
             var hasRequiredUserPrefs = false;
             
@@ -458,30 +439,15 @@ var rave = rave || (function() {
         function styleWidgetButtons(widgetId) {
             var widget = rave.getWidgetById(widgetId);
             
-            // init the maximize button
-            $("#widget-" + widgetId + "-max").button({
-                text: false,
-                icons: {
-                    primary: WIDGET_BTN_MAXIMIZE_CLASS
-                }
-            }).click({id: widgetId}, maximizeAction);
-
-            // init the delete button
-            $("#widget-" + widgetId + "-remove").button({
-                text: false,
-                icons: {
-                    primary: WIDGET_BTN_DELETE_CLASS
-                }
-            }).click({id: widgetId}, deleteAction);
-
-            // init the edit preferences button
-            $("#" + WIDGET_PREFS_EDIT_BUTTON(widgetId)).button({
+            // init the widget minimize button which is hidden by default
+            // and only renders when widget is in maximized view
+            $("#widget-" + widgetId + "-min").button({
                 text: false,
                 icons: {
-                    primary: WIDGET_BTN_EDIT_PREFS_CLASS
+                    primary: WIDGET_BTN_MINIMIZE_CLASS
                 }
-            }).click({id: widgetId}, editPrefsAction);
-                       
+            }).click({id: widgetId}, rave.minimizeWidget);
+                
             // init the collapse/restore toggle
             // conditionally style the icon and setup the event handlers
             var $toggleCollapseIcon = $("#widget-" + widgetId + "-collapse");
@@ -516,7 +482,8 @@ var rave = rave || (function() {
           init : init,          
           toggleCollapseWidgetIcon: toggleCollapseWidgetIcon,
           maximizeAction: maximizeAction,
-          minimizeAction: minimizeAction
+          minimizeAction: minimizeAction,
+          editPrefsAction: editPrefsAction
         };
 
     })();
@@ -719,6 +686,15 @@ var rave = rave || (function() {
          * 
          * @param args the argument object
          */
-        minimizeWidget: ui.minimizeAction
+        minimizeWidget: ui.minimizeAction,
+        
+        /***
+         * Display the inline edit prefs section for widget preferences inside
+         * the widget.
+         * 
+         * @param regionWidgetId the regionWidgetId of the widget
+         * 
+         */
+        editPrefs: ui.editPrefsAction
     }
 })();

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_layout.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_layout.js?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_layout.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_layout.js Tue Oct
11 18:48:51 2011
@@ -191,20 +191,30 @@ rave.layout = rave.layout || (function()
 
     // widget menu related functions
     var widgetMenu = (function() {
-        var $menu ;
-        var $menuItemMove ;
+        var $menu;
+        var $menuItemMove;
+        var $menuItemDelete;
+        var $menuItemMaximize;
 
-        function hideMenu() {
-            $(".widget-menu-button").each(function(index, element) {
-                if (!$(element).hasClass("widget-menu-item-disabled")) {
-                    $menu = $("#widget-" + rave.getObjectIdFromDomId(this.id) + "-menu");
-                    $menu.hide();
-                }
-            });
-        }
-
-        function showMenu() {
-            $menu.show();
+        /**
+         * Hides the widget menu for a specific widget
+         * @param widgetId the id of the widget to hide the menu for
+         */
+        function hideMenu(widgetId) {
+            $("#widget-" + widgetId + "-menu").hide();
+        }        
+        /**
+         * Hides all widget menus     
+         */
+        function hideAllMenus() {
+            $(".widget-menu").hide();
+        }        
+        /**
+         * Shows the widget menu for a specific widget
+         * @param widgetId the id of the widget to show the menu for
+         */
+        function showMenu(widgetId) {
+            $("#widget-" + widgetId + "-menu").show();
         }
 
         /**
@@ -227,29 +237,97 @@ rave.layout = rave.layout || (function()
                 }
             });
 
-            $(".widget-menu-item").each(function(index, element) {
-                if (!$(element).hasClass("widget-menu-item-disabled")) {
-                    $(element).bind('click', function(event) {
-                        $menu = $("#widget-" + rave.getObjectIdFromDomId(this.id) + "-menu");
-                        $menuItemMove = $("#widget-" + rave.getObjectIdFromDomId(this.id)
+ "-menu-move-item") ;
+            // loop over each widget-menu and initialize the menu items
+            // note: the edit prefs menu item is by default rendered disabled
+            //       and it is up to the provider code for that widget to 
+            //       determine if the widget has preferences, and to enable
+            //       the menu item
+            $(".widget-menu").each(function(index, element){
+                var widgetId = rave.getObjectIdFromDomId(element.id);
+                                
+                // setup the move to page menu item
+                $menuItemMove = $("#widget-" + widgetId + "-menu-move-item");
+                if (!$menuItemMove.hasClass("widget-menu-item-disabled")) {
+                    $menuItemMove.bind('click', function(event) {                       
+                        var regionWidgetId = rave.getObjectIdFromDomId(this.id);
                         $moveWidgetDialog
-                            .data('regionWidgetId', rave.getObjectIdFromDomId(this.id))
+                            .data('regionWidgetId', regionWidgetId)
                             .dialog("open");
+                            
+                        // hide the widget menu
+                        rave.layout.hideWidgetMenu(regionWidgetId);                     
 
+                            
                         // prevent the menu button click event from bubbling up to parent
                         // DOM object event handlers such as the page tab click event
                         event.stopPropagation();
                     });
-                }
+                }    
+                
+                // setup the delete widget menu item
+                $menuItemDelete  = $("#widget-" + widgetId + "-menu-delete-item");
+                if (!$menuItemDelete.hasClass("widget-menu-item-disabled")) {
+                    $menuItemDelete.bind('click', function(event) {                     
 
+                        var regionWidgetId = rave.getObjectIdFromDomId(this.id); 
+                         // hide the widget menu
+                        rave.layout.hideWidgetMenu(regionWidgetId);                     
                   
+                        // invoke the rpc call to remove the widget from the page
+                        rave.layout.deleteRegionWidget(regionWidgetId);
+                                                                                        
                                                            
+                        // prevent the menu button click event from bubbling up to parent
+                        // DOM object event handlers such as the page tab click event
+                        event.stopPropagation();
+                    });
+                }    
+                
+                // setup the maximize widget menu item
+                $menuItemMaximize  = $("#widget-" + widgetId + "-menu-maximize-item");
+                if (!$menuItemMaximize.hasClass("widget-menu-item-disabled")) {
+                    $menuItemMaximize.bind('click', function(event) {                   
   
+                        var regionWidgetId = rave.getObjectIdFromDomId(this.id); 
+                         // hide the widget menu
+                        rave.layout.hideWidgetMenu(regionWidgetId);                     
                   
+                        // maximize the widget
+                        rave.maximizeWidget({data: {id: regionWidgetId}});              
                                                                                         
                                            
+                        // prevent the menu button click event from bubbling up to parent
+                        // DOM object event handlers such as the page tab click event
+                        event.stopPropagation();
+                    });
+                }                
             });
 
             // close the widget menu if the user clicks outside of it
-            $("html").click(widgetMenu.hide);
+            $("html").click(widgetMenu.hideAll);
+        }
+        
+        /**
+         * Enables the Edit Prefs menu item in the widget menu to be clicked.
+         * Widget providers should use this function when initializing their
+         * widgets after determining if the widget has preferences to modify.
+         * 
+         * @param regionWidgetId the regionWidgetId of the regionWidget menu to enable
+         */
+        function enableEditPrefsMenuItem(regionWidgetId) {
+            // setup the edit prefs widget menu item
+            var $menuItemEditPrefs  = $("#widget-" + regionWidgetId + "-menu-editprefs-item");
+            $menuItemEditPrefs.removeClass("widget-menu-item-disabled");           
+            $menuItemEditPrefs.bind('click', function(event) {                       
+                var regionWidgetId = rave.getObjectIdFromDomId(this.id); 
+                 // hide the widget menu
+                rave.layout.hideWidgetMenu(regionWidgetId);                             
           
+                // show the edit prefs region
+                rave.editPrefs(regionWidgetId);
+                // prevent the menu button click event from bubbling up to parent
+                // DOM object event handlers such as the page tab click event
+                event.stopPropagation();
+            });                
         }
 
         return {
             init: init,
-            hide: hideMenu,
-            show: showMenu
+            hideAll: hideAllMenus,
+            hide: hideMenu,            
+            show: showMenu,
+            enableEditPrefsMenuItem: enableEditPrefsMenuItem
         }
     })();
 
@@ -315,6 +393,23 @@ rave.layout = rave.layout || (function()
     }
     
     /**
+     * Invokes the RPC call to delete a regionWidget from a page
+     * TODO: RAVE-299 - how can we load the confirmation text from the message bundles 
+     * 
+     * @param regionWidgetId the regionWidgetId to delete
+     */
+    function deleteRegionWidget(regionWidgetId) {
+        if (confirm("Are you sure you want to remove this widget from your page?")) {
+            rave.api.rpc.removeWidget({
+                regionWidgetId: regionWidgetId,
+                successCallback: function() {
+                    $("#widget-" + this.regionWidgetId + "-wrapper").remove();
+                }
+            });
+        }
+    }
+    
+    /**
      * Returns the pageId of the currently viewed page
      */
     function getCurrentPageId() {
@@ -343,6 +438,9 @@ rave.layout = rave.layout || (function()
     // public rave.layout API
     return {
         init: init,
-        getCurrentPageId: getCurrentPageId
+        getCurrentPageId: getCurrentPageId,
+        hideWidgetMenu: widgetMenu.hide,
+        deleteRegionWidget: deleteRegionWidget,
+        enableEditPrefsMenuItem: widgetMenu.enableEditPrefsMenuItem
     };    
 })();

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_opensocial.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_opensocial.js?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_opensocial.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_opensocial.js Tue
Oct 11 18:48:51 2011
@@ -136,9 +136,9 @@ rave.opensocial = rave.opensocial || (fu
             renderGadgetViewIfNotCollapsed(rave.opensocial.getCurrentView(this.regionWidgetId),
this);             
         };
         
-        // if the gadget has prefences to edit, display the edit prefs button in the gadget
chrome
-        if (gadget.metadata.hasPrefsToEdit) {            
-            $("#widget-" + gadget.regionWidgetId + "-prefs").show();
+        // if the gadget has prefences to edit, enable the edit prefs menu item
+        if (gadget.metadata.hasPrefsToEdit) { 
+            rave.layout.enableEditPrefsMenuItem(gadget.regionWidgetId);            
         }
         
         // if the gadget is not collapsed, render it

Modified: incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js?rev=1182021&r1=1182020&r2=1182021&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js Tue Oct 11
18:48:51 2011
@@ -472,9 +472,6 @@ describe("Rave", function() {
                         valuesMap["sortableAttrName"] = attrName;
                         valuesMap["sortableAttrValue"] = attrValue;
                     },
-                    unbind: function(eventName) {
-                        valuesMap["unbindEventName"] = eventName;
-                    },
                     click: function(args, fn) {
                         valuesMap["clickArgs"] = args;
                         valuesMap["clickFn"] = fn;
@@ -485,10 +482,10 @@ describe("Rave", function() {
                         valuesMap["buttonAttrArgs"] = attrArgs;
                     },
                     hide: function() {
-                        valuesMap["hideWasCalled"] = true;
+                        valuesMap["hideWasCalled-" + expression] = true;
                     },
                     show: function() {
-                        valuesMap["showWasCalled"] = true;
+                        valuesMap["showWasCalled-" + expression] = true;
                     },                    
                     height: function() {
                         
@@ -533,20 +530,15 @@ describe("Rave", function() {
             expect($().getValue("sortableAttrValue")).toEqual(true);            
             // verify the CSS styles
             expect($().hasClass("widget-wrapper-canvas")).toEqual(true);
-            expect($().hasClass("widget-wrapper")).toEqual(false);
-            // verify the unbind parameter
-            expect($().getValue("unbindEventName")).toEqual("click");
-            // verify the click parameters
-            expect($().getValue("clickArgs")).toEqual({id: args.data.id});
-            expect(rave.isFunction($().getValue("clickFn"))).toEqual(true);
-            // verify the button parameters
-            expect($().getValue("buttonOption")).toEqual("option");
-            expect($().getValue("buttonAttrName")).toEqual("icons");
-            expect($().getValue("buttonAttrArgs")).toEqual({primary:"ui-icon-arrowthick-1-sw"});
                    
+            expect($().hasClass("widget-wrapper")).toEqual(false);           
+            // verify widget menu hide was called
+            expect($().getValue("hideWasCalled-#widget-" + args.data.id + "-widget-menu-wrapper")).toEqual(true);
 
+            // verify widget minimize show was called
+            expect($().getValue("showWasCalled-#widget-" + args.data.id + "-min")).toEqual(true);
       
             // verify getWidgetById called
             expect(rave.getWidgetById).toHaveBeenCalledWith(args.data.id); 
-            // verify hide was called
-            expect($().getValue("hideWasCalled")).toEqual(true);                 
+            // verify collapse/restore icon hide was called
+            expect($().getValue("hideWasCalled-#widget-" + args.data.id + "-collapse")).toEqual(true);
                
             // verify widget.maximize was called
             expect(mockWidget.maximizeWasCalled).toEqual(true);
                    
@@ -576,22 +568,16 @@ describe("Rave", function() {
             // verify the CSS styles
             expect($().hasClass("widget-wrapper-canvas")).toEqual(false);
             expect($().hasClass("widget-wrapper")).toEqual(true);
-            // verify the unbind parameter
-            expect($().getValue("unbindEventName")).toEqual("click");
-            // verify the click parameters
-            expect($().getValue("clickArgs")).toEqual({id: args.data.id});
-            expect(rave.isFunction($().getValue("clickFn"))).toEqual(true);
-            // verify the button parameters
-            expect($().getValue("buttonOption")).toEqual("option");
-            expect($().getValue("buttonAttrName")).toEqual("icons");
-            expect($().getValue("buttonAttrArgs")).toEqual({primary:"ui-icon-arrow-4-diag"});
                    
-            // verify show was called
-            expect($().getValue("showWasCalled")).toEqual(true);                 
+            // verify widget minimize hide was called
+            expect($().getValue("hideWasCalled-#widget-" + args.data.id + "-min")).toEqual(true);
                           
+            // verify widget menu show was called
+            expect($().getValue("showWasCalled-#widget-" + args.data.id + "-widget-menu-wrapper")).toEqual(true);
                                 
+            // verify collapse/restore icon show was called
+            expect($().getValue("showWasCalled-#widget-" + args.data.id + "-collapse")).toEqual(true);
                
             // verify getWidgetById called
             expect(rave.getWidgetById).toHaveBeenCalledWith(args.data.id);              
    
             // verify widget.minimize was called
             expect(mockWidget.minimizeWasCalled).toEqual(true);             
-        });          
-        
+        });                    
     });
 });
\ No newline at end of file



Mime
View raw message