sports_db 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/clients/android/client.js +53 -0
- data/app/assets/javascripts/clients/ios/client.js +58 -0
- data/app/assets/javascripts/core/Application.js +173 -0
- data/app/assets/javascripts/core/BaseView.js +117 -0
- data/app/assets/javascripts/core/History.js +45 -0
- data/app/assets/javascripts/core/Mock.js +90 -0
- data/app/assets/javascripts/core/Timer.js +18 -0
- data/app/assets/javascripts/core/View.js +56 -0
- data/app/assets/javascripts/core/utilities.js +81 -0
- data/app/assets/javascripts/libs/SimpleInheritance.js +53 -0
- data/app/assets/javascripts/libs/microjungle.zepto.js +45 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/ajax.js +279 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/assets.js +21 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/data.js +66 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/detect.js +40 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/event.js +224 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/form.js +40 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/fx.js +91 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/fx_methods.js +72 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/gesture.js +35 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/polyfill.js +36 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/selector.js +70 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/stack.js +22 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/touch.js +85 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/zepto.js +591 -0
- data/app/assets/javascripts/libs/zepto_0.8.js +1213 -0
- data/app/assets/javascripts/plugins/assert.js +11 -0
- data/app/assets/javascripts/plugins/calnav.js +18 -0
- data/app/assets/javascripts/plugins/detect.js +16 -0
- data/app/assets/javascripts/plugins/filterable.js +12 -0
- data/app/assets/javascripts/plugins/flash.js +15 -0
- data/app/assets/javascripts/plugins/jquery.zumobi-0.2.js +57 -0
- data/app/assets/javascripts/plugins/loading.js +47 -0
- data/app/assets/javascripts/plugins/params.js +27 -0
- data/app/assets/javascripts/plugins/resizeable.js +40 -0
- data/app/assets/stylesheets/_base.css.scss +42 -0
- data/app/assets/stylesheets/_filterable.css.scss +19 -0
- data/app/assets/stylesheets/_flash.css.scss +9 -0
- data/app/assets/stylesheets/_loading.css.scss +28 -0
- data/app/assets/stylesheets/_play.css.scss +38 -0
- data/app/assets/stylesheets/_reset.css.scss +33 -0
- data/app/assets/stylesheets/_table_base.scss +121 -0
- data/app/assets/stylesheets/mock.css.scss +52 -0
- data/app/controllers/application_controller.rb +39 -0
- data/app/views/application/load.html.erb +1 -0
- data/app/views/layouts/application.html.erb +27 -0
- data/lib/sports_db/version.rb +1 -1
- metadata +90 -5
@@ -0,0 +1,81 @@
|
|
1
|
+
var console = console || {
|
2
|
+
log:function(){},
|
3
|
+
warn:function(){},
|
4
|
+
error:function(){}
|
5
|
+
};
|
6
|
+
|
7
|
+
function get_px(px) {
|
8
|
+
return ($.client.ios) ? px : (window.outerWidth / 320) * px;
|
9
|
+
}
|
10
|
+
|
11
|
+
// Take a query string and return and object.
|
12
|
+
String.prototype.toParameters = function() {
|
13
|
+
if (this.indexOf('=') == -1) {
|
14
|
+
return this;
|
15
|
+
}
|
16
|
+
var params = {};
|
17
|
+
|
18
|
+
this.split("&").forEach(function(pair) {
|
19
|
+
var s = pair.split("=");
|
20
|
+
params[decodeURIComponent(s[0].replace(/\+/g, ' '))] = decodeURIComponent(s[1].replace(/\+/g, ' '));
|
21
|
+
});
|
22
|
+
return params;
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
// Replace values in a string, e.g. `"foo {boo}".format({boo: 'hoo'}) = 'foo hoo'`.
|
27
|
+
//
|
28
|
+
// @param {Object} object
|
29
|
+
String.prototype.format = function(hash, translate_key) {
|
30
|
+
translate_key = translate_key || false;
|
31
|
+
var s = this;
|
32
|
+
for (var key in hash) {
|
33
|
+
var re = new RegExp('\\{' + (key) + '\\}','gm');
|
34
|
+
s = s.replace(re, hash[key]);
|
35
|
+
}
|
36
|
+
return s;
|
37
|
+
}
|
38
|
+
|
39
|
+
// Capitalize the first character of a string.
|
40
|
+
String.prototype.capitalize = function() {
|
41
|
+
return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
|
42
|
+
}
|
43
|
+
|
44
|
+
// Sets the object to which `this` refers to.
|
45
|
+
Function.prototype.bind = function() {
|
46
|
+
if (arguments.length < 2 && typeof arguments[0] == "undefined") return this;
|
47
|
+
var __method = this, args = $A(arguments), object = args.shift();
|
48
|
+
return function() {
|
49
|
+
return __method.apply(object, args.concat($A(arguments)));
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
// Take a DOM node collection and return an `Array`
|
54
|
+
function $A(arraylike) {
|
55
|
+
if (!arraylike) return [];
|
56
|
+
var length = arraylike.length || 0, results = new Array(length);
|
57
|
+
while (length--) results[length] = arraylike[length];
|
58
|
+
return results;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Takes an object and returns the type.
|
62
|
+
function type_of(v) {
|
63
|
+
if (typeof(v) == "object") {
|
64
|
+
if (v === null) return "null";
|
65
|
+
if (v.constructor == (new Array).constructor) return "array";
|
66
|
+
if (v.constructor == (new Date).constructor) return "date";
|
67
|
+
if (v.constructor == (new RegExp).constructor) return "regex";
|
68
|
+
return "object";
|
69
|
+
}
|
70
|
+
return typeof(v);
|
71
|
+
}
|
72
|
+
|
73
|
+
function macrojungle(tmpl) {
|
74
|
+
// This is kind of stupid.
|
75
|
+
// But at least it's only written once.
|
76
|
+
var html = $('#tmp').empty().microjungle(tmpl).html();
|
77
|
+
// If we don't actually want to get any html back (just a string),
|
78
|
+
// we wrap the string in <tmp>string</tmp> and then remove
|
79
|
+
// the tags here.
|
80
|
+
return html.replace(/<(\/){0,1}tmp>/g, '');
|
81
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// > Enforces the notion of 'classes' as a structure, maintains simple inheritance, and allows for super method calling.
|
2
|
+
//
|
3
|
+
// [http://ejohn.org/blog/simple-javascript-inheritance/](http://ejohn.org/blog/simple-javascript-inheritance/)
|
4
|
+
(function(){
|
5
|
+
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
6
|
+
// The base Class implementation (does nothing)
|
7
|
+
this.Class = function(){};
|
8
|
+
// Create a new Class that inherits from this class
|
9
|
+
Class.extend = function() {
|
10
|
+
var _super = this.prototype;
|
11
|
+
// Instantiate a base class (but only create the instance,
|
12
|
+
// don't run the initialize constructor)
|
13
|
+
initializing = true;
|
14
|
+
var prototype = new this();
|
15
|
+
initializing = false;
|
16
|
+
// Copy the properties over onto the new prototype
|
17
|
+
for (var i=0; i < arguments.length; i++) {
|
18
|
+
var prop = arguments[i];
|
19
|
+
for (var name in prop) {
|
20
|
+
// Check if we're overwriting an existing function
|
21
|
+
prototype[name] = typeof prop[name] == "function" &&
|
22
|
+
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
23
|
+
(function(name, fn){
|
24
|
+
return function() {
|
25
|
+
var tmp = this._super;
|
26
|
+
// Add a new ._super() method that is the same method
|
27
|
+
// but on the super-class
|
28
|
+
this._super = _super[name];
|
29
|
+
// The method only need to be bound temporarily, so we
|
30
|
+
// remove it when we're done executing
|
31
|
+
var ret = fn.apply(this, arguments);
|
32
|
+
this._super = tmp;
|
33
|
+
return ret;
|
34
|
+
};
|
35
|
+
})(name, prop[name]) :
|
36
|
+
prop[name];
|
37
|
+
}
|
38
|
+
}
|
39
|
+
// The dummy class constructor
|
40
|
+
function Class() {
|
41
|
+
// All construction is actually done in the initialize method
|
42
|
+
if ( !initializing && this.initialize )
|
43
|
+
this.initialize.apply(this, arguments);
|
44
|
+
}
|
45
|
+
// Populate our constructed prototype object
|
46
|
+
Class.prototype = prototype;
|
47
|
+
// Enforce the constructor to be what we expect
|
48
|
+
Class.constructor = Class;
|
49
|
+
// And make this class extendable
|
50
|
+
Class.extend = arguments.callee;
|
51
|
+
return Class;
|
52
|
+
};
|
53
|
+
})();
|
@@ -0,0 +1,45 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.fn.microjungle = function(template) {
|
3
|
+
|
4
|
+
var d = document;
|
5
|
+
|
6
|
+
// they just doing their job.
|
7
|
+
function monkeys(what, who) {
|
8
|
+
var l = what.length;
|
9
|
+
|
10
|
+
for (var i = 0; i < l; i++) {
|
11
|
+
var j = what[i];
|
12
|
+
|
13
|
+
if (j) {
|
14
|
+
if (typeof j == 'string') {
|
15
|
+
who.html(who.html() + j);
|
16
|
+
} else {
|
17
|
+
if (typeof j[0] == 'string') {
|
18
|
+
var el = $('<' + j.shift() + '>'),
|
19
|
+
attrs = {}.toString.call(j[0]) === '[object Object]' && j.shift(),
|
20
|
+
k;
|
21
|
+
|
22
|
+
if (attrs) {
|
23
|
+
for(k in attrs) {
|
24
|
+
attrs[k] && el.attr(k, attrs[k]);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
who.append(monkeys(j, el));
|
29
|
+
} else if (j.nodeType === 11) {
|
30
|
+
who.append(j);
|
31
|
+
} else {
|
32
|
+
monkeys(j, who);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
return who;
|
39
|
+
};
|
40
|
+
|
41
|
+
return this.each(function() {
|
42
|
+
$(this).append(monkeys(template, $(d.createDocumentFragment())));
|
43
|
+
});
|
44
|
+
};
|
45
|
+
})(Zepto);
|
@@ -0,0 +1,279 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
var jsonpID = 0,
|
7
|
+
isObject = $.isObject,
|
8
|
+
document = window.document,
|
9
|
+
key,
|
10
|
+
name,
|
11
|
+
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
12
|
+
scriptTypeRE = /^(?:text|application)\/javascript/i,
|
13
|
+
xmlTypeRE = /^(?:text|application)\/xml/i,
|
14
|
+
jsonType = 'application/json',
|
15
|
+
htmlType = 'text/html',
|
16
|
+
blankRE = /^\s*$/
|
17
|
+
|
18
|
+
// trigger a custom event and return false if it was cancelled
|
19
|
+
function triggerAndReturn(context, eventName, data) {
|
20
|
+
var event = $.Event(eventName)
|
21
|
+
$(context).trigger(event, data)
|
22
|
+
return !event.defaultPrevented
|
23
|
+
}
|
24
|
+
|
25
|
+
// trigger an Ajax "global" event
|
26
|
+
function triggerGlobal(settings, context, eventName, data) {
|
27
|
+
if (settings.global) return triggerAndReturn(context || document, eventName, data)
|
28
|
+
}
|
29
|
+
|
30
|
+
// Number of active Ajax requests
|
31
|
+
$.active = 0
|
32
|
+
|
33
|
+
function ajaxStart(settings) {
|
34
|
+
if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart')
|
35
|
+
}
|
36
|
+
function ajaxStop(settings) {
|
37
|
+
if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop')
|
38
|
+
}
|
39
|
+
|
40
|
+
// triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable
|
41
|
+
function ajaxBeforeSend(xhr, settings) {
|
42
|
+
var context = settings.context
|
43
|
+
if (settings.beforeSend.call(context, xhr, settings) === false ||
|
44
|
+
triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)
|
45
|
+
return false
|
46
|
+
|
47
|
+
triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])
|
48
|
+
}
|
49
|
+
function ajaxSuccess(data, xhr, settings) {
|
50
|
+
var context = settings.context, status = 'success'
|
51
|
+
settings.success.call(context, data, status, xhr)
|
52
|
+
triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])
|
53
|
+
ajaxComplete(status, xhr, settings)
|
54
|
+
}
|
55
|
+
// type: "timeout", "error", "abort", "parsererror"
|
56
|
+
function ajaxError(error, type, xhr, settings) {
|
57
|
+
var context = settings.context
|
58
|
+
settings.error.call(context, xhr, type, error)
|
59
|
+
triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])
|
60
|
+
ajaxComplete(type, xhr, settings)
|
61
|
+
}
|
62
|
+
// status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
|
63
|
+
function ajaxComplete(status, xhr, settings) {
|
64
|
+
var context = settings.context
|
65
|
+
settings.complete.call(context, xhr, status)
|
66
|
+
triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])
|
67
|
+
ajaxStop(settings)
|
68
|
+
}
|
69
|
+
|
70
|
+
// Empty function, used as default callback
|
71
|
+
function empty() {}
|
72
|
+
|
73
|
+
$.ajaxJSONP = function(options){
|
74
|
+
var callbackName = 'jsonp' + (++jsonpID),
|
75
|
+
script = document.createElement('script'),
|
76
|
+
abort = function(){
|
77
|
+
$(script).remove()
|
78
|
+
if (callbackName in window) window[callbackName] = empty
|
79
|
+
ajaxComplete('abort', xhr, options)
|
80
|
+
},
|
81
|
+
xhr = { abort: abort }, abortTimeout
|
82
|
+
|
83
|
+
if (options.error) script.onerror = function() {
|
84
|
+
xhr.abort()
|
85
|
+
options.error()
|
86
|
+
}
|
87
|
+
|
88
|
+
window[callbackName] = function(data){
|
89
|
+
clearTimeout(abortTimeout)
|
90
|
+
$(script).remove()
|
91
|
+
delete window[callbackName]
|
92
|
+
ajaxSuccess(data, xhr, options)
|
93
|
+
}
|
94
|
+
|
95
|
+
serializeData(options)
|
96
|
+
script.src = options.url.replace(/=\?/, '=' + callbackName)
|
97
|
+
$('head').append(script)
|
98
|
+
|
99
|
+
if (options.timeout > 0) abortTimeout = setTimeout(function(){
|
100
|
+
xhr.abort()
|
101
|
+
ajaxComplete('timeout', xhr, options)
|
102
|
+
}, options.timeout)
|
103
|
+
|
104
|
+
return xhr
|
105
|
+
}
|
106
|
+
|
107
|
+
$.ajaxSettings = {
|
108
|
+
// Default type of request
|
109
|
+
type: 'GET',
|
110
|
+
// Callback that is executed before request
|
111
|
+
beforeSend: empty,
|
112
|
+
// Callback that is executed if the request succeeds
|
113
|
+
success: empty,
|
114
|
+
// Callback that is executed the the server drops error
|
115
|
+
error: empty,
|
116
|
+
// Callback that is executed on request complete (both: error and success)
|
117
|
+
complete: empty,
|
118
|
+
// The context for the callbacks
|
119
|
+
context: null,
|
120
|
+
// Whether to trigger "global" Ajax events
|
121
|
+
global: true,
|
122
|
+
// Transport
|
123
|
+
xhr: function () {
|
124
|
+
return new window.XMLHttpRequest()
|
125
|
+
},
|
126
|
+
// MIME types mapping
|
127
|
+
accepts: {
|
128
|
+
script: 'text/javascript, application/javascript',
|
129
|
+
json: jsonType,
|
130
|
+
xml: 'application/xml, text/xml',
|
131
|
+
html: htmlType,
|
132
|
+
text: 'text/plain'
|
133
|
+
},
|
134
|
+
// Whether the request is to another domain
|
135
|
+
crossDomain: false,
|
136
|
+
// Default timeout
|
137
|
+
timeout: 0
|
138
|
+
}
|
139
|
+
|
140
|
+
function mimeToDataType(mime) {
|
141
|
+
return mime && ( mime == htmlType ? 'html' :
|
142
|
+
mime == jsonType ? 'json' :
|
143
|
+
scriptTypeRE.test(mime) ? 'script' :
|
144
|
+
xmlTypeRE.test(mime) && 'xml' ) || 'text'
|
145
|
+
}
|
146
|
+
|
147
|
+
function appendQuery(url, query) {
|
148
|
+
return (url + '&' + query).replace(/[&?]{1,2}/, '?')
|
149
|
+
}
|
150
|
+
|
151
|
+
// serialize payload and append it to the URL for GET requests
|
152
|
+
function serializeData(options) {
|
153
|
+
if (isObject(options.data)) options.data = $.param(options.data)
|
154
|
+
if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
|
155
|
+
options.url = appendQuery(options.url, options.data)
|
156
|
+
}
|
157
|
+
|
158
|
+
$.ajax = function(options){
|
159
|
+
var settings = $.extend({}, options || {})
|
160
|
+
for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
|
161
|
+
|
162
|
+
ajaxStart(settings)
|
163
|
+
|
164
|
+
if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) &&
|
165
|
+
RegExp.$2 != window.location.host
|
166
|
+
|
167
|
+
var dataType = settings.dataType, hasPlaceholder = /=\?/.test(settings.url)
|
168
|
+
if (dataType == 'jsonp' || hasPlaceholder) {
|
169
|
+
if (!hasPlaceholder) settings.url = appendQuery(settings.url, 'callback=?')
|
170
|
+
return $.ajaxJSONP(settings)
|
171
|
+
}
|
172
|
+
|
173
|
+
if (!settings.url) settings.url = window.location.toString()
|
174
|
+
serializeData(settings)
|
175
|
+
|
176
|
+
var mime = settings.accepts[dataType],
|
177
|
+
baseHeaders = { },
|
178
|
+
protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
|
179
|
+
xhr = $.ajaxSettings.xhr(), abortTimeout
|
180
|
+
|
181
|
+
if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'
|
182
|
+
if (mime) {
|
183
|
+
baseHeaders['Accept'] = mime
|
184
|
+
if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]
|
185
|
+
xhr.overrideMimeType && xhr.overrideMimeType(mime)
|
186
|
+
}
|
187
|
+
if (settings.contentType || (settings.data && settings.type.toUpperCase() != 'GET'))
|
188
|
+
baseHeaders['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded')
|
189
|
+
settings.headers = $.extend(baseHeaders, settings.headers || {})
|
190
|
+
|
191
|
+
xhr.onreadystatechange = function(){
|
192
|
+
if (xhr.readyState == 4) {
|
193
|
+
clearTimeout(abortTimeout)
|
194
|
+
var result, error = false
|
195
|
+
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
|
196
|
+
dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
|
197
|
+
result = xhr.responseText
|
198
|
+
|
199
|
+
try {
|
200
|
+
if (dataType == 'script') (1,eval)(result)
|
201
|
+
else if (dataType == 'xml') result = xhr.responseXML
|
202
|
+
else if (dataType == 'json') result = blankRE.test(result) ? null : JSON.parse(result)
|
203
|
+
} catch (e) { error = e }
|
204
|
+
|
205
|
+
if (error) ajaxError(error, 'parsererror', xhr, settings)
|
206
|
+
else ajaxSuccess(result, xhr, settings)
|
207
|
+
} else {
|
208
|
+
ajaxError(null, 'error', xhr, settings)
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
var async = 'async' in settings ? settings.async : true
|
214
|
+
xhr.open(settings.type, settings.url, async)
|
215
|
+
|
216
|
+
for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name])
|
217
|
+
|
218
|
+
if (ajaxBeforeSend(xhr, settings) === false) {
|
219
|
+
xhr.abort()
|
220
|
+
return false
|
221
|
+
}
|
222
|
+
|
223
|
+
if (settings.timeout > 0) abortTimeout = setTimeout(function(){
|
224
|
+
xhr.onreadystatechange = empty
|
225
|
+
xhr.abort()
|
226
|
+
ajaxError(null, 'timeout', xhr, settings)
|
227
|
+
}, settings.timeout)
|
228
|
+
|
229
|
+
// avoid sending empty string (#319)
|
230
|
+
xhr.send(settings.data ? settings.data : null)
|
231
|
+
return xhr
|
232
|
+
}
|
233
|
+
|
234
|
+
$.get = function(url, success){ return $.ajax({ url: url, success: success }) }
|
235
|
+
|
236
|
+
$.post = function(url, data, success, dataType){
|
237
|
+
if ($.isFunction(data)) dataType = dataType || success, success = data, data = null
|
238
|
+
return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType })
|
239
|
+
}
|
240
|
+
|
241
|
+
$.getJSON = function(url, success){
|
242
|
+
return $.ajax({ url: url, success: success, dataType: 'json' })
|
243
|
+
}
|
244
|
+
|
245
|
+
$.fn.load = function(url, success){
|
246
|
+
if (!this.length) return this
|
247
|
+
var self = this, parts = url.split(/\s/), selector
|
248
|
+
if (parts.length > 1) url = parts[0], selector = parts[1]
|
249
|
+
$.get(url, function(response){
|
250
|
+
self.html(selector ?
|
251
|
+
$(document.createElement('div')).html(response.replace(rscript, "")).find(selector).html()
|
252
|
+
: response)
|
253
|
+
success && success.call(self)
|
254
|
+
})
|
255
|
+
return this
|
256
|
+
}
|
257
|
+
|
258
|
+
var escape = encodeURIComponent
|
259
|
+
|
260
|
+
function serialize(params, obj, traditional, scope){
|
261
|
+
var array = $.isArray(obj)
|
262
|
+
$.each(obj, function(key, value) {
|
263
|
+
if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'
|
264
|
+
// handle data in serializeArray() format
|
265
|
+
if (!scope && array) params.add(value.name, value.value)
|
266
|
+
// recurse into nested objects
|
267
|
+
else if (traditional ? $.isArray(value) : isObject(value))
|
268
|
+
serialize(params, value, traditional, key)
|
269
|
+
else params.add(key, value)
|
270
|
+
})
|
271
|
+
}
|
272
|
+
|
273
|
+
$.param = function(obj, traditional){
|
274
|
+
var params = []
|
275
|
+
params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }
|
276
|
+
serialize(params, obj, traditional)
|
277
|
+
return params.join('&').replace('%20', '+')
|
278
|
+
}
|
279
|
+
})(Zepto)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
var cache = [], timeout
|
7
|
+
|
8
|
+
$.fn.remove = function(){
|
9
|
+
return this.each(function(){
|
10
|
+
if(this.parentNode){
|
11
|
+
if(this.tagName === 'IMG'){
|
12
|
+
cache.push(this)
|
13
|
+
this.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
|
14
|
+
if (timeout) clearTimeout(timeout)
|
15
|
+
timeout = setTimeout(function(){ cache = [] }, 60000)
|
16
|
+
}
|
17
|
+
this.parentNode.removeChild(this)
|
18
|
+
}
|
19
|
+
})
|
20
|
+
}
|
21
|
+
})(Zepto)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
// The following code is heavily inspired by jQuery's $.fn.data()
|
6
|
+
|
7
|
+
;(function($) {
|
8
|
+
var data = {}, dataAttr = $.fn.data, camelize = $.zepto.camelize,
|
9
|
+
exp = $.expando = 'Zepto' + (+new Date())
|
10
|
+
|
11
|
+
// Get value from node:
|
12
|
+
// 1. first try key as given,
|
13
|
+
// 2. then try camelized key,
|
14
|
+
// 3. fall back to reading "data-*" attribute.
|
15
|
+
function getData(node, name) {
|
16
|
+
var id = node[exp], store = id && data[id]
|
17
|
+
if (name === undefined) return store || setData(node)
|
18
|
+
else {
|
19
|
+
if (store) {
|
20
|
+
if (name in store) return store[name]
|
21
|
+
var camelName = camelize(name)
|
22
|
+
if (camelName in store) return store[camelName]
|
23
|
+
}
|
24
|
+
return dataAttr.call($(node), name)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
// Store value under camelized key on node
|
29
|
+
function setData(node, name, value) {
|
30
|
+
var id = node[exp] || (node[exp] = ++$.uuid),
|
31
|
+
store = data[id] || (data[id] = attributeData(node))
|
32
|
+
if (name !== undefined) store[camelize(name)] = value
|
33
|
+
return store
|
34
|
+
}
|
35
|
+
|
36
|
+
// Read all "data-*" attributes from a node
|
37
|
+
function attributeData(node) {
|
38
|
+
var store = {}
|
39
|
+
$.each(node.attributes, function(i, attr){
|
40
|
+
if (attr.name.indexOf('data-') == 0)
|
41
|
+
store[camelize(attr.name.replace('data-', ''))] = attr.value
|
42
|
+
})
|
43
|
+
return store
|
44
|
+
}
|
45
|
+
|
46
|
+
$.fn.data = function(name, value) {
|
47
|
+
return value === undefined ?
|
48
|
+
// set multiple values via object
|
49
|
+
$.isPlainObject(name) ?
|
50
|
+
this.each(function(i, node){
|
51
|
+
$.each(name, function(key, value){ setData(node, key, value) })
|
52
|
+
}) :
|
53
|
+
// get value from first element
|
54
|
+
this.length == 0 ? undefined : getData(this[0], name) :
|
55
|
+
// set value on all elements
|
56
|
+
this.each(function(){ setData(this, name, value) })
|
57
|
+
}
|
58
|
+
|
59
|
+
$.fn.removeData = function(names) {
|
60
|
+
if (typeof names == 'string') names = names.split(/\s+/)
|
61
|
+
return this.each(function(){
|
62
|
+
var id = this[exp], store = id && data[id]
|
63
|
+
if (store) $.each(names, function(){ delete store[camelize(this)] })
|
64
|
+
})
|
65
|
+
}
|
66
|
+
})(Zepto)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
function detect(ua){
|
7
|
+
var os = this.os = {}, browser = this.browser = {},
|
8
|
+
webkit = ua.match(/WebKit\/([\d.]+)/),
|
9
|
+
android = ua.match(/(Android)\s+([\d.]+)/),
|
10
|
+
ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
|
11
|
+
iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
|
12
|
+
webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
|
13
|
+
touchpad = webos && ua.match(/TouchPad/),
|
14
|
+
kindle = ua.match(/Kindle\/([\d.]+)/),
|
15
|
+
silk = ua.match(/Silk\/([\d._]+)/),
|
16
|
+
blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/)
|
17
|
+
|
18
|
+
// todo clean this up with a better OS/browser
|
19
|
+
// separation. we need to discern between multiple
|
20
|
+
// browsers on android, and decide if kindle fire in
|
21
|
+
// silk mode is android or not
|
22
|
+
|
23
|
+
if (browser.webkit = !!webkit) browser.version = webkit[1]
|
24
|
+
|
25
|
+
if (android) os.android = true, os.version = android[2]
|
26
|
+
if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
|
27
|
+
if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
|
28
|
+
if (webos) os.webos = true, os.version = webos[2]
|
29
|
+
if (touchpad) os.touchpad = true
|
30
|
+
if (blackberry) os.blackberry = true, os.version = blackberry[2]
|
31
|
+
if (kindle) os.kindle = true, os.version = kindle[1]
|
32
|
+
if (silk) browser.silk = true, browser.version = silk[1]
|
33
|
+
if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true
|
34
|
+
}
|
35
|
+
|
36
|
+
detect.call($, navigator.userAgent)
|
37
|
+
// make available to unit tests
|
38
|
+
$.__detect = detect
|
39
|
+
|
40
|
+
})(Zepto)
|