concerto_weather 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,10 @@
2
2
  // attach handler to woeid so when it loses focus we can look it up
3
3
  // not dry, but no middle man
4
4
  function attachWoeidHandlers() {
5
- $('input#weather_config_woeid').on('blur', getWoeidInfo);
5
+ console.log('attaching woeid handlers');
6
6
 
7
+ $('input#weather_config_woeid').on('keyup', getWoeidInfo);
8
+
7
9
  function getWoeidInfo() {
8
10
  // will place name, district-county, province-state, country, woeid into 'div.woeid-info'
9
11
 
@@ -46,13 +48,13 @@ function attachWoeidHandlers() {
46
48
  // });
47
49
 
48
50
  // icky html table construction (with classes for bootstrap)
49
- places = "<table class=\"table table-striped table-condensed table-bordered\">";
51
+ places = "<table class=\"table table-condensed\">";
50
52
  places += "<thead><tr><th>Name</th><th>Type</th><th>District/County/Region</th><th>Province/State</th><th>Country</th><th>WOEID</th></th></thead>";
51
53
  places += "<tbody>";
52
54
  tbody = "";
53
55
  j.forEach(function(item) {
54
56
  // todo: need htmlencoding
55
- tbody += "<tr><td>" + htmlEncode(item.name) + "</td><td>" +
57
+ tbody += "<tr class=\"link-hl\" data-woeid=\"" + item.woeid + "\"><td>" + htmlEncode(item.name) + "</td><td>" +
56
58
  htmlEncode(item.placeTypeName.content) + "</td><td>" +
57
59
  htmlEncode((item.admin1 ? item.admin1.content : '')) + "</td><td>" +
58
60
  htmlEncode((item.admin2 ? item.admin2.content : '')) + "</td><td>" +
@@ -63,6 +65,18 @@ function attachWoeidHandlers() {
63
65
  info = places;
64
66
  }
65
67
  $(info_el).empty().html(info);
68
+ // wire up the clicks on the rows to populate the woeid and name fields
69
+ $(info_el).find('tr').on('click', function (e) {
70
+ $('input#weather_config_woeid').val($(this).data('woeid'));
71
+ var name = "";
72
+ $(this).find('td').slice(2,5).each(function () {
73
+ text = $(this).text().trim();
74
+ if (text != "") {
75
+ name += (name != "" ? ", " : "") + text;
76
+ }
77
+ });
78
+ $('input#weather_name').val(name);
79
+ });
66
80
  },
67
81
  error: function (xoptions, textStatus) {
68
82
  $(info_el).empty().html(info);
@@ -0,0 +1,3 @@
1
+ .woeid-info tbody td:hover {
2
+ cursor: pointer;
3
+ }
@@ -1,4 +1,5 @@
1
1
  <%= javascript_include_tag "concerto_weather/application" %>
2
+ <%= stylesheet_link_tag "concerto_weather/weather" %>
2
3
 
3
4
  <fieldset>
4
5
  <legend><span>Weather</span></legend>
@@ -8,7 +9,7 @@
8
9
  <div class="clearfix">
9
10
  <%= config.label :woeid, "Where On Earth ID (WOEID)" %>
10
11
  <div class="input">
11
- <%= config.text_field :woeid, :placeholder => '12180', :class => "input-small", :value => @content.config['woeid'] %>
12
+ <%= config.text_field :woeid, :placeholder => '2508215', :class => "input-small", :value => @content.config['woeid'] %>
12
13
  <br/>
13
14
  <i class="woeid-name"><%= @content.config['name'] %></i>
14
15
  </div>
@@ -1,4 +1,5 @@
1
1
  <dl>
2
+ <h1>Weather</h1>
2
3
  <dt>WOEID</dt>
3
4
  <dd><%= content.config['woeid'] %> - <%= content.config['name'] %></dd>
4
5
  <dt>Units</dt>
@@ -1,3 +1,3 @@
1
1
  module ConcertoWeather
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerto_weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-10 00:00:00.000000000 -04:00
12
+ date: 2013-08-22 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &70178862100900 !ruby/object:Gem::Requirement
17
+ requirement: &70156158473160 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.2.12
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70178862100900
25
+ version_requirements: *70156158473160
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sqlite3
28
- requirement: &70178862100220 !ruby/object:Gem::Requirement
28
+ requirement: &70156158472180 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70178862100220
36
+ version_requirements: *70156158472180
37
37
  description: Show the current weather and a short forecast in the sidebar of Concerto
38
38
  2.
39
39
  email:
@@ -45,6 +45,7 @@ files:
45
45
  - app/assets/javascripts/concerto_weather/application.js
46
46
  - app/assets/javascripts/concerto_weather/weather.js
47
47
  - app/assets/stylesheets/concerto_weather/application.css
48
+ - app/assets/stylesheets/concerto_weather/weather.css.scss
48
49
  - app/controllers/concerto_weather/application_controller.rb
49
50
  - app/helpers/concerto_weather/application_helper.rb
50
51
  - app/models/weather.rb