- Timestamp:
- 12/05/11 14:58:27 (13 years ago)
- Location:
- Dev/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/css/awesome.css
r175 r176 31 31 color: #333; 32 32 } 33 33 /* 34 34 label { 35 35 font-size: small; … … 38 38 text-shadow: #fff 0px 0px 1px; 39 39 } 40 40 */ 41 41 legend { 42 42 padding-left: 0em; … … 873 873 width: auto; 874 874 min-width: 51em; 875 border: 3px solid #cccccc;876 background-color: white;877 875 margin: 3px; 878 876 } … … 884 882 885 883 .questionParamField { 886 display: inline; 887 } 884 float: left; 885 margin: 2px 0 2px 0; 886 } 887 888 #questionEditor_questionParams label { 889 width: 130px; 890 float: left; 891 margin: 4px 0 0 0; 892 } 893 894 .formLineBreak { 895 clear: left; 896 } -
Dev/trunk/js/questionEditorScripts.js
r175 r176 1 ////////////////////// 2 /* HELPER FUNCTIONS */ 3 ////////////////////// 4 5 function hasClass(ele,cls) { 6 if (ele.className) 7 return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); 8 } 9 10 function addClass(ele,cls) { 11 if (!this.hasClass(ele,cls)) ele.className += " "+cls; 12 } 13 14 function removeClass(ele,cls) { 15 if (hasClass(ele,cls)) { 16 var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); 17 ele.className=ele.className.replace(reg,' '); 18 } 19 } 20 21 ////////////////////////// 22 /* END HELPER FUNCTIONS */ 23 ////////////////////////// 24 25 1 26 var qUID, parentObjectUID, qName, qTag, qType, qAnswerLength; 2 27 3 28 function selectAnswerType(){ 4 5 29 var selectBox = document.getElementById("questionType"); 6 30 if (selectBox.value != undefined && selectBox.value != "") { … … 10 34 return; 11 35 } 12 13 36 removeWrongAnswerFields(selectBox); 14 15 37 switch (qType) { 16 38 case "int": … … 38 60 if (id != undefined) newElement.id = id; 39 61 if (cl != undefined) newElement.className = cl; 40 if (value != undefined) newElement.value = value; 62 if (value != undefined) { 63 newElement.value = value; 64 newElement.text = value; 65 } 41 66 return newElement; 67 } 68 69 function createNewInputLabel(text, target) { 70 var newLabel = document.createElement("label"); 71 if (target) newLabel.setAttribute("for",target); 72 newLabel.innerHTML = text; 73 return newLabel; 42 74 } 43 75 … … 48 80 } 49 81 82 function updateIdentifier() { 83 var identField = document.getElementById("questionIdentifierField"); 84 if (identField.value == undefined && identField.value == "") { 85 return; 86 } 87 var headerField = document.getElementById("header_identifier"); 88 headerField.innerHTML = identField.value; 89 } 50 90 51 91 92 /////////////////// 93 /* INT SELECTION */ 94 /////////////////// 52 95 53 96 function selectIntType() { 54 97 var selectBox = document.getElementById("questionType"); 55 98 var content = document.getElementById("questionEditor_questionParams"); 99 // Add minimum value input 56 100 var minValueBox = createNewElement("input","text","minValueBox", "questionParamField", null); 57 content.innerHTML += "<br />Min value: "; 101 var minValueBoxLabel = createNewInputLabel("Minimum value:", "minValueBox"); 102 addClass(minValueBoxLabel, "formLineBreak"); 103 content.appendChild(minValueBoxLabel); 58 104 content.appendChild(minValueBox); 105 // Add maximum value input 59 106 var maxValueBox = createNewElement("input", "text", "maxValueBox", "questionParamField", null); 60 content.innerHTML += "<br />Max value: "; 107 var maxValueBoxLabel = createNewInputLabel("Maximum value:","maxValueBox"); 108 addClass(maxValueBoxLabel, "formLineBreak"); 109 content.appendChild(maxValueBoxLabel); 61 110 content.appendChild(maxValueBox); 62 63 // set the selected value, because adding a DOM element to the parent element resets the selected value.64 for (var i = 0; i < selectBox.options.length; i++) {65 if (selectBox.options[i].value == "int") {66 selectBox.selectedValue = i;67 selectBox.selectedText = "Integer";68 // DIT WERKT NOG NIET, HIJ SELECTEERT HEM NIET, OOK AL IS SELECTED = TRUE69 // MET ANDERE WOORDEN: WTF.70 }71 }72 111 } 73 112 74 113 ///////////////////// 114 /* SCALE SELECTION */ 115 ///////////////////// 75 116 76 117 function selectScaleType() { 77 debugger; 78 var selectBox = document.getElementById("questionType"); 118 // I heard you like walls of text! 79 119 var content = document.getElementById("questionEditor_questionParams"); 120 // Add number of choices input 80 121 var numChoicesBox = createNewElement("select", null, "numChoicesBox","questionParamField",null); 81 content.innerHTML += "<br />Scale size: ";122 var numChoicesBoxLabel = createNewInputLabel("Scale size:","numChoicesBox"); 82 123 for (var i = 0; i < 10; i++) { 83 124 var option = createNewElement("option"); … … 86 127 numChoicesBox.appendChild(option); 87 128 } 129 addClass(numChoicesBoxLabel, "formLineBreak"); 130 content.appendChild(numChoicesBoxLabel); 88 131 content.appendChild(numChoicesBox); 89 numChoicesBox.addEventListener("change", selectScaleSize, false); 132 // Add legends enabled input 133 var legendsEnabledCheckBox = createNewElement("input","checkbox","legendsEnabledCheckbox","questionParamField",null); 134 var legendsEnabledCheckBoxLabel = createNewInputLabel("Enable legends","legendsEnabledCheckBox"); 135 addClass(legendsEnabledCheckBoxLabel, "formLineBreak"); 136 content.appendChild(legendsEnabledCheckBoxLabel); 137 content.appendChild(legendsEnabledCheckBox); 138 // Add legend labels boxes 139 var upperLegendBox = createNewElement("input","text","upperLegendBox","questionParamField"); 140 var lowerLegendBox = createNewElement("input","text","lowerLegendBox","questionParamField"); 141 var lowerLegendBoxLabel = createNewInputLabel("Lower legend","lowerLegendBox"); 142 var upperLegendBoxLabel = createNewInputLabel("Upper legend","upperLegendBox"); 143 addClass(lowerLegendBoxLabel,"formLineBreak"); 144 content.appendChild(lowerLegendBoxLabel); 145 content.appendChild(lowerLegendBox); 146 addClass(upperLegendBoxLabel,"formLineBreak"); 147 content.appendChild(upperLegendBoxLabel); 148 content.appendChild(upperLegendBox); 149 // Disable these boxes, since the checkbox is unchecked by default 150 lowerLegendBox.disabled = true; 151 upperLegendBox.disabled = true; 152 if (legendsEnabledCheckBox.addEventListener) { 153 legendsEnabledCheckBox.addEventListener("click", toggleScaleLegends, true); 154 } 90 155 } 91 156 92 function selectScaleSize() { 93 var numChoicesBox = document.getElementById("numChoicesBox"); 157 function toggleScaleLegends() { 94 158 var content = document.getElementById("questionEditor_questionParams"); 95 for (var i = 0; i < numChoicesBox.value; i++) { 96 var newBullet = createNewElement("input", "radio", "bullet"+i, "questionParamField","i"); 97 content.appendChild(newBullet); 159 var checkbox = document.getElementById("legendsEnabledCheckbox"); 160 var upperLegendBox = document.getElementById("upperLegendBox"); 161 var lowerLegendBox = document.getElementById("lowerLegendBox"); 162 if (checkbox.checked == true) { 163 upperLegendBox.disabled = false; 164 lowerLegendBox.disabled = false; 165 } 166 else { 167 upperLegendBox.disabled = true; 168 lowerLegendBox.disabled = true; 169 } 170 } 171 172 /////////////////////////////// 173 /* MULTIPLE CHOICE SELECTION */ 174 /////////////////////////////// 175 176 function selectChoiceType() { 177 var selectionBox = document.getElementById("questionType"); 178 var content = document.getElementById("questionEditor_questionParams"); 179 } 180 181 function resizeTextArea() { 182 var textArea = document.getElementById("questionEditor_bodyText"); 183 if (document.getElementById("hiddenScalingDiv")) { 184 var hiddenDiv = document.getElementById("hiddenScalingDiv"); 185 } 186 else { 187 var hiddenDiv = document.createElement("div"); 188 hiddenDiv.style.visibility = "hidden"; 189 textArea.appendChild(hiddenDiv); 98 190 } 99 191 192 debugger; 193 hiddenDiv.innerHTML = ""; 194 var userText = textArea.firstChild.valueOf().value; 195 alert(userText); 100 196 } 101 -
Dev/trunk/questionEditor.php
r175 r176 20 20 <div id="questionEditor"> 21 21 <div id="questionEditor_header"> 22 Editing: #QUESTION-IDENT-NO22 Editing: <span id="header_identifier">#QUESTION-IDENT-NO</span> 23 23 </div> 24 24 <div id="questionEditor_content"> 25 25 <h2>Question text:</h2> 26 26 <div id="questionEditor_bodyText"> 27 <textarea id="questionEditor_bodyText_textArea" >THIS IS THE QUESTION BODY TEXT. CLICK HERE TO EDIT!</textarea>27 <textarea id="questionEditor_bodyText_textArea" onKeyUp="resizeTextArea();">THIS IS THE QUESTION BODY TEXT. CLICK HERE TO EDIT!</textarea> 28 28 </div> 29 29 <div id="questionEditor_questionParams" > 30 Answer type: 30 <label for="questionIdentifierField" class="formLineBreak">Question tag:</label> <input type="text" id="questionIdentifierField" class="questionParamField" onChange="updateIdentifier();" /> 31 32 <label for="questionType" class="formLineBreak">Answer type:</label> 31 33 <select id="questionType" onChange="selectAnswerType();" class="questionParamField"> 32 34 <option value=""></option> … … 36 38 <option value="text">Text</option> 37 39 </select> 38 39 40 41 42 40 43 </div> 41 44 </div> 42 45 <div id="questionEditor_controls"> 43 <input type="button" value="Discard" />46 <input type="button" id="discard" value="Discard" /> 44 47 <input type="button" value="Save" /> 45 48 </div>
Note: See TracChangeset
for help on using the changeset viewer.