Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7420 from dscravag/nightly2
Browse files Browse the repository at this point in the history
Nightly 2013-01-09
  • Loading branch information
dscravag committed Jan 9, 2013
2 parents 7c348f4 + a069d55 commit f8e15c1
Show file tree
Hide file tree
Showing 190 changed files with 4,670 additions and 1,711 deletions.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -81,6 +81,7 @@ GAIA_LOCALES_PATH?=locales
LOCALES_FILE?=shared/resources/languages.json LOCALES_FILE?=shared/resources/languages.json
GAIA_LOCALE_SRCDIRS=shared $(GAIA_APP_SRCDIRS) GAIA_LOCALE_SRCDIRS=shared $(GAIA_APP_SRCDIRS)
GAIA_DEFAULT_LOCALE?=en-US GAIA_DEFAULT_LOCALE?=en-US
GAIA_INLINE_LOCALES?=1


############################################################################### ###############################################################################
# The above rules generate the profile/ folder and all its content. # # The above rules generate the profile/ folder and all its content. #
Expand Down Expand Up @@ -316,10 +317,12 @@ define run-js-command
const HOMESCREEN = "$(HOMESCREEN)"; const GAIA_PORT = "$(GAIA_PORT)"; \ const HOMESCREEN = "$(HOMESCREEN)"; const GAIA_PORT = "$(GAIA_PORT)"; \
const GAIA_APP_SRCDIRS = "$(GAIA_APP_SRCDIRS)"; \ const GAIA_APP_SRCDIRS = "$(GAIA_APP_SRCDIRS)"; \
const GAIA_LOCALES_PATH = "$(GAIA_LOCALES_PATH)"; \ const GAIA_LOCALES_PATH = "$(GAIA_LOCALES_PATH)"; \
const LOCALES_FILE = "$(LOCALES_FILE)"; \
const BUILD_APP_NAME = "$(BUILD_APP_NAME)"; \ const BUILD_APP_NAME = "$(BUILD_APP_NAME)"; \
const PRODUCTION = "$(PRODUCTION)"; \ const PRODUCTION = "$(PRODUCTION)"; \
const OFFICIAL = "$(MOZILLA_OFFICIAL)"; \ const OFFICIAL = "$(MOZILLA_OFFICIAL)"; \
const GAIA_DEFAULT_LOCALE = "$(GAIA_DEFAULT_LOCALE)"; \ const GAIA_DEFAULT_LOCALE = "$(GAIA_DEFAULT_LOCALE)"; \
const GAIA_INLINE_LOCALES = "$(GAIA_INLINE_LOCALES)"; \
const GAIA_ENGINE = "xpcshell"; \ const GAIA_ENGINE = "xpcshell"; \
'; \ '; \
$(XULRUNNERSDK) $(XPCSHELLSDK) -e "$$JS_CONSTS" -f build/utils.js "build/$(strip $1).js" $(XULRUNNERSDK) $(XPCSHELLSDK) -e "$$JS_CONSTS" -f build/utils.js "build/$(strip $1).js"
Expand Down
3 changes: 2 additions & 1 deletion apps/browser/js/browser.js
Expand Up @@ -733,7 +733,8 @@ var Browser = {
type: 'url', type: 'url',
url: this.currentTab.url, url: this.currentTab.url,
name: this.currentTab.title, name: this.currentTab.title,
icon: place.iconUri icon: place.iconUri,
useAsyncPanZoom: true
} }
}); });
}).bind(this)); }).bind(this));
Expand Down
4 changes: 3 additions & 1 deletion apps/browser/manifest.webapp
Expand Up @@ -10,7 +10,9 @@
"permissions": { "permissions": {
"browser":{}, "browser":{},
"systemXHR":{}, "systemXHR":{},
"settings":{ "access": "readonly" } "settings":{ "access": "readonly" },
"geolocation" : {},
"desktop-notification" : {}
}, },
"locales": { "locales": {
"ar": { "ar": {
Expand Down
3 changes: 2 additions & 1 deletion apps/calendar/caldav_worker.js
Expand Up @@ -3,6 +3,7 @@
'ext/ical', 'ext/ical',
'ext/caldav', 'ext/caldav',
'ext/uuid', 'ext/uuid',
'service/ical_recur_expansion',
'service/caldav'].forEach(function(script) { 'service/caldav'].forEach(function(script) {
// ?time= is for cache busting in development... // ?time= is for cache busting in development...
// there have been cases where nightly would not // there have been cases where nightly would not
Expand All @@ -11,7 +12,7 @@
}); });


var thread = new Calendar.Thread(this); var thread = new Calendar.Thread(this);
this.console = new thread.console(); this.console = new thread.console('caldav worker');


thread.addRole('caldav'); thread.addRole('caldav');


Expand Down
4 changes: 3 additions & 1 deletion apps/calendar/index.html
Expand Up @@ -95,7 +95,9 @@
</head> </head>


<body role="application" class="loading"> <body role="application" class="loading">

<section id="errors" role="status">
<p class="errors"></p>
</section>
<nav class="skin-organic" id="settings" role="region"> <nav class="skin-organic" id="settings" role="region">


<header> <header>
Expand Down
148 changes: 145 additions & 3 deletions apps/calendar/js/app.js
@@ -1,5 +1,82 @@
Calendar.App = (function(window) { Calendar.App = (function(window) {


function PendingManager() {
this.objects = [];
this.pending = 0;

this.onstart = this.onstart.bind(this);
this.onend = this.onend.bind(this);
}

PendingManager.prototype = {

onpending: function() {},
oncomplete: function() {},

register: function(object) {
object.on(object.startEvent, this.onstart);
object.on(object.completeEvent, this.onend);

var wasPending = this.isPending();

this.objects.push(object);

if (object.pending) {
this.pending++;

if (!wasPending) {
this.onpending();
}
}
},

/**
* Unregister an object.
* Note it is intended that objects that
* are unregistered are never in a state
* where we are waiting for their pending
* status to complete. If an incomplete
* object is removed it will break .pending.
*/
unregister: function(object) {
var idx = this.objects.indexOf(object);

if (idx !== -1) {
var object = this.objects[idx];
this.objects.splice(idx, 1);
return true;
}
return false;
},

isPending: function() {
var len = this.objects.length;
var i = 0;

for (; i < len; i++) {
if (this.objects[i].pending)
return true;
}

return false;
},

onstart: function() {
if (!this.pending) {
this.onpending();
}

this.pending++;
},

onend: function() {
this.pending--;
if (!this.pending) {
this.oncomplete();
}
}
};

/** /**
* Focal point for state management * Focal point for state management
* within calendar application. * within calendar application.
Expand All @@ -8,13 +85,17 @@ Calendar.App = (function(window) {
* location to reference database. * location to reference database.
*/ */
var App = { var App = {
PendingManager: PendingManager,

//XXX: always assumes that app is never lazy loaded //XXX: always assumes that app is never lazy loaded
startingURL: window.location.href, startingURL: window.location.href,


_location: window.location, _location: window.location,


_mozTimeRefreshTimeout: 3000, _mozTimeRefreshTimeout: 3000,


pendingClass: 'pending-operation',

// Dependency map for loading // Dependency map for loading
cssBase: '/style/', cssBase: '/style/',
jsBase: '/js/', jsBase: '/js/',
Expand All @@ -23,6 +104,10 @@ Calendar.App = (function(window) {
Style: {}, Style: {},
Templates: {}, Templates: {},
Utils: {}, Utils: {},
Controllers: {
RecurringEvents: []
},

Views: { Views: {
AdvancedSettings: [ AdvancedSettings: [
{type: 'Templates', name: 'Account'} {type: 'Templates', name: 'Account'}
Expand Down Expand Up @@ -79,7 +164,8 @@ Calendar.App = (function(window) {
{type: 'Templates', name: 'Week'}, {type: 'Templates', name: 'Week'},
{type: 'Utils', name: 'OrderedMap'}, {type: 'Utils', name: 'OrderedMap'},
{type: 'Views', name: 'DayBased'} {type: 'Views', name: 'DayBased'}
] ],
Errors: []
} }
}, },


Expand All @@ -95,11 +181,44 @@ Calendar.App = (function(window) {
this._providers = Object.create(null); this._providers = Object.create(null);
this._views = Object.create(null); this._views = Object.create(null);
this._routeViewFn = Object.create(null); this._routeViewFn = Object.create(null);
this._pendingManger = new PendingManager();

var self = this;
this._pendingManger.oncomplete = function onpending() {
document.body.classList.remove(self.pendingClass);
};

this._pendingManger.onpending = function oncomplete() {
document.body.classList.add(self.pendingClass);
};


this.timeController = new Calendar.Controllers.Time(this); this.timeController = new Calendar.Controllers.Time(this);
this.syncController = new Calendar.Controllers.Sync(this); this.syncController = new Calendar.Controllers.Sync(this);
this.serviceController = new Calendar.Controllers.Service(this); this.serviceController = new Calendar.Controllers.Service(this);
this.alarmController = new Calendar.Controllers.Alarm(this); this.alarmController = new Calendar.Controllers.Alarm(this);

// observe sync events
this.observePendingObject(this.syncController);
},

/**
* Adds observers to objects capable of being pending.
*
* Object must emit some kind of start/complete events
* and have the following properties:
*
* - startEvent (used to register an observer)
* - endEvent ( ditto )
* - pending
*
* @param {Object} object to observe.
*/
observePendingObject: function(object) {
this._pendingManger.register(object);
},

isPending: function() {
return this._pendingManger.isPending();
}, },


/** /**
Expand Down Expand Up @@ -195,6 +314,18 @@ Calendar.App = (function(window) {


this.timeController.move(new Date()); this.timeController.move(new Date());


// lazy load recurring event expander so as not to impact initial load.
this.loadResource('Controllers', 'RecurringEvents', function() {
self.recurringEventsController =
new Calendar.Controllers.RecurringEvents(self);

self.observePendingObject(
self.recurringEventsController
);

self.recurringEventsController.observe();
});

this.view('TimeHeader', function(header) { this.view('TimeHeader', function(header) {
header.render(); header.render();
}); });
Expand All @@ -203,6 +334,8 @@ Calendar.App = (function(window) {
colors.render(); colors.render();
}); });


this.view('Errors');

document.body.classList.remove('loading'); document.body.classList.remove('loading');
this._routes(); this._routes();
}, },
Expand Down Expand Up @@ -366,10 +499,12 @@ Calendar.App = (function(window) {
this._views[name] = new Calendar.Views[name]({ this._views[name] = new Calendar.Views[name]({
app: this app: this
}); });
cb.call(this, this._views[name]); if (cb) {
cb.call(this, this._views[name]);
}
}.bind(this)); }.bind(this));


} else { } else if (cb) {
cb.call(this, this._views[name]); cb.call(this, this._views[name]);
} }
}, },
Expand All @@ -384,6 +519,13 @@ Calendar.App = (function(window) {
*/ */
store: function(name) { store: function(name) {
return this.db.getStore(name); return this.db.getStore(name);
},

/**
* Returns the offline status.
*/
offline: function() {
return (navigator && 'onLine' in navigator) ? !navigator.onLine : true;
} }
}; };


Expand Down
26 changes: 25 additions & 1 deletion apps/calendar/js/calendar.js
@@ -1,9 +1,21 @@
(function(window) { (function(window) {


const NEXT_TICK = 'calendar-next-tick';
var nextTickStack = [];

window.Calendar = { window.Calendar = {


DEBUG: false, DEBUG: false,


/**
* Very similar to node's nextTick.
* Much faster then setTimeout.
*/
nextTick: function(callback) {
nextTickStack.push(callback);
window.postMessage(NEXT_TICK, '*');
},

/** /**
* Creates a calendar namespace. * Creates a calendar namespace.
* *
Expand Down Expand Up @@ -115,8 +127,20 @@
return mid; return mid;
} }
} }

}; };


/**
* next tick inspired by http://dbaron.org/log/20100309-faster-timeouts.
*/
window.addEventListener('message', function handleNextTick(event) {
if (event.source === window && event.data == NEXT_TICK) {
event.stopPropagation();
if (nextTickStack.length) {
(nextTickStack.shift())();
}
}
});


}(this)); }(this));


18 changes: 12 additions & 6 deletions apps/calendar/js/controllers/alarm.js
Expand Up @@ -17,12 +17,14 @@ Calendar.ns('Controllers').Alarm = (function() {


this._wifiLock = null; this._wifiLock = null;
this.app.syncController.on('syncComplete', function() { this.app.syncController.on('syncComplete', function() {
if (self._wifiLock !== null) if (self._wifiLock !== null) {
self._wifiLock.unlock(); self._wifiLock.unlock();
self._wifiLock = null;
}
}); });


this._nextPeriodicSync = this.settings.syncAlarm; this._nextPeriodicSync = this.settings.syncAlarm;

if (this._nextPeriodicSync.alarmId === null) if (this._nextPeriodicSync.alarmId === null)
this._resetSyncAlarm(false); this._resetSyncAlarm(false);


Expand Down Expand Up @@ -172,21 +174,25 @@ Calendar.ns('Controllers').Alarm = (function() {
var start = new Date(); var start = new Date();
var end = new Date(start.getTime() + duration); var end = new Date(start.getTime() + duration);


// We're resetting the sync alarm after a settings change and times are still in range // We're resetting the sync alarm after a settings
// change and times are still in range
if (!triggered && if (!triggered &&
this._nextPeriodicSync.end > start && this._nextPeriodicSync.end > start &&
this._nextPeriodicSync.start.getTime() + duration > start) { this._nextPeriodicSync.start.getTime() + duration > start) {
start = this._nextPeriodicSync.start; start = this._nextPeriodicSync.start;
end = new Date(start.getTime() + duration); end = new Date(start.getTime() + duration);
} }


var request = navigator.mozAlarms.add(end, 'ignoreTimezone', {type: 'sync'}); var request = navigator.mozAlarms.add(
end, 'ignoreTimezone', {type: 'sync'}
);

var self = this; var self = this;
request.onsuccess = function(e) { request.onsuccess = function(e) {
self._nextPeriodicSync.alarmId = e.target.result; self._nextPeriodicSync.alarmId = e.target.result;
self._nextPeriodicSync.start = start; self._nextPeriodicSync.start = start;
self._nextPeriodicSync.end = end; self._nextPeriodicSync.end = end;
self.settings.set('syncAlarm', self._nextPeriodicSync) self.settings.set('syncAlarm', self._nextPeriodicSync);
}; };
request.onerror = function(e) { request.onerror = function(e) {
debug('Error setting alarm:', e.target.error.name); debug('Error setting alarm:', e.target.error.name);
Expand Down

0 comments on commit f8e15c1

Please sign in to comment.