adding survey back in

This commit is contained in:
Graham Knop 2008-11-12 03:24:49 +00:00
parent 2d8b43f7c9
commit 48b4ba1fc8
24 changed files with 3463 additions and 2626 deletions

View file

@ -0,0 +1,453 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
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
,'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};
var fileUpload = {'File Upload':1};
var hidden = {'Hidden':1};
var hasFile;
var verb = 0;
var lastSection = 'first';
var toValidate;
var sliderWidth = 500;
var sliders;
// this.submittimer;
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 = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
//document.getElementById('survey').appendChild(te);
//YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer('','loadQuestions');});
if(qs[0] != undefined){
if(lastSection != s.id|| s.everyPageTitle > 0){
document.getElementById('headertitle').style.display='block';
}
if(lastSection != s.id|| s.everyPageText > 0){
document.getElementById('headertext').style.display = 'block';
}
if(lastSection != s.id && s.questionsOnSectionPage != '1'){
var span = document.createElement("div");
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
span.style.display = 'block';
document.getElementById('header').appendChild(span);
YAHOO.util.Event.addListener("showQuestionsButton", "click",
function(){
document.getElementById('showQuestionsButton').style.display = 'none';
if(s.everyPageTitle == 0){
document.getElementById('headertitle').style.display = 'none';
}
if(s.everyPageText == 0){
document.getElementById('headertext').style.display = 'none';
}
document.getElementById('questions').style.display='inline';
Survey.Form.addWidgets(qs);
});
}else{
document.getElementById('questions').style.display='inline';
Survey.Form.addWidgets(qs);
}
lastSection = s.id;
}else{
document.getElementById('headertitle').style.display='block';
document.getElementById('headertext').style.display = 'block';
document.getElementById('questions').style.display='inline';
Survey.Form.addWidgets(qs);
}
}
//Display questions
this.addWidgets = function(qs){
hasFile = false;
for(var i = 0; i < qs.length; i++){
var q = qs[i];
var verts = '';
var verte = '';
for(var x in q.answers){
for(var y in q.answers[x]){
if(q.answers[x][y] == undefined){q.answers[x][y] = '';}
}
}
//Check if this question should be validated
if(q.required == 1){
toValidate[q.id] = new Array();
toValidate[q.id]['type'] = q.questionType;
toValidate[q.id]['answers'] = new Array();
}
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[q.id]){
toValidate[q.id]['answers'][a.id] = 1;
}
var b = document.getElementById(a.id+'button');
/*
b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.id+'button', name: a.id+'button',
value: a.id,
container: a.id+"container", checked: false });
*/
// b.on("click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
// YAHOO.util.Event.addListener(a.id+'button', "click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
if(a.verbatim == 1){
verb = 1;
}
YAHOO.util.Event.addListener(a.id+'button', "click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
b.hid = a.id;
butts.push(b);
}
}
else if(dateType[q.questionType]){
for(var x = 0; x < q.answers.length; x++){
var a = q.answers[x];
if(toValidate[q.id]){
toValidate[q.id]['answers'][a.id] = 1;
}
var calid = a.id+'container';
var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true});
c.selectEvent.subscribe(this.selectCalendar,[c,a.id],true);
c.render();
c.hide();
var b = new YAHOO.widget.Button({ label:"Select Date", id:"pushbutton"+a.id, container:a.id+'button' });
b.on("click", this.showCalendar,[c]);
}
}
else if(slider[q.questionType]){
//First run through and put up the span placeholders and find the max value for an answer, to know how big the allocation points will be.
var max = 0;
if(q.questionType == 'Dual Slider - Range'){
new this.dualSliders(q);
}else{
for(var s in q.answers){
var a = q.answers[s];
YAHOO.util.Event.addListener(a.id, "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[q.id]){
toValidate[q.id]['total'] = a.max;
toValidate[q.id]['answers'][a.id] = 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[q.id]){
toValidate[q.id]['answers'][a.id] = 1;
}
}
}
YAHOO.util.Event.addListener("submitbutton", "click", this.formsubmit);
}
this.formsubmit = function(event){
var submit = 1;//boolean for if all was good or not
for(var i in toValidate){
var answered = 0;
if(toValidate[i]['type'] == 'Multi Slider - Allocate'){
var total = 0;
for(var z in toValidate[i]['answers']){
total += Math.round(document.getElementById(z).value);
}
if(total == toValidate[i]['total']){answered = 1;}
else{
var amountLeft = toValidate[i]['total']-total;
alert("Please allocate the remaining "+amountLeft+ ".");
}
}else{
for(var z in toValidate[i]['answers']){
var v = document.getElementById(z).value;
if(v != '' && v != undefined){
answered = 1;
break;
}
}
}
if(answered == 0){
submit = 0;
document.getElementById(i+'required').innerHTML = "<font color=red>*</font>";
}else{
document.getElementById(i+'required').innerHTML = "";
}
}
if(submit == 1){
YAHOO.log("Submitting");
Survey.Comm.callServer('','submitQuestions','surveyForm',hasFile);
}
}
this.dualSliders = function(q){
var total = sliderWidth;
// var sliders = new Array();
var a1 = q.answers[0];
var a2 = q.answers[1];
var scale = sliderWidth/a1.max;
var id = q.id;
var a1id = a1.id;
var a2id = a2.id;
var a1h = document.getElementById(a1id);
var a2h = document.getElementById(a2id);
var a1s = document.getElementById(a1id+'show');
var a2s = document.getElementById(a2id+'show');
var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg',
a1id+"slider-min-thumb", a2id+"slider-max-thumb",
sliderWidth, 1*scale, [1,sliderWidth]);
sliders[id] = s;
//YAHOO.log(1);
s.minRange = 4;
var updateUI = function () {
var min = Math.round(s.minVal/scale),
max = Math.round(s.maxVal/scale);
a1h.value = min;
a1s.innerHTML = min;
a2h.value = max;
a2s.innerHTML = max;
};
// Subscribe to the dual thumb slider's change and ready events to
// report the state.
// s.subscribe('ready', updateUI);
//s.subscribe('change', updateUI);
s.subscribe('slideEnd', updateUI);
}
this.sliders = function(q){
var total = sliderWidth;
for(var i in q.answers){
var a = q.answers[i];
var step = Math.round(q.answers[i].step);
var min = Math.round(parseFloat(q.answers[i].min));
var distance = Math.round(parseFloat(q.answers[i].max) + (-1 * min));
var scale = Math.round(sliderWidth/distance);
var lang = YAHOO.lang;
var id = a.id;
var s = YAHOO.widget.Slider.getHorizSlider(id+'slider-bg', id+'slider-thumb',
0, sliderWidth, (scale*step));
s.scale = scale;
sliders[q.Survey_questionid] = new Array();
sliders[q.Survey_questionid][id] = s;
s.input = a.id;
s.scale = scale;
document.getElementById(id).value = a.min;
var check = function() {
var t = document.getElementById(this.input);
t.value = this.getRealValue();
};
s.getRealValue = function() {
return Math.round(parseFloat(( (this.getValue() / total) * distance) + min ));
}
s.subscribe("slideEnd", 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 = sliderWidth;
var step = Math.round(parseFloat(q.answers[0].step));
var min = Math.round(parseFloat(q.answers[0].min));
var distance = Math.round(parseFloat(q.answers[0].max) + (-1 * min));
var scale = Math.round(sliderWidth/distance);
for(var i in q.answers){
var a = q.answers[i];
var Event = YAHOO.util.Event;
var lang = YAHOO.lang;
var id = a.id+'slider-bg';
var s = YAHOO.widget.Slider.getHorizSlider(id, a.id+'slider-thumb',
0, sliderWidth, scale*step);
s.animate = false;
if(sliders[q.id] == undefined){
sliders[q.id] = new Array();
}
sliders[q.id][a.id] = s;
s.input = a.id;
s.lastValue = 0;
var check = function() {
var t = 0;
for(var x in sliders[q.id]){
t+= sliders[q.id][x].getValue();
}
if(t > total){
t -= this.getValue();
t = Math.round(t);
this.setValue(total-t);// + (scale*step));
document.getElementById(this.input).value = Math.round(parseFloat(( ((total-t) / total) * distance) + min ));
}else{
this.lastValue = this.getValue();
document.getElementById(this.input).value = this.getRealValue();
}
};
s.subscribe("change", check);
s.subscribe("slideEnd", check);
var manualEntry = function(e){
// set the value when the 'return' key is detected
if (Event.getCharCode(e) === 13 || e.type == 'blur') {
var v = parseFloat(this.value, 10);
v = (lang.isNumber(v)) ? v : 0;
// v *= scale;
v = ( ( (v-min) / distance))*total;
// convert the real value into a pixel offset
for(var sl in sliders[q.id]){
if(sliders[q.id][sl].input == this.id){
sliders[q.id][sl].setValue(Math.round(v));
}
}
}
}
Event.on(document.getElementById(s.input), "blur", manualEntry);
Event.on(document.getElementById(s.input), "keypress", manualEntry);
s.getRealValue = function() {
return Math.round(parseFloat(( (this.getValue() / total) * distance) + min ));
}
document.getElementById(s.input).value = s.getRealValue();
}
}
this.selectCalendar = function(event,args,obj){
var id = obj[1];
var selected = args[0];
var date = selected[0];
var year = date[0], month = date[1], day = date[2];
var input = document.getElementById(id);
input.value = month + "/" + day + "/" + year;
obj[0].hide();
}
this.showCalendar = function(event,objs){
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];
var qid = objs[1];
var maxA = objs[2];
var butts = objs[3];
var qsize = objs[4];
var aid = objs[5];
max = parseFloat(max);
// clearTimeout(Survey.Form.submittimer);
if(maxA == 1){
if(b.className == 'mcbutton-selected'){
document.getElementById(b.hid).value = 0;
b.className='mcbutton';
}else{
document.getElementById(b.hid).value = 1;
b.className='mcbutton-selected';
}
for(var i in butts){
if(butts[i] != b){
butts[i].className='mcbutton';
document.getElementById(butts[i].hid).value = '';
}
}
}
else if(b.className == 'mcbutton'){
var bscount = 0;//button selected count
for(var i in butts){
if(butts[i].className == 'mcbutton-selected'){bscount++;}
}
var max = maxA - bscount;//= parseFloat(document.getElementById(qid+'max').innerHTML);
if(max == 0){
b.className='mcbutton';
//warn that options used up
}
else{
b.className='mcbutton-selected';
//document.getElementById(qid+'max').innerHTML = parseFloat(max-1);
document.getElementById(b.hid).value = 1;
}
}else{
b.className='mcbutton';
var bscount = 0;//button selected count
for(var i in butts){
if(butts[i].className == 'mcbutton-selected'){bscount++;}
}
var max = maxA - bscount;//= parseFloat(document.getElementById(qid+'max').innerHTML);
// document.getElementById(qid+'max').innerHTML = parseFloat(max+1);
document.getElementById(b.hid).value = '';
}
/*
if(qsize == 1 && b.className == 'mcbutton-selected'){
if(! document.getElementById(aid+'verbatim')){
Survey.Form.submittimer=setTimeout("Survey.Form.formsubmit()",500);
}
}
*/
}
}();
//----------------------------------------------------------------
//
// Initialize survey
//
//----------------------------------------------------------------
Survey.OnLoad = new function() {
var e = YAHOO.util.Event;
this.init = function() {
e.onDOMReady(this.initHandler);
}
this.initHandler = function(){
Survey.Comm.setUrl('/'+document.getElementById('assetPath').value);
Survey.Comm.callServer('','loadQuestions');
}
}();
Survey.OnLoad.init();

