bpm 1.0.0.beta.5 → 1.0.0.beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/TODO.md +18 -17
  3. data/lib/bpm/pipeline/generated_asset.rb +64 -41
  4. data/lib/bpm/pipeline/plugin_context.rb +24 -0
  5. data/lib/bpm/pipeline/transport_processor.rb +3 -3
  6. data/lib/bpm/pipeline.rb +2 -1
  7. data/lib/bpm/project.rb +7 -1
  8. data/lib/bpm/version.rb +1 -1
  9. data/lib/bpm.rb +1 -0
  10. data/spec/fixtures/projects/minitest/minitest.json +4 -2
  11. data/spec/fixtures/projects/minitest/packages/uglyduck/minifier/main.js +3 -2
  12. data/spec/fixtures/projects/minitrans/lib/main.js +3 -0
  13. data/spec/fixtures/projects/minitrans/minitrans.json +25 -0
  14. data/spec/fixtures/projects/minitrans/packages/transport/lib/main.js +1 -0
  15. data/spec/fixtures/projects/minitrans/packages/transport/package.json +21 -0
  16. data/spec/fixtures/projects/minitrans/packages/transport/transports/wrapper.js +6 -0
  17. data/spec/fixtures/projects/minitrans/packages/uglyduck/lib/main.js +3 -0
  18. data/spec/fixtures/projects/minitrans/packages/uglyduck/minifier/main.js +6 -0
  19. data/spec/fixtures/projects/minitrans/packages/uglyduck/package.json +21 -0
  20. data/spec/fixtures/projects/transporter/packages/transport/transports/wrapper.js +2 -2
  21. data/spec/plugins/minifier_spec.rb +2 -2
  22. data/spec/plugins/transport_spec.rb +38 -0
  23. metadata +41 -56
  24. data/backbone/LICENSE +0 -22
  25. data/backbone/README +0 -25
  26. data/backbone/Rakefile +0 -42
  27. data/backbone/backbone-0.5.1.bpkg +0 -0
  28. data/backbone/examples/backbone-localstorage.js +0 -84
  29. data/backbone/examples/todos/destroy.png +0 -0
  30. data/backbone/examples/todos/index.html +0 -87
  31. data/backbone/examples/todos/todos.css +0 -311
  32. data/backbone/examples/todos/todos.js +0 -258
  33. data/backbone/index.html +0 -2606
  34. data/backbone/index.js +0 -1
  35. data/backbone/lib/backbone.js +0 -1149
  36. data/backbone/lib/index.js +0 -1
  37. data/backbone/package.json +0 -14
  38. data/backbone/test/collection.js +0 -345
  39. data/backbone/test/events.js +0 -70
  40. data/backbone/test/model.coffee +0 -43
  41. data/backbone/test/model.js +0 -424
  42. data/backbone/test/noconflict.js +0 -12
  43. data/backbone/test/router.js +0 -116
  44. data/backbone/test/speed.js +0 -45
  45. data/backbone/test/sync.js +0 -133
  46. data/backbone/test/test-zepto.html +0 -30
  47. data/backbone/test/test.html +0 -31
  48. data/backbone/test/vendor/jquery-1.5.js +0 -8176
  49. data/backbone/test/vendor/jslitmus.js +0 -649
  50. data/backbone/test/vendor/json2.js +0 -481
  51. data/backbone/test/vendor/qunit.css +0 -196
  52. data/backbone/test/vendor/qunit.js +0 -1364
  53. data/backbone/test/vendor/underscore-1.1.6.js +0 -807
  54. data/backbone/test/vendor/zepto-0.6.js +0 -692
  55. data/backbone/test/view.js +0 -137
