Permalink
Browse files

merge with gid branch

  • Loading branch information...
2 parents 5f87039 + 2add36a commit bf02507f368c84c7a659791680482411f36f460c @decioferreira decioferreira committed May 24, 2012
Showing with 574 additions and 189 deletions.
  1. +1 −0 Gemfile
  2. +15 −9 Gemfile.lock
  3. +2 −0 app/assets/javascripts/application.js
  4. +11 −0 app/assets/javascripts/backbone/mangrove_validation.js.coffee
  5. 0 app/assets/javascripts/backbone/models/.gitkeep
  6. +22 −0 app/assets/javascripts/backbone/models/island.js.coffee
  7. 0 app/assets/javascripts/backbone/routers/.gitkeep
  8. +32 −0 app/assets/javascripts/backbone/routers/islands_router.js.coffee
  9. 0 app/assets/javascripts/backbone/templates/.gitkeep
  10. +15 −0 app/assets/javascripts/backbone/templates/islands/edit.jst.ejs
  11. +14 −0 app/assets/javascripts/backbone/templates/islands/index.jst.ejs
  12. +5 −0 app/assets/javascripts/backbone/templates/islands/island.jst.ejs
  13. +15 −0 app/assets/javascripts/backbone/templates/islands/new.jst.ejs
  14. +3 −0 app/assets/javascripts/backbone/templates/islands/search_results.jst.ejs
  15. +7 −0 app/assets/javascripts/backbone/templates/islands/show.jst.ejs
  16. 0 app/assets/javascripts/backbone/views/.gitkeep
  17. BIN app/assets/javascripts/backbone/views/islands/.show_view.js.coffee.swo
  18. +24 −0 app/assets/javascripts/backbone/views/islands/edit_view.js.coffee
  19. +37 −0 app/assets/javascripts/backbone/views/islands/index_view.js.coffee
  20. +19 −0 app/assets/javascripts/backbone/views/islands/island_view.js.coffee
  21. +23 −0 app/assets/javascripts/backbone/views/islands/map_controls_view.js.coffee
  22. +111 −0 app/assets/javascripts/backbone/views/islands/map_view.js.coffee
  23. +18 −0 app/assets/javascripts/backbone/views/islands/search_results_view.js.coffee
  24. +15 −0 app/assets/javascripts/backbone/views/islands/search_view.js.coffee
  25. +8 −0 app/assets/javascripts/backbone/views/islands/show_view.js.coffee
  26. +6 −74 app/assets/javascripts/user_geo_edits.js.coffee
  27. +43 −1 app/assets/stylesheets/application.css.scss
  28. +1 −1 app/views/layouts/application.html.erb
  29. +127 −104 app/views/user_geo_edits/index.html.erb
  30. BIN vendor/cache/arel-3.0.1.gem
  31. BIN vendor/cache/arel-3.0.2.gem
  32. BIN vendor/cache/ejs-1.0.0.gem
  33. BIN vendor/cache/journey-1.0.2.gem
  34. BIN vendor/cache/journey-1.0.3.gem
  35. BIN vendor/cache/json-1.6.5.gem
  36. BIN vendor/cache/json-1.7.3.gem
  37. BIN vendor/cache/libv8-3.3.10.4-x86_64-darwin-11.gem
  38. BIN vendor/cache/mail-2.4.1.gem
  39. BIN vendor/cache/mail-2.4.4.gem
  40. BIN vendor/cache/mime-types-1.17.2.gem
  41. BIN vendor/cache/mime-types-1.18.gem
  42. BIN vendor/cache/multi_json-1.1.0.gem
  43. BIN vendor/cache/multi_json-1.3.5.gem
  44. BIN vendor/cache/rack-cache-1.1.gem
  45. BIN vendor/cache/rack-cache-1.2.gem
  46. BIN vendor/cache/rails-backbone-0.7.2.gem
  47. BIN vendor/cache/{sprockets-2.1.2.gem → sprockets-2.1.3.gem}
  48. BIN vendor/cache/tzinfo-0.3.31.gem
  49. BIN vendor/cache/tzinfo-0.3.33.gem
