// Copyright (c) 2000, Macromedia, Inc. // http://www.macromedia.com/fireworks // Close All Documents.jsf // This command closes all of the open // documents and will prompt the user to // save them if they have not been saved. //Lets find out if there are any unsaved documents var numUnsavedDocs = 0; for (i = 0; i < fw.documents.length; i++) { if ( fw.documents[i].isDirty ) { numUnsavedDocs++; } } // We need to get the correct wording for the save dialog var save = true; if(numUnsavedDocs > 0) { var insertPhrase = ""; var Doc =""; if ( numUnsavedDocs >= 2 ){ insertPhrase = "There are unsaved documents. OK to save before closing?"; Doc = "documents"; }else { insertPhrase = "There is an unsaved document. OK to save before closing?"; Doc = "document"; } // Ask the user one time if they would like to save their documents save = confirm(insertPhrase); // Count backwards to always close the last document for (i = fw.documents.length - 1; i >= 0; i--) { // make the specified doc active fw.setActiveWindow(fw.documents[i], true); fw.documents[i].makeActive(); // if it is dirty, and the user selected save, save it if ( fw.documents[i].isDirty && save) { fw.documents[i].save(); // finally, close fw.documents[i].close(false); } } } // If you would like to have the close button close all of the documents without saving // then replace the following code with this commented out code. // Ask the user one time if they would like to save their documents // save = confirm(insertPhrase); // } // Count backwards to always close the last document // for (i = fw.documents.length - 1; i >= 0; i--) { // make the specified doc active // fw.setActiveWindow(fw.documents[i], true); // fw.documents[i].makeActive(); // if it is dirty, and the user selected save, save it // if ( fw.documents[i].isDirty && save) { // fw.documents[i].save(); // } // finally, close // fw.documents[i].close(false); // }