Changeset 240
- Timestamp:
- 01/18/12 17:13:25 (13 years ago)
- Location:
- Dev/branches/jos-branch
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/js/questionEditorScripts.js
r238 r240 24 24 // Properties 25 25 this.uid = null; // The uid of the question contained in this editor 26 this.saved = false; // Whether or not the question displayed in the editor has been saved already.27 26 var me = this; // Retarded self-reference because: Javascript 28 27 this.element = null; // The parent div element containing the questionEditor … … 72 71 } 73 72 } 74 this.init = function( ) {73 this.init = function(uid) { 75 74 // Outer div 76 75 this.saved = false; … … 78 77 me.element.className = "smallFrame questionEditor"; 79 78 me.element.id = sequencer.state.selectedObject.uid; 80 me.uid = sequencer.state.selectedObject.uid;79 me.uid = uid; 81 80 // Header 82 81 var titleDiv = ce("div"); … … 176 175 "title": ge("qeTitleField").innerHTML, 177 176 "code": ge("qeCodeField").value, 178 "description": ge("qeBodyTextField").value 177 "description": ge("qeBodyTextField").value, 178 "uid": me.uid 179 179 } 180 180 … … 221 221 // Then add the returned uid, if existing, to the sequencer.survey.questions array and set it for update 222 222 debugger; 223 console.log(result.responseText); 223 224 var response = JSON.parse(result.responseText); 224 225 console.log(response); … … 250 251 } 251 252 this.discard = function() { 252 debugger; 253 me.element.parentNode.removeChild(me.element); 254 me.init(); 255 sequencer.state.loaded = true; 256 sequencer.state.editing = false; 257 sequencer.survey.questions.upToDate[sequencer.survey.questions.uids.indexOf(me.uid)] = false; 258 updateSequencer(); 253 debugger; 254 me.element.parentNode.removeChild(me.element); 255 sequencer.state.loaded = true; 256 sequencer.state.editing = false; 257 sequencer.survey.questions.upToDate[sequencer.survey.questions.uids.indexOf(me.uid)] = false; 258 updateSequencer(); 259 259 260 260 } … … 476 476 uid: uid 477 477 }); 478 me.init( );478 me.init(uid); 479 479 var oldElement = ge(uid); 480 480 if (oldElement) { … … 494 494 sequencer.state.editing = true; 495 495 496 me. reset();496 me.init(null); 497 497 var container = ge("seqContentWrapper"); 498 498 container.appendChild(me.element); -
Dev/branches/jos-branch/js/sequencerScripts.js
r238 r240 178 178 179 179 /* 180 181 182 183 180 * Description: 181 * This function updates the visual elements in the sequencer content view to match the current state of the sequencer.session.pipeline property. 182 * It queries the database for object properties via AJAX (returnStep/Display/.php), then inserts divider div's in between where needed. 183 */ 184 184 185 185 switch (sequencer.settings.content.contentType.toLowerCase()) { … … 262 262 } 263 263 updateDividers(); 264 // End optional264 // End optional 265 265 } 266 266 } … … 325 325 326 326 // Optional bit with the loading GIF 327 for (var i = 0; i < needsUpdating.length; i++) { 328 var loadingDiv = ce("div"); 329 loadingDiv.className = "displayStep loading"; 330 loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />"; 331 if (needsUpdating[i][0] > sequencer.state.numSteps-1) { 332 content.appendChild(loadingDiv); 333 sequencer.state.numSteps++; 334 } 335 else { 336 content.replaceChild(loadingDiv, content.childNodes[i][0]*2); 327 if (sequencer.settings.content.contentType.toLowerCase() != "survey"){ 328 for (var i = 0; i < needsUpdating.length; i++) { 329 var loadingDiv = ce("div"); 330 loadingDiv.className = "displayStep loading"; 331 loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />"; 332 if (needsUpdating[i][0] > sequencer.state.numSteps-1) { 333 content.appendChild(loadingDiv); 334 sequencer.state.numSteps++; 335 } 336 else { 337 content.replaceChild(loadingDiv, content.childNodes[i][0]*2); 338 } 337 339 } 338 340 } 339 341 updateDividers(); 340 // End optional342 // End optional 341 343 342 344 } … … 441 443 function insertNewSteps(response, needsUpdating) { 442 444 /* 443 444 445 446 447 448 445 * This is a function displaying how to handle the visual object representation in solely javascript. 446 * Communication of relevant variables between PHP and JS happens in JSON format. 447 * PHP returns a JSON array of objects to be created by JS 448 * JS then loops through this array and creates DIVS to be inserted into the sequencer. 449 * These are inserted at the position needsUpdating gives us. 450 */ 449 451 if (!response || !response.length > 0) return; 450 452 //console.log(response); … … 760 762 newAjaxRequest(requestString, "savesession.php", function(result){ 761 763 console.log(result.responseText); 762 764 }, true); 763 765 } 764 766 … … 838 840 839 841 840 // The alternative is to use event bubbling to capture the event on a higher level.841 // Basically, we bind a super-structure onclick event that uses e.target|| event.srcElement to determine which element to move and select.842 // http://stackoverflow.com/questions/29624/how-to-maintain-correct-javascript-event-after-using-clonenodetrue843 // Pro: clean implementation, less events binded.844 // Con: Difficult, this already works fine, probably tougher to use in conjunction with multifunctionality (sessions, surveys, questionsets, etc in one kind of editor)842 // The alternative is to use event bubbling to capture the event on a higher level. 843 // Basically, we bind a super-structure onclick event that uses e.target|| event.srcElement to determine which element to move and select. 844 // http://stackoverflow.com/questions/29624/how-to-maintain-correct-javascript-event-after-using-clonenodetrue 845 // Pro: clean implementation, less events binded. 846 // Con: Difficult, this already works fine, probably tougher to use in conjunction with multifunctionality (sessions, surveys, questionsets, etc in one kind of editor) 845 847 846 848 } … … 864 866 // Derp, natuurlijk werkt de addQuestion call niet twee keer. Hij creeert twee keer exact hetzelfde object. Bottom line: het werkt. Nu de editing code voor deze questions gaan schrijven! 865 867 var response = [{ 866 uid: "1234567890testuid",867 title: "dummyQuestion",868 description: "This is a dummy question, not a real one!",869 type: "question"870 }];868 uid: "1234567890testuid", 869 title: "dummyQuestion", 870 description: "This is a dummy question, not a real one!", 871 type: "question" 872 }]; 871 873 872 874 var needsUpdating = [[ 873 0,874 "1234567890testuid",875 "question"876 ]];875 0, 876 "1234567890testuid", 877 "question" 878 ]]; 877 879 878 880 insertNewQuestions(response, needsUpdating); -
Dev/branches/jos-branch/setQuestion.php
r237 r240 13 13 $question_results = Question::get(array("uid" => $input->uid)); 14 14 if (!empty($question_results)) { 15 $question = $question s[0];15 $question = $question_results[0]; 16 16 } else { 17 17 die("Error: attempt to edit a non-existing database object!"); … … 22 22 if ($input->title) $question->title = $input->title; 23 23 if ($input->description) $question->description = $input->description; 24 if ( $input->category) $question->category = null;25 if ( $input->answers) $question->answers = null;24 if (isset($input->category) ) $question->category = null; 25 if (isset($input->answers)) $question->answers = null; 26 26 $question->save(); 27 27 $outputArray = array("created"=>false, "uid"=>$question->uid);
Note: See TracChangeset
for help on using the changeset viewer.