From cea05698afc22bd563161dd570acfa4f0b3eabc5 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 25 Feb 2013 20:41:08 -0500 Subject: [PATCH] add nav help for posts --- app/assets/javascripts/posts.js | 47 +++++++++++-------- app/assets/stylesheets/common/inline.css.scss | 4 +- .../stylesheets/specific/posts.css.scss | 14 +++++- app/presenters/post_presenter.rb | 8 +++- app/views/posts/index.html.erb | 2 + .../posts/partials/index/_nav_help.html.erb | 5 ++ .../posts/partials/show/_nav_help.html.erb | 3 ++ ..._tag_seq.html.erb => _search_seq.html.erb} | 6 +-- app/views/posts/show.html.erb | 6 ++- 9 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 app/views/posts/partials/index/_nav_help.html.erb create mode 100644 app/views/posts/partials/show/_nav_help.html.erb rename app/views/posts/partials/show/{_tag_seq.html.erb => _search_seq.html.erb} (65%) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 18048f165..fd6524a4f 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -8,6 +8,7 @@ if ($("#c-posts").length) { this.initialize_shortcuts(); + this.initialize_nav_help_link(); } if ($("#c-posts").length && $("#a-index").length) { @@ -21,7 +22,6 @@ this.initialize_post_image_resize_to_window_link(); this.initialize_similar(); this.place_jlist_ads(); - this.center_pool_nav(); if (Danbooru.meta("always-resize-images") === "true") { $("#image-resize-to-window-link").click(); @@ -50,18 +50,26 @@ } Danbooru.Post.nav_pool_prev = function() { - if ($("#tag-seq-nav").length) { - location.href = $("#tag-seq-nav a[rel=prev]").attr("href"); + if ($("#search-seq-nav").length) { + var href = $("#search-seq-nav a[rel=prev]").attr("href"); + if (href) { + location.href = href; + } } else { - location.href = $("#pool-nav a.active[rel=prev]").attr("href"); + var href = $("#pool-nav a.active[rel=prev]").attr("href"); + if (href) { + location.href = href; + } } } Danbooru.Post.nav_pool_next = function() { - if ($("#tag-seq-nav").length) { - location.href = $("#tag-seq-nav a[rel=next]").attr("href"); + if ($("#search-seq-nav").length) { + var href = $("#search-seq-nav a[rel=next]").attr("href"); + location.href = href; } else { - location.href = $("#pool-nav a.active[rel=next]").attr("href"); + var href = $("#pool-nav a.active[rel=next]").attr("href") + location.href = href; } } @@ -115,6 +123,18 @@ e.preventDefault(); }); } + + Danbooru.Post.initialize_nav_help_link = function() { + $("#close-nav-help-link").click(function(e) { + Danbooru.Cookie.put("close-nav-help", "1"); + $("#nav-help").hide(); + e.preventDefault(); + }); + + if (Danbooru.Cookie.get("close-nav-help") === "1") { + $("#nav-help").hide(); + } + } Danbooru.Post.initialize_titles = function() { $(".post-preview").each(function(i, v) { @@ -156,7 +176,6 @@ Danbooru.Note.Box.scale_all(); $("#image-resize-notice").hide(); Danbooru.Post.place_jlist_ads(); - Danbooru.Post.center_pool_nav(); e.preventDefault(); }); } @@ -185,7 +204,6 @@ Danbooru.Note.Box.scale_all(); Danbooru.Post.place_jlist_ads() - Danbooru.Post.center_pool_nav(); e.preventDefault(); }); } @@ -323,17 +341,6 @@ } } } - - Danbooru.Post.center_pool_nav = function() { - var width = $("#image").width(); - if (width > 1000) { - width = 1000; - } - if (width > 700) { - width = 700 - } - $("#pool-nav,#tag-seq-nav").width(width); - } })(); $(document).ready(function() { diff --git a/app/assets/stylesheets/common/inline.css.scss b/app/assets/stylesheets/common/inline.css.scss index 3c2b0fbf1..22c1b458f 100644 --- a/app/assets/stylesheets/common/inline.css.scss +++ b/app/assets/stylesheets/common/inline.css.scss @@ -26,9 +26,9 @@ span.edit-options { span.key { background: #333; border: 1px solid #333; - padding: 1px 3px; + padding: 1px 6px; color: white; - width: 1em; +/* width: 1em;*/ text-align: center; @include inline-block; @include border-radius(3px); diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index 9e1d3ae41..7c54c21d4 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -120,6 +120,11 @@ div#c-posts { ul { margin-left: 1em; } + + p { + margin: 0; + text-align: center; + } } div.nav-notice { @@ -127,6 +132,11 @@ div#c-posts { margin-bottom: 1em; background: #EEE; border: 1px solid #AAA; + + p { + margin: 0; + text-align: center; + } } aside#sidebar #tag-list h2 { @@ -212,11 +222,11 @@ div#c-posts { float: right; } - .pool-name, .tag-name { + .pool-name, .search-name { margin: 0 1em; } - #pool-nav, #tag-seq-nav { + #pool-nav, #search-seq-nav, #nav-help { margin: 1em 0; li { diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 537f4d99a..0a0f8c8c0 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -104,8 +104,14 @@ class PostPresenter < Presenter html = pool_link_html(html, template, other_pool) end else + first = true @post.pools.active.each do |pool| - html = pool_link_html(html, template, pool) + if first + html = pool_link_html(html, template, pool, :include_rel => true) + first = false + else + html = pool_link_html(html, template, pool) + end end end diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 8c74db2ae..af02aa175 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -28,6 +28,8 @@ <%= render "posts/partials/index/edit" %> <%= render "wiki_pages/excerpt", :post_set => @post_set %> <%= render "posts/partials/index/posts", :post_set => @post_set %> + + <%= render "posts/partials/index/nav_help" %> <%= render_rss_advertisement("short", @post_set.has_explicit?) %> diff --git a/app/views/posts/partials/index/_nav_help.html.erb b/app/views/posts/partials/index/_nav_help.html.erb new file mode 100644 index 000000000..912201acf --- /dev/null +++ b/app/views/posts/partials/index/_nav_help.html.erb @@ -0,0 +1,5 @@ +
+ + diff --git a/app/views/posts/partials/show/_nav_help.html.erb b/app/views/posts/partials/show/_nav_help.html.erb new file mode 100644 index 000000000..70c0520bf --- /dev/null +++ b/app/views/posts/partials/show/_nav_help.html.erb @@ -0,0 +1,3 @@ + diff --git a/app/views/posts/partials/show/_tag_seq.html.erb b/app/views/posts/partials/show/_search_seq.html.erb similarity index 65% rename from app/views/posts/partials/show/_tag_seq.html.erb rename to app/views/posts/partials/show/_search_seq.html.erb index b652f0ccd..9cbf3c208 100644 --- a/app/views/posts/partials/show/_tag_seq.html.erb +++ b/app/views/posts/partials/show/_search_seq.html.erb @@ -1,8 +1,8 @@ -