View file

@ -0,0 +1,73 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.Comm= new function(){
this.url = '';
this.setUrl = function(u){this.url = u;}
var callMade = 0;
var request = function(sUrl,callback,postData,form, hasFile){
if(form != undefined){
if(hasFile){
YAHOO.util.Connect.setForm(form,true);
//YAHOO.log('set file was true');
}else{
//YAHOO.log('set file was false');
YAHOO.util.Connect.setForm(form);
}
//YAHOO.log('setForm was true');
}
if(callMade == 1){
alert("Waiting on previous request");
}else{
callMade = 1;
YAHOO.log(sUrl);
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}
}
this.callback = {
upload:function(o){
callMade = 0;
Survey.Comm.callServer('','loadQuestions');
},
success:function(o){
window.scrollTo(0,0);
callMade = 0;
var response = '';
response = YAHOO.lang.JSON.parse(o.responseText);
if(response.type == 'displayquestions'){
Survey.Form.displayQuestions(response);
}else if(response.type == 'forward'){
//YAHOO.log("going to "+response.url);
location.href=response.url;
}else{
alert("bad response");
}
},
failure: function(o){
callMade = 0;
if(o.status == -1){
alert("Last request timed out, please try again");
}else{
alert("Last request failed "+o.statusText);
}
},
};
this.callServer = function(data,functionName,form,hasFile){
var postData;
if(form == undefined){
postData = "data="+YAHOO.lang.JSON.stringify(data,data);
//YAHOO.log(postData);
}
var sUrl = this.url + "?func="+functionName;
request(sUrl,this.callback,postData,form,hasFile);
}
}();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

