![]() 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/gadevoir/app/fragment/ |
Upload File : |
import Fragment from "absol/src/AppPattern/Fragment"; import OOP from "absol/src/HTML5/OOP"; import {_} from "../dom/Core"; import '../../style/app.css'; import MainFrg from "./MainFrg"; import GPhone from "../GPhone"; /*** * @extends Fragment * @constructor */ function GadevoirApp(config) { Fragment.call(this); this.config = config; this.phone = new GPhone(); this._fragHolders = []; this.setContext("PHONE", this.phone); this.setContext("APP", this); this.sync = Promise.resolve(); } OOP.mixClass(GadevoirApp, Fragment); GadevoirApp.prototype.createView = function () { this.$view = _({ class: 'gdv-app' }); }; GadevoirApp.prototype.onStart = function () { this.phone.sync.then(this.startFrag.bind(this, MainFrg, {}, false)); }; /*** * * @param {Function} clazz * @param props * @param {boolean} [overlay = false] * @return {Promise<*>} */ GadevoirApp.prototype.startFrag = function (clazz, props, overlay) { var sameClazzHolder = this._fragHolders.find(function (holder) { return holder.frag.constructor === clazz; }); if (sameClazzHolder) { sameClazzHolder.frag.stop(); } var app = this; app.sync = app.sync.then(function () { app._pauseCurrentFragment(); var holder = {}; holder.frag = new clazz(props); holder.$ctn = _('.gdv-app-frag-ctn') .addChild(holder.frag.getView()); if (overlay) { holder.$ctn.addClass('gdv-overlay') .addStyle('left', '-100%') .addStyle('opacity', '0') .addStyle('transition', 'left 0.5s, opacity 0.5s'); setTimeout(function () { holder.$ctn.addStyle('left', '0') .addStyle('opacity', '1'); setTimeout(function () { holder.$ctn.removeStyle('transition'); }, 500); }, 1); } else { app.$view.clearChild(); } app.$view.addChild(holder.$ctn); var res = new Promise(function (resolve) { var onStop = holder.frag.onStop; holder.frag.onStop = function () { onStop && onStop.apply(this, arguments); app.sync = new Promise(function (resolve1) { setTimeout(function () { var cHolder; if (app._fragHolders.indexOf(holder) >= 0) { while (app._fragHolders.length > 0) { cHolder = app._fragHolders.pop(); cHolder.frag.destroy(); cHolder.$ctn.remove(); if (cHolder === holder) break; } } resolve(holder.frag.returns); resolve1(); app._resumeCurrentFragment(); }, 1) }); } }); app._fragHolders.push(holder); holder.frag.attach(app); holder.frag.start(); return { result: res }; }); return app.sync.then(function (ref) { return ref.result; }); }; GadevoirApp.prototype._pauseCurrentFragment = function () { var holder = this._fragHolders[this._fragHolders.length - 1]; if (holder && holder.frag.state === "RUNNING") holder.frag.pause(); }; GadevoirApp.prototype._resumeCurrentFragment = function () { var holder = this._fragHolders[this._fragHolders.length - 1]; if (holder) { if (!holder.frag.getView().isDescendantOf(this.$view)) { this.$view.addChild(holder.frag.getView()); } holder.frag.resume(); } }; export default GadevoirApp;