diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d31bf51e4..d9ed43309 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,7 +2,6 @@ //= require jquery-ui-1.10.3.min.js //= require jquery.hotkeys.js //= require jquery.timeout.js -//= require typeahead.min.js //= require rails.js //= require common.js //= require_self diff --git a/app/assets/javascripts/artists.js b/app/assets/javascripts/artists.js index f51e03496..1d807788a 100644 --- a/app/assets/javascripts/artists.js +++ b/app/assets/javascripts/artists.js @@ -6,19 +6,30 @@ Danbooru.Artist.initialize_check_name_link(); if (Danbooru.meta("enable-auto-complete") === "true") { - Danbooru.Artist.initialize_typeahead(); + Danbooru.Artist.initialize_auto_complete(); } } } - Danbooru.Artist.initialize_typeahead = function() { - $("#quick_search_name").typeahead({ - name: "artists", - remote: "/artists.json?search[name]=*%QUERY*", - limit: 10, - valueKey: "name", - template: function(context) { - return "
" + context.name.replace(/_/g, " ") + "
"; + Danbooru.Artist.initialize_auto_complete = function() { + $("#quick_search_name").autocomplete({ + source: function(req, resp) { + $.ajax({ + url: "/artists.json", + data: { + "search[name]": "*" + req.term + "*" + }, + method: "get", + minLength: 2, + success: function(data) { + resp($.map(data, function(tag) { + return { + label: tag.name, + value: tag.name + }; + })); + } + }); } }); } diff --git a/app/assets/javascripts/pools.js b/app/assets/javascripts/pools.js index f543afd0d..8ca822b90 100644 --- a/app/assets/javascripts/pools.js +++ b/app/assets/javascripts/pools.js @@ -14,13 +14,25 @@ Danbooru.Pool.initialize_add_to_pool_link = function() { $("#add-to-pool-dialog").dialog({autoOpen: false}); - $("#c-pool-elements #a-new input[type=text]").typeahead({ - name: "pools", - remote: "/pools.json?search[is_active]=true&search[name_matches]=%QUERY", - limit: 10, - valueKey: "name", - template: function(context) { - return "" + context.name.replace(/_/g, " ") + "
"; + $("#c-pool-elements #a-new input[type=text]").autocomplete({ + source: function(req, resp) { + $.ajax({ + url: "/pools.json", + data: { + "search[is_active]": "true" + "search[name_matches]": req.term + }, + method: "get", + minLength: 2, + success: function(data) { + resp($.map(data, function(tag) { + return { + label: tag.name.replace(/_/g, " "), + value: tag.name + }; + })); + } + }); } }); diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 76a80dca5..8a8b95d47 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -36,13 +36,36 @@ } Danbooru.Post.initialize_tag_autocomplete = function() { - $("#tags").typeahead({ - name: "tags", - remote: "/tags.json?search[order]=count&search[name_matches]=%QUERY*", - limit: 10, - valueKey: "name", - template: function(context) { - return ""; + $("#tags,#post_tag_string,#upload_tag_string").autocomplete({ + focus: function() { + return false; + }, + select: function(event, ui) { + var terms = this.value.match(/\S+/g); + terms.pop(); + terms.push(ui.item.value); + this.value = terms.join(" ") + " "; + return false; + }, + source: function(req, resp) { + var term = req.term.match(/\S+/g).pop(); + $.ajax({ + url: "/tags.json", + data: { + "search[order]": "count", + "search[name_matches]": term + "*" + }, + method: "get", + minLength: 2, + success: function(data) { + resp($.map(data, function(tag) { + return { + label: tag.name, + value: tag.name + }; + })); + } + }); } }); } diff --git a/app/assets/javascripts/wiki_pages.js b/app/assets/javascripts/wiki_pages.js index 64eb9fd6e..739eb78b2 100644 --- a/app/assets/javascripts/wiki_pages.js +++ b/app/assets/javascripts/wiki_pages.js @@ -3,17 +3,32 @@ Danbooru.WikiPage.initialize_all = function() { if ($("#c-wiki-pages").length) { - if (Danbooru.meta("enable-auto-complete") === "true") { - $("#quick_search_title,#wiki_page_title").typeahead({ - name: "wiki_pages", - remote: "/wiki_pages.json?search[title]=*%QUERY*", - limit: 10, - valueKey: "title", - template: function(context) { - return "" + context.title.replace(/_/g, " ") + "
"; - } - }); - } + this.initialize_typeahead(); + } + } + + Danbooru.WikiPage.initialize_typeahead = function() { + if (Danbooru.meta("enable-auto-complete") === "true") { + $("#quick_search_title,#wiki_page_title").autocomplete({ + source: function(req, resp) { + $.ajax({ + url: "/wiki_pages.json", + data: { + "search[title]": "*" + req.term + "*" + }, + method: "get", + minLength: 2, + success: function(data) { + resp($.map(data, function(tag) { + return { + label: tag.title.replace(/_/g, " "), + value: tag.title + }; + })); + } + }); + } + }); } } })(); diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index 5da2b59b7..25e8a2849 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -50,27 +50,6 @@ a.blacklisted-active { background-color: rgba(0,0,0,0.1); } -.tt-suggestions { - background: white; - display: block; - border: 1px solid black; - margin: 0; - padding: 0; -} - -.tt-suggestion { - background: white; - padding: 0.25em 0.5em; -} - -.tt-is-under-cursor { - background: $highlight_color; -} - -.tt-suggestion p { - margin: 0; -} - #has-parent-relationship-preview, #has-children-relationship-preview { overflow-x: auto; white-space: nowrap; diff --git a/vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png b/vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png index ac8b229af..d262048da 100755 Binary files a/vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png and b/vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png differ diff --git a/vendor/assets/javascripts/jquery-ui-1.10.3.min.js b/vendor/assets/javascripts/jquery-ui-1.10.3.min.js index 32d5d5324..fa28d9d39 100644 --- a/vendor/assets/javascripts/jquery-ui-1.10.3.min.js +++ b/vendor/assets/javascripts/jquery-ui-1.10.3.min.js @@ -1,6 +1,6 @@ /*! jQuery UI - v1.10.3 - 2013-06-18 * http://jqueryui.com -* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.resizable.js, jquery.ui.sortable.js, jquery.ui.button.js, jquery.ui.dialog.js, jquery.ui.effect.js, jquery.ui.effect-fade.js, jquery.ui.effect-highlight.js, jquery.ui.effect-shake.js +* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.resizable.js, jquery.ui.sortable.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.effect.js, jquery.ui.effect-fade.js, jquery.ui.effect-highlight.js, jquery.ui.effect-shake.js * Copyright 2013 jQuery Foundation and other contributors Licensed MIT */ -(function(e,t){function i(t,i){var a,n,r,o=t.nodeName.toLowerCase();return"area"===o?(a=t.parentNode,n=a.name,t.href&&n&&"map"===a.nodeName.toLowerCase()?(r=e("img[usemap=#"+n+"]")[0],!!r&&s(r)):!1):(/input|select|textarea|button|object/.test(o)?!t.disabled:"a"===o?t.href||i:i)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a=0,n=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(i){if(i!==t)return this.css("zIndex",i);if(this.length)for(var s,a,n=e(this[0]);n.length&&n[0]!==document;){if(s=n.css("position"),("absolute"===s||"relative"===s||"fixed"===s)&&(a=parseInt(n.css("zIndex"),10),!isNaN(a)&&0!==a))return a;n=n.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++a)})},removeUniqueId:function(){return this.each(function(){n.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var s=e.attr(t,"tabindex"),a=isNaN(s);return(a||s>=0)&&i(t,!a)}}),e("").outerWidth(1).jquery||e.each(["Width","Height"],function(i,s){function a(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===s?["Left","Right"]:["Top","Bottom"],r=s.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+s]=function(i){return i===t?o["inner"+s].call(this):this.each(function(){e(this).css(r,a(this,i)+"px")})},e.fn["outer"+s]=function(t,i){return"number"!=typeof t?o["outer"+s].call(this,t):this.each(function(){e(this).css(r,a(this,t,!0,i)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,i,s){var a,n=e.ui[t].prototype;for(a in s)n.plugins[a]=n.plugins[a]||[],n.plugins[a].push([i,s[a]])},call:function(e,t,i){var s,a=e.plugins[t];if(a&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(s=0;a.length>s;s++)e.options[a[s][0]]&&a[s][1].apply(e.element,i)}},hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",a=!1;return t[s]>0?!0:(t[s]=1,a=t[s]>0,t[s]=0,a)}})})(jQuery);(function(e,t){var i=0,s=Array.prototype.slice,n=e.cleanData;e.cleanData=function(t){for(var i,s=0;null!=(i=t[s]);s++)try{e(i).triggerHandler("remove")}catch(a){}n(t)},e.widget=function(i,s,n){var a,r,o,h,l={},u=i.split(".")[0];i=i.split(".")[1],a=u+"-"+i,n||(n=s,s=e.Widget),e.expr[":"][a.toLowerCase()]=function(t){return!!e.data(t,a)},e[u]=e[u]||{},r=e[u][i],o=e[u][i]=function(e,i){return this._createWidget?(arguments.length&&this._createWidget(e,i),t):new o(e,i)},e.extend(o,r,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),h=new s,h.options=e.widget.extend({},h.options),e.each(n,function(i,n){return e.isFunction(n)?(l[i]=function(){var e=function(){return s.prototype[i].apply(this,arguments)},t=function(e){return s.prototype[i].apply(this,e)};return function(){var i,s=this._super,a=this._superApply;return this._super=e,this._superApply=t,i=n.apply(this,arguments),this._super=s,this._superApply=a,i}}(),t):(l[i]=n,t)}),o.prototype=e.widget.extend(h,{widgetEventPrefix:r?h.widgetEventPrefix:i},l,{constructor:o,namespace:u,widgetName:i,widgetFullName:a}),r?(e.each(r._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete r._childConstructors):s._childConstructors.push(o),e.widget.bridge(i,o)},e.widget.extend=function(i){for(var n,a,r=s.call(arguments,1),o=0,h=r.length;h>o;o++)for(n in r[o])a=r[o][n],r[o].hasOwnProperty(n)&&a!==t&&(i[n]=e.isPlainObject(a)?e.isPlainObject(i[n])?e.widget.extend({},i[n],a):e.widget.extend({},a):a);return i},e.widget.bridge=function(i,n){var a=n.prototype.widgetFullName||i;e.fn[i]=function(r){var o="string"==typeof r,h=s.call(arguments,1),l=this;return r=!o&&h.length?e.widget.extend.apply(null,[r].concat(h)):r,o?this.each(function(){var s,n=e.data(this,a);return n?e.isFunction(n[r])&&"_"!==r.charAt(0)?(s=n[r].apply(n,h),s!==n&&s!==t?(l=s&&s.jquery?l.pushStack(s.get()):s,!1):t):e.error("no such method '"+r+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+r+"'")}):this.each(function(){var t=e.data(this,a);t?t.option(r||{})._init():e.data(this,a,new n(r,this))}),l}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"