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/03/25 16:29:44 UTC

svn commit: r1460715 [3/5] - in /rave/trunk/rave-portal-resources: ./ src/main/resources/ src/main/webapp/WEB-INF/jsp/views/ src/main/webapp/WEB-INF/tags/ src/main/webapp/static/css/ src/main/webapp/static/script/ src/test/javascript/

Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_api.js
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_api.js?rev=1460715&r1=1460714&r2=1460715&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_api.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_api.js Mon Mar 25 15:29:43 2013
@@ -1,891 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-var rave = rave || {};
-/**
- * Namespace that provides client access to Rave server APIs.
- * Note required jquery libraries must be imported by the containing page.
- */
-rave.api = rave.api || (function() {
-    function handleError(jqXhr, status, error) {
-        alert(rave.getClientMessage("api.error") + error);
-    }
-
-    var restApi = (function() {
-        //Base path to RPC services
-        var path = "api/rest/";
-
-        function saveWidgetPreferences(args) {
-            var preferencesData = {"preferences": []};
-            for (var prefName in args.userPrefs) {
-                preferencesData.preferences.push({"name":prefName, "value":args.userPrefs[prefName]});
-            }
-
-            $.ajax({
-                type: 'PUT',
-                url: rave.getContext() + path + "regionWidgets/" + args.regionWidgetId + "/preferences",
-                data: JSON.stringify(preferencesData),
-                contentType: 'application/json',
-                dataType: 'json',
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            });
-        }
-
-        function saveWidgetPreference(args) {
-            $.ajax({
-                type: 'PUT',
-                url: rave.getContext() + path + "regionWidgets/" + args.regionWidgetId + "/preferences/" + args.userPref.prefName,
-                data: JSON.stringify({"name":args.userPref.prefName, "value": args.userPref.prefValue}),
-                contentType: 'application/json',
-                dataType: 'json',
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            });
-        }
-
-        function saveWidgetCollapsedState(args) {
-            $.ajax({
-                type: 'PUT',
-                url: rave.getContext() + path + "regionWidgets/" + args.regionWidgetId + "/collapsed",
-                data: JSON.stringify(args.collapsed),
-                contentType: 'application/json',
-                dataType: 'json',
-                success: function(result) {
-                    rave.doWidgetUiCollapse({"regionWidgetId": result.id,
-                                             "collapsed": result.collapsed,
-                                             "successCallback": args.successCallback});
-                },
-                error: handleError
-            });
-        }
-
-        function deletePage(args) {
-            $.ajax({
-                type: 'DELETE',
-                url: rave.getContext() + path + "page/" + args.pageId,
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            });
-        }
-
-        function deleteWidgetRating(args) {
-            $.ajax({
-                type: 'DELETE',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/rating",
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function updateWidgetRating(args) {
-            $.ajax({
-                type: 'POST',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/rating?score=" + args.score,
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function createWidgetComment(args) {
-            $.ajax({
-                type: 'POST',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/comments?text=" + escape(args.text),
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function deleteWidgetComment(args) {
-            $.ajax({
-                type: 'DELETE',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/comments/" + args.commentId,
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function updateWidgetComment(args) {
-            $.ajax({
-                type: 'POST',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/comments/" + args.commentId + "?text=" + escape(args.text),
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function getUsersForWidget(args) {
-            $.ajax({
-                type: 'GET',
-                url: rave.getContext() + path + "widgets/" + args.widgetId + "/users",
-                success: function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback(result);
-                    }
-                },
-                error: handleError
-            })
-        }
-
-        function createWidgetTag(args) {
-            $.ajax({
-                type:'POST',
-                url:rave.getContext() + path + "widgets/" + args.widgetId + "/tags?tagText=" + escape(args.text),
-                success:function (result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback();
-                    }
-                },
-                error:handleError
-            })
-        }
-
-        function getTags(args) {
-            $.ajax({
-                type:'GET',
-                url:rave.getContext() + path + "widgets/"+args.widgetId  + "/tags",
-                dataType:"json",
-                success:function (data) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback(data);
-                    }
-                }
-            });
-        }
-
-        return {
-            updateWidgetRating: updateWidgetRating,
-            deleteWidgetRating: deleteWidgetRating,
-            saveWidgetPreferences : saveWidgetPreferences,
-            saveWidgetPreference : saveWidgetPreference,
-            saveWidgetCollapsedState : saveWidgetCollapsedState,
-            createWidgetComment : createWidgetComment,
-            updateWidgetComment : updateWidgetComment,
-            deleteWidgetComment : deleteWidgetComment,
-            deletePage : deletePage,
-            getUsersForWidget: getUsersForWidget,
-            createWidgetTag: createWidgetTag,
-            getTags: getTags
-        };
-    })();
-
-    var rpcApi = (function() {
-        //Base path to RPC services
-        var path = "api/rpc/";
-
-        //This method is implemented by PageApi.java.
-        function moveWidgetOnPage(args) {
-            var widgetObjectId = rave.getObjectIdFromDomId(args.widget.id);
-            var toRegionObjectId = rave.getObjectIdFromDomId(args.targetRegion.id);
-            var fromRegionObjectId = rave.getObjectIdFromDomId(args.currentRegion.id);
-            //Note context must be set outside this library.  See page.jsp for example.
-            $.post(rave.getContext() + path + "page/regionWidget/" + widgetObjectId + "/move",
-                {
-                    newPosition: args.targetIndex,
-                    toRegion: toRegionObjectId,
-                    fromRegion: fromRegionObjectId
-                },
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                }
-            ).error(handleError);
-        }
-
-        function addWidgetToPage(args) {
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/widget/add",
-                {
-                    widgetId: args.widgetId
-                },
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    } else {
-                        var widgetTitle = rave.getClientMessage("widget.add_prefix");
-                        var addedWidget = result.result != undefined ? result.result.widgetId : undefined;
-
-                        if (addedWidget != undefined && addedWidget.title != undefined && addedWidget.title.length > 0) {
-                            widgetTitle = addedWidget.title;
-                        }
-                        // if a callback is supplied, invoke it with the regionwidget id
-                        if (args.successCallback && addedWidget != undefined){
-                            args.successCallback(result.result.id);
-                        }
-                        rave.showInfoMessage(widgetTitle + ' ' + rave.getClientMessage("widget.add_suffix"));
-                        
-                        // Update Add Widget button to reflect status
-                        var addWidgetButton = "#addWidget_" + args.widgetId;
-                        var addedText = '<i class="icon icon-ok icon-white"></i> ' + $(addWidgetButton).data('success');
-                        
-                        $(addWidgetButton).removeClass("btn-primary").addClass("btn-success").html(addedText);
-                    }
-                }).error(handleError);
-        }
-
-        function addWidgetToPageRegion(args) {
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/widget/add/region/"+ args.regionId,
-                {
-                    widgetId: args.widgetId
-                },
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    } else {
-                        var widgetTitle = rave.getClientMessage("widget.add_prefix");
-                        var addedWidget = result.result != undefined ? result.result.widgetId : undefined;
-
-                        if (addedWidget != undefined && addedWidget.title != undefined && addedWidget.title.length > 0) {
-                            widgetTitle = addedWidget.title;
-                        }
-                        // if a callback is supplied, invoke it with the regionwidget id
-                        if (args.successCallback && addedWidget != undefined){
-                            args.successCallback(result.result.id);
-                        }
-                        rave.showInfoMessage(widgetTitle + ' ' + rave.getClientMessage("widget.add_suffix"));
-                    }
-                }).error(handleError);
-        }
-
-        function deleteWidgetOnPage(args) {
-            $.post(rave.getContext() + path + "page/regionWidget/" + args.regionWidgetId + "/delete",
-                null,
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    } else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback();
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function addPage(args) {
-            $.post(rave.getContext() + path + "page/add",
-                {
-                    pageName: args.pageName,
-                    pageLayoutCode: args.pageLayoutCode
-                },
-                function(result) {
-                    if (result.error) {
-                        // check to see if a duplicate page name error occurred
-                        if (result.errorCode == 'DUPLICATE_ITEM') {
-                            $("#"+args.errorLabel).html(rave.getClientMessage("page.duplicate_name"));
-                        } else {
-                            handleRpcError(result);
-                        }
-                    } else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function getPage(args){
-            $.get(rave.getContext() + path + "page/get",
-                    {
-                        pageId: args.pageId
-                    },
-                    function(result) {
-                        if (result.error) {
-                            handleRpcError(result);
-                        } else {
-                            if (typeof args.successCallback == 'function') {
-                                args.successCallback(result);
-                            }
-                        }
-                    }).error(handleError);
-        }
-
-        function movePage(args) {
-            // the moveAfterPageId attribute could be undefined if moving
-            // to the first position. In that case don't send a moveAfterPageId
-            // post parameter
-            var data = {};
-            if (args.moveAfterPageId) {
-                data["moveAfterPageId"] = args.moveAfterPageId;
-            }
-
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/move",
-                data,
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    } else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function moveWidgetToPage(args) {
-            var data = {};
-            if (args.toPageId) {
-                data["toPageId"] = args.toPageId;
-                data["regionWidgetId"] = args.regionWidgetId;
-            }
-
-            $.post(rave.getContext() + path + "page/" + args.toPageId + "/moveWidget",
-                data,
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    } else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function updatePagePrefs(args) {
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/update",
-               {"name": args.title, "layout": args.layout},
-               function(result) {
-                   if (result.error) {
-                       if (result.errorCode == 'DUPLICATE_ITEM') {
-                           $("#"+args.errorLabel).html(rave.getClientMessage("page.duplicate_name"));
-                       } else {
-                           handleRpcError(result);
-                       }
-                   }
-                   else {
-                       if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                       }
-                   }
-               }).error(handleError);
-        }
-
-        function getPagePrefs(args) {
-            $.get(rave.getContext() + path + "page/get?pageId="+args.pageId,
-                  null,
-                  function(result) {
-                    if (typeof args.successCallback == 'function') {
-                        args.successCallback(result);
-                    }
-                  }
-            );
-        }
-
-        //TODO RAVE-228: Create a more robust error handling system and interrogation of RPC results
-        function handleRpcError(rpcResult) {
-            switch (rpcResult.errorCode) {
-                case "NO_ERROR" :
-                    break;
-                case "INVALID_PARAMS":
-                    alert(rave.getClientMessage("api.rpc.error.invalid_params"));
-                    break;
-                case "INTERNAL_ERROR":
-                    alert(rave.getClientMessage("api.rpc.error.internal"));
-                    break;
-            }
-        }
-
-        function getWidgetMetadata(args) {
-            var url = args.url;
-            var providerType = args.providerType;
-            if ( url == null || providerType == null ) {
-                alert(rave.getClientMessage("api.widget_metadata.invalid_params"));
-                return;
-            }
-            $.post(rave.getContext() + path + "widget/metadata/get",
-               {"url": url, "type": providerType},
-               function(result) {
-                   if (result.error) {
-                       alert(rave.getClientMessage("api.widget_metadata.parse_error"));
-                   }
-                   else {
-                       if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                       }
-                   }
-               }).error(handleError);
-        }
-
-        function getWidgetMetadataGroup(args) {
-            var url = args.url;
-            var providerType = args.providerType;
-            if ( url == null || providerType == null ) {
-                alert(rave.getClientMessage("api.widget_metadata.invalid_params"));
-                return;
-            }
-            $.post(rave.getContext() + path + "widget/metadatagroup/get",
-               {"url": url, "type": providerType},
-               function(result) {
-                   if (result.error) {
-                       alert(rave.getClientMessage("api.widget_metadata.parse_error"));
-                   }
-                   else {
-                       if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                       }
-                   }
-               }).error(handleError);
-        }
-
-        function getAllWidgets(args){
-            $.get(rave.getContext() + path + "widget/getall",
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function getUsers(args){
-            var offset = args.offset;
-            $.get(rave.getContext() + path + "person/get",
-                {"offset": offset},
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function searchUsers(args){
-            var searchTerm = args.searchTerm;
-            var offset = args.offset;
-            if (searchTerm == null || searchTerm == "") {
-                alert(rave.getClientMessage("api.rpc.empty.search.term"));
-                return;
-            }
-            $.get(rave.getContext() + path + "person/search",
-                    {"searchTerm": searchTerm, "offset": offset},
-                    function(result) {
-                        if (result.error) {
-                            handleRpcError(result);
-                        }
-                        else {
-                            if (typeof args.successCallback == 'function') {
-                                 args.successCallback(result);
-                            }
-                        }
-                    }).error(handleError);
-        }
-
-        function clonePageForUser(args) {
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/clone",
-               {"userId": args.userId,
-                "pageName" : args.pageName},
-               function(result) {
-                   if (typeof args.successCallback == 'function') {
-                        args.successCallback(result);
-                   }
-               }).error(handleError);
-        }
-
-        function addMemberToPage(args) {
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/addmember",
-               {"userId": args.userId},
-               function(result) {
-                   if (result.error) {
-                       handleRpcError(result);
-                   }
-                   else {
-                       if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                       }
-                   }
-               }).error(handleError);
-        }
-
-        function removeMemberFromPage(args){
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/removemember",
-                {"userId": args.userId},
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-
-        function updateSharedPageStatus(args){
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/sharestatus",
-                {"shareStatus": args.shareStatus},
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-            }).error(handleError);
-        }
-
-        function updatePageEditingStatus(args){
-            $.post(rave.getContext() + path + "page/" + args.pageId + "/editstatus",
-                {"userId": args.userId,
-                "isEditor": args.isEditor},
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-            }).error(handleError);
-        }
-
-        function addFriend(args) {
-            var user =  encodeURIComponent(encodeURIComponent(args.friendUsername));
-            $.post(rave.getContext() + path + "person/" + user + "/addfriend",
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                             args.successCallback(result);
-                        }
-                    }
-               }).error(handleError);
-        }
-        function removeFriend(args) {
-            var user =  encodeURIComponent(encodeURIComponent(args.friendUsername));
-            $.post(rave.getContext() + path + "person/" + user + "/removefriend",
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                             args.successCallback(result);
-                        }
-                    }
-               }).error(handleError);
-        }
-        function getFriends(args){
-            $.post(rave.getContext() + path + "person/getFriends",
-                function(result) {
-                    if (result.error) {
-                        handleRpcError(result);
-                    }
-                    else {
-                        if (typeof args.successCallback == 'function') {
-                            args.successCallback(result);
-                        }
-                    }
-                }).error(handleError);
-        }
-        function acceptFriendRequest(args) {
-            var user =  encodeURIComponent(encodeURIComponent(args.friendUsername));
-            $.post(rave.getContext() + path + "person/" + user + "/acceptfriendrequest",
-                    function(result) {
-                        if (result.error) {
-                            handleRpcError(result);
-                        }
-                        else {
-                            if (typeof args.successCallback == 'function') {
-                                 args.successCallback(result);
-                            }
-                        }
-                   }).error(handleError);
-        }
-
-        function addWidgetFromMarketplace(args){
-            $.post(rave.getContext() + path + "marketplace/add",
-                    {"url": args.url,
-                     providerType: args.providerType},
-                    function(result) {
-                        if (result.error) {
-                            handleRpcError(result);
-                        }
-                        else {
-                            if (typeof args.successCallback == 'function') {
-                                args.successCallback(result);
-                            }
-                        }
-                }).error(handleError);
-        }
-
-        return {
-            moveWidget : moveWidgetOnPage,
-            addWidgetToPage : addWidgetToPage,
-            addWidgetToPageRegion: addWidgetToPageRegion,
-            removeWidget : deleteWidgetOnPage,
-            addPage: addPage,
-            getPage: getPage,
-            updatePagePrefs: updatePagePrefs,
-            getPagePrefs: getPagePrefs,
-            movePage: movePage,
-            moveWidgetToPage: moveWidgetToPage,
-            getWidgetMetadata: getWidgetMetadata,
-            getWidgetMetadataGroup: getWidgetMetadataGroup,
-            getUsers : getUsers,
-            searchUsers : searchUsers,
-            clonePageForUser : clonePageForUser,
-            addMemberToPage : addMemberToPage,
-            removeMemberFromPage : removeMemberFromPage,
-            updateSharedPageStatus : updateSharedPageStatus,
-            updatePageEditingStatus: updatePageEditingStatus,
-            addFriend : addFriend,
-            removeFriend : removeFriend,
-            getFriends : getFriends,
-            acceptFriendRequest : acceptFriendRequest,
-            addWidgetFromMarketplace : addWidgetFromMarketplace,
-            getAllWidgets : getAllWidgets
-        };
-
-    })();
-
-    /*
-     *	Handler functions to handle modifications on user events
-     */
-    var handlerApi = (function() {
-
-    	//function to handle widget rating changes
-    	function widgetRatingHandler(widgetRating) {
-
-    		//retrieving the current total likes
-    		var likeTotalLabel = document.getElementById("totalLikes-"+ widgetRating.widgetId);
-    		var likeTotal = likeTotalLabel.getAttribute("data-rave-widget-likes");
-
-    		//retrieving the current total dislikes
-    		var dislikeTotalLabel = document.getElementById("totalDislikes-"+ widgetRating.widgetId);
-			var dislikeTotal = dislikeTotalLabel.getAttribute("data-rave-widget-dislikes");
-
-			//initializing temporary variables
-			var incrementingTotal = -1;
-			var decrementingTotal = -1;
-			var curButton = "";
-			var prevButton = "";
-			var prevRating = -1;
-
-			//check if like rating needs to be updated
-    		if(widgetRating.isLike) {
-
-    			//set incrementing total to like total
-    			incrementingTotal = likeTotal;
-
-    			//set the incrementing total label to like total label
-    			incrementingTotalLabel = likeTotalLabel;
-
-    			//set decrementing total to dislike total
-    			decrementingTotal = dislikeTotal;
-
-    			//set the decrementing total label to dislike total label
-    			decrementingTotalLabel = dislikeTotalLabel;
-
-    			//set the current clicked button to like button
-    			curButton = widgetRating.widgetLikeButton;
-
-    			//set the previous clicked button to dislike button
-    			prevButton = widgetRating.widgetDislikeButton;
-
-    			//set the previous rating to 0 to check if dislike was clicked earlier
-    			prevRating = 0;
-    		}
-
-    		//check if dislike rating needs to be updated
-    		else {
-
-    			//set incrementing total to dislike total
-    			incrementingTotal = dislikeTotal;
-
-    			//set the incrementing total label to dislike total label
-    			incrementingTotalLabel = dislikeTotalLabel;
-
-    			//set decrementing total to like total
-    			decrementingTotal = likeTotal;
-
-    			//set the decrementing total label to like total label
-    			decrementingTotalLabel = likeTotalLabel;
-
-    			//set the current clicked button to dislike button
-    			curButton = widgetRating.widgetDislikeButton;
-
-    			//set the previous clicked button to like button
-    			prevButton = widgetRating.widgetLikeButton;
-
-    			//set the previous rating to 10 to check if like was clicked earlier
-    			prevRating = 10;
-    		}
-
-    		//update incrementing total
-        	incrementingTotal = parseInt(incrementingTotal) + 1;
-        	if(incrementingTotalLabel == likeTotalLabel) {
-        		incrementingTotalLabel.setAttribute("data-rave-widget-likes", incrementingTotal);
-        		incrementingTotalLabel.innerHTML = incrementingTotal;
-        	}
-        	else {
-        		incrementingTotalLabel.setAttribute("data-rave-widget-dislikes", incrementingTotal);
-        		incrementingTotalLabel.innerHTML = incrementingTotal;
-        	}
-
-        	//get the value of hidden user rating
-        	var hiddenButton = document.getElementById("rate-"+ widgetRating.widgetId);
-        	var userPrevRate = hiddenButton.value;
-
-        	//if the other button in this pair was checked then ajdust its total, except in IE where
-        	//the button has already toggled BEFORE the 'change' event in which case we have to assume
-        	//that the user had a contrary selection prior to the change event
-        	if (prevButton.get(0).getAttribute("checked") == "true" || curButton.checked == true) {
-        		prevButton.get(0).setAttribute("checked", "false");
-
-        		//remove the previous rating made by the user if any by checking change in userRating
-        		if(parseInt(userPrevRate) == prevRating) {
-
-        			//update decrementing total
-        			if(parseInt(decrementingTotal) - 1 > -1) {
-        				decrementingTotal = parseInt(decrementingTotal) - 1;
-        				if(decrementingTotalLabel == likeTotalLabel) {
-        					decrementingTotalLabel.setAttribute("data-rave-widget-likes", decrementingTotal);
-        					decrementingTotalLabel.innerHTML = decrementingTotal;
-        				}
-        				else {
-        					decrementingTotalLabel.setAttribute("data-rave-widget-dislikes", decrementingTotal);
-        					decrementingTotalLabel.innerHTML = decrementingTotal;
-        				}
-        			}
-        		}
-
-        	}
-
-        	//flag this element as the currently checked one
-        	curButton.setAttribute("checked", "true");
-
-        	//set the user rating of the hidden field
-        	if(widgetRating.isLike) {
-        		hiddenButton.value = "10";
-        	}
-        	else{
-        		hiddenButton.value = "0";
-        	}
-    	}
-
-    	//function to toggle sliding down and up of user profile tabs
-    	function userProfileTabHandler(profileTab) {
-    			//parsing profile tab id to obtain panel id
-    			var panelId = "#" + profileTab.id.substring(0, profileTab.id.indexOf("Tab")) + "Panel";
-    			$(panelId).slideToggle("slow");
-    	}
-
-    	//function to toggle hide and show of tag pages
-    	function userProfileTagHandler(profileTag, defaultTagPage) {
-
-    			//first close any tag pages if open
-    			$(".profile-tag-page").hide();
-
-    			//show default tag page is set true
-    			if(defaultTagPage != null) {
-    				$(defaultTagPage).show();
-    			}
-
-    			else {
-    				//extract the tag page id from profile tag id
-    				var tagPageId = "#" + profileTag.id + "Page";
-    				//show the requested tag page
-    				$(tagPageId).show();
-    			}
-    	}
-
-    	function userProfileEditHandler(isEdit) {
-    		//get the edit element
-    		var profileInfo = document.getElementById("profileInfo");
-    		//extract hidden fields through their class
-    		var hiddenFields = "." + profileInfo.value + "-hidden";
-    		//extract labels through their class
-    		var visibleFields = "." + profileInfo.value + "-visible";
-
-    		if(isEdit) {
-    			//make hidden fields visible
-    			$(hiddenFields).show();
-    			//make visible fields invisible
-    			$(visibleFields).hide();
-    		}
-
-    		else {
-    			//make hidden fields invisible
-    			$(hiddenFields).hide();
-    			//make visible fields visible
-    			$(visibleFields).show();
-    		}
-    	}
-
-    	return {
-    		widgetRatingHandler : widgetRatingHandler,
-    		userProfileTabHandler : userProfileTabHandler,
-    		userProfileTagHandler : userProfileTagHandler,
-    		userProfileEditHandler : userProfileEditHandler
-    	};
-
-    })();
-
-    return {
-        rest : restApi,
-        rpc : rpcApi,
-        handler : handlerApi
-    };
-})();
-

Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_backbone.js
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_backbone.js?rev=1460715&r1=1460714&r2=1460715&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_backbone.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_backbone.js Mon Mar 25 15:29:43 2013
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-var rave = rave || {};
-
-/*
- Extend backbone's standard model and collection with some
- */
-rave.Model = Backbone.Model.extend({
-    get: function(attr){
-        //tweak model get so that array / object members are passed by value instead of reference
-        //needed for managing deep objects
-        return _.clone(this.attributes[attr]);
-    },
-
-    /*
-     Overridable function that models can implement for serializing themselves for view rendering,
-     since often a handlebars template needs explicit keys or booleans that don't make sense
-     in a normal json representation of the model. By default will just return toJSON().
-     */
-    toViewModel: function () {
-        return this.toJSON();
-    }
-});
-
-rave.Collection = Backbone.Collection.extend({
-    toViewModel: function () {
-        return this.map(function (model) {
-            return model.toViewModel();
-        });
-    }
-})
-
-
-/*
- rave.View is an extension of Backbone's view with some scaffolding put in place. The expectation is that a view
- will be declared with a hash of models (models or collections) that will be merged and fed to the view at render
- time. By default on any change to the models the view will be re-rendered. Also provides an implementation of
- render that probably will not need to be overrridden.
- */
-rave.View = Backbone.View.extend({
-    initialize: function () {
-        var self = this;
-        _.bindAll(this);
-
-        _.each(this.models, function (model) {
-            model.on('change', self.render);
-            model.on('reset', self.render);
-        });
-    },
-    render: function () {
-        var template = this.template;
-
-        var viewData = {};
-        _.each(this.models, function (model, key) {
-            viewData[key] = model.toViewModel();
-        });
-
-        this.$el.html(template(viewData));
-        return this;
-    }
-});
\ No newline at end of file

Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_forms.js
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_forms.js?rev=1460715&r1=1460714&r2=1460715&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_forms.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_forms.js Mon Mar 25 15:29:43 2013
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var rave = rave || {};
-rave.forms = rave.forms || (function() {
-
-    function validateNewAccountForm() {
-        $("#newAccountForm").validate({
-            rules: {
-                username : {
-                    required: true,
-                    minlength: 2
-                },
-                password : {
-                    required: true,
-                    minlength: 4
-                },
-                confirmPassword : {
-                    required: true,
-                    minlength: 4,
-                    equalTo: "#passwordField"
-                },
-                email : {
-                    required: true,
-                    email: true
-                }
-            },
-            messages: {
-                confirmPassword: {
-                    equalTo: rave.getClientMessage("form.password.invalid_match")
-                }
-            }
-        });
-    }
-
-    function validateUserProfileForm() {
-        $("#userProfileForm").validate({
-            rules: {
-                password : {
-                    required: true,
-                    minlength: 4
-                },
-                passwordConfirm : {
-                    required: true,
-                    minlength: 4,
-                    equalTo: "#passwordField"
-                }
-            },
-            messages: {
-                passwordConfirm: {
-                    equalTo: rave.getClientMessage("form.password.invalid_match")
-                }
-            }
-        });
-    }
-    
-    function validateEditAccountForm() {
-        $("#editAccountForm").validate({
-            rules: {
-            	 email : {
-                     required: true,
-                     email: true
-                 }
-            }            
-        });
-    }
-    
-    function validatePageForm() {
-        $("#pageForm").validate({
-            rules: {
-                tab_title : {
-                    required: true
-                }
-            }
-        });
-    }
-
-    return {
-        validateNewAccountForm : validateNewAccountForm,
-	    validateUserProfileForm: validateUserProfileForm,
-	    validateEditAccountForm: validateEditAccountForm,
-        validatePageForm: validatePageForm
-    };
-})();

Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_layout.js
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_layout.js?rev=1460715&r1=1460714&r2=1460715&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_layout.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_layout.js Mon Mar 25 15:29:43 2013
@@ -1,611 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var rave = rave || {};
-rave.layout = rave.layout || (function () {
-    var MOVE_PAGE_DEFAULT_POSITION_IDX = -1;
-    var $moveWidgetDialog;
-    var showImportExportUI = false;
-    var $movePageDialog = $("#movePageDialog");
-    var $pageFormTabbed = $("#pageFormTabbed");
-    var $pageFormImport = $("#pageFormImport");
-    var $omdlFile = $("#omdlFile");
-    var $pageForm = $("#pageForm");
-    var $tab_title_input = $("#tab_title"),
-        $tab_id = $("#tab_id"),
-        $page_layout_input = $("#pageLayout");
-
-    // page menu related functions
-    var pageMenu = (function () {
-        var $addPageButton = $("#addPageButton");
-        var $menuItemEdit = $("#pageMenuEdit");
-        var $menuItemDelete = $("#pageMenuDelete");
-        var $menuItemMove = $("#pageMenuMove");
-        var $menuItemShare = $("#pageMenuShare");
-        var $menuItemRevokeShare = $("#pageMenuRevokeShare");
-        var $MenuItemExport = $("#pageMenuExport");
-
-        /**
-         * Initializes the private pageMenu closure
-         * - binds click event handler to menu button
-         * - binds menu item click event handlers
-         * - binds body click event handler to close the menu
-         */
-        function init(showImportExport) {
-            showImportExportUI = showImportExport;
-            // initialize the page form validator overriding the
-            // styles to wire in bootstrap styles
-            $pageForm.validate({
-                errorElement: 'span',
-                errorClass: 'help-inline',
-                highlight: function (element, errorClass) {
-                    $(element).parent().parent().addClass('error');
-                },
-                unhighlight: function (element, errorClass) {
-                    $(element).parent().parent().removeClass('error');
-                }
-            });
-            $pageFormTabbed.validate({
-                errorElement: 'span',
-                errorClass: 'help-inline',
-                highlight: function (element, errorClass) {
-                    $(element).parent().parent().addClass('error');
-                },
-                unhighlight: function (element, errorClass) {
-                    $(element).parent().parent().removeClass('error');
-                }
-            });
-            $pageFormImport.validate({
-                errorElement: 'span',
-                errorClass: 'help-inline',
-                highlight: function (element, errorClass) {
-                    $(element).parent().parent().addClass('error');
-                },
-                unhighlight: function (element, errorClass) {
-                    $(element).parent().parent().removeClass('error');
-                }
-            });
-
-
-            // initialize the close button in the page menu dialog
-            $("#pageMenuCloseButton").click(rave.layout.closePageDialog);
-            $("#pageMenuCloseButtonTab").click(rave.layout.closePageDialogTabbed);
-            if (showImportExport) {
-                $("#pageMenuExport").removeClass('hidden');
-            }
-
-            // setup the edit page menu item
-            $addPageButton.bind('click', function (event) {
-                if (showImportExport) {
-                    var $pageMenuUpdateButtonTabbed = $("#pageMenuUpdateButtonTab");
-                    $pageMenuUpdateButtonTabbed.html(rave.getClientMessage("common.add"));
-                    $("#page-tabs").tabs();
-                    $pageMenuUpdateButtonTabbed.click(rave.layout.addOrImportPage);
-                    $('#pageMenuDialogTabbed').on('shown', function () {
-                        $("#tab_title").first().focus();
-                    });
-                    $("#pageMenuDialogTabbed").modal('show');
-                } else {
-                    $("#pageMenuDialogHeader").html(rave.getClientMessage("page.add"));
-                    var $pageMenuUpdateButton = $("#pageMenuUpdateButton");
-                    $("#pageLayoutGroup").show();
-                    $pageMenuUpdateButton.html(rave.getClientMessage("common.add"));
-                    // unbind the previous click event since we are sharing the
-                    // dialog between separate add/edit page actions
-                    $pageMenuUpdateButton.unbind('click');
-                    $pageMenuUpdateButton.click(rave.layout.addPage);
-                    $('#pageMenuDialog').on('shown', function () {
-                        $("#tab_title").first().focus();
-                    });
-                    $("#pageMenuDialog").modal('show');
-                }
-            });
-
-            // setup the edit page menu item
-            $menuItemEdit.bind('click', function (event) {
-                rave.api.rpc.getPagePrefs({pageId: getCurrentPageId(),
-                    successCallback: function (result) {
-                        $tab_title_input.val(result.result.name);
-                        $tab_id.val(result.result.id);
-                        $page_layout_input.val(result.result.pageLayout.code);
-                        $("#pageMenuDialogHeader").html(rave.getClientMessage("page.update"));
-                        var $pageMenuUpdateButton = $("#pageMenuUpdateButton");
-                        $("#pageLayoutGroup").show();
-                        $pageMenuUpdateButton.html(rave.getClientMessage("common.save"));
-                        // unbind the previous click event since we are sharing the
-                        // dialog between separate add/edit page actions
-                        $pageMenuUpdateButton.unbind('click');
-                        $pageMenuUpdateButton.click(rave.layout.updatePage);
-                        $('#pageMenuDialog').on('shown', function () {
-                            $("#tab_title").first().focus();
-                        });
-                        $("#pageMenuDialog").modal('show');
-                    }
-                });
-            });
-
-            // setup the delete page menu item if it is not disabled
-            if (!$menuItemDelete.hasClass("menu-item-disabled")) {
-                $menuItemDelete.bind('click', function (event) {
-                    // send the rpc request to delete the page
-                    rave.api.rest.deletePage({pageId: getCurrentPageId(), successCallback: rave.viewPage});
-                });
-            }
-
-            // setup the move page menu item if it is not disabled
-            if (!$menuItemMove.hasClass("menu-item-disabled")) {
-                $menuItemMove.bind('click', function (event) {
-                    $movePageDialog.modal('show');
-                });
-            }
-
-            // setup the export page menu item if it is not disabled
-            if (!$MenuItemExport.hasClass("hidden")) {
-                $MenuItemExport.bind('click', function (event) {
-                    window.open(rave.getContext() + "api/rest/" + "page/" + getCurrentPageId() + "/omdl");
-                });
-            }
-
-            // setup the revoke share page menu item
-            if (!$menuItemRevokeShare.hasClass("menu-item-disabled")) {
-                $menuItemRevokeShare.bind('click', function (event) {
-                    rave.models.currentPage.removeForSelf();
-                });
-            }
-        }
-
-        return {
-            init: init
-        }
-    })();
-
-    // widget menu related functions
-    var widgetMenu = (function () {
-        var $menu;
-        var $menuItemMove;
-        var $menuItemDelete;
-        var $menuItemMaximize;
-        var $menuItemAbout;
-        var $menuItemComment;
-        var $menuItemRate;
-
-        /**
-         * 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();
-            $(".iframe-overlay").remove();
-        }
-
-        /**
-         * Hides all widget menus
-         */
-        function hideAllMenus() {
-            $(".widget-menu").hide();
-            $(".iframe-overlay").remove();
-        }
-
-        /**
-         * 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();
-        }
-
-        /**
-         * Initializes a single widgets private widgetMenu closure
-         * - binds click event handler to menu button
-         * - binds menu item click event handlers
-         * - binds body click event handler to close the menu
-         */
-        function bindWidgetMenu(widgetId) {
-            // setup the move to page menu item
-            $menuItemMove = $("#widget-" + widgetId + "-menu-move-item");
-            if (!$menuItemMove.hasClass("menu-item-disabled")) {
-                $menuItemMove.bind('click', function (event) {
-                    var regionWidgetId = rave.getObjectIdFromDomId(this.id);
-                    // Clear the dropdown box; needing to do this may be a bug?
-                    $('.dropdown').removeClass('open');
-                    // Open the modal
-                    $("#moveWidgetModal").data('regionWidgetId', regionWidgetId);
-                    $("#moveWidgetModal").modal('show');
-
-                    // 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("menu-item-disabled")) {
-                $menuItemDelete.bind('click', function (event) {
-                    var regionWidgetId = rave.getObjectIdFromDomId(this.id);
-
-                    // 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("menu-item-disabled")) {
-                $menuItemMaximize.bind('click', function (event) {
-                    var regionWidgetId = rave.getObjectIdFromDomId(this.id);
-
-                    // 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();
-                });
-            }
-
-            // setup the about this widget menu item
-            $menuItemAbout = $("#widget-" + widgetId + "-menu-about-item");
-            if (!$menuItemAbout.hasClass("menu-item-disabled")) {
-                $menuItemAbout.bind('click', function (event) {
-                    var regionWidget = rave.getRegionWidgetById(rave.getObjectIdFromDomId(this.id));
-
-                    // go to the widget detail page
-                    rave.viewWidgetDetail(regionWidget.widgetId, getCurrentPageId());
-                    // 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 comment on this widget menu item
-            $menuItemComment = $("#widget-" + widgetId + "-menu-comment-item");
-            if (!$menuItemComment.hasClass("menu-item-disabled")) {
-                $menuItemComment.bind('click', function (event) {
-                    var regionWidget = rave.getRegionWidgetById(rave.getObjectIdFromDomId(this.id));
-
-                    // go to the widget detail page
-                    rave.viewWidgetDetail(regionWidget.widgetId, getCurrentPageId(), 'widgetComments');
-                    // 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 Rate this widget menu item
-            $menuItemRate = $("#widget-" + widgetId + "-menu-rate-item");
-            if (!$menuItemRate.hasClass("menu-item-disabled")) {
-                $menuItemRate.bind('click', function (event) {
-                    var regionWidget = rave.getRegionWidgetById(rave.getObjectIdFromDomId(this.id));
-
-                    // go to the widget detail page
-                    rave.viewWidgetDetail(regionWidget.widgetId, getCurrentPageId(), 'widgetRatings');
-                    // prevent the menu button click event from bubbling up to parent
-                    // DOM object event handlers such as the page tab click event
-                    event.stopPropagation();
-                });
-            }
-        }
-
-        /**
-         * Initializes ALL widgets private widgetMenu closure
-         */
-        function init() {
-            // 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);
-                bindWidgetMenu(widgetId);
-            });
-        }
-
-        /**
-         * Enables the Edit Prefs including the Preferences view (Custom 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
-         * @param isPreferencesView boolean to indicate whether "preferences" view or the default prefs view
-         */
-        function enableEditPrefsMenuItem(regionWidgetId, isPreferencesView) {
-            // setup the edit prefs widget menu item
-            var $menuItemEditPrefs = $("#widget-" + regionWidgetId + "-menu-editprefs-item");
-            $menuItemEditPrefs.removeClass("menu-item-disabled");
-            $menuItemEditPrefs.on('click', function (event) {
-                var regionWidgetId = rave.getObjectIdFromDomId(this.id);
-
-                // show the regular edit prefs or the Custom Edit Prefs(preferences) region
-                if (isPreferencesView) {
-                    rave.editCustomPrefs({data: {id: regionWidgetId}});
-                }
-                else {
-                    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
-                return false;
-            });
-        }
-
-        return {
-            init: init,
-            bindWidgetMenu: bindWidgetMenu,
-            hideAll: hideAllMenus,
-            hide: hideMenu,
-            show: showMenu,
-            enableEditPrefsMenuItem: enableEditPrefsMenuItem
-        }
-    })();
-
-    function addIframeOverlays(event) {
-        //e.preventDefault();
-
-        var i = 0;
-        $(".widget").each(function () {
-            var W = $(this).outerWidth(),
-                H = $(this).outerHeight(),
-                X = $(this).position().left,
-                Y = $(this).position().top;
-
-            $(this).after('<div class="iframe-overlay" onclick="rave.layout.hideWidgetMenu()" />');
-            $(this).next('.iframe-overlay').css({
-                width: W,
-                height: H,
-                position: "absolute",
-                top: Y,
-                left: X
-            });
-
-        });
-
-        // Remove any overlays onclick of all the things!!!
-        $("*:not(.dropdown-toggle)").on("click", function () {
-            $(".iframe-overlay").remove();
-        });
-    }
-
-    /**
-     * Submits the RPC call to move the widget to a new page
-     */
-    function moveWidgetToPage(regionWidgetId) {
-        var toPageId = $("#moveToPageId").val();
-        var args = { toPageId: toPageId,
-            regionWidgetId: regionWidgetId,
-            successCallback: function () {
-                rave.viewPage(toPageId);
-            }
-        };
-        // send the rpc request to move the widget to new page
-        rave.api.rpc.moveWidgetToPage(args);
-    }
-
-    /**
-     * Submits the RPC call to add a new page if form validation passes
-     */
-    function addPage() {
-        if (showImportExportUI) {
-            if ($pageFormTabbed.valid()) {
-                var newPageTitle = $("#tab_titleTabbed1").val();
-                var newPageLayoutCode = $("#pageLayoutTabbed").val();
-                // send the rpc request to create the new page
-                rave.api.rpc.addPage({pageName: newPageTitle,
-                    pageLayoutCode: newPageLayoutCode,
-                    errorLabel: 'pageFormErrorsTabbed1',
-                    successCallback: function (result) {
-                        rave.viewPage(result.result.id);
-                    }
-                });
-            }
-        } else {
-            if ($pageForm.valid()) {
-                var newPageTitle = $tab_title_input.val();
-                var newPageLayoutCode = $page_layout_input.val();
-                // send the rpc request to create the new page
-                rave.api.rpc.addPage({pageName: newPageTitle,
-                    pageLayoutCode: newPageLayoutCode,
-                    errorLabel: 'pageFormErrors',
-                    successCallback: function (result) {
-                        rave.viewPage(result.result.id);
-                    }
-                });
-            }
-        }
-    }
-
-    function importPage() {
-        if ($.browser.msie == true) {
-            alert(rave.getClientMessage("import.page.not.supported"));
-        }
-        else {
-            if ($pageFormImport.valid()) {
-                $pageFormImport.get(0).setAttribute('action', rave.getContext() + "api/rpc/page/import/omdl");
-                document.getElementById('pageFormImport').onsubmit = function () {
-                    document.getElementById('pageFormImport').target = 'file_upload_frame';
-                    document.getElementById("file_upload_frame").onload = processFileUploadResult;
-                }
-                $pageFormImport.submit();
-            }
-        }
-    }
-
-    function processFileUploadResult() {
-        // chrome & firefox a <pre> has been added to the begining of the json
-        var ret = frames['file_upload_frame'].document.getElementsByTagName("body")[0].firstChild.innerHTML;
-        var data = eval("(" + ret + ")");
-        if (data.error) {
-            if (data.errorCode == 'DUPLICATE_ITEM') {
-                $("#pageFormErrorsTabbed2").html(rave.getClientMessage("page.duplicate_name"));
-            }
-            else if (data.errorCode == 'INTERNAL_ERROR' && data.errorMessage.indexOf("BadOmdlXmlFormatException") != -1) {
-                var msg = data.errorMessage.substr(data.errorMessage.indexOf("BadOmdlXmlFormatException"), data.errorMessage.length)
-                $("#pageFormErrorsTabbed2").html(msg);
-            }
-            else {
-                alert(rave.getClientMessage("api.rpc.error.internal"));
-            }
-        }
-        else {
-            rave.viewPage(data.result.id);
-        }
-    }
-
-    function addOrImportPage() {
-        var selectedTab = $("#page-tabs").tabs('option', 'selected');
-        if (selectedTab == 0) {
-            addPage();
-        } else {
-            importPage();
-        }
-    }
-
-    /**
-     * Submits the RPC call to move the page to a new render sequence
-     */
-    function movePage() {
-        var moveAfterPageId = $("#moveAfterPageId").val();
-        var args = { pageId: $("#currentPageId").val(),
-            successCallback: function (result) {
-                rave.viewPage(result.result.id);
-            }
-        };
-
-        if (moveAfterPageId != MOVE_PAGE_DEFAULT_POSITION_IDX) {
-            args["moveAfterPageId"] = moveAfterPageId;
-        }
-
-        // send the rpc request to move the new page
-        rave.api.rpc.movePage(args);
-    }
-
-    function updatePage() {
-        if ($pageForm.valid()) {
-            // send the rpc request to update the page
-            rave.api.rpc.updatePagePrefs({pageId: $tab_id.val(),
-                title: $tab_title_input.val(),
-                layout: $page_layout_input.val(),
-                errorLabel: 'pageFormErrors',
-                successCallback: function (result) {
-                    rave.viewPage(result.result.id);
-                }});
-        }
-    }
-
-    function closePageDialog() {
-        $pageForm[0].reset();
-        $tab_id.val('');
-        $("#pageFormErrors").text('');
-        $("#pageMenuDialog").modal("hide");
-    }
-
-    function closePageDialogTabbed() {
-        $pageForm[0].reset();
-        $("#pageFormErrors").text('');
-        $("#pageFormErrorsTabbed1").text('');
-        $("#pageFormErrorsTabbed2").text('');
-        $pageFormTabbed[0].reset();
-        $pageFormImport[0].reset();
-        $("#pageMenuDialogTabbed").modal("hide");
-    }
-
-    /**
-     * Invokes the RPC call to delete a regionWidget from a page
-     *
-     * @param regionWidgetId the regionWidgetId to delete
-     */
-    function deleteRegionWidget(regionWidgetId) {
-        if (confirm(rave.getClientMessage("widget.remove_confirm"))) {
-            rave.api.rpc.removeWidget({
-                regionWidgetId: regionWidgetId,
-                successCallback: function () {
-                    // remove the widget from the dom and the internal memory map
-                    $("#widget-" + this.regionWidgetId + "-wrapper").remove();
-                    rave.removeWidgetFromMap(this.regionWidgetId);
-                    if (rave.isPageEmpty()) {
-                        rave.displayEmptyPageMessage();
-                    }
-                }
-            });
-        }
-    }
-
-    /**
-     * Returns the pageId of the currently viewed page
-     */
-    function getCurrentPageId() {
-        return $("#currentPageId").val();
-    }
-
-    /**
-     * Determines if the widget should be rendered as part of the initial page view.  This can be used to help optimize
-     * page loads as widgets located on non-active sub pages will not be rendered initially.  The function will return
-     * false if one of the following criteria is met, and true otherwise:
-     *
-     * 1) the widget is on a top level page (not a sub page)
-     * 2) the widget is on a sub page that is currently requested in the URL via the hash tag
-     *    ie /app//person/canoniocal#My%20Activity
-     * 3) the widget is on the default sub page and the page request URL doesn't contain a sub-page hash tag
-     *    ie /app/person/canonical
-     *
-     * @return boolean
-     */
-    function isWidgetOnHiddenTab(widget) {
-        var hash = decodeURIComponent(location.hash);
-        var subPage = widget.subPage;
-        return !(subPage.id === null ||
-            ("#" + subPage.name) === hash ||
-            (hash === "" && subPage.isDefault));
-    }
-
-    /***
-     * initializes the rave.layout namespace code
-     */
-    function init(showImportExport) {
-        pageMenu.init(showImportExport);
-        widgetMenu.init();
-        // initialize the bootstrap dropdowns
-        $(".dropdown-toggle").dropdown();
-    }
-
-    // public rave.layout API
-    return {
-        init: init,
-        getCurrentPageId: getCurrentPageId,
-        hideWidgetMenu: widgetMenu.hide,
-        deleteRegionWidget: deleteRegionWidget,
-        enableEditPrefsMenuItem: widgetMenu.enableEditPrefsMenuItem,
-        bindWidgetMenu: widgetMenu.bindWidgetMenu,
-        addPage: addPage,
-        addOrImportPage: addOrImportPage,
-        updatePage: updatePage,
-        movePage: movePage,
-        importPage: importPage,
-        closePageDialog: closePageDialog,
-        closePageDialogTabbed: closePageDialogTabbed,
-        moveWidgetToPage: moveWidgetToPage,
-        isWidgetOnHiddenTab: isWidgetOnHiddenTab,
-        addIframeOverlays: addIframeOverlays
-    };
-})();

Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_models.js
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_models.js?rev=1460715&r1=1460714&r2=1460715&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_models.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_models.js Mon Mar 25 15:29:43 2013
@@ -1,277 +0,0 @@
-var rave = rave || {};
-
-rave.models = (function () {
-
-    /*
-     User model. Further implementation pending.
-     */
-    var User = rave.Model.extend({
-
-    });
-
-    /*
-     Collection of users. Currently used for the share page users search.
-     */
-    var Users = rave.Collection.extend({
-        model: User,
-        pageSize: 10,
-
-        //empty pagination data, is filled in on requests
-        paginationData: {
-            start:0,
-            finish: 0,
-            total: 0,
-            prevLink: {},
-            nextLink: {},
-            pages: []
-        },
-
-        initialize: function(){
-            //ensure that parse is always invoked in the context of this object
-            _.bindAll(this, 'parse');
-        },
-
-        //filter collection with a search term
-        filter: function (term) {
-            this.searchTerm = term;
-
-            if (this.searchTerm) {
-                rave.api.rpc.searchUsers({searchTerm: this.searchTerm, offset: 0, successCallback: this.parse });
-            }
-            else {
-                rave.api.rpc.getUsers({offset: 0, successCallback: this.parse });
-            }
-        },
-
-        //used for pagination
-        fetchPage: function (page) {
-            var self = this;
-
-            var offset = page?(page-1):0;
-            offset *= this.pageSize;
-
-            if (this.searchTerm) {
-                rave.api.rpc.searchUsers({searchTerm: this.searchTerm, offset: offset, successCallback: this.parse });
-            }
-            else {
-                rave.api.rpc.getUsers({offset: offset, successCallback: this.parse });
-            }
-        },
-
-        //parse return data from the rpc call into a usable data model
-        parse: function (data) {
-            var result = data.result;
-            this.pageSize = result.pageSize || 10;
-
-            this.paginationData = {
-                start: result.offset + 1,
-                finish: result.resultSet.length + result.offset,
-                total: result.totalResults,
-                pageSize: result.pageSize,
-                prevLink: {
-                    show: result.currentPage > 1 ? true : false,
-                    pageNumber: result.currentPage - 1
-                },
-                nextLink: {
-                    show: result.currentPage < result.numberOfPages ? true : false,
-                    pageNumber: result.currentPage + 1
-                },
-                //pages will be an array of objects from 1 to number of pages
-                pages: _.map(_.range(1, result.numberOfPages + 1), function (pageNumber) {
-                    return {
-                        pageNumber: pageNumber,
-                        current: pageNumber == result.currentPage
-                    }
-                })
-            }
-
-            this.reset(result.resultSet);
-        },
-
-        //When toViewModel is invoked, also provide pagination and filter data
-        toViewModel: function () {
-            return {
-                searchTerm: this.searchTerm,
-                pagination: this.paginationData,
-                users: this.constructor.__super__.toViewModel.apply(this)
-            }
-        }
-    });
-
-    /*
-     Page model. Used for managing most of the sharing functionality.
-     */
-    var Page = rave.Model.extend({
-
-        defaults: {
-            members: {}
-        },
-
-        /*
-         TODO: currently this is used to silently bootstrap the page model from the page view. Once
-         the jsp views are lightened up we should be able to provide a full representation of the page
-         model to pass to .set() and this should not be needed.
-         */
-        addInitData: function (userId, isEditor) {
-            var members = this.get('members');
-
-            members[userId] = {
-                userId: userId,
-                editor: isEditor
-            }
-
-            this.set('members', members, {silent:true});
-        },
-
-        isUserOwner: function (userId) {
-            return userId == this.get('ownerId');
-        },
-
-        isUserView: function(userId) {
-            return userId == this.get('viewerId');
-        },
-
-        isUserMember: function (userId) {
-            return this.get('members')[userId] ? true : false;
-        },
-
-        isUserEditor: function (userId) {
-            var member = this.get('members')[userId];
-            return member && member.editor;
-        },
-
-        addMember: function (userId) {
-            var self = this;
-
-            rave.api.rpc.addMemberToPage({pageId: self.get('id'), userId: userId,
-                successCallback: function (result) {
-                    var members = self.get('members');
-
-                    members[userId] = {
-                        userId: userId,
-                        editor: false
-                    }
-
-                    self.set('members', members);
-                    /*
-                     The model does not manage or care about views. Instead it fires events
-                     that views can subscribe to for ui representation.
-                     TODO: solidify and document eventing model
-                     */
-                    self.trigger('share', 'member:add', userId);
-                }
-            });
-
-        },
-
-        removeMember: function (userId) {
-            var self = this;
-
-            rave.api.rpc.removeMemberFromPage({pageId: self.get('id'), userId: userId,
-                successCallback: function (result) {
-                    var members = self.get('members');
-
-                    delete members[userId];
-
-                    self.set('members', members);
-                    self.trigger('share', 'member:remove', userId);
-                }
-            });
-        },
-
-        removeForSelf: function(){
-            var self = this;
-
-            rave.api.rpc.removeMemberFromPage({pageId: self.get('id'), userId: self.get('viewerId'),
-                successCallback: function () {
-                    self.trigger('declineShare', self.get('id'));
-                }
-            });
-        },
-
-        addEditor: function (userId) {
-            var self = this;
-            //updatePageEditingStatus
-            rave.api.rpc.updatePageEditingStatus({pageId: self.get('id'), userId: userId, isEditor: true,
-                successCallback: function () {
-                    var members = self.get('members');
-
-                    members[userId] = {
-                        userId: userId,
-                        editor: true
-                    }
-
-                    self.set('members', members);
-                    self.trigger('share', 'editor:add', userId);
-                }
-            });
-        },
-
-        removeEditor: function (userId) {
-            var self = this;
-            rave.api.rpc.updatePageEditingStatus({pageId: self.get('id'), userId: userId, isEditor: false,
-                successCallback: function () {
-
-                    var members = self.get('members');
-
-                    members[userId] = {
-                        userId: userId,
-                        editor: false
-                    }
-
-                    self.set('members', members);
-                    self.trigger('share', 'editor:remove', userId);
-                }
-            });
-        },
-
-        cloneForUser: function (userId, pageName) {
-            pageName = pageName || null;
-            var self =this;
-            rave.api.rpc.clonePageForUser({pageId: this.get('id'), userId: userId, pageName: pageName,
-                successCallback: function(result){
-                    if(result.error) {
-                        /*
-                         TODO: this is a weird error handling condition used by clone to catch duplicate
-                         named pages. Firing an event and letting the view handle for now, but the api
-                         should be managing errors better.
-                         */
-                        return self.trigger('error', result.errorCode, userId);
-                    }
-                    self.trigger('share', 'clone', userId);
-                }
-            });
-        },
-
-        acceptShare: function(){
-            var self = this;
-            rave.api.rpc.updateSharedPageStatus({pageId: this.get('id'), shareStatus: 'accepted',
-                successCallback: function (result) {
-                    self.trigger('acceptShare', self.get('id'));
-                }
-            });
-        },
-
-        declineShare: function(){
-            var self = this;
-
-            rave.api.rpc.updateSharedPageStatus({pageId: this.get('id'), shareStatus: 'refused',
-                successCallback: function (result) {
-                    rave.api.rpc.removeMemberFromPage({pageId: self.get('id'), userId: self.get('viewerId'),
-                        successCallback: function (result) {
-                            self.trigger('declineShare', self.get('id'));
-                        }
-                    });
-                }
-            })
-        }
-    });
-
-    return {
-        currentPage: new Page(),
-        users: new Users()
-    }
-
-})();
-
-