Permalink
Browse files

much better widget structure

  • Loading branch information...
1 parent bd5e5e8 commit 2dcbd6c55e2717c7936e3e46447a6ecec869b202 @kristianmandrup committed Sep 7, 2012
Showing with 804 additions and 48 deletions.
  1. +9 −4 Gemfile
  2. +44 −15 Gemfile.lock
  3. +47 −0 app/assets/for_later/search/auto_complete.js.coffee
  4. +161 −0 app/assets/for_later/search/gmaps.js
  5. +49 −0 app/assets/for_later/search/gmaps/geocoder.coffee
  6. 0 app/assets/{javascripts → for_later}/wijmo/cultures/globalize.cultures.js
  7. 0 app/assets/{javascripts → for_later}/wijmo/globalize.min.js
  8. 0 app/assets/{javascripts → for_later}/wijmo/knockout.wijmo.js
  9. 0 app/assets/images/property/{big_ads → cover_ads}/ad1.jpg
  10. 0 app/assets/images/property/{big_ads → cover_ads}/ad2.jpg
  11. 0 app/assets/images/property/{big_ads → cover_ads}/ad3.jpg
  12. +8 −2 app/assets/javascripts/application.js
  13. +4 −0 app/assets/javascripts/widgets/bottom_bar_widget.coffee
  14. +4 −0 app/assets/javascripts/widgets/cover/sliding_ads_widget.coffee
  15. +4 −0 app/assets/javascripts/widgets/cover_widget.coffee
  16. +4 −0 app/assets/javascripts/widgets/properties/featured_widget.coffee
  17. +4 −0 app/assets/javascripts/widgets/properties/list_widget.coffee
  18. +4 −0 app/assets/javascripts/widgets/properties/map_widget.coffee
  19. +4 −0 app/assets/javascripts/widgets/properties/similar_widget.coffee
  20. +4 −0 app/assets/javascripts/widgets/property/description_widget.coffee
  21. +4 −0 app/assets/javascripts/widgets/property/location_widget.coffee
  22. +4 −0 app/assets/javascripts/widgets/property/period_widget.coffee
  23. +4 −0 app/assets/javascripts/widgets/property/photo_gallery_widget.coffee
  24. +4 −0 app/assets/javascripts/widgets/property/social_widget.coffee
  25. +4 −0 app/assets/javascripts/widgets/property_widget.coffee
  26. +7 −0 app/assets/javascripts/widgets/top_bar/form/autocomplete_widget.coffee
  27. +1 −1 app/assets/stylesheets/application.css.scss
  28. +24 −0 app/assets/stylesheets/gmaps4rails.css
  29. +1 −0 app/assets/stylesheets/widgets/bottom_bar_widget.css
  30. +1 −0 app/assets/stylesheets/widgets/cover/sliding_ads_widget.css
  31. +1 −0 app/assets/stylesheets/widgets/cover_widget.css
  32. +1 −0 app/assets/stylesheets/widgets/properties/featured_widget.css
  33. +1 −0 app/assets/stylesheets/widgets/properties/list_widget.css
  34. +1 −0 app/assets/stylesheets/widgets/properties/map_widget.css
  35. +1 −0 app/assets/stylesheets/widgets/properties/similar_widget.css
  36. +1 −0 app/assets/stylesheets/widgets/property/description_widget.css
  37. +1 −0 app/assets/stylesheets/widgets/property/location_widget.css
  38. +1 −0 app/assets/stylesheets/widgets/property/period_widget.css
  39. +1 −0 app/assets/stylesheets/widgets/property/photo_gallery_widget.css
  40. +1 −0 app/assets/stylesheets/widgets/property/social_widget.css
  41. +1 −0 app/assets/stylesheets/widgets/property_widget.css
  42. +1 −1 app/controllers/application_controller.rb
  43. +6 −0 app/controllers/home_controller.rb
  44. +5 −0 app/controllers/properties_controller.rb
  45. +0 −4 app/helpers/application_helper.rb
  46. +4 −0 app/views/gmaps4rails/_gmaps4rails_lib.html.haml
  47. +3 −1 app/views/home/page.html.haml
  48. +3 −1 app/views/layouts/application.html.haml
  49. +7 −0 app/widgets/bottom_bar/bottom_bar_widget.rb
  50. +5 −0 app/widgets/bottom_bar/views/show.html.haml
  51. +6 −0 app/widgets/cover/sliding_ads/views/show.html.haml
  52. +7 −0 app/widgets/cover/sliding_ads_widget.rb
  53. +4 −0 app/widgets/cover/views/show.html.haml
  54. +11 −0 app/widgets/cover_widget.rb
  55. +5 −0 app/widgets/properties/featured/views/show.html.haml
  56. +7 −0 app/widgets/properties/featured_widget.rb
  57. +7 −0 app/widgets/properties/list/list_widget.rb
  58. +5 −0 app/widgets/properties/list/views/show.html.haml
  59. +7 −0 app/widgets/properties/map/map_widget.rb
  60. +5 −0 app/widgets/properties/map/views/show.html.haml
  61. +7 −0 app/widgets/properties/similar/similar_widget.rb
  62. +5 −0 app/widgets/properties/similar/views/show.html.haml
  63. +7 −0 app/widgets/property/description/description_widget.rb
  64. +5 −0 app/widgets/property/description/views/show.html.haml
  65. +7 −0 app/widgets/property/location/location_widget.rb
  66. +5 −0 app/widgets/property/location/views/show.html.haml
  67. +7 −0 app/widgets/property/period/period_widget.rb
  68. +5 −0 app/widgets/property/period/views/show.html.haml
  69. +7 −0 app/widgets/property/photo_gallery/photo_gallery_widget.rb
  70. +5 −0 app/widgets/property/photo_gallery/views/show.html.haml
  71. +7 −0 app/widgets/property/property_widget.rb
  72. +7 −0 app/widgets/property/social/social_widget.rb
  73. +5 −0 app/widgets/property/social/views/show.html.haml
  74. +5 −0 app/widgets/property/views/show.html.haml
  75. +0 −7 app/widgets/top_bar/form/form_widget.rb
  76. +24 −0 app/widgets/top_bar/form_widget.rb
  77. +0 −7 app/widgets/top_bar/top_bar_widget.rb
  78. +8 −4 app/widgets/top_bar/views/display.html.haml
  79. +16 −0 app/widgets/top_bar_widget.rb
  80. +3 −1 gemfiles/Assets.gemfile
  81. +12 −0 spec/widgets/bottom_bar/bottom_bar_widget_spec.rb
  82. +12 −0 spec/widgets/cover/cover_widget_spec.rb
  83. +12 −0 spec/widgets/cover/sliding_ads/sliding_ads_widget_spec.rb
  84. +12 −0 spec/widgets/properties/featured/featured_widget_spec.rb
  85. +12 −0 spec/widgets/properties/list/list_widget_spec.rb
  86. +12 −0 spec/widgets/properties/map/map_widget_spec.rb
  87. +12 −0 spec/widgets/properties/similar/similar_widget_spec.rb
  88. +12 −0 spec/widgets/property/description/description_widget_spec.rb
  89. +12 −0 spec/widgets/property/location/location_widget_spec.rb
  90. +12 −0 spec/widgets/property/period/period_widget_spec.rb
  91. +12 −0 spec/widgets/property/photo_gallery/photo_gallery_widget_spec.rb
  92. +12 −0 spec/widgets/property/property_widget_spec.rb
  93. +12 −0 spec/widgets/property/social/social_widget_spec.rb
