Skip to content

Commit

Permalink
Beam's last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeam authored and alexbeam committed Jul 21, 2014
1 parent 74cd21d commit cc43476
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 121 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ gem 'spring', group: :development
gem 'rmagick'

#Ransack search
gem 'ransack'
gem 'ransack', github: "activerecord-hackery/ransack"

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand Down
19 changes: 12 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
GIT
remote: git://github.com/activerecord-hackery/ransack.git
revision: 36046da3ed0cc04ce9f1995264a7bde9cd547a90
specs:
ransack (1.2.3)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.0.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -104,12 +115,6 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
ransack (1.2.3)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.0.0)
rdoc (4.1.1)
json (~> 1.4)
rmagick (2.13.2)
Expand Down Expand Up @@ -162,7 +167,7 @@ DEPENDENCIES
jquery-rails
paperclip
rails (= 4.1.1)
ransack
ransack!
rmagick
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
//= require turbolinks
//= require_tree .
//= require_self
$(document).ready(function() { $(".select2").select2(); });
$(document).ready(function() { $(".select2").select2(); });
$(document).on('page:load', function() { $(".select2").select2(); });
186 changes: 186 additions & 0 deletions app/assets/javascripts/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
function SetupMap() {

var map = L.mapbox.map('map', 'examples.h186knp8').setView([-33.93, 18.42], 10);


myLayer = null;

// search
$('#company_search').on('submit', function(e) {
e.preventDefault();

fetchMarkers({
onComplete: function(data) {
// once the data has been fetched

// clear all markers
$('ul#info li').remove()

// add markers from data (if there are any?)
placeMarkers(myLayer, data);

if (data.length > 0) {
setTimeout( function() {
map.fitBounds(myLayer.getBounds());
}, 50);
setTimeout( function() {
$( "li.item" ).first().mouseover();
}, 600);
}
},
data: $('#company_search').serialize()
});
});

var fetchMarkers = function(args) {
$.ajax({
type: "GET",
data: args.data,
url: "/companies",
dataType: "json",
success: args.onComplete
});


};

var placeMarkers = function(layer, data) {

layer.setGeoJSON(data);

var info = document.getElementById('info');
var info = $('ul#info')

// Iterate through each feature layer item, build a
// marker menu item and enable a click event that pans to + opens
// a marker that's associated to the marker item.
layer.eachLayer(function(marker) {

itemName = marker.feature.properties.title +
'' + marker.feature.properties.additional + '';

itemMarker = marker.feature.properties.title +
'' + marker.feature.properties.description + '';

info.append(

$("<li class='item'>" + itemName + "</li>").on('mouseover', function(e) {

$('ul#info li').removeClass('active');
$(e.target).addClass('active');

// When a menu item is clicked, animate the map to center
// its associated marker and open its popup.

marker.openPopup();

})
);

marker.bindPopup(itemMarker,{
width: 320,
height: 320
});
});
};
myLayer = L.mapbox.featureLayer().addTo(map);

fetchMarkers({
onComplete: function(data) {
placeMarkers(myLayer, data);
setTimeout( function() {
map.fitBounds(myLayer.getBounds());
}, 50);

}
});
};

function filterButton(form) {
fetchMarkers({
onComplete: function(data) {
// once the data has been fetched

// clear all markers
$('ul#info li').remove()

// add markers from data (if there are any?)
placeMarkers(myLayer, data);

if (data.length > 0) {
setTimeout( function() {
map.fitBounds(myLayer.getBounds());
}, 50);
setTimeout( function() {
$( "li.item" ).first().mouseover();
}, 600);
}
},
data: {q: {has_tags: $('#has_tags').val()}}
});
};



var fetchMarkers = function(args) {
$.ajax({
type: "GET",
data: args.data,
url: "/companies",
dataType: "json",
success: args.onComplete
});


};

var placeMarkers = function(layer, data) {

layer.setGeoJSON(data);

var info = document.getElementById('info');
var info = $('ul#info')

// Iterate through each feature layer item, build a
// marker menu item and enable a click event that pans to + opens
// a marker that's associated to the marker item.
layer.eachLayer(function(marker) {

itemName = marker.feature.properties.title +
'' + marker.feature.properties.additional + '';

itemMarker = marker.feature.properties.title +
'' + marker.feature.properties.description + '';

info.append(

$("<li class='item'>" + itemName + "</li>").on('mouseover', function(e) {

$('ul#info li').removeClass('active');
$(e.target).addClass('active');

// When a menu item is clicked, animate the map to center
// its associated marker and open its popup.

marker.openPopup();

})
);

marker.bindPopup(itemMarker,{
width: 320,
height: 320
});
});
};
myLayer = L.mapbox.featureLayer().addTo(map);

