sports_db 0.2 → 0.2.1

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.
@@ -1,47 +1,48 @@
1
- (function($){
1
+ ;(function($){
2
2
  var load_timer;
3
3
  var LOADING_TEXT = 'Loading…';
4
- function prevent(e) {
5
- e.preventDefault();
6
- }
7
- function freeze() {
8
- $(document.body).bind("touchmove", prevent);
9
- }
10
- function thaw() {
11
- $(document.body).unbind('touchmove', prevent);
12
- }
13
- function showLoaderNow() {
14
- $('#app_load_loader').remove();
15
- freeze();
16
- loading_text = LOADING_TEXT;
17
- if (Application.currentView && Application.currentView.params.loading_text) {
18
- loading_text = Application.currentView.params.loading_text;
19
- }
20
- $('#loading_text').html(loading_text);
21
-
22
- $('#loading').css({'height': document.documentElement.clientHeight + 'px'});
23
- $.alignLoader();
4
+ var $loading = $('#loading');
5
+ var v = parseFloat($.os.version);
6
+ var deviceHasNativeSupport = ($.os.ios && v >= 5) || ($.os.android && v >= 2.2);
24
7
 
25
- $('#loading').show();
8
+ function alignLoader() {
9
+ if (!deviceHasNativeSupport && $loading.css('display') === 'block') {
10
+ $loading
11
+ .css('position', 'absolute')
12
+ .find('.loading_text')
13
+ .css('margin-top', (window.pageYOffset + 80) + 'px');
14
+ }
26
15
  }
27
- $.alignLoader = function() {
28
- $('#loading').css({'top': window.scrollY + 'px'});
29
- };
30
- $.showLoader = function(loader_text) {
16
+ $.showLoader = function() {
31
17
  if (load_timer) {
32
- load_timer.stop();
33
- load_timer = undefined;
18
+ window.clearTimeout(load_timer);
34
19
  }
35
- load_timer = new Timer(showLoaderNow, 222);
36
- load_timer.start();
20
+ load_timer = setTimeout(function() {
21
+ var txt = LOADING_TEXT;
22
+ if (Application.currentView && Application.currentView.params.loading_text) {
23
+ txt = Application.currentView.params.loading_text;
24
+ }
25
+ $('#loading_text').html(txt);
26
+ $loading
27
+ .freeze()
28
+ .show();
29
+ alignLoader();
30
+ }, 333);
37
31
  };
38
32
  $.hideLoader = function() {
39
- load_timer.stop();
40
- thaw();
41
- $('#loading').hide();
42
- $('#app_load_loader').remove();
43
- if (Application.currentView && Application.currentView.params.loading_text) {
44
- Application.currentView.params.loading_text = LOADING_TEXT;
33
+ if (load_timer) {
34
+ window.clearTimeout(load_timer);
45
35
  }
36
+
37
+ $loading
38
+ .freeze({'unfreeze':true})
39
+ .hide();
40
+
41
+ $('#app_load_loader').remove();
42
+
43
+ Application.currentView.params.loading_text = LOADING_TEXT;
46
44
  };
45
+
46
+ $(window).on('scroll', alignLoader);
47
+
47
48
  })(Zepto);
@@ -3,7 +3,7 @@
3
3
  var MAX = 17;
4
4
  var DEFAULT = 15;
5
5
  var p = Application.params.font_size;
6
- var pi = parseInt(p);
6
+ var pi = parseInt(p,10);
7
7
  var size = ((!isNaN(p) && pi <= MAX && pi >= MIN)) ? pi : DEFAULT;
8
8
 
9
9
  $.fn.resizeable = function() {
@@ -0,0 +1,24 @@
1
+ ;(function($){
2
+
3
+ $.extend($.fn, {
4
+ freeze: function(opts) {
5
+
6
+ var params = $.extend({ 'unfreeze': false }, opts);
7
+
8
+ return this.each(function() {
9
+ // This won't work in some versions of Android.
10
+ // http://code.google.com/p/android/issues/detail?id=5491
11
+ // http://code.google.com/p/android/issues/detail?id=4549
12
+
13
+ var freeze = function(e){ e.preventDefault(); };
14
+
15
+ if (params.unfreeze) {
16
+ $(this).off('touchmove', freeze);
17
+ } else {
18
+ $(this).on('touchmove', freeze);
19
+ }
20
+ });
21
+ }
22
+ });
23
+
24
+ })(Zepto);
@@ -1,18 +1,34 @@
1
1
  html, body {
2
- background-color: $page_bg;
2
+ background-color: $body_background_color;
3
3
  }
4
4
  * {
5
- -webkit-box-sizing: border-box;
6
- box-sizing: border-box;
5
+ margin: 0;
6
+ padding :0;
7
+ border: 0;
8
+ outline: 0;
9
+
10
+ font-size: 100%;
11
+ line-height: 1;
12
+
13
+ vertical-align: baseline;
14
+
15
+ background-color: transparent;
16
+ background-repeat: no-repeat;
17
+ -webkit-background-size: contain;
18
+ background-size: contain;
19
+
7
20
  -webkit-tap-highlight-color: rgba(0,0,0,0);
21
+
8
22
  -webkit-user-select: none;
9
23
  -webkit-user-modify: read-only;
10
24
  -webkit-touch-callout: none;
11
- background-repeat: no-repeat;
25
+
26
+ -webkit-box-sizing: border-box;
27
+ box-sizing: border-box;
12
28
  }
13
29
  body {
14
30
  font-size: $default_font_size;
15
- color: $txt_gray;
31
+ color: $default_color;
16
32
  margin: 0 auto;
17
33
  }
18
34
  body.ios {
@@ -22,3 +38,13 @@ body.ios {
22
38
  body.android {
23
39
  font-family: sans-serif;
24
40
  }
41
+ ol,ul {
42
+ list-style-type: none;
43
+ }
44
+ table {
45
+ border-collapse: collapse;
46
+ border-spacing: 0;
47
+ }
48
+ a {
49
+ text-decoration: none;
50
+ }
@@ -1,9 +1,21 @@
1
1
  #flash {
2
- background-color: #666;
3
- color: #fff;
2
+ background-color: $hl_color;
4
3
  line-height: 24px;
5
- font-size: 14px;
6
4
  padding: 0 10px;
7
5
  text-align: center;
6
+ color: #fff;
7
+ text-shadow: $txt_shadow;
8
+ font-weight: bold;
9
+
10
+ opacity: 1;
11
+ -webkit-transition: opacity .5s ease-in;
12
+
8
13
  height: 24px;
14
+ -webkit-transition: height .5s ease-in;
15
+
16
+ font-size: 14px;
17
+ }
18
+ #flash.hide {
19
+ opacity: 0 !important;
20
+ height: 0 !important;
9
21
  }
@@ -1,28 +1,20 @@
1
- loading{
2
- display: block;
3
- z-index:99999;
4
- position:absolute;
5
- top:0;
6
- left:0;
7
- right:0;
8
- bottom: 0;
1
+ .loading {
2
+ z-index: 99999;
3
+ position: fixed;
4
+ top: 0; left: 0; right: 0; bottom: 0;
9
5
  text-align: center;
10
- background-color:rgba(20,20,20,.1);
11
- color:#fff;
6
+ background-color: rgba(20,20,20,.2);
12
7
  }
13
- loading_text{
14
- padding: 4px 10px;
8
+ .loading_text {
9
+ padding: 8px 16px;
15
10
  display: inline-block;
16
11
  border: 1px solid #777;
17
12
  margin-top: 80px;
18
13
  text-align: center;
19
- font-size: 18px;
20
- line-height: 1;
21
- font-family: "Helvetica Neue",Helvetica,sans-serif;
22
14
  color: #fff;
23
- background-color:rgba(10,10,10,.8);
24
- -webkit-border-radius: 4px;
15
+ background-color: rgba(10,10,10,.8);
16
+ -webkit-border-radius: 3px;
25
17
  -webkit-background-clip: padding-box;
26
18
  -webkit-box-shadow: 1px 1px 5px #000;
27
- -webkit-user-select: none;
19
+ font-size: 15px;
28
20
  }
@@ -12,8 +12,9 @@
12
12
  // - NOTE the .play class is added to a parent element of the <img>,
13
13
  // not the <img> itself, because <img>s do not allow psuedo elements.
14
14
  &::after {
15
- // This url will not work from an app autogen/ file.
16
- background: transparent url(#{$imghost}playbutton@2x.png) no-repeat center;
15
+ background-repeat: no-repeat;
16
+ background-image: url(#{$imghost}playbutton@2x.png);
17
+ background-position: center;
17
18
  -webkit-background-size: auto 50%;
18
19
  background-size: auto 50%;
19
20
  }
@@ -1,6 +1,5 @@
1
- $txt_shadow: 1px 1px 0 rgba(10, 10, 10, .2);
2
-
3
1
  #mock-toolbar-container {
2
+ font-size: 10px;
4
3
  -webkit-user-select: none;
5
4
  margin:0;
6
5
  padding:0;
@@ -14,7 +13,6 @@ $txt_shadow: 1px 1px 0 rgba(10, 10, 10, .2);
14
13
  color: white !important;
15
14
  margin: 0;
16
15
  height: 44px;
17
- -webkit-box-sizing: border-box;
18
16
  border-collapse: collapse;
19
17
  border: 1px solid #111;
20
18
  background: -webkit-gradient(linear,left top,left bottom,color-stop(0, #2a2a2a),color-stop(1, #0a0a0a));
@@ -25,7 +23,7 @@ $txt_shadow: 1px 1px 0 rgba(10, 10, 10, .2);
25
23
  font-size: 18px;
26
24
  font-weight: bold;
27
25
  line-height: 2.3;
28
- text-shadow: $txt_shadow;
26
+ text-shadow: 1px 1px 0 rgba(10, 10, 10, .2);
29
27
  }
30
28
  #mock-left, #mock-right {
31
29
  display: block;
@@ -1 +1,3 @@
1
- <loading id="app_load_loader"><loading_text>Loading&hellip;</loading_text></loading>
1
+ <div id="loading" class="loading">
2
+ <div id="loading_text" class="loading_text">Loading&hellip;</div>
3
+ </div>
@@ -0,0 +1,20 @@
1
+ <% if item.is_twitter? %>
2
+ <h3 class="tweet article_heading">
3
+ <% else %>
4
+ <h3 class="article_heading">
5
+ <% end %>
6
+ <% if item.title.present? %>
7
+ <% if item.is_video? %>
8
+ <span class="is_video_prefix">[VIDEO]</span>
9
+ <% end %>
10
+ <%= raw item.title %>
11
+ <% end %>
12
+ </h3>
13
+ <p class="author_and_date">
14
+ <% if item.is_twitter? %>
15
+ <%= "via #{item.author} -" unless item.source.blank? %>
16
+ <%= short_date item.published_at unless item.published_at.blank? %>
17
+ <% else %>
18
+ <%= date_time item.published_at unless item.published_at.blank? %>
19
+ <% end %>
20
+ </p>
@@ -0,0 +1,11 @@
1
+ <% if item.is_video? && item.high_bandwidth_url.present? %>
2
+ <a class="link poster_bx play br" target="_blank" href="<%= item.high_bandwidth_url %>">
3
+ <div style="background-image: url(<%= item.article_image_url %>)"></div>
4
+ <%# <img src="< % # = item.article_image_url % >"> fixes FB#25010 %>
5
+ </a>
6
+ <% elsif item.is_article? && item.article_image_url.present? %>
7
+ <div class="poster_bx">
8
+ <div style="background-image: url(<%= item.article_image_url %>)"></div>
9
+ <%# <img src="< % # = item.article_image_url % >"> fixes FB#25010 %>
10
+ </div>
11
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <% if item.attribute_present?(:link) && item.link.present? %>
2
+ <%
3
+ # The gsub at the end is to replace a mdash with a hyphen. It was causing Android to barf.
4
+ summary = truncate(strip_tags(item.contents.strip), :length => 90).gsub("—", "-")
5
+ %>
6
+ <div class="share_btn btn hhl"
7
+ data-url="<%= item.link %>"
8
+ data-title="<%= item.title %>"
9
+ data-summary=" <%= summary %> "
10
+ <% if get_article_img_url(item) %>
11
+ data-fbimg="<%= get_article_img_url(item) %>"
12
+ <% end %>
13
+ >
14
+ Share
15
+ </div>
16
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <div class="toolbar row">
2
+ <div class="col">
3
+ <%= render 'shared/sharing', :item => item %>
4
+ </div>
5
+ <div class="col stretch"></div>
6
+ <div class="col">
7
+ <div class="btn resizeable down hhl" data-dir="-1">T-</div>
8
+ </div>
9
+ <div class="col">
10
+ <div class="btn resizeable up hhl" data-dir="+1">T+</div>
11
+ </div>
12
+ </div>
@@ -1,5 +1,17 @@
1
1
  module SportsDb
2
2
  class Engine < Rails::Engine
3
+ if Rails.env.development?
4
+ config.to_prepare do
5
+ Rails.logger.debug "*** reloading sports_db gem (only in development mode) ***"
6
+ require_dependency SportsDb::Engine.root.join('lib', 'sports_db').to_s
7
+ end
8
+
9
+ config.after_initialize do
10
+ # optional, without it will call `to_prepend` only when a file changes,
11
+ # not on every request
12
+ Rails.application.config.reload_classes_only_on_change = false
13
+ end
14
+ end
3
15
 
4
16
  end
5
- end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module SportsDb
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sports_db
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -52,13 +52,11 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - app/assets/javascripts/clients/android/client.js
54
54
  - app/assets/javascripts/clients/ios/client.js
55
- - app/assets/javascripts/core/Application.js
56
- - app/assets/javascripts/core/BaseView.js
57
55
  - app/assets/javascripts/core/History.js
58
56
  - app/assets/javascripts/core/Mock.js
59
57
  - app/assets/javascripts/core/Timer.js
60
58
  - app/assets/javascripts/core/utilities.js
61
- - app/assets/javascripts/core/View.js
59
+ - app/assets/javascripts/libs/ICanHaz.js
62
60
  - app/assets/javascripts/libs/microjungle.zepto.js
63
61
  - app/assets/javascripts/libs/SimpleInheritance.js
64
62
  - app/assets/javascripts/libs/zepto-v1.0rc1/ajax.js
@@ -75,7 +73,6 @@ files:
75
73
  - app/assets/javascripts/libs/zepto-v1.0rc1/stack.js
76
74
  - app/assets/javascripts/libs/zepto-v1.0rc1/touch.js
77
75
  - app/assets/javascripts/libs/zepto-v1.0rc1/zepto.js
78
- - app/assets/javascripts/libs/zepto_0.8.js
79
76
  - app/assets/javascripts/plugins/assert.js
80
77
  - app/assets/javascripts/plugins/calnav.js
81
78
  - app/assets/javascripts/plugins/detect.js
@@ -85,6 +82,7 @@ files:
85
82
  - app/assets/javascripts/plugins/loading.js
86
83
  - app/assets/javascripts/plugins/params.js
87
84
  - app/assets/javascripts/plugins/resizeable.js
85
+ - app/assets/javascripts/plugins/zepto.freeze.js
88
86
  - app/assets/stylesheets/_base.css.scss
89
87
  - app/assets/stylesheets/_filterable.css.scss
90
88
  - app/assets/stylesheets/_flash.css.scss
@@ -115,7 +113,10 @@ files:
115
113
  - app/models/score_notification.rb
116
114
  - app/models/twitter.rb
117
115
  - app/views/application/load.html.erb
118
- - app/views/layouts/application.html.erb
116
+ - app/views/shared/_heading.html.erb
117
+ - app/views/shared/_poster.html.erb
118
+ - app/views/shared/_sharing.html.erb
119
+ - app/views/shared/_toolbar.html.erb
119
120
  - config/routes.rb
120
121
  - lib/sports_db/engine.rb
121
122
  - lib/sports_db/external_feed_builder.rb
@@ -1,173 +0,0 @@
1
- var Application = Class.extend({
2
- initialize: function() {
3
- this.app_is_initializing = true;
4
- this.views = {};
5
- this.params = {};
6
- this.cache = {};
7
- this.currentView = null;
8
- this.clientCallbackHandlers = [];
9
- this.params = {};
10
-
11
- // Get hash params
12
- if (window.location.hash) {
13
- this.params = $.hashStrToObj();
14
- }
15
-
16
- // I'm not reallys ure we want to store these together, but whatever (For now)
17
- this.params = $.extend(window.CONFIG, this.params);
18
-
19
- // Start timer for game updates
20
- // TODO only run this on game views
21
- this.timer = new Timer($.proxy(this._fireTimerEvent, this), this.params.GAME_UPDATE_FREQUENCY);
22
- this.timer.start();
23
- },
24
- // Fire a timer event
25
- _fireTimerEvent: function() {
26
- $(document.body).trigger("timerReachInterval", false, false);
27
- },
28
- // Call the view if the method exists
29
- _onTimerReachedInterval: function() {
30
- var view = this.currentView;
31
- if (view && view._onTimerReachedInterval) {
32
- view._onTimerReachedInterval.call(view);
33
- }
34
- },
35
- // Register a view constructor under a specific name. If a link in the application has
36
- // a parameter named "view" that points to a registered view name, then the `Application`
37
- // will load that view. Optionally, you can pass in parameters, and these will be merged
38
- // with any other parameters in the link that triggers view loading (parameters in the
39
- // link override parameters in the registration binding). This allows you to bind the
40
- // same view under different names with different parameters in order to parameterize
41
- // its behavior.
42
- //
43
- // @param {Object} name
44
- // @param {Object} constructor
45
- // @param {Object} params (optional)
46
- registerView: function(name, constructor, params) {
47
- this.views[name] = { constructor: constructor, params: (params || {}) };
48
- },
49
- // Stash a view, i.e. change the url to something meaningful, but do not show the
50
- // view based on this URL change. This is needed in cases where the device goes to
51
- // sleep, and then reloads upon awakening.
52
- stashView: function(params) {
53
- var local = {};
54
- local.view = params.view;
55
- if (params.filter) { local.filter = params.filter; }
56
- if (params.key) { local.key = params.key; }
57
- local.stash = true;
58
- var url = "#" + $.objToQueryStr(local);
59
-
60
- document.location = url;
61
- },
62
- // Show a view based on the supplied parameters. The only required parameter is "view"
63
- // which must reference a valid view name.
64
- //
65
- // @param {Object} params
66
- showView: function(params) {
67
- $.assert(params.view, "No view specified (use #view=<viewName>)", "Error: no view specified.");
68
- var binding = this.views[params.view];
69
-
70
- $.assert(binding, params.view + " is not a registered view name. Did you add it to views.js?", "Error: not a registered view.");
71
-
72
- // Merge binding parameters (from views.js) into any parameters that were supplied in the URL
73
- for (var prop in binding.params) {
74
- if (typeof params[prop] === 'undefined') {
75
- params[prop] = binding.params[prop];
76
- }
77
- }
78
- var view = new binding.constructor(params);
79
- $.assert(view.create, params.view + " doesn't have a create method and is not a valid view", "Error: not a valid view.");
80
-
81
- view.create();
82
- },
83
- // When the view is done initializing, it must call this method.
84
- appendView: function(view) {
85
- view.beforeViewAppended(view.params);
86
- view.buffer.html('empty');
87
-
88
- // if we have a reference to the previous view, remove() it
89
- if (this.currentView && this.currentView.element) {
90
- $(this.currentView.element).remove();
91
- }
92
-
93
- // re-assign this.curentView to the new view, and add it to the
94
- // Application.cache
95
- this.currentView = this.cache[History.currentHash()] = view;
96
-
97
- document.body.appendChild(view.element);
98
-
99
- if (view.params.scrollY) {
100
- window.scrollTo(0,view.params.scrollY);
101
- this.params.scrollY = 0;
102
- } else {
103
- window.scrollTo(0,0);
104
- }
105
- $.alignLoader();
106
-
107
- view.afterViewAppended(view.params);
108
-
109
- $(view.element).addClass('cached');
110
- if (!view.params.skip_metrics === true) this.sendMetrics();
111
- },
112
- sendMetrics: function() {
113
- var view = Application.currentView;
114
- Client.notify({
115
- "metric": view.getMetric(),
116
- "title": view.getTitle(),
117
- "buttons": view.getButtons(),
118
- "action": view.getAction(),
119
- "filter": view.getFilter(),
120
- "section": view.getSection()
121
- });
122
- },
123
- // The web application is receiving a callback from the client to set a value or execute some
124
- // behavior. If the view has an `onClientCallback` method, this will be executed first. It can
125
- // cancel any further event handling by returning `true`. Otherwise, the application sends the
126
- // event to all of the `clientCallbackHandlers` that are registered with the application, in the
127
- // order they were registered.
128
- //
129
- // @param {String} name
130
- // @param {Object} value
131
- onClientCallback: function(name, value) {
132
- var handled = false;
133
- var view = this.currentView;
134
- if (view && view.onClientCallback) {
135
- handled = view.onClientCallback.call(view, name, value);
136
- }
137
- if (!handled) {
138
- this.clientCallbackHandlers.forEach(function(handler) {
139
- handler.call(this, name, value);
140
- }, this);
141
- }
142
- },
143
- // load a view from cache or the server when we get a hashchange event
144
- _onHashChange: function(event, data) {
145
- // If the app is not initializing, and the view is stashed, do not do anything
146
- if (!this.app_is_initializing && data.stash) {
147
- console.log('=> App is not initializing & a view is stashed. RETURN');
148
- return;
149
- }
150
-
151
- $.assert(data.view, "No view specified (use #view=<viewName>)", "Error: no view specified.");
152
-
153
- var view = this.cache[History.currentHash()];
154
- view ? this.appendView(view) : this.showView(data);
155
-
156
- this.app_is_initializing = false;
157
- },
158
- // Initializes application functionality on page load, and kicks off loading the view.
159
- //
160
- // @private
161
- _onReady: function() {
162
- $(document.body)
163
- .on("hashchange", $.proxy(Application._onHashChange, this))
164
- .on("timerReachInterval", $.proxy(Application._onTimerReachedInterval, this));
165
- }
166
- });
167
-
168
- // Singleton.
169
- Application = new Application();
170
-
171
- Zepto(function($) {
172
- Application._onReady();
173
- });