Modified: rave/trunk/rave-portal-resources/src/main/webapp/script/rave_store.js
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_store.js?rev=1329241&r1=1329240&r2=1329241&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/script/rave_store.js 
(original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/script/rave_store.js Mon 
Apr 23 13:51:02 2012
@@ -18,122 +18,120 @@
  */
 var rave = rave || {};
 rave.store = rave.store || (function() {
-    
+
     function initRatings() {
-        $(".ratingButtons").buttonset();
+        $('.ratingButtons').button();
+        $('.widgetLikeButton').click(function() {
+            // If not already active
+            if (!$(this).hasClass('active')){
+                //retrieve widget id
+                var widgetId = this.id.substring("like-".length);
 
-        $(".widgetLikeButton").button( {
-            icons: {primary: "ui-icon-plus"}
-        }).click(function() {
-               
-               //check if like radio button is not checked already
-               if(this.getAttribute("checked") != "true") {
-                       
-                       //retrieve widget id
-                       var widgetId = this.id.substring("like-".length);
-                       
-                       //update the widget score in database
+                //update the widget score in database
                        rave.api.rest.updateWidgetRating({widgetId: widgetId, 
score: 10});
-                       
-                       //call update widget rating handler function
-                       var widgetRating = {
-                                       widgetId: widgetId, 
-                                           widgetLikeButton: this, 
-                                           widgetDislikeButton: 
$("#dislike-"+widgetId),
-                                               isLike: true
-                       };
-                       
-                       //update the widget ratings on web page
-                       rave.api.handler.widgetRatingHandler(widgetRating);
-               
-               }
+
+                //call update widget rating handler function
+                var widgetRating = {
+                    widgetId: widgetId,
+                    widgetLikeButton: this,
+                    widgetDislikeButton: $("#dislike-" + widgetId),
+                    isLike: true
+                };
+
+                //update the widget ratings on web page
+                rave.api.handler.widgetRatingHandler(widgetRating);
+
+                $(this).addClass('btn-success');
+                $(this).siblings('.btn').removeClass('btn-danger');
+            }
         });
 
-        $(".widgetDislikeButton").button( {
-            icons: {primary: "ui-icon-minus"}
-        }).click(function() {
-               
-               //check if dislike radio button is not checked already
-               if(this.getAttribute("checked") != "true") {
-               
-                       //retrieve widget id
-                       var widgetId = this.id.substring("dislike-".length);
-                       
-                       //update the widget score in database
-                       rave.api.rest.updateWidgetRating({widgetId: widgetId, 
score: 0});
-                       
-                       //call update widget rating handler function
-                       var widgetRating = {
-                                       widgetId: widgetId, 
-                                           widgetLikeButton: 
$("#like-"+widgetId), 
-                                           widgetDislikeButton: this,
-                                               isLike: false
-                       };
-                       
-                       //update the widget ratings on web page
-                       rave.api.handler.widgetRatingHandler(widgetRating);
-               }
+        $('.widgetDislikeButton').click(function() {
+            // If not already active
+            if (!$(this).hasClass('active')){
+                //retrieve widget id
+                var widgetId = this.id.substring("dislike-".length);
+
+                //update the widget score in database
+                rave.api.rest.updateWidgetRating({widgetId: widgetId, score: 
0});
+
+                //call update widget rating handler function
+                var widgetRating = {
+                    widgetId: widgetId,
+                    widgetLikeButton: $("#like-" + widgetId),
+                    widgetDislikeButton: this,
+                    isLike: false
+                };
+
+                //update the widget ratings on web page
+                rave.api.handler.widgetRatingHandler(widgetRating);
+
+                $(this).addClass('btn-danger');
+                $(this).siblings('.btn').removeClass('btn-success');
+
+            }
         });
     }
-    
+
     function initComments() {
-        
+
         $(".commentNewButton").button( {
             icons: {primary: "ui-icon-disk"},
             text: false
         }).click(function() {
             var widgetId = this.id.substring("comment-new-".length);
-            rave.api.rest.createWidgetComment({widgetId: widgetId, 
+            rave.api.rest.createWidgetComment({widgetId: widgetId,
                                                 text: 
$("#newComment-"+widgetId).get(0).value,
                                                 successCallback: function() { 
window.location.reload(); }});
         });
-        
+
         $(".commentDeleteButton").button( {
             icons: {primary: "ui-icon-close"},
             text: false
         }).click(function() {
             var commentId = this.id.substring("comment-delete-".length);
             var widgetId = this.getAttribute('data-widgetid');
-            rave.api.rest.deleteWidgetComment({widgetId: widgetId, 
+                rave.api.rest.deleteWidgetComment({widgetId: widgetId,
                                                 commentId: commentId,
                                                 successCallback: function() { 
window.location.reload(); }});
         });
-        
-        $(".commentEditButton").button( {
-            icons: {primary: "ui-icon-pencil"},
-            text: false
-        }).click(function() {
+
+        $(".commentEditButton").click(function() {
             var commentId = this.id.substring("comment-edit-".length);
             var widgetId = this.getAttribute('data-widgetid');
-            var commentText = $(this).parent().find(".commentText").text();
-            $("#editComment").text(commentText);
-            $("#editComment-dialog").dialog({
-               autoOpen: true,
-               height: 150,
-               width: 350,
-               modal: true,
-               buttons : [
-                    {
-                        text : rave.getClientMessage("common.update"),
-                        click : function() {
-                           rave.api.rest.updateWidgetComment({widgetId: 
widgetId,
-                                                            commentId: 
commentId,
-                                                            text: 
$("#editComment").get(0).value,
-                                                            successCallback: 
function() { window.location.reload(); }
-                                                        })
-                        }
-                    }
-               ]
-            });
+            var commentText = 
$(this).parents(".comment").find(".commentText").text();
+            $("#editComment").html(commentText);
+            $("#editComment-dialog #updateComment").click( function(){
+                rave.api.rest.updateWidgetComment({widgetId: widgetId,
+                    commentId: commentId,
+                    text: $("#editComment").get(0).value,
+                    successCallback: function() { window.location.reload(); }
+                });
+            }).html(rave.getClientMessage("common.update"));
         });
     }
 
     function initTags(widgetId) {
+        $('*[data-toggle="basic-slide"]').click(function(){
+            var target;
 
-        $(".tagNewButton").button({
-            icons:{primary:"ui-icon-disk"},
-            text:false
-        }).click(function () {
+            if($(this).attr("data-target")){
+                target = $(this).attr("data-target");
+                console.log($(this).attr("data-target"));
+            }
+            else{
+                target = $(this).attr("href");
+                console.log("else");
+            }
+
+            if($(this).attr('data-toggle-text')){
+                var oldcontent = $(this).html();
+                $(this).html($(this).attr('data-toggle-text'));
+                $(this).attr('data-toggle-text',oldcontent);
+            }
+            $(target).slideToggle();
+        });
+        $(".tagNewButton").click(function () {
                 var widgetId = this.id.substring("tag-new-".length);
                 rave.api.rest.createWidgetTag({widgetId:widgetId,
                     text:$("#tags").get(0).value,
@@ -150,8 +148,7 @@ rave.store = rave.store || (function() {
                         value:tag.keyword
                     }
                 }));
-
-                $("#tags").autocomplete({
+                $("#tags").typeahead({
                     source:result
                 })
             }
@@ -197,5 +194,5 @@ rave.store = rave.store || (function() {
         init: init,
         initTags: initTags
     };
-    
-}());
\ No newline at end of file
+
+}());

Modified: rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js?rev=1329241&r1=1329240&r2=1329241&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js (original)
+++ rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js Mon Apr 23 
13:51:02 2012
@@ -101,29 +101,29 @@ describe("Rave", function() {
                     },
                     attr: function(a, b) {
 
-                    },                    
+                    },
                     hasClass : function (className) {
                         return classMap.indexOf(className) != -1;
                     },
                     addClass : function (className) {
                         classMap.push(className);
                     },
-                    removeClass: function(className) {                        
-                        var idx = classMap.indexOf(className); 
+                    removeClass: function(className) {
+                        var idx = classMap.indexOf(className);
                         if (idx != -1) {
-                            classMap.splice(idx, 1); 
+                            classMap.splice(idx, 1);
                         }
-                    }   
+                    }
                 }
-            };            
+            };
         }
 
         it("calls the appropriate providers", function() {
-            var HIDDEN_CLASS = "hidden";            
-            createMockJQuery(); 
+            var HIDDEN_CLASS = "hidden";
+            createMockJQuery();
             $().addClass(HIDDEN_CLASS);
             expect($().hasClass(HIDDEN_CLASS)).toEqual(true);
-            
+
             var widgetsByRegionIdMap = {};
             widgetsByRegionIdMap[1] = [
                     {type:"FOO"},
@@ -137,13 +137,13 @@ describe("Rave", function() {
             rave.registerProvider(provider2);
             rave.initWidgets(widgetsByRegionIdMap);
             expect(provider1.initWidgetsWasCalled(2)).toBeTruthy();
-            expect(provider2.initWidgetsWasCalled(2)).toBeTruthy();   
+            expect(provider2.initWidgetsWasCalled(2)).toBeTruthy();
             expect($().hasClass(HIDDEN_CLASS)).toEqual(true);
         });
 
         it("renders widgets in the appropriate order (first 'row', second 
'row', third 'row', ...)", function() {
-            createMockJQuery(); 
-            
+            createMockJQuery();
+
             var widgetsByRegionIdMap = {};
             widgetsByRegionIdMap[1] = [
                     {type:"FOO", renderOrder:1},
@@ -180,8 +180,8 @@ describe("Rave", function() {
         });
 
         it("puts widgets in buckets keyed by regionIds", function() {
-            createMockJQuery(); 
-             
+            createMockJQuery();
+
             var widgetsByRegionIdMap = {};
             var regionOneKey = 1;
             var regionTwoKey = 2;
@@ -200,8 +200,8 @@ describe("Rave", function() {
         });
 
         it("Renders an error gadget when invalid widget is provided", 
function(){
-            createMockJQuery();  
-             
+            createMockJQuery();
+
             var widgetsByRegionIdMap = {};
             widgetsByRegionIdMap[1] = [
                     {type:"FOO",  regionWidgetId:20},
@@ -210,7 +210,7 @@ describe("Rave", function() {
                     {type:"BAR",  regionWidgetId:23},
                     {type:"NONE", regionWidgetId:43}
             ];
-            
+
             var provider1 = getMockProvider("FOO");
             var provider2 = getMockProvider("BAR");
             rave.registerProvider(provider1);
@@ -235,18 +235,18 @@ describe("Rave", function() {
             expect($().expression()).toEqual("#widget-20-body");
             expect($().html()).toEqual("Widget disabled");
         });
-        
+
         it("Renders the empty page message when page has no widgets", 
function(){
             var HIDDEN_CLASS = "hidden";
-            createMockJQuery();  
+            createMockJQuery();
             $().addClass(HIDDEN_CLASS);
             expect($().hasClass(HIDDEN_CLASS)).toEqual(true);
-            
+
             var widgetsByRegionIdMap = {};
-                                   
+
             rave.initWidgets(widgetsByRegionIdMap);
-            expect($().hasClass(HIDDEN_CLASS)).toEqual(false);           
-        });        
+            expect($().hasClass(HIDDEN_CLASS)).toEqual(false);
+        });
     });
 
     describe("initUI", function() {
@@ -410,7 +410,7 @@ describe("Rave", function() {
         });
 
     });
-    
+
     describe("isFunction", function() {
 
         it("returns true when the object is a function", function() {
@@ -422,35 +422,35 @@ describe("Rave", function() {
             var obj = 1;
             var result = rave.isFunction(obj);
             expect(result).toEqual(false);
-        });        
+        });
         it("returns false when the object is a string", function() {
             var obj = "hello";
             var result = rave.isFunction(obj);
             expect(result).toEqual(false);
-        }); 
+        });
         it("returns false when the object is an object", function() {
             var obj = {"myattr" : "myvalue"};
             var result = rave.isFunction(obj);
             expect(result).toEqual(false);
-        }); 
+        });
         it("returns false when the object is null", function() {
             var obj = null;
             var result = rave.isFunction(obj);
             expect(result).toEqual(false);
-        }); 
+        });
         it("returns false when the object is undefined", function() {
             var obj;
             var result = rave.isFunction(obj);
             expect(result).toEqual(false);
-        }); 
-    });        
-    
+        });
+    });
+
     describe("toggleCollapseWidgetIcon", function() {
         //Creates a simple mock jquery object that mocks the functions used in 
this suite
         function createMockJQuery() {
             var expression;
-            var classMap = [];
-            
+            var html;
+
             $ = function(expr) {
 
                 if (typeof expr != "undefined") {
@@ -461,60 +461,60 @@ describe("Rave", function() {
                     expression : function () {
                         return expression;
                     },
-                    hasClass : function (className) {
-                        return classMap.indexOf(className) != -1;
-                    },
-                    addClass : function (className) {
-                        classMap.push(className);
-                    },
-                    removeClass: function(className) {                        
-                        var idx = classMap.indexOf(className); 
-                        if (idx != -1) {
-                            classMap.splice(idx, 1); 
+                    html : function (txt) {
+                        if (typeof txt  == "string") {
+                            html = txt;
+                            return $;
+                        } else {
+                            return html;
                         }
                     }
                 }
             };
-            
+
         }
 
-        it("changes icon from normal to collapsed", function() {               
                   
+        it("changes icon from normal to collapsed", function() {
             createMockJQuery();
-            // setup the state so the widget display is "normal"           
-            $().addClass("ui-icon-triangle-1-e");
-           
+            // setup the state so the widget display is "normal"
+            $().html('<i class="icon-chevron-up"></i>');
+
             var widgetId = 99;
-           
-            rave.toggleCollapseWidgetIcon(widgetId);
-           
-            expect($().expression()).toEqual("#widget-" + widgetId + 
"-collapse");            
-            expect($().hasClass("ui-icon-triangle-1-e")).toEqual(false);
-            expect($().hasClass("ui-icon-triangle-1-s")).toEqual(true);        
                                
-        });
-        
-        it("changes icon from collapsed to normal", function() {               
                   
-            createMockJQuery();
-            // setup the state so the widget display is "normal"           
-            $().addClass("ui-icon-triangle-1-s");
-           
+            // state it is being changed to
+            var collapsed = true;
+
+            rave.toggleCollapseWidgetIcon(widgetId, collapsed);
+
+            expect($().expression()).toEqual("#widget-" + widgetId + 
"-collapse");
+            expect($().html()).toNotEqual('<i class="icon-chevron-up"></i>');
+            expect($().html()).toEqual('<i class="icon-chevron-down"></i>');
+        });
+
+        it("changes icon from collapsed to normal", function() {
+            createMockJQuery();
+            // setup the state so the widget display is "normal"
+            $().html('<i class="icon-chevron-down"></i>');
+
             var widgetId = 99;
-           
-            rave.toggleCollapseWidgetIcon(widgetId);
-           
-            expect($().expression()).toEqual("#widget-" + widgetId + 
"-collapse");            
-            expect($().hasClass("ui-icon-triangle-1-s")).toEqual(false);
-            expect($().hasClass("ui-icon-triangle-1-e")).toEqual(true);        
                                
-        });        
-       
-    });    
-    
+            // state it is being changed to
+            var collapsed = false;
+
+            rave.toggleCollapseWidgetIcon(widgetId, collapsed);
+
+            expect($().expression()).toEqual("#widget-" + widgetId + 
"-collapse");
+            expect($().html()).toNotEqual('<i class="icon-chevron-down"></i>');
+            expect($().html()).toEqual('<i class="icon-chevron-up"></i>');
+        });
+
+    });
+
     describe("change widget view state", function(){
         //Creates a simple mock jquery object that mocks the functions used in 
this suite
         function createMockJQuery() {
             var expression;
-            var classMap = [];                        
+            var classMap = [];
             var valuesMap = {};
-            
+
             $ = function(expr) {
 
                 if (typeof expr != "undefined") {
@@ -531,10 +531,10 @@ describe("Rave", function() {
                     addClass : function (className) {
                         classMap.push(className);
                     },
-                    removeClass: function(className) {                        
-                        var idx = classMap.indexOf(className); 
+                    removeClass: function(className) {
+                        var idx = classMap.indexOf(className);
                         if (idx != -1) {
-                            classMap.splice(idx, 1); 
+                            classMap.splice(idx, 1);
                         }
                         return this;
                     },
@@ -557,99 +557,99 @@ describe("Rave", function() {
                     },
                     show: function() {
                         valuesMap["showWasCalled-" + expression] = true;
-                    },                    
+                    },
                     height: function() {
-                        
+
                     },
                     width: function() {
-                        
+
                     },
                     css: function() {
-                        
+
                     },
                     prepend: function() {
-                        
+
                     },
                     remove: function() {
                         valuesMap["removeWasCalled"] = true;
                     },
                     getValue: function(varName) {
                         return valuesMap[varName];
-                    }                    
+                    }
                 }
-            };            
+            };
         }
-        
-        it("successfully maximizes the widget", function() {                   
               
+
+        it("successfully maximizes the widget", function() {
             createMockJQuery();
-            
-            var mockWidget = {   
-                maximizeWasCalled: false,                
+
+            var mockWidget = {
+                maximizeWasCalled: false,
                 maximize: function() { this.maximizeWasCalled = true; }
             }
-                                      
+
             var args = {};
             args.data = {};
             args.data.id = 99;
             spyOn(rave, "getRegionWidgetById").andReturn(mockWidget);
-            
-            rave.maximizeWidget(args);                      
-           
-            // verify the sortable parameters                        
+
+            rave.maximizeWidget(args);
+
+            // verify the sortable parameters
             expect($().getValue("sortableOption")).toEqual("option");
             expect($().getValue("sortableAttrName")).toEqual("disabled");
-            expect($().getValue("sortableAttrValue")).toEqual(true);           
 
+            expect($().getValue("sortableAttrValue")).toEqual(true);
             // verify the CSS styles
             expect($().hasClass("widget-wrapper-canvas")).toEqual(true);
-            expect($().hasClass("widget-wrapper")).toEqual(false);           
+            expect($().hasClass("widget-wrapper")).toEqual(false);
             // verify widget menu hide was called
-            expect($().getValue("hideWasCalled-#widget-" + args.data.id + 
"-widget-menu-wrapper")).toEqual(true);  
+            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);        
+            expect($().getValue("showWasCalled-#widget-" + args.data.id + 
"-min")).toEqual(true);
             // verify getRegionWidgetById called
-            
expect(rave.getRegionWidgetById).toHaveBeenCalledWith(args.data.id); 
+            
expect(rave.getRegionWidgetById).toHaveBeenCalledWith(args.data.id);
             // verify collapse/restore icon hide was called
-            expect($().getValue("hideWasCalled-#widget-" + args.data.id + 
"-collapse")).toEqual(true);                 
+            expect($().getValue("hideWasCalled-#widget-" + args.data.id + 
"-collapse")).toEqual(true);
             // verify widget.maximize was called
             expect(mockWidget.maximizeWasCalled).toEqual(true);
-                   
-        });        
-        
-        it("successfully minimizes the widget", function() {                   
               
-            createMockJQuery();
-            
-            var mockWidget = {   
-                minimizeWasCalled: false,                
+
+        });
+
+        it("successfully minimizes the widget", function() {
+            createMockJQuery();
+
+            var mockWidget = {
+                minimizeWasCalled: false,
                 minimize: function() { this.minimizeWasCalled = true; }
             }
-                                      
+
             var args = {};
             args.data = {};
             args.data.id = 99;
             spyOn(rave, "getRegionWidgetById").andReturn(mockWidget);
-            
-            rave.minimizeWidget(args);                      
-            
+
+            rave.minimizeWidget(args);
+
             // verify remove was called
-            expect($().getValue("removeWasCalled")).toEqual(true);        
+            expect($().getValue("removeWasCalled")).toEqual(true);
             // verify the sortable parameters
             expect($().getValue("sortableOption")).toEqual("option");
             expect($().getValue("sortableAttrName")).toEqual("disabled");
-            expect($().getValue("sortableAttrValue")).toEqual(false);          
  
+            expect($().getValue("sortableAttrValue")).toEqual(false);
             // verify the CSS styles
             expect($().hasClass("widget-wrapper-canvas")).toEqual(false);
             expect($().hasClass("widget-wrapper")).toEqual(true);
             // verify widget minimize hide was called
-            expect($().getValue("hideWasCalled-#widget-" + args.data.id + 
"-min")).toEqual(true);                            
+            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);                                  
+            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);                 
+            expect($().getValue("showWasCalled-#widget-" + args.data.id + 
"-collapse")).toEqual(true);
             // verify getRegionWidgetById called
-            
expect(rave.getRegionWidgetById).toHaveBeenCalledWith(args.data.id);            
       
+            
expect(rave.getRegionWidgetById).toHaveBeenCalledWith(args.data.id);
             // verify widget.minimize was called
-            expect(mockWidget.minimizeWasCalled).toEqual(true);             
-        });                    
+            expect(mockWidget.minimizeWasCalled).toEqual(true);
+        });
     });
 
     describe("log", function(){
@@ -728,4 +728,4 @@ describe("Rave", function() {
             expect(args.onPublish).toBeDefined();
         });
     });
-});
\ No newline at end of file
+});

Modified: 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/gadgets/oauth/inject/DefaultOAuthStoreTest.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/gadgets/oauth/inject/DefaultOAuthStoreTest.java?rev=1329241&r1=1329240&r2=1329241&view=diff
==============================================================================
--- 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/gadgets/oauth/inject/DefaultOAuthStoreTest.java
 (original)
+++ 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/gadgets/oauth/inject/DefaultOAuthStoreTest.java
 Mon Apr 23 13:51:02 2012
@@ -36,13 +36,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.springframework.test.util.ReflectionTestUtils;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
 
 /**
  * Test for {@link DefaultOAuthStore}


Reply via email to