View file

@ -0,0 +1,125 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var DDM = YAHOO.util.DragDropMgr;
Survey.DDList = function(id, sGroup, config) {
Survey.DDList.superclass.constructor.call(this, id, sGroup, config);
this.logger = this.logger || YAHOO;
var el = this.getDragEl();
Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
this.goingUp = false;
this.lastY = 0;
};
YAHOO.extend(Survey.DDList, YAHOO.util.DDProxy, {
startDrag: function(x, y) {
this.logger.log(this.id + " startDrag");
// make the proxy look like the source element
var dragEl = this.getDragEl();
var clickEl = this.getEl();
Dom.setStyle(clickEl, "visibility", "hidden");
dragEl.innerHTML = clickEl.innerHTML;
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
Dom.setStyle(dragEl, "border", "2px solid gray");
},
endDrag: function(e) {
var srcEl = this.getEl();
var proxy = this.getDragEl();
// Show the proxy element and animate it to the src element's location
Dom.setStyle(proxy, "visibility", "");
var a = new YAHOO.util.Motion(
proxy, {
points: {
to: Dom.getXY(srcEl)
}
},
0.2,
YAHOO.util.Easing.easeOut
)
var proxyid = proxy.id;
var thisid = this.id;
// Hide the proxy and show the source element when finished with the animation
a.onComplete.subscribe(function() {
Dom.setStyle(proxyid, "visibility", "hidden");
Dom.setStyle(thisid, "visibility", "");
});
a.animate();
},
onDragDrop: function(e, id) {
// If there is one drop interaction, the li was dropped either on the list,
// or it was dropped on the current location of the source element.
if (DDM.interactionInfo.drop.length === 1) {
// The position of the cursor at the time of the drop (YAHOO.util.Point)
var pt = DDM.interactionInfo.point;
// The region occupied by the source element at the time of the drop
var region = DDM.interactionInfo.sourceRegion;
// Check to see if we are over the source element's location. We will
// append to the bottom of the list once we are sure it was a drop in
// the negative space (the area of the list without any list items)
if (!region.intersect(pt)) {
var destEl = Dom.get(id);
var destDD = DDM.getDDById(id);
destEl.appendChild(this.getEl());
destDD.isEmpty = false;
DDM.refreshCache();
}
}
Survey.Data.dragDrop(this.getEl());
},
onDrag: function(e) {
// Keep track of the direction of the drag for use during onDragOver
var y = Event.getPageY(e);
if (y < this.lastY) {
this.goingUp = true;
} else if (y > this.lastY) {
this.goingUp = false;
}
this.lastY = y;
},
onDragOver: function(e, id) {
var srcEl = this.getEl();
var destEl = Dom.get(id);
// We are only concerned with list items, we ignore the dragover
// notifications for the list.
if (destEl.nodeName.toLowerCase() == "li") {
var orig_p = srcEl.parentNode;
var p = destEl.parentNode;
if (this.goingUp) {
p.insertBefore(srcEl, destEl); // insert above
} else {
p.insertBefore(srcEl, destEl.nextSibling); // insert below
}
DDM.refreshCache();
}
}
});

