Ignore:
Timestamp:
2014-08-21T14:41:48+12:00 (10 years ago)
Author:
kjdon
Message:

working on the save stuff, and changing the buttons to be disabled. not quite working properly yet :-(

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/documentmaker_scripts_util.js

    r29225 r29226  
    165165}
    166166
     167function enableSaveButtons(enabled) {
     168  if (enabled) {
     169    $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
     170    $("#saveButton, #quickSaveButton").removeAttr("disabled");
     171
     172  } else {
     173    $("#saveButton, #quickSaveButton").html(gs.text.dse.saving + "...");
     174    $("#saveButton, #quickSaveButton").attr("disabled", "disabled");
     175   
     176  }
     177}
    167178function addCollectionToBuild(collection)
    168179{
     
    177188}
    178189
    179 function save()
     190function save() {
     191  saveAndRebuild(false);
     192}
     193
     194function rebuildCurrentCollection() {
     195
     196  console.log("rebuilding collection");
     197  enableSaveButtons(false);
     198  var collection = gs.cgiParams.c;
     199
     200  var collectionsArray = new Array();
     201  collectionsArray.push(collection);
     202  buildCollections(collectionsArray);
     203}
     204
     205function saveAndRebuild(rebuild)
    180206{
    181207//This works in most cases but will not work when taking a doc from one collection to another, will need to be fixed at some point
     
    218244                    alert(gs.text.dse.error_saving);
    219245               
    220                     $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    221                     $("#saveButton, #quickSaveButton").removeAttr("disabled");
     246                    enableSaveButtons(true);
    222247                   
    223248                    if(_statusBar)
     
    232257                    _statusBar.removeStatus(statusID);
    233258                }
    234                 buildCollections(_collectionsToBuild);
     259                if (rebuild) {
     260                  buildCollections(_collectionsToBuild);
     261                } else {
     262                  // reset the save button here
     263                  enableSaveButtons(true);
     264                }
    235265            }
    236266        }
     
    238268        if(_collectionsToBuild.length > 0)
    239269        {
    240             $("#saveButton, #quickSaveButton").html(gs.text.dse.saving + "...");
    241             $("#saveButton, #quickSaveButton").attr("disabled", "disabled");
     270          enableSaveButtons(false);
    242271
    243272            if(_statusBar)
     
    369398    {
    370399        console.log(gs.text.dse.empty_collection_list);
    371         $("#saveButton, #quickSaveButton").html(gs.text.save_changes);
    372         $("#saveButton, #quickSaveButton").removeAttr("disabled");
     400        enableSaveButtons(true);
    373401        return;
    374402    }
     
    415443                        _statusBar.removeStatus(statusID);
    416444                    }
    417                     $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    418                     $("#saveButton, #quickSaveButton").removeAttr("disabled");
     445                    enableSaveButtons(true);
    419446                   
    420447                    return;
     
    444471                                    _statusBar.removeStatus(statusID);
    445472                                }
    446                                 $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    447                                 $("#saveButton, #quickSaveButton").removeAttr("disabled");
     473                                enableSaveButtons(true);
    448474                               
    449475                                return;
     
    477503                                        _statusBar.removeStatus(statusID);
    478504                                    }
    479                                     $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    480                                     $("#saveButton, #quickSaveButton").removeAttr("disabled");
     505                                    enableSaveButtons(true);
    481506                                /*
    482507                                });
     
    523548                        _statusBar.removeStatus(statusID);
    524549                    }
    525                     $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    526                     $("#saveButton, #quickSaveButton").removeAttr("disabled");
     550                    enableSaveButtons(true);
    527551                   
    528552                    return;
     
    544568                        _statusBar.removeStatus(statusID);
    545569                    }
    546                     $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
    547                     $("#saveButton, #quickSaveButton").removeAttr("disabled");
     570                    enableSaveButtons(true);
    548571                }
    549572                else
     
    873896    var saveButton = document.createElement("BUTTON");
    874897    saveButton.innerHTML = gs.text.dse.save_changes;
    875     saveButton.setAttribute("onclick", "save();");
     898    saveButton.setAttribute("onclick", "saveAndRebuild();");
    876899    saveButton.setAttribute("id", "saveButton");
    877900    saveCell.appendChild(saveButton);
Note: See TracChangeset for help on using the changeset viewer.