From feb17b8acf6a7aeb449e32b84e9b87b7552e41be Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Thu, 16 Apr 2009 05:18:45 +0000 Subject: [PATCH] Improved Edit Survey section list. Removed unnecessary
's from Section list Made sections panel resizable Made current selection highlighted via CSS --- lib/WebGUI/Asset/Wobject/Survey.pm | 6 +-- www/extras/wobject/Survey/editsurvey.js | 52 ++++++++++++------- www/extras/wobject/Survey/surveyedit.css | 64 +++++++----------------- 3 files changed, 54 insertions(+), 68 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index b96076949..c03ef3595 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -800,7 +800,7 @@ sub www_loadSurvey { elsif ( $lastType eq 'question' ) { $q = 1; } - $html .= "
  • S" . ( $scount + 1 ) . ": $_->{text}<\/li>
    \n"; + $html .= "
  • S" . ( $scount + 1 ) . ": $_->{text}<\/li>\n"; push( @ids, $scount ); } elsif ( $_->{type} eq 'question' ) { @@ -808,7 +808,7 @@ sub www_loadSurvey { if ( $lastType eq 'answer' ) { $a = 1; } - $html .= "
  • Q" . ( $qcount + 1 ) . ": $_->{text}<\/li>
    \n"; + $html .= "
  • Q" . ( $qcount + 1 ) . ": $_->{text}<\/li>\n"; push @ids, "$scount-$qcount"; $lastType = 'question'; $acount = -1; @@ -818,7 +818,7 @@ sub www_loadSurvey { $html .= "
  • A" . ( $acount + 1 ) - . ": $_->{text}<\/li>
    \n"; + . ": $_->{text}<\/li>\n"; push @ids, "$scount-$qcount-$acount"; $lastType = 'answer'; } diff --git a/www/extras/wobject/Survey/editsurvey.js b/www/extras/wobject/Survey/editsurvey.js index 4425d5d59..53810357a 100644 --- a/www/extras/wobject/Survey/editsurvey.js +++ b/www/extras/wobject/Survey/editsurvey.js @@ -75,29 +75,38 @@ Survey.Data = (function(){ else { lastId = d.address; } - + // First purge any event handlers bound to sections node.. - YAHOO.util.Event.purgeElement('sections', true); + YAHOO.util.Event.purgeElement('sections', true); - // Now we can re-write its innerHTML without fear of memory leaks -// document.getElementById('sections').innerHTML = d.ddhtml; - - if(! Survey.Data.ddContainer){ - Survey.Data.ddContainer = - new YAHOO.widget.Panel("sections", - { width:"440px", - height: "420px", - draggable:true, - visible:true + if (!Survey.Data.ddContainer) { + Survey.Data.ddContainer = new YAHOO.widget.Panel("sections", { + width: "400px", + height: "600px", + draggable: true, + visible: true, + bodyStyle: { 'margin-right' : '5px' } + }); - } - ); + Survey.Data.ddContainer.setHeader("Survey Objects..."); + Survey.Data.ddContainer.setBody(d.ddhtml); + Survey.Data.ddContainer.setFooter(document.getElementById("buttons")); + Survey.Data.ddContainer.render();//document.body); } - Survey.Data.ddContainer.setHeader("Survey Objects..."); - Survey.Data.ddContainer.setBody(d.ddhtml); - Survey.Data.ddContainer.setFooter(document.getElementById("buttons")); - Survey.Data.ddContainer.render();//document.body); - + else { + Survey.Data.ddContainer.setBody(d.ddhtml); + Survey.Data.ddContainer.setFooter(document.getElementById("buttons")); + } + + // (re)Add resize handler + Survey.Data.ddContainerResize && Survey.Data.ddContainerResize.destroy(); + Survey.Data.ddContainerResize = new YAHOO.util.Resize('sections', { + proxy: true + }); + Survey.Data.ddContainerResize.on('resize', function(args){ + Survey.Data.ddContainer.cfg.setProperty("height", args.height + "px"); + }); + //add event handlers for if a tag is clicked for (var x in d.ids) { if (YAHOO.lang.hasOwnProperty(d.ids, x)) { @@ -106,6 +115,11 @@ Survey.Data = (function(){ var _s = new Survey.DDList(d.ids[x], "sections"); } } + var selectedId = focus.join('-'); + selectedId = selectedId === 'undefined' ? "0" : selectedId; + if (document.getElementById(selectedId)) { + YAHOO.util.Dom.addClass(selectedId, 'selected'); + } sButton && sButton.destroy(); sButton = new YAHOO.widget.Button({ diff --git a/www/extras/wobject/Survey/surveyedit.css b/www/extras/wobject/Survey/surveyedit.css index 1740e13a4..c4732d957 100644 --- a/www/extras/wobject/Survey/surveyedit.css +++ b/www/extras/wobject/Survey/surveyedit.css @@ -109,64 +109,30 @@ li.section { cursor: move; min-height: 10px; } - li.ssection { - background-color: #E76300; + border:1px solid #7EA6B2; cursor: move; min-height: 10px; } - -li.squestion { - background-color: #CC6600; - border:1px solid #7EA6B2; - cursor: move; - padding-left:15px; - width: 80%; - min-height: 10px; -} -li.newQuestion { -/* - background-color: #D1E6EC; - border:1px solid #7EA6B2; - cursor: move; -*/ - padding-left:25px; -} - li.question { background-color: #D1E6EC; border:1px solid #7EA6B2; cursor: move; - padding-left:15px; - width:80%; + padding-left:10px; min-height: 10px; } +li.answer { + background-color: #F1FFB8; + border:1px solid #7EA6B2; + cursor: move; + padding-left:15px; + min-height: 10px; +} +#sections li.selected { + background: #68FFBC url(/extras/versionDotOn.gif) no-repeat scroll 99% center; +} -li.answer { - background-color: #D1E6EC; - border:1px solid #7EA6B2; - cursor: move; - padding-left:50px; - width:60%; - min-height: 10px; -} -li.sanswer { - background-color: #CC6600; - border:1px solid #7EA6B2; - cursor: move; - padding-left:50px; - width:60%; - min-height: 10px; -} -li.newAnswer { -/* - background-color: #D1E6EC; - border:1px solid #7EA6B2; - cursor: move; -*/ - padding-left:50px; -} #goto-yui-ac { width:15em; margin-top:0.5em; @@ -181,3 +147,9 @@ li.newAnswer { #warnings { color: red; } +#sections_c .yui-resize .yui-resize-handle-r { + right: -6px; +} +#sections_c .yui-resize .yui-resize-handle-b { + bottom: -6px; +} \ No newline at end of file