@@ -1,692 +0,0 @@
1
- (function(undefined){
2
- if (String.prototype.trim === undefined) // fix for iOS 3.2
3
- String.prototype.trim = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, '') };
4
-
5
- // For iOS 3.x
6
- // from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
7
- if (Array.prototype.reduce === undefined)
8
- Array.prototype.reduce = function(fun){
9
- if(this === void 0 || this === null) throw new TypeError();
10
- var t = Object(this), len = t.length >>> 0, k = 0, accumulator;
11
- if(typeof fun != 'function') throw new TypeError();
12
- if(len == 0 && arguments.length == 1) throw new TypeError();
13
-
14
- if(arguments.length >= 2)
15
- accumulator = arguments[1];
16
- else
17
- do{
18
- if(k in t){
19
- accumulator = t[k++];
20
- break;
21
- }
22
- if(++k >= len) throw new TypeError();
23
- } while (true);
24
-
25
- while (k < len){
26
- if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t);
27
- k++;
28
- }
29
- return accumulator;
30
- };
31
-
32
- })();
33
- var Zepto = (function() {
34
- var undefined, key, css, $$, classList,
35
- emptyArray = [], slice = emptyArray.slice,
36
- document = window.document,
37
- elementDisplay = {}, classCache = {},
38
- getComputedStyle = document.defaultView.getComputedStyle,
39
- fragmentRE = /^\s*<[^>]+>/,
40
- container = document.createElement('div');
41
-
42
- function isF(value) { return ({}).toString.call(value) == "[object Function]" }
43
- function isO(value) { return value instanceof Object }
44
- function isA(value) { return value instanceof Array }
45
-
46
- function compact(array) { return array.filter(function(item){ return item !== undefined && item !== null }) }
47
- function flatten(array) { return [].concat.apply([], array) }
48
- function camelize(str) { return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
49
- function uniq(array) { return array.filter(function(item,index,array){ return array.indexOf(item) == index }) }
50
-
51
- function classRE(name){
52
- return name in classCache ?
53
- classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'));
54
- }
55
-
56
- function defaultDisplay(nodeName) {
57
- var element, display;
58
- if (!elementDisplay[nodeName]) {
59
- element = document.createElement(nodeName);
60
- document.body.insertAdjacentElement("beforeEnd", element);
61
- display = getComputedStyle(element, '').getPropertyValue("display");
62
- element.parentNode.removeChild(element);
63
- display == "none" && (display = "block");
64
- elementDisplay[nodeName] = display;
65
- }
66
- return elementDisplay[nodeName];
67
- }
68
-
69
- function fragment(html) {
70
- container.innerHTML = ('' + html).trim();
71
- return slice.call(container.childNodes);
72
- }
73
-
74
- function Z(dom, selector){
75
- dom = dom || emptyArray;
76
- dom.__proto__ = Z.prototype;
77
- dom.selector = selector || '';
78
- return dom;
79
- }
80
-
81
- function $(selector, context){
82
- if (!selector) return Z();
83
- if (context !== undefined) return $(context).find(selector);
84
- else if (isF(selector)) return $(document).ready(selector);
85
- else if (selector instanceof Z) return selector;
86
- else {
87
- var dom;
88
- if (isA(selector)) dom = compact(selector);
89
- else if (selector instanceof Element || selector === window || selector === document)
90
- dom = [selector], selector = null;
91
- else if (fragmentRE.test(selector)) dom = fragment(selector);
92
- else if (selector.nodeType && selector.nodeType == 3) dom = [selector];
93
- else dom = $$(document, selector);
94
- return Z(dom, selector);
95
- }
96
- }
97
-
98
- $.extend = function(target, source){ for (key in source) target[key] = source[key]; return target }
99
- $.qsa = $$ = function(element, selector){ return slice.call(element.querySelectorAll(selector)) }
100
-
101
- function filtered(nodes, selector){
102
- return selector === undefined ? $(nodes) : $(nodes).filter(selector);
103
- }
104
-
105
- function funcArg(context, arg, idx, payload){
106
- return isF(arg) ? arg.call(context, idx, payload) : arg;
107
- }
108
-
109
- $.isFunction = isF;
110
- $.isObject = isO;
111
- $.isArray = isA;
112
-
113
- $.fn = {
114
- forEach: emptyArray.forEach,
115
- map: emptyArray.map,
116
- reduce: emptyArray.reduce,
117
- push: emptyArray.push,
118
- indexOf: emptyArray.indexOf,
119
- concat: emptyArray.concat,
120
- ready: function(callback){
121
- if (document.readyState == 'complete' || document.readyState == 'loaded') callback();
122
- document.addEventListener('DOMContentLoaded', callback, false); return this;
123
- },
124
- get: function(idx){ return idx === undefined ? this : this[idx] },
125
- size: function(){ return this.length },
126
- remove: function(){ return this.each(function(){ this.parentNode.removeChild(this) }) },
127
- each: function(callback){
128
- this.forEach(function(el, idx){ callback.call(el, idx, el) });
129
- return this;
130
- },
131
- filter: function(selector){
132
- return $([].filter.call(this, function(element){
133
- return $$(element.parentNode, selector).indexOf(element) >= 0;
134
- }));
135
- },
136
- add:function(selector,context){
137
- return $(uniq(this.concat($(selector,context))));
138
- },
139
- is: function(selector){
140
- return this.length > 0 && $(this[0]).filter(selector).length > 0;
141
- },
142
- not: function(selector){
143
- var nodes=[];
144
- if (isF(selector) && selector.call !== undefined)
145
- this.each(function(idx){
146
- if (!selector.call(this,idx)) nodes.push(this);
147
- });
148
- else {
149
- var ignores = slice.call(
150
- typeof selector == 'string' ?
151
- this.filter(selector) :
152
- selector instanceof NodeList ? selector : $(selector));
153
- slice.call(this).forEach(function(el){
154
- if (ignores.indexOf(el) < 0) nodes.push(el);
155
- });
156
- }
157
- return $(nodes);
158
- },
159
- eq: function(idx){ return $(this[idx]) },
160
- first: function(){ return $(this[0]) },
161
- last: function(){ return $(this[this.length - 1]) },
162
- find: function(selector){
163
- var result;
164
- if (this.length == 1) result = $$(this[0], selector);
165
- else result = flatten(this.map(function(el){ return $$(el, selector) }));
166
- return $(result);
167
- },
168
- closest: function(selector, context){
169
- var node = this[0], nodes = $$(context !== undefined ? context : document, selector);
170
- if (nodes.length === 0) node = null;
171
- while(node && node !== document && nodes.indexOf(node) < 0) node = node.parentNode;
172
- return $(node !== document && node);
173
- },
174
- parents: function(selector){
175
- var ancestors = [], nodes = this;
176
- while (nodes.length > 0)
177
- nodes = compact(nodes.map(function(node){
178
- if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
179
- ancestors.push(node);
180
- return node;
181
- }
182
- }));
183
- return filtered(ancestors, selector);
184
- },
185
- parent: function(selector){
186
- return filtered(uniq(compact(this.pluck('parentNode'))), selector);
187
- },
188
- children: function(selector){
189
- return filtered(flatten(this.map(function(el){ return slice.call(el.children) })), selector);
190
- },
191
- siblings: function(selector){
192
- return filtered(flatten(this.map(function(el){
193
- return slice.call(el.parentNode.children).filter(function(child){ return child!==el });
194
- })), selector);
195
- },
196
- empty: function(){ return this.each(function(){ this.innerHTML = '' }) },
197
- pluck: function(property){ return this.map(function(element){ return element[property] }) },
198
- show: function(){
199
- return this.each(function() {
200
- this.style.display == "none" && (this.style.display = null);
201
- if (getComputedStyle(this, '').getPropertyValue("display") == "none") {
202
- this.style.display = defaultDisplay(this.nodeName)
203
- }
204
- })
205
- },
206
- replaceWith: function(newContent) {
207
- return this.each(function() {
208
- var element = $(this),
209
- prev = element.prev();
210
- element.remove();
211
- prev.after(newContent);
212
- });
213
- },
214
- hide: function(){
215
- return this.css("display", "none")
216
- },
217
- toggle: function(){
218
- return this.css("display") == "none" ? this.show() : this.hide();
219
- },
220
- prev: function(){ return $(this.pluck('previousElementSibling')) },
221
- next: function(){ return $(this.pluck('nextElementSibling')) },
222
- html: function(html){
223
- return html === undefined ?
224
- (this.length > 0 ? this[0].innerHTML : null) :
225
- this.each(function(idx){ this.innerHTML = funcArg(this, html, idx, this.innerHTML) });
226
- },
227
- text: function(text){
228
- return text === undefined ?
229
- (this.length > 0 ? this[0].innerText : null) :
230
- this.each(function(){ this.innerText = text });
231
- },
232
- attr: function(name, value){
233
- return (typeof name == 'string' && value === undefined) ?
234
- (this.length > 0 && this[0].nodeName == 'INPUT' && this[0].type == 'text' && name == 'value') ? (this.val()) :
235
- (this.length > 0 ? this[0].getAttribute(name) || (name in this[0] ? this[0][name] : undefined) : undefined) :
236
- this.each(function(idx){
237
- if (isO(name)) for (key in name) this.setAttribute(key, name[key])
238
- else this.setAttribute(name, funcArg(this, value, idx, this.getAttribute(name)));
239
- });
240
- },
241
- removeAttr: function(name) {
242
- return this.each(function() { this.removeAttribute(name); });
243
- },
244
- data: function(name, value){
245
- return this.attr('data-' + name, value);
246
- },
247
- val: function(value){
248
- return (value === undefined) ?
249
- (this.length > 0 ? this[0].value : null) :
250
- this.each(function(){
251
- this.value = value;
252
- });
253
- },
254
- offset: function(){
255
- if(this.length==0) return null;
256
- var obj = this[0].getBoundingClientRect();
257
- return {
258
- left: obj.left + document.body.scrollLeft,
259
- top: obj.top + document.body.scrollTop,
260
- width: obj.width,
261
- height: obj.height
262
- };
263
- },
264
- css: function(property, value){
265
- if (value === undefined && typeof property == 'string')
266
- return this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property);
267
- css = '';
268
- for (key in property) css += key + ':' + property[key] + ';';
269
- if (typeof property == 'string') css = property + ':' + value;
270
- return this.each(function() { this.style.cssText += ';' + css });
271
- },
272
- index: function(element){
273
- return this.indexOf($(element)[0]);
274
- },
275
- hasClass: function(name){
276
- return classRE(name).test(this[0].className);
277
- },
278
- addClass: function(name){
279
- return this.each(function(idx) {
280
- classList = [];
281
- var cls = this.className, newName = funcArg(this, name, idx, cls);
282
- newName.split(/\s+/g).forEach(function(klass) {
283
- if (!$(this).hasClass(klass)) {
284
- classList.push(klass)
285
- }
286
- }, this);
287
- classList.length && (this.className += (cls ? " " : "") + classList.join(" "))
288
- })
289
- },
290
- removeClass: function(name){
291
- return this.each(function(idx) {
292
- classList = this.className;
293
- funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass) {
294
- classList = classList.replace(classRE(klass), " ")
295
- });
296
- this.className = classList.trim()
297
- })
298
- },
299
- toggleClass: function(name, when){
300
- return this.each(function(idx){
301
- var cls = this.className, newName = funcArg(this, name, idx, cls);
302
- ((when !== undefined && !when) || $(this).hasClass(newName)) ?
303
- $(this).removeClass(newName) : $(this).addClass(newName)
304
- });
305
- },
306
- submit: function () {
307
- return this.each(function () {
308
- try {
309
- // Submit first form element
310
- this.submit();
311
- return;
312
- } catch(e) {};
313
- });
314
- }
315
- };
316
-
317
- ['width', 'height'].forEach(function(property){
318
- $.fn[property] = function(){ var offset = this.offset(); return offset ? offset[property] : null }
319
- });
320
-
321
- var adjacencyOperators = [ 'prepend', 'after', 'before', 'append' ];
322
- function insert(operator, element, other) {
323
- var parent = (!operator || operator == 3) ? element : element.parentNode;
324
- parent.insertBefore(other,
325
- !operator ? parent.firstChild : // prepend
326
- operator == 1 ? element.nextSibling : // after
327
- operator == 2 ? element : // before
328
- null); // append
329
- }
330
-
331
- adjacencyOperators.forEach(function(key, operator) {
332
- $.fn[key] = function(html){
333
- if (typeof(html) != 'object')
334
- html = fragment(html);
335
-
336
- return this.each(function(index, element){
337
- if (html.length || html instanceof Z) {
338
- dom = html;
339
- for (var i=0; i<dom.length; i++) {
340
- var e = dom[operator < 2 ? dom.length-i-1 : i];
341
- insert(operator, element, e);
342
- }
343
- } else {
344
- insert(operator, element, html);
345
- }
346
- });
347
- };
348
- });
349
-
350
- var reverseAdjacencyOperators = [ 'append', 'prepend' ];
351
-
352
- reverseAdjacencyOperators.forEach(function(key) {
353
- $.fn[key+'To'] = function(html){
354
- if (typeof(html) != 'object')
355
- html = fragment(html);
356
-
357
- html[key](this);
358
- return this;
359
- };
360
- });
361
-
362
- Z.prototype = $.fn;
363
-
364
- return $;
365
- })();
366
-
367
- '$' in window || (window.$ = Zepto);
368
- (function($){
369
- var $$ = $.qsa, handlers = {}, _zid = 1;
370
- function zid(element) {
371
- return element._zid || (element._zid = _zid++);
372
- }
373
- function findHandlers(element, event, fn, selector) {
374
- event = parse(event);
375
- if (event.ns) var matcher = matcherFor(event.ns);
376
- return (handlers[zid(element)] || []).filter(function(handler) {
377
- return handler
378
- && (!event.e || handler.e == event.e)
379
- && (!event.ns || matcher.test(handler.ns))
380
- && (!fn || handler.fn == fn)
381
- && (!selector || handler.sel == selector);
382
- });
383
- }
384
- function parse(event) {
385
- var parts = ('' + event).split('.');
386
- return {e: parts[0], ns: parts.slice(1).sort().join(' ')};
387
- }
388
- function matcherFor(ns) {
389
- return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)');
390
- }
391
-
392
- function add(element, events, fn, selector, delegate){
393
- var id = zid(element), set = (handlers[id] || (handlers[id] = []));
394
- events.split(/\s/).forEach(function(event){
395
- var callback = delegate || fn;
396
- var proxyfn = function(event) { return callback(event, event.data) };
397
- var handler = $.extend(parse(event), {fn: fn, proxy: proxyfn, sel: selector, del: delegate, i: set.length});
398
- set.push(handler);
399
- element.addEventListener(handler.e, proxyfn, false);
400
- });
401
- }
402
- function remove(element, events, fn, selector){
403
- var id = zid(element);
404
- (events || '').split(/\s/).forEach(function(event){
405
- findHandlers(element, event, fn, selector).forEach(function(handler){
406
- delete handlers[id][handler.i];
407
- element.removeEventListener(handler.e, handler.proxy, false);
408
- });
409
- });
410
- }
411
-
412
- $.event = { add: add, remove: remove }
413
-
414
- $.fn.bind = function(event, callback){
415
- return this.each(function(){
416
- add(this, event, callback);
417
- });
418
- };
419
- $.fn.unbind = function(event, callback){
420
- return this.each(function(){
421
- remove(this, event, callback);
422
- });
423
- };
424
- $.fn.one = function(event, callback){
425
- return this.each(function(){
426
- var self = this;
427
- add(this, event, function wrapper(){
428
- callback();
429
- remove(self, event, arguments.callee);
430
- });
431
- });
432
- };
433
-
434
- var eventMethods = ['preventDefault', 'stopImmediatePropagation', 'stopPropagation'];
435
- function createProxy(event) {
436
- var proxy = $.extend({originalEvent: event}, event);
437
- eventMethods.forEach(function(key) {
438
- proxy[key] = function() {return event[key].apply(event, arguments)};
439
- });
440
- return proxy;
441
- }
442
-
443
- $.fn.delegate = function(selector, event, callback){
444
- return this.each(function(i, element){
445
- add(element, event, callback, selector, function(e, data){
446
- var target = e.target, nodes = $$(element, selector);
447
- while (target && nodes.indexOf(target) < 0) target = target.parentNode;
448
- if (target && !(target === element) && !(target === document)) {
449
- callback.call(target, $.extend(createProxy(e), {
450
- currentTarget: target, liveFired: element
451
- }), data);
452
- }
453
- });
454
- });
455
- };
456
- $.fn.undelegate = function(selector, event, callback){
457
- return this.each(function(){
458
- remove(this, event, callback, selector);
459
- });
460
- }
461
-
462
- $.fn.live = function(event, callback){
463
- $(document.body).delegate(this.selector, event, callback);
464
- return this;
465
- };
466
- $.fn.die = function(event, callback){
467
- $(document.body).undelegate(this.selector, event, callback);
468
- return this;
469
- };
470
-
471
- $.fn.trigger = function(event, data){
472
- return this.each(function(){
473
- var e = document.createEvent('Events');
474
- e.initEvent(event, true, true)
475
- e.data = data;
476
- this.dispatchEvent(e);
477
- });
478
- };
479
- })(Zepto);
480
- (function($){
481
- function detect(ua){
482
- var ua = ua, os = {},
483
- android = ua.match(/(Android)\s+([\d.]+)/),
484
- iphone = ua.match(/(iPhone\sOS)\s([\d_]+)/),
485
- ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
486
- webos = ua.match(/(webOS)\/([\d.]+)/),
487
- blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
488
- if (android) os.android = true, os.version = android[2];
489
- if (iphone) os.ios = true, os.version = iphone[2].replace(/_/g, '.'), os.iphone = true;
490
- if (ipad) os.ios = true, os.version = ipad[2].replace(/_/g, '.'), os.ipad = true;
491
- if (webos) os.webos = true, os.version = webos[2];
492
- if (blackberry) os.blackberry = true, os.version = blackberry[2];
493
- return os;
494
- }
495
- $.os = detect(navigator.userAgent);
496
- $.__detect = detect;
497
-
498
- var v = navigator.userAgent.match(/WebKit\/([\d.]+)/);
499
- $.browser = v ? { webkit: true, version: v[1] } : { webkit: false };
500
- })(Zepto);
501
- (function($, undefined){
502
- $.fn.anim = function(properties, duration, ease, callback){
503
- var transforms = [], opacity, key;
504
- for (key in properties)
505
- if (key === 'opacity') opacity = properties[key];
506
- else transforms.push(key + '(' + properties[key] + ')');
507
-
508
- $.isFunction(callback) && this.one('webkitTransitionEnd', callback);
509
-
510
- return this.css({
511
- '-webkit-transition': 'all ' + (duration !== undefined ? duration : 0.5) + 's ' + (ease || ''),
512
- '-webkit-transform': transforms.join(' '),
513
- opacity: opacity
514
- });
515
- }
516
- })(Zepto);
517
- (function($){
518
- var jsonpID = 0,
519
- isObject = $.isObject,
520
- key;
521
-
522
- function empty() {}
523
-
524
- $.ajaxJSONP = function(options){
525
- var jsonpString = 'jsonp' + ++jsonpID,
526
- script = document.createElement('script');
527
- window[jsonpString] = function(data){
528
- options.success(data);
529
- delete window[jsonpString];
530
- };
531
- script.src = options.url.replace(/=\?/, '=' + jsonpString);
532
- $('head').append(script);
533
- };
534
-
535
- $.ajaxSettings = {
536
- type: 'GET',
537
- beforeSend: empty, success: empty, error: empty, complete: empty,
538
- accepts: {
539
- script: 'text/javascript, application/javascript',
540
- json: 'application/json',
541
- xml: 'application/xml, text/xml',
542
- html: 'text/html',
543
- text: 'text/plain'
544
- }
545
- };
546
-
547
- $.ajax = function(options){
548
- options = options || {};
549
- var settings = $.extend({}, options);
550
- for (key in $.ajaxSettings) if (!settings[key]) settings[key] = $.ajaxSettings[key];
551
-
552
- if (/=\?/.test(settings.url)) return $.ajaxJSONP(settings);
553
-
554
- if (!settings.url) settings.url = window.location.toString();
555
- if (settings.data && !settings.contentType) settings.contentType = 'application/x-www-form-urlencoded';
556
- if (isObject(settings.data)) settings.data = $.param(settings.data);
557
-
558
- if (settings.type.match(/get/i) && settings.data) {
559
- var queryString = settings.data;
560
- if (settings.url.match(/\?.*=/)) {
561
- queryString = '&' + queryString;
562
- } else if (queryString[0] != '?') {
563
- queryString = '?' + queryString;
564
- }
565
- settings.url += queryString;
566
- }
567
-
568
- var mime = settings.accepts[settings.dataType],
569
- xhr = new XMLHttpRequest();
570
-
571
- settings.headers = $.extend({'X-Requested-With': 'XMLHttpRequest'}, settings.headers || {});
572
- if (mime) settings.headers['Accept'] = mime;
573
-
574
- xhr.onreadystatechange = function(){
575
- if (xhr.readyState == 4) {
576
- var result, error = false;
577
- if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 0) {
578
- if (mime == 'application/json') {
579
- try { result = JSON.parse(xhr.responseText); }
580
- catch (e) { error = e; }
581
- }
582
- else result = xhr.responseText;
583
- if (error) settings.error(xhr, 'parsererror', error);
584
- else settings.success(result, 'success', xhr);
585
- } else {
586
- error = true;
587
- settings.error(xhr, 'error');
588
- }
589
- settings.complete(xhr, error ? 'error' : 'success');
590
- }
591
- };
592
-
593
- xhr.open(settings.type, settings.url, true);
594
- if (settings.beforeSend(xhr, settings) === false) {
595
- xhr.abort();
596
- return false;
597
- }
598
-
599
- if (settings.contentType) settings.headers['Content-Type'] = settings.contentType;
600
- for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name]);
601
- xhr.send(settings.data);
602
-
603
- return xhr;
604
- };
605
-
606
- $.get = function(url, success){ $.ajax({ url: url, success: success }) };
607
- $.post = function(url, data, success, dataType){
608
- if ($.isFunction(data)) dataType = dataType || success, success = data, data = null;
609
- $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType });
610
- };
611
- $.getJSON = function(url, success){ $.ajax({ url: url, success: success, dataType: 'json' }) };
612
-
613
- $.fn.load = function(url, success){
614
- if (!this.length) return this;
615
- var self = this, parts = url.split(/\s/), selector;
616
- if (parts.length > 1) url = parts[0], selector = parts[1];
617
- $.get(url, function(response){
618
- self.html(selector ?
619
- $(document.createElement('div')).html(response).find(selector).html()
620
- : response);
621
- success && success();
622
- });
623
- return this;
624
- };
625
-
626
- $.param = function(obj, v){
627
- var result = [], add = function(key, value){
628
- result.push(encodeURIComponent(v ? v + '[' + key + ']' : key)
629
- + '=' + encodeURIComponent(value));
630
- },
631
- isObjArray = $.isArray(obj);
632
-
633
- for(key in obj)
634
- if(isObject(obj[key]))
635
- result.push($.param(obj[key], (v ? v + '[' + key + ']' : key)));
636
- else
637
- add(isObjArray ? '' : key, obj[key]);
638
-
639
- return result.join('&').replace('%20', '+');
640
- };
641
- })(Zepto);
642
- (function($){
643
- var touch = {}, touchTimeout;
644
-
645
- function parentIfText(node){
646
- return 'tagName' in node ? node : node.parentNode;
647
- }
648
-
649
- function swipeDirection(x1, x2, y1, y2){
650
- var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2);
651
- if (xDelta >= yDelta) {
652
- return (x1 - x2 > 0 ? 'Left' : 'Right');
653
- } else {
654
- return (y1 - y2 > 0 ? 'Up' : 'Down');
655
- }
656
- }
657
-
658
- $(document).ready(function(){
659
- $(document.body).bind('touchstart', function(e){
660
- var now = Date.now(), delta = now - (touch.last || now);
661
- touch.target = parentIfText(e.touches[0].target);
662
- touchTimeout && clearTimeout(touchTimeout);
663
- touch.x1 = e.touches[0].pageX;
664
- touch.y1 = e.touches[0].pageY;
665
- if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
666
- touch.last = now;
667
- }).bind('touchmove', function(e){
668
- touch.x2 = e.touches[0].pageX;
669
- touch.y2 = e.touches[0].pageY;
670
- }).bind('touchend', function(e){
671
- if (touch.isDoubleTap) {
672
- $(touch.target).trigger('doubleTap');
673
- touch = {};
674
- } else if (touch.x2 > 0 || touch.y2 > 0) {
675
- (Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30) &&
676
- $(touch.target).trigger('swipe') &&
677
- $(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
678
- touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0;
679
- } else if ('last' in touch) {
680
- touchTimeout = setTimeout(function(){
681
- touchTimeout = null;
682
- $(touch.target).trigger('tap')
683
- touch = {};
684
- }, 250);
685
- }
686
- }).bind('touchcancel', function(){ touch = {} });
687
- });
688
-
689
- ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap'].forEach(function(m){
690
- $.fn[m] = function(callback){ return this.bind(m, callback) }
691
- });
692
- })(Zepto);