-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I cleaned it up a bit already, but let me look at the init. There is still a bug associated with deleting gadgets that have been moved.
Marlon On 6/6/11 1:36 PM, Franklin, Matthew B. wrote: > On 6/6/11 1:10 PM, "[email protected]" <[email protected]> wrote: > >> Author: mpierce >> Date: Mon Jun 6 17:10:32 2011 >> New Revision: 1132706 >> >> URL: http://svn.apache.org/viewvc?rev=1132706&view=rev >> Log: >> Reorganizing the widget deletion code (RAVE-41) so that most of the >> action takes place in rave.js rather than home.jsp. Probably this needs >> a better design pattern applied to it. > > Thanks for taking that on. I haven't had a ton of time to look over the > delete code yet, but from what I have seen, it looks like there should be > no reason that we can't do what is left in the home.jsp in the ui.init > function of rave.js (init the buttons for all widgets with one > expression). This would allow us to move the script includes for jquery, > etc back to the bottom of the page, which is where we really want them. > > I can go ahead and make this change unless Marlon or others who have been > working on it want to give it a go. > > -Matt > >> >> >> Modified: >> >> incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp >> incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js >> >> Modified: >> incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp >> URL: >> http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/web >> app/WEB-INF/views/home.jsp?rev=1132706&r1=1132705&r2=1132706&view=diff >> ========================================================================== >> ==== >> --- >> incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp >> (original) >> +++ >> incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp >> Mon Jun 6 17:10:32 2011 >> @@ -64,41 +64,35 @@ >> <div class="widget-title-bar" > >> <span >> id="widget-${regionWidget.id}-title">${regionWidget.widget.title}</span> >> >> - <span id="widget-${regionWidget.id}-toolbar" >> style="float:right;"> >> - <button id="widget-${regionWidget.id}-max" >> class="widget-toolbar-btn"></button> >> - <button >> id="widget-${regionWidget.id}-remove" >> class="widget-toolbar-btn"></button> >> - <script> >> - $("#widget-${regionWidget.id}-max").button({ >> - text: false, >> - icons: { >> - primary: "ui-icon-arrow-4-diag" >> - } >> - }).click(function() { >> - alert("not implemented yet."); >> - }); >> - >> $("#widget-${regionWidget.id}-remove").button({ >> - text: false, >> - icons: { >> - primary: "ui-icon-close" >> - } >> - }).unbind("click").click(function() >> { >> - alert("remove gadget"); >> - rave.api.rpc.removeWidget({ >> - regionWidgetId: >> "${regionWidget.id}", >> - pageId: "${defaultPage.id}", >> - region: { >> - id : >> rave.getGadgetRegion("${regionWidget.id}") >> - }, >> - succCB: function() { >> - >> $("#widget-wrapper-${regionWidget.id}").remove(); >> - } >> - }); >> - }); >> - >> rave.mapGadgetToRegion("${regionWidget.id}", "${region.id}"); >> - </script> >> - </span> >> - >> - </div> >> + <!-- These are toolbar buttons --> >> + <span id="widget-${regionWidget.id}-toolbar" >> style="float:right;"> >> + <button id="widget-${regionWidget.id}-max" >> + >> class="widget-toolbar-btn" >> + >> onclick="rave.toolbarMaximize(this)"></button> >> + <button id="widget-${regionWidget.id}-remove" >> + >> class="widget-toolbar-btn" >> + >> onclick="rave.toolbarDelete(this,${regionWidget.id},${region.id},${default >> Page.id})"> >> + </button> >> + <script> >> + //This decorates the toolbar buttons. >> As currently written, >> + //it needs to be in the forEach loop. >> + >> $("#widget-${regionWidget.id}-max").button({ >> + text: false, >> + icons: { >> + primary: "ui-icon-arrow-4-diag" >> + } >> + }); >> + >> + >> $("#widget-${regionWidget.id}-remove").button({ >> + text: false, >> + icons: { >> + primary: "ui-icon-close" >> + } >> + }); >> + </script> >> + >> + </span> >> + </div> >> <div class="widget" id="widget-${regionWidget.id}-body"> >> <!-- >> Among other things, the render-widget >> tag will populate the >> widgets[] array. >> >> Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js >> URL: >> http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/web >> app/script/rave.js?rev=1132706&r1=1132705&r2=1132706&view=diff >> ========================================================================== >> ==== >> --- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js >> (original) >> +++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js Mon >> Jun 6 17:10:32 2011 >> @@ -105,6 +105,36 @@ var rave = rave || (function() { >> >> })(); >> >> + /** >> + * Group widget toolbar functions >> + */ >> + var toolbar = (function() { >> + function init(){ >> + } >> + function maximizeAction(button){ >> + alert("Maximize: "+button.id+" not yet >> implemented."); >> + >> + }; >> + function >> deleteAction(button,myRegionWidgetId,myRegionId,myPageId){ >> +// alert("Delete:"+button.id+" >> "+myRegionWidgetId+" "+myRegionId+" >> "+myPageId); >> + rave.api.rpc.removeWidget({ >> + regionWidgetId: myRegionWidgetId, >> + pageId : myPageId, >> + region: { >> + id : myRegionId >> + }, >> + succCB: function() { >> + >> $("#widget-wrapper-"+myRegionWidgetId).remove(); >> + } >> + }); >> + rave.mapGadgetToRegion(myRegionWidgetId, >> myRegionId); >> + }; >> + return { >> + maximizeAction : maximizeAction, >> + deleteAction : deleteAction >> + } >> + })(); >> + >> function initializeProviders() { >> //Current providers are rave.wookie and rave.opensocial. >> //Providers register themselves when loaded, so >> @@ -161,14 +191,6 @@ var rave = rave || (function() { >> } >> >> /** >> - * Deletes the gadget/widget from the display. >> - * TODO: must be implemented. >> - */ >> - function deleteWidgetFromPage() { >> - return null; >> - } >> - >> - /** >> * Map a widget to the region where it is located. >> * >> * @param widgetId: id of the widget (not DOM id) >> @@ -248,10 +270,6 @@ var rave = rave || (function() { >> */ >> getContext: getContext, >> >> - /** >> - * Remove a selected gadget from the page >> - */ >> - deleteGadget : deleteWidgetFromPage, >> >> /** >> * Change or delete gadget to region map entry. >> @@ -261,6 +279,12 @@ var rave = rave || (function() { >> /** >> * Get the region where a widget/gadget belongs to. >> */ >> - getGadgetRegion : getGadgetRegion >> + getGadgetRegion : getGadgetRegion, >> + >> + /** >> + * These are exposed toolbar actions, associated with >> widget toolbar >> buttons >> + */ >> + toolbarMaximize : toolbar.maximizeAction, >> + toolbarDelete : toolbar.deleteAction >> } >> })(); >> \ No newline at end of file >> >> > -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJN7RGsAAoJEEfVXEODPFIDMhUH/3W4Z268Gp83016hxXuiimhg y0ok5VDfb3Ra/G0HzlAbdMnamE4izKN0EQYWkFGFHGLphVA8s5xJ50cDdAa03HB6 BT/ppftWvzZGH6IkzA9Fx0J2H0PEGlWBoJaomQPzuuOXAQGrtDZAW1qK7F6HSXx5 c6wcJCNbpnty8kvg5eZGG7QSY25BSud8aHwaxyBDYrKZ24cSkmQYTrZT/NcNu+8k DaHjjD71SNM16hC66LIiSRFUQx9y1g2u5NLpxdIIyNeoFo2eGDpBzIbK84qRbaOP IC5+O83lmQD0NAaIbF5HyckcRrIHwusB+q5ZNZcdus6KOUTjNBOinCRaBXz3eLk= =yQ7p -----END PGP SIGNATURE-----