View
13 Gemfile
@@ -3,7 +3,7 @@ source :rubygems
gem 'rails', '~> 3.2'
gem 'fabrication'
-gem 'gmaps4rails'
+gem 'gmaps4rails', path: '/Users/kmandrup/private/repos/Google-Maps-for-Rails'
gem 'world-flags', '~> 0.6.3'
gem 'pictos-icons', '>= 0.2.0'
@@ -14,18 +14,21 @@ gem 'easy_as_pie', '>= 0.1.0'
gem 'rails-gallery', '~> 0.2.0'
-# gem 'partializer', '~> 0.1.0'
+gem 'partializer', '~> 0.1.0'
-gem 'apotomo', '~> 1.2.3', git: 'git://github.com/kristianmandrup/apotomo.git'
+gem 'cells', path: '/Users/kmandrup/private/repos/cells'
+gem 'apotomo', '~> 1.2.3', path: '/Users/kmandrup/private/repos/apotomo' # git: 'git://github.com/kristianmandrup/apotomo.git'
gem "social-buttons", '~> 0.3.0', require: 'social_buttons'
gem 'lorem_ipsum'
gem "jquery-rails"
+gem 'gmaps-autocomplete-rails', '~> 0.1.1', git: 'git://github.com/kristianmandrup/gmaps-autocomplete-rails.git'
+
gem 'rails3-jquery-autocomplete', git: 'git://github.com/kristianmandrup/rails3-jquery-autocomplete.git'
-gem 'jquery-ui-rails'
+
# gem 'jquery_ui_rails_helpers'
gem 'jquery-ui-bootstrap-rails', git: 'git://github.com/kristianmandrup/jquery-ui-bootstrap-rails.git'
@@ -61,6 +64,8 @@ gem 'draper'
gem 'mongoid', '~> 3'
+gem 'places' # Google Places API :)
+
gem 'pry'
gem 'picturefill-rails'
View
59 Gemfile.lock
@@ -11,15 +11,6 @@ GIT
timecop (0.3.5)
GIT
- remote: git://github.com/kristianmandrup/apotomo.git
- revision: 54323193581bbf7d7267594b81f497a19842a491
- specs:
- apotomo (1.2.4)
- cells (>= 3.6.7)
- hooks (~> 0.2.0)
- onfire (~> 0.2.0)
-
-GIT
remote: git://github.com/kristianmandrup/compass-twitter-bootstrap.git
revision: 01ae251205af3e59f7f8570e27d6f05b08ae4dde
specs:
@@ -36,6 +27,13 @@ GIT
sass (>= 3.0)
GIT
+ remote: git://github.com/kristianmandrup/gmaps-autocomplete-rails.git
+ revision: 2356d64f91d2bfafd7d112d089bca88d167431ab
+ specs:
+ gmaps-autocomplete-rails (0.1.1)
+ rails (>= 3.0.0)
+
+GIT
remote: git://github.com/kristianmandrup/green_monkey.git
revision: e7615b7adf7b8705f79084ca61548633d36b9417
specs:
@@ -78,6 +76,26 @@ GIT
therubyracer (~> 0.10.2)
PATH
+ remote: /Users/kmandrup/private/repos/Google-Maps-for-Rails
+ specs:
+ gmaps4rails (1.5.5)
+
+PATH
+ remote: /Users/kmandrup/private/repos/apotomo
+ specs:
+ apotomo (1.2.4)
+ cells (>= 3.6.7)
+ hooks (~> 0.2.0)
+ onfire (~> 0.2.0)
+
+PATH
+ remote: /Users/kmandrup/private/repos/cells
+ specs:
+ cells (3.8.5)
+ actionpack (~> 3.0)
+ railties (~> 3.0)
+
+PATH
remote: /Users/kmandrup/private/repos/semantic-sass-bootstrap
specs:
semantic-sass-bootstrap (0.1.1)
@@ -125,17 +143,14 @@ GEM
railties (>= 3.0)
bourbon (2.1.1)
sass (>= 3.1)
- builder (3.0.0)
+ builder (3.0.2)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- cells (3.8.5)
- actionpack (~> 3.0)
- railties (~> 3.0)
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
chronic (0.7.0)
@@ -186,7 +201,6 @@ GEM
formtastic (~> 2.2)
formtastic-bootstrap
fssm (0.2.9)
- gmaps4rails (1.5.5)
growl (1.0.3)
haml (3.1.7)
haml-rails (0.3.4)
@@ -201,6 +215,9 @@ GEM
hashie (1.2.0)
hike (1.2.1)
hooks (0.2.1)
+ httparty (0.8.3)
+ multi_json (~> 1.0)
+ multi_xml
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.1)
@@ -239,13 +256,21 @@ GEM
tzinfo (~> 0.3.22)
moped (1.2.1)
multi_json (1.3.6)
+ multi_xml (0.5.1)
nokogiri (1.5.5)
numerizer (0.1.1)
onfire (0.2.0)
origin (1.0.8)
+ partializer (0.1.2)
+ hashie
+ rails (>= 3.0.0)
pictos-icons (0.2.1)
picturefill-rails (0.2.2)
rails (>= 3.0.0)
+ places (0.0.1)
+ hashie
+ httparty
+ json
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
@@ -356,6 +381,7 @@ DEPENDENCIES
bootstrap-wysihtml5-rails
bourbon
capybara (>= 1.1.2)
+ cells!
clear_eyes
client_side_validations
coffee-rails
@@ -371,7 +397,8 @@ DEPENDENCIES
flexlayout-rails (~> 0.1.4)
font_awesome-sass-rails (~> 2.0.0)!
formtastic-bootstrap (~> 2.0.0)
- gmaps4rails
+ gmaps-autocomplete-rails (~> 0.1.1)!
+ gmaps4rails!
green_monkey!
growl (>= 1.0.3)
haml (>= 3.0.0)
@@ -386,8 +413,10 @@ DEPENDENCIES
masonry-rails (~> 0.1)
modernizr-rails!
mongoid (~> 3)
+ partializer (~> 0.1.0)
pictos-icons (>= 0.2.0)
picturefill-rails
+ places
pry
rails (~> 3.2)
rails-gallery (~> 0.2.0)
View
47 app/assets/for_later/search/auto_complete.js.coffee
@@ -0,0 +1,47 @@
+# See http://gerger.co/blog/2011/02/17/google-maps-api-v3-location-search-with-jquery-autocomplete-plugin/
+
+# Also see http://tech.cibul.net/geocode-with-google-maps-api-v3/
+
+namespace "search"
+ AutoComplete: class AutoComplete
+ constructor: (@lat = lat, @lng = lng, @zoom = 10) ->
+ @mapOptions = {
+ zoom: @zoom
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ center: new google.maps.LatLng(@lat, @lng)
+ }
+ @map_elem = $('#map')
+ @map = new google.maps.Map map_elem, mapOptions
+ @geocoder = new google.maps.Geocoder()
+ @geocoder = new gmaps.search.Geocoder 'DK'
+ @self
+
+ config: (@minLength = 2)->
+ $("#searchbox").autocomplete
+ source: @geocoder.mapSource
+ select: @selector
+ minLength: @minLength
+
+ # This bit is executed upon selection of an address
+ selector: (event, ui) ->
+ @pos = ui.item.position
+ @lct = ui.item.locType
+ @bounds = ui.item.bounds
+
+ map.fitBounds @bounds if @bounds
+
+ $("#latitude").val ui.item.latitude
+ $("#longitude").val ui.item.longitude
+ location = new google.maps.LatLng ui.item.latitude, ui.item.longitude
+ marker.setPosition location
+ map.setCenter location
+
+ dragMarker: ->
+ google.maps.event.addListener marker, 'drag', ->
+ geocoder.geocode
+ 'latLng': marker.getPosition
+ (results, status) ->
+ if status == google.maps.GeocoderStatus.OK and results[0]
+ $('#address').val results[0].formatted_address
+ $('#latitude').val marker.getPosition().lat
+ $('#longitude').val marker.getPosition().lng
View
161 app/assets/for_later/search/gmaps.js
@@ -0,0 +1,161 @@
+// http://rjshade.com/gmaps-autocomplete/
+
+var geocoder;
+var map;
+var marker;
+
+// initialise the google maps objects, and add listeners
+function gmaps_init(){
+
+ // center of the universe
+ var latlng = new google.maps.LatLng(51.751724,-1.255284);
+
+ var options = {
+ zoom: 2,
+ center: latlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+
+ // create our map object
+ map = new google.maps.Map(document.getElementById("gmaps-canvas"), options);
+
+ // the geocoder object allows us to do latlng lookup based on address
+ geocoder = new google.maps.Geocoder();
+
+ // the marker shows us the position of the latest address
+ marker = new google.maps.Marker({
+ map: map,
+ draggable: true
+ });
+
+ // event triggered when marker is dragged and dropped
+ google.maps.event.addListener(marker, 'dragend', function() {
+ geocode_lookup( 'latLng', marker.getPosition() );
+ });
+
+ // event triggered when map is clicked
+ google.maps.event.addListener(map, 'click', function(event) {
+ marker.setPosition(event.latLng)
+ geocode_lookup( 'latLng', event.latLng );
+ });
+}
+
+// move the marker to a new position, and center the map on it
+function update_map( geometry ) {
+ map.fitBounds( geometry.viewport )
+ marker.setPosition( geometry.location )
+}
+
+// fill in the UI elements with new position data
+function update_ui( address, latLng ) {
+ $('#gmaps-input-address').autocomplete("close");
+ $('#gmaps-input-address').val(address);
+ if($("#gmaps-output-latitude").is("input")) {
+ $('#gmaps-output-latitude').val(latLng.lat());
+ } else {
+ $('#gmaps-output-latitude').html(latLng.lat());
+ }
+ if($("#gmaps-output-longitude").is("input")) {
+ $('#gmaps-output-longitude').val(latLng.lng());
+ } else {
+ $('#gmaps-output-longitude').html(latLng.lng());
+ }
+}
+
+// Query the Google geocode object
+//
+// type: 'address' for search by address
+// 'latLng' for search by latLng (reverse lookup)
+//
+// value: search query
+//
+// update: should we update the map (center map and position marker)?
+function geocode_lookup( type, value, update ) {
+ // default value: update = false
+ update = typeof update !== 'undefined' ? update : false;
+
+ request = {};
+ request[type] = value;
+
+ geocoder.geocode(request, function(results, status) {
+ $('#gmaps-error').html('');
+ if (status == google.maps.GeocoderStatus.OK) {
+ // Google geocoding has succeeded!
+ if (results[0]) {
+ // Always update the UI elements with new location data
+ update_ui( results[0].formatted_address,
+ results[0].geometry.location )
+
+ // Only update the map (position marker and center map) if requested
+ if( update ) { update_map( results[0].geometry ) }
+ } else {
+ // Geocoder status ok but no results!?
+ $('#gmaps-error').html("Sorry, something went wrong. Try again!");
+ }
+ } else {
+ // Google Geocoding has failed. Two common reasons:
+ // * Address not recognised (e.g. search for 'zxxzcxczxcx')
+ // * Location doesn't map to address (e.g. click in middle of Atlantic)
+
+ if( type == 'address' ) {
+ // User has typed in an address which we can't geocode to a location
+ $('#gmaps-error').html("Sorry! We couldn't find " + value + ". Try a different search term, or click the map." );
+ } else {
+ // User has clicked or dragged marker to somewhere that Google can't do a reverse lookup for
+ // In this case we display a warning, clear the address box, but fill in LatLng
+ $('#gmaps-error').html("Woah... that's pretty remote! You're going to have to manually enter a place name." );
+ update_ui('', value)
+ }
+ };
+ });
+};
+
+// initialise the jqueryUI autocomplete element
+function autocomplete_init() {
+ $("#gmaps-input-address").autocomplete({
+
+ // source is the list of input options shown in the autocomplete dropdown.
+ // see documentation: http://jqueryui.com/demos/autocomplete/
+ source: function(request,response) {
+
+ // the geocode method takes an address or LatLng to search for
+ // and a callback function which should process the results into
+ // a format accepted by jqueryUI autocomplete
+ geocoder.geocode( {'address': request.term }, function(results, status) {
+ response($.map(results, function(item) {
+ return {
+ label: item.formatted_address, // appears in dropdown box
+ value: item.formatted_address, // inserted into input element when selected
+ geocode: item // all geocode data: used in select callback event
+ }
+ }));
+ })
+ },
+
+ // event triggered when drop-down option selected
+ select: function(event,ui){
+ update_ui( ui.item.value, ui.item.geocode.geometry.location )
+ update_map( ui.item.geocode.geometry )
+ }
+ });
+
+ // triggered when user presses a key in the address box
+ $("#gmaps-input-address").bind('keydown', function(event) {
+ if(event.keyCode == 13) {
+ geocode_lookup( 'address', $('#gmaps-input-address').val(), true );
+
+ // ensures dropdown disappears when enter is pressed
+ $('#gmaps-input-address').autocomplete("disable")
+ } else {
+ // re-enable if previously disabled above
+ $('#gmaps-input-address').autocomplete("enable")
+ }
+ });
+}; // autocomplete_init
+
+$(document).ready(function() {
+ if( $('#gmaps-canvas').length ) {
+ gmaps_init();
+ autocomplete_init();
+ };
+});
View
49 app/assets/for_later/search/gmaps/geocoder.coffee
@@ -0,0 +1,49 @@
+# See http://gerger.co/blog/2011/02/17/google-maps-api-v3-location-search-with-jquery-autocomplete-plugin/
+
+# See also: https://developers.google.com/maps/documentation/javascript/places
+# http://stackoverflow.com/questions/8066444/geo-autocomplete-for-a-certain-country
+
+
+input = document.getElementById('user_address');
+defaultBounds = new google.maps.LatLngBounds(new google.maps.LatLng(42.71422,-4.222666), new google.maps.LatLng(51.179343,8.47412))
+autocomplete = new google.maps.places.Autocomplete(input)
+autocomplete.setBounds(defaultBounds)
+autocomplete.setTypes(['geocode'])
+
+namespace "search.gmaps"
+ Geocoder: class Geocoder
+ # http://www.iana.org/assignments/language-subtag-registry
+ constructor: (@region = region) ->
+
+ mapSource: (request, response) ->
+ geocoder = new google.maps.Geocoder if geocoder == null
+
+ geocoder.geocode
+ 'address': request.term
+
+ # country/region to search!
+ # http://www.iana.org/assignments/language-subtag-registry
+ 'region': @region
+ resultResolver
+
+ reverseGeocode: (results) ->
+ @searchLoc = results[0].geometry.location
+ @lat = results[0].geometry.location.lat
+ @lng = results[0].geometry.location.lng
+ @latlng = new google.maps.LatLng lat, lng
+ @bounds = results[0].geometry.bounds
+
+ resultResolver: (results, status) ->
+ if status == google.maps.GeocoderStatus.OK
+ reverseGeocode results
+ geocoder.geocode
+ 'latLng': latlng
+ geocodeLatLng
+
+ geocodeLatLng: (results1, status1) ->
+ if results1[1] and status1 == google.maps.GeocoderStatus.OK
+ response($.map(results1, (loc) ->
+ label : loc.formatted_address
+ value : loc.formatted_address
+ bounds : loc.geometry.bounds
+ ))
View
0 ...ipts/wijmo/cultures/globalize.cultures.js → ...ater/wijmo/cultures/globalize.cultures.js
File renamed without changes.
View
0 ...assets/javascripts/wijmo/globalize.min.js → app/assets/for_later/wijmo/globalize.min.js
File renamed without changes.
View
0 ...ssets/javascripts/wijmo/knockout.wijmo.js → app/assets/for_later/wijmo/knockout.wijmo.js
File renamed without changes.
View
0 app/assets/images/property/big_ads/ad1.jpg → app/assets/images/property/cover_ads/ad1.jpg
File renamed without changes
View
0 app/assets/images/property/big_ads/ad2.jpg → app/assets/images/property/cover_ads/ad2.jpg
File renamed without changes
View
0 app/assets/images/property/big_ads/ad3.jpg → app/assets/images/property/cover_ads/ad3.jpg
File renamed without changes
View
10 app/assets/javascripts/application.js
@@ -11,15 +11,21 @@
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
+//= require apotomo/namespaces.min
+
//= require_tree .
//= require jquery_ujs
-//= require jquery-ui
+//= require jquery.ui.all
//= require clear_eyes
-//= require autocomplete-rails
+
//= require hamlcoffee
//= require masonry/jquery.masonry.min
//= require rails.validations
+//= require autocomplete-rails
+
+//= require gmaps-autocomplete
+
//= require gallery/responsive
//= require jquery/jquery.easing-1.3
View
4 app/assets/javascripts/widgets/bottom_bar_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the BottomBar widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/cover/sliding_ads_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Cover::SlidingAds widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/cover_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Cover widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/properties/featured_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Properties::Featured widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/properties/list_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Properties::List widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/properties/map_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Properties::Map widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/properties/similar_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Properties::Similar widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property/description_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property::Description widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property/location_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property::Location widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property/period_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property::Period widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property/photo_gallery_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property::PhotoGallery widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property/social_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property::Social widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
4 app/assets/javascripts/widgets/property_widget.coffee
@@ -0,0 +1,4 @@
+# Define your coffeescript code for the Property widget
+namespace "Widget.TopBar", (exports) ->
+ # add functions or classes here
+ bar: (foo) ->
View
7 app/assets/javascripts/widgets/top_bar/form/autocomplete_widget.coffee
@@ -0,0 +1,7 @@
+$ ->
+ # See http://gerger.co/blog/2011/02/17/google-maps-api-v3-location-search-with-jquery-autocomplete-plugin/
+ # new search.AutoComplete(41.06000, 28.98700).config(2)
+ # console.log('Setup GmapsAutoComplete!!!', GmapsAutoComplete)
+ GmapsAutoComplete.init();
+ GmapsAutoComplete.autoCompleteInit();
+
View
2 app/assets/stylesheets/application.css.scss
@@ -13,4 +13,4 @@ $company-name: unquote("Rent machine");
/* Icons */
@import 'icons';
-
+@import 'jquery.ui.all';
View
24 app/assets/stylesheets/gmaps4rails.css
@@ -0,0 +1,24 @@
+.map_container {
+ padding: 6px;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ccc #ccc #999 #ccc;
+ -webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
+ -moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
+ box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
+ width: 800px;
+}
+
+.gmaps4rails_map {
+ width: 800px;
+ height: 400px;
+}
+
+.bing_map {
+ position: absolute;
+ top: 20;
+ left: 10;
+ width: 400px;
+ height: 400px;
+ border:#555555 2px solid;
+}
View
1 app/assets/stylesheets/widgets/bottom_bar_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the BottomBar widget */
View
1 app/assets/stylesheets/widgets/cover/sliding_ads_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Cover::SlidingAds widget */
View
1 app/assets/stylesheets/widgets/cover_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Cover widget */
View
1 app/assets/stylesheets/widgets/properties/featured_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Properties::Featured widget */
View
1 app/assets/stylesheets/widgets/properties/list_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Properties::List widget */
View
1 app/assets/stylesheets/widgets/properties/map_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Properties::Map widget */
View
1 app/assets/stylesheets/widgets/properties/similar_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Properties::Similar widget */
View
1 app/assets/stylesheets/widgets/property/description_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property::Description widget */
View
1 app/assets/stylesheets/widgets/property/location_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property::Location widget */
View
1 app/assets/stylesheets/widgets/property/period_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property::Period widget */
View
1 app/assets/stylesheets/widgets/property/photo_gallery_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property::PhotoGallery widget */
View
1 app/assets/stylesheets/widgets/property/social_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property::Social widget */
View
1 app/assets/stylesheets/widgets/property_widget.css
@@ -0,0 +1 @@
+/* Define your css code for the Property widget */
View
2 app/controllers/application_controller.rb
@@ -6,5 +6,5 @@ class ApplicationController < ActionController::Base
before_filter :set_locale
- protect_from_forgery
+ protect_from_forgery
end
View
6 app/controllers/home_controller.rb
@@ -1,4 +1,10 @@
class HomeController < ApplicationController
+
+ has_widgets do |root|
+ root << widget(:cover)
+ # root << widget(:bottom_bar)
+ end
+
def page
@search = Search.new
end
View
5 app/controllers/properties_controller.rb
@@ -4,6 +4,11 @@ def show
end
def index
+ # @client = Places::Client.new(:api_key => 'AIzaSyAwcZYV2Zaa7sANz8M1dGMfbq6XYgz3xLc')
+ # @search = @client.search(:lat => 32.8481659, :lng => -97.1952847, :types => "food", :name => "roots")
+ # @search.results.first.name
+ # 'Roots Coffeehouse'
+
@properties = 20.times.collect { Fabricate(:property) }
end
View
4 app/helpers/application_helper.rb
@@ -9,8 +9,4 @@ module ApplicationHelper
def current_user
session[:user] ||= User.new 'kmandrup'
end
-
- def search_decorator search
- Decorators.decorator(:search).decorate(search)
- end
end
View
4 app/views/gmaps4rails/_gmaps4rails_lib.html.haml
@@ -0,0 +1,4 @@
+- content_for :scripts do
+ = javascript_include_tag *js_dependencies
+ %script{:type => "text/javascript"}
+ =raw options.to_gmaps4rails
View
4 app/views/home/page.html.haml
@@ -1,3 +1,5 @@
/ = render 'slideshow'
-= render 'properties/search/form'
+/ = render 'properties/search/form'
/ = render 'thumbnail_ads'
+= render_widget :cover
+/ = gmaps({ "map_options" => { :libraries => ["places"] } })
View
4 app/views/layouts/application.html.haml
@@ -2,8 +2,10 @@
%html{:lang => "en"}
= render partial: 'layouts/head'
%body
- #main_wrapper
+ #container_fluid
= yield
/ Placed at the end of the document so the pages load faster
+ = gmaps_libs_now map_options: {provider: :google, :provider_key => 'AIzaSyAldHWZicBdBhSrd4xC2uh3cVIwEdWFfiY'}
+ = yield :scripts
= javascript_include_tag "application"
View
7 app/widgets/bottom_bar/bottom_bar_widget.rb
@@ -0,0 +1,7 @@
+class BottomBarWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/bottom_bar/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ BottomBarWidget#show
+ %p
+ Find me in app/widgets/bottom_bar/views/show.html.haml
View
6 app/widgets/cover/sliding_ads/views/show.html.haml
@@ -0,0 +1,6 @@
+= widget_div do
+ #layerslider{style:"width: 98%; height: 400px;"}
+ .ls-layer{rel: "slidedelay: 3000;"}
+ = image_tag 'property/cover_ads/ad1.jpg', class: "ls-bg", alt: "layer1-background"
+ .ls-layer
+ = image_tag 'property/cover_ads/ad3.jpg', class: "ls-bg", alt: "layer2-background"
View
7 app/widgets/cover/sliding_ads_widget.rb
@@ -0,0 +1,7 @@
+class Cover::SlidingAdsWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
4 app/widgets/cover/views/show.html.haml
@@ -0,0 +1,4 @@
+= widget_div do
+ = render_widget :sliding_ads
+ = render_widget :top_bar
+ = render_widget :featured_properties
View
11 app/widgets/cover_widget.rb
@@ -0,0 +1,11 @@
+class CoverWidget < Apotomo::Widget
+ has_widgets do |root|
+ root << widget('cover/sliding_ads', :sliding_ads)
+ root << widget(:top_bar)
+ root << widget('properties/featured', :featured_properties)
+ end
+
+ def show
+ render
+ end
+end
View
5 app/widgets/properties/featured/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Properties::FeaturedWidget#show
+ %p
+ Find me in app/widgets/properties/featured/views/show.html.haml
View
7 app/widgets/properties/featured_widget.rb
@@ -0,0 +1,7 @@
+class Properties::FeaturedWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
7 app/widgets/properties/list/list_widget.rb
@@ -0,0 +1,7 @@
+class Properties::ListWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/properties/list/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Properties::ListWidget#show
+ %p
+ Find me in app/widgets/properties/list/views/show.html.haml
View
7 app/widgets/properties/map/map_widget.rb
@@ -0,0 +1,7 @@
+class Properties::MapWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/properties/map/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Properties::MapWidget#show
+ %p
+ Find me in app/widgets/properties/map/views/show.html.haml
View
7 app/widgets/properties/similar/similar_widget.rb
@@ -0,0 +1,7 @@
+class Properties::SimilarWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/properties/similar/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Properties::SimilarWidget#show
+ %p
+ Find me in app/widgets/properties/similar/views/show.html.haml
View
7 app/widgets/property/description/description_widget.rb
@@ -0,0 +1,7 @@
+class Property::DescriptionWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/property/description/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Property::DescriptionWidget#show
+ %p
+ Find me in app/widgets/property/description/views/show.html.haml
View
7 app/widgets/property/location/location_widget.rb
@@ -0,0 +1,7 @@
+class Property::LocationWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/property/location/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Property::LocationWidget#show
+ %p
+ Find me in app/widgets/property/location/views/show.html.haml
View
7 app/widgets/property/period/period_widget.rb
@@ -0,0 +1,7 @@
+class Property::PeriodWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/property/period/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Property::PeriodWidget#show
+ %p
+ Find me in app/widgets/property/period/views/show.html.haml
View
7 app/widgets/property/photo_gallery/photo_gallery_widget.rb
@@ -0,0 +1,7 @@
+class Property::PhotoGalleryWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/property/photo_gallery/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Property::PhotoGalleryWidget#show
+ %p
+ Find me in app/widgets/property/photo_gallery/views/show.html.haml
View
7 app/widgets/property/property_widget.rb
@@ -0,0 +1,7 @@
+class PropertyWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
7 app/widgets/property/social/social_widget.rb
@@ -0,0 +1,7 @@
+class Property::SocialWidget < Apotomo::Widget
+
+ def show
+ render
+ end
+
+end
View
5 app/widgets/property/social/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ Property::SocialWidget#show
+ %p
+ Find me in app/widgets/property/social/views/show.html.haml
View
5 app/widgets/property/views/show.html.haml
@@ -0,0 +1,5 @@
+= widget_div do
+ %h1
+ PropertyWidget#show
+ %p
+ Find me in app/widgets/property/views/show.html.haml
View
7 app/widgets/top_bar/form/form_widget.rb
@@ -1,7 +0,0 @@
-class TopBar::FormWidget < Apotomo::Widget
-
- def display
- render
- end
-
-end
View
24 app/widgets/top_bar/form_widget.rb
@@ -0,0 +1,24 @@
+class TopBar::FormWidget < Apotomo::Widget
+
+ def display
+ render
+ end
+
+ def my_gmaps_libs(options)
+ puts "options: #{options}"
+ options_with_indifferent_access = options.with_indifferent_access
+ view_helper = Gmaps4rails::ViewHelper.new(options_with_indifferent_access)
+
+ js_dependencies = if Gmaps4rails.escape_js_url
+ view_helper.js_dependencies_array
+ else
+ view_helper.js_dependencies_array.map(&:html_safe)
+ end
+
+ render 'gmaps4rails/gmaps4rails_libs',
+ :locals => {
+ :js_dependencies => js_dependencies
+ }
+ end
+
+end
View
7 app/widgets/top_bar/top_bar_widget.rb
@@ -1,7 +0,0 @@
-class TopBarWidget < Apotomo::Widget
-
- def display
- render
- end
-
-end
View
12 app/widgets/top_bar/views/display.html.haml
@@ -1,5 +1,9 @@
= widget_div do
- %h1
- TopBarWidget#display
- %p
- Find me in app/widgets/top_bar/views/display.html.haml
+ = semantic_form_for @search, :url => url_for_event(:submit), :remote => true do |form|
+ .ui-widget
+ = form.input :location, :input_html =>{:id => 'gmaps-input-address'}, :placeholder => 'type place to search'
+ = form.inputs do
+ = @search_decorator.form(form).inputs_line 1
+ = form.inputs do
+ = @search_decorator.form(form).inputs_line 2
+
View
16 app/widgets/top_bar_widget.rb
@@ -0,0 +1,16 @@
+class TopBarWidget < Apotomo::Widget
+ has_widgets do |root|
+ # root << widget(:form)
+ end
+
+ def display
+ @search = Search.new
+ @search_decorator = Decorators.decorator(:search).decorate(@search)
+
+ options_with_indifferent_access = {map_options: {provider: :google}}.with_indifferent_access
+ view_helper = Gmaps4rails::ViewHelper.new(options_with_indifferent_access)
+ @js_dependencies = Gmaps4rails.escape_js_url ? view_helper.js_dependencies_array : view_helper.js_dependencies_array.map(&:html_safe)
+
+ render
+ end
+end
View
4 gemfiles/Assets.gemfile
@@ -4,7 +4,7 @@ group :assets do
gem 'sass-rails', '~> 3.2'
gem 'compass_twitter_bootstrap', git: 'git://github.com/kristianmandrup/compass-twitter-bootstrap.git'
- gem 'font_awesome-sass-rails', '~> 2.0.0', git: 'git://github.com/kristianmandrup/font_awesome-sass-rails.git'
+ gem 'font_awesome-sass-rails', '~> 2.0.0', path: '/Users/kmandrup/private/repos/font_awesome-sass-rails' # git: 'git://github.com/kristianmandrup/font_awesome-sass-rails.git'
gem 'compass-rails', '~> 1.0.3'
@@ -18,6 +18,8 @@ group :assets do
gem "twitter-bootstrap-rails", git: 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'bourbon' # sass helpers
+ gem 'jquery-ui-rails'
+
gem 'haml_coffee_assets'
gem 'execjs'
end
View
12 spec/widgets/bottom_bar/bottom_bar_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe BottomBarWidget do
+ has_widgets do |root|
+ root << widget('bottom_bar')
+ end
+
+ it "should render :show" do
+ render_widget('bottom_bar', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/cover/cover_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe CoverWidget do
+ has_widgets do |root|
+ root << widget('cover')
+ end
+
+ it "should render :show" do
+ render_widget('cover', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/cover/sliding_ads/sliding_ads_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Cover::SlidingAdsWidget do
+ has_widgets do |root|
+ root << widget('cover/sliding_ads')
+ end
+
+ it "should render :show" do
+ render_widget('cover/sliding_ad', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/properties/featured/featured_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Properties::FeaturedWidget do
+ has_widgets do |root|
+ root << widget('properties/featured')
+ end
+
+ it "should render :show" do
+ render_widget('properties/featured', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/properties/list/list_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Properties::ListWidget do
+ has_widgets do |root|
+ root << widget('properties/list')
+ end
+
+ it "should render :show" do
+ render_widget('properties/list', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/properties/map/map_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Properties::MapWidget do
+ has_widgets do |root|
+ root << widget('properties/map')
+ end
+
+ it "should render :show" do
+ render_widget('properties/map', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/properties/similar/similar_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Properties::SimilarWidget do
+ has_widgets do |root|
+ root << widget('properties/similar')
+ end
+
+ it "should render :show" do
+ render_widget('properties/similar', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/description/description_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Property::DescriptionWidget do
+ has_widgets do |root|
+ root << widget('property/description')
+ end
+
+ it "should render :show" do
+ render_widget('property/description', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/location/location_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Property::LocationWidget do
+ has_widgets do |root|
+ root << widget('property/location')
+ end
+
+ it "should render :show" do
+ render_widget('property/location', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/period/period_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Property::PeriodWidget do
+ has_widgets do |root|
+ root << widget('property/period')
+ end
+
+ it "should render :show" do
+ render_widget('property/period', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/photo_gallery/photo_gallery_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Property::PhotoGalleryWidget do
+ has_widgets do |root|
+ root << widget('property/photo_gallery')
+ end
+
+ it "should render :show" do
+ render_widget('property/photo_gallery', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/property_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe PropertyWidget do
+ has_widgets do |root|
+ root << widget('property')
+ end
+
+ it "should render :show" do
+ render_widget('property', :show).should have_selector("h1")
+ end
+
+end
View
12 spec/widgets/property/social/social_widget_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Property::SocialWidget do
+ has_widgets do |root|
+ root << widget('property/social')
+ end
+
+ it "should render :show" do
+ render_widget('property/social', :show).should have_selector("h1")
+ end
+
+end

0 comments on commit 2dcbd6c

Please sign in to comment.