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.
This commit is contained in:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,5 @@
;'use strict';(function(exports){var AbortablePromiseQueueError=function(currentId,expectedId){this.currentId=currentId;this.expectedId=expectedId;};AbortablePromiseQueueError.prototype.name='AbortablePromiseQueueError';AbortablePromiseQueueError.prototype.message='The current task group ID does not match.';var AbortablePromiseQueue=function AbortablePromiseQueue(){this._started=false;this._taskGroupId=0;this._queuedTasks=null;};AbortablePromiseQueue.prototype.start=function(){if(this._started){throw new Error('AbortablePromiseQueue: Should not be start()\'ed twice.');}
this._started=true;this._queuedTasks=Promise.resolve();};AbortablePromiseQueue.prototype.stop=function(){if(!this._started){throw new Error('AbortablePromiseQueue: '+'Was not start()\'ed but stop() is called.');}
this._started=false;this.abort();this._queuedTasks=null;this._taskGroupId=0;};AbortablePromiseQueue.prototype.run=function(tasks){this.abort();var idCheck=this._getIdCheckFunction();tasks.forEach(function(task){this._queuedTasks=this._queuedTasks.then(idCheck).then(task);},this);this._queuedTasks=this._queuedTasks.catch(function(e){if(e instanceof AbortablePromiseQueueError){return;}
(e!==undefined)&&console.error(e);});return this._queuedTasks;};AbortablePromiseQueue.prototype.abort=function(){this._taskGroupId++;};AbortablePromiseQueue.prototype._getIdCheckFunction=function(){var id=this._taskGroupId;return function __taskGroupIdCheck(value){if(id!==this._taskGroupId){return Promise.reject(new AbortablePromiseQueueError(this._taskGroupId,id));}
return value;}.bind(this);};exports.AbortablePromiseQueue=AbortablePromiseQueue;})(window);

View file

@ -0,0 +1,19 @@
;'use strict';(function(exports){var ActiveTargetsManager=function(app){this.app=app;this.activeTargets=null;this.blockNewUserPress=false;this.blockTargetMovedOut=false;this.userPressManager=null;this.alternativesCharMenuManager=null;this.longPressTimer=undefined;this.doubleTapTimer=undefined;this.doubleTapPreviousTarget=null;};ActiveTargetsManager.prototype.ontargetactivated=null;ActiveTargetsManager.prototype.ontargetlongpressed=null;ActiveTargetsManager.prototype.ontargetmoved=null;ActiveTargetsManager.prototype.ontargetmovedout=null;ActiveTargetsManager.prototype.ontargetmovedin=null;ActiveTargetsManager.prototype.ontargetcommitted=null;ActiveTargetsManager.prototype.ontargetcancelled=null;ActiveTargetsManager.prototype.ontargetdoubletapped=null;ActiveTargetsManager.prototype.onnewtargetwillactivate=null;ActiveTargetsManager.prototype.LONG_PRESS_TIMEOUT=700;ActiveTargetsManager.prototype.DOUBLE_TAP_TIMEOUT=450;ActiveTargetsManager.prototype.start=function(){this.app.console.log('ActiveTargetsManager.start()');this.activeTargets=new Map();var userPressManager=this.userPressManager=new UserPressManager(this.app);userPressManager.onpressstart=this._handlePressStart.bind(this);userPressManager.onpressmove=this._handlePressMove.bind(this);userPressManager.onpressend=this._handlePressEnd.bind(this);userPressManager.start();this.alternativesCharMenuManager=new AlternativesCharMenuManager(this.app);this.alternativesCharMenuManager.start();};ActiveTargetsManager.prototype.stop=function(){this.app.console.log('ActiveTargetsManager.stop()');this.activeTargets=null;this.userPressManager.stop();this.userPressManager=null;this.alternativesCharMenuManager.stop();this.alternativesCharMenuManager=null;clearTimeout(this.longPressTimer);this.doubleTapTimer=undefined;this.doubleTapPreviousTarget=null;};ActiveTargetsManager.prototype.clearAllTargets=function(){this.app.console.log('ActiveTargetsManager.clearAllTargets()');if(this.activeTargets.size){console.warn('ActiveTargetsManager: clear '+
this.activeTargets.size+' active target(s).');}
this.activeTargets.forEach(function(target,id){if(typeof this.ontargetcancelled==='function'){this.ontargetcancelled(target);}},this);this.activeTargets.clear();this.alternativesCharMenuManager.hide();clearTimeout(this.longPressTimer);};ActiveTargetsManager.prototype._handlePressStart=function(press,id){this.app.console.log('ActiveTargetsManager._handlePressStart()');if(this.blockNewUserPress||this.alternativesCharMenuManager.isShown){return;}
if(typeof this.onnewtargetwillactivate==='function'){this.activeTargets.forEach(function(target,id){this.onnewtargetwillactivate(target);},this);}
var target=press.target;this.activeTargets.set(id,target);if(typeof this.ontargetactivated==='function'){this.ontargetactivated(target,press);}
clearTimeout(this.longPressTimer);if(this.activeTargets.size===1){this.longPressTimer=setTimeout(this._handleLongPress.bind(this,press,id),this.LONG_PRESS_TIMEOUT);}};ActiveTargetsManager.prototype._handlePressMove=function(press,id){this.app.console.log('ActiveTargetsManager._handlePressMove()');if(!this.activeTargets.has(id)){return;}
var target=press.target;if(this.alternativesCharMenuManager.isShown&&this.alternativesCharMenuManager.isInMenuArea(press)){target=this.alternativesCharMenuManager.getMenuTarget(press);}
if(!target){return;}
var oldTarget=this.activeTargets.get(id);if(press.moved&&('selection'in oldTarget)){this.activeTargets.delete(id);this.ontargetcancelled(oldTarget);this.alternativesCharMenuManager.hide();clearTimeout(this.longPressTimer);return;}
if(target===oldTarget){if(typeof this.ontargetmoved==='function'){this.ontargetmoved(target,press);}
return;}
if(this.blockTargetMovedOut){return;}
this.activeTargets.set(id,target);if(typeof this.ontargetmovedout==='function'){this.ontargetmovedout(oldTarget,press);}
if(typeof this.ontargetmovedin==='function'){this.ontargetmovedin(target,press);}
if(!this.alternativesCharMenuManager.isMenuTarget(target)&&!this.alternativesCharMenuManager.isInMenuArea(press)){this.alternativesCharMenuManager.hide();}
clearTimeout(this.longPressTimer);if(this.activeTargets.size===1){this.longPressTimer=setTimeout(this._handleLongPress.bind(this,press,id),this.LONG_PRESS_TIMEOUT);}};ActiveTargetsManager.prototype._handleLongPress=function(press,id){this.app.console.log('ActiveTargetsManager._handleLongPress()');if(!this.activeTargets.has(id)){return;}
var target=this.activeTargets.get(id);if(typeof this.ontargetlongpressed==='function'){this.ontargetlongpressed(target);}
this.alternativesCharMenuManager.show(target);if(this.alternativesCharMenuManager.isShown){this._handlePressMove(press,id);}};ActiveTargetsManager.prototype._handlePressEnd=function(press,id){this.app.console.log('ActiveTargetsManager._handlePressEnd()');if(!this.activeTargets.has(id)){return;}
var target=this.activeTargets.get(id);this.activeTargets.delete(id);this.alternativesCharMenuManager.hide();clearTimeout(this.longPressTimer);if(this.doubleTapTimer&&this.doubleTapPreviousTarget===target){window.clearTimeout(this.doubleTapTimer);this.doubleTapTimer=undefined;this.doubleTapPreviousTarget=null;if(typeof this.ontargetdoubletapped==='function'){this.ontargetdoubletapped(target);}}else{window.clearTimeout(this.doubleTapTimer);this.doubleTapTimer=window.setTimeout(function(){this.doubleTapTimer=undefined;this.doubleTapPreviousTarget=null;}.bind(this),this.DOUBLE_TAP_TIMEOUT);this.doubleTapPreviousTarget=target;if(typeof this.ontargetcommitted==='function'){this.ontargetcommitted(target);}}};exports.ActiveTargetsManager=ActiveTargetsManager;})(window);

View file

@ -0,0 +1,8 @@
;'use strict';(function(exports){var AlternativesCharMenuManager=function(app){this.app=app;this.isShown=false;this._originalTarget=null;this._menuAreaTop=this._menuAreaLeft=this._menuAreaRight=this._menuAreaBottom=0;};AlternativesCharMenuManager.prototype.start=function(){this._currentMenuView=null;};AlternativesCharMenuManager.prototype.stop=function(){this._currentMenuView=null;};AlternativesCharMenuManager.prototype.show=function(target){var alternatives=this._getAlternativesForTarget(target);if(!alternatives){return;}
var viewManager=this.app.viewManager;var targetRect=viewManager.getView(target).element.getBoundingClientRect();this._currentMenuView=viewManager.showAlternativesCharMenu(target,alternatives);this.isShown=true;this._originalTarget=target;var menuRect=this._currentMenuView.getBoundingClientRect();this._menuAreaTop=menuRect.top;this._menuAreaLeft=Math.min(targetRect.left,menuRect.left);this._menuAreaLeft-=targetRect.width;this._menuAreaBottom=targetRect.bottom;this._menuAreaRight=Math.max(targetRect.right,menuRect.right);this._menuAreaRight+=targetRect.width;};AlternativesCharMenuManager.prototype._getAlternativesForTarget=function _getAlternativesForTarget(key){var alternatives;var altMap=this.app.layoutManager.currentPage.alt;var origKey=null;if(this.app.upperCaseStateManager.isUpperCaseLocked){origKey=key.uppercaseValue;alternatives=altMap[origKey]&&(altMap[origKey].upperCaseLocked||altMap[origKey]);}else if(this.app.upperCaseStateManager.isUpperCase){origKey=key.uppercaseValue;alternatives=altMap[origKey];}else{origKey=key.lowercaseValue;alternatives=altMap[origKey];}
if(!alternatives||!alternatives.length){return false;}
return[].concat(origKey,alternatives);};AlternativesCharMenuManager.prototype.hide=function(){if(!this.isShown){return;}
this.app.viewManager.hideAlternativesCharMenu();this.isShown=false;this._originalTarget=null;this._menuAreaTop=this._menuAreaLeft=this._menuAreaRight=this._menuAreaBottom=0;this._currentMenuView=null;};AlternativesCharMenuManager.prototype.isMenuTarget=function(target){if(!this._currentMenuView){return false;}
return this._currentMenuView.isMenuTarget(target);};AlternativesCharMenuManager.prototype.getMenuTarget=function(press){if(!this.isShown){throw new Error('AlternativesCharMenuManager: '+'getMenuTarget called but menu is not shown');}
return this._currentMenuView.getMenuTarget(press.clientX,press.clientY);};AlternativesCharMenuManager.prototype.isInMenuArea=function(press){if(!this.isShown){return false;}
return(press.clientY>=this._menuAreaTop&&press.clientY<=this._menuAreaBottom&&press.clientX>=this._menuAreaLeft&&press.clientX<=this._menuAreaRight);};exports.AlternativesCharMenuManager=AlternativesCharMenuManager;})(window);

View file

@ -0,0 +1 @@
;'use strict';(function(exports){var app=new KeyboardApp();app.start();exports.app=app;})(window);

View file

@ -0,0 +1,6 @@
;'use strict';(function(exports){var CandidatePanelScrollingMonitor=function(app){this.app=app;this.scrollTimer=undefined;};CandidatePanelScrollingMonitor.prototype.SCROLL_END_WAIT_MS=200;CandidatePanelScrollingMonitor.prototype.onneedcandidates=null;CandidatePanelScrollingMonitor.prototype.start=function(){};CandidatePanelScrollingMonitor.prototype.stop=function(){clearTimeout(this.scrollTimer);var candidatePanel=this.app.viewManager.candidatePanel;if(candidatePanel){var suggestionsContainer=candidatePanel.querySelector('.suggestions-container');suggestionsContainer.removeEventListener('scroll',this);}};CandidatePanelScrollingMonitor.prototype.handleEvent=function(evt){var panel=evt.target;clearTimeout(this.scrollTimer);if(panel.scrollTop===0||(panel.scrollHeight-panel.clientHeight-panel.scrollTop)>=5){return;}
this.scrollTimer=setTimeout(function(){if(typeof this.onneedcandidates==='function'){this.onneedcandidates();}}.bind(this),this.SCROLL_END_WAIT_MS);};CandidatePanelScrollingMonitor.prototype.startMonitoring=function(){var candidatePanel=this.app.viewManager.candidatePanel;if('truncated'in candidatePanel.dataset){var suggestionsContainer=candidatePanel.querySelector('.suggestions-container');suggestionsContainer.addEventListener('scroll',this);}};CandidatePanelScrollingMonitor.prototype.stopMonitoring=function(){clearTimeout(this.scrollTimer);var suggestionsContainer=this.app.viewManager.candidatePanel.querySelector('.suggestions-container');suggestionsContainer.removeEventListener('scroll',this);};var CandidatePanelManager=function(app){this.app=app;this.currentCandidates=null;this.isFullPanelShown=undefined;this.scrollingMonitor=null;};CandidatePanelManager.prototype.FIRST_PAGE_ROWS=11;CandidatePanelManager.prototype.PAGE_ROWS=12;CandidatePanelManager.prototype.oncandidateschange=null;CandidatePanelManager.prototype.start=function(){this.currentCandidates=[];this.isFullPanelShown=false;this.scrollingMonitor=new CandidatePanelScrollingMonitor(this.app);this.scrollingMonitor.start();this.scrollingMonitor.onneedcandidates=this.showNextCandidatePage.bind(this);};CandidatePanelManager.prototype.stop=function(){this.scrollingMonitor.stop();this.scrollingMonitor=null;this.isFullPanelShown=undefined;};CandidatePanelManager.prototype.showNextCandidatePage=function(){var numberOfCandidatesPerRow=this.app.viewManager.getNumberOfCandidatesPerRow();var candidatePanel=this.app.viewManager.candidatePanel;var candidateIndicator=parseInt(candidatePanel.dataset.candidateIndicator,10);var engine=this.app.inputMethodManager.currentIMEngine;if(typeof engine.getMoreCandidates==='function'){engine.getMoreCandidates(candidateIndicator,this.PAGE_ROWS*numberOfCandidatesPerRow+1,this.app.viewManager.showMoreCandidates.bind(this.app.viewManager,this.PAGE_ROWS));}else{var list=this.currentCandidates.slice(candidateIndicator,candidateIndicator+this.PAGE_ROWS*numberOfCandidatesPerRow+1);this.app.viewManager.showMoreCandidates(this.PAGE_ROWS,list);}};CandidatePanelManager.prototype.toggleFullPanel=function(fullPanel){if(this.isFullPanelShown){this.hideFullPanel();}else{this.showFullPanel();}};CandidatePanelManager.prototype.showFullPanel=function(){if(this.isFullPanelShown){return;}
this.isFullPanelShown=true;var candidatePanel=this.app.viewManager.candidatePanel;if(candidatePanel.dataset.rowCount==1){var numberOfCandidatesPerRow=this.app.viewManager.getNumberOfCandidatesPerRow();var candidateIndicator=parseInt(candidatePanel.dataset.candidateIndicator,10);var engine=this.app.inputMethodManager.currentIMEngine;if(typeof engine.getMoreCandidates==='function'){engine.getMoreCandidates(candidateIndicator,this.FIRST_PAGE_ROWS*numberOfCandidatesPerRow+1,function gotMoreCandidates(list){if(candidatePanel.dataset.rowCount!=1){return;}
this.app.viewManager.showMoreCandidates(this.FIRST_PAGE_ROWS,list);this.scrollingMonitor.startMonitoring();this.app.viewManager.toggleCandidatePanel(true);}.bind(this));}else{var list=this.currentCandidates.slice(candidateIndicator,candidateIndicator+
this.FIRST_PAGE_ROWS*numberOfCandidatesPerRow+1);this.app.viewManager.showMoreCandidates(this.FIRST_PAGE_ROWS,list);this.scrollingMonitor.startMonitoring();this.app.viewManager.toggleCandidatePanel(true);}}else{this.scrollingMonitor.startMonitoring();this.app.viewManager.toggleCandidatePanel(true);}};CandidatePanelManager.prototype.hideFullPanel=function(){if(!this.isFullPanelShown){return;}
this.isFullPanelShown=false;this.scrollingMonitor.stopMonitoring();this.app.viewManager.toggleCandidatePanel(false);};CandidatePanelManager.prototype.reset=function(){this.hideFullPanel();this.currentCandidates=[];};CandidatePanelManager.prototype.updateCandidates=function(candidates){this.currentCandidates=candidates;if(typeof this.oncandidateschange==='function'){this.oncandidateschange();}};exports.CandidatePanelScrollingMonitor=CandidatePanelScrollingMonitor;exports.CandidatePanelManager=CandidatePanelManager;})(window);

