move saved search option to sidebar
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
//= require jquery.timeout.js
|
||||
//= require jquery-ui-autocomplete-custom.js
|
||||
//= require jquery.storageapi.js
|
||||
//= require jquery.dropdown.min.js
|
||||
//= require ugoira_player.js
|
||||
//= require stupidtable.js
|
||||
//= require rails.js
|
||||
|
||||
@@ -576,7 +576,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
$("#save-search").click(function() {
|
||||
$("#save-search").click(function(e) {
|
||||
if (Danbooru.meta("disable-labeled-saved-searches") === "false") {
|
||||
$("#save-search-dialog").dialog("open");
|
||||
} else {
|
||||
@@ -587,6 +587,18 @@
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#search-dropdown #wiki-search").click(function(e) {
|
||||
window.location.href = "/wiki_pages?search%5Btitle%5D=" + encodeURIComponent($("#tags").val());
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#search-dropdown #artist-search").click(function(e) {
|
||||
window.location.href = "/artists?search%5Bname%5D=" + encodeURIComponent($("#tags").val());
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@import "jquery-ui-1.11.2.min.scss";
|
||||
@import "jquery.dropdown.css";
|
||||
@import "common/*";
|
||||
@import "specific/*";
|
||||
|
||||
@@ -38,7 +38,7 @@ div#page {
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
width: 10em;
|
||||
width: 8em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@ class PopularSearchService
|
||||
end
|
||||
end
|
||||
response
|
||||
end.force_encoding("utf-8")
|
||||
end.to_s.force_encoding("utf-8")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,6 +110,6 @@ class SavedSearch < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def label_string=(val)
|
||||
self.labels = val.scan(/\S+/).map {|x| SavedSearch.normalize_label(x)}
|
||||
self.labels = val.to_s.scan(/\S+/).map {|x| SavedSearch.normalize_label(x)}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,5 +15,16 @@
|
||||
<% end %>
|
||||
<%= hidden_field_tag "ms", "1" %>
|
||||
<%= submit_tag "Go", :name => nil %>
|
||||
<%= submit_tag "+", "data-jq-dropdown" => "#search-dropdown" %>
|
||||
<div id="search-dropdown" class="jq-dropdown jq-dropdown-tip">
|
||||
<ul class="jq-dropdown-menu">
|
||||
<% if params[:tags].present? && SavedSearch.enabled? && CurrentUser.show_saved_searches? %>
|
||||
<li><%= link_to "Save search", saved_searches_path, :id => "save-search" %></li>
|
||||
<% end %>
|
||||
|
||||
<li><%= link_to "Search wiki", wiki_pages_path, :id => "wiki-search" %></li>
|
||||
<li><%= link_to "Search artists", artists_path, :id => "artist-search" %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
<% if SavedSearch.enabled? && CurrentUser.show_saved_searches? %>
|
||||
<%= button_tag "Save search", :id => "save-search" %>
|
||||
<% end %>
|
||||
|
||||
<% if SavedSearch.enabled? %>
|
||||
<div id="save-search-dialog" title="Save Search" style="display: none;">
|
||||
<%= form_tag(saved_searches_path, :class => "simple_form", :remote => true) do %>
|
||||
|
||||
9
vendor/assets/javascripts/jquery.dropdown.min.js
vendored
Normal file
9
vendor/assets/javascripts/jquery.dropdown.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* jQuery Dropdown: A simple dropdown plugin
|
||||
*
|
||||
* Contribute: https://github.com/claviska/jquery-dropdown
|
||||
*
|
||||
* @license: MIT license: http://opensource.org/licenses/MIT
|
||||
*
|
||||
*/
|
||||
jQuery&&function($){function t(t,e){var d=t?$(this):e,n=$(d.attr("data-jq-dropdown")),a=d.hasClass("jq-dropdown-open");if(t){if($(t.target).hasClass("jq-dropdown-ignore"))return;t.preventDefault(),t.stopPropagation()}else if(d!==e.target&&$(e.target).hasClass("jq-dropdown-ignore"))return;o(),a||d.hasClass("jq-dropdown-disabled")||(d.addClass("jq-dropdown-open"),n.data("jq-dropdown-trigger",d).show(),r(),n.trigger("show",{jqDropdown:n,trigger:d}))}function o(t){var o=t?$(t.target).parents().addBack():null;if(o&&o.is(".jq-dropdown")){if(!o.is(".jq-dropdown-menu"))return;if(!o.is("A"))return}var r=jQuery.Event("hide");$(document).find(".jq-dropdown:visible").each(function(){var t=$(this);t.hide().removeData("jq-dropdown-trigger").trigger("hide",{jqDropdown:t})}),r.isDefaultPrevented()||($(document).find(".jq-dropdown:visible").each(function(){var t=$(this);t.hide().removeData("jq-dropdown-trigger").trigger("hide",{jqDropdown:t})}),$(document).find(".jq-dropdown-open").removeClass("jq-dropdown-open"))}function r(){var t=$(".jq-dropdown:visible").eq(0),o=t.data("jq-dropdown-trigger"),r=o?parseInt(o.attr("data-horizontal-offset")||0,10):null,e=o?parseInt(o.attr("data-vertical-offset")||0,10):null;0!==t.length&&o&&(t.hasClass("jq-dropdown-relative")?t.css({left:t.hasClass("jq-dropdown-anchor-right")?o.position().left-(t.outerWidth(!0)-o.outerWidth(!0))-parseInt(o.css("margin-right"),10)+r:o.position().left+parseInt(o.css("margin-left"),10)+r,top:o.position().top+o.outerHeight(!0)-parseInt(o.css("margin-top"),10)+e}):t.css({left:t.hasClass("jq-dropdown-anchor-right")?o.offset().left-(t.outerWidth()-o.outerWidth())+r:o.offset().left+r,top:o.offset().top+o.outerHeight()+e}))}$.extend($.fn,{jqDropdown:function(r,e){switch(r){case"show":return t(null,$(this)),$(this);case"hide":return o(),$(this);case"attach":return $(this).attr("data-jq-dropdown",e);case"detach":return o(),$(this).removeAttr("data-jq-dropdown");case"disable":return $(this).addClass("jq-dropdown-disabled");case"enable":return o(),$(this).removeClass("jq-dropdown-disabled")}}}),$(document).on("click.jq-dropdown","[data-jq-dropdown]",t),$(document).on("click.jq-dropdown",o),$(window).on("resize",r)}(jQuery);
|
||||
90
vendor/assets/stylesheets/jquery.dropdown.css
vendored
Normal file
90
vendor/assets/stylesheets/jquery.dropdown.css
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/* jQuery Dropdown: A simple dropdown plugin
|
||||
*
|
||||
* Contribute: https://github.com/claviska/jquery-dropdown
|
||||
*
|
||||
* @license: MIT license: http://opensource.org/licenses/MIT
|
||||
*
|
||||
*/
|
||||
.jq-dropdown {
|
||||
position: absolute;
|
||||
z-index: 1039;
|
||||
display: none;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-menu,
|
||||
.jq-dropdown .jq-dropdown-panel {
|
||||
min-width: 160px;
|
||||
max-width: 360px;
|
||||
list-style: none;
|
||||
background: white;
|
||||
border: solid 1px #ddd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
overflow: visible;
|
||||
padding: 4px 0;
|
||||
margin: 0;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-panel {
|
||||
padding: 10px;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-tip {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-tip:before {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 9px;
|
||||
content: "";
|
||||
border-left: 7px solid transparent;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ddd;
|
||||
display: inline-block;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-tip:after {
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
left: 10px;
|
||||
content: "";
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid white;
|
||||
display: inline-block;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-tip.jq-dropdown-anchor-right:before {
|
||||
left: auto;
|
||||
right: 9px;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-tip.jq-dropdown-anchor-right:after {
|
||||
left: auto;
|
||||
right: 10px;
|
||||
}
|
||||
.jq-dropdown.jq-dropdown-scroll .jq-dropdown-menu,
|
||||
.jq-dropdown.jq-dropdown-scroll .jq-dropdown-panel {
|
||||
max-height: 180px;
|
||||
overflow: auto;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-menu li {
|
||||
list-style: none;
|
||||
padding: 0 0;
|
||||
text-indent: 0;
|
||||
margin: 0;
|
||||
line-height: 18px;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-menu li > a,
|
||||
.jq-dropdown .jq-dropdown-menu label {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
line-height: 18px;
|
||||
padding: 3px 15px;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-menu li > a:hover,
|
||||
.jq-dropdown .jq-dropdown-menu label:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.jq-dropdown .jq-dropdown-menu .jq-dropdown-divider {
|
||||
font-size: 1px;
|
||||
border-top: solid 1px #e5e5e5;
|
||||
padding: 0;
|
||||
margin: 5px 0;
|
||||
}
|
||||
Reference in New Issue
Block a user