View
1 Gemfile
@@ -24,6 +24,7 @@ group :assets do
end
gem 'jquery-rails'
+gem 'rails-backbone'
gem 'devise'
#Handle background jobs
View
24 Gemfile.lock
@@ -64,7 +64,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.8)
archive-tar-minitar (0.5.2)
- arel (3.0.1)
+ arel (3.0.2)
bcrypt-ruby (3.0.1)
brightbox (2.3.9)
capistrano (>= 2.5)
@@ -101,6 +101,7 @@ GEM
railties (~> 3.1)
warden (~> 1.1.1)
diff-lcs (1.1.3)
+ ejs (1.0.0)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
@@ -119,24 +120,24 @@ GEM
highline (1.6.11)
hike (1.2.1)
i18n (0.6.0)
- journey (1.0.2)
+ journey (1.0.3)
jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
- json (1.6.5)
+ json (1.7.3)
launchy (2.1.0)
addressable (~> 2.2.6)
libv8 (3.3.10.4)
libwebsocket (0.1.3)
addressable
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
- mail (2.4.1)
+ mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.17.2)
- multi_json (1.1.0)
+ mime-types (1.18)
+ multi_json (1.3.5)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
@@ -150,7 +151,7 @@ GEM
pg (0.13.1)
polyglot (0.3.3)
rack (1.4.1)
- rack-cache (1.1)
+ rack-cache (1.2)
rack (>= 0.4)
rack-protection (1.2.0)
rack
@@ -166,6 +167,10 @@ GEM
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
+ rails-backbone (0.7.2)
+ coffee-script (~> 2.2.0)
+ ejs (~> 1.0.0)
+ railties (>= 3.1.0)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
@@ -231,7 +236,7 @@ GEM
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
- sprockets (2.1.2)
+ sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
@@ -245,7 +250,7 @@ GEM
typhoeus (0.2.4)
mime-types
mime-types
- tzinfo (0.3.31)
+ tzinfo (0.3.33)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
@@ -278,6 +283,7 @@ DEPENDENCIES
launchy
pg
rails (= 3.2.1)
+ rails-backbone
rake (= 0.9.2)
resque
rspec-rails (~> 2.6)
View
2 app/assets/javascripts/application.js
@@ -15,9 +15,11 @@
//= require jquery_ujs
//= require jquery.fancybox
//= require underscore
+//= require backbone
//= require bootstrap-generators
//= require wax.g
//= require cartodb-gmapsv3
+//= require backbone/mangrove_validation
//= require user_geo_edits
/* Override Bootstrap Tooltip show function so the tooltip doesn't get out of the page */
View
11 app/assets/javascripts/backbone/mangrove_validation.js.coffee
@@ -0,0 +1,11 @@
+#= require_self
+#= require_tree ./templates
+#= require_tree ./models
+#= require_tree ./views
+#= require_tree ./routers
+
+window.MangroveValidation =
+ Models: {}
+ Collections: {}
+ Routers: {}
+ Views: {}
View
0 app/assets/javascripts/backbone/models/.gitkeep
No changes.
View
22 app/assets/javascripts/backbone/models/island.js.coffee
@@ -0,0 +1,22 @@
+class MangroveValidation.Models.Island extends Backbone.Model
+ paramRoot: 'island'
+
+ defaults:
+ name: null
+
+class MangroveValidation.Collections.IslandsCollection extends Backbone.Collection
+ model: MangroveValidation.Models.Island
+ url: '/islands'
+
+ # Get the islands for the given search term
+ search: (query) ->
+
+ #TODO actually search
+ @reset([{name: 'result 1', island_id:1}, {name: 'result 2', island_id: 5}])
+
+ # Gets the island for the given ID, resets the collection to just that island and returns it
+ getAndResetBy: (id) ->
+
+ #TODO actually get the island from the DB
+ @reset([{name: 'result 1', island_id:1}])
+ return @.models[0]
View
0 app/assets/javascripts/backbone/routers/.gitkeep
No changes.
View
32 app/assets/javascripts/backbone/routers/islands_router.js.coffee
@@ -0,0 +1,32 @@
+class MangroveValidation.Routers.IslandsRouter extends Backbone.Router
+ initialize: (options) ->
+ @islands = new MangroveValidation.Collections.IslandsCollection()
+ @mapView = new MangroveValidation.Views.Islands.MapView(@islands)
+ @mapControlsView = new MangroveValidation.Views.Islands.MapControlsView()
+ @searchView = new MangroveValidation.Views.Islands.SearchView(@islands)
+ @searchResultsView = new MangroveValidation.Views.Islands.SearchResultsView(@islands)
+
+ routes:
+ "index" : "index"
+ ":id/edit" : "edit"
+ ":id" : "show"
+ ".*" : "index"
+
+ index: ->
+ @view = new MangroveValidation.Views.Islands.IndexView(islands: @islands)
+ $("#islands").html(@view.render().el)
+
+ # Tooltips
+ $('#map_menu .show-tooltip').tooltip({placement: 'bottom'})
+
+ show: (id) ->
+ island = @islands.getAndResetBy(id)
+
+ @view = new MangroveValidation.Views.Islands.ShowView(model: island)
+ $("#attributes-show").html(@view.render().el)
+
+ edit: (id) ->
+ island = @islands.get(id)
+
+ @view = new MangroveValidation.Views.Islands.EditView(model: island)
+ $("#islands").html(@view.render().el)
View
0 app/assets/javascripts/backbone/templates/.gitkeep
No changes.
View
15 app/assets/javascripts/backbone/templates/islands/edit.jst.ejs
@@ -0,0 +1,15 @@
+<h1>Edit island</h1>
+
+<form id="edit-island" name="island">
+ <div class="field">
+ <label for="name"> name:</label>
+ <input type="text" name="name" id="name" value="<%= name %>" >
+ </div>
+
+ <div class="actions">
+ <input type="submit" value="Update Island" />
+ </div>
+
+</form>
+
+<a href="#/index">Back</a>
View
14 app/assets/javascripts/backbone/templates/islands/index.jst.ejs
@@ -0,0 +1,14 @@
+<h1>Listing islands</h1>
+
+<table id="islands-table">
+ <tr>
+ <th>Name</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+</table>
+
+<br/>
+
+<a href="#/new">New Island</a>
View
5 app/assets/javascripts/backbone/templates/islands/island.jst.ejs
@@ -0,0 +1,5 @@
+<td><%= name %></td>
+
+<td><a href="#/">Show</td>
+<td><a href="#//edit">Edit</td>
+<td><a href="#//destroy" class="destroy">Destroy</a></td>
View
15 app/assets/javascripts/backbone/templates/islands/new.jst.ejs
@@ -0,0 +1,15 @@
+<h1>New island</h1>
+
+<form id="new-island" name="island">
+ <div class="field">
+ <label for="name"> name:</label>
+ <input type="text" name="name" id="name" value="<%= name %>" >
+ </div>
+
+ <div class="actions">
+ <input type="submit" value="Create Island" />
+ </div>
+
+</form>
+
+<a href="#/index">Back</a>
View
3 app/assets/javascripts/backbone/templates/islands/search_results.jst.ejs
@@ -0,0 +1,3 @@
+<% for(var i=0, il=results.length; i < il; i++) {%>
+ <li><%= results[i].name %></li>
+<% }%>
View
7 app/assets/javascripts/backbone/templates/islands/show.jst.ejs
@@ -0,0 +1,7 @@
+<p>
+ <b>Name:</b>
+ <%= name %>
+</p>
+
+
+<a href="#/index">Back</a>
View
0 app/assets/javascripts/backbone/views/.gitkeep
No changes.
View
BIN app/assets/javascripts/backbone/views/islands/.show_view.js.coffee.swo
Binary file not shown.
View
24 app/assets/javascripts/backbone/views/islands/edit_view.js.coffee
@@ -0,0 +1,24 @@
+MangroveValidation.Views.Islands ||= {}
+
+class MangroveValidation.Views.Islands.EditView extends Backbone.View
+ template : JST["backbone/templates/islands/edit"]
+
+ events :
+ "submit #edit-island" : "update"
+
+ update : (e) ->
+ e.preventDefault()
+ e.stopPropagation()
+
+ @model.save(null,
+ success : (island) =>
+ @model = island
+ window.location.hash = "/#{@model.id}"
+ )
+
+ render : ->
+ $(@el).html(@template(@model.toJSON() ))
+
+ this.$("form").backboneLink(@model)
+
+ return this
View
37 app/assets/javascripts/backbone/views/islands/index_view.js.coffee
@@ -0,0 +1,37 @@
+MangroveValidation.Views.Islands ||= {}
+
+class MangroveValidation.Views.Islands.IndexView extends Backbone.View
+ template: JST["backbone/templates/islands/index"]
+
+ events:
+ 'click #select-mangroves': 'selectMangroves'
+ 'click #select-corals': 'selectCorals'
+ 'click #select-salt-marshes': 'selectSaltMarshes'
+
+
+ initialize: () ->
+ @options.islands.bind('reset', @addAll)
+
+ selectMangroves: () ->
+ $('#map_menu .island-switcher .dropdown-menu a[data-island="mangroves"]').click()
+
+ selectCorals: () ->
+ $('#map_menu .island-switcher .dropdown-menu a[data-island="corals"]').click()
+
+ selectSaltMarshes: () ->
+ $('#map_menu .island-switcher .dropdown-menu a[data-island="saltmarshes"]').click()
+
+ addAll: () =>
+ @options.islands.each(@addOne)
+
+ addOne: (island) =>
+ view = new MangroveValidation.Views.Islands.IslandView({model : island})
+ @$("tbody").append(view.render().el)
+
+ render: =>
+ $(@el).html(@template(islands: @options.islands.toJSON() ))
+ @addAll()
+ # Tooltips
+ $('#map_menu .show-tooltip').tooltip({placement: 'bottom'})
+
+ return this
View
19 app/assets/javascripts/backbone/views/islands/island_view.js.coffee
@@ -0,0 +1,19 @@
+MangroveValidation.Views.Islands ||= {}
+
+class MangroveValidation.Views.Islands.IslandView extends Backbone.View
+ template: JST["backbone/templates/islands/island"]
+
+ events:
+ "click .destroy" : "destroy"
+
+ tagName: "tr"
+
+ destroy: () ->
+ @model.destroy()
+ this.remove()
+
+ return false
+
+ render: ->
+ $(@el).html(@template(@model.toJSON() ))
+ return this
View
23 app/assets/javascripts/backbone/views/islands/map_controls_view.js.coffee
@@ -0,0 +1,23 @@
+MangroveValidation.Views.Islands ||= {}
+
+class MangroveValidation.Views.Islands.MapControlsView extends Backbone.View
+ el: '#map_menu'
+
+ events:
+ 'click .help': 'showHelp'
+ 'click .zoom-in': 'zoomIn'
+ 'click .zoom-out': 'zoomOut'
+
+ initialize: ->
+ $('#landingModal').modal({backdrop: true, show: true})
+
+ showHelp: ->
+ $('#landingModal .modal-footer span.get-started').html('Continue with:')
+ $('#landingModal').modal('show')
+
+ zoomIn: ->
+ MangroveValidation.bus.trigger("zoomIn:MapControlsView")
+
+ zoomOut: ->
+ MangroveValidation.bus.trigger("zoomOut:MapControlsView")
+
View
111 app/assets/javascripts/backbone/views/islands/map_view.js.coffee
@@ -0,0 +1,111 @@
+MangroveValidation.Views.Islands ||= {}
+
+# = Map View
+# Creates and manages the map and showing of layers
+class MangroveValidation.Views.Islands.MapView extends Backbone.View
+ template: JST["backbone/templates/islands/map"]
+
+ initialize: (islands) ->
+ @islands = islands
+ # Google Maps
+ @map = new google.maps.Map($('#map_canvas')[0], window.VALIDATION.mapOptions)
+
+ # Bus binding
+ MangroveValidation.bus.bind("zoomIn:MapControlsView", @zoomIn)
+ MangroveValidation.bus.bind("zoomOut:MapControlsView", @zoomOut)
+
+ # Bind zoom behavior
+ google.maps.event.addListener @map, 'zoom_changed', @handleZoomChange
+
+ # CartoDB Layers
+ ## Show all islands in subtle colour
+ @showAllSubtleLayers()
+
+ # Bind to island events
+ @islands.on('reset', @render)
+
+ google.maps.event.addListener @map, 'click', @handleMapClick
+
+
+ # Adds cartodb layer of all islands in subtle colour
+ showAllSubtleLayers: ->
+ query = "SELECT the_geom_webmercator FROM #{window.CARTODB_TABLE}"
+ color = '#00FFFF'
+ layerParams =
+ map_canvas: 'map_canvas'
+ map: @map
+ user_name: 'carbon-tool'
+ table_name: window.CARTODB_TABLE
+ query: query
+ tile_style: "##{window.CARTODB_TABLE}{polygon-fill:#{color};polygon-opacity:0.5;line-width:0;line-opacity:0.6;line-color:#{color}} ##{window.CARTODB_TABLE} [zoom <= 7] {line-width:2} ##{window.CARTODB_TABLE} [zoom <= 4] {line-width:8}"
+
+ @allIslandsLayer = new google.maps.CartoDBLayer $.extend({}, layerParams)
+
+ renderCurrentIslands: ->
+ # Get the island IDs to filter by
+ islandIds = @islands.map (island) ->
+ island.get('island_id')
+ query = "SELECT the_geom_webmercator FROM #{window.CARTODB_TABLE} WHERE name in (#{islandIds.join()})"
+ color = '#FF0000'
+ layerParams =
+ map_canvas: 'map_canvas'
+ map: @map
+ user_name: 'carbon-tool'
+ table_name: window.CARTODB_TABLE
+ query: query
+ tile_style: "##{window.CARTODB_TABLE}{polygon-fill:#{color};polygon-opacity:0.9;line-width:0;line-opacity:0.8;line-color:#{color}} ##{window.CARTODB_TABLE} [zoom <= 7] {line-width:2} ##{window.CARTODB_TABLE} [zoom <= 4] {line-width:8}"
+
+ @currentIslandLayer = new google.maps.CartoDBLayer $.extend({}, layerParams)
+
+ handleMapClick: (event) =>
+ if true #TODO: Not in geom edit mode
+ @navigateToIslandAtPoint(event.latLng)
+ else
+ if @map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer] && window.VALIDATION.mapPolygon && window.VALIDATION.selectedLayer != 'hide'
+ path = window.VALIDATION.mapPolygon.getPath()
+ path.push(event.latLng)
+ if path.length > 0
+ $('#main_menu .erase-polygon').removeClass('disabled')
+ if path.length > 2
+ $('#main_menu .submit-polygon').removeClass('disabled')
+
+ # Asks cartobd for any islands at the given point
+ # and navigates to the island show path if one is found
+ navigateToIslandAtPoint: (point) ->
+ query = "SELECT name FROM #{window.CARTODB_TABLE}
+ WHERE ST_Intersects(the_geom, ST_GeomFromText('point(#{point.lng()} #{point.lat()})', 4326))
+ LIMIT 1"
+
+ $.ajax(
+ url: "#{window.CARTODB_API_ADDRESS}?q=#{query}"
+ success: (data) ->
+ if data.rows.length > 0
+ # If we find a island, redirect to it
+ window.router.navigate("#{data.rows[0].name}", true)
+ )
+
+ handleZoomChange: () =>
+ if window.VALIDATION.selectedLayer != 'hide' && @map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer]
+ $('#main_menu .zoom').addClass('hide')
+ $('#main_menu .select-layer').addClass('hide')
+ window.VALIDATION.mapPolygon.setEditable(true) if window.VALIDATION.mapPolygon
+ else if @map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer]
+ $('#main_menu .zoom').addClass('hide')
+ $('#main_menu .select-layer').removeClass('hide')
+ window.VALIDATION.mapPolygon.setEditable(false) if window.VALIDATION.mapPolygon
+ else
+ $('#main_menu .zoom').removeClass('hide')
+ $('#main_menu .select-layer').addClass('hide')
+ window.VALIDATION.mapPolygon.setEditable(false) if window.VALIDATION.mapPolygon
+
+ render: =>
+ @renderCurrentIslands()
+ this
+
+
+
+ zoomIn: =>
+ @map.setZoom(@map.getZoom() + 1)
+
+ zoomOut: =>
+ @map.setZoom(@map.getZoom() - 1)
View
18 app/assets/javascripts/backbone/views/islands/search_results_view.js.coffee
@@ -0,0 +1,18 @@
+MangroveValidation.Views.Islands ||= {}
+
+# = Search View
+# Visualise search results
+class MangroveValidation.Views.Islands.SearchResultsView extends Backbone.View
+ el: '#search-results'
+ template: JST["backbone/templates/islands/search_results"]
+
+ initialize: (islands) ->
+ @islands = islands
+
+ # Bind to island events
+ @islands.on('reset', @render)
+
+ render: =>
+ $(this.el).html(@template({results: @islands.toJSON()}))
+ $(this.el).show()
+
View
15 app/assets/javascripts/backbone/views/islands/search_view.js.coffee
@@ -0,0 +1,15 @@
+MangroveValidation.Views.Islands ||= {}
+
+# = Search View
+# Handles the search box
+class MangroveValidation.Views.Islands.SearchView extends Backbone.View
+ el: '#search-box'
+
+ events:
+ 'keyup #search-query': 'doSearch'
+
+ initialize: (islands) ->
+ @islands = islands
+
+ doSearch: =>
+ @islands.search(this.$('#search-query').val())
View
8 app/assets/javascripts/backbone/views/islands/show_view.js.coffee
@@ -0,0 +1,8 @@
+MangroveValidation.Views.Islands ||= {}
+
+class MangroveValidation.Views.Islands.ShowView extends Backbone.View
+ template: JST["backbone/templates/islands/show"]
+
+ render: ->
+ $(@el).html(@template(@model.toJSON() ))
+ return this
View
80 app/assets/javascripts/user_geo_edits.js.coffee
@@ -11,27 +11,16 @@ jQuery ->
# Check if user signed in
checkUserSignedIn()
- $('#select-mangroves').click ->
- $('#map_menu .layer-switcher .dropdown-menu a[data-layer="mangroves"]').click()
- $('#select-corals').click ->
- $('#map_menu .layer-switcher .dropdown-menu a[data-layer="corals"]').click()
- $('#select-salt-marshes').click ->
- $('#map_menu .layer-switcher .dropdown-menu a[data-layer="saltmarshes"]').click()
-
- # Tooltips
- $('#map_menu .show-tooltip').tooltip({placement: 'bottom'})
+ # All aboard the event bus!
+ MangroveValidation.bus = _.extend({}, Backbone.Events)
+ # Init routers
+ window.router = new MangroveValidation.Routers.IslandsRouter()
+ Backbone.history.start()
+
$('[href^=#]').click (e) ->
e.preventDefault()
- window.VALIDATION.initializeGoogleMaps()
- $('#landingModal').modal({backdrop: true, show: true})
-
- # Main menu buttons
- $('#map_menu .help').click ->
- $('#landingModal .modal-footer span.get-started').html('Continue with:')
- $('#landingModal').modal('show')
-
$('#main_menu .zoom').click ->
window.VALIDATION.map.setZoom(window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer])
@@ -180,11 +169,6 @@ jQuery ->
window.VALIDATION.mapPolygon.getPath().clear()
# Map menu buttons
- $('#map_menu .zoom-in').click ->
- window.VALIDATION.map.setZoom(window.VALIDATION.map.getZoom() + 1)
-
- $('#map_menu .zoom-out').click ->
- window.VALIDATION.map.setZoom(window.VALIDATION.map.getZoom() - 1)
$('#map_menu .hide-data-layers').click ->
if($(this).hasClass('active'))
@@ -245,56 +229,4 @@ jQuery ->
window.VALIDATION.map.setOptions({mapTypeId: google.maps.MapTypeId.HYBRID})
-window.VALIDATION.initializeGoogleMaps = ->
- # Google Maps
- window.VALIDATION.map = new google.maps.Map(document.getElementById('map_canvas'), window.VALIDATION.mapOptions)
-
- google.maps.event.addListener window.VALIDATION.map, 'zoom_changed', ->
- if window.VALIDATION.selectedLayer != 'hide' && window.VALIDATION.map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer]
- $('#main_menu .zoom').addClass('hide')
- $('#main_menu .select-layer').addClass('hide')
- $('#main_menu .actions').removeClass('hide')
- window.VALIDATION.mapPolygon.setEditable(true) if window.VALIDATION.mapPolygon
- else if window.VALIDATION.map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer]
- $('#main_menu .zoom').addClass('hide')
- $('#main_menu .select-layer').removeClass('hide')
- $('#main_menu .actions').addClass('hide')
- window.VALIDATION.mapPolygon.setEditable(false) if window.VALIDATION.mapPolygon
- else
- $('#main_menu .zoom').removeClass('hide')
- $('#main_menu .select-layer').addClass('hide')
- $('#main_menu .actions').addClass('hide')
- window.VALIDATION.mapPolygon.setEditable(false) if window.VALIDATION.mapPolygon
- # CartoDB Layers
- _.each window.VALIDATION.layers, (layer, layer_name) ->
- _.each layer.editions, (edition_properties, edition) ->
- name = switch edition
- when 'base' then layer_name
- when 'validated' then "#{layer_name}_validated"
- when 'added' then "#{layer_name}_added"
-
- if edition_properties.action?
- query = "SELECT the_geom_webmercator FROM #{window.CARTODB_TABLE} WHERE name=#{layer.id} AND status=#{edition_properties.status} AND action=#{edition_properties.action}"
- else
- query = "SELECT the_geom_webmercator FROM #{window.CARTODB_TABLE} WHERE name=#{layer.id} AND status=#{edition_properties.status}"
-
- window.VALIDATION["#{name}_params"] =
- map_canvas: 'map_canvas'
- map: window.VALIDATION.map
- user_name: 'carbon-tool'
- table_name: window.CARTODB_TABLE
- query: query
- tile_style: "##{window.CARTODB_TABLE}{polygon-fill:#{edition_properties.color};polygon-opacity:0.67;line-width:0;line-opacity:0.8;line-color:#{edition_properties.color}} ##{window.CARTODB_TABLE} [zoom <= 7] {line-width:2} ##{window.CARTODB_TABLE} [zoom <= 4] {line-width:8}"
-
- window.VALIDATION[name] = new google.maps.CartoDBLayer $.extend({}, window.VALIDATION["#{name}_params"])
- window.VALIDATION[name].hide() if edition_properties.hide
-
- google.maps.event.addListener window.VALIDATION.map, 'click', (event) ->
- if window.VALIDATION.map.getZoom() >= window.VALIDATION.minEditZoom[window.VALIDATION.selectedLayer] && window.VALIDATION.mapPolygon && window.VALIDATION.selectedLayer != 'hide'
- path = window.VALIDATION.mapPolygon.getPath()
- path.push(event.latLng)
- if path.length > 0
- $('#main_menu .erase-polygon').removeClass('disabled')
- if path.length > 2
- $('#main_menu .submit-polygon').removeClass('disabled')
View
44 app/assets/stylesheets/application.css.scss
@@ -61,8 +61,50 @@ body {
}
}
+.navbar {
+ margin-bottom:0;
+}
+
+#main-content {
+ height:100%;
+ position:relative;
+ overflow:hidden;
+
+ #map-content {
+ width:75%;
+ float:left;
+ }
+
+ #right-panel {
+ position:relative;
+ width:25%;
+ float:right;
+ height:100%;
+ background-color: #323232;
+ color: #EEE;
+
+ #search-results {
+ display:none;
+ position: absolute;
+ right: 29px;
+ z-index:1;
+ background-color: white;
+ width: 200px;
+ padding: 5px;
+ margin-left: 0;
+ list-style-type: none;
+ }
+ #attributes-show {
+ padding: 10px;
+ margin-top: 50px;
+ }
+ }
+}
+
+
#map_canvas {
- height: 100%
+ width:100%;
+ height:100%;
}
#main_menu {
View
2 app/views/layouts/application.html.erb
@@ -19,6 +19,6 @@
</head>
<body>
<%= yield %>
-<%= javascript_tag "window.CARTODB_TABLE = '#{APP_CONFIG['cartodb_table']}';" %>
+<%= javascript_tag "window.CARTODB_TABLE = '#{APP_CONFIG['cartodb_table']}';window.CARTODB_API_ADDRESS='http://carbon-tool.cartodb.com/api/v1/sql'" %>
</body>
</html>
View
231 app/views/user_geo_edits/index.html.erb
@@ -1,124 +1,147 @@
-<div id="map_canvas" style="width:100%; height:100%"></div>
+<div class="navbar">
+ <div class="navbar-inner">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </a>
+ <a class="brand" href="/">Global Islands Database</a>
+ <div class="nav-collapse collapse">
+ <ul class="nav">
+ <li class="active">
+ <a href="#">About</a>
+ </li>
+ <li>
+ <a href="#">Help</a>
+ </li>
+ <li>
+ <a href="#">Logout</a>
+ </li>
+ </ul>
+ <div id='search-box' class='pull-right'>
+ <form class="navbar-search" action="">
+ <input id='search-query' type="text" class="search-query span3" placeholder="Search">
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
-<a href="http://www.unep-wcmc.org" target="_blank" id="logo"></a>
+<div id='main-content'>
+ <div id='map-content' style='position:relative; height:100%'>
+ <div id="map_canvas" style="width:100%; height:100%"></div>
-<div id="alert-message" style="display:none">
- <div class="alert"></div>
-</div>
+ <a href="http://www.unep-wcmc.org" target="_blank" id="logo"></a>
-<div id="map_menu">
- <div id='layers-box' class='well'>
- <h2>Habitat validation tool</h3>
- <div class='control-row'>
- <div class="btn-group layer-switcher">
- <a class="btn dropdown-toggle layers-selection" data-toggle="dropdown" href="#">
- <span id="selected-layer">Mangroves</span>
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <li><a href="#" data-layer="mangroves">Mangroves</a></li>
- <li><a href="#" data-layer="corals">Corals</a></li>
- <li><a href="#" data-layer="saltmarshes">Salt marshes</a></li>
- </ul>
- </div>
- <a href="#" class="hide-data-layers btn show-tooltip" data-toggle="button" title="Hide layers"><i class="icon-eye-close"></i></a>
+ <div id="alert-message" style="display:none">
+ <div class="alert"></div>
</div>
- <div class='control-row'>
- <%= image_tag 'layer_legend.png'%>
- <br/>
- <div class="btn-group layer-switcher " data-toggle="buttons-radio">
- <button class="use-satellite btn show-tooltip btn-info active" title="Use satellite base layer">Satellite</button>
- <button class="use-hybrid btn show-tooltip" title="Use hybrid base layer">Hybrid</button>
+ <div id="map_menu">
+ <div id='layers-box' class='well'>
+ <div class='control-row'>
+ <%= image_tag 'layer_legend.png'%>
+ <br/>
+ <div class="btn-group layer-switcher " data-toggle="buttons-radio">
+ <button class="use-satellite btn show-tooltip btn-info active" title="Use satellite base layer">Satellite</button>
+ <button class="use-hybrid btn show-tooltip" title="Use hybrid base layer">Hybrid</button>
+ </div>
+ </div>
+
+ <div class='control-row break'>
+ <div class="btn-group zoom-group">
+ <a href="#" class="zoom-in btn show-tooltip" title="Zoom in"><i class="icon-plus"></i></a>
+ <a href="#" class="zoom-out btn show-tooltip" title="Zoom out"><i class="icon-minus"></i></a>
+ </div>
+ <a href="#" class="help btn show-tooltip btn-info" title="Information"><i class="icon-question-sign icon-white"></i></a>
+ <a href="/users/sign_out" class="logout btn btn-danger" style="display:none" data-method="delete" rel="nofollow">Logout</a>
+ </div>
</div>
+
</div>
- <div class='control-row break'>
- <div class="btn-group zoom-group">
- <a href="#" class="zoom-in btn show-tooltip" title="Zoom in"><i class="icon-plus"></i></a>
- <a href="#" class="zoom-out btn show-tooltip" title="Zoom out"><i class="icon-minus"></i></a>
+ <div id="main_menu">
+ <div class="actions well hide">
+ <div id='tools'>
+ <a href="#" class="validate btn btn-success"><i class="icon-ok icon-white"></i><br/>Validate</a>
+ <div class="btn-group">
+ <a href="#" class="add-area btn btn-primary"><i class="icon-plus icon-white"></i><br/>Add New</a>
+ <a href="#" class="delete-area btn btn-danger"><i class="icon-trash icon-white"></i><br/>Delete</a>
+ </div>
+ </div>
+ <div class="submit-or-erase btn-group hide">
+ <div class="control-group">
+ <div class="controls">
+ <select class="knowledge">
+ <option value="">Please select evidence type</option>
+ <option value="imagery">Underlying imagery in browser</option>
+ <option value="local data">Local data</option>
+ <option value="local knowledge">Local knowledge</option>
+ </select>
+ </div>
+ </div>
+ <div class="buttons">
+ <a href="#" class="submit-polygon btn btn-inverse disabled"><i class="icon-check icon-white"></i> Submit</a>
+ <a href="#" class="erase-polygon btn btn-danger disabled"><i class="icon-repeat icon-white"></i> Erase</a>
+ </div>
+ </div>
</div>
- <a href="#" class="help btn show-tooltip btn-info" title="Information"><i class="icon-question-sign icon-white"></i></a>
- <a href="/users/sign_out" class="logout btn btn-danger" style="display:none" data-method="delete" rel="nofollow">Logout</a>
+ <a href="#" class="zoom btn btn-inverse">Zoom in to region to start editing</a>
</div>
- </div>
-
-</div>
-<div id="main_menu">
- <div class="actions well hide">
- <div id='tools'>
- <a href="#" class="validate btn btn-success"><i class="icon-ok icon-white"></i><br/>Validate</a>
- <div class="btn-group">
- <a href="#" class="add-area btn btn-primary"><i class="icon-plus icon-white"></i><br/>Add New</a>
- <a href="#" class="delete-area btn btn-danger"><i class="icon-trash icon-white"></i><br/>Delete</a>
+ <!-- Modals -->
+ <div class="modal" id="landingModal">
+ <div class="modal-header">
+ <a class="close" data-dismiss="modal">×</a>
+ <h3>Habitat validation tool</h3>
</div>
- </div>
- <div class="submit-or-erase btn-group hide">
- <div class="control-group">
- <div class="controls">
- <select class="knowledge">
- <option value="">Please select evidence type</option>
- <option value="imagery">Underlying imagery in browser</option>
- <option value="local data">Local data</option>
- <option value="local knowledge">Local knowledge</option>
- </select>
+ <div class="modal-body">
+ <div class="logos">
+ <%= link_to image_tag('unep_wcmc_logo.png'), 'http://unep-wcmc.org/' %>
+ <%= link_to image_tag('icri_logo.gif'), 'http://www.icriforum.org/' %>
+ <%= link_to image_tag('usdos_seal_logo.png'), 'http://www.state.gov/' %>
+ <%= link_to image_tag('cclme.png'), 'http://www.canarycurrent.org/' %>
</div>
+ <p>This tool allows basic editing and validation of coastal habitat data. This is a beta version with limited functionality, being tested with the Global Distribution of Coral Reefs (2010) and the African subset of the USGS Global Distribution of Mangrove (2000) datasets. The original versions of the datasets can be downloaded from <%= link_to 'http://data.unep-wcmc.org/'%> </p>
+ <p>Validation of the datasets should be based on:</p>
+ <ol clas="roman">
+ <li>Local knowledge of the habitat</li>
+ <li>Obvious omission/commission errors in the data</li>
+ <li>Basic user interpretation of the underlying imagery</li>
+ </ol>
+ <p>This tool will ultimately improve the accuracy of coastal habitat datasets, to support better decision-making. This tool forms part of our work under the <em>Better Data, Better Decisions Initiative</em>.</p>
+ <h3>Get started!</h3>
+ <p>Simply choose the dataset you wish to edit and zoom in to the desired area. Select the type of editing that you want to undertake: Validate (agree with existing areas), Add or Delete, using the tool bar on the top right of the screen, and then start editing.</p>
+ <h3>Editing tips and advice</h3>
+ <p>All edits should be based on obvious errors/omissions in the data.</p>
+ <p>Where there is any ambiguity, no edits/additions should be made.</p>
+ <p>We are currently unable to show the different spectral bands so it is not currently possible to distinguish e.g. mangroves and terrestrial forest cover, without in-depth local knowledge of the area.</p>
+ <p>The underlying imagery is not from a specific time period, so there are limitations to the temporal resolution of the validation.</p>
+ <p>Future functionalities will allow users to:</p>
+ <ol class="roman">
+ <li>Specify the justification for the edit (e.g. imagery interpretation, expert knowledge).</li>
+ <li>Upload their own spatial data for integration into the community dataset.</li>
+ <li>Download subsets of the dataset according to their own defined area of interest.</li>
+ <li>View imagery with explicit dates to facilitate local habitat change detection analyses.</li>
+ </ol>
+ <p>For any feedback or questions, please email <%= mail_to "mads@unep-wcmc.org" %>.</p>
</div>
- <div class="buttons">
- <a href="#" class="submit-polygon btn btn-inverse disabled"><i class="icon-check icon-white"></i> Submit</a>
- <a href="#" class="erase-polygon btn btn-danger disabled"><i class="icon-repeat icon-white"></i> Erase</a>
+ <div class="modal-footer">
+ <a href="#" id="select-salt-marshes" class="btn btn-primary" data-dismiss="modal">Salt Marshes</a>
+ <a href="#" id="select-corals" class="btn btn-primary" data-dismiss="modal">Corals</a>
+ <a href="#" id="select-mangroves" class="btn btn-primary" data-dismiss="modal">Mangroves</a>
+ <h3 class="get-started">Get started with</h3>
</div>
</div>
- </div>
- <a href="#" class="zoom btn btn-inverse">Zoom in to region to start editing</a>
-</div>
-<!-- Modals -->
-<div class="modal" id="landingModal">
- <div class="modal-header">
- <a class="close" data-dismiss="modal">×</a>
- <h3>Habitat validation tool</h3>
- </div>
- <div class="modal-body">
- <div class="logos">
- <%= link_to image_tag('unep_wcmc_logo.png'), 'http://unep-wcmc.org/' %>
- <%= link_to image_tag('icri_logo.gif'), 'http://www.icriforum.org/' %>
- <%= link_to image_tag('usdos_seal_logo.png'), 'http://www.state.gov/' %>
- <%= link_to image_tag('cclme.png'), 'http://www.canarycurrent.org/' %>
- </div>
- <p>This tool allows basic editing and validation of coastal habitat data. This is a beta version with limited functionality, being tested with the Global Distribution of Coral Reefs (2010) and the African subset of the USGS Global Distribution of Mangrove (2000) datasets. The original versions of the datasets can be downloaded from <%= link_to 'http://data.unep-wcmc.org/'%> </p>
- <p>Validation of the datasets should be based on:</p>
- <ol clas="roman">
- <li>Local knowledge of the habitat</li>
- <li>Obvious omission/commission errors in the data</li>
- <li>Basic user interpretation of the underlying imagery</li>
- </ol>
- <p>This tool will ultimately improve the accuracy of coastal habitat datasets, to support better decision-making. This tool forms part of our work under the <em>Better Data, Better Decisions Initiative</em>.</p>
- <h3>Get started!</h3>
- <p>Simply choose the dataset you wish to edit and zoom in to the desired area. Select the type of editing that you want to undertake: Validate (agree with existing areas), Add or Delete, using the tool bar on the top right of the screen, and then start editing.</p>
- <h3>Editing tips and advice</h3>
- <p>All edits should be based on obvious errors/omissions in the data.</p>
- <p>Where there is any ambiguity, no edits/additions should be made.</p>
- <p>We are currently unable to show the different spectral bands so it is not currently possible to distinguish e.g. mangroves and terrestrial forest cover, without in-depth local knowledge of the area.</p>
- <p>The underlying imagery is not from a specific time period, so there are limitations to the temporal resolution of the validation.</p>
- <p>Future functionalities will allow users to:</p>
- <ol class="roman">
- <li>Specify the justification for the edit (e.g. imagery interpretation, expert knowledge).</li>
- <li>Upload their own spatial data for integration into the community dataset.</li>
- <li>Download subsets of the dataset according to their own defined area of interest.</li>
- <li>View imagery with explicit dates to facilitate local habitat change detection analyses.</li>
- </ol>
- <p>For any feedback or questions, please email <%= mail_to "mads@unep-wcmc.org" %>.</p>
+ <div class="modal hide" id="authModal"></div>
+
+ <div style="display: none;"><%= render 'form' %></div>
</div>
- <div class="modal-footer">
- <a href="#" id="select-salt-marshes" class="btn btn-primary" data-dismiss="modal">Salt Marshes</a>
- <a href="#" id="select-corals" class="btn btn-primary" data-dismiss="modal">Corals</a>
- <a href="#" id="select-mangroves" class="btn btn-primary" data-dismiss="modal">Mangroves</a>
- <h3 class="get-started">Get started with</h3>
+
+ <div id='right-panel'>
+ <ul id='search-results'></ul>
+ <div id='attributes-show'></div>
</div>
</div>
-
-<div class="modal hide" id="authModal"></div>
-
-<div style="display: none;"><%= render 'form' %></div>
View
BIN vendor/cache/arel-3.0.1.gem
Binary file not shown.
View
BIN vendor/cache/arel-3.0.2.gem
Binary file not shown.
View
BIN vendor/cache/ejs-1.0.0.gem
Binary file not shown.
View
BIN vendor/cache/journey-1.0.2.gem
Binary file not shown.
View
BIN vendor/cache/journey-1.0.3.gem
Binary file not shown.
View
BIN vendor/cache/json-1.6.5.gem
Binary file not shown.
View
BIN vendor/cache/json-1.7.3.gem
Binary file not shown.
View
BIN vendor/cache/libv8-3.3.10.4-x86_64-darwin-11.gem
Binary file not shown.
View
BIN vendor/cache/mail-2.4.1.gem
Binary file not shown.
View
BIN vendor/cache/mail-2.4.4.gem
Binary file not shown.
View
BIN vendor/cache/mime-types-1.17.2.gem
Binary file not shown.
View
BIN vendor/cache/mime-types-1.18.gem
Binary file not shown.
View
BIN vendor/cache/multi_json-1.1.0.gem
Binary file not shown.
View
BIN vendor/cache/multi_json-1.3.5.gem
Binary file not shown.
View
BIN vendor/cache/rack-cache-1.1.gem
Binary file not shown.
View
BIN vendor/cache/rack-cache-1.2.gem
Binary file not shown.
View
BIN vendor/cache/rails-backbone-0.7.2.gem
Binary file not shown.
View
BIN vendor/cache/sprockets-2.1.2.gem → vendor/cache/sprockets-2.1.3.gem
Binary file not shown.
View
BIN vendor/cache/tzinfo-0.3.31.gem
Binary file not shown.
View
BIN vendor/cache/tzinfo-0.3.33.gem
Binary file not shown.

0 comments on commit bf02507

Please sign in to comment.