Ignore:
Timestamp:
01/17/12 18:17:51 (13 years ago)
Author:
fpvanagthoven
Message:
  • Faal met perongeluk de database committen-_- Maar is weer deleted, zou nu weer moeten werken.
  • QuestionEditor? werkt nu grotendeels, paar kleine afwerkingsfoutjes (en data die nog niet in de DB passen)
  • selectQuestion scherm gemaakt, is nog niet zo multifunctioneel als je zou hopen. Ideaal gezien zou dit ipv een statische PHP pagina, een JS driven widget worden die je bijvoorbeeld kan gebruiken voor "Add existing question" in de surveyEditor.
  • Zelfde voor selectApplication.php en selectSurvey.php.
  • objectSelectionWidget class maken voor dit doeleind? (Na demo!)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jos-branch/js/sequencerScripts.js

    r233 r237  
    123123}
    124124
     125function setSequencerSize() {
     126    var seqContent = ge("seqContent");
     127    switch (sequencer.settings.content.orientation.toLowerCase()) {
     128        case "vertical":
     129            var availHeight = window.innerHeight;
     130            var yOffset = getPos(seqContent).Y;
     131            var bottomControlsHeight = 36;
     132            var bottomMargin = 12;
     133            sequencer.settings.content.height = (availHeight - yOffset - bottomControlsHeight - bottomMargin);
     134            sequencer.settings.content.width = 665;
     135            seqContent.style.height = sequencer.settings.content.height+"px";
     136            seqContent.style.width = sequencer.settings.content.width+"px";
     137            addClass(seqContent, "vertical");
     138            break;
     139        case "horizontal":
     140            sequencer.settings.content.width = 800;
     141            sequencer.settings.content.height = 125;
     142            seqContent.style.height = sequencer.settings.content.height+"px";
     143            seqContent.style.width = sequencer.settings.content.width+"px";
     144            addClass(seqContent, "horizontal");
     145            break;
     146        default:
     147            break;
     148    }
     149}
     150
    125151function initSequencer() {
    126152    // Called from loadSequencer(). Sets sequencer.settings properties depending on content type and values passed by PHP in hidden fields (currently only one), then removes these fields.
     
    129155    // load settings fields first
    130156    var fContentType = ge("sContentTypeField");
    131     var content = ge("seqContent");
    132     //sequencer.settings.content.contentType = fContentType.value.toLowerCase();
    133157    sequencer.settings.content.contentType = fContentType.value;
    134158    //Then select settings from a few presets
    135    
    136159    switch (sequencer.settings.content.contentType.toLowerCase()) {
    137160        case "session":
    138161            sequencer.settings.content.orientation = "horizontal";
    139             sequencer.settings.content.width = 800;
    140             sequencer.settings.content.height = 125;
    141             content.style.width = sequencer.settings.content.width+"px";
    142             content.style.height = sequencer.settings.content.height+"px";
    143             addClass(content, "horizontal");
    144162            break;
    145163        case "survey":
    146164            sequencer.settings.content.orientation = "vertical";
    147             sequencer.settings.content.width = 650;     //guesstimated
    148             var roomH = screen.availHeight;
    149             sequencer.settings.content.height = roomH - 200;
    150             content.style.width = sequencer.settings.content.width+"px";
    151             content.style.height = sequencer.settings.content.height+"px";
    152             addClass(content, "vertical");
    153165            break;
    154166        default:
     
    156168    }
    157169    fContentType.parentNode.parentNode.removeChild(fContentType.parentNode);
     170   
     171    window.addEventListener("load", setSequencerSize, true);
    158172}
    159173
     
    230244        requestString = "args="+JSON.stringify(args);
    231245        newAjaxRequest(requestString, "returnObjectDisplay.php", function(result){
    232             console.log(result.responseText);
     246            //console.log(result.responseText);
    233247            insertNewObjects(result.responseText, needsUpdating);
    234248        }, true);
     
    279293        requestString = "args="+JSON.stringify(args);
    280294        newAjaxRequest(requestString, "returnObjectDisplay.php", function(result){
    281             console.log(result.responseText);
     295            //console.log(result.responseText);
    282296            content.removeChild(loadingGif);
    283297            insertNewObjects(result.responseText, needsUpdating);
     
    392406    //console.log(responseText);
    393407    // Container function that calls different insertNewX() functions depending on content type. Called from updateSequencer().
    394     console.log(responseText);
     408    //console.log(responseText);
    395409    var response = JSON.parse(responseText);
    396410    // For now I assume that only one type of element can be displayed in the editor at one time. Therefore, the type of response[0] is the type of all elements of response.
     
    416430       
    417431    newAjaxRequest(c, u, function(result) {
    418         console.log(result.responseText);
     432        //console.log(result.responseText);
    419433        sequencer.survey.questions.uids.push(removeNL(result.responseText));
    420434        sequencer.survey.questions.upToDate.push(false);
     
    434448         */
    435449    if (!response || !response.length > 0) return;
    436     console.log(response);
     450    //console.log(response);
    437451   
    438452    var content = ge("seqContentWrapper");
     
    524538
    525539function insertNewQuestions(response, needsUpdating) {
     540    //TODO: QuestionDisplay ook classbased maken zoals de questionEditor?
     541   
    526542    //Code that inserts or replaces new object displays in the sequencer. Question version.
    527543    var content = ge("seqContentWrapper");
     
    571587        removeButton.className = "smallButton";
    572588        editButton.addEventListener("click", function(e){
    573             alert('Editing not yet supported!');
     589            var targ;
     590            if (!e) e = window.event;
     591            if (e.target) targ = e.target;
     592            else if (e.srcElement) targ = e.srcElement;
     593           
     594            do {
     595                targ = targ.parentNode;
     596            } while (!hasClass(targ, "question"));
     597           
     598            questionEditor.editQuestion(targ.id);
     599            e.stopPropagation();
    574600        }, false);
    575601        removeButton.addEventListener("click", function(e){
    576602            alert('Removing not yet supported!');
     603            e.stopPropagation();
    577604        }, false);
    578605        controlsDiv.appendChild(editButton);
     
    596623            }
    597624            else {
    598                 content.replaceChild(frameDiv, content.childNodes[needsUpdating[j][0]*2]);
     625                if (content.childNodes[needsUpdating[j][0]*2]) {
     626                    content.replaceChild(frameDiv, content.childNodes[needsUpdating[j][0]*2]);
     627                }
     628                else {
     629                    content.appendChild(frameDiv);
     630                    // HACK TIME!
     631                    for (var s = 0; s < content.childNodes.length; s++) {
     632                        if (hasClass(content.childNodes[s], "loading")) {
     633                            content.childNodes[s].parentNode.removeChild(content.childNodes[s]);
     634                        }
     635                    }
     636                    // Serieus, dit moet beter...
     637                }
    599638            }
    600639            sequencer.survey.questions.upToDate[needsUpdating[j][0]] = true;
     
    622661            request.questions.uids = sequencer.survey.questions.uids;
    623662            requestString = "args="+JSON.stringify(request);
    624             console.log(request);
     663            //console.log(request);
    625664            newAjaxRequest(requestString, url, function(result){
    626665                console.log(result.responseText);
     
    658697function selectStep(uid) {
    659698    // Called from clickStep(), manages CSS class assignment and updating of state variables. Also calls for info panel update.
    660    
     699    debugger;
    661700    var element = ge(uid);
    662701    if (element) {
     
    674713                break;
    675714        }
    676         (type != "survey") ? ajaxInfoRequest(uid, ge("infoPanelContent"), type) : type=type /*This does nothing*/;
     715        (type != "Question") ? ajaxInfoRequest(uid, ge("infoPanelContent"), type) : type=type /*This does nothing*/;
    677716        sequencer.state.selectedObject.uid = uid;
    678717        sequencer.state.selectedObject.index = null;  //Don't know how to do this yet.
     
    718757    requestString += "&sessionUid=";
    719758    requestString += sequencer.session.uid;
    720     console.log(requestString);
     759    //console.log(requestString);
    721760    newAjaxRequest(requestString, "savesession.php", function(result){
    722         console.log(result.responseText);
    723     }, true);
     761        //console.log(result.responseText);
     762        }, true);
    724763}
    725764
Note: See TracChangeset for help on using the changeset viewer.