sports_db 0.2 → 0.2.1
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 +1 -1
- data/app/assets/javascripts/core/utilities.js +92 -0
- data/app/assets/javascripts/libs/ICanHaz.js +542 -0
- data/app/assets/javascripts/plugins/flash.js +9 -5
- data/app/assets/javascripts/plugins/loading.js +37 -36
- data/app/assets/javascripts/plugins/resizeable.js +1 -1
- data/app/assets/javascripts/plugins/zepto.freeze.js +24 -0
- data/app/assets/stylesheets/_base.css.scss +31 -5
- data/app/assets/stylesheets/_flash.css.scss +15 -3
- data/app/assets/stylesheets/_loading.css.scss +10 -18
- data/app/assets/stylesheets/_play.css.scss +3 -2
- data/app/assets/stylesheets/mock.css.scss +2 -4
- data/app/views/application/load.html.erb +3 -1
- data/app/views/shared/_heading.html.erb +20 -0
- data/app/views/shared/_poster.html.erb +11 -0
- data/app/views/shared/_sharing.html.erb +16 -0
- data/app/views/shared/_toolbar.html.erb +12 -0
- data/lib/sports_db/engine.rb +13 -1
- data/lib/sports_db/version.rb +1 -1
- metadata +8 -7
- data/app/assets/javascripts/core/Application.js +0 -173
- data/app/assets/javascripts/core/BaseView.js +0 -117
- data/app/assets/javascripts/core/View.js +0 -56
- data/app/assets/javascripts/libs/zepto_0.8.js +0 -1213
- data/app/views/layouts/application.html.erb +0 -28
@@ -1,117 +0,0 @@
|
|
1
|
-
// A basic view implementation that expects an `URL` to be passed as one of the parameters
|
2
|
-
// to the view; it will format that `URL` using any other parameters, and use it to retrieve
|
3
|
-
// an `HTML` fragment from the server. This is only one of many strategies that could be
|
4
|
-
// followed to create views, of course. It also assumes that the parameters object will
|
5
|
-
// get a title property.
|
6
|
-
var BaseView = View.extend({
|
7
|
-
// Subclasses must ensure there is an url property to the parameter object passed
|
8
|
-
// into this superconstructor, i.e.:
|
9
|
-
//
|
10
|
-
// this._super(params)
|
11
|
-
//
|
12
|
-
// Any parameters passed in to the view constructor will be substituted
|
13
|
-
// into the URL string using the String format method (see utilities.js).
|
14
|
-
//
|
15
|
-
// @param {Object} params
|
16
|
-
initialize: function(params) {
|
17
|
-
this.url = this.getUrl(params);
|
18
|
-
this.params = params;
|
19
|
-
this.buffer = Application.params.BUFFER_EL;
|
20
|
-
},
|
21
|
-
getUrl: function(params) {
|
22
|
-
if (params.url) {
|
23
|
-
return params.url.format(params);
|
24
|
-
} else {
|
25
|
-
return "/" + Application.params.APP_NAME + "/" + params.view;
|
26
|
-
}
|
27
|
-
},
|
28
|
-
getTitle: function() {
|
29
|
-
// The title varies on the Team View between Android and iOS.
|
30
|
-
// cstuart 2011-08-29
|
31
|
-
if ($.client.ios) {
|
32
|
-
this.params.title = this.params.ios_title || this.params.title;
|
33
|
-
}
|
34
|
-
return this.params.title || this.params.view.capitalize();
|
35
|
-
},
|
36
|
-
getMetric: function() {
|
37
|
-
return this.params.metric || "/" + this.params.view.capitalize();
|
38
|
-
},
|
39
|
-
getButtons: function() {
|
40
|
-
return this.params.buttons || "Back:";
|
41
|
-
},
|
42
|
-
getAction: function() {
|
43
|
-
return this.params.action || "<None>";
|
44
|
-
},
|
45
|
-
getFilter: function() {
|
46
|
-
return this.params.filter || "<None>";
|
47
|
-
},
|
48
|
-
getSection: function() {
|
49
|
-
return this.params.view;
|
50
|
-
},
|
51
|
-
// Loads the content of the view from the server (the content should be wrapped by a `div`).
|
52
|
-
// The content is inserted into the page.
|
53
|
-
create: function() {
|
54
|
-
var view = this;
|
55
|
-
|
56
|
-
// This is a hack. The TSN keys include periods that confuse the Rails page caching system. Convert
|
57
|
-
// here to underscores, and back to periods again on the server using a filter.
|
58
|
-
view.url = view.url.replace(/\./g,"_");
|
59
|
-
|
60
|
-
function onError() {
|
61
|
-
var params = {};
|
62
|
-
// The old currentView won't exist in the case of a 404 or
|
63
|
-
// other server error.
|
64
|
-
if (Application.currentView && Application.currentView.params) {
|
65
|
-
params = Application.currentView.params;
|
66
|
-
}
|
67
|
-
$.hideLoader();
|
68
|
-
$.flash("A network error occurred.", params, true);
|
69
|
-
throw new Error('An error occurred.');
|
70
|
-
}
|
71
|
-
$.showLoader();
|
72
|
-
$.ajax({
|
73
|
-
url: view.url,
|
74
|
-
success: function(response) {
|
75
|
-
// If the server is unreachable, zepto calls `success`
|
76
|
-
// and then the `response` is empty. Catch it here and throw an error.
|
77
|
-
if (response === "") onError();
|
78
|
-
|
79
|
-
var response = $.highResifyLogosForRetinaAndAndroid(response);
|
80
|
-
|
81
|
-
view.buffer.html(response);
|
82
|
-
view.element = view.buffer.find('div').get(0);
|
83
|
-
view._evaluateDataAttribute();
|
84
|
-
Application.appendView(view);
|
85
|
-
$.hideLoader();
|
86
|
-
$.delayedLoad();
|
87
|
-
},
|
88
|
-
error: function() {
|
89
|
-
onError();
|
90
|
-
}
|
91
|
-
});
|
92
|
-
},
|
93
|
-
onClientCallback: function(name, value) {
|
94
|
-
console.log('BaseView.onClientCallback({' + name + ': ' + value + '})');
|
95
|
-
},
|
96
|
-
// If HTML returned from the server includes a `<data id="view_data" data=""></data>` element,
|
97
|
-
// this should contain an object literal (JSON string) with values that will be merged into
|
98
|
-
// the parameters for this view instance. This is used to pass back additional information
|
99
|
-
// from the server via the HTML. For example, when loading a player it might be useful to
|
100
|
-
// return the key for the player's team so that can be used when communicating with the client:
|
101
|
-
//
|
102
|
-
// <data id="view_data" data="{'title': '<%= @team.city_name %> <%= @team.team_name %>'}"></data>
|
103
|
-
//
|
104
|
-
// This will add the integer 1588 (correctly typed) under the property "team_key" to the
|
105
|
-
// parameters (`this.params`) for this view.
|
106
|
-
_evaluateDataAttribute: function() {
|
107
|
-
var view_data_el = Application.params.BUFFER_EL.find("#view_data");
|
108
|
-
if (view_data_el.size() === 0) return;
|
109
|
-
if (!view_data_el.attr('data')) return;
|
110
|
-
|
111
|
-
var data = eval.call(window, "(" + view_data_el.attr("data") + ")");
|
112
|
-
for (var key in data) {
|
113
|
-
// If you escape a non-string value, it is first converted to a string, which we don't want
|
114
|
-
this.params[key] = (typeof data[key] == "string") ? unescape(data[key]) : data[key];
|
115
|
-
}
|
116
|
-
}
|
117
|
-
});
|
@@ -1,56 +0,0 @@
|
|
1
|
-
// If your view implements an initialization function, that function will be passed a parameter
|
2
|
-
// object containing all the query parameters in the URL that triggered the view's creation, plus
|
3
|
-
// all of those values that were assigned to the view when it was registered and bound to a name.
|
4
|
-
// It does not need to hold on to these values (although the base implementation of view does, as
|
5
|
-
// `this.params`). At the end of a view's create method, it should have inserted a dom element into
|
6
|
-
// the body of the page. This will be assigned as the "element" property to the view by the application,
|
7
|
-
// as it needs to be referenced outside your view class.
|
8
|
-
var View = Class.extend({
|
9
|
-
// This method should create (by any means desirable) a DOM element and insert it into the page.
|
10
|
-
// Our base implementation queries for an HTML fragment from the server, but this is up to
|
11
|
-
// your view implementation.
|
12
|
-
create: function() {
|
13
|
-
throw new Error("Create method not implemented in subclass");
|
14
|
-
},
|
15
|
-
// Title of this view. We may not actually use titles in this version of the application,
|
16
|
-
// but we needed to provide this in the past.
|
17
|
-
getTitle: function() {
|
18
|
-
throw new Error("getTitle method not implemented in subclass");
|
19
|
-
},
|
20
|
-
// The name of the view that is used to log metrics to Google Analytics. The view
|
21
|
-
// may also provide additional calls to `Client.notify({'metric': 'metricName'})` if it updates
|
22
|
-
// internally (changing tabs, for example).
|
23
|
-
getMetric: function() {
|
24
|
-
throw new Error("getMetric method not implemented in subclass");
|
25
|
-
},
|
26
|
-
getButtons: function() {
|
27
|
-
throw new Error("getButtons method not implemented in subclass");
|
28
|
-
},
|
29
|
-
// Send off any necessary notifications to the client. This avoids and issue on iOS where
|
30
|
-
// two notifications send right after one another causes one of them to fail.
|
31
|
-
getAction: function() {
|
32
|
-
throw new Error("getAction method not implemented in subclass");
|
33
|
-
},
|
34
|
-
// Tell the client what a filtereable view is filtered to.
|
35
|
-
getFilter: function() {
|
36
|
-
throw new Error("getFilter method not implemented in subclass");
|
37
|
-
},
|
38
|
-
// Tell the client what section we are in.
|
39
|
-
getSection: function() {
|
40
|
-
throw new Error("getSection method not implemented in subclass");
|
41
|
-
},
|
42
|
-
// Called before the view is appended to the page.
|
43
|
-
beforeViewAppended: function() {
|
44
|
-
|
45
|
-
},
|
46
|
-
// Called after the view is appended into the page. Either if comes from the cache, or if
|
47
|
-
// it is from a get request.
|
48
|
-
afterViewAppended: function() {
|
49
|
-
|
50
|
-
}
|
51
|
-
// The client has executed a callback on the web page, to pass a value to the page
|
52
|
-
// or to execute some functionality.
|
53
|
-
/*
|
54
|
-
,onClientCallback( name, value ) {}
|
55
|
-
*/
|
56
|
-
});
|