![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-form/js/editor/UndoHistory.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UndoHistoryItem = UndoHistoryItem; exports.default = void 0; var _FCore = _interopRequireDefault(require("../core/FCore")); var _EventEmitter = _interopRequireDefault(require("absol/src/HTML5/EventEmitter")); var _Context = _interopRequireDefault(require("absol/src/AppPattern/Context")); require("../../css/undohistory.css"); var _R = _interopRequireDefault(require("../R")); var _BaseEditor = _interopRequireDefault(require("../core/BaseEditor")); var _Dom = _interopRequireDefault(require("absol/src/HTML5/Dom")); var _WindowManager = _interopRequireDefault(require("../dom/WindowManager")); var _ = _FCore.default._; var $ = _FCore.default.$; /** * @constructor */ function UndoHistory() { _BaseEditor.default.call(this); this._lastPosition = undefined; this.items = []; this.lastItemIndex = this.items.length - 1; } Object.defineProperties(UndoHistory.prototype, Object.getOwnPropertyDescriptors(_BaseEditor.default.prototype)); UndoHistory.prototype.constructor = UndoHistory; UndoHistory.prototype.CONFIG_STORE_KEY = "AS_UndoHistory_config"; UndoHistory.prototype.config = { windowStyle: { left: '57px', top: _Dom.default.getScreenSize().height - 230 + 'px' } }; UndoHistory.prototype.getView = function () { if (this.$view) return this.$view; this.$view = _({ attr: { tabIndex: '1' }, class: ['as-undo-history'], child: [{ class: 'as-undo-history-active-buttons', child: [{ tag: 'button', class: 'as-undo-history-active-undo', attr: { title: 'Undo' }, props: { disabled: true }, child: 'span.mdi.mdi-undo' }, { tag: 'button', class: 'as-undo-history-active-redo', attr: { title: 'Redo' }, props: { disabled: true }, child: 'span.mdi.mdi-redo' }, { class: 'as-undo-history-active-buttons-right-container', child: { tag: 'button', attr: { title: 'Clear' }, class: 'as-undo-history-active-clear', child: 'span.mdi.mdi-delete' } }] }, { tag: 'bscroller', class: ['as-undo-history-item-list'], child: this.items.map(function (item) { return item.getView(); }) }], on: { keydown: this.ev_cmdKeyDown.bind(this) } }); this.$list = $('.as-undo-history-item-list', this.$view); this.$undoBtn = $('button.as-undo-history-active-undo', this.$view).on('click', this.undo.bind(this)); this.$redoBtn = $('button.as-undo-history-active-redo', this.$view).on('click', this.redo.bind(this)); this.$clear = $('button.as-undo-history-active-clear', this.$view).on('click', this.clear.bind(this)); return this.$view; }; UndoHistory.prototype.checkout = function (item, viewOnly) { var cItem; var found = false; for (var i = this.items.length - 1; i >= 0; --i) { cItem = this.items[i]; if (cItem == item) { cItem.setActive(true); found = true; this.lastItemIndex = i; } else { cItem.setActive(false); } cItem.setDisabled(!found); } this.$list.scrollInto(item.getView()); this.$undoBtn.disabled = this.lastItemIndex <= 0; this.$redoBtn.disabled = this.lastItemIndex >= this.items.length - 1; if (!viewOnly) this.emit('checkout', { type: 'checkout', target: this, item: item }, this); }; UndoHistory.prototype.undo = function () { if (this.lastItemIndex > 0) { this.checkout(this.items[this.lastItemIndex - 1]); } }; UndoHistory.prototype.redo = function () { if (this.lastItemIndex < this.items.length - 1) { this.checkout(this.items[this.lastItemIndex + 1]); } }; UndoHistory.prototype.canUndo = function () { return this.lastItemIndex > 0; }; UndoHistory.prototype.canRedo = function () { return this.lastItemIndex < this.items.length - 1; }; /** * @param {String} type * @param {*} data * @param {String=} description * @param {Date=} timestamp */ UndoHistory.prototype.commit = function (type, data, description, timestamp) { var item; while (this.items.length > this.lastItemIndex + 1) { item = this.items.pop(); item.getView().remove(); } var res = new UndoHistoryItem(this, type, data, description, timestamp); this.items.push(res); this.$list.addChild(res.getView()); this.checkout(res, true); return res; }; UndoHistory.prototype.clear = function () { if (this.items.length < 2) return; var lastItem = this.items.pop(); var lastData = lastItem.data; lastItem.getView().remove(); while (this.items.length > 0) { lastItem = this.items.pop(); lastItem.getView().remove(); } this.commit('clear', lastData, 'Clear History'); }; UndoHistory.prototype.renew = function () { var lastItem; while (this.items.length > 0) { lastItem = this.items.pop(); lastItem.getView().remove(); } }; UndoHistory.prototype.ev_cmdKeyDown = function (event) { this.editor && this.editor.ev_cmdKeyDown(event); }; /** * @param {UndoHistory}parent * @param {String} type * @param {*} data * @param {String} description * @param {Date} timestamp */ function UndoHistoryItem(parent, type, data, description, timestamp) { this.parent = parent; this.type = type || 'edit'; this.data = data; this.description = description || 'Change'; this.timestamp = timestamp || new Date(); this._active = false; this._disabled = false; } /** * @typedef {string|"move"|"remove"|"edit-attribute"|"edit"|"add"|"set-data"|"move-resize"|"move-order"|"clear"|"cut"} UndoTypeNames */ UndoHistoryItem.prototype.typeIcon = { move: 'span.mdi.mdi-cursor-move', remove: 'span.mdi.mdi-delete-variant[style="color: rgb(255,59,59)"]', 'edit-attribute': 'span.mdi.mdi-circle-edit-outline', edit: 'span.mdi.mdi-circle-edit-outline', add: 'span.mdi.mdi-pen-plus', 'set-data': 'span.mdi.mdi-open-in-app', 'move-resize': 'span.mdi.mdi-move-resize', 'move-order': 'span.mdi.mdi-arrow-up-down-bold', 'clear': 'span.mdi.mdi-check-outline', 'cut': 'span.mdi.mdi-content-cut' }; UndoHistoryItem.prototype.setActive = function (bool) { this._active = !!bool; if (this.$view) { if (bool) { this.$view.addClass('as-undo-history-item-active'); } else { this.$view.removeClass('as-undo-history-item-active'); } } }; UndoHistoryItem.prototype.setDisabled = function (bool) { this._disabled = !!bool; if (this.$view) { if (bool) { this.$view.addClass('as-undo-history-item-disabled'); } else { this.$view.removeClass('as-undo-history-item-disabled'); } } }; UndoHistoryItem.prototype.getActive = function () { return this._active; }; UndoHistoryItem.prototype.getView = function () { if (this.$view) return this.$view; this.$view = _({ class: ['as-undo-history-item'].concat(this._active ? ['as-undo-history-item-active'] : []).concat(this._disabled ? ['as-undo-history-item-disabled'] : []), attr: { title: this.timestamp.toLocaleTimeString() }, child: [{ class: 'as-undo-history-item-icon-container', child: this.typeIcon[this.type] }, { text: this.description }], on: { click: this.ev_click.bind(this) } }); return this.$view; }; UndoHistoryItem.prototype.ev_click = function (event) { this.parent.checkout(this); }; var _default = UndoHistory; exports.default = _default;