/** * Update insert/overwrite label * @param {Event} event (unused) * @param {Editor} editor Current editor * @param {string} newstate New overwrite state * @param {boolean=} doNotAnimate True if state should not be animated */ function _updateOverwriteLabel(event, editor, newstate, doNotAnimate) { if ($statusOverwrite.text() === (newstate ? Strings.STATUSBAR_OVERWRITE : Strings.STATUSBAR_INSERT)) { // label already up-to-date return; } $statusOverwrite.text(newstate ? Strings.STATUSBAR_OVERWRITE : Strings.STATUSBAR_INSERT); if (!doNotAnimate) { AnimationUtils.animateUsingClass($statusOverwrite[0], "flash", 1500); } }
ModalBar.prototype.close = function (restoreScrollPos, animate) { if (restoreScrollPos === undefined) { restoreScrollPos = true; } if (animate === undefined) { animate = true; } // Store our height before closing, while we can still measure it var result = new $.Deferred(), barHeight = this.height(), self = this; function doRemove() { self._$root.remove(); result.resolve(); } if (this._autoClose) { window.document.body.removeEventListener("focusin", this._handleFocusChange, true); } if (animate) { AnimationUtils.animateUsingClass(this._$root.get(0), "modal-bar-hide") .done(doRemove); } else { doRemove(); } // Preserve scroll position of the current full editor across the editor refresh, adjusting for the // height of the modal bar so the code doesn't appear to shift if possible. var fullEditor = EditorManager.getCurrentFullEditor(), scrollPos; if (restoreScrollPos && fullEditor) { scrollPos = fullEditor.getScrollPos(); } EditorManager.resizeEditor(); if (restoreScrollPos && fullEditor) { fullEditor._codeMirror.scrollTo(scrollPos.x, scrollPos.y - barHeight); } EditorManager.focusEditor(); return result.promise(); };
ModalBar.prototype.close = function (restoreScrollPos, animate) { var result = new $.Deferred(), self = this; if (restoreScrollPos === undefined) { restoreScrollPos = true; } if (animate === undefined) { animate = true; } // If someone hasn't already called `prepareClose()` to pop the ModalBar out of the flow // and resize the editor, then do that here. if (!this._$root.hasClass("popout")) { this.prepareClose(restoreScrollPos); } if (this._autoClose) { window.document.body.removeEventListener("focusin", this._handleFocusChange, true); } $(this).triggerHandler("close"); function doRemove() { self._$root.remove(); result.resolve(); } if (animate) { AnimationUtils.animateUsingClass(this._$root.get(0), "offscreen") .done(doRemove); } else { doRemove(); } EditorManager.focusEditor(); return result.promise(); };