View file

@ -0,0 +1,8 @@
;'use strict';(function(exports){var KeyboardConsole=function KeyboardConsole(){this._timers=null;};KeyboardConsole.prototype.start=function(){var timers=this._timers=new Map();timers.set('domLoading',performance.timing.domLoading);this._startTime=Date.now();};KeyboardConsole.prototype.LOG_LEVEL=0;KeyboardConsole.prototype.trace=function(){if(this.LOG_LEVEL<3){return;}
console.trace.apply(console,arguments);};KeyboardConsole.prototype.time=function(timerName){if(this.LOG_LEVEL<2){return;}
console.time(timerName);};KeyboardConsole.prototype.timeEnd=function(timerName){if(this.LOG_LEVEL<2){return;}
if(this._timers.has(timerName)){console.log(timerName+': '+
(Date.now()-this._timers.get(timerName))+'ms');return;}
console.timeEnd(timerName);};KeyboardConsole.prototype.log=function(){if(this.LOG_LEVEL<2){return;}
console.log.apply(console,arguments);};KeyboardConsole.prototype.info=function(){if(this.LOG_LEVEL<1){return;}
console.info.apply(console,arguments);};exports.KeyboardConsole=KeyboardConsole;})(window);

View file

@ -0,0 +1,6 @@
;'use strict';(function(exports){var VibrationFeedback=function(app){this.app=app;this.settings=null;};VibrationFeedback.prototype.VIBRATE_MS=50;VibrationFeedback.prototype.start=function(){var settings=this.settings=new VibrationFeedbackSettings();settings.promiseManager=this.app.settingsPromiseManager;settings.initSettings().catch(function rejected(){console.warn('VibrationFeedback: Failed to get initial settings.');});};VibrationFeedback.prototype.stop=function(){this.settings=null;};VibrationFeedback.prototype.triggerFeedback=function(){if(!this.settings.initialized){console.warn('VibrationFeedback: '+'Sound feedback needed but settings is not available yet.');return;}
if(typeof window.navigator.vibrate!=='function'){console.warn('VibrationFeedback: '+'No navigator.vibrate() on this platform.');return;}
var vibrationFeedbackSettingsValues=this.settings.getSettingsSync();if(!vibrationFeedbackSettingsValues.vibrationEnabled){return;}
window.navigator.vibrate(this.VIBRATE_MS);};var SoundFeedback=function(app){this.app=app;this.activated=false;this.settings=null;this.clicker=null;this.specialClicker=null;};SoundFeedback.prototype.start=function(){var settings=this.settings=new SoundFeedbackSettings();settings.promiseManager=this.app.settingsPromiseManager;settings.onsettingchange=this._handleSettingsChange.bind(this);settings.initSettings().then(this._handleSettingsChange.bind(this),function rejected(){console.warn('SoundFeedback: Failed to get initial settings.');});};SoundFeedback.prototype.stop=function(){this.settings=null;this.player=null;};SoundFeedback.prototype.activate=function(){this.activated=true;if(this.player){this.player.activate();}};SoundFeedback.prototype.deactivate=function(){this.activated=false;if(this.player){this.player.deactivate();}};SoundFeedback.prototype._handleSettingsChange=function(settings){if(settings.clickEnabled&&!!settings.isSoundEnabled){this.player=new SoundFeedbackPlayer();this.player.prepare();if(this.activated){this.player.activate();}}else{this.player=null;}};SoundFeedback.prototype.triggerFeedback=function(target){if(!this.settings.initialized){console.warn('SoundFeedback: '+'Sound feedback needed but settings is not available yet.');return;}
if(!this.player){return;}
this.player.play(target.isSpecialKey);};var FeedbackManager=function(app){this.app=app;this.vibrationFeedback=null;this.soundFeedback=null;};FeedbackManager.prototype.start=function(){this.vibrationFeedback=new VibrationFeedback(this.app);this.vibrationFeedback.start();this.soundFeedback=new SoundFeedback(this.app);this.soundFeedback.start();};FeedbackManager.prototype.stop=function(){this.settings=null;this.vibrationFeedback.stop();this.soundFeedback.stop();this.vibrationFeedback=null;this.soundFeedback=null;};FeedbackManager.prototype.activate=function(){this.soundFeedback.activate();};FeedbackManager.prototype.deactivate=function(){this.soundFeedback.deactivate();};FeedbackManager.prototype.triggerFeedback=function(target){this.vibrationFeedback.triggerFeedback(target);this.soundFeedback.triggerFeedback(target);};exports.VibrationFeedback=VibrationFeedback;exports.SoundFeedback=SoundFeedback;exports.FeedbackManager=FeedbackManager;})(window);

View file

@ -0,0 +1,5 @@
;'use strict';(function(exports){var HandwritingPadsManager=function(app){this._started=false;this._timeOutId=undefined;this._strokeWidth=5;this._responseTime=200;this._strokePoints=[];this._currentTarget=null;this._cleared=false;this.app=app;};HandwritingPadsManager.prototype.MAX_RESPONSE_TIME=600;HandwritingPadsManager.prototype.start=function(){if(this._started){throw new Error('HandwritingPadsManager: '+'Instance should not be start()\'ed twice.');}
this.handwritingPadSettings=new HandwritingPadSettings();this.handwritingPadSettings.promiseManager=this.app.settingsPromiseManager;this.handwritingPadSettings.onsettingchange=this._handleSettingsChange.bind(this);this.handwritingPadSettings.initSettings().then(this._handleSettingsChange.bind(this),function rejected(){console.error('Fatal Error! Failed to get initial '+'handwriting pad settings.');});this._started=true;};HandwritingPadsManager.prototype.stop=function(){if(!this._started){throw new Error('HandwritingPadsManager: '+'Instance was never start()\'ed but stop() is called.');}
this.handwritingPadSettings=null;this._started=false;};HandwritingPadsManager.prototype._handleSettingsChange=function(values){this._strokeWidth=values.strokeWidth;this._responseTime=values.responseTime;};HandwritingPadsManager.prototype.handlePressStart=function(press){clearTimeout(this._timeOutId);if(!this._currentTarget){this._currentTarget=press.target;}else if(this._currentTarget!=press.target&&!this._cleared){this.app.layoutRenderingManager.clearHandwritingPad(this._currentTarget);this._strokePoints=[];this._currentTarget=press.target;}
this._cleared=false;var point=this.app.layoutRenderingManager.drawHandwritingPad(press,true,this._strokeWidth);this._strokePoints.push(point.posX,point.posY);};HandwritingPadsManager.prototype.handlePressMove=function(press){var point=this.app.layoutRenderingManager.drawHandwritingPad(press,false,this._strokeWidth);this._strokePoints.push(point.posX,point.posY);};HandwritingPadsManager.prototype.handlePressEnd=function(){this._timeOutId=setTimeout(this._sendStrokePoints.bind(this),this.MAX_RESPONSE_TIME-this._responseTime);this._strokePoints.push(-1,0);};HandwritingPadsManager.prototype._sendStrokePoints=function(){if(this._strokePoints.length<=1){return;}
var ime=this.app.inputMethodManager.currentIMEngine;if(ime.sendStrokePoints){ime.sendStrokePoints(this._strokePoints);}};HandwritingPadsManager.prototype.clear=function(){this.app.layoutRenderingManager.clearHandwritingPad(this._currentTarget);this._strokePoints=[];this._cleared=true;};exports.HandwritingPadsManager=HandwritingPadsManager;})(window);

View file

@ -0,0 +1,7 @@
;'use strict';(function(exports){var InputMethodDatabaseConfig=function(){this._configPromise=null;};InputMethodDatabaseConfig.prototype.CONFIG_FILE_PATH='./js/settings/layouts.json';InputMethodDatabaseConfig.prototype.start=function(){this._getConfig();};InputMethodDatabaseConfig.prototype.stop=function(){this._configPromise=null;};InputMethodDatabaseConfig.prototype.isDataPreloaded=function(imEngineName,dataPath){return this._configPromise.then(function(layouts){if(!layouts){return true;}
var layout=layouts.find(function(layout){return(layout.dictFilePath===dataPath&&layout.imEngineId===imEngineName);});if(!layout){console.warn('InputMethodDatabaseConfig: '+'Ask for isDataPreloaded for data unlisted in config','imEngineName=',imEngineName,'dataPath=',dataPath);return true;}
return layout.preloaded;});};InputMethodDatabaseConfig.prototype.isAllDataPreloaded=function(){return this._configPromise.then(function(layouts){if(!layouts){return true;}
return layouts.every(function(layout){return layout.preloaded;});});};InputMethodDatabaseConfig.prototype._getConfig=function(){this._configPromise=new Promise(function(resolve,reject){var xhr=new XMLHttpRequest();xhr.open('GET',this.CONFIG_FILE_PATH);xhr.responseType='json';xhr.onload=function(){if(xhr.response){resolve(xhr.response);}else{resolve(null);}};xhr.onerror=function(){reject();};xhr.send();}.bind(this)).catch(function(e){e&&console.error(e);return null;});};var InputMethodDatabaseLoader=function InputMethodDatabaseLoader(){this.config=null;this._loadDBStorePromise=null;this.dbStore=null;};InputMethodDatabaseLoader.prototype.DATABASE_NAME='imEngineData';InputMethodDatabaseLoader.prototype.SOURCE_DIR='./js/imes/';InputMethodDatabaseLoader.prototype.start=function(){this.config=new InputMethodDatabaseConfig();this.config.start();this._loadDBStorePromise=this.config.isAllDataPreloaded().then(function(allDataPreloaded){if(allDataPreloaded){return;}
this.dbStore=new PromiseStorage(this.DATABASE_NAME);this.dbStore.start();}.bind(this)).catch(function(e){e&&console.error(e);});};InputMethodDatabaseLoader.prototype.stop=function(){this.config.stop();this.config=null;return this._loadDBStorePromise.then(function(){if(this.dbStore){this.dbStore.stop();this.dbStore=null;}
this._loadDBStorePromise=null;}.bind(this));};InputMethodDatabaseLoader.prototype.load=function(imEngineName,dataPath){var p=this.config.isDataPreloaded(imEngineName,dataPath).then(function(isDataPreloaded){if(isDataPreloaded){var url=this.SOURCE_DIR+imEngineName+'/'+dataPath;return this._loadPreloadData(url);}else{var databaseId=imEngineName+'/'+dataPath;return this._loadDBStoreData(databaseId);}}.bind(this)).catch(function(e){e&&console.error('InputMethodDatabaseLoader: Failed to load data.','imEngineName=',imEngineName,'dataPath=',dataPath,'error=',e);throw e;});return p;};InputMethodDatabaseLoader.prototype._loadPreloadData=function(url){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest();xhr.open('GET',url,true);xhr.responseType='arraybuffer';xhr.onload=function(){if(xhr.status!==404&&xhr.response&&xhr.response.byteLength){resolve(xhr.response);}else{reject(xhr.statusText);}};xhr.send();}.bind(this));};InputMethodDatabaseLoader.prototype._loadDBStoreData=function(databaseId){return this._loadDBStorePromise.then(function(){if(!this.dbStore){console.error('InputMethodDatabaseLoader:'+'Asked to load data from IndexedDB but build config indicates'+' otherwise.');throw undefined;}
return this.dbStore.getItem(databaseId);}.bind(this));};exports.InputMethodDatabaseConfig=InputMethodDatabaseConfig;exports.InputMethodDatabaseLoader=InputMethodDatabaseLoader;})(window);

View file

