Making WordPress.org

Ticket #542: 542.2.patch

File 542.2.patch, 25.1 KB (added by keesiemeijer, 8 years ago)

Add partial matches for autocomplete list

  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php

     
    7171require __DIR__ . '/inc/formatting.php';
    7272
    7373/**
     74 * Autocomplete.
     75 */
     76require __DIR__ . '/inc/autocomplete.php';
     77
     78/**
    7479 * Set the content width based on the theme's design and stylesheet.
    7580 */
    7681if ( ! isset( $content_width ) ) {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/autocomplete.php

     
     1<?php
     2/**
     3 * Code Reference autocomplete for the search form.
     4 *
     5 * @package wporg-developer
     6 */
     7
     8/**
     9 * Class to handle autocomplete for the search form.
     10 */
     11class DevHub_Search_Form_Autocomplete {
     12
     13
     14        public function __construct() {
     15                $this->init();
     16        }
     17
     18        /**
     19         * Initialization
     20         *
     21         * @access public
     22         */
     23        public function init() {
     24
     25                add_action( 'wp_ajax_autocomplete',  array( $this, 'autocomplete_data_update' ) );
     26                add_action( "wp_ajax_nopriv_autocomplete",  array( $this, 'autocomplete_data_update' ) );
     27
     28                // Enqueue scripts and styles.
     29                add_action( 'wp_enqueue_scripts', array( $this, 'scripts_and_styles' ), 11 );
     30        }
     31
     32
     33        /**
     34         * Enqueues scripts and styles.
     35         *
     36         * @access public
     37         */
     38        public function scripts_and_styles() {
     39
     40                wp_enqueue_style( 'awesomplete-css', get_template_directory_uri() . '/stylesheets/awesomplete.css', array(), '20160114' );
     41                wp_enqueue_style( 'autocomplete-css', get_template_directory_uri() . '/stylesheets/autocomplete.css', array(), '20160114' );
     42
     43                wp_register_script( 'awesomplete', get_template_directory_uri() . '/js/awesomplete.min.js', array(), '20160114', true );
     44                wp_enqueue_script( 'awesomplete' );
     45
     46                wp_register_script( 'autocomplete', get_template_directory_uri() . '/js/autocomplete.js', array( 'awesomplete' ), '20160114', true );
     47                wp_localize_script( 'autocomplete', 'autocomplete', array(
     48                                'ajaxurl' => admin_url( 'admin-ajax.php' ),
     49                                'nonce'   => wp_create_nonce( 'autocomplete_nonce' ),
     50                        )
     51                );
     52
     53                wp_enqueue_script( 'autocomplete' );
     54        }
     55
     56
     57        /**
     58         * Handles AJAX updates for the autocomplete list.
     59         *
     60         * @access public
     61         *
     62         * @return string JSON data
     63         */
     64        public function autocomplete_data_update() {
     65
     66                check_ajax_referer( 'autocomplete_nonce', 'nonce' );
     67
     68                if ( !( isset( $_POST['data'] ) && $_POST['data'] ) ) {
     69                        wp_send_json_error();
     70                }
     71
     72                // Parse the search form fields.
     73                wp_parse_str( $_POST['data'], $form_data );
     74
     75                if ( !isset( $form_data['post_type'] ) || !isset( $form_data['s'] ) ) {
     76                        wp_send_json_error();
     77                }
     78
     79                $post_types        = array();
     80                $parser_post_types = DevHub\get_parsed_post_types();
     81
     82                foreach ( $form_data['post_type'] as $post_type ) {
     83                        if ( in_array( $post_type , $parser_post_types ) ) {
     84                                $post_types[] = $post_type;
     85                        }
     86                }
     87
     88                $args = array(
     89                        'posts_per_page'       => -1,
     90                        'post_type'            => $post_types,
     91                        's'                    => $form_data['s'],
     92                        'orderby'              => '',
     93                        'search_orderby_title' => 1,
     94                        'order'                => 'ASC',
     95                );
     96
     97                $search = get_posts( $args );
     98
     99                $form_data['posts'] = array();
     100                if ( !empty( $search ) ) {
     101                        $form_data['posts'] = wp_list_pluck( $search, 'post_title' );
     102                }
     103
     104                wp_send_json_success ( $form_data );
     105        }
     106
     107
     108}
     109
     110$autocomplete = new DevHub_Search_Form_Autocomplete();
     111 No newline at end of file
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/autocomplete.js

     
     1/**
     2 * Autocomplete JS.
     3 *
     4 * Uses the Awesomplete widget from Lea Verou.
     5 * https://leaverou.github.io/awesomplete/
     6 */
     7
     8( function( $ ) {
     9
     10        if ( typeof autocomplete === 'undefined' ) {
     11                return;
     12        }
     13
     14        var form = $( '.searchform' ),
     15                searchfield = $( '#search-field', form ),
     16                processing = false,
     17                search = '';
     18
     19        var awesome = new Awesomplete( searchfield.get( 0 ), {
     20                maxItems: 9999,
     21                filter: function( text, input ) {
     22                        // Filter autocomplete matches
     23
     24                        // Full match
     25                        if ( Awesomplete.FILTER_CONTAINS( text, input ) ) {
     26                                // mark
     27                                return true;
     28                        }
     29
     30                        // Replace - _ and whitespace with a single space
     31                        var _text = Awesomplete.$.regExpEscape( text.trim().toLowerCase().replace( /[\_\-\s]+/g, ' ' ) );
     32                        var _input = Awesomplete.$.regExpEscape( input.trim().toLowerCase().replace( /[\_\-\s]+/g, ' ' ) );
     33
     34                        // Matches with with single spaces between words
     35                        if ( Awesomplete.FILTER_CONTAINS( _text, _input ) ) {
     36                                return true;
     37                        }
     38
     39                        _input = _input.split( " " );
     40                        var words = _input.length;
     41
     42                        if ( 1 >= words ) {
     43                                return false;
     44                        }
     45
     46                        // Partial matches
     47                        var partials = 0;
     48                        for ( i = 0; i < words; i++ ) {
     49                                if ( _text.indexOf( _input[ i ].trim() ) !== -1 ) {
     50                                        partials++;
     51                                }
     52                        }
     53
     54                        if ( partials === words ) {
     55                                return true;
     56                        }
     57
     58                        return false;
     59                }
     60        } );
     61
     62        // On input event for the search field.
     63        searchfield.on( 'input.autocomplete', function( e ) {
     64
     65                // Update the autocomlete list:
     66                //     if there are more than 2 characters
     67                //     and it's not already processing an Ajax request
     68                if ( !processing && $( this ).val().length > 2 ) {
     69                        search = $( this ).val();
     70                        autocomplete_update();
     71                }
     72        } );
     73
     74
     75        /**
     76         * Updates the autocomplete list
     77         */
     78        function autocomplete_update() {
     79
     80                processing = true;
     81
     82                var data = {
     83                        action: "autocomplete",
     84                        data: form.serialize(),
     85                        nonce: autocomplete.nonce,
     86                };
     87
     88                $.post( autocomplete.ajaxurl, data )
     89                        .done( function( response ) {
     90
     91                                if ( typeof response.success === 'undefined' ) {
     92                                        return false;
     93                                }
     94
     95                                if ( typeof response.data.posts === 'undefined' ) {
     96                                        return false;
     97                                }
     98
     99                                if ( ( response.success === true ) && response.data.posts.length ) {
     100                                        // Update the autocomplete list
     101                                        awesome.list = response.data.posts;
     102                                }
     103                        } )
     104                        .always( function() {
     105                                processing = false;
     106
     107                                // Check if the search was updated during processing
     108                                if ( search !== searchfield.val() ) {
     109                                        searchfield.trigger( "input.autocomplete" );
     110                                }
     111                        } );
     112        }
     113
     114} )( jQuery );
     115 No newline at end of file
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/awesomplete.js

     
     1/**
     2 * Simple, lightweight, usable local autocomplete library for modern browsers
     3 * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P
     4 * @author Lea Verou http://leaverou.github.io/awesomplete
     5 * MIT license
     6 */
     7
     8(function () {
     9
     10var _ = function (input, o) {
     11        var me = this;
     12
     13        // Setup
     14
     15        this.input = $(input);
     16        this.input.setAttribute("autocomplete", "off");
     17        this.input.setAttribute("aria-autocomplete", "list");
     18
     19        o = o || {};
     20
     21        configure.call(this, {
     22                minChars: 2,
     23                maxItems: 10,
     24                autoFirst: false,
     25                filter: _.FILTER_CONTAINS,
     26                sort: _.SORT_BYLENGTH,
     27                item: function (text, input) {
     28                        var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
     29                        return $.create("li", {
     30                                innerHTML: html,
     31                                "aria-selected": "false"
     32                        });
     33                },
     34                replace: function (text) {
     35                        this.input.value = text;
     36                }
     37        }, o);
     38
     39        this.index = -1;
     40
     41        // Create necessary elements
     42
     43        this.container = $.create("div", {
     44                className: "awesomplete",
     45                around: input
     46        });
     47
     48        this.ul = $.create("ul", {
     49                hidden: "hidden",
     50                inside: this.container
     51        });
     52
     53        this.status = $.create("span", {
     54                className: "visually-hidden",
     55                role: "status",
     56                "aria-live": "assertive",
     57                "aria-relevant": "additions",
     58                inside: this.container
     59        });
     60
     61        // Bind events
     62
     63        $.bind(this.input, {
     64                "input": this.evaluate.bind(this),
     65                "blur": this.close.bind(this),
     66                "keydown": function(evt) {
     67                        var c = evt.keyCode;
     68
     69                        // If the dropdown `ul` is in view, then act on keydown for the following keys:
     70                        // Enter / Esc / Up / Down
     71                        if(me.opened) {
     72                                if (c === 13 && me.selected) { // Enter
     73                                        evt.preventDefault();
     74                                        me.select();
     75                                }
     76                                else if (c === 27) { // Esc
     77                                        me.close();
     78                                }
     79                                else if (c === 38 || c === 40) { // Down/Up arrow
     80                                        evt.preventDefault();
     81                                        me[c === 38? "previous" : "next"]();
     82                                }
     83                        }
     84                }
     85        });
     86
     87        $.bind(this.input.form, {"submit": this.close.bind(this)});
     88
     89        $.bind(this.ul, {"mousedown": function(evt) {
     90                var li = evt.target;
     91
     92                if (li !== this) {
     93
     94                        while (li && !/li/i.test(li.nodeName)) {
     95                                li = li.parentNode;
     96                        }
     97
     98                        if (li && evt.button === 0) {  // Only select on left click
     99                                evt.preventDefault();
     100                                me.select(li, evt);
     101                        }
     102                }
     103        }});
     104
     105        if (this.input.hasAttribute("list")) {
     106                this.list = "#" + this.input.getAttribute("list");
     107                this.input.removeAttribute("list");
     108        }
     109        else {
     110                this.list = this.input.getAttribute("data-list") || o.list || [];
     111        }
     112
     113        _.all.push(this);
     114};
     115
     116_.prototype = {
     117        set list(list) {
     118                if (Array.isArray(list)) {
     119                        this._list = list;
     120                }
     121                else if (typeof list === "string" && list.indexOf(",") > -1) {
     122                                this._list = list.split(/\s*,\s*/);
     123                }
     124                else { // Element or CSS selector
     125                        list = $(list);
     126
     127                        if (list && list.children) {
     128                                this._list = slice.apply(list.children).map(function (el) {
     129                                        return el.textContent.trim();
     130                                });
     131                        }
     132                }
     133
     134                if (document.activeElement === this.input) {
     135                        this.evaluate();
     136                }
     137        },
     138
     139        get selected() {
     140                return this.index > -1;
     141        },
     142
     143        get opened() {
     144                return this.ul && this.ul.getAttribute("hidden") == null;
     145        },
     146
     147        close: function () {
     148                this.ul.setAttribute("hidden", "");
     149                this.index = -1;
     150
     151                $.fire(this.input, "awesomplete-close");
     152        },
     153
     154        open: function () {
     155                this.ul.removeAttribute("hidden");
     156
     157                if (this.autoFirst && this.index === -1) {
     158                        this.goto(0);
     159                }
     160
     161                $.fire(this.input, "awesomplete-open");
     162        },
     163
     164        next: function () {
     165                var count = this.ul.children.length;
     166
     167                this.goto(this.index < count - 1? this.index + 1 : -1);
     168        },
     169
     170        previous: function () {
     171                var count = this.ul.children.length;
     172
     173                this.goto(this.selected? this.index - 1 : count - 1);
     174        },
     175
     176        // Should not be used, highlights specific item without any checks!
     177        goto: function (i) {
     178                var lis = this.ul.children;
     179
     180                if (this.selected) {
     181                        lis[this.index].setAttribute("aria-selected", "false");
     182                }
     183
     184                this.index = i;
     185
     186                if (i > -1 && lis.length > 0) {
     187                        lis[i].setAttribute("aria-selected", "true");
     188                        this.status.textContent = lis[i].textContent;
     189                }
     190
     191                $.fire(this.input, "awesomplete-highlight");
     192        },
     193
     194        select: function (selected, originalEvent) {
     195                selected = selected || this.ul.children[this.index];
     196
     197                if (selected) {
     198                        var prevented;
     199
     200                        $.fire(this.input, "awesomplete-select", {
     201                                text: selected.textContent,
     202                                preventDefault: function () {
     203                                        prevented = true;
     204                                },
     205                                originalEvent: originalEvent
     206                        });
     207
     208                        if (!prevented) {
     209                                this.replace(selected.textContent);
     210                                this.close();
     211                                $.fire(this.input, "awesomplete-selectcomplete");
     212                        }
     213                }
     214        },
     215
     216        evaluate: function() {
     217                var me = this;
     218                var value = this.input.value;
     219
     220                if (value.length >= this.minChars && this._list.length > 0) {
     221                        this.index = -1;
     222                        // Populate list with options that match
     223                        this.ul.innerHTML = "";
     224
     225                        this._list
     226                                .filter(function(item) {
     227                                        return me.filter(item, value);
     228                                })
     229                                .sort(this.sort)
     230                                .every(function(text, i) {
     231                                        me.ul.appendChild(me.item(text, value));
     232
     233                                        return i < me.maxItems - 1;
     234                                });
     235
     236                        if (this.ul.children.length === 0) {
     237                                this.close();
     238                        } else {
     239                                this.open();
     240                        }
     241                }
     242                else {
     243                        this.close();
     244                }
     245        }
     246};
     247
     248// Static methods/properties
     249
     250_.all = [];
     251
     252_.FILTER_CONTAINS = function (text, input) {
     253        return RegExp($.regExpEscape(input.trim()), "i").test(text);
     254};
     255
     256_.FILTER_STARTSWITH = function (text, input) {
     257        return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text);
     258};
     259
     260_.SORT_BYLENGTH = function (a, b) {
     261        if (a.length !== b.length) {
     262                return a.length - b.length;
     263        }
     264
     265        return a < b? -1 : 1;
     266};
     267
     268// Private functions
     269
     270function configure(properties, o) {
     271        for (var i in properties) {
     272                var initial = properties[i],
     273                    attrValue = this.input.getAttribute("data-" + i.toLowerCase());
     274
     275                if (typeof initial === "number") {
     276                        this[i] = parseInt(attrValue);
     277                }
     278                else if (initial === false) { // Boolean options must be false by default anyway
     279                        this[i] = attrValue !== null;
     280                }
     281                else if (initial instanceof Function) {
     282                        this[i] = null;
     283                }
     284                else {
     285                        this[i] = attrValue;
     286                }
     287
     288                if (!this[i] && this[i] !== 0) {
     289                        this[i] = (i in o)? o[i] : initial;
     290                }
     291        }
     292}
     293
     294// Helpers
     295
     296var slice = Array.prototype.slice;
     297
     298function $(expr, con) {
     299        return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
     300}
     301
     302function $$(expr, con) {
     303        return slice.call((con || document).querySelectorAll(expr));
     304}
     305
     306$.create = function(tag, o) {
     307        var element = document.createElement(tag);
     308
     309        for (var i in o) {
     310                var val = o[i];
     311
     312                if (i === "inside") {
     313                        $(val).appendChild(element);
     314                }
     315                else if (i === "around") {
     316                        var ref = $(val);
     317                        ref.parentNode.insertBefore(element, ref);
     318                        element.appendChild(ref);
     319                }
     320                else if (i in element) {
     321                        element[i] = val;
     322                }
     323                else {
     324                        element.setAttribute(i, val);
     325                }
     326        }
     327
     328        return element;
     329};
     330
     331$.bind = function(element, o) {
     332        if (element) {
     333                for (var event in o) {
     334                        var callback = o[event];
     335
     336                        event.split(/\s+/).forEach(function (event) {
     337                                element.addEventListener(event, callback);
     338                        });
     339                }
     340        }
     341};
     342
     343$.fire = function(target, type, properties) {
     344        var evt = document.createEvent("HTMLEvents");
     345
     346        evt.initEvent(type, true, true );
     347
     348        for (var j in properties) {
     349                evt[j] = properties[j];
     350        }
     351
     352        target.dispatchEvent(evt);
     353};
     354
     355$.regExpEscape = function (s) {
     356        return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
     357}
     358
     359// Initialization
     360
     361function init() {
     362        $$("input.awesomplete").forEach(function (input) {
     363                new _(input);
     364        });
     365}
     366
     367// Are we in a browser? Check for Document constructor
     368if (typeof Document !== "undefined") {
     369        // DOM already loaded?
     370        if (document.readyState !== "loading") {
     371                init();
     372        }
     373        else {
     374                // Wait for it
     375                document.addEventListener("DOMContentLoaded", init);
     376        }
     377}
     378
     379_.$ = $;
     380_.$$ = $$;
     381
     382// Make sure to export Awesomplete on self when in a browser
     383if (typeof self !== "undefined") {
     384        self.Awesomplete = _;
     385}
     386
     387// Expose Awesomplete as a CJS module
     388if (typeof module === "object" && module.exports) {
     389        module.exports = _;
     390}
     391
     392return _;
     393
     394}());
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/awesomplete.min.js

    Property changes on: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/awesomplete.js
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
    \ No newline at end of property
     
     1// Awesomplete - Lea Verou - MIT license
     2(function(){function m(a,b){for(var c in a){var g=a[c],e=this.input.getAttribute("data-"+c.toLowerCase());this[c]="number"===typeof g?parseInt(e):!1===g?null!==e:g instanceof Function?null:e;this[c]||0===this[c]||(this[c]=c in b?b[c]:g)}}function d(a,b){return"string"===typeof a?(b||document).querySelector(a):a||null}function h(a,b){return k.call((b||document).querySelectorAll(a))}function l(){h("input.awesomplete").forEach(function(a){new f(a)})}var f=function(a,b){var c=this;this.input=d(a);this.input.setAttribute("autocomplete",
     3"off");this.input.setAttribute("aria-autocomplete","list");b=b||{};m.call(this,{minChars:2,maxItems:10,autoFirst:!1,filter:f.FILTER_CONTAINS,sort:f.SORT_BYLENGTH,item:function(a,b){var c=""===b?a:a.replace(RegExp(d.regExpEscape(b.trim()),"gi"),"<mark>$&</mark>");return d.create("li",{innerHTML:c,"aria-selected":"false"})},replace:function(a){this.input.value=a}},b);this.index=-1;this.container=d.create("div",{className:"awesomplete",around:a});this.ul=d.create("ul",{hidden:"hidden",inside:this.container});
     4this.status=d.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-relevant":"additions",inside:this.container});d.bind(this.input,{input:this.evaluate.bind(this),blur:this.close.bind(this),keydown:function(a){var b=a.keyCode;if(c.opened)if(13===b&&c.selected)a.preventDefault(),c.select();else if(27===b)c.close();else if(38===b||40===b)a.preventDefault(),c[38===b?"previous":"next"]()}});d.bind(this.input.form,{submit:this.close.bind(this)});d.bind(this.ul,{mousedown:function(a){var b=
     5a.target;if(b!==this){for(;b&&!/li/i.test(b.nodeName);)b=b.parentNode;b&&0===a.button&&c.select(b,a)}}});this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||b.list||[];f.all.push(this)};f.prototype={set list(a){Array.isArray(a)?this._list=a:"string"===typeof a&&-1<a.indexOf(",")?this._list=a.split(/\s*,\s*/):(a=d(a))&&a.children&&(this._list=k.apply(a.children).map(function(a){return a.textContent.trim()}));
     6document.activeElement===this.input&&this.evaluate()},get selected(){return-1<this.index},get opened(){return this.ul&&null==this.ul.getAttribute("hidden")},close:function(){this.ul.setAttribute("hidden","");this.index=-1;d.fire(this.input,"awesomplete-close")},open:function(){this.ul.removeAttribute("hidden");this.autoFirst&&-1===this.index&&this["goto"](0);d.fire(this.input,"awesomplete-open")},next:function(){this["goto"](this.index<this.ul.children.length-1?this.index+1:-1)},previous:function(){var a=
     7this.ul.children.length;this["goto"](this.selected?this.index-1:a-1)},"goto":function(a){var b=this.ul.children;this.selected&&b[this.index].setAttribute("aria-selected","false");this.index=a;-1<a&&0<b.length&&(b[a].setAttribute("aria-selected","true"),this.status.textContent=b[a].textContent);d.fire(this.input,"awesomplete-highlight")},select:function(a,b){if(a=a||this.ul.children[this.index]){var c;d.fire(this.input,"awesomplete-select",{text:a.textContent,preventDefault:function(){c=!0},originalEvent:b});
     8c||(this.replace(a.textContent),this.close(),d.fire(this.input,"awesomplete-selectcomplete"))}},evaluate:function(){var a=this,b=this.input.value;b.length>=this.minChars&&0<this._list.length?(this.index=-1,this.ul.innerHTML="",this._list.filter(function(c){return a.filter(c,b)}).sort(this.sort).every(function(c,d){a.ul.appendChild(a.item(c,b));return d<a.maxItems-1}),0===this.ul.children.length?this.close():this.open()):this.close()}};f.all=[];f.FILTER_CONTAINS=function(a,b){return RegExp(d.regExpEscape(b.trim()),
     9"i").test(a)};f.FILTER_STARTSWITH=function(a,b){return RegExp("^"+d.regExpEscape(b.trim()),"i").test(a)};f.SORT_BYLENGTH=function(a,b){return a.length!==b.length?a.length-b.length:a<b?-1:1};var k=Array.prototype.slice;d.create=function(a,b){var c=document.createElement(a),g;for(g in b){var e=b[g];"inside"===g?d(e).appendChild(c):"around"===g?(e=d(e),e.parentNode.insertBefore(c,e),c.appendChild(e)):g in c?c[g]=e:c.setAttribute(g,e)}return c};d.bind=function(a,b){if(a)for(var c in b){var d=b[c];c.split(/\s+/).forEach(function(b){a.addEventListener(b,
     10d)})}};d.fire=function(a,b,c){var d=document.createEvent("HTMLEvents");d.initEvent(b,!0,!0);for(var e in c)d[e]=c[e];a.dispatchEvent(d)};d.regExpEscape=function(a){return a.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")};"undefined"!==typeof Document&&("loading"!==document.readyState?l():document.addEventListener("DOMContentLoaded",l));f.$=d;f.$$=h;"undefined"!==typeof self&&(self.Awesomplete=f);"object"===typeof module&&module.exports&&(module.exports=f);return f})();
     11 No newline at end of file
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/autocomplete.css

    Property changes on: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/awesomplete.min.js
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
    \ No newline at end of property
     
     1/**
     2 * Autocomplete Css
     3 *
     4 * Mainly overrides for awesomplete.css
     5 */
     6div.awesomplete > ul > li:hover {
     7        background: hsl(200, 40%, 90%);
     8}
     9
     10div.awesomplete > ul > li[aria-selected="true"] {
     11                background: hsl(200, 40%, 80%);
     12                color: #404040;
     13}
     14
     15div.awesomplete mark {
     16        color: #404040;
     17}
     18
     19div.awesomplete li:hover mark, div.awesomplete li[aria-selected="true"] mark {
     20        background: hsl(65, 100%, 49%);
     21}
     22
     23.devhub-wrap div.awesomplete > ul {
     24        max-height: 13.5em;
     25        color: #404040;
     26        margin-top: -.9em;
     27        overflow: auto;
     28        background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.9));
     29}
     30
     31.devhub-wrap .searchform label div.awesomplete > input,
     32.devhub-wrap div.awesomplete { 
     33        width: 100%;
     34}
     35
     36.devhub-wrap .searchform div.search-post-type {
     37        clear: both;
     38}
     39
     40.devhub-wrap .searchform,
     41.devhub-wrap .searchform div:first-child,
     42.devhub-wrap div.awesomplete {
     43        /* Needs to be visible for the awesomplete popup */
     44        overflow: visible;
     45}
     46
     47div.awesomplete > ul > li:hover {
     48                color: black;
     49}
     50
     51div.awesomplete > ul:before {
     52        content: none;
     53}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/awesomplete.css

     
     1[hidden] { display: none; }
     2
     3.visually-hidden {
     4        position: absolute;
     5        clip: rect(0, 0, 0, 0);
     6}
     7
     8div.awesomplete {
     9        display: inline-block;
     10        position: relative;
     11}
     12
     13div.awesomplete > input {
     14        display: block;
     15}
     16
     17div.awesomplete > ul {
     18        position: absolute;
     19        left: 0;
     20        z-index: 1;
     21        min-width: 100%;
     22        box-sizing: border-box;
     23        list-style: none;
     24        padding: 0;
     25        border-radius: .3em;
     26        margin: .2em 0 0;
     27        background: hsla(0,0%,100%,.9);
     28        background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));
     29        border: 1px solid rgba(0,0,0,.3);
     30        box-shadow: .05em .2em .6em rgba(0,0,0,.2);
     31        text-shadow: none;
     32}
     33
     34div.awesomplete > ul[hidden],
     35div.awesomplete > ul:empty {
     36        display: none;
     37}
     38
     39@supports (transform: scale(0)) {
     40        div.awesomplete > ul {
     41                transition: .3s cubic-bezier(.4,.2,.5,1.4);
     42                transform-origin: 1.43em -.43em;
     43        }
     44       
     45        div.awesomplete > ul[hidden],
     46        div.awesomplete > ul:empty {
     47                opacity: 0;
     48                transform: scale(0);
     49                display: block;
     50                transition-timing-function: ease;
     51        }
     52}
     53
     54        /* Pointer */
     55        div.awesomplete > ul:before {
     56                content: "";
     57                position: absolute;
     58                top: -.43em;
     59                left: 1em;
     60                width: 0; height: 0;
     61                padding: .4em;
     62                background: white;
     63                border: inherit;
     64                border-right: 0;
     65                border-bottom: 0;
     66                -webkit-transform: rotate(45deg);
     67                transform: rotate(45deg);
     68        }
     69
     70        div.awesomplete > ul > li {
     71                position: relative;
     72                padding: .2em .5em;
     73                cursor: pointer;
     74        }
     75       
     76        div.awesomplete > ul > li:hover {
     77                background: hsl(200, 40%, 80%);
     78                color: black;
     79        }
     80       
     81        div.awesomplete > ul > li[aria-selected="true"] {
     82                background: hsl(205, 40%, 40%);
     83                color: white;
     84        }
     85       
     86                div.awesomplete mark {
     87                        background: hsl(65, 100%, 50%);
     88                }
     89               
     90                div.awesomplete li:hover mark {
     91                        background: hsl(68, 100%, 41%);
     92                }
     93               
     94                div.awesomplete li[aria-selected="true"] mark {
     95                        background: hsl(86, 100%, 21%);
     96                        color: inherit;
     97                }
     98 No newline at end of file