pageflow 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

@@ -0,0 +1,87 @@
1
+ // Cocktail.js 0.3.0
2
+ // (c) 2012 Onsi Fakhouri
3
+ // Cocktail.js may be freely distributed under the MIT license.
4
+ // http://github.com/onsi/cocktail
5
+ (function() {
6
+ var Cocktail;
7
+
8
+ if (typeof exports !== 'undefined') {
9
+ Cocktail = exports;
10
+ } else {
11
+ Cocktail = this.Cocktail = {};
12
+ }
13
+
14
+ Cocktail.mixins = {};
15
+
16
+ Cocktail.mixin = function mixin(klass) {
17
+ var mixins = _.chain(arguments).toArray().rest().flatten().value();
18
+
19
+ var collisions = {};
20
+
21
+ _(mixins).each(function(mixin) {
22
+ if (_.isString(mixin)) {
23
+ mixin = Cocktail.mixins[mixin];
24
+ }
25
+ _(mixin).each(function(value, key) {
26
+ if (_.isFunction(value)) {
27
+ if (klass.prototype[key]) {
28
+ collisions[key] = collisions[key] || [klass.prototype[key]];
29
+ collisions[key].push(value);
30
+ }
31
+ klass.prototype[key] = value;
32
+ } else if (_.isObject(value)) {
33
+ klass.prototype[key] = _.extend({}, value, klass.prototype[key] || {});
34
+ }
35
+ });
36
+ });
37
+
38
+ _(collisions).each(function(propertyValues, propertyName) {
39
+ klass.prototype[propertyName] = function() {
40
+ var that = this,
41
+ args = arguments,
42
+ returnValue = undefined;
43
+
44
+ _(propertyValues).each(function(value) {
45
+ var returnedValue = _.isFunction(value) ? value.apply(that, args) : value;
46
+ returnValue = (returnedValue === undefined ? returnValue : returnedValue);
47
+ });
48
+
49
+ return returnValue;
50
+ };
51
+ });
52
+ };
53
+
54
+ var originalExtend;
55
+
56
+ Cocktail.patch = function patch(Backbone) {
57
+ originalExtend = Backbone.Model.extend;
58
+
59
+ var extend = function(protoProps, classProps) {
60
+ var klass = originalExtend.call(this, protoProps, classProps);
61
+
62
+ var mixins = klass.prototype.mixins;
63
+ if (mixins && klass.prototype.hasOwnProperty('mixins')) {
64
+ Cocktail.mixin(klass, mixins);
65
+ }
66
+
67
+ return klass;
68
+ };
69
+
70
+ _([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
71
+ klass.mixin = function mixin() {
72
+ Cocktail.mixin(this, _.toArray(arguments));
73
+ };
74
+
75
+ klass.extend = extend;
76
+ });
77
+ };
78
+
79
+ Cocktail.unpatch = function unpatch(Backbone) {
80
+ _([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
81
+ klass.mixin = undefined;
82
+ klass.extend = originalExtend;
83
+ });
84
+ };
85
+
86
+ Cocktail.patch(Backbone);
87
+ })();
@@ -0,0 +1,500 @@
1
+ /*jshint expr: true*/
2
+ /**
3
+ * @preserve HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
4
+ */
5
+ ;(function(window, document) {
6
+ /*jshint evil:true */
7
+ /** version */
8
+ var version = '3.6.2';
9
+
10
+ /** Preset options */
11
+ var options = window.html5 || {};
12
+
13
+ /** Used to skip problem elements */
14
+ var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
15
+
16
+ /** Not all elements can be cloned in IE **/
17
+ var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
18
+
19
+ /** Detect whether the browser supports default html5 styles */
20
+ var supportsHtml5Styles;
21
+
22
+ /** Name of the expando, to work with multiple documents or to re-shiv one document */
23
+ var expando = '_html5shiv';
24
+
25
+ /** The id for the the documents expando */
26
+ var expanID = 0;
27
+
28
+ /** Cached data for each document */
29
+ var expandoData = {};
30
+
31
+ /** Detect whether the browser supports unknown elements */
32
+ var supportsUnknownElements;
33
+
34
+ (function() {
35
+ try {
36
+ var a = document.createElement('a');
37
+ a.innerHTML = '<xyz></xyz>';
38
+ //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
39
+ supportsHtml5Styles = ('hidden' in a);
40
+
41
+ supportsUnknownElements = a.childNodes.length == 1 || (function() {
42
+ // assign a false positive if unable to shiv
43
+ (document.createElement)('a');
44
+ var frag = document.createDocumentFragment();
45
+ return (
46
+ typeof frag.cloneNode == 'undefined' ||
47
+ typeof frag.createDocumentFragment == 'undefined' ||
48
+ typeof frag.createElement == 'undefined'
49
+ );
50
+ }());
51
+ } catch(e) {
52
+ // assign a false positive if detection fails => unable to shiv
53
+ supportsHtml5Styles = true;
54
+ supportsUnknownElements = true;
55
+ }
56
+
57
+ }());
58
+
59
+ /*--------------------------------------------------------------------------*/
60
+
61
+ /**
62
+ * Creates a style sheet with the given CSS text and adds it to the document.
63
+ * @private
64
+ * @param {Document} ownerDocument The document.
65
+ * @param {String} cssText The CSS text.
66
+ * @returns {StyleSheet} The style element.
67
+ */
68
+ function addStyleSheet(ownerDocument, cssText) {
69
+ var p = ownerDocument.createElement('p'),
70
+ parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
71
+
72
+ p.innerHTML = 'x<style>' + cssText + '</style>';
73
+ return parent.insertBefore(p.lastChild, parent.firstChild);
74
+ }
75
+
76
+ /**
77
+ * Returns the value of `html5.elements` as an array.
78
+ * @private
79
+ * @returns {Array} An array of shived element node names.
80
+ */
81
+ function getElements() {
82
+ var elements = html5.elements;
83
+ return typeof elements == 'string' ? elements.split(' ') : elements;
84
+ }
85
+
86
+ /**
87
+ * Returns the data associated to the given document
88
+ * @private
89
+ * @param {Document} ownerDocument The document.
90
+ * @returns {Object} An object of data.
91
+ */
92
+ function getExpandoData(ownerDocument) {
93
+ var data = expandoData[ownerDocument[expando]];
94
+ if (!data) {
95
+ data = {};
96
+ expanID++;
97
+ ownerDocument[expando] = expanID;
98
+ expandoData[expanID] = data;
99
+ }
100
+ return data;
101
+ }
102
+
103
+ /**
104
+ * returns a shived element for the given nodeName and document
105
+ * @memberOf html5
106
+ * @param {String} nodeName name of the element
107
+ * @param {Document} ownerDocument The context document.
108
+ * @returns {Object} The shived element.
109
+ */
110
+ function createElement(nodeName, ownerDocument, data){
111
+ if (!ownerDocument) {
112
+ ownerDocument = document;
113
+ }
114
+ if(supportsUnknownElements){
115
+ return ownerDocument.createElement(nodeName);
116
+ }
117
+ if (!data) {
118
+ data = getExpandoData(ownerDocument);
119
+ }
120
+ var node;
121
+
122
+ if (data.cache[nodeName]) {
123
+ node = data.cache[nodeName].cloneNode();
124
+ } else if (saveClones.test(nodeName)) {
125
+ node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
126
+ } else {
127
+ node = data.createElem(nodeName);
128
+ }
129
+
130
+ // Avoid adding some elements to fragments in IE < 9 because
131
+ // * Attributes like `name` or `type` cannot be set/changed once an element
132
+ // is inserted into a document/fragment
133
+ // * Link elements with `src` attributes that are inaccessible, as with
134
+ // a 403 response, will cause the tab/window to crash
135
+ // * Script elements appended to fragments will execute when their `src`
136
+ // or `text` property is set
137
+ return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node;
138
+ }
139
+
140
+ /**
141
+ * returns a shived DocumentFragment for the given document
142
+ * @memberOf html5
143
+ * @param {Document} ownerDocument The context document.
144
+ * @returns {Object} The shived DocumentFragment.
145
+ */
146
+ function createDocumentFragment(ownerDocument, data){
147
+ if (!ownerDocument) {
148
+ ownerDocument = document;
149
+ }
150
+ if(supportsUnknownElements){
151
+ return ownerDocument.createDocumentFragment();
152
+ }
153
+ data = data || getExpandoData(ownerDocument);
154
+ var clone = data.frag.cloneNode(),
155
+ i = 0,
156
+ elems = getElements(),
157
+ l = elems.length;
158
+ for(;i<l;i++){
159
+ clone.createElement(elems[i]);
160
+ }
161
+ return clone;
162
+ }
163
+
164
+ /**
165
+ * Shivs the `createElement` and `createDocumentFragment` methods of the document.
166
+ * @private
167
+ * @param {Document|DocumentFragment} ownerDocument The document.
168
+ * @param {Object} data of the document.
169
+ */
170
+ function shivMethods(ownerDocument, data) {
171
+ if (!data.cache) {
172
+ data.cache = {};
173
+ data.createElem = ownerDocument.createElement;
174
+ data.createFrag = ownerDocument.createDocumentFragment;
175
+ data.frag = data.createFrag();
176
+ }
177
+
178
+
179
+ ownerDocument.createElement = function(nodeName) {
180
+ //abort shiv
181
+ if (!html5.shivMethods) {
182
+ return data.createElem(nodeName);
183
+ }
184
+ return createElement(nodeName, ownerDocument, data);
185
+ };
186
+
187
+ ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
188
+ 'var n=f.cloneNode(),c=n.createElement;' +
189
+ 'h.shivMethods&&(' +
190
+ // unroll the `createElement` calls
191
+ getElements().join().replace(/\w+/g, function(nodeName) {
192
+ data.createElem(nodeName);
193
+ data.frag.createElement(nodeName);
194
+ return 'c("' + nodeName + '")';
195
+ }) +
196
+ ');return n}'
197
+ )(html5, data.frag);
198
+ }
199
+
200
+ /*--------------------------------------------------------------------------*/
201
+
202
+ /**
203
+ * Shivs the given document.
204
+ * @memberOf html5
205
+ * @param {Document} ownerDocument The document to shiv.
206
+ * @returns {Document} The shived document.
207
+ */
208
+ function shivDocument(ownerDocument) {
209
+ if (!ownerDocument) {
210
+ ownerDocument = document;
211
+ }
212
+ var data = getExpandoData(ownerDocument);
213
+
214
+ if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
215
+ data.hasCSS = !!addStyleSheet(ownerDocument,
216
+ // corrects block display not defined in IE6/7/8/9
217
+ 'article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
218
+ // adds styling not present in IE6/7/8/9
219
+ 'mark{background:#FF0;color:#000}' +
220
+ // hides non-rendered elements
221
+ 'template{display:none}'
222
+ );
223
+ }
224
+ if (!supportsUnknownElements) {
225
+ shivMethods(ownerDocument, data);
226
+ }
227
+ return ownerDocument;
228
+ }
229
+
230
+ /*--------------------------------------------------------------------------*/
231
+
232
+ /**
233
+ * The `html5` object is exposed so that more elements can be shived and
234
+ * existing shiving can be detected on iframes.
235
+ * @type Object
236
+ * @example
237
+ *
238
+ * // options can be changed before the script is included
239
+ * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
240
+ */
241
+ var html5 = {
242
+
243
+ /**
244
+ * An array or space separated string of node names of the elements to shiv.
245
+ * @memberOf html5
246
+ * @type Array|String
247
+ */
248
+ 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary template time video',
249
+
250
+ /**
251
+ * current version of html5shiv
252
+ */
253
+ 'version': version,
254
+
255
+ /**
256
+ * A flag to indicate that the HTML5 style sheet should be inserted.
257
+ * @memberOf html5
258
+ * @type Boolean
259
+ */
260
+ 'shivCSS': (options.shivCSS !== false),
261
+
262
+ /**
263
+ * Is equal to true if a browser supports creating unknown/HTML5 elements
264
+ * @memberOf html5
265
+ * @type boolean
266
+ */
267
+ 'supportsUnknownElements': supportsUnknownElements,
268
+
269
+ /**
270
+ * A flag to indicate that the document's `createElement` and `createDocumentFragment`
271
+ * methods should be overwritten.
272
+ * @memberOf html5
273
+ * @type Boolean
274
+ */
275
+ 'shivMethods': (options.shivMethods !== false),
276
+
277
+ /**
278
+ * A string to describe the type of `html5` object ("default" or "default print").
279
+ * @memberOf html5
280
+ * @type String
281
+ */
282
+ 'type': 'default',
283
+
284
+ // shivs the document according to the specified `html5` object options
285
+ 'shivDocument': shivDocument,
286
+
287
+ //creates a shived element
288
+ createElement: createElement,
289
+
290
+ //creates a shived documentFragment
291
+ createDocumentFragment: createDocumentFragment
292
+ };
293
+
294
+ /*--------------------------------------------------------------------------*/
295
+
296
+ // expose html5
297
+ window.html5 = html5;
298
+
299
+ // shiv the document
300
+ shivDocument(document);
301
+
302
+ /*------------------------------- Print Shiv -------------------------------*/
303
+
304
+ /** Used to filter media types */
305
+ var reMedia = /^$|\b(?:all|print)\b/;
306
+
307
+ /** Used to namespace printable elements */
308
+ var shivNamespace = 'html5shiv';
309
+
310
+ /** Detect whether the browser supports shivable style sheets */
311
+ var supportsShivableSheets = !supportsUnknownElements && (function() {
312
+ // assign a false negative if unable to shiv
313
+ var docEl = document.documentElement;
314
+ return !(
315
+ typeof document.namespaces == 'undefined' ||
316
+ typeof document.parentWindow == 'undefined' ||
317
+ typeof docEl.applyElement == 'undefined' ||
318
+ typeof docEl.removeNode == 'undefined' ||
319
+ typeof window.attachEvent == 'undefined'
320
+ );
321
+ }());
322
+
323
+ /*--------------------------------------------------------------------------*/
324
+
325
+ /**
326
+ * Wraps all HTML5 elements in the given document with printable elements.
327
+ * (eg. the "header" element is wrapped with the "html5shiv:header" element)
328
+ * @private
329
+ * @param {Document} ownerDocument The document.
330
+ * @returns {Array} An array wrappers added.
331
+ */
332
+ function addWrappers(ownerDocument) {
333
+ var node,
334
+ nodes = ownerDocument.getElementsByTagName('*'),
335
+ index = nodes.length,
336
+ reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
337
+ result = [];
338
+
339
+ while (index--) {
340
+ node = nodes[index];
341
+ if (reElements.test(node.nodeName)) {
342
+ result.push(node.applyElement(createWrapper(node)));
343
+ }
344
+ }
345
+ return result;
346
+ }
347
+
348
+ /**
349
+ * Creates a printable wrapper for the given element.
350
+ * @private
351
+ * @param {Element} element The element.
352
+ * @returns {Element} The wrapper.
353
+ */
354
+ function createWrapper(element) {
355
+ var node,
356
+ nodes = element.attributes,
357
+ index = nodes.length,
358
+ wrapper = element.ownerDocument.createElement(shivNamespace + ':' + element.nodeName);
359
+
360
+ // copy element attributes to the wrapper
361
+ while (index--) {
362
+ node = nodes[index];
363
+ node.specified && wrapper.setAttribute(node.nodeName, node.nodeValue);
364
+ }
365
+ // copy element styles to the wrapper
366
+ wrapper.style.cssText = element.style.cssText;
367
+ return wrapper;
368
+ }
369
+
370
+ /**
371
+ * Shivs the given CSS text.
372
+ * (eg. header{} becomes html5shiv\:header{})
373
+ * @private
374
+ * @param {String} cssText The CSS text to shiv.
375
+ * @returns {String} The shived CSS text.
376
+ */
377
+ function shivCssText(cssText) {
378
+ var pair,
379
+ parts = cssText.split('{'),
380
+ index = parts.length,
381
+ reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
382
+ replacement = '$1' + shivNamespace + '\\:$2';
383
+
384
+ while (index--) {
385
+ pair = parts[index] = parts[index].split('}');
386
+ pair[pair.length - 1] = pair[pair.length - 1].replace(reElements, replacement);
387
+ parts[index] = pair.join('}');
388
+ }
389
+ return parts.join('{');
390
+ }
391
+
392
+ /**
393
+ * Removes the given wrappers, leaving the original elements.
394
+ * @private
395
+ * @params {Array} wrappers An array of printable wrappers.
396
+ */
397
+ function removeWrappers(wrappers) {
398
+ var index = wrappers.length;
399
+ while (index--) {
400
+ wrappers[index].removeNode();
401
+ }
402
+ }
403
+
404
+ /*--------------------------------------------------------------------------*/
405
+
406
+ /**
407
+ * Shivs the given document for print.
408
+ * @memberOf html5
409
+ * @param {Document} ownerDocument The document to shiv.
410
+ * @returns {Document} The shived document.
411
+ */
412
+ function shivPrint(ownerDocument) {
413
+ var shivedSheet,
414
+ wrappers,
415
+ data = getExpandoData(ownerDocument),
416
+ namespaces = ownerDocument.namespaces,
417
+ ownerWindow = ownerDocument.parentWindow;
418
+
419
+ if (!supportsShivableSheets || ownerDocument.printShived) {
420
+ return ownerDocument;
421
+ }
422
+ if (typeof namespaces[shivNamespace] == 'undefined') {
423
+ namespaces.add(shivNamespace);
424
+ }
425
+
426
+ function removeSheet() {
427
+ clearTimeout(data._removeSheetTimer);
428
+ if (shivedSheet) {
429
+ shivedSheet.removeNode(true);
430
+ }
431
+ shivedSheet= null;
432
+ }
433
+
434
+ ownerWindow.attachEvent('onbeforeprint', function() {
435
+
436
+ removeSheet();
437
+
438
+ var imports,
439
+ length,
440
+ sheet,
441
+ collection = ownerDocument.styleSheets,
442
+ cssText = [],
443
+ index = collection.length,
444
+ sheets = Array(index);
445
+
446
+ // convert styleSheets collection to an array
447
+ while (index--) {
448
+ sheets[index] = collection[index];
449
+ }
450
+ // concat all style sheet CSS text
451
+ while ((sheet = sheets.pop())) {
452
+ // IE does not enforce a same origin policy for external style sheets...
453
+ // but has trouble with some dynamically created stylesheets
454
+ if (!sheet.disabled && reMedia.test(sheet.media)) {
455
+
456
+ try {
457
+ imports = sheet.imports;
458
+ length = imports.length;
459
+ } catch(er){
460
+ length = 0;
461
+ }
462
+
463
+ for (index = 0; index < length; index++) {
464
+ sheets.push(imports[index]);
465
+ }
466
+
467
+ try {
468
+ cssText.push(sheet.cssText);
469
+ } catch(er){}
470
+ }
471
+ }
472
+
473
+ // wrap all HTML5 elements with printable elements and add the shived style sheet
474
+ cssText = shivCssText(cssText.reverse().join(''));
475
+ wrappers = addWrappers(ownerDocument);
476
+ shivedSheet = addStyleSheet(ownerDocument, cssText);
477
+
478
+ });
479
+
480
+ ownerWindow.attachEvent('onafterprint', function() {
481
+ // remove wrappers, leaving the original elements, and remove the shived style sheet
482
+ removeWrappers(wrappers);
483
+ clearTimeout(data._removeSheetTimer);
484
+ data._removeSheetTimer = setTimeout(removeSheet, 500);
485
+ });
486
+
487
+ ownerDocument.printShived = true;
488
+ return ownerDocument;
489
+ }
490
+
491
+ /*--------------------------------------------------------------------------*/
492
+
493
+ // expose API
494
+ html5.type += ' print';
495
+ html5.shivPrint = shivPrint;
496
+
497
+ // shiv for print
498
+ shivPrint(document);
499
+
500
+ }(this, document));