sports_db 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,34 @@
1
1
  var Application = Class.extend({
2
2
  initialize: function() {
3
3
 
4
- this.views = {};
5
- this.params = {};
6
- this.cache = {};
7
- this.currentView = null;
8
4
  this.clientCallbackHandlers = [];
9
- this.wrapper = $('#view_wrapper');
10
- this.buffer = $('#tmp');
11
- this.footer = $('#footer');
12
- this.client = {};
13
- this.setClientParams();
5
+ this.views = {};
6
+ this.params = {};
7
+ this.cache = {};
8
+ this.client = {};
9
+ this.features = {};
10
+ this.currentView = null;
11
+ this.wrapper = $('#view_wrapper');
12
+ this.buffer = $('#tmp');
13
+ this.footer = $('#footer');
14
+
15
+ this.parseClientParams();
14
16
 
15
17
  // Get hash params
16
18
  if (window.location.hash) {
17
- this.params = $.serialize(location.hash.slice(1));
19
+ this.params = $.deserialize(location.hash.slice(1));
18
20
  }
19
21
 
20
22
  this.params = $.extend(window.CONFIG, this.params);
21
23
 
22
- if (!this.params.clientSupportsClose) {
24
+ var client = this.client.ios ? 'ios' : 'android';
25
+
26
+ this.features.supportsClose = this.getConfigValue('clientSupportsClose', false);
27
+ this.features.supportsAlert = this.getConfigValue('clientSupportsAlert', false);
28
+ this.features.supportsNudgeNav = this.getConfigValue('clientSupportsNudgeNav', true);
29
+ this.features.hasFooter = this.getConfigValue('hasFooter', !!document.getElementById('footer'));
30
+
31
+ if (!this.features.supportsClose) {
23
32
  this.app_is_initializing = true;
24
33
  }
25
34
 
@@ -28,7 +37,10 @@ var Application = Class.extend({
28
37
  this.timer = new Timer($.proxy(this._fireTimerEvent, this), this.params.defaultTimer);
29
38
  this.timer.start();
30
39
  },
31
- setClientParams: function() {
40
+ getConfigValue: function(value, defaultValue) {
41
+ return this.params.hasOwnProperty(value) ? this.params[value] : defaultValue;
42
+ },
43
+ parseClientParams: function() {
32
44
  var q = $.deserialize( location.search.slice(1) );
33
45
 
34
46
  $.assert(q.client, '`client` param is required.');
@@ -68,10 +80,10 @@ var Application = Class.extend({
68
80
  // view based on this URL change. This is needed in cases where the device goes to
69
81
  // sleep, and then reloads upon awakening.
70
82
  stashView: function(params) {
71
- $.assert(!this.params.clientSupportsClose, "App should not be using Application.stashView method");
83
+ $.assert(!this.features.supportsClose, "App should not be using Application.stashView method");
72
84
 
73
85
  // TODO kill this method in all apps. Need client support.
74
- if (!this.params.clientSupportsClose) {
86
+ if (!this.features.supportsClose) {
75
87
  console.log('** Application.stashView');
76
88
  var local = {};
77
89
  local.view = params.view;
@@ -148,8 +160,7 @@ var Application = Class.extend({
148
160
  $(document.body).trigger('Application:viewAppended', [this.currentView.params]);
149
161
 
150
162
  // Show the footer
151
- // TODO do not show the footer if this is NFL3 v5 or above
152
- if (this.footer) {
163
+ if (this.footer && this.features.hasFooter) {
153
164
  this.footer.show();
154
165
  }
155
166
 
@@ -210,7 +221,7 @@ var Application = Class.extend({
210
221
  },
211
222
  // load a view from cache or the server when we get a hashchange event
212
223
  _onHashChange: function(event, memo) {
213
- if (!this.params.clientSupportsClose) {
224
+ if (!this.features.supportsClose) {
214
225
  // If the app is not initializing, and the view is stashed, do not do anything
215
226
  if (!this.app_is_initializing && memo.stash) {
216
227
  console.log('=> App is not initializing & a view is stashed. RETURN');
@@ -230,7 +241,7 @@ var Application = Class.extend({
230
241
  this.showView(memo);
231
242
  }
232
243
 
233
- if (!this.params.clientSupportsClose) {
244
+ if (!this.features.supportsClose) {
234
245
  this.app_is_initializing = false;
235
246
  }
236
247
  },
@@ -29,23 +29,27 @@
29
29
 
30
30
  window.scrollTo(0,1);
31
31
 
32
- if (Application.params.clientSupportsClose) {
33
- Client.notify({
34
- 'buttons': ($('.summary_link').size() < 2) ? 'Close:' : 'Close:NudgeNav',
35
- 'metric': getMetricPrefix(view) + '/Detail',
36
- 'refreshAd': true
37
- });
38
- } else {
39
- // Makes the back button to work
32
+ // Kind of ridiculous.
33
+ // Does the client support the close button?
34
+ var backOrClose = Application.features.supportsClose ? 'Close:' : 'Back:';
35
+ // Does the client support Nudge Nav. Note, on android while nudge nav is
36
+ // "supported", there are not nudge nav buttons in the toolbar (they are in
37
+ // the hardware/software menu button)
38
+ var nudgeOrNot = (Application.features.supportsNudgeNav && $('.summary_link').size() > 1) ? 'NudgeNav' : '';
39
+ var buttons = backOrClose + nudgeOrNot;
40
+
41
+ if (!Application.features.supportsClose) {
42
+ // Makes the back button to work on clients
43
+ // that don't support close.
40
44
  Application.stashView(view.params);
41
- Client.notify({
42
- "buttons": view.params.should_have_buttons,
43
- "metric": getMetricPrefix(view) + "/Detail",
44
- "title": view.getTitle(),
45
- 'refreshAd': true
46
- });
47
45
  }
48
-
46
+ Client.notify({
47
+ 'buttons': buttons,
48
+ 'metric': getMetricPrefix(view) + '/Detail',
49
+ // I'm not sure if title is reqd here or not. cstuart 2013-07-29
50
+ 'title': view.getTitle(),
51
+ 'refreshAd': true
52
+ });
49
53
  };
50
54
 
51
55
  var handlers = function() {
@@ -117,7 +121,7 @@
117
121
  });
118
122
  show_article({ 'id': params.digest });
119
123
  } else {
120
- if (Application.params.clientSupportsAlert) {
124
+ if (Application.features.supportsAlert) {
121
125
  Client.notify({
122
126
  'action': 'alert',
123
127
  'heading': 'An error occurred',
@@ -141,12 +145,16 @@
141
145
  $('.article_wrapper').hide();
142
146
  $(document.body).removeClass('displaying_article');
143
147
 
148
+ if (Application.features.hasFooter) {
149
+ Application.footer.show();
150
+ }
151
+
144
152
  handlers();
145
153
 
146
154
  if (opts.params.digest) {
147
155
  handle_notifications(opts.params);
148
156
  }
149
- if (!Application.params.clientSupportsClose) {
157
+ if (!Application.features.supportsClose) {
150
158
  Application.currentView.params.should_have_buttons = ($('.summary_link').size() < 2) ? "Back:" : "Back:NudgeNav";
151
159
  }
152
160
  }
@@ -164,6 +172,10 @@
164
172
  $('.article_wrapper').hide();
165
173
  $(document.body).removeClass('displaying_article');
166
174
 
175
+ if (Application.features.hasFooter){
176
+ Application.footer.show();
177
+ }
178
+
167
179
  window.scrollTo(0, view.params.pageYOffset);
168
180
 
169
181
  Client.notify({
@@ -30,7 +30,18 @@ body {
30
30
  font-size: $default_font_size;
31
31
  font-family: $default_font;
32
32
  margin: 0 auto;
33
+ color: $default_color;
34
+ }
35
+ #app_wrapper {
36
+ position: relative;
33
37
  }
38
+ #view_wrapper,
39
+ #footer {
40
+ position: relative;
41
+ padding: 5px;
42
+ }
43
+ #html_params { display: none; }
44
+
34
45
  body.ios {
35
46
  font-family: helvetica, sans-serif;
36
47
  text-rendering: optimizeLegibility;
@@ -39,7 +39,7 @@
39
39
  padding-bottom: 4px !important;
40
40
  text-align: left;
41
41
  vertical-align: top;
42
- font-size: 12px;
42
+ font-size: 13px;
43
43
  font-weight: bold;
44
44
  background-color: $zebra_strip_even;
45
45
  }
data/app/models/media.rb CHANGED
@@ -2,10 +2,10 @@ require 'digest/md5'
2
2
 
3
3
  class Media < ActiveRecord::Base
4
4
 
5
- # Create a hash based on publication time and title that should uniquely identify
5
+ # Create a hash based on publication time and title that should uniquely identify
6
6
  # this publication of the document.
7
7
  before_save :before_save_method
8
-
8
+
9
9
  def before_save_method
10
10
  if (self["title"].nil?)
11
11
  raise "This is an issue.... there's no title"
@@ -15,19 +15,19 @@ class Media < ActiveRecord::Base
15
15
  str = (self["published_at"].nil?) ? self["title"] : (self["title"] + self["published_at"].to_s)
16
16
  self["digest"] = Digest::SHA1.hexdigest(str)
17
17
  end
18
-
19
- def is_video?
18
+
19
+ def is_video?
20
20
  true
21
21
  end
22
22
 
23
23
  def is_twitter?
24
24
  false
25
25
  end
26
-
26
+
27
27
  def is_article?
28
28
  false
29
29
  end
30
-
30
+
31
31
  def thumbnail_url
32
32
  self.thumb_image_url
33
33
  end
@@ -1,3 +1,13 @@
1
+ # == Given a version number MAJOR.MINOR.PATCH, increment the:
2
+
3
+ # - MAJOR version when you make incompatible API changes,
4
+ # - MINOR version when you add functionality in a
5
+ # backwards-compatible manner, and
6
+ # - PATCH version when you make backwards-compatible bug fixes.
7
+ #
8
+ # Additional labels for pre-release and build metadata are
9
+ # available as extensions to the MAJOR.MINOR.PATCH format.
10
+
1
11
  module SportsDb
2
- VERSION = "0.2.6"
12
+ VERSION = "0.2.7"
3
13
  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.6
4
+ version: 0.2.7
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-07-26 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails