]> git.openstreetmap.org Git - rails.git/commitdiff
Add support for rotating banners, add banners for SOTM, SOTMUS
authorBryan Housel <bryan@mapbox.com>
Mon, 20 Jun 2016 22:09:55 +0000 (18:09 -0400)
committerBryan Housel <bryan@mapbox.com>
Mon, 20 Jun 2016 22:09:55 +0000 (18:09 -0400)
app/assets/images/banners/.keep [new file with mode: 0644]
app/assets/images/banners/sotm-2016.jpg [new file with mode: 0644]
app/assets/images/banners/sotmus-2016.jpg [new file with mode: 0644]
app/assets/javascripts/index.js
app/assets/stylesheets/common.scss
app/views/layouts/_banner.html.erb [new file with mode: 0644]
app/views/layouts/map.html.erb

diff --git a/app/assets/images/banners/.keep b/app/assets/images/banners/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/assets/images/banners/sotm-2016.jpg b/app/assets/images/banners/sotm-2016.jpg
new file mode 100644 (file)
index 0000000..8f25867
Binary files /dev/null and b/app/assets/images/banners/sotm-2016.jpg differ
diff --git a/app/assets/images/banners/sotmus-2016.jpg b/app/assets/images/banners/sotmus-2016.jpg
new file mode 100644 (file)
index 0000000..ea67d5a
Binary files /dev/null and b/app/assets/images/banners/sotmus-2016.jpg differ
index fdbeaba22fbc0bf50b96133405cc62c93d52d0c5..44692eac13f922a39d7c9e0e6f8a321fc8b28ca5 100644 (file)
@@ -161,17 +161,27 @@ $(document).ready(function () {
       map.getLayersCode(),
       map._object);
 
-    $.removeCookie("_osm_location");
-    $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
+    $.removeCookie('_osm_location');
+    $.cookie('_osm_location', OSM.locationCookie(map), { expires: expiry, path: '/' });
   });
 
   if ($.cookie('_osm_welcome') === 'hide') {
     $('.welcome').hide();
   }
 
-  $('.welcome .close').on('click', function() {
+  $('.welcome .close-wrap').on('click', function() {
     $('.welcome').hide();
-    $.cookie("_osm_welcome", 'hide', { expires: expiry });
+    $.cookie('_osm_welcome', 'hide', { expires: expiry });
+  });
+
+  $('#banner .close-wrap').on('click', function(e) {
+    debugger;
+    var cookieId = e.target.id;
+    $('#banner').hide();
+    e.preventDefault();
+    if (cookieId) {
+      $.cookie(cookieId, 'hide', { expires: expiry });
+    }
   });
 
   if (OSM.PIWIK) {
index cf687653e1efa19bd18fd82ddf7ad20d4aec8055..fa9c51b94cbf04dd4dc0c220c716ad7930e0bb1e 100644 (file)
@@ -173,6 +173,7 @@ small, aside {
 .icon.clipboard   { background-position: -160px 0; }
 .icon.link        { background-position: -180px 0; }
 .icon.close       { background-position: -200px 0; }
+.close-wrap:hover .icon.close,
 .icon.close:hover { background-position: -200px -20px; }
 .icon.check       { background-position: -220px 0; }
 .icon.note        { background-position: -240px 0; }
@@ -546,6 +547,13 @@ body.compact {
     background: #fff;
     font-size: 12px;
 
+    > div {
+      position: relative;
+      float: left;
+      clear: both;
+      width: 100%;
+    }
+
     h2 {
       padding: $lineheight $lineheight $lineheight/2;
     }
@@ -556,9 +564,24 @@ body.compact {
       font-size: 13px;
     }
 
+    .close-wrap {
+      cursor: pointer;
+      position: absolute;
+      top: 0;
+      right: 0;
+      width: 60px;
+      height: 60px;
+
+      .icon.close {
+        pointer-events: none;
+        position: absolute;
+        right: 20px;
+        top: 20px;
+      }
+    }
+
     .icon.close {
       float: right;
-      cursor: pointer;
     }
 
     p.error {
@@ -568,25 +591,25 @@ body.compact {
     }
   }
 
-  .welcome {
-    display: none;
-  }
-
   .overlay-sidebar #sidebar {
     position: absolute;
     z-index: 1000;
     height: auto;
-    border-bottom-right-radius: 5px;
     overflow: hidden;
+
     .welcome {
       display: block;
     }
+
     #sidebar_content {
       display: none;
     }
   }
 
   .welcome {
+    display: none;
+    padding-bottom: 5px;
+
     p {
       padding: $lineheight/2 $lineheight $lineheight;
       font-size: 110%;
@@ -607,6 +630,15 @@ body.compact {
     }
   }
 
+  #banner {
+    display: block;
+
+    img {
+      display: block;
+      width: $sidebarWidth;
+    }
+  }
+
   #map {
     height: 100%;
     overflow: hidden;
diff --git a/app/views/layouts/_banner.html.erb b/app/views/layouts/_banner.html.erb
new file mode 100644 (file)
index 0000000..94abb5c
--- /dev/null
@@ -0,0 +1,41 @@
+<% active_banners = {
+  :sotmus2016 => {
+    :alt => 'State of the Map US 2016',
+    :link => 'http://stateofthemap.us/',
+    :img => 'banners/sotmus-2016.jpg'
+  },
+  :sotm2016 => {
+    :alt => 'State of the Map 2016',
+    :link => 'http://2016.stateofthemap.org/',
+    :img => 'banners/sotm-2016.jpg'
+  }
+}
+
+bannerSym = nil
+cookieStr = nil
+queuePos = active_banners.length
+
+# pick least recently seen banner that is not hidden
+active_banners.each_key do |k|
+  c = '_osm_banner_' + k.to_s
+  val = cookies[c.to_sym] || 0
+  next if val == 'hide'
+
+  if val.to_i > 0
+    cookies[c.to_sym] = val.to_i - 1
+  end
+
+  if val.to_i <= queuePos
+    bannerSym = k
+    cookieStr = c
+    queuePos = val.to_i
+  end
+end
+
+unless bannerSym.nil?
+  banner = active_banners[bannerSym]
+  cookies[cookieStr.to_sym] = active_banners.length   # bump to end of queue
+%>
+<%= link_to (image_tag banner[:img], :alt => banner[:alt], :title => banner[:alt]), banner[:link] %>
+<div class="close-wrap" id="<%= cookieStr %>"><span class="icon close"></span></div>
+<% end %>
index cb2fd0e07a33007e082d437710ee88b75effba5d..6607bf7a5879eba6d026edbe809fc42835947516 100644 (file)
 
     <% unless @user %>
       <div class="welcome">
-        <h2><a><span class="icon close"></span></a><%= t 'layouts.intro_header' %></h2>
+        <h2><%= t 'layouts.intro_header' %></h2>
+        <div class="close-wrap"><span class="icon close"></span></div>
         <p><%= t 'layouts.intro_text' %></p>
         <a class="button learn-more" href="<%= about_path %>"><%= t('layouts.learn_more') %></a>
         <a class="button sign-up" href="<%= user_new_path %>"><%= t('layouts.start_mapping') %></a>
       </div>
     <% end %>
+
+    <div id="banner">
+      <%= render :partial => "layouts/banner" %>
+    </div>
   </div>
 
   <noscript>