Commit d8ce8c9ae4862804d35b54aee976d580545434b4
- .gitignore 35 -----------------------------------
- js/lib/backbone.js 1431 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- js/lib/bootstrap.js 2025 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- js/lib/jquery-1.8.0.min.js 2 ++
- js/lib/modernizr-2.6.1.min.js 4 ++++
- js/lib/underscore.js 1200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Diff rendering mode:
- inline
- side by side
.gitignore
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 | 1 | ||
37 | *.*~ | 2 | *.*~ |
js/lib/backbone.js
1 | // Backbone.js 0.9.2 | ||
---|---|---|---|
2 | |||
3 | // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. | ||
4 | // Backbone may be freely distributed under the MIT license. | ||
5 | // For all details and documentation: | ||
6 | // http://backbonejs.org | ||
7 | |||
8 | (function(){ | ||
9 | |||
10 | // Initial Setup | ||
11 | // ------------- | ||
12 | |||
13 | // Save a reference to the global object (`window` in the browser, `global` | ||
14 | // on the server). | ||
15 | var root = this; | ||
16 | |||
17 | // Save the previous value of the `Backbone` variable, so that it can be | ||
18 | // restored later on, if `noConflict` is used. | ||
19 | var previousBackbone = root.Backbone; | ||
20 | |||
21 | // Create a local reference to slice/splice. | ||
22 | var slice = Array.prototype.slice; | ||
23 | var splice = Array.prototype.splice; | ||
24 | |||
25 | // The top-level namespace. All public Backbone classes and modules will | ||
26 | // be attached to this. Exported for both CommonJS and the browser. | ||
27 | var Backbone; | ||
28 | if (typeof exports !== 'undefined') { | ||
29 | Backbone = exports; | ||
30 | } else { | ||
31 | Backbone = root.Backbone = {}; | ||
32 | } | ||
33 | |||
34 | // Current version of the library. Keep in sync with `package.json`. | ||
35 | Backbone.VERSION = '0.9.2'; | ||
36 | |||
37 | // Require Underscore, if we're on the server, and it's not already present. | ||
38 | var _ = root._; | ||
39 | if (!_ && (typeof require !== 'undefined')) _ = require('underscore'); | ||
40 | |||
41 | // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable. | ||
42 | var $ = root.jQuery || root.Zepto || root.ender; | ||
43 | |||
44 | // Set the JavaScript library that will be used for DOM manipulation and | ||
45 | // Ajax calls (a.k.a. the `$` variable). By default Backbone will use: jQuery, | ||
46 | // Zepto, or Ender; but the `setDomLibrary()` method lets you inject an | ||
47 | // alternate JavaScript library (or a mock library for testing your views | ||
48 | // outside of a browser). | ||
49 | Backbone.setDomLibrary = function(lib) { | ||
50 | $ = lib; | ||
51 | }; | ||
52 | |||
53 | // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable | ||
54 | // to its previous owner. Returns a reference to this Backbone object. | ||
55 | Backbone.noConflict = function() { | ||
56 | root.Backbone = previousBackbone; | ||
57 | return this; | ||
58 | }; | ||
59 | |||
60 | // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option | ||
61 | // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and | ||
62 | // set a `X-Http-Method-Override` header. | ||
63 | Backbone.emulateHTTP = false; | ||
64 | |||
65 | // Turn on `emulateJSON` to support legacy servers that can't deal with direct | ||
66 | // `application/json` requests ... will encode the body as | ||
67 | // `application/x-www-form-urlencoded` instead and will send the model in a | ||
68 | // form param named `model`. | ||
69 | Backbone.emulateJSON = false; | ||
70 | |||
71 | // Backbone.Events | ||
72 | // ----------------- | ||
73 | |||
74 | // Regular expression used to split event strings | ||
75 | var eventSplitter = /\s+/; | ||
76 | |||
77 | // A module that can be mixed in to *any object* in order to provide it with | ||
78 | // custom events. You may bind with `on` or remove with `off` callback functions | ||
79 | // to an event; trigger`-ing an event fires all callbacks in succession. | ||
80 | // | ||
81 | // var object = {}; | ||
82 | // _.extend(object, Backbone.Events); | ||
83 | // object.on('expand', function(){ alert('expanded'); }); | ||
84 | // object.trigger('expand'); | ||
85 | // | ||
86 | var Events = Backbone.Events = { | ||
87 | |||
88 | // Bind one or more space separated events, `events`, to a `callback` | ||
89 | // function. Passing `"all"` will bind the callback to all events fired. | ||
90 | on: function(events, callback, context) { | ||
91 | |||
92 | var calls, event, node, tail, list; | ||
93 | if (!callback) return this; | ||
94 | events = events.split(eventSplitter); | ||
95 | calls = this._callbacks || (this._callbacks = {}); | ||
96 | |||
97 | // Create an immutable callback list, allowing traversal during | ||
98 | // modification. The tail is an empty object that will always be used | ||
99 | // as the next node. | ||
100 | while (event = events.shift()) { | ||
101 | list = calls[event]; | ||
102 | node = list ? list.tail : {}; | ||
103 | node.next = tail = {}; | ||
104 | node.context = context; | ||
105 | node.callback = callback; | ||
106 | calls[event] = {tail: tail, next: list ? list.next : node}; | ||
107 | } | ||
108 | |||
109 | return this; | ||
110 | }, | ||
111 | |||
112 | // Remove one or many callbacks. If `context` is null, removes all callbacks | ||
113 | // with that function. If `callback` is null, removes all callbacks for the | ||
114 | // event. If `events` is null, removes all bound callbacks for all events. | ||
115 | off: function(events, callback, context) { | ||
116 | var event, calls, node, tail, cb, ctx; | ||
117 | |||
118 | // No events, or removing *all* events. | ||
119 | if (!(calls = this._callbacks)) return; | ||
120 | if (!(events || callback || context)) { | ||
121 | delete this._callbacks; | ||
122 | return this; | ||
123 | } | ||
124 | |||
125 | // Loop through the listed events and contexts, splicing them out of the | ||
126 | // linked list of callbacks if appropriate. | ||
127 | events = events ? events.split(eventSplitter) : _.keys(calls); | ||
128 | while (event = events.shift()) { | ||
129 | node = calls[event]; | ||
130 | delete calls[event]; | ||
131 | if (!node || !(callback || context)) continue; | ||
132 | // Create a new list, omitting the indicated callbacks. | ||
133 | tail = node.tail; | ||
134 | while ((node = node.next) !== tail) { | ||
135 | cb = node.callback; | ||
136 | ctx = node.context; | ||
137 | if ((callback && cb !== callback) || (context && ctx !== context)) { | ||
138 | this.on(event, cb, ctx); | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return this; | ||
144 | }, | ||
145 | |||
146 | // Trigger one or many events, firing all bound callbacks. Callbacks are | ||
147 | // passed the same arguments as `trigger` is, apart from the event name | ||
148 | // (unless you're listening on `"all"`, which will cause your callback to | ||
149 | // receive the true name of the event as the first argument). | ||
150 | trigger: function(events) { | ||
151 | var event, node, calls, tail, args, all, rest; | ||
152 | if (!(calls = this._callbacks)) return this; | ||
153 | all = calls.all; | ||
154 | events = events.split(eventSplitter); | ||
155 | rest = slice.call(arguments, 1); | ||
156 | |||
157 | // For each event, walk through the linked list of callbacks twice, | ||
158 | // first to trigger the event, then to trigger any `"all"` callbacks. | ||
159 | while (event = events.shift()) { | ||
160 | if (node = calls[event]) { | ||
161 | tail = node.tail; | ||
162 | while ((node = node.next) !== tail) { | ||
163 | node.callback.apply(node.context || this, rest); | ||
164 | } | ||
165 | } | ||
166 | if (node = all) { | ||
167 | tail = node.tail; | ||
168 | args = [event].concat(rest); | ||
169 | while ((node = node.next) !== tail) { | ||
170 | node.callback.apply(node.context || this, args); | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | |||
175 | return this; | ||
176 | } | ||
177 | |||
178 | }; | ||
179 | |||
180 | // Aliases for backwards compatibility. | ||
181 | Events.bind = Events.on; | ||
182 | Events.unbind = Events.off; | ||
183 | |||
184 | // Backbone.Model | ||
185 | // -------------- | ||
186 | |||
187 | // Create a new model, with defined attributes. A client id (`cid`) | ||
188 | // is automatically generated and assigned for you. | ||
189 | var Model = Backbone.Model = function(attributes, options) { | ||
190 | var defaults; | ||
191 | attributes || (attributes = {}); | ||
192 | if (options && options.parse) attributes = this.parse(attributes); | ||
193 | if (defaults = getValue(this, 'defaults')) { | ||
194 | attributes = _.extend({}, defaults, attributes); | ||
195 | } | ||
196 | if (options && options.collection) this.collection = options.collection; | ||
197 | this.attributes = {}; | ||
198 | this._escapedAttributes = {}; | ||
199 | this.cid = _.uniqueId('c'); | ||
200 | this.changed = {}; | ||
201 | this._silent = {}; | ||
202 | this._pending = {}; | ||
203 | this.set(attributes, {silent: true}); | ||
204 | // Reset change tracking. | ||
205 | this.changed = {}; | ||
206 | this._silent = {}; | ||
207 | this._pending = {}; | ||
208 | this._previousAttributes = _.clone(this.attributes); | ||
209 | this.initialize.apply(this, arguments); | ||
210 | }; | ||
211 | |||
212 | // Attach all inheritable methods to the Model prototype. | ||
213 | _.extend(Model.prototype, Events, { | ||
214 | |||
215 | // A hash of attributes whose current and previous value differ. | ||
216 | changed: null, | ||
217 | |||
218 | // A hash of attributes that have silently changed since the last time | ||
219 | // `change` was called. Will become pending attributes on the next call. | ||
220 | _silent: null, | ||
221 | |||
222 | // A hash of attributes that have changed since the last `'change'` event | ||
223 | // began. | ||
224 | _pending: null, | ||
225 | |||
226 | // The default name for the JSON `id` attribute is `"id"`. MongoDB and | ||
227 | // CouchDB users may want to set this to `"_id"`. | ||
228 | idAttribute: 'id', | ||
229 | |||
230 | // Initialize is an empty function by default. Override it with your own | ||
231 | // initialization logic. | ||
232 | initialize: function(){}, | ||
233 | |||
234 | // Return a copy of the model's `attributes` object. | ||
235 | toJSON: function(options) { | ||
236 | return _.clone(this.attributes); | ||
237 | }, | ||
238 | |||
239 | // Get the value of an attribute. | ||
240 | get: function(attr) { | ||
241 | return this.attributes[attr]; | ||
242 | }, | ||
243 | |||
244 | // Get the HTML-escaped value of an attribute. | ||
245 | escape: function(attr) { | ||
246 | var html; | ||
247 | if (html = this._escapedAttributes[attr]) return html; | ||
248 | var val = this.get(attr); | ||
249 | return this._escapedAttributes[attr] = _.escape(val == null ? '' : '' + val); | ||
250 | }, | ||
251 | |||
252 | // Returns `true` if the attribute contains a value that is not null | ||
253 | // or undefined. | ||
254 | has: function(attr) { | ||
255 | return this.get(attr) != null; | ||
256 | }, | ||
257 | |||
258 | // Set a hash of model attributes on the object, firing `"change"` unless | ||
259 | // you choose to silence it. | ||
260 | set: function(key, value, options) { | ||
261 | var attrs, attr, val; | ||
262 | |||
263 | // Handle both `"key", value` and `{key: value}` -style arguments. | ||
264 | if (_.isObject(key) || key == null) { | ||
265 | attrs = key; | ||
266 | options = value; | ||
267 | } else { | ||
268 | attrs = {}; | ||
269 | attrs[key] = value; | ||
270 | } | ||
271 | |||
272 | // Extract attributes and options. | ||
273 | options || (options = {}); | ||
274 | if (!attrs) return this; | ||
275 | if (attrs instanceof Model) attrs = attrs.attributes; | ||
276 | if (options.unset) for (attr in attrs) attrs[attr] = void 0; | ||
277 | |||
278 | // Run validation. | ||
279 | if (!this._validate(attrs, options)) return false; | ||
280 | |||
281 | // Check for changes of `id`. | ||
282 | if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; | ||
283 | |||
284 | var changes = options.changes = {}; | ||
285 | var now = this.attributes; | ||
286 | var escaped = this._escapedAttributes; | ||
287 | var prev = this._previousAttributes || {}; | ||
288 | |||
289 | // For each `set` attribute... | ||
290 | for (attr in attrs) { | ||
291 | val = attrs[attr]; | ||
292 | |||
293 | // If the new and current value differ, record the change. | ||
294 | if (!_.isEqual(now[attr], val) || (options.unset && _.has(now, attr))) { | ||
295 | delete escaped[attr]; | ||
296 | (options.silent ? this._silent : changes)[attr] = true; | ||
297 | } | ||
298 | |||
299 | // Update or delete the current value. | ||
300 | options.unset ? delete now[attr] : now[attr] = val; | ||
301 | |||
302 | // If the new and previous value differ, record the change. If not, | ||
303 | // then remove changes for this attribute. | ||
304 | if (!_.isEqual(prev[attr], val) || (_.has(now, attr) != _.has(prev, attr))) { | ||
305 | this.changed[attr] = val; | ||
306 | if (!options.silent) this._pending[attr] = true; | ||
307 | } else { | ||
308 | delete this.changed[attr]; | ||
309 | delete this._pending[attr]; | ||
310 | } | ||
311 | } | ||
312 | |||
313 | // Fire the `"change"` events. | ||
314 | if (!options.silent) this.change(options); | ||
315 | return this; | ||
316 | }, | ||
317 | |||
318 | // Remove an attribute from the model, firing `"change"` unless you choose | ||
319 | // to silence it. `unset` is a noop if the attribute doesn't exist. | ||
320 | unset: function(attr, options) { | ||
321 | (options || (options = {})).unset = true; | ||
322 | return this.set(attr, null, options); | ||
323 | }, | ||
324 | |||
325 | // Clear all attributes on the model, firing `"change"` unless you choose | ||
326 | // to silence it. | ||
327 | clear: function(options) { | ||
328 | (options || (options = {})).unset = true; | ||
329 | return this.set(_.clone(this.attributes), options); | ||
330 | }, | ||
331 | |||
332 | // Fetch the model from the server. If the server's representation of the | ||
333 | // model differs from its current attributes, they will be overriden, | ||
334 | // triggering a `"change"` event. | ||
335 | fetch: function(options) { | ||
336 | options = options ? _.clone(options) : {}; | ||
337 | var model = this; | ||
338 | var success = options.success; | ||
339 | options.success = function(resp, status, xhr) { | ||
340 | if (!model.set(model.parse(resp, xhr), options)) return false; | ||
341 | if (success) success(model, resp); | ||
342 | }; | ||
343 | options.error = Backbone.wrapError(options.error, model, options); | ||
344 | return (this.sync || Backbone.sync).call(this, 'read', this, options); | ||
345 | }, | ||
346 | |||
347 | // Set a hash of model attributes, and sync the model to the server. | ||
348 | // If the server returns an attributes hash that differs, the model's | ||
349 | // state will be `set` again. | ||
350 | save: function(key, value, options) { | ||
351 | var attrs, current; | ||
352 | |||
353 | // Handle both `("key", value)` and `({key: value})` -style calls. | ||
354 | if (_.isObject(key) || key == null) { | ||
355 | attrs = key; | ||
356 | options = value; | ||
357 | } else { | ||
358 | attrs = {}; | ||
359 | attrs[key] = value; | ||
360 | } | ||
361 | options = options ? _.clone(options) : {}; | ||
362 | |||
363 | // If we're "wait"-ing to set changed attributes, validate early. | ||
364 | if (options.wait) { | ||
365 | if (!this._validate(attrs, options)) return false; | ||
366 | current = _.clone(this.attributes); | ||
367 | } | ||
368 | |||
369 | // Regular saves `set` attributes before persisting to the server. | ||
370 | var silentOptions = _.extend({}, options, {silent: true}); | ||
371 | if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) { | ||
372 | return false; | ||
373 | } | ||
374 | |||
375 | // After a successful server-side save, the client is (optionally) | ||
376 | // updated with the server-side state. | ||
377 | var model = this; | ||
378 | var success = options.success; | ||
379 | options.success = function(resp, status, xhr) { | ||
380 | var serverAttrs = model.parse(resp, xhr); | ||
381 | if (options.wait) { | ||
382 | delete options.wait; | ||
383 | serverAttrs = _.extend(attrs || {}, serverAttrs); | ||
384 | } | ||
385 | if (!model.set(serverAttrs, options)) return false; | ||
386 | if (success) { | ||
387 | success(model, resp); | ||
388 | } else { | ||
389 | model.trigger('sync', model, resp, options); | ||
390 | } | ||
391 | }; | ||
392 | |||
393 | // Finish configuring and sending the Ajax request. | ||
394 | options.error = Backbone.wrapError(options.error, model, options); | ||
395 | var method = this.isNew() ? 'create' : 'update'; | ||
396 | var xhr = (this.sync || Backbone.sync).call(this, method, this, options); | ||
397 | if (options.wait) this.set(current, silentOptions); | ||
398 | return xhr; | ||
399 | }, | ||
400 | |||
401 | // Destroy this model on the server if it was already persisted. | ||
402 | // Optimistically removes the model from its collection, if it has one. | ||
403 | // If `wait: true` is passed, waits for the server to respond before removal. | ||
404 | destroy: function(options) { | ||
405 | options = options ? _.clone(options) : {}; | ||
406 | var model = this; | ||
407 | var success = options.success; | ||
408 | |||
409 | var triggerDestroy = function() { | ||
410 | model.trigger('destroy', model, model.collection, options); | ||
411 | }; | ||
412 | |||
413 | if (this.isNew()) { | ||
414 | triggerDestroy(); | ||
415 | return false; | ||
416 | } | ||
417 | |||
418 | options.success = function(resp) { | ||
419 | if (options.wait) triggerDestroy(); | ||
420 | if (success) { | ||
421 | success(model, resp); | ||
422 | } else { | ||
423 | model.trigger('sync', model, resp, options); | ||
424 | } | ||
425 | }; | ||
426 | |||
427 | options.error = Backbone.wrapError(options.error, model, options); | ||
428 | var xhr = (this.sync || Backbone.sync).call(this, 'delete', this, options); | ||
429 | if (!options.wait) triggerDestroy(); | ||
430 | return xhr; | ||
431 | }, | ||
432 | |||
433 | // Default URL for the model's representation on the server -- if you're | ||
434 | // using Backbone's restful methods, override this to change the endpoint | ||
435 | // that will be called. | ||
436 | url: function() { | ||
437 | var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError(); | ||
438 | if (this.isNew()) return base; | ||
439 | return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id); | ||
440 | }, | ||
441 | |||
442 | // **parse** converts a response into the hash of attributes to be `set` on | ||
443 | // the model. The default implementation is just to pass the response along. | ||
444 | parse: function(resp, xhr) { | ||
445 | return resp; | ||
446 | }, | ||
447 | |||
448 | // Create a new model with identical attributes to this one. | ||
449 | clone: function() { | ||
450 | return new this.constructor(this.attributes); | ||
451 | }, | ||
452 | |||
453 | // A model is new if it has never been saved to the server, and lacks an id. | ||
454 | isNew: function() { | ||
455 | return this.id == null; | ||
456 | }, | ||
457 | |||
458 | // Call this method to manually fire a `"change"` event for this model and | ||
459 | // a `"change:attribute"` event for each changed attribute. | ||
460 | // Calling this will cause all objects observing the model to update. | ||
461 | change: function(options) { | ||
462 | options || (options = {}); | ||
463 | var changing = this._changing; | ||
464 | this._changing = true; | ||
465 | |||
466 | // Silent changes become pending changes. | ||
467 | for (var attr in this._silent) this._pending[attr] = true; | ||
468 | |||
469 | // Silent changes are triggered. | ||
470 | var changes = _.extend({}, options.changes, this._silent); | ||
471 | this._silent = {}; | ||
472 | for (var attr in changes) { | ||
473 | this.trigger('change:' + attr, this, this.get(attr), options); | ||
474 | } | ||
475 | if (changing) return this; | ||
476 | |||
477 | // Continue firing `"change"` events while there are pending changes. | ||
478 | while (!_.isEmpty(this._pending)) { | ||
479 | this._pending = {}; | ||
480 | this.trigger('change', this, options); | ||
481 | // Pending and silent changes still remain. | ||
482 | for (var attr in this.changed) { | ||
483 | if (this._pending[attr] || this._silent[attr]) continue; | ||
484 | delete this.changed[attr]; | ||
485 | } | ||
486 | this._previousAttributes = _.clone(this.attributes); | ||
487 | } | ||
488 | |||
489 | this._changing = false; | ||
490 | return this; | ||
491 | }, | ||
492 | |||
493 | // Determine if the model has changed since the last `"change"` event. | ||
494 | // If you specify an attribute name, determine if that attribute has changed. | ||
495 | hasChanged: function(attr) { | ||
496 | if (!arguments.length) return !_.isEmpty(this.changed); | ||
497 | return _.has(this.changed, attr); | ||
498 | }, | ||
499 | |||
500 | // Return an object containing all the attributes that have changed, or | ||
501 | // false if there are no changed attributes. Useful for determining what | ||
502 | // parts of a view need to be updated and/or what attributes need to be | ||
503 | // persisted to the server. Unset attributes will be set to undefined. | ||
504 | // You can also pass an attributes object to diff against the model, | ||
505 | // determining if there *would be* a change. | ||
506 | changedAttributes: function(diff) { | ||
507 | if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; | ||
508 | var val, changed = false, old = this._previousAttributes; | ||
509 | for (var attr in diff) { | ||
510 | if (_.isEqual(old[attr], (val = diff[attr]))) continue; | ||
511 | (changed || (changed = {}))[attr] = val; | ||
512 | } | ||
513 | return changed; | ||
514 | }, | ||
515 | |||
516 | // Get the previous value of an attribute, recorded at the time the last | ||
517 | // `"change"` event was fired. | ||
518 | previous: function(attr) { | ||
519 | if (!arguments.length || !this._previousAttributes) return null; | ||
520 | return this._previousAttributes[attr]; | ||
521 | }, | ||
522 | |||
523 | // Get all of the attributes of the model at the time of the previous | ||
524 | // `"change"` event. | ||
525 | previousAttributes: function() { | ||
526 | return _.clone(this._previousAttributes); | ||
527 | }, | ||
528 | |||
529 | // Check if the model is currently in a valid state. It's only possible to | ||
530 | // get into an *invalid* state if you're using silent changes. | ||
531 | isValid: function() { | ||
532 | return !this.validate(this.attributes); | ||
533 | }, | ||
534 | |||
535 | // Run validation against the next complete set of model attributes, | ||
536 | // returning `true` if all is well. If a specific `error` callback has | ||
537 | // been passed, call that instead of firing the general `"error"` event. | ||
538 | _validate: function(attrs, options) { | ||
539 | if (options.silent || !this.validate) return true; | ||
540 | attrs = _.extend({}, this.attributes, attrs); | ||
541 | var error = this.validate(attrs, options); | ||
542 | if (!error) return true; | ||
543 | if (options && options.error) { | ||
544 | options.error(this, error, options); | ||
545 | } else { | ||
546 | this.trigger('error', this, error, options); | ||
547 | } | ||
548 | return false; | ||
549 | } | ||
550 | |||
551 | }); | ||
552 | |||
553 | // Backbone.Collection | ||
554 | // ------------------- | ||
555 | |||
556 | // Provides a standard collection class for our sets of models, ordered | ||
557 | // or unordered. If a `comparator` is specified, the Collection will maintain | ||
558 | // its models in sort order, as they're added and removed. | ||
559 | var Collection = Backbone.Collection = function(models, options) { | ||
560 | options || (options = {}); | ||
561 | if (options.model) this.model = options.model; | ||
562 | if (options.comparator) this.comparator = options.comparator; | ||
563 | this._reset(); | ||
564 | this.initialize.apply(this, arguments); | ||
565 | if (models) this.reset(models, {silent: true, parse: options.parse}); | ||
566 | }; | ||
567 | |||
568 | // Define the Collection's inheritable methods. | ||
569 | _.extend(Collection.prototype, Events, { | ||
570 | |||
571 | // The default model for a collection is just a **Backbone.Model**. | ||
572 | // This should be overridden in most cases. | ||
573 | model: Model, | ||
574 | |||
575 | // Initialize is an empty function by default. Override it with your own | ||
576 | // initialization logic. | ||
577 | initialize: function(){}, | ||
578 | |||
579 | // The JSON representation of a Collection is an array of the | ||
580 | // models' attributes. | ||
581 | toJSON: function(options) { | ||
582 | return this.map(function(model){ return model.toJSON(options); }); | ||
583 | }, | ||
584 | |||
585 | // Add a model, or list of models to the set. Pass **silent** to avoid | ||
586 | // firing the `add` event for every new model. | ||
587 | add: function(models, options) { | ||
588 | var i, index, length, model, cid, id, cids = {}, ids = {}, dups = []; | ||
589 | options || (options = {}); | ||
590 | models = _.isArray(models) ? models.slice() : [models]; | ||
591 | |||
592 | // Begin by turning bare objects into model references, and preventing | ||
593 | // invalid models or duplicate models from being added. | ||
594 | for (i = 0, length = models.length; i < length; i++) { | ||
595 | if (!(model = models[i] = this._prepareModel(models[i], options))) { | ||
596 | throw new Error("Can't add an invalid model to a collection"); | ||
597 | } | ||
598 | cid = model.cid; | ||
599 | id = model.id; | ||
600 | if (cids[cid] || this._byCid[cid] || ((id != null) && (ids[id] || this._byId[id]))) { | ||
601 | dups.push(i); | ||
602 | continue; | ||
603 | } | ||
604 | cids[cid] = ids[id] = model; | ||
605 | } | ||
606 | |||
607 | // Remove duplicates. | ||
608 | i = dups.length; | ||
609 | while (i--) { | ||
610 | models.splice(dups[i], 1); | ||
611 | } | ||
612 | |||
613 | // Listen to added models' events, and index models for lookup by | ||
614 | // `id` and by `cid`. | ||
615 | for (i = 0, length = models.length; i < length; i++) { | ||
616 | (model = models[i]).on('all', this._onModelEvent, this); | ||
617 | this._byCid[model.cid] = model; | ||
618 | if (model.id != null) this._byId[model.id] = model; | ||
619 | } | ||
620 | |||
621 | // Insert models into the collection, re-sorting if needed, and triggering | ||
622 | // `add` events unless silenced. | ||
623 | this.length += length; | ||
624 | index = options.at != null ? options.at : this.models.length; | ||
625 | splice.apply(this.models, [index, 0].concat(models)); | ||
626 | if (this.comparator) this.sort({silent: true}); | ||
627 | if (options.silent) return this; | ||
628 | for (i = 0, length = this.models.length; i < length; i++) { | ||
629 | if (!cids[(model = this.models[i]).cid]) continue; | ||
630 | options.index = i; | ||
631 | model.trigger('add', model, this, options); | ||
632 | } | ||
633 | return this; | ||
634 | }, | ||
635 | |||
636 | // Remove a model, or a list of models from the set. Pass silent to avoid | ||
637 | // firing the `remove` event for every model removed. | ||
638 | remove: function(models, options) { | ||
639 | var i, l, index, model; | ||
640 | options || (options = {}); | ||
641 | models = _.isArray(models) ? models.slice() : [models]; | ||
642 | for (i = 0, l = models.length; i < l; i++) { | ||
643 | model = this.getByCid(models[i]) || this.get(models[i]); | ||
644 | if (!model) continue; | ||
645 | delete this._byId[model.id]; | ||
646 | delete this._byCid[model.cid]; | ||
647 | index = this.indexOf(model); | ||
648 | this.models.splice(index, 1); | ||
649 | this.length--; | ||
650 | if (!options.silent) { | ||
651 | options.index = index; | ||
652 | model.trigger('remove', model, this, options); | ||
653 | } | ||
654 | this._removeReference(model); | ||
655 | } | ||
656 | return this; | ||
657 | }, | ||
658 | |||
659 | // Add a model to the end of the collection. | ||
660 | push: function(model, options) { | ||
661 | model = this._prepareModel(model, options); | ||
662 | this.add(model, options); | ||
663 | return model; | ||
664 | }, | ||
665 | |||
666 | // Remove a model from the end of the collection. | ||
667 | pop: function(options) { | ||
668 | var model = this.at(this.length - 1); | ||
669 | this.remove(model, options); | ||
670 | return model; | ||
671 | }, | ||
672 | |||
673 | // Add a model to the beginning of the collection. | ||
674 | unshift: function(model, options) { | ||
675 | model = this._prepareModel(model, options); | ||
676 | this.add(model, _.extend({at: 0}, options)); | ||
677 | return model; | ||
678 | }, | ||
679 | |||
680 | // Remove a model from the beginning of the collection. | ||
681 | shift: function(options) { | ||
682 | var model = this.at(0); | ||
683 | this.remove(model, options); | ||
684 | return model; | ||
685 | }, | ||
686 | |||
687 | // Get a model from the set by id. | ||
688 | get: function(id) { | ||
689 | if (id == null) return void 0; | ||
690 | return this._byId[id.id != null ? id.id : id]; | ||
691 | }, | ||
692 | |||
693 | // Get a model from the set by client id. | ||
694 | getByCid: function(cid) { | ||
695 | return cid && this._byCid[cid.cid || cid]; | ||
696 | }, | ||
697 | |||
698 | // Get the model at the given index. | ||
699 | at: function(index) { | ||
700 | return this.models[index]; | ||
701 | }, | ||
702 | |||
703 | // Return models with matching attributes. Useful for simple cases of `filter`. | ||
704 | where: function(attrs) { | ||
705 | if (_.isEmpty(attrs)) return []; | ||
706 | return this.filter(function(model) { | ||
707 | for (var key in attrs) { | ||
708 | if (attrs[key] !== model.get(key)) return false; | ||
709 | } | ||
710 | return true; | ||
711 | }); | ||
712 | }, | ||
713 | |||
714 | // Force the collection to re-sort itself. You don't need to call this under | ||
715 | // normal circumstances, as the set will maintain sort order as each item | ||
716 | // is added. | ||
717 | sort: function(options) { | ||
718 | options || (options = {}); | ||
719 | if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); | ||
720 | var boundComparator = _.bind(this.comparator, this); | ||
721 | if (this.comparator.length == 1) { | ||
722 | this.models = this.sortBy(boundComparator); | ||
723 | } else { | ||
724 | this.models.sort(boundComparator); | ||
725 | } | ||
726 | if (!options.silent) this.trigger('reset', this, options); | ||
727 | return this; | ||
728 | }, | ||
729 | |||
730 | // Pluck an attribute from each model in the collection. | ||
731 | pluck: function(attr) { | ||
732 | return _.map(this.models, function(model){ return model.get(attr); }); | ||
733 | }, | ||
734 | |||
735 | // When you have more items than you want to add or remove individually, | ||
736 | // you can reset the entire set with a new list of models, without firing | ||
737 | // any `add` or `remove` events. Fires `reset` when finished. | ||
738 | reset: function(models, options) { | ||
739 | models || (models = []); | ||
740 | options || (options = {}); | ||
741 | for (var i = 0, l = this.models.length; i < l; i++) { | ||
742 | this._removeReference(this.models[i]); | ||
743 | } | ||
744 | this._reset(); | ||
745 | this.add(models, _.extend({silent: true}, options)); | ||
746 | if (!options.silent) this.trigger('reset', this, options); | ||
747 | return this; | ||
748 | }, | ||
749 | |||
750 | // Fetch the default set of models for this collection, resetting the | ||
751 | // collection when they arrive. If `add: true` is passed, appends the | ||
752 | // models to the collection instead of resetting. | ||
753 | fetch: function(options) { | ||
754 | options = options ? _.clone(options) : {}; | ||
755 | if (options.parse === undefined) options.parse = true; | ||
756 | var collection = this; | ||
757 | var success = options.success; | ||
758 | options.success = function(resp, status, xhr) { | ||
759 | collection[options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options); | ||
760 | if (success) success(collection, resp); | ||
761 | }; | ||
762 | options.error = Backbone.wrapError(options.error, collection, options); | ||
763 | return (this.sync || Backbone.sync).call(this, 'read', this, options); | ||
764 | }, | ||
765 | |||
766 | // Create a new instance of a model in this collection. Add the model to the | ||
767 | // collection immediately, unless `wait: true` is passed, in which case we | ||
768 | // wait for the server to agree. | ||
769 | create: function(model, options) { | ||
770 | var coll = this; | ||
771 | options = options ? _.clone(options) : {}; | ||
772 | model = this._prepareModel(model, options); | ||
773 | if (!model) return false; | ||
774 | if (!options.wait) coll.add(model, options); | ||
775 | var success = options.success; | ||
776 | options.success = function(nextModel, resp, xhr) { | ||
777 | if (options.wait) coll.add(nextModel, options); | ||
778 | if (success) { | ||
779 | success(nextModel, resp); | ||
780 | } else { | ||
781 | nextModel.trigger('sync', model, resp, options); | ||
782 | } | ||
783 | }; | ||
784 | model.save(null, options); | ||
785 | return model; | ||
786 | }, | ||
787 | |||
788 | // **parse** converts a response into a list of models to be added to the | ||
789 | // collection. The default implementation is just to pass it through. | ||
790 | parse: function(resp, xhr) { | ||
791 | return resp; | ||
792 | }, | ||
793 | |||
794 | // Proxy to _'s chain. Can't be proxied the same way the rest of the | ||
795 | // underscore methods are proxied because it relies on the underscore | ||
796 | // constructor. | ||
797 | chain: function () { | ||
798 | return _(this.models).chain(); | ||
799 | }, | ||
800 | |||
801 | // Reset all internal state. Called when the collection is reset. | ||
802 | _reset: function(options) { | ||
803 | this.length = 0; | ||
804 | this.models = []; | ||
805 | this._byId = {}; | ||
806 | this._byCid = {}; | ||
807 | }, | ||
808 | |||
809 | // Prepare a model or hash of attributes to be added to this collection. | ||
810 | _prepareModel: function(model, options) { | ||
811 | options || (options = {}); | ||
812 | if (!(model instanceof Model)) { | ||
813 | var attrs = model; | ||
814 | options.collection = this; | ||
815 | model = new this.model(attrs, options); | ||
816 | if (!model._validate(model.attributes, options)) model = false; | ||
817 | } else if (!model.collection) { | ||
818 | model.collection = this; | ||
819 | } | ||
820 | return model; | ||
821 | }, | ||
822 | |||
823 | // Internal method to remove a model's ties to a collection. | ||
824 | _removeReference: function(model) { | ||
825 | if (this == model.collection) { | ||
826 | delete model.collection; | ||
827 | } | ||
828 | model.off('all', this._onModelEvent, this); | ||
829 | }, | ||
830 | |||
831 | // Internal method called every time a model in the set fires an event. | ||
832 | // Sets need to update their indexes when models change ids. All other | ||
833 | // events simply proxy through. "add" and "remove" events that originate | ||
834 | // in other collections are ignored. | ||
835 | _onModelEvent: function(event, model, collection, options) { | ||
836 | if ((event == 'add' || event == 'remove') && collection != this) return; | ||
837 | if (event == 'destroy') { | ||
838 | this.remove(model, options); | ||
839 | } | ||
840 | if (model && event === 'change:' + model.idAttribute) { | ||
841 | delete this._byId[model.previous(model.idAttribute)]; | ||
842 | this._byId[model.id] = model; | ||
843 | } | ||
844 | this.trigger.apply(this, arguments); | ||
845 | } | ||
846 | |||
847 | }); | ||
848 | |||
849 | // Underscore methods that we want to implement on the Collection. | ||
850 | var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find', | ||
851 | 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', | ||
852 | 'include', 'contains', 'invoke', 'max', 'min', 'sortBy', 'sortedIndex', | ||
853 | 'toArray', 'size', 'first', 'initial', 'rest', 'last', 'without', 'indexOf', | ||
854 | 'shuffle', 'lastIndexOf', 'isEmpty', 'groupBy']; | ||
855 | |||
856 | // Mix in each Underscore method as a proxy to `Collection#models`. | ||
857 | _.each(methods, function(method) { | ||
858 | Collection.prototype[method] = function() { | ||
859 | return _[method].apply(_, [this.models].concat(_.toArray(arguments))); | ||
860 | }; | ||
861 | }); | ||
862 | |||
863 | // Backbone.Router | ||
864 | // ------------------- | ||
865 | |||
866 | // Routers map faux-URLs to actions, and fire events when routes are | ||
867 | // matched. Creating a new one sets its `routes` hash, if not set statically. | ||
868 | var Router = Backbone.Router = function(options) { | ||
869 | options || (options = {}); | ||
870 | if (options.routes) this.routes = options.routes; | ||
871 | this._bindRoutes(); | ||
872 | this.initialize.apply(this, arguments); | ||
873 | }; | ||
874 | |||
875 | // Cached regular expressions for matching named param parts and splatted | ||
876 | // parts of route strings. | ||
877 | var namedParam = /:\w+/g; | ||
878 | var splatParam = /\*\w+/g; | ||
879 | var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g; | ||
880 | |||
881 | // Set up all inheritable **Backbone.Router** properties and methods. | ||
882 | _.extend(Router.prototype, Events, { | ||
883 | |||
884 | // Initialize is an empty function by default. Override it with your own | ||
885 | // initialization logic. | ||
886 | initialize: function(){}, | ||
887 | |||
888 | // Manually bind a single named route to a callback. For example: | ||
889 | // | ||
890 | // this.route('search/:query/p:num', 'search', function(query, num) { | ||
891 | // ... | ||
892 | // }); | ||
893 | // | ||
894 | route: function(route, name, callback) { | ||
895 | Backbone.history || (Backbone.history = new History); | ||
896 | if (!_.isRegExp(route)) route = this._routeToRegExp(route); | ||
897 | if (!callback) callback = this[name]; | ||
898 | Backbone.history.route(route, _.bind(function(fragment) { | ||
899 | var args = this._extractParameters(route, fragment); | ||
900 | callback && callback.apply(this, args); | ||
901 | this.trigger.apply(this, ['route:' + name].concat(args)); | ||
902 | Backbone.history.trigger('route', this, name, args); | ||
903 | }, this)); | ||
904 | return this; | ||
905 | }, | ||
906 | |||
907 | // Simple proxy to `Backbone.history` to save a fragment into the history. | ||
908 | navigate: function(fragment, options) { | ||
909 | Backbone.history.navigate(fragment, options); | ||
910 | }, | ||
911 | |||
912 | // Bind all defined routes to `Backbone.history`. We have to reverse the | ||
913 | // order of the routes here to support behavior where the most general | ||
914 | // routes can be defined at the bottom of the route map. | ||
915 | _bindRoutes: function() { | ||
916 | if (!this.routes) return; | ||
917 | var routes = []; | ||
918 | for (var route in this.routes) { | ||
919 | routes.unshift([route, this.routes[route]]); | ||
920 | } | ||
921 | for (var i = 0, l = routes.length; i < l; i++) { | ||
922 | this.route(routes[i][0], routes[i][1], this[routes[i][1]]); | ||
923 | } | ||
924 | }, | ||
925 | |||
926 | // Convert a route string into a regular expression, suitable for matching | ||
927 | // against the current location hash. | ||
928 | _routeToRegExp: function(route) { | ||
929 | route = route.replace(escapeRegExp, '\\$&') | ||
930 | .replace(namedParam, '([^\/]+)') | ||
931 | .replace(splatParam, '(.*?)'); | ||
932 | return new RegExp('^' + route + '$'); | ||
933 | }, | ||
934 | |||
935 | // Given a route, and a URL fragment that it matches, return the array of | ||
936 | // extracted parameters. | ||
937 | _extractParameters: function(route, fragment) { | ||
938 | return route.exec(fragment).slice(1); | ||
939 | } | ||
940 | |||
941 | }); | ||
942 | |||
943 | // Backbone.History | ||
944 | // ---------------- | ||
945 | |||
946 | // Handles cross-browser history management, based on URL fragments. If the | ||
947 | // browser does not support `onhashchange`, falls back to polling. | ||
948 | var History = Backbone.History = function() { | ||
949 | this.handlers = []; | ||
950 | _.bindAll(this, 'checkUrl'); | ||
951 | }; | ||
952 | |||
953 | // Cached regex for cleaning leading hashes and slashes . | ||
954 | var routeStripper = /^[#\/]/; | ||
955 | |||
956 | // Cached regex for detecting MSIE. | ||
957 | var isExplorer = /msie [\w.]+/; | ||
958 | |||
959 | // Has the history handling already been started? | ||
960 | History.started = false; | ||
961 | |||
962 | // Set up all inheritable **Backbone.History** properties and methods. | ||
963 | _.extend(History.prototype, Events, { | ||
964 | |||
965 | // The default interval to poll for hash changes, if necessary, is | ||
966 | // twenty times a second. | ||
967 | interval: 50, | ||
968 | |||
969 | // Gets the true hash value. Cannot use location.hash directly due to bug | ||
970 | // in Firefox where location.hash will always be decoded. | ||
971 | getHash: function(windowOverride) { | ||
972 | var loc = windowOverride ? windowOverride.location : window.location; | ||
973 | var match = loc.href.match(/#(.*)$/); | ||
974 | return match ? match[1] : ''; | ||
975 | }, | ||
976 | |||
977 | // Get the cross-browser normalized URL fragment, either from the URL, | ||
978 | // the hash, or the override. | ||
979 | getFragment: function(fragment, forcePushState) { | ||
980 | if (fragment == null) { | ||
981 | if (this._hasPushState || forcePushState) { | ||
982 | fragment = window.location.pathname; | ||
983 | var search = window.location.search; | ||
984 | if (search) fragment += search; | ||
985 | } else { | ||
986 | fragment = this.getHash(); | ||
987 | } | ||
988 | } | ||
989 | if (!fragment.indexOf(this.options.root)) fragment = fragment.substr(this.options.root.length); | ||
990 | return fragment.replace(routeStripper, ''); | ||
991 | }, | ||
992 | |||
993 | // Start the hash change handling, returning `true` if the current URL matches | ||
994 | // an existing route, and `false` otherwise. | ||
995 | start: function(options) { | ||
996 | if (History.started) throw new Error("Backbone.history has already been started"); | ||
997 | History.started = true; | ||
998 | |||
999 | // Figure out the initial configuration. Do we need an iframe? | ||
1000 | // Is pushState desired ... is it available? | ||
1001 | this.options = _.extend({}, {root: '/'}, this.options, options); | ||
1002 | this._wantsHashChange = this.options.hashChange !== false; | ||
1003 | this._wantsPushState = !!this.options.pushState; | ||
1004 | this._hasPushState = !!(this.options.pushState && window.history && window.history.pushState); | ||
1005 | var fragment = this.getFragment(); | ||
1006 | var docMode = document.documentMode; | ||
1007 | var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); | ||
1008 | |||
1009 | if (oldIE) { | ||
1010 | this.iframe = $('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow; | ||
1011 | this.navigate(fragment); | ||
1012 | } | ||
1013 | |||
1014 | // Depending on whether we're using pushState or hashes, and whether | ||
1015 | // 'onhashchange' is supported, determine how we check the URL state. | ||
1016 | if (this._hasPushState) { | ||
1017 | $(window).bind('popstate', this.checkUrl); | ||
1018 | } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { | ||
1019 | $(window).bind('hashchange', this.checkUrl); | ||
1020 | } else if (this._wantsHashChange) { | ||
1021 | this._checkUrlInterval = setInterval(this.checkUrl, this.interval); | ||
1022 | } | ||
1023 | |||
1024 | // Determine if we need to change the base url, for a pushState link | ||
1025 | // opened by a non-pushState browser. | ||
1026 | this.fragment = fragment; | ||
1027 | var loc = window.location; | ||
1028 | var atRoot = loc.pathname == this.options.root; | ||
1029 | |||
1030 | // If we've started off with a route from a `pushState`-enabled browser, | ||
1031 | // but we're currently in a browser that doesn't support it... | ||
1032 | if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) { | ||
1033 | this.fragment = this.getFragment(null, true); | ||
1034 | window.location.replace(this.options.root + '#' + this.fragment); | ||
1035 | // Return immediately as browser will do redirect to new url | ||
1036 | return true; | ||
1037 | |||
1038 | // Or if we've started out with a hash-based route, but we're currently | ||
1039 | // in a browser where it could be `pushState`-based instead... | ||
1040 | } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) { | ||
1041 | this.fragment = this.getHash().replace(routeStripper, ''); | ||
1042 | window.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment); | ||
1043 | } | ||
1044 | |||
1045 | if (!this.options.silent) { | ||
1046 | return this.loadUrl(); | ||
1047 | } | ||
1048 | }, | ||
1049 | |||
1050 | // Disable Backbone.history, perhaps temporarily. Not useful in a real app, | ||
1051 | // but possibly useful for unit testing Routers. | ||
1052 | stop: function() { | ||
1053 | $(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl); | ||
1054 | clearInterval(this._checkUrlInterval); | ||
1055 | History.started = false; | ||
1056 | }, | ||
1057 | |||
1058 | // Add a route to be tested when the fragment changes. Routes added later | ||
1059 | // may override previous routes. | ||
1060 | route: function(route, callback) { | ||
1061 | this.handlers.unshift({route: route, callback: callback}); | ||
1062 | }, | ||
1063 | |||
1064 | // Checks the current URL to see if it has changed, and if it has, | ||
1065 | // calls `loadUrl`, normalizing across the hidden iframe. | ||
1066 | checkUrl: function(e) { | ||
1067 | var current = this.getFragment(); | ||
1068 | if (current == this.fragment && this.iframe) current = this.getFragment(this.getHash(this.iframe)); | ||
1069 | if (current == this.fragment) return false; | ||
1070 | if (this.iframe) this.navigate(current); | ||
1071 | this.loadUrl() || this.loadUrl(this.getHash()); | ||
1072 | }, | ||
1073 | |||
1074 | // Attempt to load the current URL fragment. If a route succeeds with a | ||
1075 | // match, returns `true`. If no defined routes matches the fragment, | ||
1076 | // returns `false`. | ||
1077 | loadUrl: function(fragmentOverride) { | ||
1078 | var fragment = this.fragment = this.getFragment(fragmentOverride); | ||
1079 | var matched = _.any(this.handlers, function(handler) { | ||
1080 | if (handler.route.test(fragment)) { | ||
1081 | handler.callback(fragment); | ||
1082 | return true; | ||
1083 | } | ||
1084 | }); | ||
1085 | return matched; | ||
1086 | }, | ||
1087 | |||
1088 | // Save a fragment into the hash history, or replace the URL state if the | ||
1089 | // 'replace' option is passed. You are responsible for properly URL-encoding | ||
1090 | // the fragment in advance. | ||
1091 | // | ||
1092 | // The options object can contain `trigger: true` if you wish to have the | ||
1093 | // route callback be fired (not usually desirable), or `replace: true`, if | ||
1094 | // you wish to modify the current URL without adding an entry to the history. | ||
1095 | navigate: function(fragment, options) { | ||
1096 | if (!History.started) return false; | ||
1097 | if (!options || options === true) options = {trigger: options}; | ||
1098 | var frag = (fragment || '').replace(routeStripper, ''); | ||
1099 | if (this.fragment == frag) return; | ||
1100 | |||
1101 | // If pushState is available, we use it to set the fragment as a real URL. | ||
1102 | if (this._hasPushState) { | ||
1103 | if (frag.indexOf(this.options.root) != 0) frag = this.options.root + frag; | ||
1104 | this.fragment = frag; | ||
1105 | window.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, frag); | ||
1106 | |||
1107 | // If hash changes haven't been explicitly disabled, update the hash | ||
1108 | // fragment to store history. | ||
1109 | } else if (this._wantsHashChange) { | ||
1110 | this.fragment = frag; | ||
1111 | this._updateHash(window.location, frag, options.replace); | ||
1112 | if (this.iframe && (frag != this.getFragment(this.getHash(this.iframe)))) { | ||
1113 | // Opening and closing the iframe tricks IE7 and earlier to push a history entry on hash-tag change. | ||
1114 | // When replace is true, we don't want this. | ||
1115 | if(!options.replace) this.iframe.document.open().close(); | ||
1116 | this._updateHash(this.iframe.location, frag, options.replace); | ||
1117 | } | ||
1118 | |||
1119 | // If you've told us that you explicitly don't want fallback hashchange- | ||
1120 | // based history, then `navigate` becomes a page refresh. | ||
1121 | } else { | ||
1122 | window.location.assign(this.options.root + fragment); | ||
1123 | } | ||
1124 | if (options.trigger) this.loadUrl(fragment); | ||
1125 | }, | ||
1126 | |||
1127 | // Update the hash location, either replacing the current entry, or adding | ||
1128 | // a new one to the browser history. | ||
1129 | _updateHash: function(location, fragment, replace) { | ||
1130 | if (replace) { | ||
1131 | location.replace(location.toString().replace(/(javascript:|#).*$/, '') + '#' + fragment); | ||
1132 | } else { | ||
1133 | location.hash = fragment; | ||
1134 | } | ||
1135 | } | ||
1136 | }); | ||
1137 | |||
1138 | // Backbone.View | ||
1139 | // ------------- | ||
1140 | |||
1141 | // Creating a Backbone.View creates its initial element outside of the DOM, | ||
1142 | // if an existing element is not provided... | ||
1143 | var View = Backbone.View = function(options) { | ||
1144 | this.cid = _.uniqueId('view'); | ||
1145 | this._configure(options || {}); | ||
1146 | this._ensureElement(); | ||
1147 | this.initialize.apply(this, arguments); | ||
1148 | this.delegateEvents(); | ||
1149 | }; | ||
1150 | |||
1151 | // Cached regex to split keys for `delegate`. | ||
1152 | var delegateEventSplitter = /^(\S+)\s*(.*)$/; | ||
1153 | |||
1154 | // List of view options to be merged as properties. | ||
1155 | var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName']; | ||
1156 | |||
1157 | // Set up all inheritable **Backbone.View** properties and methods. | ||
1158 | _.extend(View.prototype, Events, { | ||
1159 | |||
1160 | // The default `tagName` of a View's element is `"div"`. | ||
1161 | tagName: 'div', | ||
1162 | |||
1163 | // jQuery delegate for element lookup, scoped to DOM elements within the | ||
1164 | // current view. This should be prefered to global lookups where possible. | ||
1165 | $: function(selector) { | ||
1166 | return this.$el.find(selector); | ||
1167 | }, | ||
1168 | |||
1169 | // Initialize is an empty function by default. Override it with your own | ||
1170 | // initialization logic. | ||
1171 | initialize: function(){}, | ||
1172 | |||
1173 | // **render** is the core function that your view should override, in order | ||
1174 | // to populate its element (`this.el`), with the appropriate HTML. The | ||
1175 | // convention is for **render** to always return `this`. | ||
1176 | render: function() { | ||
1177 | return this; | ||
1178 | }, | ||
1179 | |||
1180 | // Remove this view from the DOM. Note that the view isn't present in the | ||
1181 | // DOM by default, so calling this method may be a no-op. | ||
1182 | remove: function() { | ||
1183 | this.$el.remove(); | ||
1184 | return this; | ||
1185 | }, | ||
1186 | |||
1187 | // For small amounts of DOM Elements, where a full-blown template isn't | ||
1188 | // needed, use **make** to manufacture elements, one at a time. | ||
1189 | // | ||
1190 | // var el = this.make('li', {'class': 'row'}, this.model.escape('title')); | ||
1191 | // | ||
1192 | make: function(tagName, attributes, content) { | ||
1193 | var el = document.createElement(tagName); | ||
1194 | if (attributes) $(el).attr(attributes); | ||
1195 | if (content) $(el).html(content); | ||
1196 | return el; | ||
1197 | }, | ||
1198 | |||
1199 | // Change the view's element (`this.el` property), including event | ||
1200 | // re-delegation. | ||
1201 | setElement: function(element, delegate) { | ||
1202 | if (this.$el) this.undelegateEvents(); | ||
1203 | this.$el = (element instanceof $) ? element : $(element); | ||
1204 | this.el = this.$el[0]; | ||
1205 | if (delegate !== false) this.delegateEvents(); | ||
1206 | return this; | ||
1207 | }, | ||
1208 | |||
1209 | // Set callbacks, where `this.events` is a hash of | ||
1210 | // | ||
1211 | // *{"event selector": "callback"}* | ||
1212 | // | ||
1213 | // { | ||
1214 | // 'mousedown .title': 'edit', | ||
1215 | // 'click .button': 'save' | ||
1216 | // 'click .open': function(e) { ... } | ||
1217 | // } | ||
1218 | // | ||
1219 | // pairs. Callbacks will be bound to the view, with `this` set properly. | ||
1220 | // Uses event delegation for efficiency. | ||
1221 | // Omitting the selector binds the event to `this.el`. | ||
1222 | // This only works for delegate-able events: not `focus`, `blur`, and | ||
1223 | // not `change`, `submit`, and `reset` in Internet Explorer. | ||
1224 | delegateEvents: function(events) { | ||
1225 | if (!(events || (events = getValue(this, 'events')))) return; | ||
1226 | this.undelegateEvents(); | ||
1227 | for (var key in events) { | ||
1228 | var method = events[key]; | ||
1229 | if (!_.isFunction(method)) method = this[events[key]]; | ||
1230 | if (!method) throw new Error('Method "' + events[key] + '" does not exist'); | ||
1231 | var match = key.match(delegateEventSplitter); | ||
1232 | var eventName = match[1], selector = match[2]; | ||
1233 | method = _.bind(method, this); | ||
1234 | eventName += '.delegateEvents' + this.cid; | ||
1235 | if (selector === '') { | ||
1236 | this.$el.bind(eventName, method); | ||
1237 | } else { | ||
1238 | this.$el.delegate(selector, eventName, method); | ||
1239 | } | ||
1240 | } | ||
1241 | }, | ||
1242 | |||
1243 | // Clears all callbacks previously bound to the view with `delegateEvents`. | ||
1244 | // You usually don't need to use this, but may wish to if you have multiple | ||
1245 | // Backbone views attached to the same DOM element. | ||
1246 | undelegateEvents: function() { | ||
1247 | this.$el.unbind('.delegateEvents' + this.cid); | ||
1248 | }, | ||
1249 | |||
1250 | // Performs the initial configuration of a View with a set of options. | ||
1251 | // Keys with special meaning *(model, collection, id, className)*, are | ||
1252 | // attached directly to the view. | ||
1253 | _configure: function(options) { | ||
1254 | if (this.options) options = _.extend({}, this.options, options); | ||
1255 | for (var i = 0, l = viewOptions.length; i < l; i++) { | ||
1256 | var attr = viewOptions[i]; | ||
1257 | if (options[attr]) this[attr] = options[attr]; | ||
1258 | } | ||
1259 | this.options = options; | ||
1260 | }, | ||
1261 | |||
1262 | // Ensure that the View has a DOM element to render into. | ||
1263 | // If `this.el` is a string, pass it through `$()`, take the first | ||
1264 | // matching element, and re-assign it to `el`. Otherwise, create | ||
1265 | // an element from the `id`, `className` and `tagName` properties. | ||
1266 | _ensureElement: function() { | ||
1267 | if (!this.el) { | ||
1268 | var attrs = getValue(this, 'attributes') || {}; | ||
1269 | if (this.id) attrs.id = this.id; | ||
1270 | if (this.className) attrs['class'] = this.className; | ||
1271 | this.setElement(this.make(this.tagName, attrs), false); | ||
1272 | } else { | ||
1273 | this.setElement(this.el, false); | ||
1274 | } | ||
1275 | } | ||
1276 | |||
1277 | }); | ||
1278 | |||
1279 | // The self-propagating extend function that Backbone classes use. | ||
1280 | var extend = function (protoProps, classProps) { | ||
1281 | var child = inherits(this, protoProps, classProps); | ||
1282 | child.extend = this.extend; | ||
1283 | return child; | ||
1284 | }; | ||
1285 | |||
1286 | // Set up inheritance for the model, collection, and view. | ||
1287 | Model.extend = Collection.extend = Router.extend = View.extend = extend; | ||
1288 | |||
1289 | // Backbone.sync | ||
1290 | // ------------- | ||
1291 | |||
1292 | // Map from CRUD to HTTP for our default `Backbone.sync` implementation. | ||
1293 | var methodMap = { | ||
1294 | 'create': 'POST', | ||
1295 | 'update': 'PUT', | ||
1296 | 'delete': 'DELETE', | ||
1297 | 'read': 'GET' | ||
1298 | }; | ||
1299 | |||
1300 | // Override this function to change the manner in which Backbone persists | ||
1301 | // models to the server. You will be passed the type of request, and the | ||
1302 | // model in question. By default, makes a RESTful Ajax request | ||
1303 | // to the model's `url()`. Some possible customizations could be: | ||
1304 | // | ||
1305 | // * Use `setTimeout` to batch rapid-fire updates into a single request. | ||
1306 | // * Send up the models as XML instead of JSON. | ||
1307 | // * Persist models via WebSockets instead of Ajax. | ||
1308 | // | ||
1309 | // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests | ||
1310 | // as `POST`, with a `_method` parameter containing the true HTTP method, | ||
1311 | // as well as all requests with the body as `application/x-www-form-urlencoded` | ||
1312 | // instead of `application/json` with the model in a param named `model`. | ||
1313 | // Useful when interfacing with server-side languages like **PHP** that make | ||
1314 | // it difficult to read the body of `PUT` requests. | ||
1315 | Backbone.sync = function(method, model, options) { | ||
1316 | var type = methodMap[method]; | ||
1317 | |||
1318 | // Default options, unless specified. | ||
1319 | options || (options = {}); | ||
1320 | |||
1321 | // Default JSON-request options. | ||
1322 | var params = {type: type, dataType: 'json'}; | ||
1323 | |||
1324 | // Ensure that we have a URL. | ||
1325 | if (!options.url) { | ||
1326 | params.url = getValue(model, 'url') || urlError(); | ||
1327 | } | ||
1328 | |||
1329 | // Ensure that we have the appropriate request data. | ||
1330 | if (!options.data && model && (method == 'create' || method == 'update')) { | ||
1331 | params.contentType = 'application/json'; | ||
1332 | params.data = JSON.stringify(model.toJSON()); | ||
1333 | } | ||
1334 | |||
1335 | // For older servers, emulate JSON by encoding the request into an HTML-form. | ||
1336 | if (Backbone.emulateJSON) { | ||
1337 | params.contentType = 'application/x-www-form-urlencoded'; | ||
1338 | params.data = params.data ? {model: params.data} : {}; | ||
1339 | } | ||
1340 | |||
1341 | // For older servers, emulate HTTP by mimicking the HTTP method with `_method` | ||
1342 | // And an `X-HTTP-Method-Override` header. | ||
1343 | if (Backbone.emulateHTTP) { | ||
1344 | if (type === 'PUT' || type === 'DELETE') { | ||
1345 | if (Backbone.emulateJSON) params.data._method = type; | ||
1346 | params.type = 'POST'; | ||
1347 | params.beforeSend = function(xhr) { | ||
1348 | xhr.setRequestHeader('X-HTTP-Method-Override', type); | ||
1349 | }; | ||
1350 | } | ||
1351 | } | ||
1352 | |||
1353 | // Don't process data on a non-GET request. | ||
1354 | if (params.type !== 'GET' && !Backbone.emulateJSON) { | ||
1355 | params.processData = false; | ||
1356 | } | ||
1357 | |||
1358 | // Make the request, allowing the user to override any Ajax options. | ||
1359 | return $.ajax(_.extend(params, options)); | ||
1360 | }; | ||
1361 | |||
1362 | // Wrap an optional error callback with a fallback error event. | ||
1363 | Backbone.wrapError = function(onError, originalModel, options) { | ||
1364 | return function(model, resp) { | ||
1365 | resp = model === originalModel ? resp : model; | ||
1366 | if (onError) { | ||
1367 | onError(originalModel, resp, options); | ||
1368 | } else { | ||
1369 | originalModel.trigger('error', originalModel, resp, options); | ||
1370 | } | ||
1371 | }; | ||
1372 | }; | ||
1373 | |||
1374 | // Helpers | ||
1375 | // ------- | ||
1376 | |||
1377 | // Shared empty constructor function to aid in prototype-chain creation. | ||
1378 | var ctor = function(){}; | ||
1379 | |||
1380 | // Helper function to correctly set up the prototype chain, for subclasses. | ||
1381 | // Similar to `goog.inherits`, but uses a hash of prototype properties and | ||
1382 | // class properties to be extended. | ||
1383 | var inherits = function(parent, protoProps, staticProps) { | ||
1384 | var child; | ||
1385 | |||
1386 | // The constructor function for the new subclass is either defined by you | ||
1387 | // (the "constructor" property in your `extend` definition), or defaulted | ||
1388 | // by us to simply call the parent's constructor. | ||
1389 | if (protoProps && protoProps.hasOwnProperty('constructor')) { | ||
1390 | child = protoProps.constructor; | ||
1391 | } else { | ||
1392 | child = function(){ parent.apply(this, arguments); }; | ||
1393 | } | ||
1394 | |||
1395 | // Inherit class (static) properties from parent. | ||
1396 | _.extend(child, parent); | ||
1397 | |||
1398 | // Set the prototype chain to inherit from `parent`, without calling | ||
1399 | // `parent`'s constructor function. | ||
1400 | ctor.prototype = parent.prototype; | ||
1401 | child.prototype = new ctor(); | ||
1402 | |||
1403 | // Add prototype properties (instance properties) to the subclass, | ||
1404 | // if supplied. | ||
1405 | if (protoProps) _.extend(child.prototype, protoProps); | ||
1406 | |||
1407 | // Add static properties to the constructor function, if supplied. | ||
1408 | if (staticProps) _.extend(child, staticProps); | ||
1409 | |||
1410 | // Correctly set child's `prototype.constructor`. | ||
1411 | child.prototype.constructor = child; | ||
1412 | |||
1413 | // Set a convenience property in case the parent's prototype is needed later. | ||
1414 | child.__super__ = parent.prototype; | ||
1415 | |||
1416 | return child; | ||
1417 | }; | ||
1418 | |||
1419 | // Helper function to get a value from a Backbone object as a property | ||
1420 | // or as a function. | ||
1421 | var getValue = function(object, prop) { | ||
1422 | if (!(object && object[prop])) return null; | ||
1423 | return _.isFunction(object[prop]) ? object[prop]() : object[prop]; | ||
1424 | }; | ||
1425 | |||
1426 | // Throw an error when a URL is needed, and none is supplied. | ||
1427 | var urlError = function() { | ||
1428 | throw new Error('A "url" property or function must be specified'); | ||
1429 | }; | ||
1430 | |||
1431 | }).call(this); |
js/lib/bootstrap.js
1 | /* =================================================== | ||
---|---|---|---|
2 | * bootstrap-transition.js v2.2.1 | ||
3 | * http://twitter.github.com/bootstrap/javascript.html#transitions | ||
4 | * =================================================== | ||
5 | * Copyright 2012 Twitter, Inc. | ||
6 | * | ||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
8 | * you may not use this file except in compliance with the License. | ||
9 | * You may obtain a copy of the License at | ||
10 | * | ||
11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | * | ||
13 | * Unless required by applicable law or agreed to in writing, software | ||
14 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
16 | * See the License for the specific language governing permissions and | ||
17 | * limitations under the License. | ||
18 | * ========================================================== */ | ||
19 | |||
20 | |||
21 | !function ($) { | ||
22 | |||
23 | "use strict"; // jshint ;_; | ||
24 | |||
25 | |||
26 | /* CSS TRANSITION SUPPORT (http://www.modernizr.com/) | ||
27 | * ======================================================= */ | ||
28 | |||
29 | $(function () { | ||
30 | |||
31 | $.support.transition = (function () { | ||
32 | |||
33 | var transitionEnd = (function () { | ||
34 | |||
35 | var el = document.createElement('bootstrap') | ||
36 | , transEndEventNames = { | ||
37 | 'WebkitTransition' : 'webkitTransitionEnd' | ||
38 | , 'MozTransition' : 'transitionend' | ||
39 | , 'OTransition' : 'oTransitionEnd otransitionend' | ||
40 | , 'transition' : 'transitionend' | ||
41 | } | ||
42 | , name | ||
43 | |||
44 | for (name in transEndEventNames){ | ||
45 | if (el.style[name] !== undefined) { | ||
46 | return transEndEventNames[name] | ||
47 | } | ||
48 | } | ||
49 | |||
50 | }()) | ||
51 | |||
52 | return transitionEnd && { | ||
53 | end: transitionEnd | ||
54 | } | ||
55 | |||
56 | })() | ||
57 | |||
58 | }) | ||
59 | |||
60 | }(window.jQuery);/* ========================================================== | ||
61 | * bootstrap-alert.js v2.2.1 | ||
62 | * http://twitter.github.com/bootstrap/javascript.html#alerts | ||
63 | * ========================================================== | ||
64 | * Copyright 2012 Twitter, Inc. | ||
65 | * | ||
66 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
67 | * you may not use this file except in compliance with the License. | ||
68 | * You may obtain a copy of the License at | ||
69 | * | ||
70 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
71 | * | ||
72 | * Unless required by applicable law or agreed to in writing, software | ||
73 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
74 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
75 | * See the License for the specific language governing permissions and | ||
76 | * limitations under the License. | ||
77 | * ========================================================== */ | ||
78 | |||
79 | |||
80 | !function ($) { | ||
81 | |||
82 | "use strict"; // jshint ;_; | ||
83 | |||
84 | |||
85 | /* ALERT CLASS DEFINITION | ||
86 | * ====================== */ | ||
87 | |||
88 | var dismiss = '[data-dismiss="alert"]' | ||
89 | , Alert = function (el) { | ||
90 | $(el).on('click', dismiss, this.close) | ||
91 | } | ||
92 | |||
93 | Alert.prototype.close = function (e) { | ||
94 | var $this = $(this) | ||
95 | , selector = $this.attr('data-target') | ||
96 | , $parent | ||
97 | |||
98 | if (!selector) { | ||
99 | selector = $this.attr('href') | ||
100 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 | ||
101 | } | ||
102 | |||
103 | $parent = $(selector) | ||
104 | |||
105 | e && e.preventDefault() | ||
106 | |||
107 | $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) | ||
108 | |||
109 | $parent.trigger(e = $.Event('close')) | ||
110 | |||
111 | if (e.isDefaultPrevented()) return | ||
112 | |||
113 | $parent.removeClass('in') | ||
114 | |||
115 | function removeElement() { | ||
116 | $parent | ||
117 | .trigger('closed') | ||
118 | .remove() | ||
119 | } | ||
120 | |||
121 | $.support.transition && $parent.hasClass('fade') ? | ||
122 | $parent.on($.support.transition.end, removeElement) : | ||
123 | removeElement() | ||
124 | } | ||
125 | |||
126 | |||
127 | /* ALERT PLUGIN DEFINITION | ||
128 | * ======================= */ | ||
129 | |||
130 | $.fn.alert = function (option) { | ||
131 | return this.each(function () { | ||
132 | var $this = $(this) | ||
133 | , data = $this.data('alert') | ||
134 | if (!data) $this.data('alert', (data = new Alert(this))) | ||
135 | if (typeof option == 'string') data[option].call($this) | ||
136 | }) | ||
137 | } | ||
138 | |||
139 | $.fn.alert.Constructor = Alert | ||
140 | |||
141 | |||
142 | /* ALERT DATA-API | ||
143 | * ============== */ | ||
144 | |||
145 | $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) | ||
146 | |||
147 | }(window.jQuery);/* ============================================================ | ||
148 | * bootstrap-button.js v2.2.1 | ||
149 | * http://twitter.github.com/bootstrap/javascript.html#buttons | ||
150 | * ============================================================ | ||
151 | * Copyright 2012 Twitter, Inc. | ||
152 | * | ||
153 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
154 | * you may not use this file except in compliance with the License. | ||
155 | * You may obtain a copy of the License at | ||
156 | * | ||
157 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
158 | * | ||
159 | * Unless required by applicable law or agreed to in writing, software | ||
160 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
161 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
162 | * See the License for the specific language governing permissions and | ||
163 | * limitations under the License. | ||
164 | * ============================================================ */ | ||
165 | |||
166 | |||
167 | !function ($) { | ||
168 | |||
169 | "use strict"; // jshint ;_; | ||
170 | |||
171 | |||
172 | /* BUTTON PUBLIC CLASS DEFINITION | ||
173 | * ============================== */ | ||
174 | |||
175 | var Button = function (element, options) { | ||
176 | this.$element = $(element) | ||
177 | this.options = $.extend({}, $.fn.button.defaults, options) | ||
178 | } | ||
179 | |||
180 | Button.prototype.setState = function (state) { | ||
181 | var d = 'disabled' | ||
182 | , $el = this.$element | ||
183 | , data = $el.data() | ||
184 | , val = $el.is('input') ? 'val' : 'html' | ||
185 | |||
186 | state = state + 'Text' | ||
187 | data.resetText || $el.data('resetText', $el[val]()) | ||
188 | |||
189 | $el[val](data[state] || this.options[state]) | ||
190 | |||
191 | // push to event loop to allow forms to submit | ||
192 | setTimeout(function () { | ||
193 | state == 'loadingText' ? | ||
194 | $el.addClass(d).attr(d, d) : | ||
195 | $el.removeClass(d).removeAttr(d) | ||
196 | }, 0) | ||
197 | } | ||
198 | |||
199 | Button.prototype.toggle = function () { | ||
200 | var $parent = this.$element.closest('[data-toggle="buttons-radio"]') | ||
201 | |||
202 | $parent && $parent | ||
203 | .find('.active') | ||
204 | .removeClass('active') | ||
205 | |||
206 | this.$element.toggleClass('active') | ||
207 | } | ||
208 | |||
209 | |||
210 | /* BUTTON PLUGIN DEFINITION | ||
211 | * ======================== */ | ||
212 | |||
213 | $.fn.button = function (option) { | ||
214 | return this.each(function () { | ||
215 | var $this = $(this) | ||
216 | , data = $this.data('button') | ||
217 | , options = typeof option == 'object' && option | ||
218 | if (!data) $this.data('button', (data = new Button(this, options))) | ||
219 | if (option == 'toggle') data.toggle() | ||
220 | else if (option) data.setState(option) | ||
221 | }) | ||
222 | } | ||
223 | |||
224 | $.fn.button.defaults = { | ||
225 | loadingText: 'loading...' | ||
226 | } | ||
227 | |||
228 | $.fn.button.Constructor = Button | ||
229 | |||
230 | |||
231 | /* BUTTON DATA-API | ||
232 | * =============== */ | ||
233 | |||
234 | $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { | ||
235 | var $btn = $(e.target) | ||
236 | if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') | ||
237 | $btn.button('toggle') | ||
238 | }) | ||
239 | |||
240 | }(window.jQuery);/* ========================================================== | ||
241 | * bootstrap-carousel.js v2.2.1 | ||
242 | * http://twitter.github.com/bootstrap/javascript.html#carousel | ||
243 | * ========================================================== | ||
244 | * Copyright 2012 Twitter, Inc. | ||
245 | * | ||
246 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
247 | * you may not use this file except in compliance with the License. | ||
248 | * You may obtain a copy of the License at | ||
249 | * | ||
250 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
251 | * | ||
252 | * Unless required by applicable law or agreed to in writing, software | ||
253 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
254 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
255 | * See the License for the specific language governing permissions and | ||
256 | * limitations under the License. | ||
257 | * ========================================================== */ | ||
258 | |||
259 | |||
260 | !function ($) { | ||
261 | |||
262 | "use strict"; // jshint ;_; | ||
263 | |||
264 | |||
265 | /* CAROUSEL CLASS DEFINITION | ||
266 | * ========================= */ | ||
267 | |||
268 | var Carousel = function (element, options) { | ||
269 | this.$element = $(element) | ||
270 | this.options = options | ||
271 | this.options.slide && this.slide(this.options.slide) | ||
272 | this.options.pause == 'hover' && this.$element | ||
273 | .on('mouseenter', $.proxy(this.pause, this)) | ||
274 | .on('mouseleave', $.proxy(this.cycle, this)) | ||
275 | } | ||
276 | |||
277 | Carousel.prototype = { | ||
278 | |||
279 | cycle: function (e) { | ||
280 | if (!e) this.paused = false | ||
281 | this.options.interval | ||
282 | && !this.paused | ||
283 | && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) | ||
284 | return this | ||
285 | } | ||
286 | |||
287 | , to: function (pos) { | ||
288 | var $active = this.$element.find('.item.active') | ||
289 | , children = $active.parent().children() | ||
290 | , activePos = children.index($active) | ||
291 | , that = this | ||
292 | |||
293 | if (pos > (children.length - 1) || pos < 0) return | ||
294 | |||
295 | if (this.sliding) { | ||
296 | return this.$element.one('slid', function () { | ||
297 | that.to(pos) | ||
298 | }) | ||
299 | } | ||
300 | |||
301 | if (activePos == pos) { | ||
302 | return this.pause().cycle() | ||
303 | } | ||
304 | |||
305 | return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos])) | ||
306 | } | ||
307 | |||
308 | , pause: function (e) { | ||
309 | if (!e) this.paused = true | ||
310 | if (this.$element.find('.next, .prev').length && $.support.transition.end) { | ||
311 | this.$element.trigger($.support.transition.end) | ||
312 | this.cycle() | ||
313 | } | ||
314 | clearInterval(this.interval) | ||
315 | this.interval = null | ||
316 | return this | ||
317 | } | ||
318 | |||
319 | , next: function () { | ||
320 | if (this.sliding) return | ||
321 | return this.slide('next') | ||
322 | } | ||
323 | |||
324 | , prev: function () { | ||
325 | if (this.sliding) return | ||
326 | return this.slide('prev') | ||
327 | } | ||
328 | |||
329 | , slide: function (type, next) { | ||
330 | var $active = this.$element.find('.item.active') | ||
331 | , $next = next || $active[type]() | ||
332 | , isCycling = this.interval | ||
333 | , direction = type == 'next' ? 'left' : 'right' | ||
334 | , fallback = type == 'next' ? 'first' : 'last' | ||
335 | , that = this | ||
336 | , e | ||
337 | |||
338 | this.sliding = true | ||
339 | |||
340 | isCycling && this.pause() | ||
341 | |||
342 | $next = $next.length ? $next : this.$element.find('.item')[fallback]() | ||
343 | |||
344 | e = $.Event('slide', { | ||
345 | relatedTarget: $next[0] | ||
346 | }) | ||
347 | |||
348 | if ($next.hasClass('active')) return | ||
349 | |||
350 | if ($.support.transition && this.$element.hasClass('slide')) { | ||
351 | this.$element.trigger(e) | ||
352 | if (e.isDefaultPrevented()) return | ||
353 | $next.addClass(type) | ||
354 | $next[0].offsetWidth // force reflow | ||
355 | $active.addClass(direction) | ||
356 | $next.addClass(direction) | ||
357 | this.$element.one($.support.transition.end, function () { | ||
358 | $next.removeClass([type, direction].join(' ')).addClass('active') | ||
359 | $active.removeClass(['active', direction].join(' ')) | ||
360 | that.sliding = false | ||
361 | setTimeout(function () { that.$element.trigger('slid') }, 0) | ||
362 | }) | ||
363 | } else { | ||
364 | this.$element.trigger(e) | ||
365 | if (e.isDefaultPrevented()) return | ||
366 | $active.removeClass('active') | ||
367 | $next.addClass('active') | ||
368 | this.sliding = false | ||
369 | this.$element.trigger('slid') | ||
370 | } | ||
371 | |||
372 | isCycling && this.cycle() | ||
373 | |||
374 | return this | ||
375 | } | ||
376 | |||
377 | } | ||
378 | |||
379 | |||
380 | /* CAROUSEL PLUGIN DEFINITION | ||
381 | * ========================== */ | ||
382 | |||
383 | $.fn.carousel = function (option) { | ||
384 | return this.each(function () { | ||
385 | var $this = $(this) | ||
386 | , data = $this.data('carousel') | ||
387 | , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) | ||
388 | , action = typeof option == 'string' ? option : options.slide | ||
389 | if (!data) $this.data('carousel', (data = new Carousel(this, options))) | ||
390 | if (typeof option == 'number') data.to(option) | ||
391 | else if (action) data[action]() | ||
392 | else if (options.interval) data.cycle() | ||
393 | }) | ||
394 | } | ||
395 | |||
396 | $.fn.carousel.defaults = { | ||
397 | interval: 5000 | ||
398 | , pause: 'hover' | ||
399 | } | ||
400 | |||
401 | $.fn.carousel.Constructor = Carousel | ||
402 | |||
403 | |||
404 | /* CAROUSEL DATA-API | ||
405 | * ================= */ | ||
406 | |||
407 | $(document).on('click.carousel.data-api', '[data-slide]', function (e) { | ||
408 | var $this = $(this), href | ||
409 | , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 | ||
410 | , options = $.extend({}, $target.data(), $this.data()) | ||
411 | $target.carousel(options) | ||
412 | e.preventDefault() | ||
413 | }) | ||
414 | |||
415 | }(window.jQuery);/* ============================================================= | ||
416 | * bootstrap-collapse.js v2.2.1 | ||
417 | * http://twitter.github.com/bootstrap/javascript.html#collapse | ||
418 | * ============================================================= | ||
419 | * Copyright 2012 Twitter, Inc. | ||
420 | * | ||
421 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
422 | * you may not use this file except in compliance with the License. | ||
423 | * You may obtain a copy of the License at | ||
424 | * | ||
425 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
426 | * | ||
427 | * Unless required by applicable law or agreed to in writing, software | ||
428 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
429 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
430 | * See the License for the specific language governing permissions and | ||
431 | * limitations under the License. | ||
432 | * ============================================================ */ | ||
433 | |||
434 | |||
435 | !function ($) { | ||
436 | |||
437 | "use strict"; // jshint ;_; | ||
438 | |||
439 | |||
440 | /* COLLAPSE PUBLIC CLASS DEFINITION | ||
441 | * ================================ */ | ||
442 | |||
443 | var Collapse = function (element, options) { | ||
444 | this.$element = $(element) | ||
445 | this.options = $.extend({}, $.fn.collapse.defaults, options) | ||
446 | |||
447 | if (this.options.parent) { | ||
448 | this.$parent = $(this.options.parent) | ||
449 | } | ||
450 | |||
451 | this.options.toggle && this.toggle() | ||
452 | } | ||
453 | |||
454 | Collapse.prototype = { | ||
455 | |||
456 | constructor: Collapse | ||
457 | |||
458 | , dimension: function () { | ||
459 | var hasWidth = this.$element.hasClass('width') | ||
460 | return hasWidth ? 'width' : 'height' | ||
461 | } | ||
462 | |||
463 | , show: function () { | ||
464 | var dimension | ||
465 | , scroll | ||
466 | , actives | ||
467 | , hasData | ||
468 | |||
469 | if (this.transitioning) return | ||
470 | |||
471 | dimension = this.dimension() | ||
472 | scroll = $.camelCase(['scroll', dimension].join('-')) | ||
473 | actives = this.$parent && this.$parent.find('> .accordion-group > .in') | ||
474 | |||
475 | if (actives && actives.length) { | ||
476 | hasData = actives.data('collapse') | ||
477 | if (hasData && hasData.transitioning) return | ||
478 | actives.collapse('hide') | ||
479 | hasData || actives.data('collapse', null) | ||
480 | } | ||
481 | |||
482 | this.$element[dimension](0) | ||
483 | this.transition('addClass', $.Event('show'), 'shown') | ||
484 | $.support.transition && this.$element[dimension](this.$element[0][scroll]) | ||
485 | } | ||
486 | |||
487 | , hide: function () { | ||
488 | var dimension | ||
489 | if (this.transitioning) return | ||
490 | dimension = this.dimension() | ||
491 | this.reset(this.$element[dimension]()) | ||
492 | this.transition('removeClass', $.Event('hide'), 'hidden') | ||
493 | this.$element[dimension](0) | ||
494 | } | ||
495 | |||
496 | , reset: function (size) { | ||
497 | var dimension = this.dimension() | ||
498 | |||
499 | this.$element | ||
500 | .removeClass('collapse') | ||
501 | [dimension](size || 'auto') | ||
502 | [0].offsetWidth | ||
503 | |||
504 | this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') | ||
505 | |||
506 | return this | ||
507 | } | ||
508 | |||
509 | , transition: function (method, startEvent, completeEvent) { | ||
510 | var that = this | ||
511 | , complete = function () { | ||
512 | if (startEvent.type == 'show') that.reset() | ||
513 | that.transitioning = 0 | ||
514 | that.$element.trigger(completeEvent) | ||
515 | } | ||
516 | |||
517 | this.$element.trigger(startEvent) | ||
518 | |||
519 | if (startEvent.isDefaultPrevented()) return | ||
520 | |||
521 | this.transitioning = 1 | ||
522 | |||
523 | this.$element[method]('in') | ||
524 | |||
525 | $.support.transition && this.$element.hasClass('collapse') ? | ||
526 | this.$element.one($.support.transition.end, complete) : | ||
527 | complete() | ||
528 | } | ||
529 | |||
530 | , toggle: function () { | ||
531 | this[this.$element.hasClass('in') ? 'hide' : 'show']() | ||
532 | } | ||
533 | |||
534 | } | ||
535 | |||
536 | |||
537 | /* COLLAPSIBLE PLUGIN DEFINITION | ||
538 | * ============================== */ | ||
539 | |||
540 | $.fn.collapse = function (option) { | ||
541 | return this.each(function () { | ||
542 | var $this = $(this) | ||
543 | , data = $this.data('collapse') | ||
544 | , options = typeof option == 'object' && option | ||
545 | if (!data) $this.data('collapse', (data = new Collapse(this, options))) | ||
546 | if (typeof option == 'string') data[option]() | ||
547 | }) | ||
548 | } | ||
549 | |||
550 | $.fn.collapse.defaults = { | ||
551 | toggle: true | ||
552 | } | ||
553 | |||
554 | $.fn.collapse.Constructor = Collapse | ||
555 | |||
556 | |||
557 | /* COLLAPSIBLE DATA-API | ||
558 | * ==================== */ | ||
559 | |||
560 | $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { | ||
561 | var $this = $(this), href | ||
562 | , target = $this.attr('data-target') | ||
563 | || e.preventDefault() | ||
564 | || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 | ||
565 | , option = $(target).data('collapse') ? 'toggle' : $this.data() | ||
566 | $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') | ||
567 | $(target).collapse(option) | ||
568 | }) | ||
569 | |||
570 | }(window.jQuery);/* ============================================================ | ||
571 | * bootstrap-dropdown.js v2.2.1 | ||
572 | * http://twitter.github.com/bootstrap/javascript.html#dropdowns | ||
573 | * ============================================================ | ||
574 | * Copyright 2012 Twitter, Inc. | ||
575 | * | ||
576 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
577 | * you may not use this file except in compliance with the License. | ||
578 | * You may obtain a copy of the License at | ||
579 | * | ||
580 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
581 | * | ||
582 | * Unless required by applicable law or agreed to in writing, software | ||
583 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
584 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
585 | * See the License for the specific language governing permissions and | ||
586 | * limitations under the License. | ||
587 | * ============================================================ */ | ||
588 | |||
589 | |||
590 | !function ($) { | ||
591 | |||
592 | "use strict"; // jshint ;_; | ||
593 | |||
594 | |||
595 | /* DROPDOWN CLASS DEFINITION | ||
596 | * ========================= */ | ||
597 | |||
598 | var toggle = '[data-toggle=dropdown]' | ||
599 | , Dropdown = function (element) { | ||
600 | var $el = $(element).on('click.dropdown.data-api', this.toggle) | ||
601 | $('html').on('click.dropdown.data-api', function () { | ||
602 | $el.parent().removeClass('open') | ||
603 | }) | ||
604 | } | ||
605 | |||
606 | Dropdown.prototype = { | ||
607 | |||
608 | constructor: Dropdown | ||
609 | |||
610 | , toggle: function (e) { | ||
611 | var $this = $(this) | ||
612 | , $parent | ||
613 | , isActive | ||
614 | |||
615 | if ($this.is('.disabled, :disabled')) return | ||
616 | |||
617 | $parent = getParent($this) | ||
618 | |||
619 | isActive = $parent.hasClass('open') | ||
620 | |||
621 | clearMenus() | ||
622 | |||
623 | if (!isActive) { | ||
624 | $parent.toggleClass('open') | ||
625 | $this.focus() | ||
626 | } | ||
627 | |||
628 | return false | ||
629 | } | ||
630 | |||
631 | , keydown: function (e) { | ||
632 | var $this | ||
633 | , $items | ||
634 | , $active | ||
635 | , $parent | ||
636 | , isActive | ||
637 | , index | ||
638 | |||
639 | if (!/(38|40|27)/.test(e.keyCode)) return | ||
640 | |||
641 | $this = $(this) | ||
642 | |||
643 | e.preventDefault() | ||
644 | e.stopPropagation() | ||
645 | |||
646 | if ($this.is('.disabled, :disabled')) return | ||
647 | |||
648 | $parent = getParent($this) | ||
649 | |||
650 | isActive = $parent.hasClass('open') | ||
651 | |||
652 | if (!isActive || (isActive && e.keyCode == 27)) return $this.click() | ||
653 | |||
654 | $items = $('[role=menu] li:not(.divider) a', $parent) | ||
655 | |||
656 | if (!$items.length) return | ||
657 | |||
658 | index = $items.index($items.filter(':focus')) | ||
659 | |||
660 | if (e.keyCode == 38 && index > 0) index-- // up | ||
661 | if (e.keyCode == 40 && index < $items.length - 1) index++ // down | ||
662 | if (!~index) index = 0 | ||
663 | |||
664 | $items | ||
665 | .eq(index) | ||
666 | .focus() | ||
667 | } | ||
668 | |||
669 | } | ||
670 | |||
671 | function clearMenus() { | ||
672 | $(toggle).each(function () { | ||
673 | getParent($(this)).removeClass('open') | ||
674 | }) | ||
675 | } | ||
676 | |||
677 | function getParent($this) { | ||
678 | var selector = $this.attr('data-target') | ||
679 | , $parent | ||
680 | |||
681 | if (!selector) { | ||
682 | selector = $this.attr('href') | ||
683 | selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 | ||
684 | } | ||
685 | |||
686 | $parent = $(selector) | ||
687 | $parent.length || ($parent = $this.parent()) | ||
688 | |||
689 | return $parent | ||
690 | } | ||
691 | |||
692 | |||
693 | /* DROPDOWN PLUGIN DEFINITION | ||
694 | * ========================== */ | ||
695 | |||
696 | $.fn.dropdown = function (option) { | ||
697 | return this.each(function () { | ||
698 | var $this = $(this) | ||
699 | , data = $this.data('dropdown') | ||
700 | if (!data) $this.data('dropdown', (data = new Dropdown(this))) | ||
701 | if (typeof option == 'string') data[option].call($this) | ||
702 | }) | ||
703 | } | ||
704 | |||
705 | $.fn.dropdown.Constructor = Dropdown | ||
706 | |||
707 | |||
708 | /* APPLY TO STANDARD DROPDOWN ELEMENTS | ||
709 | * =================================== */ | ||
710 | |||
711 | $(document) | ||
712 | .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) | ||
713 | .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) | ||
714 | .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) | ||
715 | .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) | ||
716 | |||
717 | }(window.jQuery);/* ========================================================= | ||
718 | * bootstrap-modal.js v2.2.1 | ||
719 | * http://twitter.github.com/bootstrap/javascript.html#modals | ||
720 | * ========================================================= | ||
721 | * Copyright 2012 Twitter, Inc. | ||
722 | * | ||
723 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
724 | * you may not use this file except in compliance with the License. | ||
725 | * You may obtain a copy of the License at | ||
726 | * | ||
727 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
728 | * | ||
729 | * Unless required by applicable law or agreed to in writing, software | ||
730 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
731 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
732 | * See the License for the specific language governing permissions and | ||
733 | * limitations under the License. | ||
734 | * ========================================================= */ | ||
735 | |||
736 | |||
737 | !function ($) { | ||
738 | |||
739 | "use strict"; // jshint ;_; | ||
740 | |||
741 | |||
742 | /* MODAL CLASS DEFINITION | ||
743 | * ====================== */ | ||
744 | |||
745 | var Modal = function (element, options) { | ||
746 | this.options = options | ||
747 | this.$element = $(element) | ||
748 | .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) | ||
749 | this.options.remote && this.$element.find('.modal-body').load(this.options.remote) | ||
750 | } | ||
751 | |||
752 | Modal.prototype = { | ||
753 | |||
754 | constructor: Modal | ||
755 | |||
756 | , toggle: function () { | ||
757 | return this[!this.isShown ? 'show' : 'hide']() | ||
758 | } | ||
759 | |||
760 | , show: function () { | ||
761 | var that = this | ||
762 | , e = $.Event('show') | ||
763 | |||
764 | this.$element.trigger(e) | ||
765 | |||
766 | if (this.isShown || e.isDefaultPrevented()) return | ||
767 | |||
768 | this.isShown = true | ||
769 | |||
770 | this.escape() | ||
771 | |||
772 | this.backdrop(function () { | ||
773 | var transition = $.support.transition && that.$element.hasClass('fade') | ||
774 | |||
775 | if (!that.$element.parent().length) { | ||
776 | that.$element.appendTo(document.body) //don't move modals dom position | ||
777 | } | ||
778 | |||
779 | that.$element | ||
780 | .show() | ||
781 | |||
782 | if (transition) { | ||
783 | that.$element[0].offsetWidth // force reflow | ||
784 | } | ||
785 | |||
786 | that.$element | ||
787 | .addClass('in') | ||
788 | .attr('aria-hidden', false) | ||
789 | |||
790 | that.enforceFocus() | ||
791 | |||
792 | transition ? | ||
793 | that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : | ||
794 | that.$element.focus().trigger('shown') | ||
795 | |||
796 | }) | ||
797 | } | ||
798 | |||
799 | , hide: function (e) { | ||
800 | e && e.preventDefault() | ||
801 | |||
802 | var that = this | ||
803 | |||
804 | e = $.Event('hide') | ||
805 | |||
806 | this.$element.trigger(e) | ||
807 | |||
808 | if (!this.isShown || e.isDefaultPrevented()) return | ||
809 | |||
810 | this.isShown = false | ||
811 | |||
812 | this.escape() | ||
813 | |||
814 | $(document).off('focusin.modal') | ||
815 | |||
816 | this.$element | ||
817 | .removeClass('in') | ||
818 | .attr('aria-hidden', true) | ||
819 | |||
820 | $.support.transition && this.$element.hasClass('fade') ? | ||
821 | this.hideWithTransition() : | ||
822 | this.hideModal() | ||
823 | } | ||
824 | |||
825 | , enforceFocus: function () { | ||
826 | var that = this | ||
827 | $(document).on('focusin.modal', function (e) { | ||
828 | if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { | ||
829 | that.$element.focus() | ||
830 | } | ||
831 | }) | ||
832 | } | ||
833 | |||
834 | , escape: function () { | ||
835 | var that = this | ||
836 | if (this.isShown && this.options.keyboard) { | ||
837 | this.$element.on('keyup.dismiss.modal', function ( e ) { | ||
838 | e.which == 27 && that.hide() | ||
839 | }) | ||
840 | } else if (!this.isShown) { | ||
841 | this.$element.off('keyup.dismiss.modal') | ||
842 | } | ||
843 | } | ||
844 | |||
845 | , hideWithTransition: function () { | ||
846 | var that = this | ||
847 | , timeout = setTimeout(function () { | ||
848 | that.$element.off($.support.transition.end) | ||
849 | that.hideModal() | ||
850 | }, 500) | ||
851 | |||
852 | this.$element.one($.support.transition.end, function () { | ||
853 | clearTimeout(timeout) | ||
854 | that.hideModal() | ||
855 | }) | ||
856 | } | ||
857 | |||
858 | , hideModal: function (that) { | ||
859 | this.$element | ||
860 | .hide() | ||
861 | .trigger('hidden') | ||
862 | |||
863 | this.backdrop() | ||
864 | } | ||
865 | |||
866 | , removeBackdrop: function () { | ||
867 | this.$backdrop.remove() | ||
868 | this.$backdrop = null | ||
869 | } | ||
870 | |||
871 | , backdrop: function (callback) { | ||
872 | var that = this | ||
873 | , animate = this.$element.hasClass('fade') ? 'fade' : '' | ||
874 | |||
875 | if (this.isShown && this.options.backdrop) { | ||
876 | var doAnimate = $.support.transition && animate | ||
877 | |||
878 | this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') | ||
879 | .appendTo(document.body) | ||
880 | |||
881 | this.$backdrop.click( | ||
882 | this.options.backdrop == 'static' ? | ||
883 | $.proxy(this.$element[0].focus, this.$element[0]) | ||
884 | : $.proxy(this.hide, this) | ||
885 | ) | ||
886 | |||
887 | if (doAnimate) this.$backdrop[0].offsetWidth // force reflow | ||
888 | |||
889 | this.$backdrop.addClass('in') | ||
890 | |||
891 | doAnimate ? | ||
892 | this.$backdrop.one($.support.transition.end, callback) : | ||
893 | callback() | ||
894 | |||
895 | } else if (!this.isShown && this.$backdrop) { | ||
896 | this.$backdrop.removeClass('in') | ||
897 | |||
898 | $.support.transition && this.$element.hasClass('fade')? | ||
899 | this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) : | ||
900 | this.removeBackdrop() | ||
901 | |||
902 | } else if (callback) { | ||
903 | callback() | ||
904 | } | ||
905 | } | ||
906 | } | ||
907 | |||
908 | |||
909 | /* MODAL PLUGIN DEFINITION | ||
910 | * ======================= */ | ||
911 | |||
912 | $.fn.modal = function (option) { | ||
913 | return this.each(function () { | ||
914 | var $this = $(this) | ||
915 | , data = $this.data('modal') | ||
916 | , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) | ||
917 | if (!data) $this.data('modal', (data = new Modal(this, options))) | ||
918 | if (typeof option == 'string') data[option]() | ||
919 | else if (options.show) data.show() | ||
920 | }) | ||
921 | } | ||
922 | |||
923 | $.fn.modal.defaults = { | ||
924 | backdrop: true | ||
925 | , keyboard: true | ||
926 | , show: true | ||
927 | } | ||
928 | |||
929 | $.fn.modal.Constructor = Modal | ||
930 | |||
931 | |||
932 | /* MODAL DATA-API | ||
933 | * ============== */ | ||
934 | |||
935 | $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { | ||
936 | var $this = $(this) | ||
937 | , href = $this.attr('href') | ||
938 | , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 | ||
939 | , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) | ||
940 | |||
941 | e.preventDefault() | ||
942 | |||
943 | $target | ||
944 | .modal(option) | ||
945 | .one('hide', function () { | ||
946 | $this.focus() | ||
947 | }) | ||
948 | }) | ||
949 | |||
950 | }(window.jQuery); | ||
951 | /* =========================================================== | ||
952 | * bootstrap-tooltip.js v2.2.1 | ||
953 | * http://twitter.github.com/bootstrap/javascript.html#tooltips | ||
954 | * Inspired by the original jQuery.tipsy by Jason Frame | ||
955 | * =========================================================== | ||
956 | * Copyright 2012 Twitter, Inc. | ||
957 | * | ||
958 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
959 | * you may not use this file except in compliance with the License. | ||
960 | * You may obtain a copy of the License at | ||
961 | * | ||
962 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
963 | * | ||
964 | * Unless required by applicable law or agreed to in writing, software | ||
965 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
966 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
967 | * See the License for the specific language governing permissions and | ||
968 | * limitations under the License. | ||
969 | * ========================================================== */ | ||
970 | |||
971 | |||
972 | !function ($) { | ||
973 | |||
974 | "use strict"; // jshint ;_; | ||
975 | |||
976 | |||
977 | /* TOOLTIP PUBLIC CLASS DEFINITION | ||
978 | * =============================== */ | ||
979 | |||
980 | var Tooltip = function (element, options) { | ||
981 | this.init('tooltip', element, options) | ||
982 | } | ||
983 | |||
984 | Tooltip.prototype = { | ||
985 | |||
986 | constructor: Tooltip | ||
987 | |||
988 | , init: function (type, element, options) { | ||
989 | var eventIn | ||
990 | , eventOut | ||
991 | |||
992 | this.type = type | ||
993 | this.$element = $(element) | ||
994 | this.options = this.getOptions(options) | ||
995 | this.enabled = true | ||
996 | |||
997 | if (this.options.trigger == 'click') { | ||
998 | this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) | ||
999 | } else if (this.options.trigger != 'manual') { | ||
1000 | eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' | ||
1001 | eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' | ||
1002 | this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) | ||
1003 | this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) | ||
1004 | } | ||
1005 | |||
1006 | this.options.selector ? | ||
1007 | (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : | ||
1008 | this.fixTitle() | ||
1009 | } | ||
1010 | |||
1011 | , getOptions: function (options) { | ||
1012 | options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data()) | ||
1013 | |||
1014 | if (options.delay && typeof options.delay == 'number') { | ||
1015 | options.delay = { | ||
1016 | show: options.delay | ||
1017 | , hide: options.delay | ||
1018 | } | ||
1019 | } | ||
1020 | |||
1021 | return options | ||
1022 | } | ||
1023 | |||
1024 | , enter: function (e) { | ||
1025 | var self = $(e.currentTarget)[this.type](this._options).data(this.type) | ||
1026 | |||
1027 | if (!self.options.delay || !self.options.delay.show) return self.show() | ||
1028 | |||
1029 | clearTimeout(this.timeout) | ||
1030 | self.hoverState = 'in' | ||
1031 | this.timeout = setTimeout(function() { | ||
1032 | if (self.hoverState == 'in') self.show() | ||
1033 | }, self.options.delay.show) | ||
1034 | } | ||
1035 | |||
1036 | , leave: function (e) { | ||
1037 | var self = $(e.currentTarget)[this.type](this._options).data(this.type) | ||
1038 | |||
1039 | if (this.timeout) clearTimeout(this.timeout) | ||
1040 | if (!self.options.delay || !self.options.delay.hide) return self.hide() | ||
1041 | |||
1042 | self.hoverState = 'out' | ||
1043 | this.timeout = setTimeout(function() { | ||
1044 | if (self.hoverState == 'out') self.hide() | ||
1045 | }, self.options.delay.hide) | ||
1046 | } | ||
1047 | |||
1048 | , show: function () { | ||
1049 | var $tip | ||
1050 | , inside | ||
1051 | , pos | ||
1052 | , actualWidth | ||
1053 | , actualHeight | ||
1054 | , placement | ||
1055 | , tp | ||
1056 | |||
1057 | if (this.hasContent() && this.enabled) { | ||
1058 | $tip = this.tip() | ||
1059 | this.setContent() | ||
1060 | |||
1061 | if (this.options.animation) { | ||
1062 | $tip.addClass('fade') | ||
1063 | } | ||
1064 | |||
1065 | placement = typeof this.options.placement == 'function' ? | ||
1066 | this.options.placement.call(this, $tip[0], this.$element[0]) : | ||
1067 | this.options.placement | ||
1068 | |||
1069 | inside = /in/.test(placement) | ||
1070 | |||
1071 | $tip | ||
1072 | .detach() | ||
1073 | .css({ top: 0, left: 0, display: 'block' }) | ||
1074 | .insertAfter(this.$element) | ||
1075 | |||
1076 | pos = this.getPosition(inside) | ||
1077 | |||
1078 | actualWidth = $tip[0].offsetWidth | ||
1079 | actualHeight = $tip[0].offsetHeight | ||
1080 | |||
1081 | switch (inside ? placement.split(' ')[1] : placement) { | ||
1082 | case 'bottom': | ||
1083 | tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} | ||
1084 | break | ||
1085 | case 'top': | ||
1086 | tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2} | ||
1087 | break | ||
1088 | case 'left': | ||
1089 | tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth} | ||
1090 | break | ||
1091 | case 'right': | ||
1092 | tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width} | ||
1093 | break | ||
1094 | } | ||
1095 | |||
1096 | $tip | ||
1097 | .offset(tp) | ||
1098 | .addClass(placement) | ||
1099 | .addClass('in') | ||
1100 | } | ||
1101 | } | ||
1102 | |||
1103 | , setContent: function () { | ||
1104 | var $tip = this.tip() | ||
1105 | , title = this.getTitle() | ||
1106 | |||
1107 | $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) | ||
1108 | $tip.removeClass('fade in top bottom left right') | ||
1109 | } | ||
1110 | |||
1111 | , hide: function () { | ||
1112 | var that = this | ||
1113 | , $tip = this.tip() | ||
1114 | |||
1115 | $tip.removeClass('in') | ||
1116 | |||
1117 | function removeWithAnimation() { | ||
1118 | var timeout = setTimeout(function () { | ||
1119 | $tip.off($.support.transition.end).detach() | ||
1120 | }, 500) | ||
1121 | |||
1122 | $tip.one($.support.transition.end, function () { | ||
1123 | clearTimeout(timeout) | ||
1124 | $tip.detach() | ||
1125 | }) | ||
1126 | } | ||
1127 | |||
1128 | $.support.transition && this.$tip.hasClass('fade') ? | ||
1129 | removeWithAnimation() : | ||
1130 | $tip.detach() | ||
1131 | |||
1132 | return this | ||
1133 | } | ||
1134 | |||
1135 | , fixTitle: function () { | ||
1136 | var $e = this.$element | ||
1137 | if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { | ||
1138 | $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title') | ||
1139 | } | ||
1140 | } | ||
1141 | |||
1142 | , hasContent: function () { | ||
1143 | return this.getTitle() | ||
1144 | } | ||
1145 | |||
1146 | , getPosition: function (inside) { | ||
1147 | return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), { | ||
1148 | width: this.$element[0].offsetWidth | ||
1149 | , height: this.$element[0].offsetHeight | ||
1150 | }) | ||
1151 | } | ||
1152 | |||
1153 | , getTitle: function () { | ||
1154 | var title | ||
1155 | , $e = this.$element | ||
1156 | , o = this.options | ||
1157 | |||
1158 | title = $e.attr('data-original-title') | ||
1159 | || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) | ||
1160 | |||
1161 | return title | ||
1162 | } | ||
1163 | |||
1164 | , tip: function () { | ||
1165 | return this.$tip = this.$tip || $(this.options.template) | ||
1166 | } | ||
1167 | |||
1168 | , validate: function () { | ||
1169 | if (!this.$element[0].parentNode) { | ||
1170 | this.hide() | ||
1171 | this.$element = null | ||
1172 | this.options = null | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | , enable: function () { | ||
1177 | this.enabled = true | ||
1178 | } | ||
1179 | |||
1180 | , disable: function () { | ||
1181 | this.enabled = false | ||
1182 | } | ||
1183 | |||
1184 | , toggleEnabled: function () { | ||
1185 | this.enabled = !this.enabled | ||
1186 | } | ||
1187 | |||
1188 | , toggle: function (e) { | ||
1189 | var self = $(e.currentTarget)[this.type](this._options).data(this.type) | ||
1190 | self[self.tip().hasClass('in') ? 'hide' : 'show']() | ||
1191 | } | ||
1192 | |||
1193 | , destroy: function () { | ||
1194 | this.hide().$element.off('.' + this.type).removeData(this.type) | ||
1195 | } | ||
1196 | |||
1197 | } | ||
1198 | |||
1199 | |||
1200 | /* TOOLTIP PLUGIN DEFINITION | ||
1201 | * ========================= */ | ||
1202 | |||
1203 | $.fn.tooltip = function ( option ) { | ||
1204 | return this.each(function () { | ||
1205 | var $this = $(this) | ||
1206 | , data = $this.data('tooltip') | ||
1207 | , options = typeof option == 'object' && option | ||
1208 | if (!data) $this.data('tooltip', (data = new Tooltip(this, options))) | ||
1209 | if (typeof option == 'string') data[option]() | ||
1210 | }) | ||
1211 | } | ||
1212 | |||
1213 | $.fn.tooltip.Constructor = Tooltip | ||
1214 | |||
1215 | $.fn.tooltip.defaults = { | ||
1216 | animation: true | ||
1217 | , placement: 'top' | ||
1218 | , selector: false | ||
1219 | , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' | ||
1220 | , trigger: 'hover' | ||
1221 | , title: '' | ||
1222 | , delay: 0 | ||
1223 | , html: false | ||
1224 | } | ||
1225 | |||
1226 | }(window.jQuery);/* =========================================================== | ||
1227 | * bootstrap-popover.js v2.2.1 | ||
1228 | * http://twitter.github.com/bootstrap/javascript.html#popovers | ||
1229 | * =========================================================== | ||
1230 | * Copyright 2012 Twitter, Inc. | ||
1231 | * | ||
1232 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1233 | * you may not use this file except in compliance with the License. | ||
1234 | * You may obtain a copy of the License at | ||
1235 | * | ||
1236 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1237 | * | ||
1238 | * Unless required by applicable law or agreed to in writing, software | ||
1239 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1240 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1241 | * See the License for the specific language governing permissions and | ||
1242 | * limitations under the License. | ||
1243 | * =========================================================== */ | ||
1244 | |||
1245 | |||
1246 | !function ($) { | ||
1247 | |||
1248 | "use strict"; // jshint ;_; | ||
1249 | |||
1250 | |||
1251 | /* POPOVER PUBLIC CLASS DEFINITION | ||
1252 | * =============================== */ | ||
1253 | |||
1254 | var Popover = function (element, options) { | ||
1255 | this.init('popover', element, options) | ||
1256 | } | ||
1257 | |||
1258 | |||
1259 | /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js | ||
1260 | ========================================== */ | ||
1261 | |||
1262 | Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, { | ||
1263 | |||
1264 | constructor: Popover | ||
1265 | |||
1266 | , setContent: function () { | ||
1267 | var $tip = this.tip() | ||
1268 | , title = this.getTitle() | ||
1269 | , content = this.getContent() | ||
1270 | |||
1271 | $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) | ||
1272 | $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content) | ||
1273 | |||
1274 | $tip.removeClass('fade top bottom left right in') | ||
1275 | } | ||
1276 | |||
1277 | , hasContent: function () { | ||
1278 | return this.getTitle() || this.getContent() | ||
1279 | } | ||
1280 | |||
1281 | , getContent: function () { | ||
1282 | var content | ||
1283 | , $e = this.$element | ||
1284 | , o = this.options | ||
1285 | |||
1286 | content = $e.attr('data-content') | ||
1287 | || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content) | ||
1288 | |||
1289 | return content | ||
1290 | } | ||
1291 | |||
1292 | , tip: function () { | ||
1293 | if (!this.$tip) { | ||
1294 | this.$tip = $(this.options.template) | ||
1295 | } | ||
1296 | return this.$tip | ||
1297 | } | ||
1298 | |||
1299 | , destroy: function () { | ||
1300 | this.hide().$element.off('.' + this.type).removeData(this.type) | ||
1301 | } | ||
1302 | |||
1303 | }) | ||
1304 | |||
1305 | |||
1306 | /* POPOVER PLUGIN DEFINITION | ||
1307 | * ======================= */ | ||
1308 | |||
1309 | $.fn.popover = function (option) { | ||
1310 | return this.each(function () { | ||
1311 | var $this = $(this) | ||
1312 | , data = $this.data('popover') | ||
1313 | , options = typeof option == 'object' && option | ||
1314 | if (!data) $this.data('popover', (data = new Popover(this, options))) | ||
1315 | if (typeof option == 'string') data[option]() | ||
1316 | }) | ||
1317 | } | ||
1318 | |||
1319 | $.fn.popover.Constructor = Popover | ||
1320 | |||
1321 | $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, { | ||
1322 | placement: 'right' | ||
1323 | , trigger: 'click' | ||
1324 | , content: '' | ||
1325 | , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' | ||
1326 | }) | ||
1327 | |||
1328 | }(window.jQuery);/* ============================================================= | ||
1329 | * bootstrap-scrollspy.js v2.2.1 | ||
1330 | * http://twitter.github.com/bootstrap/javascript.html#scrollspy | ||
1331 | * ============================================================= | ||
1332 | * Copyright 2012 Twitter, Inc. | ||
1333 | * | ||
1334 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1335 | * you may not use this file except in compliance with the License. | ||
1336 | * You may obtain a copy of the License at | ||
1337 | * | ||
1338 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1339 | * | ||
1340 | * Unless required by applicable law or agreed to in writing, software | ||
1341 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1342 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1343 | * See the License for the specific language governing permissions and | ||
1344 | * limitations under the License. | ||
1345 | * ============================================================== */ | ||
1346 | |||
1347 | |||
1348 | !function ($) { | ||
1349 | |||
1350 | "use strict"; // jshint ;_; | ||
1351 | |||
1352 | |||
1353 | /* SCROLLSPY CLASS DEFINITION | ||
1354 | * ========================== */ | ||
1355 | |||
1356 | function ScrollSpy(element, options) { | ||
1357 | var process = $.proxy(this.process, this) | ||
1358 | , $element = $(element).is('body') ? $(window) : $(element) | ||
1359 | , href | ||
1360 | this.options = $.extend({}, $.fn.scrollspy.defaults, options) | ||
1361 | this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process) | ||
1362 | this.selector = (this.options.target | ||
1363 | || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 | ||
1364 | || '') + ' .nav li > a' | ||
1365 | this.$body = $('body') | ||
1366 | this.refresh() | ||
1367 | this.process() | ||
1368 | } | ||
1369 | |||
1370 | ScrollSpy.prototype = { | ||
1371 | |||
1372 | constructor: ScrollSpy | ||
1373 | |||
1374 | , refresh: function () { | ||
1375 | var self = this | ||
1376 | , $targets | ||
1377 | |||
1378 | this.offsets = $([]) | ||
1379 | this.targets = $([]) | ||
1380 | |||
1381 | $targets = this.$body | ||
1382 | .find(this.selector) | ||
1383 | .map(function () { | ||
1384 | var $el = $(this) | ||
1385 | , href = $el.data('target') || $el.attr('href') | ||
1386 | , $href = /^#\w/.test(href) && $(href) | ||
1387 | return ( $href | ||
1388 | && $href.length | ||
1389 | && [[ $href.position().top, href ]] ) || null | ||
1390 | }) | ||
1391 | .sort(function (a, b) { return a[0] - b[0] }) | ||
1392 | .each(function () { | ||
1393 | self.offsets.push(this[0]) | ||
1394 | self.targets.push(this[1]) | ||
1395 | }) | ||
1396 | } | ||
1397 | |||
1398 | , process: function () { | ||
1399 | var scrollTop = this.$scrollElement.scrollTop() + this.options.offset | ||
1400 | , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight | ||
1401 | , maxScroll = scrollHeight - this.$scrollElement.height() | ||
1402 | , offsets = this.offsets | ||
1403 | , targets = this.targets | ||
1404 | , activeTarget = this.activeTarget | ||
1405 | , i | ||
1406 | |||
1407 | if (scrollTop >= maxScroll) { | ||
1408 | return activeTarget != (i = targets.last()[0]) | ||
1409 | && this.activate ( i ) | ||
1410 | } | ||
1411 | |||
1412 | for (i = offsets.length; i--;) { | ||
1413 | activeTarget != targets[i] | ||
1414 | && scrollTop >= offsets[i] | ||
1415 | && (!offsets[i + 1] || scrollTop <= offsets[i + 1]) | ||
1416 | && this.activate( targets[i] ) | ||
1417 | } | ||
1418 | } | ||
1419 | |||
1420 | , activate: function (target) { | ||
1421 | var active | ||
1422 | , selector | ||
1423 | |||
1424 | this.activeTarget = target | ||
1425 | |||
1426 | $(this.selector) | ||
1427 | .parent('.active') | ||
1428 | .removeClass('active') | ||
1429 | |||
1430 | selector = this.selector | ||
1431 | + '[data-target="' + target + '"],' | ||
1432 | + this.selector + '[href="' + target + '"]' | ||
1433 | |||
1434 | active = $(selector) | ||
1435 | .parent('li') | ||
1436 | .addClass('active') | ||
1437 | |||
1438 | if (active.parent('.dropdown-menu').length) { | ||
1439 | active = active.closest('li.dropdown').addClass('active') | ||
1440 | } | ||
1441 | |||
1442 | active.trigger('activate') | ||
1443 | } | ||
1444 | |||
1445 | } | ||
1446 | |||
1447 | |||
1448 | /* SCROLLSPY PLUGIN DEFINITION | ||
1449 | * =========================== */ | ||
1450 | |||
1451 | $.fn.scrollspy = function (option) { | ||
1452 | return this.each(function () { | ||
1453 | var $this = $(this) | ||
1454 | , data = $this.data('scrollspy') | ||
1455 | , options = typeof option == 'object' && option | ||
1456 | if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options))) | ||
1457 | if (typeof option == 'string') data[option]() | ||
1458 | }) | ||
1459 | } | ||
1460 | |||
1461 | $.fn.scrollspy.Constructor = ScrollSpy | ||
1462 | |||
1463 | $.fn.scrollspy.defaults = { | ||
1464 | offset: 10 | ||
1465 | } | ||
1466 | |||
1467 | |||
1468 | /* SCROLLSPY DATA-API | ||
1469 | * ================== */ | ||
1470 | |||
1471 | $(window).on('load', function () { | ||
1472 | $('[data-spy="scroll"]').each(function () { | ||
1473 | var $spy = $(this) | ||
1474 | $spy.scrollspy($spy.data()) | ||
1475 | }) | ||
1476 | }) | ||
1477 | |||
1478 | }(window.jQuery);/* ======================================================== | ||
1479 | * bootstrap-tab.js v2.2.1 | ||
1480 | * http://twitter.github.com/bootstrap/javascript.html#tabs | ||
1481 | * ======================================================== | ||
1482 | * Copyright 2012 Twitter, Inc. | ||
1483 | * | ||
1484 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1485 | * you may not use this file except in compliance with the License. | ||
1486 | * You may obtain a copy of the License at | ||
1487 | * | ||
1488 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1489 | * | ||
1490 | * Unless required by applicable law or agreed to in writing, software | ||
1491 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1492 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1493 | * See the License for the specific language governing permissions and | ||
1494 | * limitations under the License. | ||
1495 | * ======================================================== */ | ||
1496 | |||
1497 | |||
1498 | !function ($) { | ||
1499 | |||
1500 | "use strict"; // jshint ;_; | ||
1501 | |||
1502 | |||
1503 | /* TAB CLASS DEFINITION | ||
1504 | * ==================== */ | ||
1505 | |||
1506 | var Tab = function (element) { | ||
1507 | this.element = $(element) | ||
1508 | } | ||
1509 | |||
1510 | Tab.prototype = { | ||
1511 | |||
1512 | constructor: Tab | ||
1513 | |||
1514 | , show: function () { | ||
1515 | var $this = this.element | ||
1516 | , $ul = $this.closest('ul:not(.dropdown-menu)') | ||
1517 | , selector = $this.attr('data-target') | ||
1518 | , previous | ||
1519 | , $target | ||
1520 | , e | ||
1521 | |||
1522 | if (!selector) { | ||
1523 | selector = $this.attr('href') | ||
1524 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 | ||
1525 | } | ||
1526 | |||
1527 | if ( $this.parent('li').hasClass('active') ) return | ||
1528 | |||
1529 | previous = $ul.find('.active:last a')[0] | ||
1530 | |||
1531 | e = $.Event('show', { | ||
1532 | relatedTarget: previous | ||
1533 | }) | ||
1534 | |||
1535 | $this.trigger(e) | ||
1536 | |||
1537 | if (e.isDefaultPrevented()) return | ||
1538 | |||
1539 | $target = $(selector) | ||
1540 | |||
1541 | this.activate($this.parent('li'), $ul) | ||
1542 | this.activate($target, $target.parent(), function () { | ||
1543 | $this.trigger({ | ||
1544 | type: 'shown' | ||
1545 | , relatedTarget: previous | ||
1546 | }) | ||
1547 | }) | ||
1548 | } | ||
1549 | |||
1550 | , activate: function ( element, container, callback) { | ||
1551 | var $active = container.find('> .active') | ||
1552 | , transition = callback | ||
1553 | && $.support.transition | ||
1554 | && $active.hasClass('fade') | ||
1555 | |||
1556 | function next() { | ||
1557 | $active | ||
1558 | .removeClass('active') | ||
1559 | .find('> .dropdown-menu > .active') | ||
1560 | .removeClass('active') | ||
1561 | |||
1562 | element.addClass('active') | ||
1563 | |||
1564 | if (transition) { | ||
1565 | element[0].offsetWidth // reflow for transition | ||
1566 | element.addClass('in') | ||
1567 | } else { | ||
1568 | element.removeClass('fade') | ||
1569 | } | ||
1570 | |||
1571 | if ( element.parent('.dropdown-menu') ) { | ||
1572 | element.closest('li.dropdown').addClass('active') | ||
1573 | } | ||
1574 | |||
1575 | callback && callback() | ||
1576 | } | ||
1577 | |||
1578 | transition ? | ||
1579 | $active.one($.support.transition.end, next) : | ||
1580 | next() | ||
1581 | |||
1582 | $active.removeClass('in') | ||
1583 | } | ||
1584 | } | ||
1585 | |||
1586 | |||
1587 | /* TAB PLUGIN DEFINITION | ||
1588 | * ===================== */ | ||
1589 | |||
1590 | $.fn.tab = function ( option ) { | ||
1591 | return this.each(function () { | ||
1592 | var $this = $(this) | ||
1593 | , data = $this.data('tab') | ||
1594 | if (!data) $this.data('tab', (data = new Tab(this))) | ||
1595 | if (typeof option == 'string') data[option]() | ||
1596 | }) | ||
1597 | } | ||
1598 | |||
1599 | $.fn.tab.Constructor = Tab | ||
1600 | |||
1601 | |||
1602 | /* TAB DATA-API | ||
1603 | * ============ */ | ||
1604 | |||
1605 | $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { | ||
1606 | e.preventDefault() | ||
1607 | $(this).tab('show') | ||
1608 | }) | ||
1609 | |||
1610 | }(window.jQuery);/* ============================================================= | ||
1611 | * bootstrap-typeahead.js v2.2.1 | ||
1612 | * http://twitter.github.com/bootstrap/javascript.html#typeahead | ||
1613 | * ============================================================= | ||
1614 | * Copyright 2012 Twitter, Inc. | ||
1615 | * | ||
1616 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1617 | * you may not use this file except in compliance with the License. | ||
1618 | * You may obtain a copy of the License at | ||
1619 | * | ||
1620 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1621 | * | ||
1622 | * Unless required by applicable law or agreed to in writing, software | ||
1623 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1624 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1625 | * See the License for the specific language governing permissions and | ||
1626 | * limitations under the License. | ||
1627 | * ============================================================ */ | ||
1628 | |||
1629 | |||
1630 | !function($){ | ||
1631 | |||
1632 | "use strict"; // jshint ;_; | ||
1633 | |||
1634 | |||
1635 | /* TYPEAHEAD PUBLIC CLASS DEFINITION | ||
1636 | * ================================= */ | ||
1637 | |||
1638 | var Typeahead = function (element, options) { | ||
1639 | this.$element = $(element) | ||
1640 | this.options = $.extend({}, $.fn.typeahead.defaults, options) | ||
1641 | this.matcher = this.options.matcher || this.matcher | ||
1642 | this.sorter = this.options.sorter || this.sorter | ||
1643 | this.highlighter = this.options.highlighter || this.highlighter | ||
1644 | this.updater = this.options.updater || this.updater | ||
1645 | this.$menu = $(this.options.menu).appendTo('body') | ||
1646 | this.source = this.options.source | ||
1647 | this.shown = false | ||
1648 | this.listen() | ||
1649 | } | ||
1650 | |||
1651 | Typeahead.prototype = { | ||
1652 | |||
1653 | constructor: Typeahead | ||
1654 | |||
1655 | , select: function () { | ||
1656 | var val = this.$menu.find('.active').attr('data-value') | ||
1657 | this.$element | ||
1658 | .val(this.updater(val)) | ||
1659 | .change() | ||
1660 | return this.hide() | ||
1661 | } | ||
1662 | |||
1663 | , updater: function (item) { | ||
1664 | return item | ||
1665 | } | ||
1666 | |||
1667 | , show: function () { | ||
1668 | var pos = $.extend({}, this.$element.offset(), { | ||
1669 | height: this.$element[0].offsetHeight | ||
1670 | }) | ||
1671 | |||
1672 | this.$menu.css({ | ||
1673 | top: pos.top + pos.height | ||
1674 | , left: pos.left | ||
1675 | }) | ||
1676 | |||
1677 | this.$menu.show() | ||
1678 | this.shown = true | ||
1679 | return this | ||
1680 | } | ||
1681 | |||
1682 | , hide: function () { | ||
1683 | this.$menu.hide() | ||
1684 | this.shown = false | ||
1685 | return this | ||
1686 | } | ||
1687 | |||
1688 | , lookup: function (event) { | ||
1689 | var items | ||
1690 | |||
1691 | this.query = this.$element.val() | ||
1692 | |||
1693 | if (!this.query || this.query.length < this.options.minLength) { | ||
1694 | return this.shown ? this.hide() : this | ||
1695 | } | ||
1696 | |||
1697 | items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source | ||
1698 | |||
1699 | return items ? this.process(items) : this | ||
1700 | } | ||
1701 | |||
1702 | , process: function (items) { | ||
1703 | var that = this | ||
1704 | |||
1705 | items = $.grep(items, function (item) { | ||
1706 | return that.matcher(item) | ||
1707 | }) | ||
1708 | |||
1709 | items = this.sorter(items) | ||
1710 | |||
1711 | if (!items.length) { | ||
1712 | return this.shown ? this.hide() : this | ||
1713 | } | ||
1714 | |||
1715 | return this.render(items.slice(0, this.options.items)).show() | ||
1716 | } | ||
1717 | |||
1718 | , matcher: function (item) { | ||
1719 | return ~item.toLowerCase().indexOf(this.query.toLowerCase()) | ||
1720 | } | ||
1721 | |||
1722 | , sorter: function (items) { | ||
1723 | var beginswith = [] | ||
1724 | , caseSensitive = [] | ||
1725 | , caseInsensitive = [] | ||
1726 | , item | ||
1727 | |||
1728 | while (item = items.shift()) { | ||
1729 | if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item) | ||
1730 | else if (~item.indexOf(this.query)) caseSensitive.push(item) | ||
1731 | else caseInsensitive.push(item) | ||
1732 | } | ||
1733 | |||
1734 | return beginswith.concat(caseSensitive, caseInsensitive) | ||
1735 | } | ||
1736 | |||
1737 | , highlighter: function (item) { | ||
1738 | var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') | ||
1739 | return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) { | ||
1740 | return '<strong>' + match + '</strong>' | ||
1741 | }) | ||
1742 | } | ||
1743 | |||
1744 | , render: function (items) { | ||
1745 | var that = this | ||
1746 | |||
1747 | items = $(items).map(function (i, item) { | ||
1748 | i = $(that.options.item).attr('data-value', item) | ||
1749 | i.find('a').html(that.highlighter(item)) | ||
1750 | return i[0] | ||
1751 | }) | ||
1752 | |||
1753 | items.first().addClass('active') | ||
1754 | this.$menu.html(items) | ||
1755 | return this | ||
1756 | } | ||
1757 | |||
1758 | , next: function (event) { | ||
1759 | var active = this.$menu.find('.active').removeClass('active') | ||
1760 | , next = active.next() | ||
1761 | |||
1762 | if (!next.length) { | ||
1763 | next = $(this.$menu.find('li')[0]) | ||
1764 | } | ||
1765 | |||
1766 | next.addClass('active') | ||
1767 | } | ||
1768 | |||
1769 | , prev: function (event) { | ||
1770 | var active = this.$menu.find('.active').removeClass('active') | ||
1771 | , prev = active.prev() | ||
1772 | |||
1773 | if (!prev.length) { | ||
1774 | prev = this.$menu.find('li').last() | ||
1775 | } | ||
1776 | |||
1777 | prev.addClass('active') | ||
1778 | } | ||
1779 | |||
1780 | , listen: function () { | ||
1781 | this.$element | ||
1782 | .on('blur', $.proxy(this.blur, this)) | ||
1783 | .on('keypress', $.proxy(this.keypress, this)) | ||
1784 | .on('keyup', $.proxy(this.keyup, this)) | ||
1785 | |||
1786 | if (this.eventSupported('keydown')) { | ||
1787 | this.$element.on('keydown', $.proxy(this.keydown, this)) | ||
1788 | } | ||
1789 | |||
1790 | this.$menu | ||
1791 | .on('click', $.proxy(this.click, this)) | ||
1792 | .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) | ||
1793 | } | ||
1794 | |||
1795 | , eventSupported: function(eventName) { | ||
1796 | var isSupported = eventName in this.$element | ||
1797 | if (!isSupported) { | ||
1798 | this.$element.setAttribute(eventName, 'return;') | ||
1799 | isSupported = typeof this.$element[eventName] === 'function' | ||
1800 | } | ||
1801 | return isSupported | ||
1802 | } | ||
1803 | |||
1804 | , move: function (e) { | ||
1805 | if (!this.shown) return | ||
1806 | |||
1807 | switch(e.keyCode) { | ||
1808 | case 9: // tab | ||
1809 | case 13: // enter | ||
1810 | case 27: // escape | ||
1811 | e.preventDefault() | ||
1812 | break | ||
1813 | |||
1814 | case 38: // up arrow | ||
1815 | e.preventDefault() | ||
1816 | this.prev() | ||
1817 | break | ||
1818 | |||
1819 | case 40: // down arrow | ||
1820 | e.preventDefault() | ||
1821 | this.next() | ||
1822 | break | ||
1823 | } | ||
1824 | |||
1825 | e.stopPropagation() | ||
1826 | } | ||
1827 | |||
1828 | , keydown: function (e) { | ||
1829 | this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27]) | ||
1830 | this.move(e) | ||
1831 | } | ||
1832 | |||
1833 | , keypress: function (e) { | ||
1834 | if (this.suppressKeyPressRepeat) return | ||
1835 | this.move(e) | ||
1836 | } | ||
1837 | |||
1838 | , keyup: function (e) { | ||
1839 | switch(e.keyCode) { | ||
1840 | case 40: // down arrow | ||
1841 | case 38: // up arrow | ||
1842 | case 16: // shift | ||
1843 | case 17: // ctrl | ||
1844 | case 18: // alt | ||
1845 | break | ||
1846 | |||
1847 | case 9: // tab | ||
1848 | case 13: // enter | ||
1849 | if (!this.shown) return | ||
1850 | this.select() | ||
1851 | break | ||
1852 | |||
1853 | case 27: // escape | ||
1854 | if (!this.shown) return | ||
1855 | this.hide() | ||
1856 | break | ||
1857 | |||
1858 | default: | ||
1859 | this.lookup() | ||
1860 | } | ||
1861 | |||
1862 | e.stopPropagation() | ||
1863 | e.preventDefault() | ||
1864 | } | ||
1865 | |||
1866 | , blur: function (e) { | ||
1867 | var that = this | ||
1868 | setTimeout(function () { that.hide() }, 150) | ||
1869 | } | ||
1870 | |||
1871 | , click: function (e) { | ||
1872 | e.stopPropagation() | ||
1873 | e.preventDefault() | ||
1874 | this.select() | ||
1875 | } | ||
1876 | |||
1877 | , mouseenter: function (e) { | ||
1878 | this.$menu.find('.active').removeClass('active') | ||
1879 | $(e.currentTarget).addClass('active') | ||
1880 | } | ||
1881 | |||
1882 | } | ||
1883 | |||
1884 | |||
1885 | /* TYPEAHEAD PLUGIN DEFINITION | ||
1886 | * =========================== */ | ||
1887 | |||
1888 | $.fn.typeahead = function (option) { | ||
1889 | return this.each(function () { | ||
1890 | var $this = $(this) | ||
1891 | , data = $this.data('typeahead') | ||
1892 | , options = typeof option == 'object' && option | ||
1893 | if (!data) $this.data('typeahead', (data = new Typeahead(this, options))) | ||
1894 | if (typeof option == 'string') data[option]() | ||
1895 | }) | ||
1896 | } | ||
1897 | |||
1898 | $.fn.typeahead.defaults = { | ||
1899 | source: [] | ||
1900 | , items: 8 | ||
1901 | , menu: '<ul class="typeahead dropdown-menu"></ul>' | ||
1902 | , item: '<li><a href="#"></a></li>' | ||
1903 | , minLength: 1 | ||
1904 | } | ||
1905 | |||
1906 | $.fn.typeahead.Constructor = Typeahead | ||
1907 | |||
1908 | |||
1909 | /* TYPEAHEAD DATA-API | ||
1910 | * ================== */ | ||
1911 | |||
1912 | $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { | ||
1913 | var $this = $(this) | ||
1914 | if ($this.data('typeahead')) return | ||
1915 | e.preventDefault() | ||
1916 | $this.typeahead($this.data()) | ||
1917 | }) | ||
1918 | |||
1919 | }(window.jQuery); | ||
1920 | /* ========================================================== | ||
1921 | * bootstrap-affix.js v2.2.1 | ||
1922 | * http://twitter.github.com/bootstrap/javascript.html#affix | ||
1923 | * ========================================================== | ||
1924 | * Copyright 2012 Twitter, Inc. | ||
1925 | * | ||
1926 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1927 | * you may not use this file except in compliance with the License. | ||
1928 | * You may obtain a copy of the License at | ||
1929 | * | ||
1930 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1931 | * | ||
1932 | * Unless required by applicable law or agreed to in writing, software | ||
1933 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1934 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1935 | * See the License for the specific language governing permissions and | ||
1936 | * limitations under the License. | ||
1937 | * ========================================================== */ | ||
1938 | |||
1939 | |||
1940 | !function ($) { | ||
1941 | |||
1942 | "use strict"; // jshint ;_; | ||
1943 | |||
1944 | |||
1945 | /* AFFIX CLASS DEFINITION | ||
1946 | * ====================== */ | ||
1947 | |||
1948 | var Affix = function (element, options) { | ||
1949 | this.options = $.extend({}, $.fn.affix.defaults, options) | ||
1950 | this.$window = $(window) | ||
1951 | .on('scroll.affix.data-api', $.proxy(this.checkPosition, this)) | ||
1952 | .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this)) | ||
1953 | this.$element = $(element) | ||
1954 | this.checkPosition() | ||
1955 | } | ||
1956 | |||
1957 | Affix.prototype.checkPosition = function () { | ||
1958 | if (!this.$element.is(':visible')) return | ||
1959 | |||
1960 | var scrollHeight = $(document).height() | ||
1961 | , scrollTop = this.$window.scrollTop() | ||
1962 | , position = this.$element.offset() | ||
1963 | , offset = this.options.offset | ||
1964 | , offsetBottom = offset.bottom | ||
1965 | , offsetTop = offset.top | ||
1966 | , reset = 'affix affix-top affix-bottom' | ||
1967 | , affix | ||
1968 | |||
1969 | if (typeof offset != 'object') offsetBottom = offsetTop = offset | ||
1970 | if (typeof offsetTop == 'function') offsetTop = offset.top() | ||
1971 | if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() | ||
1972 | |||
1973 | affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? | ||
1974 | false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? | ||
1975 | 'bottom' : offsetTop != null && scrollTop <= offsetTop ? | ||
1976 | 'top' : false | ||
1977 | |||
1978 | if (this.affixed === affix) return | ||
1979 | |||
1980 | this.affixed = affix | ||
1981 | this.unpin = affix == 'bottom' ? position.top - scrollTop : null | ||
1982 | |||
1983 | this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : '')) | ||
1984 | } | ||
1985 | |||
1986 | |||
1987 | /* AFFIX PLUGIN DEFINITION | ||
1988 | * ======================= */ | ||
1989 | |||
1990 | $.fn.affix = function (option) { | ||
1991 | return this.each(function () { | ||
1992 | var $this = $(this) | ||
1993 | , data = $this.data('affix') | ||
1994 | , options = typeof option == 'object' && option | ||
1995 | if (!data) $this.data('affix', (data = new Affix(this, options))) | ||
1996 | if (typeof option == 'string') data[option]() | ||
1997 | }) | ||
1998 | } | ||
1999 | |||
2000 | $.fn.affix.Constructor = Affix | ||
2001 | |||
2002 | $.fn.affix.defaults = { | ||
2003 | offset: 0 | ||
2004 | } | ||
2005 | |||
2006 | |||
2007 | /* AFFIX DATA-API | ||
2008 | * ============== */ | ||
2009 | |||
2010 | $(window).on('load', function () { | ||
2011 | $('[data-spy="affix"]').each(function () { | ||
2012 | var $spy = $(this) | ||
2013 | , data = $spy.data() | ||
2014 | |||
2015 | data.offset = data.offset || {} | ||
2016 | |||
2017 | data.offsetBottom && (data.offset.bottom = data.offsetBottom) | ||
2018 | data.offsetTop && (data.offset.top = data.offsetTop) | ||
2019 | |||
2020 | $spy.affix(data) | ||
2021 | }) | ||
2022 | }) | ||
2023 | |||
2024 | |||
2025 | }(window.jQuery); |
js/lib/jquery-1.8.0.min.js
1 | /*! jQuery v@1.8.0 jquery.com | jquery.org/license */ | ||
---|---|---|---|
2 | (function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)p.event.add(b,c,h[c][d])}g.data&&(g.data=p.extend({},g.data))}function bE(a,b){var c;if(b.nodeType!==1)return;b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?(b.parentNode&&(b.outerHTML=a.outerHTML),p.support.html5Clone&&a.innerHTML&&!p.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):c==="input"&&bv.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text),b.removeAttribute(p.expando)}function bF(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bG(a){bv.test(a.type)&&(a.defaultChecked=a.checked)}function bX(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=bV.length;while(e--){b=bV[e]+c;if(b in a)return b}return d}function bY(a,b){return a=b||a,p.css(a,"display")==="none"||!p.contains(a.ownerDocument,a)}function bZ(a,b){var c,d,e=[],f=0,g=a.length;for(;f<g;f++){c=a[f];if(!c.style)continue;e[f]=p._data(c,"olddisplay"),b?(!e[f]&&c.style.display==="none"&&(c.style.display=""),c.style.display===""&&bY(c)&&(e[f]=p._data(c,"olddisplay",cb(c.nodeName)))):(d=bH(c,"display"),!e[f]&&d!=="none"&&p._data(c,"olddisplay",d))}for(f=0;f<g;f++){c=a[f];if(!c.style)continue;if(!b||c.style.display==="none"||c.style.display==="")c.style.display=b?e[f]||"":"none"}return a}function b$(a,b,c){var d=bO.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function b_(a,b,c,d){var e=c===(d?"border":"content")?4:b==="width"?1:0,f=0;for(;e<4;e+=2)c==="margin"&&(f+=p.css(a,c+bU[e],!0)),d?(c==="content"&&(f-=parseFloat(bH(a,"padding"+bU[e]))||0),c!=="margin"&&(f-=parseFloat(bH(a,"border"+bU[e]+"Width"))||0)):(f+=parseFloat(bH(a,"padding"+bU[e]))||0,c!=="padding"&&(f+=parseFloat(bH(a,"border"+bU[e]+"Width"))||0));return f}function ca(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=!0,f=p.support.boxSizing&&p.css(a,"boxSizing")==="border-box";if(d<=0){d=bH(a,b);if(d<0||d==null)d=a.style[b];if(bP.test(d))return d;e=f&&(p.support.boxSizingReliable||d===a.style[b]),d=parseFloat(d)||0}return d+b_(a,b,c||(f?"border":"content"),e)+"px"}function cb(a){if(bR[a])return bR[a];var b=p("<"+a+">").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write("<!doctype html><html><body>"),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bR[a]=c,c}function ch(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||cd.test(a)?d(a,e):ch(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ch(a+"["+e+"]",b[e],c,d);else d(a,b)}function cy(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h<i;h++)d=g[h],f=/^\+/.test(d),f&&(d=d.substr(1)||"*"),e=a[d]=a[d]||[],e[f?"unshift":"push"](c)}}function cz(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h,i=a[f],j=0,k=i?i.length:0,l=a===cu;for(;j<k&&(l||!h);j++)h=i[j](c,d,e),typeof h=="string"&&(!l||g[h]?h=b:(c.dataTypes.unshift(h),h=cz(a,c,d,e,h,g)));return(l||!h)&&!g["*"]&&(h=cz(a,c,d,e,"*",g)),h}function cA(a,c){var d,e,f=p.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((f[d]?a:e||(e={}))[d]=c[d]);e&&p.extend(!0,a,e)}function cB(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(f in k)f in d&&(c[k[f]]=d[f]);while(j[0]==="*")j.shift(),e===b&&(e=a.mimeType||c.getResponseHeader("content-type"));if(e)for(f in i)if(i[f]&&i[f].test(e)){j.unshift(f);break}if(j[0]in d)g=j[0];else{for(f in d){if(!j[0]||a.converters[f+" "+j[0]]){g=f;break}h||(h=f)}g=g||h}if(g)return g!==j[0]&&j.unshift(g),d[g]}function cC(a,b){var c,d,e,f,g=a.dataTypes.slice(),h=g[0],i={},j=0;a.dataFilter&&(b=a.dataFilter(b,a.dataType));if(g[1])for(c in a.converters)i[c.toLowerCase()]=a.converters[c];for(;e=g[++j];)if(e!=="*"){if(h!=="*"&&h!==e){c=i[h+" "+e]||i["* "+e];if(!c)for(d in i){f=d.split(" ");if(f[1]===e){c=i[h+" "+f[0]]||i["* "+f[0]];if(c){c===!0?c=i[d]:i[d]!==!0&&(e=f[0],g.splice(j--,0,e));break}}}if(c!==!0)if(c&&a["throws"])b=c(b);else try{b=c(b)}catch(k){return{state:"parsererror",error:c?k:"No conversion from "+h+" to "+e}}}h=e}return{state:"success",data:b}}function cK(){try{return new a.XMLHttpRequest}catch(b){}}function cL(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cT(){return setTimeout(function(){cM=b},0),cM=p.now()}function cU(a,b){p.each(b,function(b,c){var d=(cS[b]||[]).concat(cS["*"]),e=0,f=d.length;for(;e<f;e++)if(d[e].call(a,b,c))return})}function cV(a,b,c){var d,e=0,f=0,g=cR.length,h=p.Deferred().always(function(){delete i.elem}),i=function(){var b=cM||cT(),c=Math.max(0,j.startTime+j.duration-b),d=1-(c/j.duration||0),e=0,f=j.tweens.length;for(;e<f;e++)j.tweens[e].run(d);return h.notifyWith(a,[j,d,c]),d<1&&f?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:p.extend({},b),opts:p.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:cM||cT(),duration:c.duration,tweens:[],createTween:function(b,c,d){var e=p.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(e),e},stop:function(b){var c=0,d=b?j.tweens.length:0;for(;c<d;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;cW(k,j.opts.specialEasing);for(;e<g;e++){d=cR[e].call(j,a,k,j.opts);if(d)return d}return cU(j,k),p.isFunction(j.opts.start)&&j.opts.start.call(a,j),p.fx.timer(p.extend(i,{anim:j,queue:j.opts.queue,elem:a})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function cW(a,b){var c,d,e,f,g;for(c in a){d=p.camelCase(c),e=b[d],f=a[c],p.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=p.cssHooks[d];if(g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}}function cX(a,b,c){var d,e,f,g,h,i,j,k,l=this,m=a.style,n={},o=[],q=a.nodeType&&bY(a);c.queue||(j=p._queueHooks(a,"fx"),j.unqueued==null&&(j.unqueued=0,k=j.empty.fire,j.empty.fire=function(){j.unqueued||k()}),j.unqueued++,l.always(function(){l.always(function(){j.unqueued--,p.queue(a,"fx").length||j.empty.fire()})})),a.nodeType===1&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],p.css(a,"display")==="inline"&&p.css(a,"float")==="none"&&(!p.support.inlineBlockNeedsLayout||cb(a.nodeName)==="inline"?m.display="inline-block":m.zoom=1)),c.overflow&&(m.overflow="hidden",p.support.shrinkWrapBlocks||l.done(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b){f=b[d];if(cO.exec(f)){delete b[d];if(f===(q?"hide":"show"))continue;o.push(d)}}g=o.length;if(g){h=p._data(a,"fxshow")||p._data(a,"fxshow",{}),q?p(a).show():l.done(function(){p(a).hide()}),l.done(function(){var b;p.removeData(a,"fxshow",!0);for(b in n)p.style(a,b,n[b])});for(d=0;d<g;d++)e=o[d],i=l.createTween(e,q?h[e]:0),n[e]=h[e]||p.style(a,e),e in h||(h[e]=i.start,q&&(i.end=i.start,i.start=e==="width"||e==="height"?1:0))}}function cY(a,b,c,d,e){return new cY.prototype.init(a,b,c,d,e)}function cZ(a,b){var c,d={height:a},e=0;for(;e<4;e+=2-b)c=bU[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function c_(a){return p.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}var c,d,e=a.document,f=a.location,g=a.navigator,h=a.jQuery,i=a.$,j=Array.prototype.push,k=Array.prototype.slice,l=Array.prototype.indexOf,m=Object.prototype.toString,n=Object.prototype.hasOwnProperty,o=String.prototype.trim,p=function(a,b){return new p.fn.init(a,b,c)},q=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,r=/\S/,s=/\s+/,t=r.test("Â ")?/^[\s\xA0]+|[\s\xA0]+$/g:/^\s+|\s+$/g,u=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.0",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i<j;i++)if((a=arguments[i])!=null)for(c in a){d=h[c],e=a[c];if(h===e)continue;k&&e&&(p.isPlainObject(e)||(f=p.isArray(e)))?(f?(f=!1,g=d&&p.isArray(d)?d:[]):g=d&&p.isPlainObject(d)?d:{},h[c]=p.extend(k,g,e)):e!==b&&(h[c]=e)}return h},p.extend({noConflict:function(b){return a.$===p&&(a.$=i),b&&a.jQuery===p&&(a.jQuery=h),p},isReady:!1,readyWait:1,holdReady:function(a){a?p.readyWait++:p.ready(!0)},ready:function(a){if(a===!0?--p.readyWait:p.isReady)return;if(!e.body)return setTimeout(p.ready,1);p.isReady=!0;if(a!==!0&&--p.readyWait>0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f<g;)if(c.apply(a[f++],d)===!1)break}else if(h){for(e in a)if(c.call(a[e],e,a[e])===!1)break}else for(;f<g;)if(c.call(a[f],f,a[f++])===!1)break;return a},trim:o?function(a){return a==null?"":o.call(a)}:function(a){return a==null?"":a.toString().replace(t,"")},makeArray:function(a,b){var c,d=b||[];return a!=null&&(c=p.type(a),a.length==null||c==="string"||c==="function"||c==="regexp"||p.isWindow(a)?j.call(d,a):p.merge(d,a)),d},inArray:function(a,b,c){var d;if(b){if(l)return l.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=c.length,e=a.length,f=0;if(typeof d=="number")for(;f<d;f++)a[e++]=c[f];else while(c[f]!==b)a[e++]=c[f++];return a.length=e,a},grep:function(a,b,c){var d,e=[],f=0,g=a.length;c=!!c;for(;f<g;f++)d=!!b(a[f],f),c!==d&&e.push(a[f]);return e},map:function(a,c,d){var e,f,g=[],h=0,i=a.length,j=a instanceof p||i!==b&&typeof i=="number"&&(i>0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h<i;h++)e=c(a[h],h,d),e!=null&&(g[g.length]=e);else for(f in a)e=c(a[f],f,d),e!=null&&(g[g.length]=e);return g.concat.apply([],g)},guid:1,proxy:function(a,c){var d,e,f;return typeof c=="string"&&(d=a[c],c=a,a=d),p.isFunction(a)?(e=k.call(arguments,2),f=function(){return a.apply(c,e.concat(k.call(arguments)))},f.guid=a.guid=a.guid||f.guid||p.guid++,f):b},access:function(a,c,d,e,f,g,h){var i,j=d==null,k=0,l=a.length;if(d&&typeof d=="object"){for(k in d)p.access(a,c,k,d[k],1,g,e);f=1}else if(e!==b){i=h===b&&p.isFunction(e),j&&(i?(i=c,c=function(a,b,c){return i.call(p(a),c)}):(c.call(a,e),c=null));if(c)for(;k<l;k++)c(a[k],d,i?e.call(a[k],k,c(a[k],d)):e,h);f=1}return f?a:j?c.call(a):l?c(a[0],d):g},now:function(){return(new Date).getTime()}}),p.ready.promise=function(b){if(!d){d=p.Deferred();if(e.readyState==="complete"||e.readyState!=="loading"&&e.addEventListener)setTimeout(p.ready,1);else if(e.addEventListener)e.addEventListener("DOMContentLoaded",D,!1),a.addEventListener("load",p.ready,!1);else{e.attachEvent("onreadystatechange",D),a.attachEvent("onload",p.ready);var c=!1;try{c=a.frameElement==null&&e.documentElement}catch(f){}c&&c.doScroll&&function g(){if(!p.isReady){try{c.doScroll("left")}catch(a){return setTimeout(g,50)}p.ready()}}()}}return d.promise(b)},p.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){E["[object "+b+"]"]=b.toLowerCase()}),c=p(e);var F={};p.Callbacks=function(a){a=typeof a=="string"?F[a]||G(a):p.extend({},a);var c,d,e,f,g,h,i=[],j=!a.once&&[],k=function(b){c=a.memory&&b,d=!0,h=f||0,f=0,g=i.length,e=!0;for(;i&&h<g;h++)if(i[h].apply(b[0],b[1])===!1&&a.stopOnFalse){c=!1;break}e=!1,i&&(j?j.length&&k(j.shift()):c?i=[]:l.disable())},l={add:function(){if(i){var b=i.length;(function d(b){p.each(b,function(b,c){p.isFunction(c)&&(!a.unique||!l.has(c))?i.push(c):c&&c.length&&d(c)})})(arguments),e?g=i.length:c&&(f=b,k(c))}return this},remove:function(){return i&&p.each(arguments,function(a,b){var c;while((c=p.inArray(b,i,c))>-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;b<d;b++)c[b]&&p.isFunction(c[b].promise)?c[b].promise().done(g(b,j,c)).fail(f.reject).progress(g(b,i,h)):--e}return e||f.resolveWith(j,c),f.promise()}}),p.support=function(){var b,c,d,f,g,h,i,j,k,l,m,n=e.createElement("div");n.setAttribute("className","t"),n.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length||!d)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="<div></div>",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/^(?:\{.*\}|\[.*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||++p.uuid:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e<f;e++)delete d[b[e]];if(!(c?K:p.isEmptyObject)(d))return}}if(!c){delete h[i].data;if(!K(h[i]))return}g?p.cleanData([a],!0):p.support.deleteExpando||h!=h.window?delete h[i]:h[i]=null},_data:function(a,b,c){return p.data(a,b,c,!0)},acceptData:function(a){var b=a.nodeName&&p.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),p.fn.extend({data:function(a,c){var d,e,f,g,h,i=this[0],j=0,k=null;if(a===b){if(this.length){k=p.data(i);if(i.nodeType===1&&!p._data(i,"parsedAttrs")){f=i.attributes;for(h=f.length;j<h;j++)g=f[j].name,g.indexOf("data-")===0&&(g=p.camelCase(g.substring(5)),J(i,g,k[g]));p._data(i,"parsedAttrs",!0)}}return k}return typeof a=="object"?this.each(function(){p.data(this,a)}):(d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!",p.access(this,function(c){if(c===b)return k=this.triggerHandler("getData"+e,[d[0]]),k===b&&i&&(k=p.data(i,a),k=J(i,a,k)),k===b&&d[1]?this.data(d[0]):k;d[1]=c,this.each(function(){var b=p(this);b.triggerHandler("setData"+e,d),p.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.shift(),e=p._queueHooks(a,b),f=function(){p.dequeue(a,b)};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),delete e.stop,d.call(a,f,e)),!c.length&&e&&e.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length<d?p.queue(this[0],a):c===b?this:this.each(function(){var b=p.queue(this,a,c);p._queueHooks(this,a),a==="fx"&&b[0]!=="inprogress"&&p.dequeue(this,a)})},dequeue:function(a){return this.each(function(){p.dequeue(this,a)})},delay:function(a,b){return a=p.fx?p.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,e=1,f=p.Deferred(),g=this,h=this.length,i=function(){--e||f.resolveWith(g,[g])};typeof a!="string"&&(c=a,a=b),a=a||"fx";while(h--)(d=p._data(g[h],a+"queueHooks"))&&d.empty&&(e++,d.empty.add(i));return i(),f.promise(c)}});var L,M,N,O=/[\t\r\n]/g,P=/\r/g,Q=/^(?:button|input)$/i,R=/^(?:button|input|object|select|textarea)$/i,S=/^a(?:rea|)$/i,T=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,U=p.support.getSetAttribute;p.fn.extend({attr:function(a,b){return p.access(this,p.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{f=" "+e.className+" ";for(g=0,h=b.length;g<h;g++)~f.indexOf(" "+b[g]+" ")||(f+=b[g]+" ");e.className=p.trim(f)}}}return this},removeClass:function(a){var c,d,e,f,g,h,i;if(p.isFunction(a))return this.each(function(b){p(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(s);for(h=0,i=this.length;h<i;h++){e=this[h];if(e.nodeType===1&&e.className){d=(" "+e.className+" ").replace(O," ");for(f=0,g=c.length;f<g;f++)while(d.indexOf(" "+c[f]+" ")>-1)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(O," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c<d;c++){e=h[c];if(e.selected&&(p.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!p.nodeName(e.parentNode,"optgroup"))){b=p(e).val();if(i)return b;g.push(b)}}return i&&!g.length&&h.length?p(h[f]).val():g},set:function(a,b){var c=p.makeArray(b);return p(a).find("option").each(function(){this.selected=p.inArray(p(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g<d.length;g++)e=d[g],e&&(c=p.propFix[e]||e,f=T.test(e),f||p.attr(a,e,""),a.removeAttribute(U?e:c),f&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(Q.test(a.nodeName)&&a.parentNode)p.error("type property can't be changed");else if(!p.support.radioValue&&b==="radio"&&p.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}},value:{get:function(a,b){return L&&p.nodeName(a,"button")?L.get(a,b):b in a?a.value:null},set:function(a,b,c){if(L&&p.nodeName(a,"button"))return L.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(!a||h===3||h===8||h===2)return;return g=h!==1||!p.isXMLDoc(a),g&&(c=p.propFix[c]||c,f=p.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&(e=f.get(a,c))!==null?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):R.test(a.nodeName)||S.test(a.nodeName)&&a.href?0:b}}}}),M={get:function(a,c){var d,e=p.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;return b===!1?p.removeAttr(a,c):(d=p.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase())),c}},U||(N={name:!0,id:!0,coords:!0},L=p.valHooks.button={get:function(a,c){var d;return d=a.getAttributeNode(c),d&&(N[c]?d.value!=="":d.specified)?d.value:b},set:function(a,b,c){var d=a.getAttributeNode(c);return d||(d=e.createAttribute(c),a.setAttributeNode(d)),d.value=b+""}},p.each(["width","height"],function(a,b){p.attrHooks[b]=p.extend(p.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),p.attrHooks.contenteditable={get:L.get,set:function(a,b,c){b===""&&(b="false"),L.set(a,b,c)}}),p.support.hrefNormalized||p.each(["href","src","width","height"],function(a,c){p.attrHooks[c]=p.extend(p.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),p.support.style||(p.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),p.support.optSelected||(p.propHooks.selected=p.extend(p.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),p.support.enctype||(p.propFix.enctype="encoding"),p.support.checkOn||p.each(["radio","checkbox"],function(){p.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]=p.extend(p.valHooks[this],{set:function(a,b){if(p.isArray(b))return a.checked=p.inArray(p(a).val(),b)>=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j<c.length;j++){k=W.exec(c[j])||[],l=k[1],m=(k[2]||"").split(".").sort(),r=p.event.special[l]||{},l=(f?r.delegateType:r.bindType)||l,r=p.event.special[l]||{},n=p.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,namespace:m.join(".")},o),q=i[l];if(!q){q=i[l]=[],q.delegateCount=0;if(!r.setup||r.setup.call(a,e,m,h)===!1)a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h)}r.add&&(r.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?q.splice(q.delegateCount++,0,n):q.push(n),p.event.global[l]=!0}a=null},global:{},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,q,r=p.hasData(a)&&p._data(a);if(!r||!(m=r.events))return;b=p.trim(_(b||"")).split(" ");for(f=0;f<b.length;f++){g=W.exec(b[f])||[],h=i=g[1],j=g[2];if(!h){for(h in m)p.event.remove(a,h+b[f],c,d,!0);continue}n=p.event.special[h]||{},h=(d?n.delegateType:n.bindType)||h,o=m[h]||[],k=o.length,j=j?new RegExp("(^|\\.)"+j.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(l=0;l<o.length;l++)q=o[l],(e||i===q.origType)&&(!c||c.guid===q.guid)&&(!j||j.test(q.namespace))&&(!d||d===q.selector||d==="**"&&q.selector)&&(o.splice(l--,1),q.selector&&o.delegateCount--,n.remove&&n.remove.call(a,q));o.length===0&&k!==o.length&&((!n.teardown||n.teardown.call(a,j,r.handle)===!1)&&p.removeEvent(a,h,r.handle),delete m[h])}p.isEmptyObject(m)&&(delete r.handle,p.removeData(a,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,f,g){if(!f||f.nodeType!==3&&f.nodeType!==8){var h,i,j,k,l,m,n,o,q,r,s=c.type||c,t=[];if($.test(s+p.event.triggered))return;s.indexOf("!")>=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;j<q.length&&!c.isPropagationStopped();j++)k=q[j][0],c.type=q[j][1],o=(p._data(k,"events")||{})[c.type]&&p._data(k,"handle"),o&&o.apply(k,d),o=m&&k[m],o&&p.acceptData(k)&&o.apply(k,d)===!1&&c.preventDefault();return c.type=s,!g&&!c.isDefaultPrevented()&&(!n._default||n._default.apply(f.ownerDocument,d)===!1)&&(s!=="click"||!p.nodeName(f,"a"))&&p.acceptData(f)&&m&&f[s]&&(s!=="focus"&&s!=="blur"||c.target.offsetWidth!==0)&&!p.isWindow(f)&&(l=f[m],l&&(f[m]=null),p.event.triggered=s,f[s](),p.event.triggered=b,l&&(f[m]=l)),c.result}return},dispatch:function(c){c=p.event.fix(c||a.event);var d,e,f,g,h,i,j,k,l,m,n,o=(p._data(this,"events")||{})[c.type]||[],q=o.delegateCount,r=[].slice.call(arguments),s=!c.exclusive&&!c.namespace,t=p.event.special[c.type]||{},u=[];r[0]=c,c.delegateTarget=this;if(t.preDispatch&&t.preDispatch.call(this,c)===!1)return;if(q&&(!c.button||c.type!=="click")){g=p(this),g.context=this;for(f=c.target;f!=this;f=f.parentNode||this)if(f.disabled!==!0||c.type!=="click"){i={},k=[],g[0]=f;for(d=0;d<q;d++)l=o[d],m=l.selector,i[m]===b&&(i[m]=g.is(m)),i[m]&&k.push(l);k.length&&u.push({elem:f,matches:k})}}o.length>q&&u.push({elem:this,matches:o.slice(q)});for(d=0;d<u.length&&!c.isPropagationStopped();d++){j=u[d],c.currentTarget=j.elem;for(e=0;e<j.matches.length&&!c.isImmediatePropagationStopped();e++){l=j.matches[e];if(s||!c.namespace&&!l.namespace||c.namespace_re&&c.namespace_re.test(l.namespace))c.data=l.data,c.handleObj=l,h=((p.event.special[l.origType]||{}).handle||l.handler).apply(j.elem,r),h!==b&&(c.result=h,h===!1&&(c.preventDefault(),c.stopPropagation()))}}return t.postDispatch&&t.postDispatch.call(this,c),c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,f,g,h=c.button,i=c.fromElement;return a.pageX==null&&c.clientX!=null&&(d=a.target.ownerDocument||e,f=d.documentElement,g=d.body,a.pageX=c.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=c.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?c.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0),a}},fix:function(a){if(a[p.expando])return a;var b,c,d=a,f=p.event.fixHooks[a.type]||{},g=f.props?this.props.concat(f.props):this.props;a=p.Event(d);for(b=g.length;b;)c=g[--b],a[c]=d[c];return a.target||(a.target=d.srcElement||e),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,f.filter?f.filter(a,d):a},special:{ready:{setup:p.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){p.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=p.extend(new p.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?p.event.trigger(e,null,b):p.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},p.event.handle=p.event.dispatch,p.removeEvent=e.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]=="undefined"&&(a[d]=null),a.detachEvent(d,c))},p.Event=function(a,b){if(this instanceof p.Event)a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?bb:ba):this.type=a,b&&p.extend(this,b),this.timeStamp=a&&a.timeStamp||p.now(),this[p.expando]=!0;else return new p.Event(a,b)},p.Event.prototype={preventDefault:function(){this.isDefaultPrevented=bb;var a=this.originalEvent;if(!a)return;a.preventDefault?a.preventDefault():a.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=bb;var a=this.originalEvent;if(!a)return;a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=bb,this.stopPropagation()},isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba},p.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){p.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj,g=f.selector;if(!e||e!==d&&!p.contains(d,e))a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b;return c}}}),p.support.submitBubbles||(p.event.special.submit={setup:function(){if(p.nodeName(this,"form"))return!1;p.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=p.nodeName(c,"input")||p.nodeName(c,"button")?c.form:b;d&&!p._data(d,"_submit_attached")&&(p.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),p._data(d,"_submit_attached",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&p.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(p.nodeName(this,"form"))return!1;p.event.remove(this,"._submit")}}),p.support.changeBubbles||(p.event.special.change={setup:function(){if(V.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")p.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),p.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),p.event.simulate("change",this,a,!0)});return!1}p.event.add(this,"beforeactivate._change",function(a){var b=a.target;V.test(b.nodeName)&&!p._data(b,"_change_attached")&&(p.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&p.event.simulate("change",this.parentNode,a,!0)}),p._data(b,"_change_attached",!0))})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){return p.event.remove(this,"._change"),V.test(this.nodeName)}}),p.support.focusinBubbles||p.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){p.event.simulate(b,a.target,p.event.fix(a),!0)};p.event.special[b]={setup:function(){c++===0&&e.addEventListener(a,d,!0)},teardown:function(){--c===0&&e.removeEventListener(a,d,!0)}}}),p.fn.extend({on:function(a,c,d,e,f){var g,h;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(h in a)this.on(h,c,d,a[h],f);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=ba;else if(!e)return this;return f===1&&(g=e,e=function(a){return p().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=p.guid++)),this.each(function(){p.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){var e,f;if(a&&a.preventDefault&&a.handleObj)return e=a.handleObj,p(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this;if(typeof a=="object"){for(f in a)this.off(f,c,a[f]);return this}if(c===!1||typeof c=="function")d=c,c=b;return d===!1&&(d=ba),this.each(function(){p.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){return p(this.context).on(a,this.selector,b,c),this},die:function(a,b){return p(this.context).off(a,this.selector||"**",b),this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a||"**",c)},trigger:function(a,b){return this.each(function(){p.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return p.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||p.guid++,d=0,e=function(c){var e=(p._data(this,"lastToggle"+a.guid)||0)%d;return p._data(this,"lastToggle"+a.guid,e+1),c.preventDefault(),b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),p.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){p.fn[b]=function(a,c){return c==null&&(c=a,a=null),arguments.length>0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bd(a,b,c,d){var e=0,f=b.length;for(;e<f;e++)Z(a,b[e],c,d)}function be(a,b,c,d,e,f){var g,h=$.setFilters[b.toLowerCase()];return h||Z.error(b),(a||!(g=e))&&bd(a||"*",d,g=[],e),g.length>0?h(g,c,f):[]}function bf(a,c,d,e,f){var g,h,i,j,k,l,m,n,p=0,q=f.length,s=L.POS,t=new RegExp("^"+s.source+"(?!"+r+")","i"),u=function(){var a=1,c=arguments.length-2;for(;a<c;a++)arguments[a]===b&&(g[a]=b)};for(;p<q;p++){s.exec(""),a=f[p],j=[],i=0,k=e;while(g=s.exec(a)){n=s.lastIndex=g.index+g[0].length;if(n>i){m=a.slice(i,g.index),i=n,l=[c],B.test(m)&&(k&&(l=k),k=e);if(h=H.test(m))m=m.slice(0,-5).replace(B,"$&*");g.length>1&&g[0].replace(t,u),k=be(m,g[1],g[2],l,k,h)}}k?(j=j.concat(k),(m=a.slice(i))&&m!==")"?B.test(m)?bd(m,j,d,e):Z(m,c,d,e?e.concat(k):k):o.apply(d,j)):Z(a,c,d,e)}return q===1?d:Z.uniqueSort(d)}function bg(a,b,c){var d,e,f,g=[],i=0,j=D.exec(a),k=!j.pop()&&!j.pop(),l=k&&a.match(C)||[""],m=$.preFilter,n=$.filter,o=!c&&b!==h;for(;(e=l[i])!=null&&k;i++){g.push(d=[]),o&&(e=" "+e);while(e){k=!1;if(j=B.exec(e))e=e.slice(j[0].length),k=d.push({part:j.pop().replace(A," "),captures:j});for(f in n)(j=L[f].exec(e))&&(!m[f]||(j=m[f](j,b,c)))&&(e=e.slice(j.shift().length),k=d.push({part:f,captures:j}));if(!k)break}}return k||Z.error(a),g}function bh(a,b,e){var f=b.dir,g=m++;return a||(a=function(a){return a===e}),b.first?function(b,c){while(b=b[f])if(b.nodeType===1)return a(b,c)&&b}:function(b,e){var h,i=g+"."+d,j=i+"."+c;while(b=b[f])if(b.nodeType===1){if((h=b[q])===j)return b.sizset;if(typeof h=="string"&&h.indexOf(i)===0){if(b.sizset)return b}else{b[q]=j;if(a(b,e))return b.sizset=!0,b;b.sizset=!1}}}}function bi(a,b){return a?function(c,d){var e=b(c,d);return e&&a(e===!0?c:e,d)}:b}function bj(a,b,c){var d,e,f=0;for(;d=a[f];f++)$.relative[d.part]?e=bh(e,$.relative[d.part],b):(d.captures.push(b,c),e=bi(e,$.filter[d.part].apply(null,d.captures)));return e}function bk(a){return function(b,c){var d,e=0;for(;d=a[e];e++)if(d(b,c))return!0;return!1}}var c,d,e,f,g,h=a.document,i=h.documentElement,j="undefined",k=!1,l=!0,m=0,n=[].slice,o=[].push,q=("sizcache"+Math.random()).replace(".",""),r="[\\x20\\t\\r\\n\\f]",s="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",t=s.replace("w","w#"),u="([*^$|!~]?=)",v="\\["+r+"*("+s+")"+r+"*(?:"+u+r+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+t+")|)|)"+r+"*\\]",w=":("+s+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",x=":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",y=r+"*([\\x20\\t\\r\\n\\f>+~])"+r+"*",z="(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|"+v+"|"+w.replace(2,7)+"|[^\\\\(),])+",A=new RegExp("^"+r+"+|((?:^|[^\\\\])(?:\\\\.)*)"+r+"+$","g"),B=new RegExp("^"+y),C=new RegExp(z+"?(?="+r+"*,|$)","g"),D=new RegExp("^(?:(?!,)(?:(?:^|,)"+r+"*"+z+")*?|"+r+"*(.*?))(\\)|$)"),E=new RegExp(z.slice(19,-6)+"\\x20\\t\\r\\n\\f>+~])+|"+y,"g"),F=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,G=/[\x20\t\r\n\f]*[+~]/,H=/:not\($/,I=/h\d/i,J=/input|select|textarea|button/i,K=/\\(?!\\)/g,L={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),NAME:new RegExp("^\\[name=['\"]?("+s+")['\"]?\\]"),TAG:new RegExp("^("+s.replace("[-","[-\\*")+")"),ATTR:new RegExp("^"+v),PSEUDO:new RegExp("^"+w),CHILD:new RegExp("^:(only|nth|last|first)-child(?:\\("+r+"*(even|odd|(([+-]|)(\\d*)n|)"+r+"*(?:([+-]|)"+r+"*(\\d+)|))"+r+"*\\)|)","i"),POS:new RegExp(x,"ig"),needsContext:new RegExp("^"+r+"*[>+~]|"+x,"i")},M={},N=[],O={},P=[],Q=function(a){return a.sizzleFilter=!0,a},R=function(a){return function(b){return b.nodeName.toLowerCase()==="input"&&b.type===a}},S=function(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}},T=function(a){var b=!1,c=h.createElement("div");try{b=a(c)}catch(d){}return c=null,b},U=T(function(a){a.innerHTML="<select></select>";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),V=T(function(a){a.id=q+0,a.innerHTML="<a name='"+q+"'></a><div name='"+q+"'></div>",i.insertBefore(a,i.firstChild);var b=h.getElementsByName&&h.getElementsByName(q).length===2+h.getElementsByName(q+0).length;return g=!h.getElementById(q),i.removeChild(a),b}),W=T(function(a){return a.appendChild(h.createComment("")),a.getElementsByTagName("*").length===0}),X=T(function(a){return a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!==j&&a.firstChild.getAttribute("href")==="#"}),Y=T(function(a){return a.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!a.getElementsByClassName||a.getElementsByClassName("e").length===0?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length!==1)}),Z=function(a,b,c,d){c=c||[],b=b||h;var e,f,g,i,j=b.nodeType;if(j!==1&&j!==9)return[];if(!a||typeof a!="string")return c;g=ba(b);if(!g&&!d)if(e=F.exec(a))if(i=e[1]){if(j===9){f=b.getElementById(i);if(!f||!f.parentNode)return c;if(f.id===i)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(i))&&bb(b,f)&&f.id===i)return c.push(f),c}else{if(e[2])return o.apply(c,n.call(b.getElementsByTagName(a),0)),c;if((i=e[3])&&Y&&b.getElementsByClassName)return o.apply(c,n.call(b.getElementsByClassName(i),0)),c}return bm(a,b,c,d,g)},$=Z.selectors={cacheLength:50,match:L,order:["ID","TAG"],attrHandle:{},createPseudo:Q,find:{ID:g?function(a,b,c){if(typeof b.getElementById!==j&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==j&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==j&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:W?function(a,b){if(typeof b.getElementsByTagName!==j)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(K,""),a[3]=(a[4]||a[5]||"").replace(K,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||Z.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&Z.error(a[0]),a},PSEUDO:function(a){var b,c=a[4];return L.CHILD.test(a[0])?null:(c&&(b=D.exec(c))&&b.pop()&&(a[0]=a[0].slice(0,b[0].length-c.length-1),c=b[0].slice(0,-1)),a.splice(2,3,c||a[3]),a)}},filter:{ID:g?function(a){return a=a.replace(K,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(K,""),function(b){var c=typeof b.getAttributeNode!==j&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(K,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=M[a];return b||(b=M[a]=new RegExp("(^|"+r+")"+a+"("+r+"|$)"),N.push(a),N.length>$.cacheLength&&delete M[N.shift()]),function(a){return b.test(a.className||typeof a.getAttribute!==j&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return b?function(d){var e=Z.attr(d,a),f=e+"";if(e==null)return b==="!=";switch(b){case"=":return f===c;case"!=":return f!==c;case"^=":return c&&f.indexOf(c)===0;case"*=":return c&&f.indexOf(c)>-1;case"$=":return c&&f.substr(f.length-c.length)===c;case"~=":return(" "+f+" ").indexOf(c)>-1;case"|=":return f===c||f.substr(0,c.length+1)===c+"-"}}:function(b){return Z.attr(b,a)!=null}},CHILD:function(a,b,c,d){if(a==="nth"){var e=m++;return function(a){var b,f,g=0,h=a;if(c===1&&d===0)return!0;b=a.parentNode;if(b&&(b[q]!==e||!a.sizset)){for(h=b.firstChild;h;h=h.nextSibling)if(h.nodeType===1){h.sizset=++g;if(h===a)break}b[q]=e}return f=a.sizset-d,c===0?f===0:f%c===0&&f/c>=0}}return function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b,c,d){var e=$.pseudos[a]||$.pseudos[a.toLowerCase()];return e||Z.error("unsupported pseudo: "+a),e.sizzleFilter?e(b,c,d):e}},pseudos:{not:Q(function(a,b,c){var d=bl(a.replace(A,"$1"),b,c);return function(a){return!d(a)}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!$.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},contains:Q(function(a){return function(b){return(b.textContent||b.innerText||bc(b)).indexOf(a)>-1}}),has:Q(function(a){return function(b){return Z(a,b).length>0}}),header:function(a){return I.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:R("radio"),checkbox:R("checkbox"),file:R("file"),password:R("password"),image:R("image"),submit:S("submit"),reset:S("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return J.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b,c){return c?a.slice(1):[a[0]]},last:function(a,b,c){var d=a.pop();return c?a:[d]},even:function(a,b,c){var d=[],e=c?1:0,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},odd:function(a,b,c){var d=[],e=c?0:1,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},lt:function(a,b,c){return c?a.slice(+b):a.slice(0,+b)},gt:function(a,b,c){return c?a.slice(0,+b+1):a.slice(+b+1)},eq:function(a,b,c){var d=a.splice(+b,1);return c?a:d}}};$.setFilters.nth=$.setFilters.eq,$.filters=$.pseudos,X||($.attrHandle={href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}}),V&&($.order.push("NAME"),$.find.NAME=function(a,b){if(typeof b.getElementsByName!==j)return b.getElementsByName(a)}),Y&&($.order.splice(1,0,"CLASS"),$.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!==j&&!c)return b.getElementsByClassName(a)});try{n.call(i.childNodes,0)[0].nodeType}catch(_){n=function(a){var b,c=[];for(;b=this[a];a++)c.push(b);return c}}var ba=Z.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?b.nodeName!=="HTML":!1},bb=Z.contains=i.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains?function(a,b){var c=a.nodeType===9?a.documentElement:a,d=b.parentNode;return a===d||!!(d&&d.nodeType===1&&c.contains&&c.contains(d))}:function(a,b){while(b=b.parentNode)if(b===a)return!0;return!1},bc=Z.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(e===1||e===9||e===11){if(typeof a.textContent=="string")return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=bc(a)}else if(e===3||e===4)return a.nodeValue}else for(;b=a[d];d++)c+=bc(b);return c};Z.attr=function(a,b){var c,d=ba(a);return d||(b=b.toLowerCase()),$.attrHandle[b]?$.attrHandle[b](a):U||d?a.getAttribute(b):(c=a.getAttributeNode(b),c?typeof a[b]=="boolean"?a[b]?b:null:c.specified?c.value:null:null)},Z.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},[0,0].sort(function(){return l=0}),i.compareDocumentPosition?e=function(a,b){return a===b?(k=!0,0):(!a.compareDocumentPosition||!b.compareDocumentPosition?a.compareDocumentPosition:a.compareDocumentPosition(b)&4)?-1:1}:(e=function(a,b){if(a===b)return k=!0,0;if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],g=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return f(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)g.unshift(j),j=j.parentNode;c=e.length,d=g.length;for(var l=0;l<c&&l<d;l++)if(e[l]!==g[l])return f(e[l],g[l]);return l===c?f(a,g[l],-1):f(e[l],b,1)},f=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),Z.uniqueSort=function(a){var b,c=1;if(e){k=l,a.sort(e);if(k)for(;b=a[c];c++)b===a[c-1]&&a.splice(c--,1)}return a};var bl=Z.compile=function(a,b,c){var d,e,f,g=O[a];if(g&&g.context===b)return g;e=bg(a,b,c);for(f=0;d=e[f];f++)e[f]=bj(d,b,c);return g=O[a]=bk(e),g.context=b,g.runs=g.dirruns=0,P.push(a),P.length>$.cacheLength&&delete O[P.shift()],g};Z.matches=function(a,b){return Z(a,null,null,b)},Z.matchesSelector=function(a,b){return Z(b,null,null,[a]).length>0};var bm=function(a,b,e,f,g){a=a.replace(A,"$1");var h,i,j,k,l,m,p,q,r,s=a.match(C),t=a.match(E),u=b.nodeType;if(L.POS.test(a))return bf(a,b,e,f,s);if(f)h=n.call(f,0);else if(s&&s.length===1){if(t.length>1&&u===9&&!g&&(s=L.ID.exec(t[0]))){b=$.find.ID(s[1],b,g)[0];if(!b)return e;a=a.slice(t.shift().length)}q=(s=G.exec(t[0]))&&!s.index&&b.parentNode||b,r=t.pop(),m=r.split(":not")[0];for(j=0,k=$.order.length;j<k;j++){p=$.order[j];if(s=L[p].exec(m)){h=$.find[p]((s[1]||"").replace(K,""),q,g);if(h==null)continue;m===r&&(a=a.slice(0,a.length-r.length)+m.replace(L[p],""),a||o.apply(e,n.call(h,0)));break}}}if(a){i=bl(a,b,g),d=i.dirruns++,h==null&&(h=$.find.TAG("*",G.test(a)&&b.parentNode||b));for(j=0;l=h[j];j++)c=i.runs++,i(l,b)&&e.push(l)}return e};h.querySelectorAll&&function(){var a,b=bm,c=/'|\\/g,d=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,e=[],f=[":active"],g=i.matchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||i.msMatchesSelector;T(function(a){a.innerHTML="<select><option selected></option></select>",a.querySelectorAll("[selected]").length||e.push("\\["+r+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),T(function(a){a.innerHTML="<p test=''></p>",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+r+"*(?:\"\"|'')"),a.innerHTML="<input type='hidden'>",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=e.length&&new RegExp(e.join("|")),bm=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a)))if(d.nodeType===9)try{return o.apply(f,n.call(d.querySelectorAll(a),0)),f}catch(i){}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d.getAttribute("id"),k=j||q,l=G.test(a)&&d.parentNode||d;j?k=k.replace(c,"\\$&"):d.setAttribute("id",k);try{return o.apply(f,n.call(l.querySelectorAll(a.replace(C,"[id='"+k+"'] $&")),0)),f}catch(i){}finally{j||d.removeAttribute("id")}}return b(a,d,f,g,h)},g&&(T(function(b){a=g.call(b,"div");try{g.call(b,"[test!='']:sizzle"),f.push($.match.PSEUDO)}catch(c){}}),f=new RegExp(f.join("|")),Z.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!ba(b)&&!f.test(c)&&(!e||!e.test(c)))try{var h=g.call(b,c);if(h||a||b.document&&b.document.nodeType!==11)return h}catch(i){}return Z(c,null,null,[b]).length>0})}(),Z.attr=p.attr,p.find=Z,p.expr=Z.selectors,p.expr[":"]=p.expr.pseudos,p.unique=Z.uniqueSort,p.text=Z.getText,p.isXMLDoc=Z.isXML,p.contains=Z.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b<c;b++)if(p.contains(h[b],this))return!0});g=this.pushStack("","find",a);for(b=0,c=this.length;b<c;b++){d=g.length,p.find(a,this[b],g);if(b>0)for(e=d;e<g.length;e++)for(f=0;f<d;f++)if(g[f]===g[e]){g.splice(e--,1);break}}return g},has:function(a){var b,c=p(a,this),d=c.length;return this.filter(function(){for(b=0;b<d;b++)if(p.contains(this,c[b]))return!0})},not:function(a){return this.pushStack(bj(this,a,!1),"not",a)},filter:function(a){return this.pushStack(bj(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?bf.test(a)?p(a,this.context).index(this[0])>=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d<e;d++){c=this[d];while(c&&c.ownerDocument&&c!==b&&c.nodeType!==11){if(g?g.index(c)>-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/<tbody/i,br=/<|&#?\w+;/,bs=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,bu=new RegExp("<(?:"+bl+")[\\s/>]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,bz={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X<div>","</div>"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return bh(this[0])?this.length?this.pushStack(p(p.isFunction(a)?a():a),"replaceWith",a):this:p.isFunction(a)?this.each(function(b){var c=p(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=p(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;p(this).remove(),b?p(b).before(a):p(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],l=this.length;if(!p.support.checkClone&&l>1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i<l;i++)d.call(c&&p.nodeName(this[i],"table")?bC(this[i],"tbody"):this[i],i===h?g:p.clone(g,!0,!0))}g=f=null,k.length&&p.each(k,function(a,b){b.src?p.ajax?p.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):p.error("no ajax"):p.globalEval((b.text||b.textContent||b.innerHTML||"").replace(by,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),p.buildFragment=function(a,c,d){var f,g,h,i=a[0];return c=c||e,c=(c[0]||c).ownerDocument||c[0]||c,typeof c.createDocumentFragment=="undefined"&&(c=e),a.length===1&&typeof i=="string"&&i.length<512&&c===e&&i.charAt(0)==="<"&&!bt.test(i)&&(p.support.checkClone||!bw.test(i))&&(p.support.html5Clone||!bu.test(i))&&(g=!0,f=p.fragments[i],h=f!==b),f||(f=c.createDocumentFragment(),p.clean(a,c,f,d),g&&(p.fragments[i]=h&&f)),{fragment:f,cacheable:g}},p.fragments={},p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){p.fn[a]=function(c){var d,e=0,f=[],g=p(c),h=g.length,i=this.length===1&&this[0].parentNode;if((i==null||i&&i.nodeType===11&&i.childNodes.length===1)&&h===1)return g[b](this[0]),this;for(;e<h;e++)d=(e>0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=0,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(g=b===e&&bA;(h=a[s])!=null;s++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{g=g||bk(b),l=l||g.appendChild(b.createElement("div")),h=h.replace(bo,"<$1></$2>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]==="<table>"&&!m?l.childNodes:[];for(f=n.length-1;f>=0;--f)p.nodeName(n[f],"tbody")&&!n[f].childNodes.length&&n[f].parentNode.removeChild(n[f])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l=g.lastChild}h.nodeType?t.push(h):t=p.merge(t,h)}l&&(g.removeChild(l),h=l=g=null);if(!p.support.appendChecked)for(s=0;(h=t[s])!=null;s++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(s=0;(h=t[s])!=null;s++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[s+1,0].concat(r)),s+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^margin/,bO=new RegExp("^("+q+")(.*)$","i"),bP=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bQ=new RegExp("^([-+])=("+q+")","i"),bR={},bS={position:"absolute",visibility:"hidden",display:"block"},bT={letterSpacing:0,fontWeight:400,lineHeight:1},bU=["Top","Right","Bottom","Left"],bV=["Webkit","O","Moz","ms"],bW=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return bZ(this,!0)},hide:function(){return bZ(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bW.apply(this,arguments):this.each(function(){(c?a:bY(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bX(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bQ.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bX(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bT&&(f=bT[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],c===""&&!p.contains(a.ownerDocument.documentElement,a)&&(c=p.style(a,b)),bP.test(c)&&bN.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bP.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0||bH(a,"display")!=="none"?ca(a,b,d):p.swap(a,bS,function(){return ca(a,b,d)})},set:function(a,c,d){return b$(a,c,d?b_(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bP.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bU[d]+b]=e[d]||e[d-2]||e[0];return f}},bN.test(a)||(p.cssHooks[a+b].set=b$)});var cc=/%20/g,cd=/\[\]$/,ce=/\r?\n/g,cf=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,cg=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||cg.test(this.nodeName)||cf.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(ce,"\r\n")}}):{name:b.name,value:c.replace(ce,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ch(d,a[d],c,f);return e.join("&").replace(cc,"+")};var ci,cj,ck=/#.*$/,cl=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cm=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,cn=/^(?:GET|HEAD)$/,co=/^\/\//,cp=/\?/,cq=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,cr=/([?&])_=[^&]*/,cs=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,ct=p.fn.load,cu={},cv={},cw=["*/"]+["*"];try{ci=f.href}catch(cx){ci=e.createElement("a"),ci.href="",ci=ci.href}cj=cs.exec(ci.toLowerCase())||[],p.fn.load=function(a,c,d){if(typeof a!="string"&&ct)return ct.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),p.isFunction(c)?(d=c,c=b):typeof c=="object"&&(f="POST"),p.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?p("<div>").append(a.replace(cq,"")).find(e):a)}),this},p.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){p.fn[b]=function(a){return this.on(b,a)}}),p.each(["get","post"],function(a,c){p[c]=function(a,d,e,f){return p.isFunction(d)&&(f=f||e,e=d,d=b),p.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),p.extend({getScript:function(a,c){return p.get(a,b,c,"script")},getJSON:function(a,b,c){return p.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?cA(a,p.ajaxSettings):(b=a,a=p.ajaxSettings),cA(a,b),a},ajaxSettings:{url:ci,isLocal:cm.test(cj[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":cw},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":p.parseJSON,"text xml":p.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:cy(cu),ajaxTransport:cy(cv),ajax:function(a,c){function y(a,c,f,i){var k,s,t,u,w,y=c;if(v===2)return;v=2,h&&clearTimeout(h),g=b,e=i||"",x.readyState=a>0?4:0,f&&(u=cB(l,x,f));if(a>=200&&a<300||a===304)l.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(p.lastModified[d]=w),w=x.getResponseHeader("Etag"),w&&(p.etag[d]=w)),a===304?(y="notmodified",k=!0):(k=cC(l,u),y=k.state,s=k.data,t=k.error,k=!t);else{t=y;if(!y||a)y="error",a<0&&(a=0)}x.status=a,x.statusText=""+(c||y),k?o.resolveWith(m,[s,y,x]):o.rejectWith(m,[x,y,t]),x.statusCode(r),r=b,j&&n.trigger("ajax"+(k?"Success":"Error"),[x,l,k?s:t]),q.fireWith(m,[x,y]),j&&(n.trigger("ajaxComplete",[x,l]),--p.active||p.event.trigger("ajaxStop"))}typeof a=="object"&&(c=a,a=b),c=c||{};var d,e,f,g,h,i,j,k,l=p.ajaxSetup({},c),m=l.context||l,n=m!==l&&(m.nodeType||m instanceof p)?p(m):p.event,o=p.Deferred(),q=p.Callbacks("once memory"),r=l.statusCode||{},t={},u={},v=0,w="canceled",x={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=u[c]=u[c]||a,t[a]=b}return this},getAllResponseHeaders:function(){return v===2?e:null},getResponseHeader:function(a){var c;if(v===2){if(!f){f={};while(c=cl.exec(e))f[c[1].toLowerCase()]=c[2]}c=f[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(l.mimeType=a),this},abort:function(a){return a=a||w,g&&g.abort(a),y(0,a),this}};o.promise(x),x.success=x.done,x.error=x.fail,x.complete=q.add,x.statusCode=function(a){if(a){var b;if(v<2)for(b in a)r[b]=[r[b],a[b]];else b=a[x.status],x.always(b)}return this},l.url=((a||l.url)+"").replace(ck,"").replace(co,cj[1]+"//"),l.dataTypes=p.trim(l.dataType||"*").toLowerCase().split(s),l.crossDomain==null&&(i=cs.exec(l.url.toLowerCase()),l.crossDomain=!(!i||i[1]==cj[1]&&i[2]==cj[2]&&(i[3]||(i[1]==="http:"?80:443))==(cj[3]||(cj[1]==="http:"?80:443)))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=p.param(l.data,l.traditional)),cz(cu,l,c,x);if(v===2)return x;j=l.global,l.type=l.type.toUpperCase(),l.hasContent=!cn.test(l.type),j&&p.active++===0&&p.event.trigger("ajaxStart");if(!l.hasContent){l.data&&(l.url+=(cp.test(l.url)?"&":"?")+l.data,delete l.data),d=l.url;if(l.cache===!1){var z=p.now(),A=l.url.replace(cr,"$1_="+z);l.url=A+(A===l.url?(cp.test(l.url)?"&":"?")+"_="+z:"")}}(l.data&&l.hasContent&&l.contentType!==!1||c.contentType)&&x.setRequestHeader("Content-Type",l.contentType),l.ifModified&&(d=d||l.url,p.lastModified[d]&&x.setRequestHeader("If-Modified-Since",p.lastModified[d]),p.etag[d]&&x.setRequestHeader("If-None-Match",p.etag[d])),x.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+cw+"; q=0.01":""):l.accepts["*"]);for(k in l.headers)x.setRequestHeader(k,l.headers[k]);if(!l.beforeSend||l.beforeSend.call(m,x,l)!==!1&&v!==2){w="abort";for(k in{success:1,error:1,complete:1})x[k](l[k]);g=cz(cv,l,c,x);if(!g)y(-1,"No Transport");else{x.readyState=1,j&&n.trigger("ajaxSend",[x,l]),l.async&&l.timeout>0&&(h=setTimeout(function(){x.abort("timeout")},l.timeout));try{v=1,g.send(t,y)}catch(B){if(v<2)y(-1,B);else throw B}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var cD=[],cE=/\?/,cF=/(=)\?(?=&|$)|\?\?/,cG=p.now();p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=cD.pop()||p.expando+"_"+cG++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&cF.test(j),m=k&&!l&&typeof i=="string"&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&cF.test(i);if(c.dataTypes[0]==="jsonp"||l||m)return f=c.jsonpCallback=p.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(cF,"$1"+f):m?c.data=i.replace(cF,"$1"+f):k&&(c.url+=(cE.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||p.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,cD.push(f)),h&&p.isFunction(g)&&g(h[0]),h=g=b}),"script"}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),p.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=e.head||e.getElementsByTagName("head")[0]||e.documentElement;return{send:function(f,g){c=e.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||g(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var cH,cI=a.ActiveXObject?function(){for(var a in cH)cH[a](0,1)}:!1,cJ=0;p.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cK()||cL()}:cK,function(a){p.extend(p.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(p.ajaxSettings.xhr()),p.support.ajax&&p.ajaxTransport(function(c){if(!c.crossDomain||p.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async);if(c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||i.readyState===4)){d=b,g&&(i.onreadystatechange=p.noop,cI&&delete cH[g]);if(e)i.readyState!==4&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}!h&&c.isLocal&&!c.crossDomain?h=l.text?200:404:h===1223&&(h=204)}}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?i.readyState===4?setTimeout(d,0):(g=++cJ,cI&&(cH||(cH={},p(a).unload(cI)),cH[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var cM,cN,cO=/^(?:toggle|show|hide)$/,cP=new RegExp("^(?:([-+])=|)("+q+")([a-z%]*)$","i"),cQ=/queueHooks$/,cR=[cX],cS={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=cP.exec(b),h=f.cur(),i=+h||0,j=1;if(g){c=+g[2],d=g[3]||(p.cssNumber[a]?"":"px");if(d!=="px"&&i){i=p.css(f.elem,a,!0)||c||1;do e=j=j||".5",i=i/j,p.style(f.elem,a,i+d),j=f.cur()/h;while(j!==1&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};p.Animation=p.extend(cV,{tweener:function(a,b){p.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");var c,d=0,e=a.length;for(;d<e;d++)c=a[d],cS[c]=cS[c]||[],cS[c].unshift(b)},prefilter:function(a,b){b?cR.unshift(a):cR.push(a)}}),p.Tween=cY,cY.prototype={constructor:cY,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(p.cssNumber[c]?"":"px")},cur:function(){var a=cY.propHooks[this.prop];return a&&a.get?a.get(this):cY.propHooks._default.get(this)},run:function(a){var b,c=cY.propHooks[this.prop];return this.pos=b=p.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration),this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):cY.propHooks._default.set(this),this}},cY.prototype.init.prototype=cY.prototype,cY.propHooks={_default:{get:function(a){var b;return a.elem[a.prop]==null||!!a.elem.style&&a.elem.style[a.prop]!=null?(b=p.css(a.elem,a.prop,!1,""),!b||b==="auto"?0:b):a.elem[a.prop]},set:function(a){p.fx.step[a.prop]?p.fx.step[a.prop](a):a.elem.style&&(a.elem.style[p.cssProps[a.prop]]!=null||p.cssHooks[a.prop])?p.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},cY.propHooks.scrollTop=cY.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},p.each(["toggle","show","hide"],function(a,b){var c=p.fn[b];p.fn[b]=function(d,e,f){return d==null||typeof d=="boolean"||!a&&p.isFunction(d)&&p.isFunction(e)?c.apply(this,arguments):this.animate(cZ(b,!0),d,e,f)}}),p.fn.extend({fadeTo:function(a,b,c,d){return this.filter(bY).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=p.isEmptyObject(a),f=p.speed(b,c,d),g=function(){var b=cV(this,p.extend({},a),f);e&&b.stop(!0)};return e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=a!=null&&a+"queueHooks",f=p.timers,g=p._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&cQ.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&p.dequeue(this,a)})}}),p.each({slideDown:cZ("show"),slideUp:cZ("hide"),slideToggle:cZ("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){p.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),p.speed=function(a,b,c){var d=a&&typeof a=="object"?p.extend({},a):{complete:c||!c&&b||p.isFunction(a)&&a,duration:a,easing:c&&b||b&&!p.isFunction(b)&&b};d.duration=p.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in p.fx.speeds?p.fx.speeds[d.duration]:p.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(){p.isFunction(d.old)&&d.old.call(this),d.queue&&p.dequeue(this,d.queue)},d},p.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},p.timers=[],p.fx=cY.prototype.init,p.fx.tick=function(){var a,b=p.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||p.fx.stop()},p.fx.timer=function(a){a()&&p.timers.push(a)&&!cN&&(cN=setInterval(p.fx.tick,p.fx.interval))},p.fx.interval=13,p.fx.stop=function(){clearInterval(cN),cN=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fx.step={},p.expr&&p.expr.filters&&(p.expr.filters.animated=function(a){return p.grep(p.timers,function(b){return a===b.elem}).length});var c$=/^(?:body|html)$/i;p.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){p.offset.setOffset(this,a,b)});var c,d,e,f,g,h,i,j,k,l,m=this[0],n=m&&m.ownerDocument;if(!n)return;return(e=n.body)===m?p.offset.bodyOffset(m):(d=n.documentElement,p.contains(d,m)?(c=m.getBoundingClientRect(),f=c_(n),g=d.clientTop||e.clientTop||0,h=d.clientLeft||e.clientLeft||0,i=f.pageYOffset||d.scrollTop,j=f.pageXOffset||d.scrollLeft,k=c.top+i-g,l=c.left+j-h,{top:k,left:l}):{top:0,left:0})},p.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return p.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(p.css(a,"marginTop"))||0,c+=parseFloat(p.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=p.css(a,"position");d==="static"&&(a.style.position="relative");var e=p(a),f=e.offset(),g=p.css(a,"top"),h=p.css(a,"left"),i=(d==="absolute"||d==="fixed")&&p.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),p.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},p.fn.extend({position:function(){if(!this[0])return;var a=this[0],b=this.offsetParent(),c=this.offset(),d=c$.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(p.css(a,"marginTop"))||0,c.left-=parseFloat(p.css(a,"marginLeft"))||0,d.top+=parseFloat(p.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(p.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||e.body;while(a&&!c$.test(a.nodeName)&&p.css(a,"position")==="static")a=a.offsetParent;return a||e.body})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);p.fn[a]=function(e){return p.access(this,function(a,e,f){var g=c_(a);if(f===b)return g?c in g?g[c]:g.document.documentElement[e]:a[e];g?g.scrollTo(d?p(g).scrollLeft():f,d?f:p(g).scrollTop()):a[e]=f},a,e,arguments.length,null)}}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){p.fn[e]=function(e,f){var g=arguments.length&&(d||typeof e!="boolean"),h=d||(e===!0||f===!0?"margin":"border");return p.access(this,function(c,d,e){var f;return p.isWindow(c)?c.document.documentElement["client"+a]:c.nodeType===9?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?p.css(c,d,e,h):p.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=p,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return p})})(window); |
js/lib/modernizr-2.6.1.min.js
1 | /* Modernizr 2.6.1 (Custom Build) | MIT & BSD | ||
---|---|---|---|
2 | * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load | ||
3 | */ | ||
4 | ;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.1",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["­",'<style id="s',h,'">',a,"</style>"].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(['#modernizr:after{content:"',l,'";visibility:hidden}'].join(""),function(b){a=b.offsetHeight>=1}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,i){var j=b(a),l=j.autoCallback;j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2})))}function i(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var j,l,m=this.yepnope.loader;if(e(a))g(a,0,m,0);else if(w(a))for(j=0;j<a.length;j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);else Object(a)===a&&i(a,m)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))}; |
js/lib/underscore.js
1 | // Underscore.js 1.4.2 | ||
---|---|---|---|
2 | // http://underscorejs.org | ||
3 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. | ||
4 | // Underscore may be freely distributed under the MIT license. | ||
5 | |||
6 | (function() { | ||
7 | |||
8 | // Baseline setup | ||
9 | // -------------- | ||
10 | |||
11 | // Establish the root object, `window` in the browser, or `global` on the server. | ||
12 | var root = this; | ||
13 | |||
14 | // Save the previous value of the `_` variable. | ||
15 | var previousUnderscore = root._; | ||
16 | |||
17 | // Establish the object that gets returned to break out of a loop iteration. | ||
18 | var breaker = {}; | ||
19 | |||
20 | // Save bytes in the minified (but not gzipped) version: | ||
21 | var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; | ||
22 | |||
23 | // Create quick reference variables for speed access to core prototypes. | ||
24 | var push = ArrayProto.push, | ||
25 | slice = ArrayProto.slice, | ||
26 | concat = ArrayProto.concat, | ||
27 | unshift = ArrayProto.unshift, | ||
28 | toString = ObjProto.toString, | ||
29 | hasOwnProperty = ObjProto.hasOwnProperty; | ||
30 | |||
31 | // All **ECMAScript 5** native function implementations that we hope to use | ||
32 | // are declared here. | ||
33 | var | ||
34 | nativeForEach = ArrayProto.forEach, | ||
35 | nativeMap = ArrayProto.map, | ||
36 | nativeReduce = ArrayProto.reduce, | ||
37 | nativeReduceRight = ArrayProto.reduceRight, | ||
38 | nativeFilter = ArrayProto.filter, | ||
39 | nativeEvery = ArrayProto.every, | ||
40 | nativeSome = ArrayProto.some, | ||
41 | nativeIndexOf = ArrayProto.indexOf, | ||
42 | nativeLastIndexOf = ArrayProto.lastIndexOf, | ||
43 | nativeIsArray = Array.isArray, | ||
44 | nativeKeys = Object.keys, | ||
45 | nativeBind = FuncProto.bind; | ||
46 | |||
47 | // Create a safe reference to the Underscore object for use below. | ||
48 | var _ = function(obj) { | ||
49 | if (obj instanceof _) return obj; | ||
50 | if (!(this instanceof _)) return new _(obj); | ||
51 | this._wrapped = obj; | ||
52 | }; | ||
53 | |||
54 | // Export the Underscore object for **Node.js**, with | ||
55 | // backwards-compatibility for the old `require()` API. If we're in | ||
56 | // the browser, add `_` as a global object via a string identifier, | ||
57 | // for Closure Compiler "advanced" mode. | ||
58 | if (typeof exports !== 'undefined') { | ||
59 | if (typeof module !== 'undefined' && module.exports) { | ||
60 | exports = module.exports = _; | ||
61 | } | ||
62 | exports._ = _; | ||
63 | } else { | ||
64 | root['_'] = _; | ||
65 | } | ||
66 | |||
67 | // Current version. | ||
68 | _.VERSION = '1.4.2'; | ||
69 | |||
70 | // Collection Functions | ||
71 | // -------------------- | ||
72 | |||
73 | // The cornerstone, an `each` implementation, aka `forEach`. | ||
74 | // Handles objects with the built-in `forEach`, arrays, and raw objects. | ||
75 | // Delegates to **ECMAScript 5**'s native `forEach` if available. | ||
76 | var each = _.each = _.forEach = function(obj, iterator, context) { | ||
77 | if (obj == null) return; | ||
78 | if (nativeForEach && obj.forEach === nativeForEach) { | ||
79 | obj.forEach(iterator, context); | ||
80 | } else if (obj.length === +obj.length) { | ||
81 | for (var i = 0, l = obj.length; i < l; i++) { | ||
82 | if (iterator.call(context, obj[i], i, obj) === breaker) return; | ||
83 | } | ||
84 | } else { | ||
85 | for (var key in obj) { | ||
86 | if (_.has(obj, key)) { | ||
87 | if (iterator.call(context, obj[key], key, obj) === breaker) return; | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | }; | ||
92 | |||
93 | // Return the results of applying the iterator to each element. | ||
94 | // Delegates to **ECMAScript 5**'s native `map` if available. | ||
95 | _.map = _.collect = function(obj, iterator, context) { | ||
96 | var results = []; | ||
97 | if (obj == null) return results; | ||
98 | if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); | ||
99 | each(obj, function(value, index, list) { | ||
100 | results[results.length] = iterator.call(context, value, index, list); | ||
101 | }); | ||
102 | return results; | ||
103 | }; | ||
104 | |||
105 | // **Reduce** builds up a single result from a list of values, aka `inject`, | ||
106 | // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. | ||
107 | _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { | ||
108 | var initial = arguments.length > 2; | ||
109 | if (obj == null) obj = []; | ||
110 | if (nativeReduce && obj.reduce === nativeReduce) { | ||
111 | if (context) iterator = _.bind(iterator, context); | ||
112 | return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); | ||
113 | } | ||
114 | each(obj, function(value, index, list) { | ||
115 | if (!initial) { | ||
116 | memo = value; | ||
117 | initial = true; | ||
118 | } else { | ||
119 | memo = iterator.call(context, memo, value, index, list); | ||
120 | } | ||
121 | }); | ||
122 | if (!initial) throw new TypeError('Reduce of empty array with no initial value'); | ||
123 | return memo; | ||
124 | }; | ||
125 | |||
126 | // The right-associative version of reduce, also known as `foldr`. | ||
127 | // Delegates to **ECMAScript 5**'s native `reduceRight` if available. | ||
128 | _.reduceRight = _.foldr = function(obj, iterator, memo, context) { | ||
129 | var initial = arguments.length > 2; | ||
130 | if (obj == null) obj = []; | ||
131 | if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { | ||
132 | if (context) iterator = _.bind(iterator, context); | ||
133 | return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); | ||
134 | } | ||
135 | var length = obj.length; | ||
136 | if (length !== +length) { | ||
137 | var keys = _.keys(obj); | ||
138 | length = keys.length; | ||
139 | } | ||
140 | each(obj, function(value, index, list) { | ||
141 | index = keys ? keys[--length] : --length; | ||
142 | if (!initial) { | ||
143 | memo = obj[index]; | ||
144 | initial = true; | ||
145 | } else { | ||
146 | memo = iterator.call(context, memo, obj[index], index, list); | ||
147 | } | ||
148 | }); | ||
149 | if (!initial) throw new TypeError('Reduce of empty array with no initial value'); | ||
150 | return memo; | ||
151 | }; | ||
152 | |||
153 | // Return the first value which passes a truth test. Aliased as `detect`. | ||
154 | _.find = _.detect = function(obj, iterator, context) { | ||
155 | var result; | ||
156 | any(obj, function(value, index, list) { | ||
157 | if (iterator.call(context, value, index, list)) { | ||
158 | result = value; | ||
159 | return true; | ||
160 | } | ||
161 | }); | ||
162 | return result; | ||
163 | }; | ||
164 | |||
165 | // Return all the elements that pass a truth test. | ||
166 | // Delegates to **ECMAScript 5**'s native `filter` if available. | ||
167 | // Aliased as `select`. | ||
168 | _.filter = _.select = function(obj, iterator, context) { | ||
169 | var results = []; | ||
170 | if (obj == null) return results; | ||
171 | if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); | ||
172 | each(obj, function(value, index, list) { | ||
173 | if (iterator.call(context, value, index, list)) results[results.length] = value; | ||
174 | }); | ||
175 | return results; | ||
176 | }; | ||
177 | |||
178 | // Return all the elements for which a truth test fails. | ||
179 | _.reject = function(obj, iterator, context) { | ||
180 | var results = []; | ||
181 | if (obj == null) return results; | ||
182 | each(obj, function(value, index, list) { | ||
183 | if (!iterator.call(context, value, index, list)) results[results.length] = value; | ||
184 | }); | ||
185 | return results; | ||
186 | }; | ||
187 | |||
188 | // Determine whether all of the elements match a truth test. | ||
189 | // Delegates to **ECMAScript 5**'s native `every` if available. | ||
190 | // Aliased as `all`. | ||
191 | _.every = _.all = function(obj, iterator, context) { | ||
192 | iterator || (iterator = _.identity); | ||
193 | var result = true; | ||
194 | if (obj == null) return result; | ||
195 | if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); | ||
196 | each(obj, function(value, index, list) { | ||
197 | if (!(result = result && iterator.call(context, value, index, list))) return breaker; | ||
198 | }); | ||
199 | return !!result; | ||
200 | }; | ||
201 | |||
202 | // Determine if at least one element in the object matches a truth test. | ||
203 | // Delegates to **ECMAScript 5**'s native `some` if available. | ||
204 | // Aliased as `any`. | ||
205 | var any = _.some = _.any = function(obj, iterator, context) { | ||
206 | iterator || (iterator = _.identity); | ||
207 | var result = false; | ||
208 | if (obj == null) return result; | ||
209 | if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); | ||
210 | each(obj, function(value, index, list) { | ||
211 | if (result || (result = iterator.call(context, value, index, list))) return breaker; | ||
212 | }); | ||
213 | return !!result; | ||
214 | }; | ||
215 | |||
216 | // Determine if the array or object contains a given value (using `===`). | ||
217 | // Aliased as `include`. | ||
218 | _.contains = _.include = function(obj, target) { | ||
219 | var found = false; | ||
220 | if (obj == null) return found; | ||
221 | if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; | ||
222 | found = any(obj, function(value) { | ||
223 | return value === target; | ||
224 | }); | ||
225 | return found; | ||
226 | }; | ||
227 | |||
228 | // Invoke a method (with arguments) on every item in a collection. | ||
229 | _.invoke = function(obj, method) { | ||
230 | var args = slice.call(arguments, 2); | ||
231 | return _.map(obj, function(value) { | ||
232 | return (_.isFunction(method) ? method : value[method]).apply(value, args); | ||
233 | }); | ||
234 | }; | ||
235 | |||
236 | // Convenience version of a common use case of `map`: fetching a property. | ||
237 | _.pluck = function(obj, key) { | ||
238 | return _.map(obj, function(value){ return value[key]; }); | ||
239 | }; | ||
240 | |||
241 | // Convenience version of a common use case of `filter`: selecting only objects | ||
242 | // with specific `key:value` pairs. | ||
243 | _.where = function(obj, attrs) { | ||
244 | if (_.isEmpty(attrs)) return []; | ||
245 | return _.filter(obj, function(value) { | ||
246 | for (var key in attrs) { | ||
247 | if (attrs[key] !== value[key]) return false; | ||
248 | } | ||
249 | return true; | ||
250 | }); | ||
251 | }; | ||
252 | |||
253 | // Return the maximum element or (element-based computation). | ||
254 | // Can't optimize arrays of integers longer than 65,535 elements. | ||
255 | // See: https://bugs.webkit.org/show_bug.cgi?id=80797 | ||
256 | _.max = function(obj, iterator, context) { | ||
257 | if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { | ||
258 | return Math.max.apply(Math, obj); | ||
259 | } | ||
260 | if (!iterator && _.isEmpty(obj)) return -Infinity; | ||
261 | var result = {computed : -Infinity}; | ||
262 | each(obj, function(value, index, list) { | ||
263 | var computed = iterator ? iterator.call(context, value, index, list) : value; | ||
264 | computed >= result.computed && (result = {value : value, computed : computed}); | ||
265 | }); | ||
266 | return result.value; | ||
267 | }; | ||
268 | |||
269 | // Return the minimum element (or element-based computation). | ||
270 | _.min = function(obj, iterator, context) { | ||
271 | if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { | ||
272 | return Math.min.apply(Math, obj); | ||
273 | } | ||
274 | if (!iterator && _.isEmpty(obj)) return Infinity; | ||
275 | var result = {computed : Infinity}; | ||
276 | each(obj, function(value, index, list) { | ||
277 | var computed = iterator ? iterator.call(context, value, index, list) : value; | ||
278 | computed < result.computed && (result = {value : value, computed : computed}); | ||
279 | }); | ||
280 | return result.value; | ||
281 | }; | ||
282 | |||
283 | // Shuffle an array. | ||
284 | _.shuffle = function(obj) { | ||
285 | var rand; | ||
286 | var index = 0; | ||
287 | var shuffled = []; | ||
288 | each(obj, function(value) { | ||
289 | rand = _.random(index++); | ||
290 | shuffled[index - 1] = shuffled[rand]; | ||
291 | shuffled[rand] = value; | ||
292 | }); | ||
293 | return shuffled; | ||
294 | }; | ||
295 | |||
296 | // An internal function to generate lookup iterators. | ||
297 | var lookupIterator = function(value) { | ||
298 | return _.isFunction(value) ? value : function(obj){ return obj[value]; }; | ||
299 | }; | ||
300 | |||
301 | // Sort the object's values by a criterion produced by an iterator. | ||
302 | _.sortBy = function(obj, value, context) { | ||
303 | var iterator = lookupIterator(value); | ||
304 | return _.pluck(_.map(obj, function(value, index, list) { | ||
305 | return { | ||
306 | value : value, | ||
307 | index : index, | ||
308 | criteria : iterator.call(context, value, index, list) | ||
309 | }; | ||
310 | }).sort(function(left, right) { | ||
311 | var a = left.criteria; | ||
312 | var b = right.criteria; | ||
313 | if (a !== b) { | ||
314 | if (a > b || a === void 0) return 1; | ||
315 | if (a < b || b === void 0) return -1; | ||
316 | } | ||
317 | return left.index < right.index ? -1 : 1; | ||
318 | }), 'value'); | ||
319 | }; | ||
320 | |||
321 | // An internal function used for aggregate "group by" operations. | ||
322 | var group = function(obj, value, context, behavior) { | ||
323 | var result = {}; | ||
324 | var iterator = lookupIterator(value); | ||
325 | each(obj, function(value, index) { | ||
326 | var key = iterator.call(context, value, index, obj); | ||
327 | behavior(result, key, value); | ||
328 | }); | ||
329 | return result; | ||
330 | }; | ||
331 | |||
332 | // Groups the object's values by a criterion. Pass either a string attribute | ||
333 | // to group by, or a function that returns the criterion. | ||
334 | _.groupBy = function(obj, value, context) { | ||
335 | return group(obj, value, context, function(result, key, value) { | ||
336 | (_.has(result, key) ? result[key] : (result[key] = [])).push(value); | ||
337 | }); | ||
338 | }; | ||
339 | |||
340 | // Counts instances of an object that group by a certain criterion. Pass | ||
341 | // either a string attribute to count by, or a function that returns the | ||
342 | // criterion. | ||
343 | _.countBy = function(obj, value, context) { | ||
344 | return group(obj, value, context, function(result, key, value) { | ||
345 | if (!_.has(result, key)) result[key] = 0; | ||
346 | result[key]++; | ||
347 | }); | ||
348 | }; | ||
349 | |||
350 | // Use a comparator function to figure out the smallest index at which | ||
351 | // an object should be inserted so as to maintain order. Uses binary search. | ||
352 | _.sortedIndex = function(array, obj, iterator, context) { | ||
353 | iterator = iterator == null ? _.identity : lookupIterator(iterator); | ||
354 | var value = iterator.call(context, obj); | ||
355 | var low = 0, high = array.length; | ||
356 | while (low < high) { | ||
357 | var mid = (low + high) >>> 1; | ||
358 | iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; | ||
359 | } | ||
360 | return low; | ||
361 | }; | ||
362 | |||
363 | // Safely convert anything iterable into a real, live array. | ||
364 | _.toArray = function(obj) { | ||
365 | if (!obj) return []; | ||
366 | if (obj.length === +obj.length) return slice.call(obj); | ||
367 | return _.values(obj); | ||
368 | }; | ||
369 | |||
370 | // Return the number of elements in an object. | ||
371 | _.size = function(obj) { | ||
372 | return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; | ||
373 | }; | ||
374 | |||
375 | // Array Functions | ||
376 | // --------------- | ||
377 | |||
378 | // Get the first element of an array. Passing **n** will return the first N | ||
379 | // values in the array. Aliased as `head` and `take`. The **guard** check | ||
380 | // allows it to work with `_.map`. | ||
381 | _.first = _.head = _.take = function(array, n, guard) { | ||
382 | return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; | ||
383 | }; | ||
384 | |||
385 | // Returns everything but the last entry of the array. Especially useful on | ||
386 | // the arguments object. Passing **n** will return all the values in | ||
387 | // the array, excluding the last N. The **guard** check allows it to work with | ||
388 | // `_.map`. | ||
389 | _.initial = function(array, n, guard) { | ||
390 | return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); | ||
391 | }; | ||
392 | |||
393 | // Get the last element of an array. Passing **n** will return the last N | ||
394 | // values in the array. The **guard** check allows it to work with `_.map`. | ||
395 | _.last = function(array, n, guard) { | ||
396 | if ((n != null) && !guard) { | ||
397 | return slice.call(array, Math.max(array.length - n, 0)); | ||
398 | } else { | ||
399 | return array[array.length - 1]; | ||
400 | } | ||
401 | }; | ||
402 | |||
403 | // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. | ||
404 | // Especially useful on the arguments object. Passing an **n** will return | ||
405 | // the rest N values in the array. The **guard** | ||
406 | // check allows it to work with `_.map`. | ||
407 | _.rest = _.tail = _.drop = function(array, n, guard) { | ||
408 | return slice.call(array, (n == null) || guard ? 1 : n); | ||
409 | }; | ||
410 | |||
411 | // Trim out all falsy values from an array. | ||
412 | _.compact = function(array) { | ||
413 | return _.filter(array, function(value){ return !!value; }); | ||
414 | }; | ||
415 | |||
416 | // Internal implementation of a recursive `flatten` function. | ||
417 | var flatten = function(input, shallow, output) { | ||
418 | each(input, function(value) { | ||
419 | if (_.isArray(value)) { | ||
420 | shallow ? push.apply(output, value) : flatten(value, shallow, output); | ||
421 | } else { | ||
422 | output.push(value); | ||
423 | } | ||
424 | }); | ||
425 | return output; | ||
426 | }; | ||
427 | |||
428 | // Return a completely flattened version of an array. | ||
429 | _.flatten = function(array, shallow) { | ||
430 | return flatten(array, shallow, []); | ||
431 | }; | ||
432 | |||
433 | // Return a version of the array that does not contain the specified value(s). | ||
434 | _.without = function(array) { | ||
435 | return _.difference(array, slice.call(arguments, 1)); | ||
436 | }; | ||
437 | |||
438 | // Produce a duplicate-free version of the array. If the array has already | ||
439 | // been sorted, you have the option of using a faster algorithm. | ||
440 | // Aliased as `unique`. | ||
441 | _.uniq = _.unique = function(array, isSorted, iterator, context) { | ||
442 | var initial = iterator ? _.map(array, iterator, context) : array; | ||
443 | var results = []; | ||
444 | var seen = []; | ||
445 | each(initial, function(value, index) { | ||
446 | if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { | ||
447 | seen.push(value); | ||
448 | results.push(array[index]); | ||
449 | } | ||
450 | }); | ||
451 | return results; | ||
452 | }; | ||
453 | |||
454 | // Produce an array that contains the union: each distinct element from all of | ||
455 | // the passed-in arrays. | ||
456 | _.union = function() { | ||
457 | return _.uniq(concat.apply(ArrayProto, arguments)); | ||
458 | }; | ||
459 | |||
460 | // Produce an array that contains every item shared between all the | ||
461 | // passed-in arrays. | ||
462 | _.intersection = function(array) { | ||
463 | var rest = slice.call(arguments, 1); | ||
464 | return _.filter(_.uniq(array), function(item) { | ||
465 | return _.every(rest, function(other) { | ||
466 | return _.indexOf(other, item) >= 0; | ||
467 | }); | ||
468 | }); | ||
469 | }; | ||
470 | |||
471 | // Take the difference between one array and a number of other arrays. | ||
472 | // Only the elements present in just the first array will remain. | ||
473 | _.difference = function(array) { | ||
474 | var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); | ||
475 | return _.filter(array, function(value){ return !_.contains(rest, value); }); | ||
476 | }; | ||
477 | |||
478 | // Zip together multiple lists into a single array -- elements that share | ||
479 | // an index go together. | ||
480 | _.zip = function() { | ||
481 | var args = slice.call(arguments); | ||
482 | var length = _.max(_.pluck(args, 'length')); | ||
483 | var results = new Array(length); | ||
484 | for (var i = 0; i < length; i++) { | ||
485 | results[i] = _.pluck(args, "" + i); | ||
486 | } | ||
487 | return results; | ||
488 | }; | ||
489 | |||
490 | // Converts lists into objects. Pass either a single array of `[key, value]` | ||
491 | // pairs, or two parallel arrays of the same length -- one of keys, and one of | ||
492 | // the corresponding values. | ||
493 | _.object = function(list, values) { | ||
494 | var result = {}; | ||
495 | for (var i = 0, l = list.length; i < l; i++) { | ||
496 | if (values) { | ||
497 | result[list[i]] = values[i]; | ||
498 | } else { | ||
499 | result[list[i][0]] = list[i][1]; | ||
500 | } | ||
501 | } | ||
502 | return result; | ||
503 | }; | ||
504 | |||
505 | // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), | ||
506 | // we need this function. Return the position of the first occurrence of an | ||
507 | // item in an array, or -1 if the item is not included in the array. | ||
508 | // Delegates to **ECMAScript 5**'s native `indexOf` if available. | ||
509 | // If the array is large and already in sort order, pass `true` | ||
510 | // for **isSorted** to use binary search. | ||
511 | _.indexOf = function(array, item, isSorted) { | ||
512 | if (array == null) return -1; | ||
513 | var i = 0, l = array.length; | ||
514 | if (isSorted) { | ||
515 | if (typeof isSorted == 'number') { | ||
516 | i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); | ||
517 | } else { | ||
518 | i = _.sortedIndex(array, item); | ||
519 | return array[i] === item ? i : -1; | ||
520 | } | ||
521 | } | ||
522 | if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); | ||
523 | for (; i < l; i++) if (array[i] === item) return i; | ||
524 | return -1; | ||
525 | }; | ||
526 | |||
527 | // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. | ||
528 | _.lastIndexOf = function(array, item, from) { | ||
529 | if (array == null) return -1; | ||
530 | var hasIndex = from != null; | ||
531 | if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { | ||
532 | return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); | ||
533 | } | ||
534 | var i = (hasIndex ? from : array.length); | ||
535 | while (i--) if (array[i] === item) return i; | ||
536 | return -1; | ||
537 | }; | ||
538 | |||
539 | // Generate an integer Array containing an arithmetic progression. A port of | ||
540 | // the native Python `range()` function. See | ||
541 | // [the Python documentation](http://docs.python.org/library/functions.html#range). | ||
542 | _.range = function(start, stop, step) { | ||
543 | if (arguments.length <= 1) { | ||
544 | stop = start || 0; | ||
545 | start = 0; | ||
546 | } | ||
547 | step = arguments[2] || 1; | ||
548 | |||
549 | var len = Math.max(Math.ceil((stop - start) / step), 0); | ||
550 | var idx = 0; | ||
551 | var range = new Array(len); | ||
552 | |||
553 | while(idx < len) { | ||
554 | range[idx++] = start; | ||
555 | start += step; | ||
556 | } | ||
557 | |||
558 | return range; | ||
559 | }; | ||
560 | |||
561 | // Function (ahem) Functions | ||
562 | // ------------------ | ||
563 | |||
564 | // Reusable constructor function for prototype setting. | ||
565 | var ctor = function(){}; | ||
566 | |||
567 | // Create a function bound to a given object (assigning `this`, and arguments, | ||
568 | // optionally). Binding with arguments is also known as `curry`. | ||
569 | // Delegates to **ECMAScript 5**'s native `Function.bind` if available. | ||
570 | // We check for `func.bind` first, to fail fast when `func` is undefined. | ||
571 | _.bind = function bind(func, context) { | ||
572 | var bound, args; | ||
573 | if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); | ||
574 | if (!_.isFunction(func)) throw new TypeError; | ||
575 | args = slice.call(arguments, 2); | ||
576 | return bound = function() { | ||
577 | if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); | ||
578 | ctor.prototype = func.prototype; | ||
579 | var self = new ctor; | ||
580 | var result = func.apply(self, args.concat(slice.call(arguments))); | ||
581 | if (Object(result) === result) return result; | ||
582 | return self; | ||
583 | }; | ||
584 | }; | ||
585 | |||
586 | // Bind all of an object's methods to that object. Useful for ensuring that | ||
587 | // all callbacks defined on an object belong to it. | ||
588 | _.bindAll = function(obj) { | ||
589 | var funcs = slice.call(arguments, 1); | ||
590 | if (funcs.length == 0) funcs = _.functions(obj); | ||
591 | each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); | ||
592 | return obj; | ||
593 | }; | ||
594 | |||
595 | // Memoize an expensive function by storing its results. | ||
596 | _.memoize = function(func, hasher) { | ||
597 | var memo = {}; | ||
598 | hasher || (hasher = _.identity); | ||
599 | return function() { | ||
600 | var key = hasher.apply(this, arguments); | ||
601 | return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); | ||
602 | }; | ||
603 | }; | ||
604 | |||
605 | // Delays a function for the given number of milliseconds, and then calls | ||
606 | // it with the arguments supplied. | ||
607 | _.delay = function(func, wait) { | ||
608 | var args = slice.call(arguments, 2); | ||
609 | return setTimeout(function(){ return func.apply(null, args); }, wait); | ||
610 | }; | ||
611 | |||
612 | // Defers a function, scheduling it to run after the current call stack has | ||
613 | // cleared. | ||
614 | _.defer = function(func) { | ||
615 | return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); | ||
616 | }; | ||
617 | |||
618 | // Returns a function, that, when invoked, will only be triggered at most once | ||
619 | // during a given window of time. | ||
620 | _.throttle = function(func, wait) { | ||
621 | var context, args, timeout, throttling, more, result; | ||
622 | var whenDone = _.debounce(function(){ more = throttling = false; }, wait); | ||
623 | return function() { | ||
624 | context = this; args = arguments; | ||
625 | var later = function() { | ||
626 | timeout = null; | ||
627 | if (more) { | ||
628 | result = func.apply(context, args); | ||
629 | } | ||
630 | whenDone(); | ||
631 | }; | ||
632 | if (!timeout) timeout = setTimeout(later, wait); | ||
633 | if (throttling) { | ||
634 | more = true; | ||
635 | } else { | ||
636 | throttling = true; | ||
637 | result = func.apply(context, args); | ||
638 | } | ||
639 | whenDone(); | ||
640 | return result; | ||
641 | }; | ||
642 | }; | ||
643 | |||
644 | // Returns a function, that, as long as it continues to be invoked, will not | ||
645 | // be triggered. The function will be called after it stops being called for | ||
646 | // N milliseconds. If `immediate` is passed, trigger the function on the | ||
647 | // leading edge, instead of the trailing. | ||
648 | _.debounce = function(func, wait, immediate) { | ||
649 | var timeout, result; | ||
650 | return function() { | ||
651 | var context = this, args = arguments; | ||
652 | var later = function() { | ||
653 | timeout = null; | ||
654 | if (!immediate) result = func.apply(context, args); | ||
655 | }; | ||
656 | var callNow = immediate && !timeout; | ||
657 | clearTimeout(timeout); | ||
658 | timeout = setTimeout(later, wait); | ||
659 | if (callNow) result = func.apply(context, args); | ||
660 | return result; | ||
661 | }; | ||
662 | }; | ||
663 | |||
664 | // Returns a function that will be executed at most one time, no matter how | ||
665 | // often you call it. Useful for lazy initialization. | ||
666 | _.once = function(func) { | ||
667 | var ran = false, memo; | ||
668 | return function() { | ||
669 | if (ran) return memo; | ||
670 | ran = true; | ||
671 | memo = func.apply(this, arguments); | ||
672 | func = null; | ||
673 | return memo; | ||
674 | }; | ||
675 | }; | ||
676 | |||
677 | // Returns the first function passed as an argument to the second, | ||
678 | // allowing you to adjust arguments, run code before and after, and | ||
679 | // conditionally execute the original function. | ||
680 | _.wrap = function(func, wrapper) { | ||
681 | return function() { | ||
682 | var args = [func]; | ||
683 | push.apply(args, arguments); | ||
684 | return wrapper.apply(this, args); | ||
685 | }; | ||
686 | }; | ||
687 | |||
688 | // Returns a function that is the composition of a list of functions, each | ||
689 | // consuming the return value of the function that follows. | ||
690 | _.compose = function() { | ||
691 | var funcs = arguments; | ||
692 | return function() { | ||
693 | var args = arguments; | ||
694 | for (var i = funcs.length - 1; i >= 0; i--) { | ||
695 | args = [funcs[i].apply(this, args)]; | ||
696 | } | ||
697 | return args[0]; | ||
698 | }; | ||
699 | }; | ||
700 | |||
701 | // Returns a function that will only be executed after being called N times. | ||
702 | _.after = function(times, func) { | ||
703 | if (times <= 0) return func(); | ||
704 | return function() { | ||
705 | if (--times < 1) { | ||
706 | return func.apply(this, arguments); | ||
707 | } | ||
708 | }; | ||
709 | }; | ||
710 | |||
711 | // Object Functions | ||
712 | // ---------------- | ||
713 | |||
714 | // Retrieve the names of an object's properties. | ||
715 | // Delegates to **ECMAScript 5**'s native `Object.keys` | ||
716 | _.keys = nativeKeys || function(obj) { | ||
717 | if (obj !== Object(obj)) throw new TypeError('Invalid object'); | ||
718 | var keys = []; | ||
719 | for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; | ||
720 | return keys; | ||
721 | }; | ||
722 | |||
723 | // Retrieve the values of an object's properties. | ||
724 | _.values = function(obj) { | ||
725 | var values = []; | ||
726 | for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); | ||
727 | return values; | ||
728 | }; | ||
729 | |||
730 | // Convert an object into a list of `[key, value]` pairs. | ||
731 | _.pairs = function(obj) { | ||
732 | var pairs = []; | ||
733 | for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); | ||
734 | return pairs; | ||
735 | }; | ||
736 | |||
737 | // Invert the keys and values of an object. The values must be serializable. | ||
738 | _.invert = function(obj) { | ||
739 | var result = {}; | ||
740 | for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; | ||
741 | return result; | ||
742 | }; | ||
743 | |||
744 | // Return a sorted list of the function names available on the object. | ||
745 | // Aliased as `methods` | ||
746 | _.functions = _.methods = function(obj) { | ||
747 | var names = []; | ||
748 | for (var key in obj) { | ||
749 | if (_.isFunction(obj[key])) names.push(key); | ||
750 | } | ||
751 | return names.sort(); | ||
752 | }; | ||
753 | |||
754 | // Extend a given object with all the properties in passed-in object(s). | ||
755 | _.extend = function(obj) { | ||
756 | each(slice.call(arguments, 1), function(source) { | ||
757 | for (var prop in source) { | ||
758 | obj[prop] = source[prop]; | ||
759 | } | ||
760 | }); | ||
761 | return obj; | ||
762 | }; | ||
763 | |||
764 | // Return a copy of the object only containing the whitelisted properties. | ||
765 | _.pick = function(obj) { | ||
766 | var copy = {}; | ||
767 | var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | ||
768 | each(keys, function(key) { | ||
769 | if (key in obj) copy[key] = obj[key]; | ||
770 | }); | ||
771 | return copy; | ||
772 | }; | ||
773 | |||
774 | // Return a copy of the object without the blacklisted properties. | ||
775 | _.omit = function(obj) { | ||
776 | var copy = {}; | ||
777 | var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | ||
778 | for (var key in obj) { | ||
779 | if (!_.contains(keys, key)) copy[key] = obj[key]; | ||
780 | } | ||
781 | return copy; | ||
782 | }; | ||
783 | |||
784 | // Fill in a given object with default properties. | ||
785 | _.defaults = function(obj) { | ||
786 | each(slice.call(arguments, 1), function(source) { | ||
787 | for (var prop in source) { | ||
788 | if (obj[prop] == null) obj[prop] = source[prop]; | ||
789 | } | ||
790 | }); | ||
791 | return obj; | ||
792 | }; | ||
793 | |||
794 | // Create a (shallow-cloned) duplicate of an object. | ||
795 | _.clone = function(obj) { | ||
796 | if (!_.isObject(obj)) return obj; | ||
797 | return _.isArray(obj) ? obj.slice() : _.extend({}, obj); | ||
798 | }; | ||
799 | |||
800 | // Invokes interceptor with the obj, and then returns obj. | ||
801 | // The primary purpose of this method is to "tap into" a method chain, in | ||
802 | // order to perform operations on intermediate results within the chain. | ||
803 | _.tap = function(obj, interceptor) { | ||
804 | interceptor(obj); | ||
805 | return obj; | ||
806 | }; | ||
807 | |||
808 | // Internal recursive comparison function for `isEqual`. | ||
809 | var eq = function(a, b, aStack, bStack) { | ||
810 | // Identical objects are equal. `0 === -0`, but they aren't identical. | ||
811 | // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. | ||
812 | if (a === b) return a !== 0 || 1 / a == 1 / b; | ||
813 | // A strict comparison is necessary because `null == undefined`. | ||
814 | if (a == null || b == null) return a === b; | ||
815 | // Unwrap any wrapped objects. | ||
816 | if (a instanceof _) a = a._wrapped; | ||
817 | if (b instanceof _) b = b._wrapped; | ||
818 | // Compare `[[Class]]` names. | ||
819 | var className = toString.call(a); | ||
820 | if (className != toString.call(b)) return false; | ||
821 | switch (className) { | ||
822 | // Strings, numbers, dates, and booleans are compared by value. | ||
823 | case '[object String]': | ||
824 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is | ||
825 | // equivalent to `new String("5")`. | ||
826 | return a == String(b); | ||
827 | case '[object Number]': | ||
828 | // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for | ||
829 | // other numeric values. | ||
830 | return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); | ||
831 | case '[object Date]': | ||
832 | case '[object Boolean]': | ||
833 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their | ||
834 | // millisecond representations. Note that invalid dates with millisecond representations | ||
835 | // of `NaN` are not equivalent. | ||
836 | return +a == +b; | ||
837 | // RegExps are compared by their source patterns and flags. | ||
838 | case '[object RegExp]': | ||
839 | return a.source == b.source && | ||
840 | a.global == b.global && | ||
841 | a.multiline == b.multiline && | ||
842 | a.ignoreCase == b.ignoreCase; | ||
843 | } | ||
844 | if (typeof a != 'object' || typeof b != 'object') return false; | ||
845 | // Assume equality for cyclic structures. The algorithm for detecting cyclic | ||
846 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. | ||
847 | var length = aStack.length; | ||
848 | while (length--) { | ||
849 | // Linear search. Performance is inversely proportional to the number of | ||
850 | // unique nested structures. | ||
851 | if (aStack[length] == a) return bStack[length] == b; | ||
852 | } | ||
853 | // Add the first object to the stack of traversed objects. | ||
854 | aStack.push(a); | ||
855 | bStack.push(b); | ||
856 | var size = 0, result = true; | ||
857 | // Recursively compare objects and arrays. | ||
858 | if (className == '[object Array]') { | ||
859 | // Compare array lengths to determine if a deep comparison is necessary. | ||
860 | size = a.length; | ||
861 | result = size == b.length; | ||
862 | if (result) { | ||
863 | // Deep compare the contents, ignoring non-numeric properties. | ||
864 | while (size--) { | ||
865 | if (!(result = eq(a[size], b[size], aStack, bStack))) break; | ||
866 | } | ||
867 | } | ||
868 | } else { | ||
869 | // Objects with different constructors are not equivalent, but `Object`s | ||
870 | // from different frames are. | ||
871 | var aCtor = a.constructor, bCtor = b.constructor; | ||
872 | if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && | ||
873 | _.isFunction(bCtor) && (bCtor instanceof bCtor))) { | ||
874 | return false; | ||
875 | } | ||
876 | // Deep compare objects. | ||
877 | for (var key in a) { | ||
878 | if (_.has(a, key)) { | ||
879 | // Count the expected number of properties. | ||
880 | size++; | ||
881 | // Deep compare each member. | ||
882 | if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; | ||
883 | } | ||
884 | } | ||
885 | // Ensure that both objects contain the same number of properties. | ||
886 | if (result) { | ||
887 | for (key in b) { | ||
888 | if (_.has(b, key) && !(size--)) break; | ||
889 | } | ||
890 | result = !size; | ||
891 | } | ||
892 | } | ||
893 | // Remove the first object from the stack of traversed objects. | ||
894 | aStack.pop(); | ||
895 | bStack.pop(); | ||
896 | return result; | ||
897 | }; | ||
898 | |||
899 | // Perform a deep comparison to check if two objects are equal. | ||
900 | _.isEqual = function(a, b) { | ||
901 | return eq(a, b, [], []); | ||
902 | }; | ||
903 | |||
904 | // Is a given array, string, or object empty? | ||
905 | // An "empty" object has no enumerable own-properties. | ||
906 | _.isEmpty = function(obj) { | ||
907 | if (obj == null) return true; | ||
908 | if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; | ||
909 | for (var key in obj) if (_.has(obj, key)) return false; | ||
910 | return true; | ||
911 | }; | ||
912 | |||
913 | // Is a given value a DOM element? | ||
914 | _.isElement = function(obj) { | ||
915 | return !!(obj && obj.nodeType === 1); | ||
916 | }; | ||
917 | |||
918 | // Is a given value an array? | ||
919 | // Delegates to ECMA5's native Array.isArray | ||
920 | _.isArray = nativeIsArray || function(obj) { | ||
921 | return toString.call(obj) == '[object Array]'; | ||
922 | }; | ||
923 | |||
924 | // Is a given variable an object? | ||
925 | _.isObject = function(obj) { | ||
926 | return obj === Object(obj); | ||
927 | }; | ||
928 | |||
929 | // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. | ||
930 | each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { | ||
931 | _['is' + name] = function(obj) { | ||
932 | return toString.call(obj) == '[object ' + name + ']'; | ||
933 | }; | ||
934 | }); | ||
935 | |||
936 | // Define a fallback version of the method in browsers (ahem, IE), where | ||
937 | // there isn't any inspectable "Arguments" type. | ||
938 | if (!_.isArguments(arguments)) { | ||
939 | _.isArguments = function(obj) { | ||
940 | return !!(obj && _.has(obj, 'callee')); | ||
941 | }; | ||
942 | } | ||
943 | |||
944 | // Optimize `isFunction` if appropriate. | ||
945 | if (typeof (/./) !== 'function') { | ||
946 | _.isFunction = function(obj) { | ||
947 | return typeof obj === 'function'; | ||
948 | }; | ||
949 | } | ||
950 | |||
951 | // Is a given object a finite number? | ||
952 | _.isFinite = function(obj) { | ||
953 | return _.isNumber(obj) && isFinite(obj); | ||
954 | }; | ||
955 | |||
956 | // Is the given value `NaN`? (NaN is the only number which does not equal itself). | ||
957 | _.isNaN = function(obj) { | ||
958 | return _.isNumber(obj) && obj != +obj; | ||
959 | }; | ||
960 | |||
961 | // Is a given value a boolean? | ||
962 | _.isBoolean = function(obj) { | ||
963 | return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; | ||
964 | }; | ||
965 | |||
966 | // Is a given value equal to null? | ||
967 | _.isNull = function(obj) { | ||
968 | return obj === null; | ||
969 | }; | ||
970 | |||
971 | // Is a given variable undefined? | ||
972 | _.isUndefined = function(obj) { | ||
973 | return obj === void 0; | ||
974 | }; | ||
975 | |||
976 | // Shortcut function for checking if an object has a given property directly | ||
977 | // on itself (in other words, not on a prototype). | ||
978 | _.has = function(obj, key) { | ||
979 | return hasOwnProperty.call(obj, key); | ||
980 | }; | ||
981 | |||
982 | // Utility Functions | ||
983 | // ----------------- | ||
984 | |||
985 | // Run Underscore.js in *noConflict* mode, returning the `_` variable to its | ||
986 | // previous owner. Returns a reference to the Underscore object. | ||
987 | _.noConflict = function() { | ||
988 | root._ = previousUnderscore; | ||
989 | return this; | ||
990 | }; | ||
991 | |||
992 | // Keep the identity function around for default iterators. | ||
993 | _.identity = function(value) { | ||
994 | return value; | ||
995 | }; | ||
996 | |||
997 | // Run a function **n** times. | ||
998 | _.times = function(n, iterator, context) { | ||
999 | for (var i = 0; i < n; i++) iterator.call(context, i); | ||
1000 | }; | ||
1001 | |||
1002 | // Return a random integer between min and max (inclusive). | ||
1003 | _.random = function(min, max) { | ||
1004 | if (max == null) { | ||
1005 | max = min; | ||
1006 | min = 0; | ||
1007 | } | ||
1008 | return min + (0 | Math.random() * (max - min + 1)); | ||
1009 | }; | ||
1010 | |||
1011 | // List of HTML entities for escaping. | ||
1012 | var entityMap = { | ||
1013 | escape: { | ||
1014 | '&': '&', | ||
1015 | '<': '<', | ||
1016 | '>': '>', | ||
1017 | '"': '"', | ||
1018 | "'": ''', | ||
1019 | '/': '/' | ||
1020 | } | ||
1021 | }; | ||
1022 | entityMap.unescape = _.invert(entityMap.escape); | ||
1023 | |||
1024 | // Regexes containing the keys and values listed immediately above. | ||
1025 | var entityRegexes = { | ||
1026 | escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), | ||
1027 | unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') | ||
1028 | }; | ||
1029 | |||
1030 | // Functions for escaping and unescaping strings to/from HTML interpolation. | ||
1031 | _.each(['escape', 'unescape'], function(method) { | ||
1032 | _[method] = function(string) { | ||
1033 | if (string == null) return ''; | ||
1034 | return ('' + string).replace(entityRegexes[method], function(match) { | ||
1035 | return entityMap[method][match]; | ||
1036 | }); | ||
1037 | }; | ||
1038 | }); | ||
1039 | |||
1040 | // If the value of the named property is a function then invoke it; | ||
1041 | // otherwise, return it. | ||
1042 | _.result = function(object, property) { | ||
1043 | if (object == null) return null; | ||
1044 | var value = object[property]; | ||
1045 | return _.isFunction(value) ? value.call(object) : value; | ||
1046 | }; | ||
1047 | |||
1048 | // Add your own custom functions to the Underscore object. | ||
1049 | _.mixin = function(obj) { | ||
1050 | each(_.functions(obj), function(name){ | ||
1051 | var func = _[name] = obj[name]; | ||
1052 | _.prototype[name] = function() { | ||
1053 | var args = [this._wrapped]; | ||
1054 | push.apply(args, arguments); | ||
1055 | return result.call(this, func.apply(_, args)); | ||
1056 | }; | ||
1057 | }); | ||
1058 | }; | ||
1059 | |||
1060 | // Generate a unique integer id (unique within the entire client session). | ||
1061 | // Useful for temporary DOM ids. | ||
1062 | var idCounter = 0; | ||
1063 | _.uniqueId = function(prefix) { | ||
1064 | var id = idCounter++; | ||
1065 | return prefix ? prefix + id : id; | ||
1066 | }; | ||
1067 | |||
1068 | // By default, Underscore uses ERB-style template delimiters, change the | ||
1069 | // following template settings to use alternative delimiters. | ||
1070 | _.templateSettings = { | ||
1071 | evaluate : /<%([\s\S]+?)%>/g, | ||
1072 | interpolate : /<%=([\s\S]+?)%>/g, | ||
1073 | escape : /<%-([\s\S]+?)%>/g | ||
1074 | }; | ||
1075 | |||
1076 | // When customizing `templateSettings`, if you don't want to define an | ||
1077 | // interpolation, evaluation or escaping regex, we need one that is | ||
1078 | // guaranteed not to match. | ||
1079 | var noMatch = /(.)^/; | ||
1080 | |||
1081 | // Certain characters need to be escaped so that they can be put into a | ||
1082 | // string literal. | ||
1083 | var escapes = { | ||
1084 | "'": "'", | ||
1085 | '\\': '\\', | ||
1086 | '\r': 'r', | ||
1087 | '\n': 'n', | ||
1088 | '\t': 't', | ||
1089 | '\u2028': 'u2028', | ||
1090 | '\u2029': 'u2029' | ||
1091 | }; | ||
1092 | |||
1093 | var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; | ||
1094 | |||
1095 | // JavaScript micro-templating, similar to John Resig's implementation. | ||
1096 | // Underscore templating handles arbitrary delimiters, preserves whitespace, | ||
1097 | // and correctly escapes quotes within interpolated code. | ||
1098 | _.template = function(text, data, settings) { | ||
1099 | settings = _.defaults({}, settings, _.templateSettings); | ||
1100 | |||
1101 | // Combine delimiters into one regular expression via alternation. | ||
1102 | var matcher = new RegExp([ | ||
1103 | (settings.escape || noMatch).source, | ||
1104 | (settings.interpolate || noMatch).source, | ||
1105 | (settings.evaluate || noMatch).source | ||
1106 | ].join('|') + '|$', 'g'); | ||
1107 | |||
1108 | // Compile the template source, escaping string literals appropriately. | ||
1109 | var index = 0; | ||
1110 | var source = "__p+='"; | ||
1111 | text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { | ||
1112 | source += text.slice(index, offset) | ||
1113 | .replace(escaper, function(match) { return '\\' + escapes[match]; }); | ||
1114 | source += | ||
1115 | escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : | ||
1116 | interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : | ||
1117 | evaluate ? "';\n" + evaluate + "\n__p+='" : ''; | ||
1118 | index = offset + match.length; | ||
1119 | }); | ||
1120 | source += "';\n"; | ||
1121 | |||
1122 | // If a variable is not specified, place data values in local scope. | ||
1123 | if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; | ||
1124 | |||
1125 | source = "var __t,__p='',__j=Array.prototype.join," + | ||
1126 | "print=function(){__p+=__j.call(arguments,'');};\n" + | ||
1127 | source + "return __p;\n"; | ||
1128 | |||
1129 | try { | ||
1130 | var render = new Function(settings.variable || 'obj', '_', source); | ||
1131 | } catch (e) { | ||
1132 | e.source = source; | ||
1133 | throw e; | ||
1134 | } | ||
1135 | |||
1136 | if (data) return render(data, _); | ||
1137 | var template = function(data) { | ||
1138 | return render.call(this, data, _); | ||
1139 | }; | ||
1140 | |||
1141 | // Provide the compiled function source as a convenience for precompilation. | ||
1142 | template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; | ||
1143 | |||
1144 | return template; | ||
1145 | }; | ||
1146 | |||
1147 | // Add a "chain" function, which will delegate to the wrapper. | ||
1148 | _.chain = function(obj) { | ||
1149 | return _(obj).chain(); | ||
1150 | }; | ||
1151 | |||
1152 | // OOP | ||
1153 | // --------------- | ||
1154 | // If Underscore is called as a function, it returns a wrapped object that | ||
1155 | // can be used OO-style. This wrapper holds altered versions of all the | ||
1156 | // underscore functions. Wrapped objects may be chained. | ||
1157 | |||
1158 | // Helper function to continue chaining intermediate results. | ||
1159 | var result = function(obj) { | ||
1160 | return this._chain ? _(obj).chain() : obj; | ||
1161 | }; | ||
1162 | |||
1163 | // Add all of the Underscore functions to the wrapper object. | ||
1164 | _.mixin(_); | ||
1165 | |||
1166 | // Add all mutator Array functions to the wrapper. | ||
1167 | each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { | ||
1168 | var method = ArrayProto[name]; | ||
1169 | _.prototype[name] = function() { | ||
1170 | var obj = this._wrapped; | ||
1171 | method.apply(obj, arguments); | ||
1172 | if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; | ||
1173 | return result.call(this, obj); | ||
1174 | }; | ||
1175 | }); | ||
1176 | |||
1177 | // Add all accessor Array functions to the wrapper. | ||
1178 | each(['concat', 'join', 'slice'], function(name) { | ||
1179 | var method = ArrayProto[name]; | ||
1180 | _.prototype[name] = function() { | ||
1181 | return result.call(this, method.apply(this._wrapped, arguments)); | ||
1182 | }; | ||
1183 | }); | ||
1184 | |||
1185 | _.extend(_.prototype, { | ||
1186 | |||
1187 | // Start chaining a wrapped Underscore object. | ||
1188 | chain: function() { | ||
1189 | this._chain = true; | ||
1190 | return this; | ||
1191 | }, | ||
1192 | |||
1193 | // Extracts the result from a wrapped and chained object. | ||
1194 | value: function() { | ||
1195 | return this._wrapped; | ||
1196 | } | ||
1197 | |||
1198 | }); | ||
1199 | |||
1200 | }).call(this); |