-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot-10-b.js
184 lines (160 loc) · 6.54 KB
/
boot-10-b.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/** @file
*
* General client-side application initialization.
*
* Requires:
* req.js
*/
/*jslint nomen:false,laxbreak:true,white:false,onevar:false */
/*global Backbone:false */
(function() {
// Define the application object
var app = this.app = (this.app || {config:{}, options:{},
Model:{}, View:{},
Controller:{}, Helper:{}});
app.config = {
mode: 'development',
docId: '0001c',
animSpeed: 200,
table: {
options: {name:'app.options', id:'mine'},
notes: {name:'app.notes.10'}
}
};
/** @brief Boot the application once all dependencies are loaded. */
function bootApp() {
var $ = jQuery.noConflict();
app.config.docId =
app.config.docId
.replace(/^\?(?:\/?samples\/)?(.*?)(\.(?:json|html))?$/, '$1$2');
if (! app.config.docId.match(/\.(json|html)$/)) {
app.config.docId += '.json';
}
$(document).ready(function() {
/* Startup the application (js/jquery.summary-10-b.js)
* attaching to the DOM element with id 'app-Summary'
*/
app.main = new $.Summary({
el: $('#app-Summary'),
doc: 'samples/'+ app.config.docId
});
});
}
/******************************************************************************
* Load dependencies and, once loading is complete, invoke bootApp().
*
*/
if (app.config.mode === 'development') {
// Development dependencies
Req.assets = {
'preloadImages':{ src: 'js/preloadImages.js' },
'urlParser': { src: 'js/urlParser.js' },
'underscore': {
src: 'js/underscore.js',
onload: function() {
// Set _.template to use mustache-like delimiters {{ }}, {{= }}
_.templateSettings = {
evaluate: /\{\{([\s\S]+?)\}\}/g,
interpolate: /\{\{=([\s\S]+?)\}\}/g,
escape: /\{\{-([\s\S]+?)\}\}/g
};
}
},
'jquery': {
src: 'js/jquery.js',
// script.onload handler that runs as soon as the script has loaded
onload: function () {
// be strict about jQuery usage.
//var $ = jQuery.noConflict();
// Setup an easy-to-use Req.js plugin for jQuery ($.Req)
$.fn.Req = function(){
var args = arguments, t = this;
if (t.length)
{
Req.apply(null, $.map(args, function(a) {
return $.isFunction(a)
? function(){a.call(t);}
: a;
}) );
}
return t;
};
}
},
'utils': { src: 'js/jquery.utils.js', req:['jquery']},
'hoverIntent': { src: 'js/jquery.hoverIntent.js',
req: ['jquery']},
// Rangy and plugins
'rangy': { src: 'js/rangy.js' },
// Backbone and storage
'backbone': { src: 'js/backbone.js',
req: ['underscore', 'jquery']},
'backbone.localStorage':
{ src: 'js/backbone.localStorage.js',
req: ['backbone']},
// Backbone models
'model.options':{ src: 'js/model/options.js',
req: ['backbone.localStorage']},
'model.user': { src: 'js/model/user.js', req:['backbone']},
'model.comment':{ src: 'js/model/comment.js', req:['backbone']},
'model.range': { src: 'js/model/range.js', req:['backbone']},
'model.note': { src: 'js/model/note.js',
req: [ 'model.comment', 'model.range' ]},
'model.sentence':
{ src: 'js/model/sentence.js',req:['backbone']},
'model.paragraph':
{ src: 'js/model/paragraph.js',
req:['model.sentence']},
'model.section':{ src: 'js/model/section.js', req:['model.paragraph']},
'model.doc': { src: 'js/model/doc.js', req:['model.section']},
// Backbone views
'view.sentence':{ src: 'js/view/sentence.js', req: ['model.sentence']},
'view.paragraph':
{ src: 'js/view/paragraph.js',
req: ['model.paragraph', 'view.sentence']},
'view.section': { src: 'js/view/section.js',
req: ['model.section', 'view.paragraph']},
'view.range': { src: 'js/view/range-10.js',
req: ['model.range', 'rangy']},
'view.selection':
{ src: 'js/view/selection-10.js',
req: ['view.range']},
'view.comment': { src: 'js/view/comment.js',
req: ['model.comment']},
'view.note': { src: 'js/view/note-10.js',
req: ['view.selection', 'view.comment',
'model.note']},
'view.doc': { src: 'js/view/doc-10-b.js',
req: ['model.doc',
'view.section', 'view.selection', 'view.note']},
// jQuery-ui and widgets
'jquery-ui': { src: 'js/jquery-ui.js', req: ['jquery'] },
'ui.checkbox': { src: 'js/ui.checkbox.js', req: ['jquery-ui'] },
// Final suummary app
'summary': { src: 'js/jquery.summary-10-b.js',
req: [ 'jquery', 'utils', 'hoverIntent',
'rangy',
'ui.checkbox',
'model.options', 'model.user',
'view.note', 'view.doc'
] }
};
} else {
// Non-Development/Production dependencies
Req.assets = {
'preloadImages':{ src: 'js/preloadImages.min.js' },
'urlParser': { src: 'js/urlParser.min.js' },
'summary': { src: 'js/summary-10-b-full.min.js' }
};
}
Req('preloadImages', function() {
// Preload global images/sprites
preloadImages('css/images/loading.gif', 'css/images/icons-16.png');
},
'urlParser', function() {
app.config.docId = getSearchVar('docId') || app.config.docId;
},
'summary',
bootApp
);
}).call(this);