]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/jquery/suggest.js
WordPress 4.6.3-scripts
[autoinstalls/wordpress.git] / wp-includes / js / jquery / suggest.js
index 7f46cbc643f4b1e070489082025d2762482a16e0..97aab0523793d89168b8fd0b46003bff8df9ef3c 100644 (file)
@@ -18,7 +18,7 @@
                var $input, $results, timeout, prevLength, cache, cacheSize;
 
                $input = $(input).attr("autocomplete", "off");
-               $results = $(document.createElement("ul"));
+               $results = $("<ul/>");
 
                timeout = false;                // hold timeout ID for suggestion results to appear
                prevLength = 0;                 // last recorded length of $input.val()
 
                resetPosition();
                $(window)
-                       .load(resetPosition)            // just in case user is changing size of page while loading
-                       .resize(resetPosition);
+                       .on( 'load', resetPosition ) // just in case user is changing size of page while loading
+                       .on( 'resize', resetPosition );
 
                $input.blur(function() {
                        setTimeout(function() { $results.hide() }, 200);
                });
 
-
-               // help IE users if possible
-               if ( $.browser.msie ) {
-                       try {
-                               $results.bgiframe();
-                       } catch(e) { }
-               }
-
-               // I really hate browser detection, but I don't see any other way
-               if ($.browser.mozilla)
-                       $input.keypress(processKey);    // onkeypress repeats arrow keys in Mozilla/Opera
-               else
-                       $input.keydown(processKey);             // onkeydown repeats arrow keys in IE/Safari
-
-
-
+               $input.keydown(processKey);
 
                function resetPosition() {
                        // requires jquery.dimension plugin
                        if ($currentResult) {
                                if ( options.multiple ) {
                                        if ( $input.val().indexOf(options.multipleSep) != -1 ) {
-                                               $currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) );
+                                               $currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) ) + ' ';
                                        } else {
                                                $currentVal = "";
                                        }
-                                       $input.val( $currentVal + $currentResult.text() + options.multipleSep);
+                                       $input.val( $currentVal + $currentResult.text() + options.multipleSep + ' ' );
                                        $input.focus();
                                } else {
                                        $input.val($currentResult.text());
                                }
                                $results.hide();
+                               $input.trigger('change');
 
                                if (options.onSelect)
                                        options.onSelect.apply($input[0]);
 
                options = options || {};
                options.multiple = options.multiple || false;
-               options.multipleSep = options.multipleSep || ", ";
+               options.multipleSep = options.multipleSep || ",";
                options.source = source;
                options.delay = options.delay || 100;
                options.resultsClass = options.resultsClass || 'ac_results';
 
        };
 
-})(jQuery);
\ No newline at end of file
+})(jQuery);