Changeset 240 for Dev/branches/jos-branch/js/sequencerScripts.js
- Timestamp:
- 01/18/12 17:13:25 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.