proper star icon
This commit is contained in:
parent
919532af81
commit
0fdb38b0a5
5 changed files with 45 additions and 12 deletions
BIN
app/assets/images/star.png
Normal file
BIN
app/assets/images/star.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 514 B |
|
@ -50,8 +50,8 @@ Metamaps.Map = {
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.starMap').click(function () {
|
$('.starMap').click(function () {
|
||||||
if ($(this).text() === 'star') self.star()
|
if ($(this).is('.starred')) self.unstar()
|
||||||
else self.unstar()
|
else self.star()
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.sidebarFork').click(function () {
|
$('.sidebarFork').click(function () {
|
||||||
|
@ -147,20 +147,28 @@ Metamaps.Map = {
|
||||||
if (!Metamaps.Active.Mapper || !Metamaps.Stars) return
|
if (!Metamaps.Active.Mapper || !Metamaps.Stars) return
|
||||||
// update the star/unstar icon
|
// update the star/unstar icon
|
||||||
if (Metamaps.Stars.find(function (s) { return s.user_id === Metamaps.Active.Mapper.id })) {
|
if (Metamaps.Stars.find(function (s) { return s.user_id === Metamaps.Active.Mapper.id })) {
|
||||||
$('.starMap').html('unstar')
|
$('.starMap').addClass('starred')
|
||||||
|
$('.starMap .tooltipsAbove').html('Unstar')
|
||||||
} else {
|
} else {
|
||||||
$('.starMap').html('star')
|
$('.starMap').removeClass('starred')
|
||||||
|
$('.starMap .tooltipsAbove').html('Star')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
star: function () {
|
star: function () {
|
||||||
|
var self = Metamaps.Map
|
||||||
|
|
||||||
if (!Metamaps.Active.Map) return
|
if (!Metamaps.Active.Map) return
|
||||||
$.post('/maps/' + Metamaps.Active.Map.id + '/star')
|
$.post('/maps/' + Metamaps.Active.Map.id + '/star')
|
||||||
$('.starMap').html('unstar')
|
Metamaps.Stars.push({ user_id: Metamaps.Active.Mapper.id, map_id: Metamaps.Active.Map.id })
|
||||||
|
self.updateStar()
|
||||||
},
|
},
|
||||||
unstar: function () {
|
unstar: function () {
|
||||||
|
var self = Metamaps.Map
|
||||||
|
|
||||||
if (!Metamaps.Active.Map) return
|
if (!Metamaps.Active.Map) return
|
||||||
$.post('/maps/' + Metamaps.Active.Map.id + '/unstar')
|
$.post('/maps/' + Metamaps.Active.Map.id + '/unstar')
|
||||||
$('.starMap').html('star')
|
Metamaps.Stars = Metamaps.Stars.filter(function (s) { return s.user_id != Metamaps.Active.Mapper.id })
|
||||||
|
self.updateStar()
|
||||||
},
|
},
|
||||||
fork: function () {
|
fork: function () {
|
||||||
Metamaps.GlobalUI.openLightbox('forkmap')
|
Metamaps.GlobalUI.openLightbox('forkmap')
|
||||||
|
|
|
@ -334,7 +334,8 @@
|
||||||
right: 70px;
|
right: 70px;
|
||||||
}
|
}
|
||||||
.mapPage .openCheatsheet .tooltipsAbove, .topicPage .openCheatsheet .tooltipsAbove {
|
.mapPage .openCheatsheet .tooltipsAbove, .topicPage .openCheatsheet .tooltipsAbove {
|
||||||
left: 29px;
|
right: 1px;
|
||||||
|
left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unauthenticated .homePage .infoAndHelp {
|
.unauthenticated .homePage .infoAndHelp {
|
||||||
|
@ -376,9 +377,18 @@
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
.starMap {
|
.starMap {
|
||||||
width: auto;
|
background-image: url(<%= asset_data_uri('star.png') %>);
|
||||||
padding-right: 8px;
|
background-position: 0 0;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
width: 32px;
|
||||||
}
|
}
|
||||||
|
.starMap:hover, .starMap.starred {
|
||||||
|
background-position: 0 -32px;
|
||||||
|
}
|
||||||
|
.starMap.starred:hover {
|
||||||
|
background-position: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
.unauthenticated .mapPage .starMap {
|
.unauthenticated .mapPage .starMap {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +449,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoomExtents:hover .tooltips, .zoomIn:hover .tooltips, .zoomOut:hover .tooltips, .takeScreenshot:hover .tooltips, .sidebarFilterIcon:hover .tooltipsUnder, .sidebarForkIcon:hover .tooltipsUnder, .addMap:hover .tooltipsUnder, .authenticated .sidebarAccountIcon:hover .tooltipsUnder,
|
.zoomExtents:hover .tooltips, .zoomIn:hover .tooltips, .zoomOut:hover .tooltips, .takeScreenshot:hover .tooltips, .sidebarFilterIcon:hover .tooltipsUnder, .sidebarForkIcon:hover .tooltipsUnder, .addMap:hover .tooltipsUnder, .authenticated .sidebarAccountIcon:hover .tooltipsUnder,
|
||||||
.mapInfoIcon:hover .tooltipsAbove, .openCheatsheet:hover .tooltipsAbove, .chat-button:hover .tooltips {
|
.mapInfoIcon:hover .tooltipsAbove, .openCheatsheet:hover .tooltipsAbove, .chat-button:hover .tooltips, .starMap:hover .tooltipsAbove {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,6 +533,13 @@
|
||||||
top: 10px;
|
top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.starMap .tooltipsAbove {
|
||||||
|
left: -2px;
|
||||||
|
}
|
||||||
|
.starMap.starred .tooltipsAbove {
|
||||||
|
left: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
.openCheatsheet .tooltipsAbove {
|
.openCheatsheet .tooltipsAbove {
|
||||||
left: -4px;
|
left: -4px;
|
||||||
}
|
}
|
||||||
|
@ -560,7 +577,7 @@
|
||||||
right: 37% !important;
|
right: 37% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mapInfoIcon div:after, .openCheatsheet div:after {
|
.mapInfoIcon div:after, .openCheatsheet div:after, .starMap div:after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 76%;
|
top: 76%;
|
||||||
|
|
|
@ -79,6 +79,10 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def starred_map?(map)
|
||||||
|
return !!self.stars.index{|s| s.map_id == map.id }
|
||||||
|
end
|
||||||
|
|
||||||
def settings
|
def settings
|
||||||
# make sure we always return a UserPreference instance
|
# make sure we always return a UserPreference instance
|
||||||
self[:settings] = UserPreference.new if self[:settings].nil?
|
self[:settings] = UserPreference.new if self[:settings].nil?
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
|
|
||||||
<div class="infoAndHelp">
|
<div class="infoAndHelp">
|
||||||
<%= render :partial => 'maps/mapinfobox' %>
|
<%= render :partial => 'maps/mapinfobox' %>
|
||||||
<div class="starMap infoElement mapElement">Star</div>
|
|
||||||
|
<% starred = current_user && @map && current_user.starred_map?(@map)
|
||||||
|
starClass = starred ? 'starred' : ''
|
||||||
|
tooltip = starred ? 'Star' : 'Unstar' %>
|
||||||
|
<div class="starMap infoElement mapElement <%= starClass %>"><div class="tooltipsAbove"><%= tooltip %></div></div>
|
||||||
<div class="mapInfoIcon infoElement mapElement"><div class="tooltipsAbove">Map Info</div></div>
|
<div class="mapInfoIcon infoElement mapElement"><div class="tooltipsAbove">Map Info</div></div>
|
||||||
<div class="openCheatsheet openLightbox infoElement mapElement" data-open="cheatsheet"><div class="tooltipsAbove">Help</div></div>
|
<div class="openCheatsheet openLightbox infoElement mapElement" data-open="cheatsheet"><div class="tooltipsAbove">Help</div></div>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue