VulpesOS/assets/webapps/settings.gaiamobile.org/js/startup.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

12 lines
No EOL
5.3 KiB
JavaScript

(function(exports){'use strict';function InitialPanelHandler(rootElement){this._rootElement=rootElement;this._pendingTargetPanel=null;this._anchors=[];this._inputs=[];this._inputListenerInfos=[];this._settings=navigator.mozSettings;if(this._settings){this._init();}}
InitialPanelHandler.prototype={get pendingTargetPanel(){return this._pendingTargetPanel;},_addClickListeners:function iph_addClickListeners(){this._anchors=Array.prototype.slice.call(this._rootElement.querySelectorAll('li a[href]'));this._anchors.forEach(function(anchor){anchor.onclick=(event)=>{event.preventDefault();this._pendingTargetPanel=anchor.getAttribute('href');this._pendingTargetPanel=this._pendingTargetPanel.replace('#','');};},this);},_removeClickListeners:function iph_removeClickListeners(){this._anchors.forEach(function(anchor){anchor.onclick=null;});},_addInputListeners:function iph_addInputListeners(){this._inputs=Array.prototype.slice.call(this._rootElement.querySelectorAll('input[name]'));this._inputs.forEach(function(input){var name=input.getAttribute('name');var boundOnSettingChange=this._onSettingChange.bind(this,input);input.onchange=this._onInputChange.bind(this);this._settings.createLock().get(name).then((result)=>{this._updateInput(input,result[name]);});this._settings.addObserver(name,boundOnSettingChange);this._inputListenerInfos.push({name:name,handler:boundOnSettingChange});},this);},_removeInputListeners:function iph_removeInputListeners(){this._inputs.forEach(function(input){input.onchange=null;});this._inputListenerInfos.forEach(function(inputListenerInfo){this._settings.removeObserver(inputListenerInfo.name,inputListenerInfo.handler);},this);},_onSettingChange:function iph_onSettingChange(input,event){this._updateInput(input,event.settingValue);},_onInputChange:function iph_onInputChange(event){var input=event.target;var type=input.type;var key=input.name;if(!key||event.type!=='change'){return;}
if(input.dataset.setting){return;}
var value;switch(type){case'checkbox':case'switch':value=input.checked;break;case'range':value=parseFloat(parseFloat(input.value).toFixed(1));break;case'select-one':case'radio':case'text':case'password':value=input.value;if(input.dataset.valueType==='integer'){value=parseInt(value,10);}
break;}
var cset={};cset[key]=value;this._settings.createLock().set(cset);},_updateInput:function iph_updateInput(input,value){var i;var count;switch(input.type){case'checkbox':case'switch':if(input.checked===value){return;}
input.checked=value;break;case'range':if(input.value===value){return;}
input.value=value;break;case'select':for(i=0,count=input.options.length;i<count;i++){if(input.options[i].value===value){input.options[i].selected=true;break;}}
break;}},_init:function iph_init(){this._addClickListeners();this._addInputListeners();},release:function iph_release(){this._removeClickListeners();this._removeInputListeners();}};exports.InitialPanelHandler=function ctor_InitialPanelHandler(rootElement){return new InitialPanelHandler(rootElement);};})(window);(function(exports){'use strict';function AppStarter(){this._started=false;this._launchContext=null;}
AppStarter.prototype={_getInitialPanelId:function as_getInitialPanelId(){return new Promise(function(resolve){if(navigator.mozHasPendingMessage('activity')){LazyLoader.load(['js/activity_handler.js'],function ah_loaded(){window.ActivityHandler.ready().then(function ah_ready(){resolve(window.ActivityHandler.targetPanelId);});});}else{resolve('root');}});},_showInitialPanel:function as_showInitialPanel(initialPanelId){var initialPanel=document.getElementById(initialPanelId);return LazyLoader.load([initialPanel]).then(()=>{initialPanel.classList.add('current');});},_createLaunchContext:function as_createLaunchContext(initialPanelId,initialPanelHandler,activityHandler){this._launchContext={get initialPanelId(){return initialPanelId;},get initialPanelHandler(){return initialPanelHandler;},get activityHandler(){return activityHandler;}};var that=this;Object.defineProperty(exports,'LaunchContext',{configurable:true,get:function(){return that._launchContext;}});},_loadAlameda:function as_loadAlameda(){var scriptNode=document.createElement('script');scriptNode.setAttribute('data-main','js/main.js');scriptNode.src='js/vendor/alameda.js';document.head.appendChild(scriptNode);},start:function as_start(){if(this._started){return Promise.resolve();}else{this._started=true;}
document.l10n.ready.then(function l10nDone(){window.performance.mark('navigationLoaded');window.performance.mark('navigationInteractive');});var initialPanelId;return this._getInitialPanelId().then((panelId)=>{initialPanelId=panelId;return this._showInitialPanel(panelId);}).then(()=>{var initialPanelHandler=InitialPanelHandler(document.getElementById(initialPanelId));window.performance.mark('contentInteractive');this._createLaunchContext(initialPanelId,initialPanelHandler,window.ActivityHandler);}).then(()=>{return new Promise((resolve)=>{setTimeout(()=>{this._loadAlameda();resolve();},100);});});}};exports.AppStarter=function ctor_appStarter(){return new AppStarter();};})(window);(function(){'use strict';var appStarter=AppStarter();if(document.readyState!=='loading'){appStarter.start();}else{document.addEventListener('readystatechange',function readyStateChange(){if(document.readyState=='interactive'){document.removeEventListener('readystatechange',readyStateChange);appStarter.start();}});}})();