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:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
define(['require','modules/settings_cache','modules/base/module','modules/mvvm/observable'],function(require){'use strict';var SettingsCache=require('modules/settings_cache');var Module=require('modules/base/module');var Observable=require('modules/mvvm/observable');var settings=window.navigator.mozSettings;var _kClockAutoEnabled='time.clock.automatic-update.enabled';var _kTimezoneAutoEnabled='time.timezone.automatic-update.enabled';var _kClockAutoAvailable='time.clock.automatic-update.available';var _kTimezoneAutoAvailable='time.timezone.automatic-update.available';var _kTimezone='time.timezone';var _kUserSelected='time.timezone.user-selected';var _kLocaleTime='locale.hour12';var _updateDateTimeout=null;var _updateTimeTimeout=null;var DateTime=Module.create(function DateTime(){this.super(Observable).call(this);this._init();}).extend(Observable);Observable.defineObservableProperty(DateTime.prototype,'clockAutoEnabled',{readonly:true,value:true});Observable.defineObservableProperty(DateTime.prototype,'clockAutoAvailable',{readonly:true,value:true});Observable.defineObservableProperty(DateTime.prototype,'timezoneAutoAvailable',{readonly:true,value:true});Observable.defineObservableProperty(DateTime.prototype,'timezone',{readonly:true,value:''});Observable.defineObservableProperty(DateTime.prototype,'userSelectedTimezone',{readonly:true,value:''});Observable.defineObservableProperty(DateTime.prototype,'date',{readonly:true,value:''});Observable.defineObservableProperty(DateTime.prototype,'time',{readonly:true,value:''});Observable.defineObservableProperty(DateTime.prototype,'currentHour12',{readonly:true,value:true});DateTime.prototype._init=function(){this._mozTime=window.navigator.mozTime;if(!this._mozTime){console.error('Could not get window.navigator.mozTime');return;}
|
||||
this._boundSetTimeAutoEnabled=function(event){this._clockAutoEnabled=event.settingValue;this._setTimezoneAutoEnabled(event.settingValue);}.bind(this);this._boundSetClockAutoAvailable=function(event){this._clockAutoAvailable=event.settingValue;}.bind(this);this._boundSetTimezoneAutoAvailable=function(event){this._timezoneAutoAvailable=event.settingValue;}.bind(this);this._boundSetTimezone=function(event){this._timezone=event.settingValue;}.bind(this);this._boundUserSelectedTimezone=function(event){this._userSelectedTimezone=event.settingValue;}.bind(this);this._boundCurrentHour12=function(event){this._currentHour12=event.settingValue;this._autoUpdateDateTime();}.bind(this);this._getDefaults();this._attachListeners();};DateTime.prototype._attachListeners=function(){window.navigator.mozSettings.addObserver(_kClockAutoEnabled,this._boundSetTimeAutoEnabled);window.navigator.mozSettings.addObserver(_kClockAutoAvailable,this._boundSetClockAutoAvailable);window.navigator.mozSettings.addObserver(_kTimezoneAutoAvailable,this._boundSetTimezoneAutoAvailable);window.navigator.mozSettings.addObserver(_kTimezone,this._boundSetTimezone);window.navigator.mozSettings.addObserver(_kUserSelected,this._boundUserSelectedTimezone);window.navigator.mozSettings.addObserver(_kLocaleTime,this._boundCurrentHour12);document.addEventListener('DOMRetranslated',this);window.addEventListener('moztimechange',this);};DateTime.prototype.handleEvent=function(evt){switch(evt.type){case'moztimechange':this._autoUpdateDateTime();break;case'DOMRetranslated':var d=new Date();this._date=this._formatDate(d);this._time=this._formatTime(d);break;}};DateTime.prototype._getDefaults=function(){SettingsCache.getSettings(function(results){this._clockAutoEnabled=results[_kClockAutoEnabled];this._clockAutoAvailable=results[_kClockAutoAvailable];this._timezoneAutoAvailable=results[_kTimezoneAutoAvailable];this._timezone=results[_kTimezone];this._currentHour12=results[_kLocaleTime];this._autoUpdateDateTime();}.bind(this));};DateTime.prototype._autoUpdateDateTime=function(){window.clearTimeout(_updateDateTimeout);window.clearTimeout(_updateTimeTimeout);this._autoUpdateDate();this._autoUpdateTime();};DateTime.prototype._autoUpdateDate=function(){var d=new Date();this._date=this._formatDate(d);var remainMillisecond=(24-d.getHours())*3600*1000-
|
||||
d.getMinutes()*60*1000-d.getMilliseconds();_updateDateTimeout=window.setTimeout(function updateDateTimeout(){this._autoUpdateDate();}.bind(this),remainMillisecond);};DateTime.prototype._autoUpdateTime=function(){var d=new Date();this._time=this._formatTime(d);var remainMillisecond=(60-d.getSeconds())*1000;_updateTimeTimeout=window.setTimeout(function updateTimeTimeout(){this._autoUpdateTime();}.bind(this),remainMillisecond);};DateTime.prototype._formatDate=function(d){return d.toLocaleString(navigator.languages,{year:'numeric',month:'long',day:'2-digit',});};DateTime.prototype._formatTime=function(d){return d.toLocaleString(navigator.languages,{hour12:navigator.mozHour12,hour:'numeric',minute:'numeric',});};DateTime.prototype.setTime=function(type,value){var newDate=new Date();var tokens;switch(type){case'date':tokens=value.split('-');newDate.setYear(tokens[0]);newDate.setMonth(tokens[1]-1);newDate.setDate(tokens[2]);break;case'time':tokens=value.split(':');newDate.setHours(parseInt(tokens[0]));newDate.setMinutes(parseInt(tokens[1]));break;}
|
||||
this._mozTime.set(newDate);};DateTime.prototype._setTimezoneAutoEnabled=function(enabled){var cset={};cset[_kTimezoneAutoEnabled]=enabled;settings.createLock().set(cset);},DateTime.prototype.setUserSelectedTimezone=function(selected){var cset={};cset[_kTimezone]=selected;settings.createLock().set(cset);};DateTime.prototype.setCurrentHour12=function(selected){var cset={};cset[_kLocaleTime]=selected;settings.createLock().set(cset);};DateTime.prototype.getHour12ForCurrentLocale=function(){var format=new Intl.DateTimeFormat(navigator.languages,{hour:'numeric'});return format.resolvedOptions().hour12;};return DateTime();});
|
||||
Loading…
Reference in a new issue