@ -0,0 +1,16 @@
;'use strict';(function(exports){var InputMethods={};InputMethods['default']={init:function(glue){this._glue=glue;},click:function(keyCode,isRepeat){return this._glue.sendKey(keyCode,isRepeat);},handleKey:function(dict){return this._glue.sendKey(dict);},displaysCandidates:function(){return false;}};var InputMethodGlue=function InputMethodGlue(){this.app=null;};InputMethodGlue.prototype.SOURCE_DIR='./js/imes/';InputMethodGlue.prototype.init=function(app,imEngineName){this.app=app;this.imEngineName=imEngineName;this.path=this.SOURCE_DIR+imEngineName;};InputMethodGlue.prototype.sendCandidates=function(candidates){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call sendCandidates() when '+'inputContext does not exist.');return;}
this.app.candidatePanelManager.updateCandidates(candidates);};InputMethodGlue.prototype.setComposition=function(symbols,cursor){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call setComposition() when '+'inputContext does not exist.');return;}
cursor=cursor||symbols.length;this.app.console.info('inputContext.setComposition()');return this.app.inputContext.setComposition(symbols,cursor).catch(function(e){console.warn('InputMethodGlue: setComposition() rejected with error',e);this.app.console.log(symbols,cursor);return Promise.reject(e);}.bind(this));};InputMethodGlue.prototype.endComposition=function(text){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call endComposition() when '+'inputContext does not exist.');return;}
text=text||'';this.app.console.info('inputContext.endComposition()');return this.app.inputContext.endComposition(text).catch(function(e){console.warn('InputMethodGlue: endComposition() rejected with error',e);this.app.console.log(text);return Promise.reject(e);}.bind(this));};InputMethodGlue.prototype.sendKey=function(keyCodeOrDict,isRepeat){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call sendKey() when '+'inputContext does not exist.');return Promise.reject();}
var promise;if(typeof keyCodeOrDict==='object'){this.app.console.info('inputContext.sendKey(), dict:',keyCodeOrDict);promise=this.app.inputContext.sendKey(keyCodeOrDict);}else{this.app.console.info('inputContext.sendKey(), code:'+keyCodeOrDict);switch(keyCodeOrDict){case KeyEvent.DOM_VK_BACK_SPACE:promise=this.app.inputContext.sendKey(keyCodeOrDict,0,0,isRepeat);break;case KeyEvent.DOM_VK_RETURN:promise=this.app.inputContext.sendKey(keyCodeOrDict,0,0);break;default:promise=this.app.inputContext.sendKey(0,keyCodeOrDict,0);break;}}
return promise.catch(function(e){console.warn('InputMethodGlue: sendKey() rejected with error',e);this.app.console.log(keyCodeOrDict,isRepeat);return Promise.reject(e);}.bind(this));};InputMethodGlue.prototype.sendString=function(str){this.app.console.trace();for(var i=0;i<str.length;i++){this.sendKey(str.charCodeAt(i));}};InputMethodGlue.prototype.setLayoutPage=function(newpage){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call setLayoutPage() when '+'inputContext does not exist.');return;}
if(newpage!==this.app.layoutManager.PAGE_INDEX_DEFAULT){throw new Error('InputMethodGlue: '+'imEngine is only allowed to switch to default page');}
this.app.setLayoutPage(newpage);};InputMethodGlue.prototype.setUpperCase=function(state){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call setUpperCase() when '+'inputContext does not exist.');return;}
this.app.upperCaseStateManager.switchUpperCaseState(state);};InputMethodGlue.prototype.replaceSurroundingText=function(text,offset,length){this.app.console.trace();if(!this.app.inputContext){console.warn('InputMethodGlue: call replaceSurroundingText() when '+'inputContext does not exist.');return Promise.reject();}
this.app.console.info('inputContext.replaceSurroundingText()');var p=this.app.inputContext.replaceSurroundingText(text,offset,length);p.catch(function(e){console.warn('InputMethodGlue: '+'replaceSurroundingText() rejected with error',e);this.app.console.log(text,offset,length);return Promise.reject(e);}.bind(this));return p;};InputMethodGlue.prototype.getNumberOfCandidatesPerRow=function(){return this.app.viewManager.getNumberOfCandidatesPerRow();};InputMethodGlue.prototype.getData=function(dataPath){return this.app.inputMethodDatabaseLoader.load(this.imEngineName,dataPath);};var InputMethodLoader=function(app){this.app=app;};InputMethodLoader.prototype.SOURCE_DIR='./js/imes/';InputMethodLoader.prototype.start=function(){this._initializedIMEngines={};this._imEnginesPromises={};this.initPreloadedInputMethod();};InputMethodLoader.prototype.initPreloadedInputMethod=function(){var imEngineName;var InputMethods=exports.InputMethods;for(imEngineName in InputMethods){this.initInputMethod(imEngineName);this._imEnginesPromises[imEngineName]=Promise.resolve(this._initializedIMEngines[imEngineName]);}};InputMethodLoader.prototype.getInputMethod=function(imEngineName){return this._initializedIMEngines[imEngineName];};InputMethodLoader.prototype.getInputMethodAsync=function(imEngineName){if(this._imEnginesPromises[imEngineName]){return this._imEnginesPromises[imEngineName];}
var p=new Promise(function(resolve,reject){var script=document.createElement('script');script.onload=resolve;script.onerror=function(){this._imEnginesPromises[imEngineName]=null;console.error('InputMethodLoader: unable to load '+imEngineName+'.');reject();}.bind(this);script.src=this.SOURCE_DIR+imEngineName+'/'+imEngineName+'.js';document.body.appendChild(script);}.bind(this)).then(function(){return this.initInputMethod(imEngineName);}.bind(this)).then(function(){return this._initializedIMEngines[imEngineName];}.bind(this));this._imEnginesPromises[imEngineName]=p;return p;};InputMethodLoader.prototype.initInputMethod=function(imEngineName){var InputMethods=exports.InputMethods;if(!(imEngineName in InputMethods)){throw new Error('InputMethodLoader: '+imEngineName+' did not expose itself correctly.');}
var imEngine=InputMethods[imEngineName];var glue=new InputMethodGlue();glue.init(this.app,imEngineName);this._initializedIMEngines[imEngineName]=InputMethods[imEngineName];InputMethods[imEngineName]=null;return imEngine.init(glue);};var InputMethodManager=function InputMethodManager(app){this.currentIMEngine=null;this.app=app;};InputMethodManager.prototype.start=function(){this.loader=new InputMethodLoader(this.app);this.loader.start();this.imEngineSettings=new IMEngineSettings();this.imEngineSettings.promiseManager=this.app.settingsPromiseManager;this.imEngineSettings.initSettings().catch(function rejected(){console.error('Fatal Error! Failed to get initial imEngine settings.');});this.currentIMEngine=this.loader.getInputMethod('default');};InputMethodManager.prototype.activateIMEngine=function(imEngineName){this.app.console.log('InputMethodManager.activateIMEngine()',imEngineName);var loaderPromise=this.loader.getInputMethodAsync(imEngineName);var settingsPromise=this.imEngineSettings.initSettings();var p=Promise.all([loaderPromise,settingsPromise]).then(function(values){var imEngine=values[0];if(typeof imEngine.activate==='function'){var settingsValues=values[1];var currentPage=this.app.layoutManager.currentPage;var lang=this.app.layoutManager.currentPage.autoCorrectLanguage||this.app.layoutManager.currentPage.handwritingLanguage;var correctPunctuation='autoCorrectPunctuation'in currentPage?currentPage.autoCorrectPunctuation:true;var inputContext=this.app.inputContext;this.app.console.log('InputMethodManager::currentIMEngine.activate()');imEngine.activate(lang,{type:inputContext.inputType,inputmode:inputContext.inputMode,selectionStart:inputContext.selectionStart,selectionEnd:inputContext.selectionEnd,text:inputContext.text},{suggest:settingsValues.suggestionsEnabled,correct:settingsValues.correctionsEnabled,correctPunctuation:correctPunctuation});}
if(typeof imEngine.stateChange==='function'){this.app.inputContext.addEventListener('selectionchange',this);this.app.inputContext.addEventListener('surroundingtextchange',this);}
this.currentIMEngine=imEngine;}.bind(this));return p;};InputMethodManager.prototype.deactivateIMEngine=function(){if(this.currentIMEngine&&this.currentIMEngine.deactivate){this.app.console.log('InputMethodManager::currentIMEngine.deactivate()');this.currentIMEngine.deactivate();}
if(this.app.inputContext){this.app.inputContext.removeEventListener('selectionchange',this);this.app.inputContext.removeEventListener('surroundingtextchange',this);}
this.currentIMEngine=this.loader.getInputMethod('default');};InputMethodManager.prototype.handleEvent=function(evt){this.app.console.info('InputMethodManager.handleEvent()',evt);var inputContext=this.app.inputContext;var inputContextStates={ownAction:evt.detail.ownAction,type:inputContext.inputType,inputmode:inputContext.inputMode,selectionStart:inputContext.selectionStart,selectionEnd:inputContext.selectionEnd,text:inputContext.text};this.app.console.log('InputMethodManager::currentIMEngine.stateChange()',inputContextStates);this.currentIMEngine.stateChange(inputContextStates);};exports.InputMethods=InputMethods;exports.InputMethodGlue=InputMethodGlue;exports.InputMethodLoader=InputMethodLoader;exports.InputMethodManager=InputMethodManager;})(window);

View file

@ -0,0 +1,3 @@
;'use strict';(function(exports){var KeyboardApp=function(){this.console=null;this.inputMethodManager=null;this.inputMethodDatabaseLoader=null;this.layoutManager=null;this.settingsPromiseManager=null;this.l10nLoader=null;this.targetHandlersManager=null;this.handwritingPadsManager=null;this.feedbackManager=null;this.visualHighlightManager=null;this.candidatePanelManager=null;this.upperCaseStateManager=null;this.layoutRenderingManager=null;this.stateManager=null;this.viewManager=null;this.inputContext=null;};KeyboardApp.prototype.CONATINER_ELEMENT_ID='keyboard';KeyboardApp.prototype.start=function(){this._startComponents();};KeyboardApp.prototype._startComponents=function(){this.console=new KeyboardConsole();this.console.start();this.console.log('KeyboardApp._startComponents()');this.console.trace();this.console.time('KeyboardApp._startComponents()');this.settingsPromiseManager=new SettingsPromiseManager();this.inputMethodManager=new InputMethodManager(this);this.inputMethodManager.start();this.inputMethodDatabaseLoader=new InputMethodDatabaseLoader(this);this.inputMethodDatabaseLoader.start();this.layoutManager=new LayoutManager(this);this.layoutManager.start();this.l10nLoader=new L10nLoader();this.targetHandlersManager=new TargetHandlersManager(this);this.targetHandlersManager.start();this.handwritingPadsManager=new HandwritingPadsManager(this);this.handwritingPadsManager.start();this.feedbackManager=new FeedbackManager(this);this.feedbackManager.start();this.visualHighlightManager=new VisualHighlightManager(this);this.visualHighlightManager.start();this.viewManager=new ViewManager(this);this.viewManager.start();var renderingManager=this.layoutRenderingManager=new LayoutRenderingManager(this);renderingManager.start();this.upperCaseStateManager=new UpperCaseStateManager();this.upperCaseStateManager.onstatechange=renderingManager.updateUpperCaseRendering.bind(renderingManager);this.upperCaseStateManager.start();this.candidatePanelManager=new CandidatePanelManager(this);this.candidatePanelManager.oncandidateschange=renderingManager.updateCandidatesRendering.bind(renderingManager);this.candidatePanelManager.start();this.stateManager=new StateManager(this);this.stateManager.start();this.console.timeEnd('KeyboardApp._startComponents()');};KeyboardApp.prototype.stop=function(){this.console.log('KeyboardApp.stop()');this._stopComponents();this.inputContext=null;};KeyboardApp.prototype._stopComponents=function(){this.console=null;this.inputMethodManager=null;this.inputMethodDatabaseLoader.stop();this.inputMethodDatabaseLoader=null;this.layoutManager=null;this.settingsPromiseManager=null;this.l10nLoader=null;this.targetHandlersManager.stop();this.targetHandlersManager=null;this.handwritingPadsManager.stop();this.handwritingPadsManager=null;this.feedbackManager.stop();this.feedbackManager=null;this.visualHighlightManager.stop();this.visualHighlightManager=null;this.candidatePanelManager.stop();this.candidatePanelManager=null;this.upperCaseStateManager.onstatechange=null;this.upperCaseStateManager.stop();this.upperCaseStateManager=null;this.layoutRenderingManager.stop();this.layoutRenderingManager=null;this.stateManager.stop();this.stateManager=null;this.viewManager.stop();this.viewManager=null;};KeyboardApp.prototype.getContainer=function(){return document.getElementById(this.CONATINER_ELEMENT_ID);};KeyboardApp.prototype.setInputContext=function(inputContext){this.console.log('KeyboardApp.setInputContext()',inputContext);this.inputContext=inputContext;};KeyboardApp.prototype.getBasicInputType=function(){if(!this.inputContext){return'text';}
var type=this.inputContext.inputType;switch(type){case'url':case'tel':case'email':case'text':case'search':break;case'password':default:type='text';break;case'number':case'range':type='number';break;}
return type;};KeyboardApp.prototype.supportsSwitching=function(){return navigator.mozInputMethod.mgmt.supportsSwitching();};KeyboardApp.prototype.setLayoutPage=function setLayoutPage(page){this.console.log('KeyboardApp.setLayoutPage()',page);this.layoutManager.updateLayoutPage(page);this.layoutRenderingManager.updateLayoutRendering();var engine=this.inputMethodManager.currentIMEngine;if(typeof engine.setLayoutPage==='function'){engine.setLayoutPage(this.layoutManager.currentPageIndex);}};exports.KeyboardApp=KeyboardApp;})(window);

View file

@ -0,0 +1,2 @@
;'use strict';(function(exports){var L10nLoader=function(){this.loadStarted=false;};L10nLoader.prototype.SCRIPT_URL='/shared/js/l10n.js';L10nLoader.prototype.load=function(){if(this.loadStarted){return;}
this.loadStarted=true;document.documentElement.lang='x-untranslated';var script=document.createElement('script');script.src=this.SCRIPT_URL;document.body.appendChild(script);};exports.L10nLoader=L10nLoader;})(window);

View file