View file

@ -0,0 +1,123 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.Data = new function(){
var lastDataSet = {};
var focus;
this.dragDrop = function(did){
var type;
YAHOO.log('In drag drop');
if(did.className.match("section")){type = 'section';}
else if(did.className.match("question")){type = 'question';}
else{ type = 'answer';}
var first = {id:did.id,type:type};
var before = document.getElementById(did.id).previousSibling;
while(1){
if( before == undefined || (before.id != undefined && before.id != '') ){
break;
}
var before = before.previousSibling;
}
var data = {id:'',type:''};
if(before != undefined && before.id != undefined && before.id != ''){
if(before.className.match("section")){type = 'section';}
else if(before.className.match("question")){type = 'question';}
else{ type = 'answer';}
data = {id:before.id,type:type};
}
YAHOO.log(first.id+' '+data.id);
Survey.Comm.dragDrop(first,data);
}
this.clicked = function(){
Survey.Comm.loadSurvey(this.id);
}
this.loadData = function(d){
focus = d.address;//What is the current highlighted item.
document.getElementById('sections').innerHTML=d.ddhtml;
//add event handlers for if a tag is clicked
for(var x in d.ids){
YAHOO.log('adding handler for '+ d.ids[x]);
YAHOO.util.Event.addListener(d.ids[x], "click", this.clicked);
new Survey.DDList(d.ids[x],"sections");
}
//add the add object buttons
// if(d.buttons['section']){
document.getElementById('addSection').innerHTML = '';
document.getElementById('addQuestion').innerHTML = '';
document.getElementById('addAnswer').innerHTML = '';
var button = new YAHOO.widget.Button({ label:"Add Section", id:"addsection", container:"addSection" });
button.on("click", this.addSection);
// }
// if(d.buttons['question']){
var button = new YAHOO.widget.Button({ label:"Add Question", id:"addquestion", container:"addQuestion" });
button.on("click", this.addQuestion,d.buttons['question']);
// }
if(d.buttons['answer']){
var button = new YAHOO.widget.Button({ label:"Add Answer", id:"addanswer", container:"addAnswer" });
button.on("click", this.addAnswer,d.buttons['answer']);
}
this.loadObjectEdit(d.edithtml,d.type);
lastDataSet = d;
}
this.addSection = function(){
Survey.Comm.newSection();
}
this.addQuestion = function(e,id){
Survey.Comm.newQuestion(id);
}
this.addAnswer = function(e,id){
Survey.Comm.newAnswer(id);
}
this.loadObjectEdit = function(edit,type){
if(edit){
Survey.ObjectTemplate.loadObject(edit,type);
}
}
this.loadLast = function(){
this.loadData(lastDataSet);
}
}();
//----------------------------------------------------------------
//
// Initialize survey
//
//----------------------------------------------------------------
Survey.OnLoad = function() {
var e = YAHOO.util.Event;
return {
init: function() {
e.onDOMReady(this.initHandler);
},
initHandler: function(){
new YAHOO.util.DDTarget("sections","sections");
Survey.Comm.loadSurvey();
},
}
}();
Survey.OnLoad.init();