fetchMarkers({
onComplete: function(data) {
placeMarkers(myLayer, data);
setTimeout( function() {
map.fitBounds(myLayer.getBounds());
}, 50);

}
});
156 changes: 156 additions & 0 deletions app/assets/javascripts/map.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# SetupMap = ->
# map = L.mapbox.map("map", "examples.h186knp8").setView([
# -33.93
# 18.42
# ], 10)
# window.myLayer = null

# # search
# $("#company_search").on "submit", (e) ->
# e.preventDefault()
# fetchMarkers
# onComplete: (data) ->

# # once the data has been fetched

# # clear all markers
# $("ul#info li").remove()

# # add markers from data (if there are any?)
# placeMarkers myLayer, data
# if data.length > 0
# setTimeout (->
# map.fitBounds myLayer.getBounds()
# return
# ), 50
# setTimeout (->
# $("li.item").first().mouseover()
# return
# ), 600
# return

# data: $("#company_search").serialize()

# return

# fetchMarkers = (args) ->
# $.ajax
# type: "GET"
# data: args.data
# url: "/companies"
# dataType: "json"
# success: args.onComplete

# return

# placeMarkers = (layer, data) ->
# layer.setGeoJSON data
# info = document.getElementById("info")
# info = $("ul#info")

# # Iterate through each feature layer item, build a
# # marker menu item and enable a click event that pans to + opens
# # a marker that's associated to the marker item.
# layer.eachLayer (marker) ->
# itemName = marker.feature.properties.title + "" + marker.feature.properties.additional + ""
# itemMarker = marker.feature.properties.title + "" + marker.feature.properties.description + ""
# info.append $("<li class='item'>" + itemName + "</li>").on("mouseover", (e) ->
# $("ul#info li").removeClass "active"
# $(e.target).addClass "active"

# # When a menu item is clicked, animate the map to center
# # its associated marker and open its popup.
# marker.openPopup()
# return
# )
# marker.bindPopup itemMarker,
# width: 320
# height: 320

# return

# return

# myLayer = L.mapbox.featureLayer().addTo(map)
# fetchMarkers onComplete: (data) ->
# placeMarkers myLayer, data
# setTimeout (->
# map.fitBounds myLayer.getBounds()
# return
# ), 50
# return

# return
# filterButton = (form) ->
# fetchMarkers
# onComplete: (data) ->

# # once the data has been fetched

# # clear all markers
# $("ul#info li").remove()

# # add markers from data (if there are any?)
# placeMarkers myLayer, data
# if data.length > 0
# setTimeout (->
# map.fitBounds myLayer.getBounds()
# return
# ), 50
# setTimeout (->
# $("li.item").first().mouseover()
# return
# ), 600
# return

# data:
# q:
# has_tags: $("#has_tags").val()

# return
# fetchMarkers = (args) ->
# $.ajax
# type: "GET"
# data: args.data
# url: "/companies"
# dataType: "json"
# success: args.onComplete

# return

# placeMarkers = (layer, data) ->
# layer.setGeoJSON data
# info = document.getElementById("info")
# info = $("ul#info")

# # Iterate through each feature layer item, build a
# # marker menu item and enable a click event that pans to + opens
# # a marker that's associated to the marker item.
# layer.eachLayer (marker) ->
# itemName = marker.feature.properties.title + "" + marker.feature.properties.additional + ""
# itemMarker = marker.feature.properties.title + "" + marker.feature.properties.description + ""
# info.append $("<li class='item'>" + itemName + "</li>").on("mouseover", (e) ->
# $("ul#info li").removeClass "active"
# $(e.target).addClass "active"

# # When a menu item is clicked, animate the map to center
# # its associated marker and open its popup.
# marker.openPopup()
# return
# )
# marker.bindPopup itemMarker,
# width: 320
# height: 320

# return

# return

# window.myLayer = L.mapbox.featureLayer().addTo(map)
# fetchMarkers onComplete: (data) ->
# placeMarkers myLayer, data
# setTimeout (->
# map.fitBounds myLayer.getBounds()
# return
# ), 50
# return
Loading

0 comments on commit cc43476

Please sign in to comment.