@ -0,0 +1,3 @@
;'use strict';(function(exports){var Keyboards={};Keyboards.defaultLayout={pages:[{},{alt:{'1':['¹'],'2':['²'],'3':['³'],'4':['⁴'],'5':['⁵'],'6':['⁶'],'7':['⁷'],'8':['⁸'],'9':['⁹'],'0':['⁰','º'],'$':['€','£','¢','¥'],'"':['“','”'],'\'':['‘','’'],'?':['¿'],'!':['¡'],'+':['-','×','÷','±']},keys:[[{value:'1'},{value:'2'},{value:'3'},{value:'4'},{value:'5'},{value:'6'},{value:'7'},{value:'8'},{value:'9'},{value:'0'}],[{value:'@'},{value:'#'},{value:'$',className:'alternate-indicator'},{value:'&'},{value:'*'},{value:'-'},{value:'_'},{value:'/'},{value:'('},{value:')'}],[{value:'Alt',ratio:1.5,keyCode:KeyboardEvent.DOM_VK_ALT,className:'page-switch-key',targetPage:2},{value:'+',supportsSwitching:{value:','}},{value:':'},{value:';'},{value:'"'},{value:'\''},{value:'!'},{value:'?'},{value:'⌫',ratio:1.5,keyCode:KeyboardEvent.DOM_VK_BACK_SPACE}],[{value:'&nbsp',ratio:8,keyCode:KeyboardEvent.DOM_VK_SPACE},{value:'↵',ratio:2,keyCode:KeyboardEvent.DOM_VK_RETURN}]]},{alt:{'+':['-','×','÷','±'],'®':['™']},keys:[[{value:'€'},{value:'£'},{value:'¢'},{value:'¥'},{value:'%'},{value:'©'},{value:'®'},{value:'·'},{value:'|'},{value:'\\'}],[{value:'~'},{value:'℃'},{value:'℉'},{value:'°'},{value:'<'},{value:'>'},{value:'['},{value:']'},{value:'{'},{value:'}'}],[{value:'Alt',ratio:1.5,keyCode:KeyboardEvent.DOM_VK_ALT,className:'page-switch-key',targetPage:1},{value:'+'},{value:'='},{value:'`'},{value:'^'},{value:'§'},{value:'«'},{value:'»'},{value:'⌫',ratio:1.5,keyCode:KeyboardEvent.DOM_VK_BACK_SPACE}],[{value:'&nbsp',ratio:8,keyCode:KeyboardEvent.DOM_VK_SPACE},{value:'↵',ratio:2,keyCode:KeyboardEvent.DOM_VK_RETURN}]]}]};Keyboards.numberLayout={width:3,keyClassName:'big-key special-key',keys:[[{value:'1'},{value:'2'},{value:'3'}],[{value:'4'},{value:'5'},{value:'6'}],[{value:'7'},{value:'8'},{value:'9'}],[{value:'.',longPressValue:','},{value:'0',longPressValue:'-'},{value:'⌫',keyCode:KeyboardEvent.DOM_VK_BACK_SPACE}]]};Keyboards.pinLayout={width:3,keyClassName:'big-key special-key bottom-symbol',keys:[[{value:'1'},{value:'2'},{value:'3'}],[{value:'4'},{value:'5'},{value:'6'}],[{value:'7'},{value:'8'},{value:'9'}],[{value:''},{value:'0'},{value:'⌫',keyCode:KeyboardEvent.DOM_VK_BACK_SPACE}]]};Keyboards.telLayout={width:3,keyClassName:'big-key special-key bottom-symbol',keys:[[{value:'1',longPressValue:'('},{value:'2',longPressValue:')'},{value:'3',longPressValue:'/'}],[{value:'4',longPressValue:'-'},{value:'5',longPressValue:'_'},{value:'6',longPressValue:','}],[{value:'7',longPressValue:':'},{value:'8',longPressValue:'.'},{value:'9',longPressValue:';'}],[{value:'*',longPressValue:'#'},{value:'0',longPressValue:'+'},{value:'⌫',keyCode:KeyboardEvent.DOM_VK_BACK_SPACE}]]};var LayoutLoader=function(app){this.app=app;};LayoutLoader.prototype.SOURCE_DIR='./js/layouts/';LayoutLoader.prototype.start=function(){this._initializedLayouts={};this._layoutsPromises={};this.initLayouts();};LayoutLoader.prototype.initLayouts=function(){var Keyboards=exports.Keyboards;exports.Keyboards={};var layoutName;for(layoutName in Keyboards){if(this._initializedLayouts[layoutName]){console.warn('LayoutLoader: '+layoutName+' is overwritten.');}
var layoutNormalizer=new LayoutNormalizer(Keyboards[layoutName]);layoutNormalizer.normalize();this._initializedLayouts[layoutName]=layoutNormalizer.normalizedLayout;if(!this._layoutsPromises[layoutName]){this._layoutsPromises[layoutName]=Promise.resolve(this._initializedLayouts[layoutName]);}}};LayoutLoader.prototype.getLayout=function(layoutName){return this._initializedLayouts[layoutName];};LayoutLoader.prototype.getLayoutAsync=function(layoutName){if(this._layoutsPromises[layoutName]){return this._layoutsPromises[layoutName];}
var p=new Promise(function(resolve,reject){var script=document.createElement('script');script.onload=function(){this.initLayouts();resolve(this._initializedLayouts[layoutName]);}.bind(this);script.onerror=function(){this._layoutsPromises[layoutName]=null;console.error('LayoutLoader: unable to load '+layoutName+'.');reject();}.bind(this);script.src=this.SOURCE_DIR+layoutName+'.js';document.body.appendChild(script);}.bind(this));this._layoutsPromises[layoutName]=p;return p;};exports.Keyboards=Keyboards;exports.LayoutLoader=LayoutLoader;})(window);

View file

@ -0,0 +1,23 @@
;'use strict';(function(exports){var LayoutManager=function(app){this.app=app;this._typeGenericLayoutName=undefined;this.currentPage=null;this.currentPageIndex=this.PAGE_INDEX_DEFAULT;};LayoutManager.prototype.start=function(){this.loader=new LayoutLoader();this.loader.start();};LayoutManager.prototype.KEYCODE_SWITCH_KEYBOARD=-3;LayoutManager.prototype.KEYCODE_TOGGLE_CANDIDATE_PANEL=-4;LayoutManager.prototype.DEFAULT_LAYOUT_NAME='defaultLayout';LayoutManager.prototype.PAGE_INDEX_DEFAULT=0;LayoutManager.prototype.switchCurrentLayout=function(layoutName){var loaderPromise=this.loader.getLayoutAsync(layoutName);var p=loaderPromise.then(function(layout){this._typeGenericLayoutName=layoutName;this.currentPageIndex=this.PAGE_INDEX_DEFAULT;this._updateCurrentPage();}.bind(this));return p;};LayoutManager.prototype.updateLayoutPage=function(page){this.currentPageIndex=page;this._updateCurrentPage();};LayoutManager.prototype._updateCurrentPage=function(){if(!this.app.inputContext||!this._typeGenericLayoutName){console.warn('LayoutManager: '+'calling _updateCurrentPage() when there is no '+'inputContext or _typeGenericLayoutName.');this.currentPage=null;return;}
var inputMode=this.app.inputContext.inputMode;var basicInputType=this.app.getBasicInputType();var supportsSwitching=this.app.supportsSwitching();var typeSpecificLayoutName=this._typeSpecificLayoutName(basicInputType,inputMode);var layout=this.loader.getLayout(typeSpecificLayoutName||this._typeGenericLayoutName);if(!layout){console.error('LayoutManager: Can\'t load the layout.','typeSpecificLayoutName=',typeSpecificLayoutName,'typeGenericLayoutName=',this._typeGenericLayoutName,'currentPageIndex=',this.currentPageIndex);this.currentPage=null;return;}
var page=layout.pages[this.currentPageIndex];if(!page){var defaultLayout=this.loader.getLayout(this.DEFAULT_LAYOUT_NAME);page=defaultLayout.pages[this.currentPageIndex];}
if(!page){console.error('LayoutManager: Can\'t load the page from layout.','typeSpecificLayoutName=',typeSpecificLayoutName,'typeGenericLayoutName=',this._typeGenericLayoutName,'currentPageIndex=',this.currentPageIndex);this.currentPage=null;return;}
page=this.currentPage=Object.create(page);var keyNormalizer=new LayoutKeyNormalizer(page);['imEngine','autoCorrectLanguage','autoCorrectPunctuation','needsCandidatePanel','lang'].forEach(function(prop){if(prop in layout){page[prop]=layout[prop];}});page.layoutName=typeSpecificLayoutName||this._typeGenericLayoutName;page.pageIndex=this.currentPageIndex;var spaceKeyFindResult=this._findKey(page,KeyboardEvent.DOM_VK_SPACE);var spaceKeyRowCount=spaceKeyFindResult.keyRowCount;var spaceKeyCount=spaceKeyFindResult.keyCount;if(!spaceKeyFindResult.keyFound){console.warn('LayoutManager:'+'No space key found. No special keys will be added.');return;}
page.keys=[].concat(page.keys);var copiedRows=[];var spaceKeyRow=page.keys[spaceKeyRowCount]=[].concat(page.keys[spaceKeyRowCount]);copiedRows.push(spaceKeyRowCount);var spaceKeyObject=page.keys[spaceKeyRowCount][spaceKeyCount]=Object.create(page.keys[spaceKeyRowCount][spaceKeyCount]);var enterKeyFindResult=this._findKey(page,KeyboardEvent.DOM_VK_RETURN);var enterKeyCount=enterKeyFindResult.keyCount;var enterKeyObject=page.keys[spaceKeyRowCount][enterKeyCount]=Object.create(page.keys[spaceKeyRowCount][enterKeyCount]);var pageSwitchingKeyObject=null;if(!layout.disableAlternateLayout){spaceKeyObject.ratio-=2;pageSwitchingKeyObject={keyCode:KeyboardEvent.DOM_VK_ALT,ratio:2,className:'page-switch-key'};if(this.currentPageIndex===this.PAGE_INDEX_DEFAULT){Object.assign(pageSwitchingKeyObject,{value:layout.alternateLayoutKey||'12&',ariaLabel:'alternateLayoutKey2',targetPage:1});}else{Object.assign(pageSwitchingKeyObject,{value:layout.basicLayoutKey||'ABC',ariaLabel:'basicLayoutKey2',targetPage:this.PAGE_INDEX_DEFAULT});}
pageSwitchingKeyObject=keyNormalizer.normalizeKey(pageSwitchingKeyObject,false);spaceKeyRow.splice(spaceKeyCount,0,pageSwitchingKeyObject);spaceKeyCount++;}
var needsSwitchingKey=supportsSwitching&&!layout.hidesSwitchKey;if(needsSwitchingKey){var imeSwitchKey={value:'&#x1f310;',uppercaseValue:'&#x1f310;',keyCode:this.KEYCODE_SWITCH_KEYBOARD,className:'switch-key',isSpecialKey:true};if(layout.shortLabel){imeSwitchKey.value=layout.shortLabel;imeSwitchKey.uppercaseValue=layout.shortLabel;imeSwitchKey.className+=' alternate-indicator';}
spaceKeyObject.ratio-=1;spaceKeyRow.splice(spaceKeyCount,0,imeSwitchKey);spaceKeyCount++;var r=page.keys.length,c,row,key;while(r--){row=page.keys[r];c=row.length;while(c--){key=row[c];if(key.supportsSwitching){if(copiedRows.indexOf(r)===-1){page.keys[r]=[].concat(page.keys[r]);copiedRows.push(r);}
page.keys[r][c]=Object.create(key.supportsSwitching);}}}}
if(!page.typeInsensitive){var periodKey=keyNormalizer.normalizeKey({value:'.'},!!(page.alt&&page.alt['.']));var modifyType='default';if(this.currentPageIndex===this.PAGE_INDEX_DEFAULT){switch(basicInputType){case'url':modifyType='url';break;case'email':modifyType='email';break;case'text':modifyType='default';break;case'search':modifyType='search';break;}}else{if('search'===basicInputType){modifyType='search';}else{modifyType='default';}}
switch(modifyType){case'url':spaceKeyObject.ratio-=2.0;spaceKeyRow.splice(spaceKeyCount,0,keyNormalizer.normalizeKey({value:'/'},false));spaceKeyCount++;spaceKeyRow.splice(spaceKeyCount+1,0,periodKey);break;case'email':spaceKeyObject.ratio-=2;spaceKeyRow.splice(spaceKeyCount,0,keyNormalizer.normalizeKey({value:'@'},false));spaceKeyCount++;spaceKeyRow.splice(spaceKeyCount+1,0,periodKey);break;case'search':if(enterKeyObject){enterKeyObject.className='search-icon';}
case'default':var overwrites=page.textLayoutOverwrite||{};if(overwrites[',']!==false&&(!needsSwitchingKey||page.needsCommaKey)){var commaKey;if(overwrites[',']){commaKey=overwrites[','];}else{commaKey=keyNormalizer.normalizeKey({value:','},!!(page.alt&&page.alt[',']));}
spaceKeyObject.ratio-=1;spaceKeyRow.splice(spaceKeyCount,0,commaKey);spaceKeyCount++;}
if(overwrites['.']!==false){if(overwrites['.']){periodKey=overwrites['.'];}
spaceKeyObject.ratio-=1;spaceKeyRow.splice(spaceKeyCount+1,0,periodKey);}
break;}}
var keyCount=page.width?page.width:10;if(!layout.disableAlternateLayout){if(spaceKeyCount==3&&keyCount==10){if(enterKeyObject){enterKeyObject.ratio=2.5;}
pageSwitchingKeyObject.ratio=1.5;}}};LayoutManager.prototype._typeSpecificLayoutName=function(basicInputType,inputMode){switch(basicInputType){case'tel':return'telLayout';case'number':switch(inputMode){case'digit':return'pinLayout';default:return'numberLayout';}
break;case'text':switch(inputMode){case'digit':return'pinLayout';case'numeric':return'numberLayout';case'-moz-sms':var smsLayoutName=this._typeGenericLayoutName+'-sms';if(this.loader.getLayout(smsLayoutName)){return smsLayoutName;}}
break;}
return'';};LayoutManager.prototype._findKey=function(page,keyCode){var r=page.keys.length,c,row,key;while(r--){row=page.keys[r];c=row.length;while(c--){key=row[c];if(key.keyCode==keyCode){return{keyFound:true,keyRowCount:r,keyCount:c};}}}
return{keyFound:false,keyRowCount:-1,keyCount:-1};};exports.SWITCH_KEYBOARD=LayoutManager.prototype.KEYCODE_SWITCH_KEYBOARD;exports.TOGGLE_CANDIDATE_PANEL=LayoutManager.prototype.KEYCODE_TOGGLE_CANDIDATE_PANEL;exports.PAGE_INDEX_DEFAULT=LayoutManager.prototype.PAGE_INDEX_DEFAULT;exports.LayoutManager=LayoutManager;})(window);