View file

@ -0,0 +1,69 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.AnswerTemplate = new function(){
this.params;
this.loadAnswer = function(params){
for(var p in params){
if(params[p] == undefined){params[p] = '';}
}
var html = "\
<div id='answer'>\
<div class='hd'>Please enter answer information</div>\
<div class='bd'>\
\
<form name='form' method='POST' action='?func=submitAnswerEdit'>\
\
<p>Answer Number: "+params.sequenceNumber + "\
\
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
<input type='hidden' name='Survey_answerId' value='"+params.Survey_answerId+"'>";
html = html + "<p>Answer Text:\n<textarea name='answerText'>"+params.answerText+"</textArea>\n";
html = html + "<p>Recorded Answer\n<textarea name='recordedAnswer'>"+params.recordedAnswer+"</textArea>\n";
html = html + "<p>Jump to:<input type=text value='"+params.gotoQuestion+"' name=gotoQuestion size=4>";
html = html + "<span id='textParams'><p>Text Answer Cols:<input type=text size=2 value='"+params.textCols+"' name=textCols> Rows: \
<input type=text size=2 value='"+params.textRows+"' name=textRows> </p></span>";
html = html + "<p>Is this the correct answer:\n" +
this.makeRadio('isCorrect',[{text:'Yes',value:1},{text:'No',value:0}],params.isCorrect);
html = html + "<p>Min:<input type=text value='"+params.min+"' name=min size=2>";
html = html + "<p>Max:<input type=text value='"+params.max+"' name=max size=2>";
html = html + "<p>Step:<input type=text value='"+params.step+"' name=step size=2>";
html = html + "<p>Verbatim:\n" +
this.makeRadio('verbatim',[{text:'Yes',value:1},{text:'No',value:0}],params.verbatim);
document.getElementById('edit').innerHTML = html;
var butts = [{ text:"Submit", handler:function(){this.submit();}, isDefault:true },{ text:"Cancel", handler:function(){this.cancel();}} ];
if(params.Survey_answerId != ''){
butts[2] = { text:"Delete", handler:function(){Survey.Comm.deleteAnswer(Survey.AnswerTemplate.params.Survey_answerId);}};
}
var form = new YAHOO.widget.Dialog("answer",
{ width : "500px",
fixedcenter : true,
visible : false,
constraintoviewport : true,
buttons : butts
});
form.callback = Survey.Comm.callback;
form.render();
form.show();
this.params = params;
};
this.makeRadio = function(name,values,checked){
var html = '';
for(var i in values){
if(checked == values[i]['value']){
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
}else{
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
}
}
html = html + "\n";
return html;
}
}();

