B2G/gecko/browser/devtools/scratchpad/scratchpad.js
/**
   * Prompt to save scratchpad if it has unsaved changes.
   *
   * @param function aCallback
   *        Optional function you want to call when file is saved. The callback
   *        receives three arguments:
   *          - toClose (boolean) - tells if the window should be closed.
   *          - saved (boolen) - tells if the file has been saved.
   *          - status (number) - the file save status result (if the file was
   *          saved).
   * @return boolean
   *         Whether the window should be closed
   */
Prompt to save scratchpad if it has unsaved changes.
@param function aCallback
Optional function you want to call when file is saved. The callback
receives three arguments:
- toClose (boolean) - tells if the window should be closed.
- saved (boolen) - tells if the file has been saved.
- status (number) - the file save status result (if the file was
saved).
@return boolean
Whether the window should be closed
Prompt to save scratchpad if it has unsaved changes . @param function aCallback Optional function you want to call when file is saved . The callback receives three arguments : - toClose ( boolean ) - tells if the window should be closed . - saved ( boolen ) - tells if the file has been saved . - status ( number ) - the file save status result ( if the file was saved ) . @return boolean Whether the window should be closed
function SP_promptSave(aCallback)
  {
    if (this.filename && this.editor.dirty) {
      let ps = Services.prompt;
      let flags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_SAVE +
                  ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL +
                  ps.BUTTON_POS_2 * ps.BUTTON_TITLE_DONT_SAVE;
      let button = ps.confirmEx(window,
                          this.strings.GetStringFromName("confirmClose.title"),
                          this.strings.GetStringFromName("confirmClose"),
                          flags, null, null, null, null, {});
      if (button == BUTTON_POSITION_CANCEL) {
        if (aCallback) {
          aCallback(false, false);
        }
        return false;
      }
      if (button == BUTTON_POSITION_SAVE) {
        this.saveFile(function(aStatus) {
          if (aCallback) {
            aCallback(true, true, aStatus);
          }
        });
        return true;
      }
    }
    if (aCallback) {
      aCallback(true, false);
    }
    return true;
  }
function SP_promptSave ( aCallback ) { if ( this . filename && this . editor . dirty ) { let ps = Services . prompt ; let flags = ps . BUTTON_POS_0 * ps . BUTTON_TITLE_SAVE + ps . BUTTON_POS_1 * ps . BUTTON_TITLE_CANCEL + ps . BUTTON_POS_2 * ps . BUTTON_TITLE_DONT_SAVE ; let button = ps . confirmEx ( window , this . strings . GetStringFromName ( "confirmClose.title" ) , this . strings . GetStringFromName ( "confirmClose" ) , flags , null , null , null , null , { } ) ; if ( button == BUTTON_POSITION_CANCEL ) { if ( aCallback ) { aCallback ( false , false ) ; } return false ; } if ( button == BUTTON_POSITION_SAVE ) { this . saveFile ( function ( aStatus ) { if ( aCallback ) { aCallback ( true , true , aStatus ) ; } } ) ; return true ; } } if ( aCallback ) { aCallback ( true , false ) ; } return true ; }
Prompt to save scratchpad if it has unsaved changes.
Prompt to save scratchpad if it has unsaved changes .