View file

@ -0,0 +1,12 @@
;'use strict';(function(exports){var LayoutKeyNormalizer=function(page){this._page=page;};LayoutKeyNormalizer.prototype._isSpecialKey=function(key){var SPECIAL_CODES=[KeyEvent.DOM_VK_BACK_SPACE,KeyEvent.DOM_VK_CAPS_LOCK,KeyEvent.DOM_VK_RETURN,KeyEvent.DOM_VK_ALT];var hasSpecialCode=key.keyCode&&(SPECIAL_CODES.indexOf(key.keyCode)!==-1);return hasSpecialCode||key.keyCode<=0;};LayoutKeyNormalizer.prototype._isButton=function(key){var SPECIAL_BUTTONS=[KeyEvent.DOM_VK_RETURN];return this._isSpecialKey(key)&&SPECIAL_BUTTONS.indexOf(key.keyCode)!==-1;};LayoutKeyNormalizer.prototype._getUpperCaseValue=function(key){if(KeyEvent.DOM_VK_SPACE===key.keyCode||this._isSpecialKey(key)||key.compositeKey){return key.value;}
var upperCase=this._page.upperCase||{};return upperCase[key.value]||key.value.toUpperCase();};LayoutKeyNormalizer.prototype.normalizeKey=function(key,showAlternatesIndicator){var keyChar=key.value;var upperCaseKeyChar=this._getUpperCaseValue(key);var code=key.keyCode||keyChar.charCodeAt(0);var upperCode=key.keyCode||upperCaseKeyChar.charCodeAt(0);key.keyCode=code;key.keyCodeUpper=upperCode;key.lowercaseValue=keyChar;key.uppercaseValue=upperCaseKeyChar;key.isSpecialKey=this._isSpecialKey(key);key.isButton=this._isButton(key);if(showAlternatesIndicator){key.className='alternate-indicator';}
if(key.longPressValue){var longPressKeyCode=key.longPressKeyCode||key.longPressValue.charCodeAt(0);key.longPressKeyCode=longPressKeyCode;}
if(key.supportsSwitching){this.normalizeKey(key.supportsSwitching,false);}
if(KeyboardEvent.DOM_VK_ALT===code&&!('targetPage'in key)){console.error('LayoutNormalizer: no targetPage for switching key.');}
return key;};var LayoutNormalizer=function(layout){this._layout=layout;this._normalizedLayout=null;};LayoutNormalizer.prototype._hasAlternativeKeys=function(key,page){var alt=page.alt||{};return key in alt;};LayoutNormalizer.prototype._normalizePageKeys=function(page){var keyRows=page.keys||[];var keyNormalizer=new LayoutKeyNormalizer(page);page.keys=keyRows.map(function(keyRow){return keyRow.map(function(key){return keyNormalizer.normalizeKey(key,false);},this);},this);var overwrites=page.textLayoutOverwrite||{};page.textLayoutOverwrite=Object.keys(overwrites).reduce(function(result,overwrittenKey){if(false===overwrites[overwrittenKey]){result[overwrittenKey]=false;}else{var hasAlternativeKeys=this._hasAlternativeKeys(overwrites[overwrittenKey],page);result[overwrittenKey]=keyNormalizer.normalizeKey({value:overwrites[overwrittenKey]},hasAlternativeKeys);}
return result;}.bind(this),{});};LayoutNormalizer.prototype._normalizePageAltKeys=function(page){var alt=page.alt=page.alt||{};var upperCase=page.upperCase=page.upperCase||{};var altKeys=Object.keys(alt);altKeys.forEach(function(key){var alternatives=alt[key];if(!Array.isArray(alternatives)){if(alternatives.indexOf(' ')!==-1){alternatives=alternatives.split(' ');if(alternatives.length===2&&alternatives[1]===''){alternatives.pop();}}else{alternatives=alternatives.split('');}}
alt[key]=alternatives;var upperCaseKey=upperCase[key]||key.toUpperCase();if(!alt[upperCaseKey]){var needDifferentUpperCaseLockedAlternatives=false;alt[upperCaseKey]=alternatives.map(function(key){if(key.length===1){return key.toUpperCase();}
needDifferentUpperCaseLockedAlternatives=needDifferentUpperCaseLockedAlternatives||(key.substr(1).toUpperCase()!==key.substr(1));return key[0].toUpperCase()+key.substr(1);});if(needDifferentUpperCaseLockedAlternatives){alt[upperCaseKey].upperCaseLocked=alternatives.map(function(key){return key.toUpperCase();});}}},this);};LayoutNormalizer.prototype.normalize=function(){var pages;if('pages'in this._layout){pages=this._layout.pages;}else{pages=this._layout.pages=[];}
if(!pages[0]){pages[0]={};['alt','keys','upperCase','width','keyClassName','typeInsensitive','textLayoutOverwrite','needsCommaKey','secondLayout','specificCssRule'].forEach(function(prop){if(this._layout[prop]){pages[0][prop]=this._layout[prop];delete this._layout[prop];}},this);}
pages.forEach(function(page){this._normalizePageKeys(page);this._normalizePageAltKeys(page);},this);this._normalizedLayout=this._layout;};Object.defineProperty(LayoutNormalizer.prototype,'normalizedLayout',{configurable:true,get:function ln_getNormalizedLayout(){if(!this._normalizedLayout){throw Error('Tried to get normalized layout before calling normalize()');}
return this._normalizedLayout;}});exports.LayoutKeyNormalizer=LayoutKeyNormalizer;exports.LayoutNormalizer=LayoutNormalizer;})(window);

View file

@ -0,0 +1,9 @@
;'use strict';(function(exports){var LayoutRenderingManager=function(app){this.app=app;this._currentRenderingPage=null;this._resizeListenerTimer=undefined;this.domObjectMap=null;};LayoutRenderingManager.prototype.start=function(){this.app.console.log('LayoutRenderingManager.start()');this._resizeListenerTimer=setTimeout(function attachResizeListener(){this.app.console.log('LayoutRenderingManager.attachResizeListener()');window.addEventListener('resize',this);}.bind(this),2000);this.domObjectMap=new WeakMap();};LayoutRenderingManager.prototype.stop=function(){clearTimeout(this._resizeListenerTimer);this._resizeListenerTimer=undefined;window.removeEventListener('resize',this);this.domObjectMap=null;};LayoutRenderingManager.prototype.handleEvent=function(){this.app.console.log('LayoutRenderingManager.handleEvent()');if(document.hidden){this.app.console.log('LayoutRenderingManager: Ignore resizing call since '+'document is hidden.');return;}
if(this._currentRenderingPage!==this.app.layoutManager.currentPage){this.app.console.log('LayoutRenderingManager: Ignore resizing call since '+'layout is not ready yet.');return;}
this.app.viewManager.resize();this._updateHeight();this._updateLayoutParams();};LayoutRenderingManager.prototype.updateCandidatesRendering=function(){if(this._currentRenderingPage!==this.app.layoutManager.currentPage){this.app.console.log('LayoutRenderingManager: Ignore updateCandidatesRendering() call since '+'layout is not ready yet.');return;}
this.app.viewManager.showCandidates(this.app.candidatePanelManager.currentCandidates);};LayoutRenderingManager.prototype.updateUpperCaseRendering=function(){this.app.console.log('LayoutRenderingManager.updateUpperCaseRendering()');if(this._currentRenderingPage!==this.app.layoutManager.currentPage){this.app.console.log('LayoutRenderingManager: Ignore updateUpperCaseRendering() call since '+'layout is not ready yet.');return;}
window.requestAnimationFrame(function(){this.app.console.log('LayoutRenderingManager.updateUpperCaseRendering()::'+'requestAnimationFrame');this.app.viewManager.setUpperCaseLock(this.app.upperCaseStateManager);}.bind(this));};LayoutRenderingManager.prototype.updateLayoutRendering=function(){this.app.console.log('LayoutRenderingManager.updateLayoutRendering()');this.app.console.time('LayoutRenderingManager.updateLayoutRendering()');var currentPage=this._currentRenderingPage=this.app.layoutManager.currentPage;var currentIMEngine=this.app.inputMethodManager.currentIMEngine;this.app.console.log('needsCandidatePanel',currentPage.autoCorrectLanguage,currentPage.needsCandidatePanel,typeof currentIMEngine.displaysCandidates!=='function',(currentIMEngine.displaysCandidates&&currentIMEngine.displaysCandidates()));var needsCandidatePanel=!!((currentPage.autoCorrectLanguage||currentPage.needsCandidatePanel)&&((typeof currentIMEngine.displaysCandidates!=='function')||currentIMEngine.displaysCandidates()));if(currentPage.updateByIMEngine){if(typeof currentIMEngine.updatePageKeys!=='function'){throw new Error('LayoutRenderingManager: unable to update '+'page keys by IMEngine');}
currentIMEngine.updatePageKeys(currentPage);}
var p=new Promise(function(resolve){this.app.viewManager.render(currentPage,{uppercase:this.app.upperCaseStateManager.isUpperCase,inputType:this.app.getBasicInputType(),showCandidatePanel:needsCandidatePanel},resolve);}.bind(this)).then(this._afterRenderDrew.bind(this));p.catch(function(e){console.error(e);});this._updateHeight();this.app.console.timeEnd('LayoutRenderingManager.updateLayoutRendering()');return p;};LayoutRenderingManager.prototype.drawHandwritingPad=function(press,start,strokeWidth){return this.app.viewManager.drawHandwritingPad(press,start,strokeWidth);};LayoutRenderingManager.prototype.clearHandwritingPad=function(target){this.app.viewManager.clearHandwritingPad(target);};LayoutRenderingManager.prototype._afterRenderDrew=function(){this.app.console.log('LayoutRenderingManager._afterRenderDrew()');this.app.console.time('LayoutRenderingManager._afterRenderDrew()');this.app.viewManager.setUpperCaseLock(this.app.upperCaseStateManager);this.app.viewManager.showCandidates(this.app.candidatePanelManager.currentCandidates);this._updateLayoutParams();this.app.console.timeEnd('LayoutRenderingManager._afterRenderDrew()');};LayoutRenderingManager.prototype._updateLayoutParams=function(){this.app.console.log('LayoutRenderingManager._updateLayoutParams()');var currentIMEngine=this.app.inputMethodManager.currentIMEngine;var layoutManager=this.app.layoutManager;if((typeof currentIMEngine.setLayoutParams!=='function')||layoutManager.currentPageIndex!==layoutManager.PAGE_INDEX_DEFAULT){return;}
var candidatePanel=this.app.viewManager.candidatePanel;var yBias=candidatePanel?candidatePanel.clientHeight:0;currentIMEngine.setLayoutParams({keyboardWidth:this.app.viewManager.getWidth(),keyboardHeight:(this.app.viewManager.getHeight()-yBias),keyArray:this.app.viewManager.getKeyArray(),keyWidth:this.app.viewManager.getKeyWidth(),keyHeight:this.app.viewManager.getKeyHeight()});};LayoutRenderingManager.prototype._updateHeight=function(){this.app.console.log('LayoutRenderingManager._updateHeight()');this.app.console.time('LayoutRenderingManager._updateHeight()');var imeHeight=this.app.viewManager.getHeight();var imeWidth=this.app.viewManager.getWidth();imeHeight=Math.floor(imeHeight*window.devicePixelRatio)/window.devicePixelRatio;this.app.console.timeEnd('LayoutRenderingManager._updateHeight()');this.app.console.timeEnd('activate');this.app.console.timeEnd('domLoading');window.resizeTo(imeWidth,imeHeight);};LayoutRenderingManager.prototype.getTargetObject=function(elem){this.app.console.log('LayoutRenderingManager.getTargetObject()',elem);if(!elem){return{};}
var target=this.domObjectMap.get(elem);this.app.console.log('target=',target,'prototype=',target&&Object.getPrototypeOf(target));return target||{};};exports.LayoutRenderingManager=LayoutRenderingManager;})(window);

View file

