-
Notifications
You must be signed in to change notification settings - Fork 27
/
app.js
63 lines (55 loc) · 1.79 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*!
* Copyright (c) 2011, Nick Rabinowitz / Google Ancient Places Project
* Licensed under the BSD License (see LICENSE.txt)
*/
// removed in production by uglify
if (typeof DEBUG === 'undefined') {
DEBUG = true;
// cache busting for development
require.config({
urlArgs: "bust=" + (new Date()).getTime()
});
}
require.config({
baseUrl: 'app'
});
require(['gv', 'config', 'models/Books', 'models/State', 'views/AppView', 'views/Layout', 'routers/Router'],
function(gv, config, Books) {
// change Backbone.sync to use JSON/JSONP
var defaultSync = Backbone.sync;
Backbone.sync = function(method, model, options) {
options = _.extend({
dataType: gv.settings.API_DATA_TYPE,
cache: true
}, options);
defaultSync(method, model, options);
};
// initialize empty book list
gv.books = new Books();
// add parameters for permalinks
gv.addParameter('bookid', { deserialize: parseInt });
gv.addParameter('pageid', { deserialize: String });
gv.addParameter('placeid', { deserialize: parseInt });
gv.addParameter('pageview');
gv.addParameter('barsort');
gv.addParameter('mapzoom', { deserialize: parseInt });
gv.addParameter('mapcenter', {
deserialize: function(s) {
var params = s.split(",");
return params.length < 2 ? null :
new mxn.LatLonPoint(
parseFloat(params[0]),
parseFloat(params[1])
);
},
serialize: function(value) {
return value.lat + "," + value.lng;
}
});
// kick things off
$(function() {
gv.configure(config)
.start();
if (DEBUG) console.log('Application initialized');
});
});