View file

@ -0,0 +1,75 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.Comm = new function(){
var callMade = 0;
var request = function(sUrl,callback,postData){
if(callMade == 1){
alert("Waiting on previous request");
}else{
callMade = 1;
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}
}
this.callback = {
success:function(o){
callMade = 0;
Survey.Data.loadData(YAHOO.lang.JSON.parse(o.responseText));
},
failure: function(o){
callMade = 0;
alert("Last request failed");
Survey.Data.loadLast();
},
timeout: 5000
};
this.loadSurvey = function(p){
var postData = "data="+p;
var sUrl = "?func=loadSurvey";
request(sUrl,this.callback,postData);
}
this.dragDrop = function(target,before){
var p = {};
p['target'] = target;
p['before'] = before;
var postData = "data="+YAHOO.lang.JSON.stringify(p);
var sUrl = "?func=dragDrop";
request(sUrl,this.callback,postData);
}
this.submitEdit = function(p){
var postData = "data="+YAHOO.lang.JSON.stringify(p);
var sUrl = "?func=submitEdit";
request(sUrl,this.callback,postData);
}
this.newSection = function(){
var sUrl = "?func=newObject";
request(sUrl,this.callback);
}
this.newQuestion = function(id){
var postData = "data="+id;
var sUrl = "?func=newObject";
request(sUrl,this.callback,postData);
}
this.newAnswer = function(id){
var postData = "data="+id;
var sUrl = "?func=newObject";
request(sUrl,this.callback,postData);
}
this.deleteAnswer = function(id){
var postData = "data="+id;
var sUrl = "?func=deleteAnswer";
request(sUrl,this.callback,postData);
}
this.deleteQuestion = function(id){
var postData = "data="+id;
var sUrl = "?func=deleteQuestion";
request(sUrl,this.callback,postData);
}
this.deleteSection = function(id){
var postData = "data="+id;
var sUrl = "?func=deleteSection";
request(sUrl,this.callback,postData);
}
}();

View file

@ -0,0 +1,32 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.ObjectTemplate = new function(){
this.loadObject = function(html,type){
document.getElementById('edit').innerHTML = html;
var butts = [
{ text:"Submit", handler:function(){this.submit();}, isDefault:true },
{ text:"Copy", handler:function(){document.getElementById('copy').value = 1; this.submit();}},
{ text:"Cancel", handler:function(){this.cancel();}},
{ text:"Delete", handler:function(){document.getElementById('delete').value = 1; this.submit();}}
];
var form = new YAHOO.widget.Dialog(type,
{
width : "500px",
fixedcenter : true,
visible : false,
constraintoviewport : true,
buttons : butts
} );
form.callback = Survey.Comm.callback;
form.render();
form.show();
}
}();

View file