@ -0,0 +1,11 @@
;;'use strict';(function(exports){var SettingsPromiseManager=function SettingsPromiseManager(){this._readLock=null;this._writeLock=null;};SettingsPromiseManager.prototype._cleanLock=function(type){var propName;switch(type){case'read':propName='_readLock';break;case'write':propName='_writeLock';break;default:throw new Error('SettingsPromiseManager: Not such type.');}
if(this[propName]&&this[propName].closed){this[propName]=null;}};SettingsPromiseManager.prototype._getLock=function(type){var propName;switch(type){case'read':propName='_readLock';break;case'write':propName='_writeLock';break;default:throw new Error('SettingsPromiseManager: Not such type.');}
if(this[propName]&&!this[propName].closed){return this[propName];}
var settings=window.navigator.mozSettings;this[propName]=settings.createLock();return this[propName];};SettingsPromiseManager.prototype._getReadLock=function(){return this._getLock('read');};SettingsPromiseManager.prototype._getWriteLock=function(){return this._getLock('write');};SettingsPromiseManager.prototype.get=function(obj){if(typeof obj==='string'){return this.getOne(obj);}
if(typeof obj!=='object'){throw new Error('SettingsPromiseManager.get: '+'require object, array, or string.');}
var arr=Array.isArray(obj)?obj:Object.keys(obj);var promise=Promise.all(arr.map(function(key){return this.getOne(key);},this));return promise;};SettingsPromiseManager.prototype.getOne=function(key){var promise=new Promise(function(resolve,reject){var req=this._getReadLock().get(key);req.onsuccess=function(){this._cleanLock('read');resolve(req.result[key]);}.bind(this);req.onerror=function(){this._cleanLock('read');reject();}.bind(this);}.bind(this));return promise;};SettingsPromiseManager.prototype.set=function(obj,value){if(typeof obj==='string'){return this.setOne(obj,value);}
if(typeof obj!=='object'){throw new Error('SettingsPromiseManager.set: require object.');}
var promise=new Promise(function(resolve,reject){var req=this._getWriteLock().set(obj);req.onsuccess=function(){this._cleanLock('write');resolve();}.bind(this);req.onerror=function(){this._cleanLock('write');reject();}.bind(this);}.bind(this));return promise;};SettingsPromiseManager.prototype.setOne=function(key,value){var obj={};obj[key]=value;return this.set(obj);};SettingsPromiseManager.prototype.updateOne=function(key,callback){var promise=new Promise(function(resolve,reject){var lock=this._getWriteLock();var req=lock.get(key);req.onsuccess=function(){var newValue=callback(req.result[key]);var obj={};obj[key]=newValue;resolve(lock.set(obj));}.bind(this);req.onerror=function(){reject(req.error);}.bind(this);}.bind(this)).then(function(){this._cleanLock('write');}.bind(this),function(e){this._cleanLock('write');throw e;}.bind(this));return promise;};var SettingsManagerBase=function(){this.initialized=false;this._callbacks=null;this._values={};this._initPromise=null;};SettingsManagerBase.prototype.onsettingchange=null;SettingsManagerBase.prototype.KEYS=[];SettingsManagerBase.prototype.PROPERTIES=[];SettingsManagerBase.prototype.getSettingsSync=function(){return this._values;};SettingsManagerBase.prototype.initSettings=function(){if(this._initPromise){return this._initPromise;}
var promise=this.promiseManager.get(this.KEYS).then(function(results){results.forEach(function(value,i){this._values[this.PROPERTIES[i]]=value;},this);this.startObserve();this.initialized=true;return this._values;}.bind(this),function(error){this._initPromise=null;return Promise.reject(error);}.bind(this));this._initPromise=promise;return promise;};SettingsManagerBase.prototype.startObserve=function(){if(this._callbacks){return;}
var callbacks=this._callbacks=[];this.KEYS.forEach(function(key,i){var callback=function(e){this._values[this.PROPERTIES[i]]=e.settingValue;if(typeof this.onsettingchange==='function'){this.onsettingchange(this._values);}}.bind(this);navigator.mozSettings.addObserver(key,callback);callbacks.push(callback);},this);};SettingsManagerBase.prototype.stopObserve=function(){if(!this._callbacks){return;}
var callbacks=this._callbacks;this.KEYS.forEach(function(key,i){navigator.mozSettings.removeObserver(key,callbacks[i]);},this);this._callbacks=null;};var SoundFeedbackSettings=function(){};SoundFeedbackSettings.prototype=new SettingsManagerBase();SoundFeedbackSettings.prototype.KEYS=['keyboard.clicksound','audio.volume.notification'];SoundFeedbackSettings.prototype.PROPERTIES=['clickEnabled','isSoundEnabled'];var VibrationFeedbackSettings=function(){};VibrationFeedbackSettings.prototype=new SettingsManagerBase();VibrationFeedbackSettings.prototype.KEYS=['keyboard.vibration'];VibrationFeedbackSettings.prototype.PROPERTIES=['vibrationEnabled'];var IMEngineSettings=function(){};IMEngineSettings.prototype=new SettingsManagerBase();IMEngineSettings.prototype.KEYS=['keyboard.wordsuggestion','keyboard.autocorrect'];IMEngineSettings.prototype.PROPERTIES=['suggestionsEnabled','correctionsEnabled'];var HandwritingPadSettings=function(){};HandwritingPadSettings.prototype=new SettingsManagerBase();HandwritingPadSettings.prototype.KEYS=['keyboard.handwriting.strokeWidth','keyboard.handwriting.responseTime'];HandwritingPadSettings.prototype.PROPERTIES=['strokeWidth','responseTime'];var UserPressManagerSettings=function(){};UserPressManagerSettings.prototype=new SettingsManagerBase();UserPressManagerSettings.prototype.KEYS=['deviceinfo.hardware','deviceinfo.product_model'];UserPressManagerSettings.prototype.PROPERTIES=['deviceinfoHardware','deviceinfoProductModel'];exports.SettingsPromiseManager=SettingsPromiseManager;exports.SettingsManagerBase=SettingsManagerBase;exports.SoundFeedbackSettings=SoundFeedbackSettings;exports.VibrationFeedbackSettings=VibrationFeedbackSettings;exports.IMEngineSettings=IMEngineSettings;exports.HandwritingPadSettings=HandwritingPadSettings;exports.UserPressManagerSettings=UserPressManagerSettings;})(window);

View file

@ -0,0 +1,6 @@
;'use strict';(function(exports){var SoundFeedbackPlayer=function(){this._audioCtx=null;this._clickerAudioBuf=null;this._specialClickerAudioBuf=null;};SoundFeedbackPlayer.prototype.CLICK_SOUND_URL='./resources/sounds/key.wav';SoundFeedbackPlayer.prototype.SPECIAL_SOUND_URL='./resources/sounds/special.wav';SoundFeedbackPlayer.prototype.activate=function(){if(this._audioCtx){return;}
this._audioCtx=new AudioContext('system');};SoundFeedbackPlayer.prototype.deactivate=function(){this._audioCtx=null;};SoundFeedbackPlayer.prototype.prepare=function(){if(typeof AudioContext==='undefined'||typeof OfflineAudioContext==='undefined'){console.error('SoundFeedbackPlayer: No Web Audio API on this platform.');return;}
var clickerPromise=this._getAudioFileAsArrayBuffer(this.CLICK_SOUND_URL).then(this._decodeAudioData.bind(this)).then(function(audioBuffer){this._clickerAudioBuf=audioBuffer;}.bind(this));var specialClickerPromise=this._getAudioFileAsArrayBuffer(this.SPECIAL_SOUND_URL).then(this._decodeAudioData.bind(this)).then(function(audioBuffer){this._specialClickerAudioBuf=audioBuffer;}.bind(this));return Promise.all([clickerPromise,specialClickerPromise]).catch(function(e){console.error(e);throw e;});};SoundFeedbackPlayer.prototype._getAudioFileAsArrayBuffer=function(url){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest();xhr.open('GET',url);xhr.responseType='arraybuffer';xhr.onload=function(){if(!xhr.response){reject('SoundFeedbackPlayer: Cannot load file: '+url);return;}
resolve(xhr.response);};xhr.send();});};SoundFeedbackPlayer.prototype._decodeAudioData=function(arrayBuffer){return new Promise(function(resolve,reject){var ctx=new OfflineAudioContext(2,1,44100);ctx.decodeAudioData(arrayBuffer,function(audioBuffer){resolve(audioBuffer);},function(){reject('SoundFeedbackPlayer: decodeAudioData failed.');});}.bind(this));};SoundFeedbackPlayer.prototype.play=function(isSpecialKey){if(!this._clickerAudioBuf||!this._specialClickerAudioBuf){console.warn('SoundFeedbackPlayer: '+'Sound feedback needed but audio buffer is not available yet.');return;}
if(!this._audioCtx){console.error('SoundFeedbackPlayer: play() is called but not activated?');return;}
var ctx=this._audioCtx;var source=ctx.createBufferSource();source.buffer=isSpecialKey?this._specialClickerAudioBuf:this._clickerAudioBuf;source.connect(ctx.destination);source.start(0);};exports.SoundFeedbackPlayer=SoundFeedbackPlayer;})(window);

View file

@ -0,0 +1,8 @@
;'use strict';(function(exports){var StateManager=function(app){this.app=app;this._started=false;this._isActive=undefined;this._layoutName=undefined;};StateManager.prototype.start=function(){this.app.console.log('StateManager.start()');if(this._started){throw new Error('StateManager: Should not be start()\'ed twice.');}
this._started=true;this._isActive=false;this._queue=new AbortablePromiseQueue();this._queue.start();window.addEventListener('hashchange',this);window.addEventListener('visibilitychange',this);navigator.mozInputMethod.addEventListener('inputcontextchange',this);this.app.setInputContext(navigator.mozInputMethod.inputcontext);this._layoutName=window.location.hash.substr(1);var active=(!document.hidden&&!!this.app.inputContext);if(!active){this._queue.run([this._preloadLayout.bind(this),this._preloadInputMethod.bind(this),this.app.l10nLoader.load.bind(this.app.l10nLoader)]);}
this._updateActiveState(active);};StateManager.prototype.stop=function(){this.app.console.log('StateManager.stop()');if(!this._started){throw new Error('StateManager: Was not start()\'ed but stop() is called.');}
this._started=false;this._queue.stop();this._queue=null;window.removeEventListener('hashchange',this);window.removeEventListener('visibilitychange',this);navigator.mozInputMethod.removeEventListener('inputcontextchange',this);this._isActive=undefined;this._layoutName=undefined;};StateManager.prototype.handleEvent=function(evt){var active=(!document.hidden&&!!navigator.mozInputMethod.inputcontext);this.app.console.info('StateManager.handleEvent()',evt,active);switch(evt.type){case'hashchange':this._layoutName=window.location.hash.substr(1);if(!active){this._queue.run([this._preloadLayout.bind(this),this._preloadInputMethod.bind(this)]);}
break;case'visibilitychange':break;case'inputcontextchange':this.app.setInputContext(navigator.mozInputMethod.inputcontext);break;}
this._updateActiveState(active);};StateManager.prototype._updateActiveState=function(active){this.app.console.log('StateManager._updateActiveState()',active);if(active){this.app.console.time('activate');this._queue.run([function(){this.app.candidatePanelManager.hideFullPanel();this.app.candidatePanelManager.updateCandidates([]);this.app.inputMethodManager.deactivateIMEngine();this.app.feedbackManager.activate();}.bind(this),this.app.layoutManager.switchCurrentLayout.bind(this.app.layoutManager,this._layoutName),this._activateIMEngineForCurrentPage.bind(this),this.app.layoutRenderingManager.updateLayoutRendering.bind(this.app.layoutRenderingManager),this.app.l10nLoader.load.bind(this.app.l10nLoader)]);}else{if(active===this._isActive){return;}
this._queue.run([function(){this.app.candidatePanelManager.hideFullPanel();this.app.candidatePanelManager.updateCandidates([]);this.app.targetHandlersManager.activeTargetsManager.clearAllTargets();this.app.feedbackManager.deactivate();}.bind(this),this.app.inputMethodManager.deactivateIMEngine.bind(this.app.inputMethodManager)]);}
this._isActive=active;};StateManager.prototype._preloadLayout=function(){this.app.console.log('StateManager._preloadLayout()');var layoutLoader=this.app.layoutManager.loader;return layoutLoader.getLayoutAsync(this._layoutName);};StateManager.prototype._preloadInputMethod=function(layout){this.app.console.log('StateManager._preloadInputMethod()');var imEngineName=layout.imEngine;var imEngineLoader=this.app.inputMethodManager.loader;if(imEngineName){var p=imEngineLoader.getInputMethodAsync(imEngineName);return p;}};StateManager.prototype._activateIMEngineForCurrentPage=function(){this.app.console.log('StateManager._activateIMEngineForCurrentPage()');var page=this.app.layoutManager.currentPage;var imEngineName=page.imEngine||'default';this.app.upperCaseStateManager.reset();this.app.candidatePanelManager.reset();var p=this.app.inputMethodManager.activateIMEngine(imEngineName);return p;};exports.StateManager=StateManager;})(window);

View file

