From 77fc16d97fec7b47f9b8784d40e943588b4d966c Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Tue, 6 May 2008 14:56:29 +0000 Subject: [PATCH] Major updates to spec --- www/extras/wobject/Survey/administersurvey.js | 164 ++++++++++-------- www/extras/wobject/Survey/bg-fader-500.gif | Bin 0 -> 1197 bytes .../wobject/Survey/editsurvey/answer.js | 4 +- .../wobject/Survey/editsurvey/question.js | 6 +- .../wobject/Survey/editsurvey/section.js | 5 +- www/extras/wobject/Survey/survey.css | 40 ++++- 6 files changed, 137 insertions(+), 82 deletions(-) create mode 100644 www/extras/wobject/Survey/bg-fader-500.gif diff --git a/www/extras/wobject/Survey/administersurvey.js b/www/extras/wobject/Survey/administersurvey.js index e0ca610d9..44970bb72 100644 --- a/www/extras/wobject/Survey/administersurvey.js +++ b/www/extras/wobject/Survey/administersurvey.js @@ -4,9 +4,9 @@ if (typeof Survey == "undefined") { Survey.Form = new function() { - var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Ideology':1, 'Race':1,'Party':1,'Education':1}; - var scale = {'Scale':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1, - 'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1}; + var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Ideology':1, 'Race':1,'Party':1,'Education':1 + ,'Scale':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1, + 'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1}; var text = {'Text':1, 'Email':1, 'Phone Number':1, 'Text Date':1, 'Currency':1}; var slider = {'Slider':1, 'Dual Slider - Range':1, 'Multi Slider - Allocate':1}; var dateType = {'Date':1,'Date Range':1}; @@ -19,18 +19,24 @@ Survey.Form = new function() { var toValidate; + var sliderWidth = 500; + + var sliders; + + this.displayQuestions = function(params){ toValidate = new Array();//clear array var qs = params.questions; var s = params.section; + sliders = new Array(); //What to show and where document.getElementById('survey').innerHTML = params.html; -var te = document.createElement('span'); -te.innerHTML = ""; -document.getElementById('survey').appendChild(te); -YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer('','loadQuestions');}); +//var te = document.createElement('span'); +//te.innerHTML = ""; +//document.getElementById('survey').appendChild(te); +//YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer('','loadQuestions');}); if(qs[0] != undefined){ if(lastSection != s.Survey_sectionId || s.everyPageTitle > 0){ @@ -86,35 +92,31 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer //Check if this question should be validated if(q.required == 1){ toValidate[q.Survey_questionId] = new Array(); + toValidate[q.Survey_questionId]['type'] = q.questionType; + toValidate[q.Survey_questionId]['answers'] = new Array(); } - if(multipleChoice[q.questionType] || scale[q.questionType]){ + if(multipleChoice[q.questionType]){ var butts = new Array(); verb = 0; for(var x = 0; x < q.answers.length; x++){ - var a = q.answers[x]; if(toValidate[a.Survey_questionId]){ - toValidate[a.Survey_questionId][a.Survey_answerId] = 1; + toValidate[a.Survey_questionId]['answers'][a.Survey_answerId] = 1; } - var b; - if(scale[q.questionType]){ - b = new YAHOO.widget.Button({ type: "checkbox", label: a.recordedAnswer, id: a.Survey_answerId+'button', name: a.Survey_answerId+'button', - value: a.Survey_answerId, - container: a.Survey_answerId+"container", checked: false }); - b.label=a.recordedAnswer; - }else{ - // b = new YAHOO.widget.Button({ type: "checkbox", id: a.Survey_answerId+'button', name: a.Survey_answerId+'button', + var b = document.getElementById(a.Survey_answerId+'button'); + /* b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.Survey_answerId+'button', name: a.Survey_answerId+'button', - value: a.Survey_answerId, - container: a.Survey_answerId+"container", checked: false }); - } - //b.set('label',a.answerText); - b.on("click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts,qs.length,a.Survey_answerId]); + value: a.Survey_answerId, + container: a.Survey_answerId+"container", checked: false }); + */ +// b.on("click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts,qs.length,a.Survey_answerId]); +// YAHOO.util.Event.addListener(a.Survey_answerId+'button', "click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts,qs.length,a.Survey_answerId]); if(a.verbatim == 1){ verb = 1; } + YAHOO.util.Event.addListener(a.Survey_answerId+'button', "click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts,qs.length,a.Survey_answerId]); b.hid = a.Survey_answerId; butts.push(b); } @@ -123,7 +125,7 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer for(var x = 0; x < q.answers.length; x++){ var a = q.answers[x]; if(toValidate[a.Survey_questionId]){ - toValidate[a.Survey_questionId][a.Survey_answerId] = 1; + toValidate[a.Survey_questionId]['answers'][a.Survey_answerId] = 1; } var calid = a.Survey_answerId+'container'; var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true}); @@ -142,24 +144,34 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer }else{ for(var s in q.answers){ var a = q.answers[s]; + YAHOO.util.Event.addListener(a.Survey_answerId, "blur", this.sliderTextSet); if(a.max - a.min > max){max = a.max - a.min;} } } if(q.questionType == 'Multi Slider - Allocate'){ //sliderManagers[sliderManagers.length] = new this.sliderManager(q,max); + for(var x = 0; x < q.answers.length; x++){ + var a = q.answers[x]; + if(toValidate[a.Survey_questionId]){ + toValidate[a.Survey_questionId]['total'] = a.max; + toValidate[a.Survey_questionId]['answers'][a.Survey_answerId] = 1; + } + } new this.sliderManager(q,max); } else if(q.questionType == 'Slider'){ new this.sliders(q); } } + else if(fileUpload[q.questionType]){ hasFile = true; } + else if(text[q.questionType]){ var a = q.answers[x]; if(toValidate[a.Survey_questionId]){ - toValidate[a.Survey_questionId][a.Survey_answerId] = 1; + toValidate[a.Survey_questionId]['answers'][a.Survey_answerId] = 1; } } } @@ -171,11 +183,23 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer var submit = 1;//boolean for if all was good or not for(var i in toValidate){ var answered = 0; - for(var z in toValidate[i]){ - var v = document.getElementById(z).value; - if(v != '' && v != undefined){ - answered = 1; - break; + if(toValidate[i]['type'] == 'Multi Slider - Allocate'){ + var total = 0; + for(var z in toValidate[i]['answers']){ + total += Math.round(document.getElementById(z).value); + } +console.log(total+" and "+ toValidate[i]['total']); + if(total == toValidate[i]['total']){answered = 1;} + }else{ + for(var z in toValidate[i]['answers']){ + var v = document.getElementById(z).value; + if(v != '' && v != undefined){ + answered = 1; + break; + } + else{ + console.log(z+' was not answered'); + } } } if(answered == 0){ @@ -194,11 +218,11 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer this.dualSliders = function(q){ - var total = 200; - var sliders = new Array(); + var total = sliderWidth; +// var sliders = new Array(); var a1 = q.answers[0]; var a2 = q.answers[1]; - var scale = 200/a1.max; + var scale = sliderWidth/a1.max; var id = q.Survey_questionId; var a1id = a1.Survey_answerId; @@ -210,7 +234,8 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer var a2s = document.getElementById(a2id+'show'); var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg', a1id+"slider-min-thumb", a2id+"slider-max-thumb", - 200, 1*scale, [1,200]); + sliderWidth, 1*scale, [1,sliderWidth]); + sliders[id] = s; s.minRange = 4; var updateUI = function () { @@ -228,40 +253,37 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer s.subscribe('change', updateUI); } this.sliders = function(q){ - var total = 200; + var total = sliderWidth; for(var i in q.answers){ var a = q.answers[i]; var step = q.answers[i].step; - var scale = 200/q.answers[i].max; + var scale = sliderWidth/q.answers[i].max; var Event = YAHOO.util.Event; var lang = YAHOO.lang; var id = a.Survey_answerId; var s = YAHOO.widget.Slider.getHorizSlider(id+'slider-bg', id+'slider-thumb', - 0, 200, (scale*step)); - // 0, 200, 1); + 0, sliderWidth, (scale*step)); + s.scale = scale; + sliders[id] = s; s.max = a.max*scale; s.input = a.Survey_answerId; s.scale = scale; document.getElementById(id).value = a.min; var check = function() { var t = document.getElementById(this.input); - var tshow = document.getElementById(this.input+'show'); t.value = this.getRealValue(); - tshow.innerHTML = this.getRealValue(); }; s.getRealValue = function() { return this.getValue() / this.scale; } s.subscribe("slideEnd", check); - s.subscribe("change", check); } } //an object which creates sliders for allocation type questions and then manages their events and keeps them from overallocating this.sliderManager = function(q,t){ - var total = 200; + var total = sliderWidth; var step = q.answers[0].step; - var scale = 200/q.answers[0].max; - var sliders = new Array(); + var scale = sliderWidth/q.answers[0].max; for(var i in q.answers){ var a = q.answers[i]; @@ -269,9 +291,10 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer var lang = YAHOO.lang; var id = a.Survey_answerId+'slider-bg'; var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb', - 0, 200, scale*step); - s.input = a.Survey_answerId; - s.lastValue = 0; + 0, sliderWidth, scale*step); + sliders[a.Survey_answerId] = s; + s.input = a.Survey_answerId; + s.lastValue = 0; var check = function() { var t = 0; for(var x in sliders){ @@ -280,14 +303,12 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer if(t > total){ t -= this.getValue(); t = Math.round(t); - this.setValue(total-t + scale*step); + this.setValue(total-t);// + (scale*step)); }else{ this.lastValue = this.getValue(); document.getElementById(this.input).value = this.getRealValue(); - document.getElementById(this.input+'show').innerHTML = this.getRealValue(); } }; - s.subscribe("slideEnd", check); s.subscribe("change", check); var manualEntry = function(e){ // set the value when the 'return' key is detected @@ -304,14 +325,12 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer } } } - Event.on(document.getElementById(s.input), "keydown", manualEntry); Event.on(document.getElementById(s.input), "blur", manualEntry); s.getRealValue = function() { return Math.round(parseInt(this.getValue()) / scale); } - sliders.push(s); document.getElementById(s.input).value = s.getRealValue(); } } @@ -331,6 +350,11 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer objs[0].show(); } + this.sliderTextSet = function(event,objs){ + this.value = this.value * 1; + if(this.value == 'NaN'){this.value = 0;} + sliders[this.id].setValue(Math.round(this.value * sliders[this.id].scale)); + } this.buttonChanged = function(event,objs){ var b = objs[0]; @@ -341,32 +365,36 @@ YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer var aid = objs[5]; max = parseInt(max); if(maxA == 1){ + if(b.getAttribute('class') == 'mcbutton-selected'){ + document.getElementById(b.hid).value = 0; + b.setAttribute('class','mcbutton'); + }else{ + document.getElementById(b.hid).value = 1; + b.setAttribute('class','mcbutton-selected'); + } for(var i in butts){ if(butts[i] != b){ - butts[i].set('checked',false); + butts[i].setAttribute('class','mcbutton'); document.getElementById(butts[i].hid).value = ''; } } - if(b.get('checked') == true){ - document.getElementById(b.hid).value = 1; - }else{ - document.getElementById(b.hid).value = ''; - } } - else if(b.get('checked')){ + else if(b.getAttribute('class') == 'mcbutton'){ var max = parseInt(document.getElementById(qid+'max').innerHTML); - if(max == 0){ - b.set('checked',false); - //warn that options used up - } - else{ - document.getElementById(qid+'max').innerHTML = parseInt(max-1); - document.getElementById(b.hid).value = ''; - } + if(max == 0){ + b.setAttribute('class','mcbutton'); + //warn that options used up + } + else{ + b.setAttribute('class','mcbutton-selected'); + document.getElementById(qid+'max').innerHTML = parseInt(max-1); + document.getElementById(b.hid).value = 1; + } }else{ + b.setAttribute('class','mcbutton'); var max = parseInt(document.getElementById(qid+'max').innerHTML); document.getElementById(qid+'max').innerHTML = parseInt(max+1); - document.getElementById(b.hid).value = 1; + document.getElementById(b.hid).value = ''; } if(qsize == 1){ if(! document.getElementById(aid+'verbatim')){ diff --git a/www/extras/wobject/Survey/bg-fader-500.gif b/www/extras/wobject/Survey/bg-fader-500.gif new file mode 100644 index 0000000000000000000000000000000000000000..d8072b855e8823c837de667cfd57c52b7705364d GIT binary patch liter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$S1G-^2|5y{PWO9Fa7k?S8x6G*k`Z(_S|>x L{rBLX5CH%?;B%7l literal 0 HcmV?d00001 diff --git a/www/extras/wobject/Survey/editsurvey/answer.js b/www/extras/wobject/Survey/editsurvey/answer.js index 857a73835..f9fdabac7 100644 --- a/www/extras/wobject/Survey/editsurvey/answer.js +++ b/www/extras/wobject/Survey/editsurvey/answer.js @@ -23,7 +23,7 @@ Survey.AnswerTemplate = new function(){ "; html = html + "

Answer Text:\n\n"; html = html + "

Recorded Answer\n\n"; - html = html + "

Jump to Question:"; + html = html + "

Jump to:"; html = html + "

Text Answer Cols: Rows: \

"; html = html + "

Is this the correct answer:\n" + @@ -41,7 +41,7 @@ Survey.AnswerTemplate = new function(){ } var form = new YAHOO.widget.Dialog("answer", - { width : "300px", + { width : "500px", fixedcenter : true, visible : false, constraintoviewport : true, diff --git a/www/extras/wobject/Survey/editsurvey/question.js b/www/extras/wobject/Survey/editsurvey/question.js index e47a7d408..214c4b28b 100644 --- a/www/extras/wobject/Survey/editsurvey/question.js +++ b/www/extras/wobject/Survey/editsurvey/question.js @@ -27,7 +27,7 @@ Survey.QuestionTemplate = new function(){ else{ html = html + "\n"; } - html = html + "

Question custom variable name:

"; + html = html + "

Question variable name:

"; html = html + "

Randomize answers:"; html = html+ this.makeRadio('randomizeAnswers',[{text:'Yes',value:1},{text:'No',value:0}],params.randomizeAnswers); @@ -48,6 +48,8 @@ Survey.QuestionTemplate = new function(){

Vertical display:"; html = html+ this.makeRadio('verticalDisplay',[{text:'Yes',value:1},{text:'No',value:0}],params.verticalDisplay); + html = html + "

Show text in button:"; + html = html + this.makeRadio('textInButton',[{text:'Yes',value:1},{text:'No',value:0}],params.textInButton); html = html + "

Allow comment:"; html = html + this.makeRadio('allowComment',[{text:'Yes',value:1},{text:'No',value:0}],params.allowComment); html = html + "

   Cols: Rows: \ @@ -70,7 +72,7 @@ Survey.QuestionTemplate = new function(){ } var form = new YAHOO.widget.Dialog("question", - { width : "315px", + { width : "500px", fixedcenter : true, visible : false, constraintoviewport : true, diff --git a/www/extras/wobject/Survey/editsurvey/section.js b/www/extras/wobject/Survey/editsurvey/section.js index 11d00b05b..e2dee5a8e 100644 --- a/www/extras/wobject/Survey/editsurvey/section.js +++ b/www/extras/wobject/Survey/editsurvey/section.js @@ -12,7 +12,7 @@ Survey.SectionTemplate = new function(){ var html = "\

\ -
Please enter section formation
\ +
Please enter section information
\
\
\

Section Number: "+params.sequenceNumber + "\ @@ -30,6 +30,7 @@ Survey.SectionTemplate = new function(){ No"; } html = html + "

Section custom variable name:

"; + html = html + "

Section branch goto variable name:

"; html = html + "\

Question per Page:\ \ +

Section Text:

\ "; html = html + "

Title on every page: " + this.makeRadio('everyPageTitle',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageTitle); html = html + "

Text on every page: " + this.makeRadio('everyPageText',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageText); diff --git a/www/extras/wobject/Survey/survey.css b/www/extras/wobject/Survey/survey.css index 9f326db1c..24f4927a1 100644 --- a/www/extras/wobject/Survey/survey.css +++ b/www/extras/wobject/Survey/survey.css @@ -3,14 +3,15 @@ div.dateanswer { } div.slider-bg { position: relative; - background:url(/extras/wobject/Survey/bg-fader.gif) 5px 0 no-repeat; - height:28px; - width:228px; + background:url(/extras/wobject/Survey/bg-fader-500.gif) 5px 0 no-repeat; + height:68px; + width:529px; } div.slider-thumb { cursor:default; position: absolute; - top: 4px; + top: 30px; + left: 4px; } div.slider-min-thumb { cursor:default; @@ -31,10 +32,33 @@ div.slider-max-thumb { #questions { display: none; } -.yui-button{ +input.mcbutton{ + font-size: 10px; + font-weight: bold; + text-decoration: none; + background-color: #CCCCCC; + background-repeat: repeat-x; text-align: center; + display: block; + margin: 0.5em; + padding: .8em; + width: 60px; + font-family: Verdana, Arial, Helvetica, sans-serif; + color: #000000; + background-image: url(/extras/wobject/Survey/gradient-glossy.png); } -.yui-button button{ - text-align: center; - min-width: 100px; +input.mcbutton:hover{ + background-color: #B6D2F1; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #000000; +} +input.mcbutton-selected{ + background-color: #172D9D; + color: #FFFFFF; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + font-weight: bold; + background-image: url(/extras/wobject/Survey/gradient-glossy.png); + background-position: 0px 0px; }