@ -0,0 +1,40 @@
<div id='question'>
<div class='hd'>Please enter question information</div>
<div class='bd'>
<form name='form' method='POST' action='?func=submitObjectEdit'>
<p>Question Number: <tmpl_var displayed_id>
<input type='hidden' name='id' value='<tmpl_var id>'>
<p>Question Text:\n";
<textarea name='questionText'><tmpl_var text></textArea>\n";
<p>Question variable name:<input maxlength=35 size=10 type=text value='<tmpl_var variable>' name=variable size=2></p>";
<p>Randomize answers:";
<input type='radio' name='randomizeAnswers' value=1 <tmpl_if randomizeAnswers>checked</tmpl_if>>Yes
<input type='radio' name='randomizeAnswers' value=0 <tmpl_unless randomizeAnswers>checked</tmpl_unless>>No
<p>Question type:
<select name='questionType'>
<tmpl_loop questionType>
<option value='<tmpl_var text>' <tmpl_if selected>selected</tmpl_if>><tmpl_var text></option>
</tmpl_loop>
</select>
<p>Randomized words:
<textarea name=randomizWords><tmpl_var randomWords></textArea>
<p>Vertical display:
<input type='radio' name='verticalDisplay' value=1 <tmpl_if verticalDisplay>checked</tmpl_if>>Yes
<input type='radio' name='verticalDisplay' value=0 <tmpl_unless verticalDisplay>checked</tmpl_unless>>No
<p>Show text in button:
<input type='radio' name='textInButton' value=1 <tmpl_if textInButton>checked</tmpl_if>>Yes
<input type='radio' name='textInButton' value=0 <tmpl_unless textInButton>checked</tmpl_unless>>No
<p>Allow comment:
<input type='radio' name='allowComment' value=1 <tmpl_if allowComment>checked</tmpl_if>>Yes
<input type='radio' name='allowComment' value=0 <tmpl_unless allowComment>checked</tmpl_unlexx>>No
<span id='commentParams'><p>&nbsp;&nbsp; Cols:<input type=text size=2 value='<tmpl_var commentCols>' name=commentCols> Rows:
<input type=text size=2 value='<tmpl_var commentRows>' name=commentRows> </p></span>
<p>Maximum number of answers:<input type=text value='<tmpl_var maxAnswers>' name=maxAnswers size=2>
<p>Required:
<input type='radio' name='required' value=1 <tmpl_if required>checked</tmpl_if>>Yes
<input type='radio' name='required' value=0 <tmpl_unless required>checked</tmpl_unless>>No
</form>
</div>
</div>

View file

@ -0,0 +1,112 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.QuestionTemplate = new function(){
this.loadQuestion = function(params){
for(var p in params){
if(params[p] == undefined){params[p] = '';}
}
var html = "\
<div id='question'>\
<div class='hd'>Please enter question information</div>\
<div class='bd'>\
\
<form name='form' method='POST' action='?func=submitQuestionEdit'>\
<p>Question Number: "+params.sequenceNumber + "\
\
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
<p>Question Text:\n";
if(params.questionText == ''){
html = html + "<textarea name='questionText'>Enter Text Here</textArea>\n";
}
else{
html = html + "<textarea name='questionText'>"+params.questionText+"</textArea>\n";
}
html = html + "<p>Question variable name:<input maxlength=35 size=10 type=text value='"+ params.questionVariable +"' name=questionVariable size=2></p>";
html = html + "<p>Randomize answers:";
html = html+ this.makeRadio('randomizeAnswers',[{text:'Yes',value:1},{text:'No',value:0}],params.randomizeAnswers);
html = html + "<p>Question type:";
var questions = ['Agree/Disagree','Certainty','Concern','Confidence','Currency','Date','Date Range','Dual Slider - Range','Education','Effectiveness',
'Email','File Upload','Gender','Hidden','Ideology','Importance','Likelihood','Multi Slider - Allocate','Multiple Choice','Oppose/Support',
'Party','Phone Number','Race','Risk','Satisfaction','Scale','Security','Slider','Text','Text Date','Threat','True/False','Yes/No'];
// var questions = ['Multiple Choice','Gender','Yes/No','True/False','Agree/Disagree','Oppose/Support','Importance','Likelihood','Certainty','Satisfaction',
// 'Confidence','Effectiveness','Concern','Risk','Threat','Security','Ideology','Race','Party','Education',
// 'Text', 'Email', 'Phone Number', 'Text Date', 'Currency',
// 'Slider','Dual Slider - Range','Multi Slider - Allocate', 'Date','Date Range', 'File Upload','Hidden'];
html = html + this.makeMenu('questionType',questions,questions,params.questionType);
html = html + "\
<p>Randomized words:\
<textarea name=randomizedWords>"+params.randomizedWords+"</textArea>\
<p>Vertical display:";
html = html+ this.makeRadio('verticalDisplay',[{text:'Yes',value:1},{text:'No',value:0}],params.verticalDisplay);
html = html + "<p>Show text in button:";
html = html + this.makeRadio('textInButton',[{text:'Yes',value:1},{text:'No',value:0}],params.textInButton);
html = html + "<p>Allow comment:";
html = html + this.makeRadio('allowComment',[{text:'Yes',value:1},{text:'No',value:0}],params.allowComment);
html = html + "<span id='commentParams'><p>&nbsp;&nbsp; Cols:<input type=text size=2 value='"+params.commentCols+"' name=commentCols> Rows: \
<input type=text size=2 value='"+params.commentRows+"' name=commentRows> </p></span>";
html = html + "<p>Maximum number of answers:<input type=text value='"+params.maxAnswers+"' name=maxAnswers size=2>";
html = html + "<p>Required:";
html = html+ this.makeRadio('required',[{text:'Yes',value:1},{text:'No',value:0}],params.required);
html = html + "\
</form>\
</div>\
</div>\
";
document.getElementById('edit').innerHTML = html;
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}} ];
if(params.Survey_questionId != ''){
butts[2] = {text:"Delete", handler:function(){Survey.Comm.deleteQuestion(params.Survey_questionId);}};
}
var form = new YAHOO.widget.Dialog("question",
{ width : "500px",
fixedcenter : true,
visible : false,
constraintoviewport : true,
buttons : butts
} );
form.callback = Survey.Comm.callback;
form.render();
form.show();
}
this.makeMenu = function(name,values,text,selected){
var html = "<select name='"+name+"'>\n";
for(var i in values){
if(values[i] == selected){
html = html + "<option value='"+values[i]+"' selected>"+text[i]+"</option>\n";
}else{
html = html + "<option value='"+values[i]+"' >"+text[i]+"</option>\n";
}
}
html = html + "</select>\n";
return html;
}
this.makeRadio = function(name,values,checked){
var html = '';
for(var i in values){
if(checked == values[i]['value']){
html = html+ "<input type='radio' id='"+name+"' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
}else{
html = html+ "<input type='radio' id='"+name+"' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
}
}
html = html + "\n";
return html;
}
}();