@ -0,0 +1,14 @@
;'use strict';(function(exports){var DefaultTargetHandler=function(target,app){this.target=target;this.app=app;this.ignoreCommitActions=false;};DefaultTargetHandler.prototype.activate=function(){this.app.console.log('DefaultTargetHandler.activate()');this.app.feedbackManager.triggerFeedback(this.target);this.app.visualHighlightManager.show(this.target);};DefaultTargetHandler.prototype.longPress=function(){this.app.console.log('DefaultTargetHandler.longPress()');if(!('longPressValue'in this.target)){return;}
this.ignoreCommitActions=true;var keyCode=this.target.longPressKeyCode;var promise=Promise.resolve(this.app.inputMethodManager.currentIMEngine.click(keyCode));this.app.visualHighlightManager.hide(this.target);return promise;};DefaultTargetHandler.prototype.moveOut=function(){this.app.console.log('DefaultTargetHandler.moveOut()');this.app.visualHighlightManager.hide(this.target);};DefaultTargetHandler.prototype.moveIn=function(){this.app.console.log('DefaultTargetHandler.moveIn()');this.app.visualHighlightManager.show(this.target);};DefaultTargetHandler.prototype.commit=function(){this.app.console.log('DefaultTargetHandler.commit()');if(this.ignoreCommitActions){this.app.console.log('DefaultTargetHandler.commit()::return early');return;}
var keyCode=this.target.keyCode;var keyCodeUpper=this.target.keyCodeUpper;var engine=this.app.inputMethodManager.currentIMEngine;var code=this.app.upperCaseStateManager.isUpperCase?keyCodeUpper:keyCode;this.app.console.log('DefaultTargetHandler.commit()::engine.click',code);var promise=Promise.resolve(engine.click(code));this.app.visualHighlightManager.hide(this.target);return promise;};DefaultTargetHandler.prototype.cancel=function(){this.app.console.log('DefaultTargetHandler.cancel()');this.app.visualHighlightManager.hide(this.target);};DefaultTargetHandler.prototype.doubleTap=function(){this.app.console.log('DefaultTargetHandler.doubleTap()');return this.commit();};DefaultTargetHandler.prototype.newTargetActivate=function(){this.commit();this.ignoreCommitActions=true;};DefaultTargetHandler.prototype.move=function(){};var NullTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};NullTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);NullTargetHandler.prototype.activate=NullTargetHandler.prototype.moveIn=NullTargetHandler.prototype.moveOut=NullTargetHandler.prototype.commit=NullTargetHandler.prototype.cancel=NullTargetHandler.prototype.doubleTap=function(){};var SpaceKeyTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};SpaceKeyTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);SpaceKeyTargetHandler.prototype.longPress=function(){this.app.targetHandlersManager.activeTargetsManager.clearAllTargets();navigator.mozInputMethod.mgmt.hide();this.app.visualHighlightManager.hide(this.target);};var CandidateSelectionTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};CandidateSelectionTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);CandidateSelectionTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('CandidateSelectionTargetHandler.commit()::return early');return;}
this.app.candidatePanelManager.hideFullPanel();var engine=this.app.inputMethodManager.currentIMEngine;if(typeof engine.select==='function'){engine.select(this.target.text,this.target.data);}
this.app.visualHighlightManager.hide(this.target);};var BackspaceTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);this.deleteTimeout=undefined;this.deleteInterval=undefined;this.ignoreCommitActions=false;};BackspaceTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);BackspaceTargetHandler.prototype.REPEAT_RATE=50;BackspaceTargetHandler.prototype.REPEAT_TIMEOUT=500;BackspaceTargetHandler.prototype._sendDelete=function(isRepeat){var engine=this.app.inputMethodManager.currentIMEngine;engine.click(KeyEvent.DOM_VK_BACK_SPACE,null,isRepeat);};BackspaceTargetHandler.prototype.activate=function(){this.app.feedbackManager.triggerFeedback(this.target);this.app.visualHighlightManager.show(this.target);this.deleteTimeout=setTimeout(function(){this._sendDelete(true);this.deleteInterval=setInterval(function(){this._sendDelete(true);}.bind(this),this.REPEAT_RATE);}.bind(this),this.REPEAT_TIMEOUT);};BackspaceTargetHandler.prototype.moveOut=function(){this.app.visualHighlightManager.hide(this.target);clearTimeout(this.deleteTimeout);clearInterval(this.deleteInterval);};BackspaceTargetHandler.prototype.moveIn=function(){this.ignoreCommitActions=true;};BackspaceTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('BackspaceTargetHandler.commit()::return early');return;}
clearTimeout(this.deleteTimeout);clearInterval(this.deleteInterval);this._sendDelete(false);this.app.visualHighlightManager.hide(this.target);};BackspaceTargetHandler.prototype.cancel=function(){clearTimeout(this.deleteTimeout);clearInterval(this.deleteInterval);this.app.visualHighlightManager.hide(this.target);};var CompositeTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};CompositeTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);CompositeTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('CompositeTargetHandler.commit()::return early');return;}
var compositeString=this.target.compositeKey;var promise;var engine=this.app.inputMethodManager.currentIMEngine;if(engine.handleKey){promise=engine.handleKey({key:compositeString,printable:true});}else{promise=Promise.resolve();compositeString.split('').forEach(function(chr){promise=promise.then(function(){return engine.click(chr.charCodeAt(0));},function(e){console.error(e);return engine.click(chr.charCodeAt(0));});});}
this.app.visualHighlightManager.hide(this.target);return promise;};var PageSwitchingTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};PageSwitchingTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);PageSwitchingTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('PageSwitchingTargetHandler.commit()::return early');return;}
var page=this.target.targetPage;this.app.setLayoutPage(page);this.app.visualHighlightManager.hide(this.target);var currentIMEngine=this.app.inputMethodManager.currentIMEngine;if(typeof currentIMEngine.empty==='function'){currentIMEngine.empty();}};var CapsLockTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);this.isPreviouslyUpperCase=undefined;};CapsLockTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);CapsLockTargetHandler.prototype.isNewTargetActivated=false;CapsLockTargetHandler.prototype.activate=function(){this.isPreviouslyUpperCase=this.app.upperCaseStateManager.isUpperCase;this.app.upperCaseStateManager.switchUpperCaseState({isUpperCaseLocked:true});this.app.feedbackManager.triggerFeedback(this.target);this.app.visualHighlightManager.show(this.target);};CapsLockTargetHandler.prototype.commit=function(){if(this.isNewTargetActivated){this.app.upperCaseStateManager.switchUpperCaseState({isUpperCase:false,isUpperCaseLocked:false});}else{this.app.upperCaseStateManager.switchUpperCaseState({isUpperCase:!this.isPreviouslyUpperCase,isUpperCaseLocked:false});}
this.app.visualHighlightManager.hide(this.target);};CapsLockTargetHandler.prototype.doubleTap=function(){this.app.upperCaseStateManager.switchUpperCaseState({isUpperCaseLocked:true});this.app.visualHighlightManager.hide(this.target);};CapsLockTargetHandler.prototype.newTargetActivate=function(){this.isNewTargetActivated=true;};var SwitchKeyboardTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};SwitchKeyboardTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);SwitchKeyboardTargetHandler.prototype.longPress=function(){this.ignoreCommitActions=true;this.app.targetHandlersManager.activeTargetsManager.clearAllTargets();navigator.mozInputMethod.mgmt.showAll();this.app.visualHighlightManager.hide(this.target);};SwitchKeyboardTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){return;}
this.app.targetHandlersManager.activeTargetsManager.clearAllTargets();navigator.mozInputMethod.mgmt.next();this.app.visualHighlightManager.hide(this.target);};var ToggleCandidatePanelTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};ToggleCandidatePanelTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);ToggleCandidatePanelTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('ToggleCandidatePanelTargetHandler.commit()::return early');return;}
this.app.candidatePanelManager.toggleFullPanel();this.app.visualHighlightManager.hide(this.target);};var DismissSuggestionsTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};DismissSuggestionsTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);DismissSuggestionsTargetHandler.prototype.commit=function(){if(this.ignoreCommitActions){this.app.console.log('DismissSuggestionsTargetHandler.commit()::return early');return;}
var engine=this.app.inputMethodManager.currentIMEngine;if(typeof engine.dismissSuggestions==='function'){engine.dismissSuggestions();}
this.app.visualHighlightManager.hide(this.target);};var HandwritingPadTargetHandler=function(target,app){DefaultTargetHandler.apply(this,arguments);};HandwritingPadTargetHandler.prototype=Object.create(DefaultTargetHandler.prototype);HandwritingPadTargetHandler.prototype.activate=function(press){this.app.handwritingPadsManager.handlePressStart(press);};HandwritingPadTargetHandler.prototype.move=function(press){this.app.handwritingPadsManager.handlePressMove(press);};HandwritingPadTargetHandler.prototype.moveOut=function(press){};HandwritingPadTargetHandler.prototype.moveIn=function(press){this.app.handwritingPadsManager.handlePressStart(press);};HandwritingPadTargetHandler.prototype.commit=function(){this.app.handwritingPadsManager.handlePressEnd();};HandwritingPadTargetHandler.prototype.newTargetActivate=function(){};exports.DefaultTargetHandler=DefaultTargetHandler;exports.NullTargetHandler=NullTargetHandler;exports.SpaceKeyTargetHandler=SpaceKeyTargetHandler;exports.CandidateSelectionTargetHandler=CandidateSelectionTargetHandler;exports.BackspaceTargetHandler=BackspaceTargetHandler;exports.CompositeTargetHandler=CompositeTargetHandler;exports.PageSwitchingTargetHandler=PageSwitchingTargetHandler;exports.CapsLockTargetHandler=CapsLockTargetHandler;exports.SwitchKeyboardTargetHandler=SwitchKeyboardTargetHandler;exports.ToggleCandidatePanelTargetHandler=ToggleCandidatePanelTargetHandler;exports.DismissSuggestionsTargetHandler=DismissSuggestionsTargetHandler;exports.HandwritingPadTargetHandler=HandwritingPadTargetHandler;})(window);

View file

@ -0,0 +1,7 @@
;'use strict';(function(exports){var TargetHandlersManager=function(app){this.handlers=undefined;this.activeTargetsManager=null;this.app=app;this.promiseQueue=Promise.resolve();};TargetHandlersManager.prototype.start=function(){this.app.console.log('TargetHandlersManager.start()');this.handlers=new WeakMap();var activeTargetsManager=this.activeTargetsManager=new ActiveTargetsManager(this.app);activeTargetsManager.ontargetactivated=this._callTargetAction.bind(this,'activate',true,false);activeTargetsManager.ontargetlongpressed=this._callTargetAction.bind(this,'longPress',false,false);activeTargetsManager.ontargetmoved=this._callTargetAction.bind(this,'move',false,false);activeTargetsManager.ontargetmovedout=this._callTargetAction.bind(this,'moveOut',false,true);activeTargetsManager.ontargetmovedin=this._callTargetAction.bind(this,'moveIn',true,false);activeTargetsManager.ontargetcommitted=this._callTargetAction.bind(this,'commit',false,true);activeTargetsManager.ontargetcancelled=this._callTargetAction.bind(this,'cancel',false,true);activeTargetsManager.ontargetdoubletapped=this._callTargetAction.bind(this,'doubleTap',false,true);activeTargetsManager.onnewtargetwillactivate=this._callTargetAction.bind(this,'newTargetActivate',false,false);activeTargetsManager.start();};TargetHandlersManager.prototype.stop=function(){this.app.console.log('TargetHandlersManager.stop()');this.handlers=null;this.activeTargetsManager.stop();this.activeTargetsManager=null;};TargetHandlersManager.prototype._callTargetAction=function(action,setHandler,deleteHandler,target,press){this.app.console.log('TargetHandlersManager._callTargetAction()',action,setHandler,deleteHandler,target);this._preprocessActions(action,target);var handler;if(this.handlers.has(target)){handler=this.handlers.get(target);if(setHandler){console.warn('TargetHandlersManager: '+'calling targetHandler.'+action+'() on existing handler.');}
if(deleteHandler){this.handlers.delete(target);}}else{handler=this._createHandlerForTarget(target);if(!setHandler){console.warn('TargetHandlersManager: '+'calling targetHandler.'+action+'() on non-existing handler.');}
if(!deleteHandler){this.handlers.set(target,handler);}}
this.promiseQueue=this.promiseQueue.then(function(){return handler[action](press);}).catch(function(e){console.warn('TargetHandlersManager: '+'Error occurred for '+action+': ',e);});};TargetHandlersManager.prototype._createHandlerForTarget=function(target){this.app.console.log('TargetHandlersManager._createHandlerForTarget()');var handler;if('isDismissSuggestionsButton'in target){handler=new DismissSuggestionsTargetHandler(target,this.app);}else if('suggestion'in target){handler=new CandidateSelectionTargetHandler(target,this.app);}else if('compositeKey'in target){handler=new CompositeTargetHandler(target,this.app);}else if(target.isHandwritingPad){handler=new HandwritingPadTargetHandler(target,this.app);}else if('keyCode'in target){switch(target.keyCode){case KeyEvent.DOM_VK_BACK_SPACE:handler=new BackspaceTargetHandler(target,this.app);break;case KeyEvent.DOM_VK_SPACE:handler=new SpaceKeyTargetHandler(target,this.app);break;case KeyEvent.DOM_VK_ALT:handler=new PageSwitchingTargetHandler(target,this.app);break;case this.app.layoutManager.KEYCODE_SWITCH_KEYBOARD:handler=new SwitchKeyboardTargetHandler(target,this.app);break;case this.app.layoutManager.KEYCODE_TOGGLE_CANDIDATE_PANEL:handler=new ToggleCandidatePanelTargetHandler(target,this.app);break;case KeyEvent.DOM_VK_CAPS_LOCK:handler=new CapsLockTargetHandler(target,this.app);break;default:handler=new DefaultTargetHandler(target,this.app);break;}}else{handler=new NullTargetHandler(target,this.app);}
return handler;};TargetHandlersManager.prototype._preprocessActions=function(action,target){switch(action){case'activate':case'moveIn':if(target.isHandwritingPad){this.activeTargetsManager.blockNewUserPress=true;this.activeTargetsManager.blockTargetMovedOut=true;}
break;case'commit':case'doubleTap':if(target.isHandwritingPad){this.activeTargetsManager.blockNewUserPress=false;this.activeTargetsManager.blockTargetMovedOut=false;}
break;}};exports.TargetHandlersManager=TargetHandlersManager;})(window);

View file

@ -0,0 +1,4 @@
;'use strict';(function(exports){var UpperCaseStateManager=function(){this.isUpperCase=undefined;this.isUpperCaseLocked=undefined;};UpperCaseStateManager.prototype.onstatechange=null;UpperCaseStateManager.prototype.start=UpperCaseStateManager.prototype.reset=function(){this.isUpperCase=false;this.isUpperCaseLocked=false;};UpperCaseStateManager.prototype.stop=function(){this.isUpperCase=undefined;this.isUpperCaseLocked=undefined;};UpperCaseStateManager.prototype.switchUpperCaseState=function(state){if(!state){return;}
var newIsUpperCase=(typeof state.isUpperCase==='boolean')?state.isUpperCase:this.isUpperCase;var newIsUpperCaseLocked=(typeof state.isUpperCaseLocked==='boolean')?state.isUpperCaseLocked:this.isUpperCaseLocked;if(newIsUpperCaseLocked){newIsUpperCase=true;}
var statechanged=(this.isUpperCase!==newIsUpperCase)||(this.isUpperCaseLocked!==newIsUpperCaseLocked);if(!statechanged){return;}
this.isUpperCase=newIsUpperCase;this.isUpperCaseLocked=newIsUpperCaseLocked;if(typeof this.onstatechange==='function'){this.onstatechange();}};exports.UpperCaseStateManager=UpperCaseStateManager;})(window);

View file

