diff options
Diffstat (limited to 'js/components/search.js')
| -rwxr-xr-x | js/components/search.js | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/js/components/search.js b/js/components/search.js deleted file mode 100755 index 6f8a46e..0000000 --- a/js/components/search.js +++ /dev/null | |||
| @@ -1,92 +0,0 @@ | |||
| 1 | /*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ | ||
| 2 | (function(addon) { | ||
| 3 | |||
| 4 | var component; | ||
| 5 | |||
| 6 | if (window.UIkit) { | ||
| 7 | component = addon(UIkit); | ||
| 8 | } | ||
| 9 | |||
| 10 | if (typeof define == "function" && define.amd) { | ||
| 11 | define("uikit-search", ["uikit"], function(){ | ||
| 12 | return component || addon(UIkit); | ||
| 13 | }); | ||
| 14 | } | ||
| 15 | |||
| 16 | })(function(UI){ | ||
| 17 | |||
| 18 | "use strict"; | ||
| 19 | |||
| 20 | UI.component('search', { | ||
| 21 | defaults: { | ||
| 22 | msgResultsHeader : 'Search Results', | ||
| 23 | msgMoreResults : 'More Results', | ||
| 24 | msgNoResults : 'No results found', | ||
| 25 | template : '<ul class="uk-nav uk-nav-search uk-autocomplete-results">\ | ||
| 26 | {{#msgResultsHeader}}<li class="uk-nav-header uk-skip">{{msgResultsHeader}}</li>{{/msgResultsHeader}}\ | ||
| 27 | {{#items && items.length}}\ | ||
| 28 | {{~items}}\ | ||
| 29 | <li data-url="{{!$item.url}}">\ | ||
| 30 | <a href="{{!$item.url}}">\ | ||
| 31 | {{{$item.title}}}\ | ||
| 32 | {{#$item.text}}<div>{{{$item.text}}}</div>{{/$item.text}}\ | ||
| 33 | </a>\ | ||
| 34 | </li>\ | ||
| 35 | {{/items}}\ | ||
| 36 | {{#msgMoreResults}}\ | ||
| 37 | <li class="uk-nav-divider uk-skip"></li>\ | ||
| 38 | <li class="uk-search-moreresults" data-moreresults="true"><a href="#" onclick="jQuery(this).closest(\'form\').submit();">{{msgMoreResults}}</a></li>\ | ||
| 39 | {{/msgMoreResults}}\ | ||
| 40 | {{/end}}\ | ||
| 41 | {{^items.length}}\ | ||
| 42 | {{#msgNoResults}}<li class="uk-skip"><a>{{msgNoResults}}</a></li>{{/msgNoResults}}\ | ||
| 43 | {{/end}}\ | ||
| 44 | </ul>', | ||
| 45 | |||
| 46 | renderer: function(data) { | ||
| 47 | |||
| 48 | var opts = this.options; | ||
| 49 | |||
| 50 | this.dropdown.append(this.template({"items":data.results || [], "msgResultsHeader":opts.msgResultsHeader, "msgMoreResults": opts.msgMoreResults, "msgNoResults": opts.msgNoResults})); | ||
| 51 | this.show(); | ||
| 52 | } | ||
| 53 | }, | ||
| 54 | |||
| 55 | boot: function() { | ||
| 56 | |||
| 57 | // init code | ||
| 58 | UI.$html.on("focus.search.uikit", "[data-uk-search]", function(e) { | ||
| 59 | var ele =UI.$(this); | ||
| 60 | |||
| 61 | if (!ele.data("search")) { | ||
| 62 | UI.search(ele, UI.Utils.options(ele.attr("data-uk-search"))); | ||
| 63 | } | ||
| 64 | }); | ||
| 65 | }, | ||
| 66 | |||
| 67 | init: function() { | ||
| 68 | var $this = this; | ||
| 69 | |||
| 70 | this.autocomplete = UI.autocomplete(this.element, this.options); | ||
| 71 | |||
| 72 | this.autocomplete.dropdown.addClass('uk-dropdown-search'); | ||
| 73 | |||
| 74 | this.autocomplete.input.on("keyup", function(){ | ||
| 75 | $this.element[$this.autocomplete.input.val() ? "addClass":"removeClass"]("uk-active"); | ||
| 76 | }).closest("form").on("reset", function(){ | ||
| 77 | $this.value=""; | ||
| 78 | $this.element.removeClass("uk-active"); | ||
| 79 | }); | ||
| 80 | |||
| 81 | this.on('selectitem.uk.autocomplete', function(e, data) { | ||
| 82 | if (data.url) { | ||
| 83 | location.href = data.url; | ||
| 84 | } else if(data.moreresults) { | ||
| 85 | $this.autocomplete.input.closest('form').submit(); | ||
| 86 | } | ||
| 87 | }); | ||
| 88 | |||
| 89 | this.element.data("search", this); | ||
| 90 | } | ||
| 91 | }); | ||
| 92 | }); | ||