View file

@ -0,0 +1,28 @@
if (typeof Survey == "undefined") {
var Survey = {};
}
Survey.SectionTemplate = new function(){
this.loadSection = function(html){
document.getElementById('edit').innerHTML = html;
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}},
{text:"Delete", handler:function(){document.getElementById('delete').setValue(1); this.submit();}}
];
var form = new YAHOO.widget.Dialog("section",
{ width : "500px",
fixedcenter : true,
visible : false,
constraintoviewport : true,
buttons : butts
} );
form.callback = Survey.Comm.callback;
form.render();
form.show();
}
}();

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

View file

@ -0,0 +1,85 @@
body {
margin: 0;
background-repeat: repeat-y;
background-position: 0px 0px;
}
.header {
width: 80%;
height: 20px;
margin-left: 80px;
}
#survey {
margin-left: 80px;
width: 85%;
}
div.dateanswer {
min-height: 250px;
}
div.slider-bg {
position: relative;
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: 30px;
left: 4px;
}
div.slider-min-thumb {
cursor:default;
position: absolute;
top: 4px;
}
div.slider-max-thumb {
cursor:default;
position: absolute;
top: 4px;
}
#headertitle {
display: none;
}
#headertext {
display: none;
}
#questions {
display: none;
}
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);
}
input.mcbutton:hover{
background-color: #B6D2F1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
input.mcbutton-selected{
background-color: #172D9D;
background-repeat: repeat-x;
color: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
margin: 0.5em;
padding: .8em;
width: 60px;
text-align: center;
display: block;
font-weight: bold;
background-image: url(/extras/wobject/Survey/gradient-glossy.png);
background-position: 0px 0px;
}

View file

@ -0,0 +1,132 @@
div.testarea {
width: 200px;
height: 100px;
z-index: 999;
border: 1px solid gray;
background: #f7f7f7;
position: absolute;
top: 5%;
left:5%;
}
div.trashcan {
border: 1px solid gray;
width: 175px;
height: 50px;
}
div.workarea {
padding:10px;
padding-top:40px;
float:left
}
div.editarea {
margin-top:40px;
padding:10px;
float:left;
border: 1px solid gray;
}
div.editquestion {
padding:10px;
float:left;
}
div.editanswer {
padding:10px;
float:left;
}
#submitbutton { padding:20px; }
div.entry {
padding-bottom:10px;
padding-left:10px;
}
ul.draglist {
position: relative;
width: 340px;
background: #f7f7f7;
border: 1px solid gray;
list-style: none;
margin:0;
padding:0;
padding-bottom:20px;
}
ul.draglist li {
margin: 5px;
}
ul.questionList {
position: relative;
background: #f7f7f7;
border: 1px solid gray;
list-style: none;
margin:0;
padding:0;
min-height: 40px
}
li.section {
background-color: #CCCCFF;
border:1px solid #7EA6B2;
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%;
min-height: 10px;
}
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;
padding-left:50px;
# cursor: move;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B