@ -0,0 +1,19 @@
;'use strict';(function(exports){var UserPress=function(obj,coords){this.target=obj;this.updateCoords(coords,false);this.startTime=Date.now();this.startCoords=coords;this.startTarget=obj;};UserPress.prototype.updateCoords=function(coords,moved){this.moved=moved;this.clientX=coords.clientX;this.clientY=coords.clientY;this.endTime=Date.now();};var UserPressManager=function(app){this._started=false;this._ignoreMouseEvents=false;this.presses=new Map();this.touchstartCounts=new WeakMap();this.app=app;};UserPressManager.prototype.onpressstart=null;UserPressManager.prototype.onpressmove=null;UserPressManager.prototype.onpressend=null;UserPressManager.prototype.MOVE_LIMIT=5;UserPressManager.prototype.MIN_BOGUS_EVENT_DISTANCE=20;UserPressManager.prototype.MIN_BOGUS_EVENT_VELOCITY=0.3;UserPressManager.prototype.start=function(){this.app.console.log('UserPressManager.start()');if(this._started){throw new Error('UserPressManager: '+'Instance should not be start()\'ed twice.');}
this._started=true;this._container=this.app.getContainer();this._container.addEventListener('touchstart',this);this._container.addEventListener('mousedown',this);this._container.addEventListener('contextmenu',this);this._isLowEndDevice=false;this.settings=new UserPressManagerSettings();this.settings.promiseManager=this.app.settingsPromiseManager;this.settings.onsettingchange=this._handleSettingsChange.bind(this);this.settings.initSettings().then(this._handleSettingsChange.bind(this),function rejected(err){console.error('Fatal Error! Failed to get initial '+'targetHandlersManager settings.',err);});};UserPressManager.prototype.stop=function(){this.app.console.log('UserPressManager.stop()');if(!this._started){throw new Error('UserPressManager: '+'Instance was never start()\'ed but stop() is called.');}
this._started=false;this._container.removeEventListener('touchstart',this);this._container.removeEventListener('mousedown',this);this._container.removeEventListener('mousemove',this);this._container.removeEventListener('mouseup',this);this._container.removeEventListener('mouseleave',this);this._container.removeEventListener('contextmenu',this);this.settings=null;};UserPressManager.prototype.handleEvent=function(evt){var touch,touchId,el,i,touchstartCount;switch(evt.type){case'contextmenu':evt.preventDefault();break;case'touchstart':this._ignoreMouseEvents=true;touchstartCount=this.touchstartCounts.get(evt.target)||0;touchstartCount++;this.touchstartCounts.set(evt.target,touchstartCount);evt.target.addEventListener('touchmove',this);evt.target.addEventListener('touchend',this);evt.target.addEventListener('touchcancel',this);for(i=0;i<evt.changedTouches.length;i++){touch=evt.changedTouches[i];touchId=touch.identifier;el=touch.target;this._handleNewPress(el,touch,touchId);}
break;case'touchmove':for(i=0;i<evt.changedTouches.length;i++){touch=evt.changedTouches[i];touchId=touch.identifier;if(!this._distanceReachesLimit(touchId,touch)){continue;}
el=document.elementFromPoint(touch.clientX,touch.clientY);this._handleChangedPress(el,touch,touchId);}
break;case'touchend':case'touchcancel':touchstartCount=this.touchstartCounts.get(evt.target);touchstartCount--;if(touchstartCount){this.touchstartCounts.set(evt.target,touchstartCount);}else{evt.target.removeEventListener('touchmove',this);evt.target.removeEventListener('touchend',this);evt.target.removeEventListener('touchcancel',this);this.touchstartCounts.delete(evt.target);}
if(!this._started){return;}
for(i=0;i<evt.changedTouches.length;i++){touch=evt.changedTouches[i];touchId=touch.identifier;el=document.elementFromPoint(touch.clientX,touch.clientY);this._handleFinishPress(el,touch,touchId);}
break;case'mousedown':evt.preventDefault();if(this._ignoreMouseEvents){return;}
this._container.addEventListener('mousemove',this);this._container.addEventListener('mouseup',this);this._container.addEventListener('mouseleave',this);this._handleNewPress(evt.target,evt,'_mouse');break;case'mousemove':if(!this._distanceReachesLimit('_mouse',evt)){return;}
this._handleChangedPress(evt.target,evt,'_mouse');break;case'mouseup':case'mouseleave':this._container.removeEventListener('mousemove',this);this._container.removeEventListener('mouseup',this);this._container.removeEventListener('mouseleave',this);this._handleFinishPress(evt.target,evt,'_mouse');break;}};UserPressManager.prototype._handleNewPress=function(el,coords,id){this.app.console.info('UserPressManager._handleNewPress()');var press=new UserPress(this.app.layoutRenderingManager.getTargetObject(el),coords);this.presses.set(id,press);if(typeof this.onpressstart==='function'){this.onpressstart(press,id);}};UserPressManager.prototype._handleChangedPress=function(el,coords,id){this.app.console.info('UserPressManager._handleChangedPress()');var press=this.presses.get(id);press.target=this.app.layoutRenderingManager.getTargetObject(el);press.updateCoords(coords,true);if(typeof this.onpressmove==='function'){this.onpressmove(press,id);}};UserPressManager.prototype._handleFinishPress=function(el,coords,id){this.app.console.info('UserPressManager._handleFinishPress()');if(this._isLowEndDevice){this._handleLowEndDeviceFinishPress(el,coords,id);return;}
var press=this.presses.get(id);press.target=this.app.layoutRenderingManager.getTargetObject(el);press.updateCoords(coords,press.moved||this._distanceReachesLimit(id,coords));if(typeof this.onpressend==='function'){this.onpressend(press,id);}
this.presses.delete(id);};UserPressManager.prototype._handleLowEndDeviceFinishPress=function(el,coords,id){this.app.console.info('UserPressManager._handleLowEndDeviceFinishPress()');var press=this.presses.get(id);press.target=this.app.layoutRenderingManager.getTargetObject(el);press.updateCoords(coords,press.moved||this._distanceReachesLimit(id,coords));if(this._exceedSpeedLimit(press)&&press.target.keyCode!==press.startTarget.keyCode){var currentTargetObject=press.target;press.target=press.startTarget;press.updateCoords(press.startCoords,true);if(typeof this.onpressmove==='function'){this.onpressmove(press,id);}
if(typeof this.onpressend==='function'){this.onpressend(press,id);}
this.presses.delete(id);var syntheticPress=new UserPress(currentTargetObject,coords);if(typeof this.onpressstart==='function'){this.onpressstart(syntheticPress,id);}
syntheticPress.updateCoords(coords,false);if(typeof this.onpressend==='function'){this.onpressend(syntheticPress,id);}}else{if(typeof this.onpressend==='function'){this.onpressend(press,id);}
this.presses.delete(id);}};UserPressManager.prototype._exceedSpeedLimit=function(press){var dx=press.startCoords.clientX-press.clientX;var dy=press.startCoords.clientY-press.clientY;if(dx+dy===0){return false;}
var time=press.endTime-press.startTime;var distance=Math.sqrt(dx*dx+dy*dy);if(distance<this.MIN_BOGUS_EVENT_DISTANCE){return false;}
return(distance/time>this.MIN_BOGUS_EVENT_VELOCITY);};UserPressManager.prototype._distanceReachesLimit=function(id,newCoord){var press=this.presses.get(id);var dx=press.clientX-newCoord.clientX;var dy=press.clientY-newCoord.clientY;var limit=this.MOVE_LIMIT;return(dx>=limit||dx<=-limit||dy>=limit||dy<=-limit);};UserPressManager.prototype._handleSettingsChange=function(values){this._isLowEndDevice=values.deviceinfoHardware==='sp8810'||values.deviceinfoHardware==='roamer2'||values.deviceinfoProductModel==='GP-KEON'||values.deviceinfoProductModel==='GoFox F15';};exports.UserPress=UserPress;exports.UserPressManager=UserPressManager;})(window);

View file

@ -0,0 +1,24 @@
;'use strict';(function(exports){function ViewManager(app){this.app=app;this.viewMap=new WeakMap();this.currentPageView=null;this.pageViews=new Map();this.alternativesCharMenu=null;this.columnCount=10;}
ViewManager.prototype={get candidatePanel(){if(!this.currentPageView||!this.currentPageView.candidatePanel){return;}
return this.currentPageView.candidatePanel.element;}};ViewManager.prototype.start=function(){this.container=document.getElementById('keyboard');this.cachedWindowHeight=window.innerHeight||window.screen.height;this.cachedWindowWidth=window.innerWidth||window.screen.width;window.addEventListener('resize',this);};ViewManager.prototype.stop=function(){this.container=null;this.viewMap=null;this.currentPageView=null;this.pageViews=null;window.removeEventListener('resize',this);};ViewManager.prototype.handleEvent=function(evt){if(evt.type!=='resize'){return;}
this.cachedWindowHeight=window.innerHeight||window.screen.height;this.cachedWindowWidth=window.innerWidth||window.screen.width;};ViewManager.prototype.setUpperCaseLock=function(state){if(!this.currentPageView){console.error('No current page view!');return;}
this.currentPageView.setUpperCaseLock(state);};ViewManager.prototype.render=function(layout,flags,callback){this.app.console.log('ViewManager.render()');this.app.console.time('ViewManager.render()');flags=flags||{};this.columnCount=layout.width||10;var supportsSwitching='mozInputMethod'in navigator?navigator.mozInputMethod.mgmt.supportsSwitching():false;var pageId=[layout.layoutName,layout.pageIndex,(''+flags.inputType).substr(0,1),(''+flags.showCandidatePanel).substr(0,1),supportsSwitching].join('-');var pageView=this.pageViews.get(pageId);if(!pageView){var options={classNames:['keyboard-type-container'],totalWidth:this.container.clientWidth,showCandidatePanel:flags.showCandidatePanel};pageView=this._createPageView(layout,options);if(!layout.updateByIMEngine){this.pageViews.set(pageId,pageView);}
pageView.render();this.container.appendChild(pageView.element);if(flags.showCandidatePanel){this.showCandidates([]);}}
pageView.setUpperCaseLock({isUpperCase:flags.uppercase,isUpperCaseLocked:false});if(this.currentPageView!==pageView){if(this.currentPageView){this.currentPageView.hide();}
if(this.currentPageView&&this.currentPageView.layout.updateByIMEngine){this.currentPageView.destroy();}
pageView.show();this.currentPageView=pageView;this.resize(callback);}else if((this.container.classList.contains('landscape')&&this.screenInPortraitMode())||(this.container.classList.contains('portrait')&&!this.screenInPortraitMode())){this.resize(callback);}
else{if(callback){window.requestAnimationFrame(callback);}}
this.app.console.timeEnd('ViewManager.render()');};ViewManager.prototype.drawHandwritingPad=function(press,start,strokeWidth){var handwritingPadView=this.viewMap.get(press.target);return handwritingPadView.drawHandwritingPad(press,start,strokeWidth);};ViewManager.prototype.clearHandwritingPad=function(target){var handwritingPadView=this.viewMap.get(target);return handwritingPadView.clearHandwritingPad();};ViewManager.prototype.highlightKey=function(target){if(!this.currentPageView){console.error('No current page view!');return;}
this.currentPageView.highlightKey(target);};ViewManager.prototype.unHighlightKey=function(target){if(!this.currentPageView){console.error('ViewManager: No current page view!');return;}
this.currentPageView.unHighlightKey(target);};ViewManager.prototype.toggleCandidatePanel=function(expand){if(!this.currentPageView){console.error('ViewManager: No current page view!');return;}
this.currentPageView.resetCandidatePanel();this._toggleCandidatePanelWithoutResetScroll(expand);};ViewManager.prototype._toggleCandidatePanelWithoutResetScroll=function(expand){if(expand){this.container.classList.remove('candidate-panel');this.container.classList.add('full-candidate-panel');}else{this.container.classList.remove('full-candidate-panel');this.container.classList.add('candidate-panel');}};ViewManager.prototype.showAlternativesCharMenu=function(key,altChars){var options={keyWidth:(this.cachedWindowWidth/this.columnCount)|0,screenInPortraitMode:this.screenInPortraitMode};var alternativesCharMenu=new AlternativesCharMenuView(this.currentPageView.element,altChars,options,this);var keyElement=this.viewMap.get(key).element;alternativesCharMenu.show(keyElement);this.alternativesCharMenu=alternativesCharMenu;return alternativesCharMenu;};ViewManager.prototype.hideAlternativesCharMenu=function(){if(!this.alternativesCharMenu){console.error('No alternative char menu to hide!');return;}
this.alternativesCharMenu.hide();};ViewManager.prototype.resize=function(callback){var changeScale;if(this.screenInPortraitMode()){changeScale=this.cachedWindowWidth/32;document.documentElement.style.fontSize=changeScale+'px';this.container.classList.remove('landscape');this.container.classList.add('portrait');}else{changeScale=this.cachedWindowWidth/64;document.documentElement.style.fontSize=changeScale+'px';this.container.classList.remove('portrait');this.container.classList.add('landscape');}
if(!this.currentPageView){return;}
this.currentPageView.resize(this.cachedWindowWidth);if(callback){window.requestAnimationFrame(callback);}};ViewManager.prototype.getWidth=function(){if(!this.currentPageView){return 0;}
return this.cachedWindowWidth;};ViewManager.prototype.getHeight=function(){if(!this.currentPageView){return 0;}
return this.currentPageView.getHeight()|0;};ViewManager.prototype.showCandidates=function(candidates){if(!this.currentPageView){return;}
this._toggleCandidatePanelWithoutResetScroll(false);this.currentPageView.showCandidates(candidates);};ViewManager.prototype.showMoreCandidates=function(rowLimit,candidates){if(!this.currentPageView){return;}
this.currentPageView.showMoreCandidates(rowLimit,candidates);};ViewManager.prototype.getNumberOfCandidatesPerRow=function(){if(!this.currentPageView){return;}
return this.currentPageView.getNumberOfCandidatesPerRow();};ViewManager.prototype.getKeyArray=function(){return this.currentPageView.getVisualData();};ViewManager.prototype.getKeyWidth=function(){return Math.ceil(this.cachedWindowWidth/this.columnCount);};ViewManager.prototype.getKeyHeight=function(){if(!this.currentPageView){return 0;}
return this.currentPageView.getKeyHeight();};ViewManager.prototype.registerView=function(target,view){this.app.layoutRenderingManager.domObjectMap.set(view.element,target);this.viewMap.set(target,view);};ViewManager.prototype.screenInPortraitMode=function(){return this.cachedWindowWidth<=this.cachedWindowHeight;};ViewManager.prototype.getRemToPx=function(){return this.screenInPortraitMode()?this.cachedWindowWidth/32:this.cachedWindowWidth/64;};ViewManager.prototype.getView=function(target){return this.viewMap.get(target);};ViewManager.prototype._createPageView=function(layout,options){var pageView;if(layout.panelKeys){pageView=new SwipeablePageView(layout,options,this);}else{pageView=new LayoutPageView(layout,options,this);}
return pageView;};exports.ViewManager=ViewManager;})(window);

View file

@ -0,0 +1,2 @@
;'use strict';(function(exports){var VisualHighlightManager=function(app){this.app=app;this.highlightDelayTimers=new Map();};VisualHighlightManager.prototype.HIGHTLIGHT_DELAY_MS=85;VisualHighlightManager.prototype.start=function(){};VisualHighlightManager.prototype.stop=function(){};VisualHighlightManager.prototype.show=function(target){this.highlightDelayTimers.forEach(function(timer,target){clearTimeout(timer);this.highlightDelayTimers.delete(target);this.app.viewManager.unHighlightKey(target);},this);this.app.viewManager.highlightKey(target);};VisualHighlightManager.prototype.hide=function(target){if(this.highlightDelayTimers.has(target)){clearTimeout(this.highlightDelayTimers.get(target));}
var timer=setTimeout(function(){this.highlightDelayTimers.delete(target);this.app.viewManager.unHighlightKey(target);}.bind(this),this.HIGHTLIGHT_DELAY_MS);this.highlightDelayTimers.set(target,timer);};exports.VisualHighlightManager=VisualHighlightManager;})(window);