Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
17 lines
No EOL
3.9 KiB
JavaScript
17 lines
No EOL
3.9 KiB
JavaScript
;(function startup(){'use strict';var firstScanDone=false;showUI();registerEventHandlers();finishDBInitialization();setInitialView();registerActivityHandler();displayThumbnails();doNotScanInBackgroundHack(photodb);function showUI(){document.body.classList.remove('hidden');if(!isPhone){LazyLoader.load('js/frame_scripts.js');}
|
|
window.performance.mark('navigationLoaded');}
|
|
function registerEventHandlers(){$('thumbnails-select-button').onclick=setView.bind(null,LAYOUT_MODE.select);$('selected-header').addEventListener('action',setView.bind(null,LAYOUT_MODE.list));if(!isPhone){$('fullscreen-toolbar-header').addEventListener('action',function(){setView(LAYOUT_MODE.list);});}
|
|
fullscreenButtons.camera.onclick=launchCameraApp;$('thumbnails-camera-button').onclick=launchCameraApp;Overlay.addEventListener('camera',launchCameraApp);$('thumbnails-delete-button').onclick=deleteSelectedItems;$('thumbnails-share-button').onclick=shareSelectedItems;Overlay.addEventListener('cancel',function(){if(picking){Pick.cancel();}});window.onresize=resizeHandler;window.performance.mark('navigationInteractive');}
|
|
function finishDBInitialization(){photodb.onupgrading=function(evt){Overlay.show('upgrade');};photodb.onunavailable=function(){if(!picking){if(currentView===LAYOUT_MODE.edit){exitEdit();}
|
|
setView(LAYOUT_MODE.list);}else{Pick.restart();}
|
|
var why=photodb.state;if(why===MediaDB.NOCARD){Overlay.show('nocard');}
|
|
else if(why===MediaDB.UNMOUNTED){Overlay.show('pluggedin');}};photodb.onready=function(){if(Overlay.current==='nocard'||Overlay.current==='pluggedin'||Overlay.current==='upgrade'){Overlay.hide();}};photodb.onscanstart=function onscanstart(){fullscreenButtons.edit.classList.add('disabled');$('throbber').classList.remove('hidden');$('throbber').classList.add('throb');};photodb.onscanend=function onscanend(){fullscreenButtons.edit.classList.remove('disabled');if(Overlay.current==='scanning'){Overlay.show('emptygallery');}
|
|
else if(!isPhone&&!currentFrame.displayingImage&&!currentFrame.displayingVideo){showFile(0);}
|
|
$('throbber').classList.remove('throb');setTimeout(function(){$('throbber').classList.add('hidden');},100);if(!firstScanDone){firstScanDone=true;window.performance.mark('fullyLoaded');}};photodb.oncardremoved=function oncardremoved(){if(picking){Pick.cancel();return;}
|
|
setView(LAYOUT_MODE.list);};photodb.oncreated=function(event){event.detail.forEach(fileCreated);};photodb.ondeleted=function(event){event.detail.forEach(fileDeleted);};switch(photodb.state){case MediaDB.UPGRADING:photodb.onupgrading();break;case MediaDB.READY:photodb.onready();break;case MediaDB.NOCARD:case MediaDB.UNMOUNTED:photodb.onunavailable();break;}}
|
|
function setInitialView(){if(picking){setView(LAYOUT_MODE.pick);}
|
|
else{setView(LAYOUT_MODE.list);}}
|
|
function registerActivityHandler(){navigator.mozSetMessageHandler('activity',function activityHandler(a){var activityName=a.source.name;switch(activityName){case'browse':if(currentView===LAYOUT_MODE.fullscreen){setView(LAYOUT_MODE.list);}
|
|
break;case'pick':LazyLoader.load('js/pick.js',function(){Pick.start(a);});break;}});}
|
|
function displayThumbnails(){thumbnails=Thumbnails.container;thumbnailList=Thumbnails.list;var placeholder=$('thumbnails-placeholder');placeholder.parentElement.replaceChild(thumbnails,placeholder);thumbnails.addEventListener('click',thumbnailClickHandler);Thumbnails.firstpage.then(function(){window.performance.mark('visuallyLoaded');window.performance.mark('contentInteractive');setTimeout(function(){LazyLoader.load(['shared/elements/gaia-header/dist/gaia-header.js'],function(){var headers=document.querySelectorAll('gaia-header');for(var i=0;i<headers.length;++i){headers[i].removeAttribute('no-font-fit');}});});});Thumbnails.complete.then(function(){if(files.length===0){Overlay.show('scanning');}
|
|
window.performance.mark('mediaEnumerated');photodb.addEventListener('ready',function(){photodb.scan();});if(photodb.state===MediaDB.READY){photodb.scan();}});}})(); |