JAL-1807 update
[jalviewjs.git] / site / swingjs / jquery / JQuery_UI_Core2.js
1 if (self.Clazz) {
2
3 Clazz.declarePackage ("swingjs.jquery");
4 c$ = Clazz.declareType (swingjs.jquery, "JQuery_UI_Core2");
5 Clazz.makeConstructor (c$, 
6 function () {
7 });
8
9 }
10
11 // menu button autocomplete
12
13 if (!jQuery.ui.menu)
14 try{
15
16 /*!
17  * jQuery UI Menu 1.10.4
18  * http://jqueryui.com
19  *
20  * Copyright 2014 jQuery Foundation and other contributors
21  * Released under the MIT license.
22  * http://jquery.org/license
23  *
24  * http://api.jqueryui.com/menu/
25  *
26  * Depends:
27  *      jquery.ui.core.js
28  *      jquery.ui.widget.js
29  *      jquery.ui.position.js
30  */
31 (function( $, undefined ) {
32
33 $.widget( "ui.menu", {
34         version: "1.10.4",
35         defaultElement: "<ul>",
36         delay: 300,
37         options: {
38                 icons: {
39                         submenu: "ui-icon-carat-1-e"
40                 },
41                 menus: "ul",
42                 position: {
43                         my: "left top",
44                         at: "right top"
45                 },
46                 role: "menu",
47
48                 // callbacks
49                 blur: null,
50                 focus: null,
51                 select: null
52         },
53
54         _create: function() {
55                 this.activeMenu = this.element;
56                 // flag used to prevent firing of the click handler
57                 // as the event bubbles up through nested menus
58                 this.mouseHandled = false;
59                 this.element
60                         .uniqueId()
61                         .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
62                         .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
63                         .attr({
64                                 role: this.options.role,
65                                 tabIndex: 0
66                         })
67                         // need to catch all clicks on disabled menu
68                         // not possible through _on
69                         .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
70                                 if ( this.options.disabled ) {
71                                         event.preventDefault();
72                                 }
73                         }, this ));
74
75                 if ( this.options.disabled ) {
76                         this.element
77                                 .addClass( "ui-state-disabled" )
78                                 .attr( "aria-disabled", "true" );
79                 }
80
81                 this._on({
82                         // Prevent focus from sticking to links inside menu after clicking
83                         // them (focus should always stay on UL during navigation).
84                         "mousedown .ui-menu-item > a": function( event ) {
85                                 event.preventDefault();
86                         },
87                         "click .ui-state-disabled > a": function( event ) {
88                                 event.preventDefault();
89                         },
90                         "click .ui-menu-item:has(a)": function( event ) {
91                                 var target = $( event.target ).closest( ".ui-menu-item" );
92                                 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
93                                         this.select( event );
94
95                                         // Only set the mouseHandled flag if the event will bubble, see #9469.
96                                         if ( !event.isPropagationStopped() ) {
97                                                 this.mouseHandled = true;
98                                         }
99
100                                         // Open submenu on click
101                                         if ( target.has( ".ui-menu" ).length ) {
102                                                 this.expand( event );
103                                         } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
104
105                                                 // Redirect focus to the menu
106                                                 this.element.trigger( "focus", [ true ] );
107
108                                                 // If the active item is on the top level, let it stay active.
109                                                 // Otherwise, blur the active item since it is no longer visible.
110                                                 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
111                                                         clearTimeout( this.timer );
112                                                 }
113                                         }
114                                 }
115                         },
116                         "mouseenter .ui-menu-item": function( event ) {
117                                 var target = $( event.currentTarget );
118                                 // Remove ui-state-active class from siblings of the newly focused menu item
119                                 // to avoid a jump caused by adjacent elements both having a class with a border
120                                 target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
121                                 this.focus( event, target );
122                         },
123                         mouseleave: "collapseAll",
124                         "mouseleave .ui-menu": "collapseAll",
125                         focus: function( event, keepActiveItem ) {
126                                 // If there's already an active item, keep it active
127                                 // If not, activate the first item
128                                 var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
129
130                                 if ( !keepActiveItem ) {
131                                         this.focus( event, item );
132                                 }
133                         },
134                         blur: function( event ) {
135                                 this._delay(function() {
136                                         if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
137                                                 this.collapseAll( event );
138                                         }
139                                 });
140                         },
141                         keydown: "_keydown"
142                 });
143
144                 this.refresh();
145
146                 // Clicks outside of a menu collapse any open menus
147                 this._on( this.document, {
148                         click: function( event ) {
149                                 if ( !$( event.target ).closest( ".ui-menu" ).length ) {
150                                         this.collapseAll( event );
151                                 }
152
153                                 // Reset the mouseHandled flag
154                                 this.mouseHandled = false;
155                         }
156                 });
157         },
158
159         _destroy: function() {
160                 // Destroy (sub)menus
161                 this.element
162                         .removeAttr( "aria-activedescendant" )
163                         .find( ".ui-menu" ).addBack()
164                                 .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
165                                 .removeAttr( "role" )
166                                 .removeAttr( "tabIndex" )
167                                 .removeAttr( "aria-labelledby" )
168                                 .removeAttr( "aria-expanded" )
169                                 .removeAttr( "aria-hidden" )
170                                 .removeAttr( "aria-disabled" )
171                                 .removeUniqueId()
172                                 .show();
173
174                 // Destroy menu items
175                 this.element.find( ".ui-menu-item" )
176                         .removeClass( "ui-menu-item" )
177                         .removeAttr( "role" )
178                         .removeAttr( "aria-disabled" )
179                         .children( "a" )
180                                 .removeUniqueId()
181                                 .removeClass( "ui-corner-all ui-state-hover" )
182                                 .removeAttr( "tabIndex" )
183                                 .removeAttr( "role" )
184                                 .removeAttr( "aria-haspopup" )
185                                 .children().each( function() {
186                                         var elem = $( this );
187                                         if ( elem.data( "ui-menu-submenu-carat" ) ) {
188                                                 elem.remove();
189                                         }
190                                 });
191
192                 // Destroy menu dividers
193                 this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
194         },
195
196         _keydown: function( event ) {
197                 var match, prev, character, skip, regex,
198                         preventDefault = true;
199
200                 function escape( value ) {
201                         return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
202                 }
203
204                 switch ( event.keyCode ) {
205                 case $.ui.keyCode.PAGE_UP:
206                         this.previousPage( event );
207                         break;
208                 case $.ui.keyCode.PAGE_DOWN:
209                         this.nextPage( event );
210                         break;
211                 case $.ui.keyCode.HOME:
212                         this._move( "first", "first", event );
213                         break;
214                 case $.ui.keyCode.END:
215                         this._move( "last", "last", event );
216                         break;
217                 case $.ui.keyCode.UP:
218                         this.previous( event );
219                         break;
220                 case $.ui.keyCode.DOWN:
221                         this.next( event );
222                         break;
223                 case $.ui.keyCode.LEFT:
224                         this.collapse( event );
225                         break;
226                 case $.ui.keyCode.RIGHT:
227                         if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
228                                 this.expand( event );
229                         }
230                         break;
231                 case $.ui.keyCode.ENTER:
232                 case $.ui.keyCode.SPACE:
233                         this._activate( event );
234                         break;
235                 case $.ui.keyCode.ESCAPE:
236                         this.collapse( event );
237                         break;
238                 default:
239                         preventDefault = false;
240                         prev = this.previousFilter || "";
241                         character = String.fromCharCode( event.keyCode );
242                         skip = false;
243
244                         clearTimeout( this.filterTimer );
245
246                         if ( character === prev ) {
247                                 skip = true;
248                         } else {
249                                 character = prev + character;
250                         }
251
252                         regex = new RegExp( "^" + escape( character ), "i" );
253                         match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
254                                 return regex.test( $( this ).children( "a" ).text() );
255                         });
256                         match = skip && match.index( this.active.next() ) !== -1 ?
257                                 this.active.nextAll( ".ui-menu-item" ) :
258                                 match;
259
260                         // If no matches on the current filter, reset to the last character pressed
261                         // to move down the menu to the first item that starts with that character
262                         if ( !match.length ) {
263                                 character = String.fromCharCode( event.keyCode );
264                                 regex = new RegExp( "^" + escape( character ), "i" );
265                                 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
266                                         return regex.test( $( this ).children( "a" ).text() );
267                                 });
268                         }
269
270                         if ( match.length ) {
271                                 this.focus( event, match );
272                                 if ( match.length > 1 ) {
273                                         this.previousFilter = character;
274                                         this.filterTimer = this._delay(function() {
275                                                 delete this.previousFilter;
276                                         }, 1000 );
277                                 } else {
278                                         delete this.previousFilter;
279                                 }
280                         } else {
281                                 delete this.previousFilter;
282                         }
283                 }
284
285                 if ( preventDefault ) {
286                         event.preventDefault();
287                 }
288         },
289
290         _activate: function( event ) {
291                 if ( !this.active.is( ".ui-state-disabled" ) ) {
292                         if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
293                                 this.expand( event );
294                         } else {
295                                 this.select( event );
296                         }
297                 }
298         },
299
300         refresh: function() {
301                 var menus,
302                         icon = this.options.icons.submenu,
303                         submenus = this.element.find( this.options.menus );
304
305                 this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
306
307                 // Initialize nested menus
308                 submenus.filter( ":not(.ui-menu)" )
309                         .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
310                         .hide()
311                         .attr({
312                                 role: this.options.role,
313                                 "aria-hidden": "true",
314                                 "aria-expanded": "false"
315                         })
316                         .each(function() {
317                                 var menu = $( this ),
318                                         item = menu.prev( "a" ),
319                                         submenuCarat = $( "<span>" )
320                                                 .addClass( "ui-menu-icon ui-icon " + icon )
321                                                 .data( "ui-menu-submenu-carat", true );
322
323                                 item
324                                         .attr( "aria-haspopup", "true" )
325                                         .prepend( submenuCarat );
326                                 menu.attr( "aria-labelledby", item.attr( "id" ) );
327                         });
328
329                 menus = submenus.add( this.element );
330
331                 // Don't refresh list items that are already adapted
332                 menus.children( ":not(.ui-menu-item):has(a)" )
333                         .addClass( "ui-menu-item" )
334                         .attr( "role", "presentation" )
335                         .children( "a" )
336                                 .uniqueId()
337                                 .addClass( "ui-corner-all" )
338                                 .attr({
339                                         tabIndex: -1,
340                                         role: this._itemRole()
341                                 });
342
343                 // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
344                 menus.children( ":not(.ui-menu-item)" ).each(function() {
345                         var item = $( this );
346                         // hyphen, em dash, en dash
347                         if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
348                                 item.addClass( "ui-widget-content ui-menu-divider" );
349                         }
350                 });
351
352                 // Add aria-disabled attribute to any disabled menu item
353                 menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
354
355                 // If the active item has been removed, blur the menu
356                 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
357                         this.blur();
358                 }
359         },
360
361         _itemRole: function() {
362                 return {
363                         menu: "menuitem",
364                         listbox: "option"
365                 }[ this.options.role ];
366         },
367
368         _setOption: function( key, value ) {
369                 if ( key === "icons" ) {
370                         this.element.find( ".ui-menu-icon" )
371                                 .removeClass( this.options.icons.submenu )
372                                 .addClass( value.submenu );
373                 }
374                 this._super( key, value );
375         },
376
377         focus: function( event, item ) {
378                 var nested, focused;
379                 this.blur( event, event && event.type === "focus" );
380
381                 this._scrollIntoView( item );
382
383                 this.active = item.first();
384                 focused = this.active.children( "a" ).addClass( "ui-state-focus" );
385                 // Only update aria-activedescendant if there's a role
386                 // otherwise we assume focus is managed elsewhere
387                 if ( this.options.role ) {
388                         this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
389                 }
390
391                 // Highlight active parent menu item, if any
392                 this.active
393                         .parent()
394                         .closest( ".ui-menu-item" )
395                         .children( "a:first" )
396                         .addClass( "ui-state-active" );
397
398                 if ( event && event.type === "keydown" ) {
399                         this._close();
400                 } else {
401                         this.timer = this._delay(function() {
402                                 this._close();
403                         }, this.delay );
404                 }
405
406                 nested = item.children( ".ui-menu" );
407                 if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
408                         this._startOpening(nested);
409                 }
410                 this.activeMenu = item.parent();
411
412                 this._trigger( "focus", event, { item: item } );
413         },
414
415         _scrollIntoView: function( item ) {
416                 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
417                 if ( this._hasScroll() ) {
418                         borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
419                         paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
420                         offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
421                         scroll = this.activeMenu.scrollTop();
422                         elementHeight = this.activeMenu.height();
423                         itemHeight = item.height();
424
425                         if ( offset < 0 ) {
426                                 this.activeMenu.scrollTop( scroll + offset );
427                         } else if ( offset + itemHeight > elementHeight ) {
428                                 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
429                         }
430                 }
431         },
432
433         blur: function( event, fromFocus ) {
434                 if ( !fromFocus ) {
435                         clearTimeout( this.timer );
436                 }
437
438                 if ( !this.active ) {
439                         return;
440                 }
441
442                 this.active.children( "a" ).removeClass( "ui-state-focus" );
443                 this.active = null;
444
445                 this._trigger( "blur", event, { item: this.active } );
446         },
447
448         _startOpening: function( submenu ) {
449                 clearTimeout( this.timer );
450
451                 // Don't open if already open fixes a Firefox bug that caused a .5 pixel
452                 // shift in the submenu position when mousing over the carat icon
453                 if ( submenu.attr( "aria-hidden" ) !== "true" ) {
454                         return;
455                 }
456
457                 this.timer = this._delay(function() {
458                         this._close();
459                         this._open( submenu );
460                 }, this.delay );
461         },
462
463         _open: function( submenu ) {
464                 var position = $.extend({
465                         of: this.active
466                 }, this.options.position );
467
468                 clearTimeout( this.timer );
469                 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
470                         .hide()
471                         .attr( "aria-hidden", "true" );
472
473                 submenu
474                         .show()
475                         .removeAttr( "aria-hidden" )
476                         .attr( "aria-expanded", "true" )
477                         .position( position );
478         },
479
480         collapseAll: function( event, all ) {
481                 clearTimeout( this.timer );
482                 this.timer = this._delay(function() {
483                         // If we were passed an event, look for the submenu that contains the event
484                         var currentMenu = all ? this.element :
485                                 $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
486
487                         // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
488                         if ( !currentMenu.length ) {
489                                 currentMenu = this.element;
490                         }
491
492                         this._close( currentMenu );
493
494                         this.blur( event );
495                         this.activeMenu = currentMenu;
496                 }, this.delay );
497         },
498
499         // With no arguments, closes the currently active menu - if nothing is active
500         // it closes all menus.  If passed an argument, it will search for menus BELOW
501         _close: function( startMenu ) {
502                 if ( !startMenu ) {
503                         startMenu = this.active ? this.active.parent() : this.element;
504                 }
505
506                 startMenu
507                         .find( ".ui-menu" )
508                                 .hide()
509                                 .attr( "aria-hidden", "true" )
510                                 .attr( "aria-expanded", "false" )
511                         .end()
512                         .find( "a.ui-state-active" )
513                                 .removeClass( "ui-state-active" );
514         },
515
516         collapse: function( event ) {
517                 var newItem = this.active &&
518                         this.active.parent().closest( ".ui-menu-item", this.element );
519                 if ( newItem && newItem.length ) {
520                         this._close();
521                         this.focus( event, newItem );
522                 }
523         },
524
525         expand: function( event ) {
526                 var newItem = this.active &&
527                         this.active
528                                 .children( ".ui-menu " )
529                                 .children( ".ui-menu-item" )
530                                 .first();
531
532                 if ( newItem && newItem.length ) {
533                         this._open( newItem.parent() );
534
535                         // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
536                         this._delay(function() {
537                                 this.focus( event, newItem );
538                         });
539                 }
540         },
541
542         next: function( event ) {
543                 this._move( "next", "first", event );
544         },
545
546         previous: function( event ) {
547                 this._move( "prev", "last", event );
548         },
549
550         isFirstItem: function() {
551                 return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
552         },
553
554         isLastItem: function() {
555                 return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
556         },
557
558         _move: function( direction, filter, event ) {
559                 var next;
560                 if ( this.active ) {
561                         if ( direction === "first" || direction === "last" ) {
562                                 next = this.active
563                                         [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
564                                         .eq( -1 );
565                         } else {
566                                 next = this.active
567                                         [ direction + "All" ]( ".ui-menu-item" )
568                                         .eq( 0 );
569                         }
570                 }
571                 if ( !next || !next.length || !this.active ) {
572                         next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
573                 }
574
575                 this.focus( event, next );
576         },
577
578         nextPage: function( event ) {
579                 var item, base, height;
580
581                 if ( !this.active ) {
582                         this.next( event );
583                         return;
584                 }
585                 if ( this.isLastItem() ) {
586                         return;
587                 }
588                 if ( this._hasScroll() ) {
589                         base = this.active.offset().top;
590                         height = this.element.height();
591                         this.active.nextAll( ".ui-menu-item" ).each(function() {
592                                 item = $( this );
593                                 return item.offset().top - base - height < 0;
594                         });
595
596                         this.focus( event, item );
597                 } else {
598                         this.focus( event, this.activeMenu.children( ".ui-menu-item" )
599                                 [ !this.active ? "first" : "last" ]() );
600                 }
601         },
602
603         previousPage: function( event ) {
604                 var item, base, height;
605                 if ( !this.active ) {
606                         this.next( event );
607                         return;
608                 }
609                 if ( this.isFirstItem() ) {
610                         return;
611                 }
612                 if ( this._hasScroll() ) {
613                         base = this.active.offset().top;
614                         height = this.element.height();
615                         this.active.prevAll( ".ui-menu-item" ).each(function() {
616                                 item = $( this );
617                                 return item.offset().top - base + height > 0;
618                         });
619
620                         this.focus( event, item );
621                 } else {
622                         this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
623                 }
624         },
625
626         _hasScroll: function() {
627                 return this.element.outerHeight() < this.element.prop( "scrollHeight" );
628         },
629
630         select: function( event ) {
631                 // TODO: It should never be possible to not have an active item at this
632                 // point, but the tests don't trigger mouseenter before click.
633                 this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
634                 var ui = { item: this.active };
635                 if ( !this.active.has( ".ui-menu" ).length ) {
636                         this.collapseAll( event, true );
637                 }
638                 this._trigger( "select", event, ui );
639         }
640 });
641
642 }( jQuery ));
643
644
645 }catch (e) {
646 System.out.println("coremenu failed to load jQuery.ui.menu -- jQuery version conflict?");
647 }
648
649 if (!jQuery.ui.button)
650 try{
651
652 /*!
653  * jQuery UI Button 1.10.4
654  * http://jqueryui.com
655  *
656  * Copyright 2014 jQuery Foundation and other contributors
657  * Released under the MIT license.
658  * http://jquery.org/license
659  *
660  * http://api.jqueryui.com/button/
661  *
662  * Depends:
663  *      jquery.ui.core.js
664  *      jquery.ui.widget.js
665  */
666 (function( $, undefined ) {
667
668 var lastActive,
669         baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
670         typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
671         formResetHandler = function() {
672                 var form = $( this );
673                 setTimeout(function() {
674                         form.find( ":ui-button" ).button( "refresh" );
675                 }, 1 );
676         },
677         radioGroup = function( radio ) {
678                 var name = radio.name,
679                         form = radio.form,
680                         radios = $( [] );
681                 if ( name ) {
682                         name = name.replace( /'/g, "\\'" );
683                         if ( form ) {
684                                 radios = $( form ).find( "[name='" + name + "']" );
685                         } else {
686                                 radios = $( "[name='" + name + "']", radio.ownerDocument )
687                                         .filter(function() {
688                                                 return !this.form;
689                                         });
690                         }
691                 }
692                 return radios;
693         };
694
695 $.widget( "ui.button", {
696         version: "1.10.4",
697         defaultElement: "<button>",
698         options: {
699                 disabled: null,
700                 text: true,
701                 label: null,
702                 icons: {
703                         primary: null,
704                         secondary: null
705                 }
706         },
707         _create: function() {
708                 this.element.closest( "form" )
709                         .unbind( "reset" + this.eventNamespace )
710                         .bind( "reset" + this.eventNamespace, formResetHandler );
711
712                 if ( typeof this.options.disabled !== "boolean" ) {
713                         this.options.disabled = !!this.element.prop( "disabled" );
714                 } else {
715                         this.element.prop( "disabled", this.options.disabled );
716                 }
717
718                 this._determineButtonType();
719                 this.hasTitle = !!this.buttonElement.attr( "title" );
720
721                 var that = this,
722                         options = this.options,
723                         toggleButton = this.type === "checkbox" || this.type === "radio",
724                         activeClass = !toggleButton ? "ui-state-active" : "";
725
726                 if ( options.label === null ) {
727                         options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
728                 }
729
730                 this._hoverable( this.buttonElement );
731
732                 this.buttonElement
733                         .addClass( baseClasses )
734                         .attr( "role", "button" )
735                         .bind( "mouseenter" + this.eventNamespace, function() {
736                                 if ( options.disabled ) {
737                                         return;
738                                 }
739                                 if ( this === lastActive ) {
740                                         $( this ).addClass( "ui-state-active" );
741                                 }
742                         })
743                         .bind( "mouseleave" + this.eventNamespace, function() {
744                                 if ( options.disabled ) {
745                                         return;
746                                 }
747                                 $( this ).removeClass( activeClass );
748                         })
749                         .bind( "click" + this.eventNamespace, function( event ) {
750                                 if ( options.disabled ) {
751                                         event.preventDefault();
752                                         event.stopImmediatePropagation();
753                                 }
754                         });
755
756                 // Can't use _focusable() because the element that receives focus
757                 // and the element that gets the ui-state-focus class are different
758                 this._on({
759                         focus: function() {
760                                 this.buttonElement.addClass( "ui-state-focus" );
761                         },
762                         blur: function() {
763                                 this.buttonElement.removeClass( "ui-state-focus" );
764                         }
765                 });
766
767                 if ( toggleButton ) {
768                         this.element.bind( "change" + this.eventNamespace, function() {
769                                 that.refresh();
770                         });
771                 }
772
773                 if ( this.type === "checkbox" ) {
774                         this.buttonElement.bind( "click" + this.eventNamespace, function() {
775                                 if ( options.disabled ) {
776                                         return false;
777                                 }
778                         });
779                 } else if ( this.type === "radio" ) {
780                         this.buttonElement.bind( "click" + this.eventNamespace, function() {
781                                 if ( options.disabled ) {
782                                         return false;
783                                 }
784                                 $( this ).addClass( "ui-state-active" );
785                                 that.buttonElement.attr( "aria-pressed", "true" );
786
787                                 var radio = that.element[ 0 ];
788                                 radioGroup( radio )
789                                         .not( radio )
790                                         .map(function() {
791                                                 return $( this ).button( "widget" )[ 0 ];
792                                         })
793                                         .removeClass( "ui-state-active" )
794                                         .attr( "aria-pressed", "false" );
795                         });
796                 } else {
797                         this.buttonElement
798                                 .bind( "mousedown" + this.eventNamespace, function() {
799                                         if ( options.disabled ) {
800                                                 return false;
801                                         }
802                                         $( this ).addClass( "ui-state-active" );
803                                         lastActive = this;
804                                         that.document.one( "mouseup", function() {
805                                                 lastActive = null;
806                                         });
807                                 })
808                                 .bind( "mouseup" + this.eventNamespace, function() {
809                                         if ( options.disabled ) {
810                                                 return false;
811                                         }
812                                         $( this ).removeClass( "ui-state-active" );
813                                 })
814                                 .bind( "keydown" + this.eventNamespace, function(event) {
815                                         if ( options.disabled ) {
816                                                 return false;
817                                         }
818                                         if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
819                                                 $( this ).addClass( "ui-state-active" );
820                                         }
821                                 })
822                                 // see #8559, we bind to blur here in case the button element loses
823                                 // focus between keydown and keyup, it would be left in an "active" state
824                                 .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
825                                         $( this ).removeClass( "ui-state-active" );
826                                 });
827
828                         if ( this.buttonElement.is("a") ) {
829                                 this.buttonElement.keyup(function(event) {
830                                         if ( event.keyCode === $.ui.keyCode.SPACE ) {
831                                                 // TODO pass through original event correctly (just as 2nd argument doesn't work)
832                                                 $( this ).click();
833                                         }
834                                 });
835                         }
836                 }
837
838                 // TODO: pull out $.Widget's handling for the disabled option into
839                 // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
840                 // be overridden by individual plugins
841                 this._setOption( "disabled", options.disabled );
842                 this._resetButton();
843         },
844
845         _determineButtonType: function() {
846                 var ancestor, labelSelector, checked;
847
848                 if ( this.element.is("[type=checkbox]") ) {
849                         this.type = "checkbox";
850                 } else if ( this.element.is("[type=radio]") ) {
851                         this.type = "radio";
852                 } else if ( this.element.is("input") ) {
853                         this.type = "input";
854                 } else {
855                         this.type = "button";
856                 }
857
858                 if ( this.type === "checkbox" || this.type === "radio" ) {
859                         // we don't search against the document in case the element
860                         // is disconnected from the DOM
861                         ancestor = this.element.parents().last();
862                         labelSelector = "label[for='" + this.element.attr("id") + "']";
863                         this.buttonElement = ancestor.find( labelSelector );
864                         if ( !this.buttonElement.length ) {
865                                 ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
866                                 this.buttonElement = ancestor.filter( labelSelector );
867                                 if ( !this.buttonElement.length ) {
868                                         this.buttonElement = ancestor.find( labelSelector );
869                                 }
870                         }
871                         this.element.addClass( "ui-helper-hidden-accessible" );
872
873                         checked = this.element.is( ":checked" );
874                         if ( checked ) {
875                                 this.buttonElement.addClass( "ui-state-active" );
876                         }
877                         this.buttonElement.prop( "aria-pressed", checked );
878                 } else {
879                         this.buttonElement = this.element;
880                 }
881         },
882
883         widget: function() {
884                 return this.buttonElement;
885         },
886
887         _destroy: function() {
888                 this.element
889                         .removeClass( "ui-helper-hidden-accessible" );
890                 this.buttonElement
891                         .removeClass( baseClasses + " ui-state-active " + typeClasses )
892                         .removeAttr( "role" )
893                         .removeAttr( "aria-pressed" )
894                         .html( this.buttonElement.find(".ui-button-text").html() );
895
896                 if ( !this.hasTitle ) {
897                         this.buttonElement.removeAttr( "title" );
898                 }
899         },
900
901         _setOption: function( key, value ) {
902                 this._super( key, value );
903                 if ( key === "disabled" ) {
904                         this.element.prop( "disabled", !!value );
905                         if ( value ) {
906                                 this.buttonElement.removeClass( "ui-state-focus" );
907                         }
908                         return;
909                 }
910                 this._resetButton();
911         },
912
913         refresh: function() {
914                 //See #8237 & #8828
915                 var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
916
917                 if ( isDisabled !== this.options.disabled ) {
918                         this._setOption( "disabled", isDisabled );
919                 }
920                 if ( this.type === "radio" ) {
921                         radioGroup( this.element[0] ).each(function() {
922                                 if ( $( this ).is( ":checked" ) ) {
923                                         $( this ).button( "widget" )
924                                                 .addClass( "ui-state-active" )
925                                                 .attr( "aria-pressed", "true" );
926                                 } else {
927                                         $( this ).button( "widget" )
928                                                 .removeClass( "ui-state-active" )
929                                                 .attr( "aria-pressed", "false" );
930                                 }
931                         });
932                 } else if ( this.type === "checkbox" ) {
933                         if ( this.element.is( ":checked" ) ) {
934                                 this.buttonElement
935                                         .addClass( "ui-state-active" )
936                                         .attr( "aria-pressed", "true" );
937                         } else {
938                                 this.buttonElement
939                                         .removeClass( "ui-state-active" )
940                                         .attr( "aria-pressed", "false" );
941                         }
942                 }
943         },
944
945         _resetButton: function() {
946                 if ( this.type === "input" ) {
947                         if ( this.options.label ) {
948                                 this.element.val( this.options.label );
949                         }
950                         return;
951                 }
952                 var buttonElement = this.buttonElement.removeClass( typeClasses ),
953                         buttonText = $( "<span></span>", this.document[0] )
954                                 .addClass( "ui-button-text" )
955                                 .html( this.options.label )
956                                 .appendTo( buttonElement.empty() )
957                                 .text(),
958                         icons = this.options.icons,
959                         multipleIcons = icons.primary && icons.secondary,
960                         buttonClasses = [];
961
962                 if ( icons.primary || icons.secondary ) {
963                         if ( this.options.text ) {
964                                 buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
965                         }
966
967                         if ( icons.primary ) {
968                                 buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
969                         }
970
971                         if ( icons.secondary ) {
972                                 buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
973                         }
974
975                         if ( !this.options.text ) {
976                                 buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
977
978                                 if ( !this.hasTitle ) {
979                                         buttonElement.attr( "title", $.trim( buttonText ) );
980                                 }
981                         }
982                 } else {
983                         buttonClasses.push( "ui-button-text-only" );
984                 }
985                 buttonElement.addClass( buttonClasses.join( " " ) );
986         }
987 });
988
989 $.widget( "ui.buttonset", {
990         version: "1.10.4",
991         options: {
992                 items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
993         },
994
995         _create: function() {
996                 this.element.addClass( "ui-buttonset" );
997         },
998
999         _init: function() {
1000                 this.refresh();
1001         },
1002
1003         _setOption: function( key, value ) {
1004                 if ( key === "disabled" ) {
1005                         this.buttons.button( "option", key, value );
1006                 }
1007
1008                 this._super( key, value );
1009         },
1010
1011         refresh: function() {
1012                 var rtl = this.element.css( "direction" ) === "rtl";
1013
1014                 this.buttons = this.element.find( this.options.items )
1015                         .filter( ":ui-button" )
1016                                 .button( "refresh" )
1017                         .end()
1018                         .not( ":ui-button" )
1019                                 .button()
1020                         .end()
1021                         .map(function() {
1022                                 return $( this ).button( "widget" )[ 0 ];
1023                         })
1024                                 .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
1025                                 .filter( ":first" )
1026                                         .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
1027                                 .end()
1028                                 .filter( ":last" )
1029                                         .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
1030                                 .end()
1031                         .end();
1032         },
1033
1034         _destroy: function() {
1035                 this.element.removeClass( "ui-buttonset" );
1036                 this.buttons
1037                         .map(function() {
1038                                 return $( this ).button( "widget" )[ 0 ];
1039                         })
1040                                 .removeClass( "ui-corner-left ui-corner-right" )
1041                         .end()
1042                         .button( "destroy" );
1043         }
1044 });
1045
1046 }( jQuery ) );
1047
1048 }catch (e) {
1049 System.out.println("coremenu failed to load jQuery.ui.button -- jQuery version conflict?");
1050 }
1051
1052 if (!jQuery.ui.autocomplete)
1053 try{
1054
1055 /*!
1056  * jQuery UI Autocomplete 1.10.4
1057  * http://jqueryui.com
1058  *
1059  * Copyright 2014 jQuery Foundation and other contributors
1060  * Released under the MIT license.
1061  * http://jquery.org/license
1062  *
1063  * http://api.jqueryui.com/autocomplete/
1064  *
1065  * Depends:
1066  *      jquery.ui.core.js
1067  *      jquery.ui.widget.js
1068  *      jquery.ui.position.js
1069  *      jquery.ui.menu.js
1070  */
1071 (function( $, undefined ) {
1072
1073 $.widget( "ui.autocomplete", {
1074         version: "1.10.4",
1075         defaultElement: "<input>",
1076         options: {
1077                 appendTo: null,
1078                 autoFocus: false,
1079                 delay: 300,
1080                 minLength: 1,
1081                 position: {
1082                         my: "left top",
1083                         at: "left bottom",
1084                         collision: "none"
1085                 },
1086                 source: null,
1087
1088                 // callbacks
1089                 change: null,
1090                 close: null,
1091                 focus: null,
1092                 open: null,
1093                 response: null,
1094                 search: null,
1095                 select: null
1096         },
1097
1098         requestIndex: 0,
1099         pending: 0,
1100
1101         _create: function() {
1102                 // Some browsers only repeat keydown events, not keypress events,
1103                 // so we use the suppressKeyPress flag to determine if we've already
1104                 // handled the keydown event. #7269
1105                 // Unfortunately the code for & in keypress is the same as the up arrow,
1106                 // so we use the suppressKeyPressRepeat flag to avoid handling keypress
1107                 // events when we know the keydown event was used to modify the
1108                 // search term. #7799
1109                 var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
1110                         nodeName = this.element[0].nodeName.toLowerCase(),
1111                         isTextarea = nodeName === "textarea",
1112                         isInput = nodeName === "input";
1113
1114                 this.isMultiLine =
1115                         // Textareas are always multi-line
1116                         isTextarea ? true :
1117                         // Inputs are always single-line, even if inside a contentEditable element
1118                         // IE also treats inputs as contentEditable
1119                         isInput ? false :
1120                         // All other element types are determined by whether or not they're contentEditable
1121                         this.element.prop( "isContentEditable" );
1122
1123                 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
1124                 this.isNewMenu = true;
1125
1126                 this.element
1127                         .addClass( "ui-autocomplete-input" )
1128                         .attr( "autocomplete", "off" );
1129
1130                 this._on( this.element, {
1131                         keydown: function( event ) {
1132                                 if ( this.element.prop( "readOnly" ) ) {
1133                                         suppressKeyPress = true;
1134                                         suppressInput = true;
1135                                         suppressKeyPressRepeat = true;
1136                                         return;
1137                                 }
1138
1139                                 suppressKeyPress = false;
1140                                 suppressInput = false;
1141                                 suppressKeyPressRepeat = false;
1142                                 var keyCode = $.ui.keyCode;
1143                                 switch( event.keyCode ) {
1144                                 case keyCode.PAGE_UP:
1145                                         suppressKeyPress = true;
1146                                         this._move( "previousPage", event );
1147                                         break;
1148                                 case keyCode.PAGE_DOWN:
1149                                         suppressKeyPress = true;
1150                                         this._move( "nextPage", event );
1151                                         break;
1152                                 case keyCode.UP:
1153                                         suppressKeyPress = true;
1154                                         this._keyEvent( "previous", event );
1155                                         break;
1156                                 case keyCode.DOWN:
1157                                         suppressKeyPress = true;
1158                                         this._keyEvent( "next", event );
1159                                         break;
1160                                 case keyCode.ENTER:
1161                                 case keyCode.NUMPAD_ENTER:
1162                                         // when menu is open and has focus
1163                                         if ( this.menu.active ) {
1164                                                 // #6055 - Opera still allows the keypress to occur
1165                                                 // which causes forms to submit
1166                                                 suppressKeyPress = true;
1167                                                 event.preventDefault();
1168                                                 this.menu.select( event );
1169                                         }
1170                                         break;
1171                                 case keyCode.TAB:
1172                                         if ( this.menu.active ) {
1173                                                 this.menu.select( event );
1174                                         }
1175                                         break;
1176                                 case keyCode.ESCAPE:
1177                                         if ( this.menu.element.is( ":visible" ) ) {
1178                                                 this._value( this.term );
1179                                                 this.close( event );
1180                                                 // Different browsers have different default behavior for escape
1181                                                 // Single press can mean undo or clear
1182                                                 // Double press in IE means clear the whole form
1183                                                 event.preventDefault();
1184                                         }
1185                                         break;
1186                                 default:
1187                                         suppressKeyPressRepeat = true;
1188                                         // search timeout should be triggered before the input value is changed
1189                                         this._searchTimeout( event );
1190                                         break;
1191                                 }
1192                         },
1193                         keypress: function( event ) {
1194                                 if ( suppressKeyPress ) {
1195                                         suppressKeyPress = false;
1196                                         if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
1197                                                 event.preventDefault();
1198                                         }
1199                                         return;
1200                                 }
1201                                 if ( suppressKeyPressRepeat ) {
1202                                         return;
1203                                 }
1204
1205                                 // replicate some key handlers to allow them to repeat in Firefox and Opera
1206                                 var keyCode = $.ui.keyCode;
1207                                 switch( event.keyCode ) {
1208                                 case keyCode.PAGE_UP:
1209                                         this._move( "previousPage", event );
1210                                         break;
1211                                 case keyCode.PAGE_DOWN:
1212                                         this._move( "nextPage", event );
1213                                         break;
1214                                 case keyCode.UP:
1215                                         this._keyEvent( "previous", event );
1216                                         break;
1217                                 case keyCode.DOWN:
1218                                         this._keyEvent( "next", event );
1219                                         break;
1220                                 }
1221                         },
1222                         input: function( event ) {
1223                                 if ( suppressInput ) {
1224                                         suppressInput = false;
1225                                         event.preventDefault();
1226                                         return;
1227                                 }
1228                                 this._searchTimeout( event );
1229                         },
1230                         focus: function() {
1231                                 this.selectedItem = null;
1232                                 this.previous = this._value();
1233                         },
1234                         blur: function( event ) {
1235                                 if ( this.cancelBlur ) {
1236                                         delete this.cancelBlur;
1237                                         return;
1238                                 }
1239
1240                                 clearTimeout( this.searching );
1241                                 this.close( event );
1242                                 this._change( event );
1243                         }
1244                 });
1245
1246                 this._initSource();
1247                 this.menu = $( "<ul>" )
1248                         .addClass( "ui-autocomplete ui-front" )
1249                         .appendTo( this._appendTo() )
1250                         .menu({
1251                                 // disable ARIA support, the live region takes care of that
1252                                 role: null
1253                         })
1254                         .hide()
1255                         .data( "ui-menu" );
1256
1257                 this._on( this.menu.element, {
1258                         mousedown: function( event ) {
1259                                 // prevent moving focus out of the text field
1260                                 event.preventDefault();
1261
1262                                 // IE doesn't prevent moving focus even with event.preventDefault()
1263                                 // so we set a flag to know when we should ignore the blur event
1264                                 this.cancelBlur = true;
1265                                 this._delay(function() {
1266                                         delete this.cancelBlur;
1267                                 });
1268
1269                                 // clicking on the scrollbar causes focus to shift to the body
1270                                 // but we can't detect a mouseup or a click immediately afterward
1271                                 // so we have to track the next mousedown and close the menu if
1272                                 // the user clicks somewhere outside of the autocomplete
1273                                 var menuElement = this.menu.element[ 0 ];
1274                                 if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
1275                                         this._delay(function() {
1276                                                 var that = this;
1277                                                 this.document.one( "mousedown", function( event ) {
1278                                                         if ( event.target !== that.element[ 0 ] &&
1279                                                                         event.target !== menuElement &&
1280                                                                         !$.contains( menuElement, event.target ) ) {
1281                                                                 that.close();
1282                                                         }
1283                                                 });
1284                                         });
1285                                 }
1286                         },
1287                         menufocus: function( event, ui ) {
1288                                 // support: Firefox
1289                                 // Prevent accidental activation of menu items in Firefox (#7024 #9118)
1290                                 if ( this.isNewMenu ) {
1291                                         this.isNewMenu = false;
1292                                         if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
1293                                                 this.menu.blur();
1294
1295                                                 this.document.one( "mousemove", function() {
1296                                                         $( event.target ).trigger( event.originalEvent );
1297                                                 });
1298
1299                                                 return;
1300                                         }
1301                                 }
1302
1303                                 var item = ui.item.data( "ui-autocomplete-item" );
1304                                 if ( false !== this._trigger( "focus", event, { item: item } ) ) {
1305                                         // use value to match what will end up in the input, if it was a key event
1306                                         if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
1307                                                 this._value( item.value );
1308                                         }
1309                                 } else {
1310                                         // Normally the input is populated with the item's value as the
1311                                         // menu is navigated, causing screen readers to notice a change and
1312                                         // announce the item. Since the focus event was canceled, this doesn't
1313                                         // happen, so we update the live region so that screen readers can
1314                                         // still notice the change and announce it.
1315                                         this.liveRegion.text( item.value );
1316                                 }
1317                         },
1318                         menuselect: function( event, ui ) {
1319                                 var item = ui.item.data( "ui-autocomplete-item" ),
1320                                         previous = this.previous;
1321
1322                                 // only trigger when focus was lost (click on menu)
1323                                 if ( this.element[0] !== this.document[0].activeElement ) {
1324                                         this.element.focus();
1325                                         this.previous = previous;
1326                                         // #6109 - IE triggers two focus events and the second
1327                                         // is asynchronous, so we need to reset the previous
1328                                         // term synchronously and asynchronously :-(
1329                                         this._delay(function() {
1330                                                 this.previous = previous;
1331                                                 this.selectedItem = item;
1332                                         });
1333                                 }
1334
1335                                 if ( false !== this._trigger( "select", event, { item: item } ) ) {
1336                                         this._value( item.value );
1337                                 }
1338                                 // reset the term after the select event
1339                                 // this allows custom select handling to work properly
1340                                 this.term = this._value();
1341
1342                                 this.close( event );
1343                                 this.selectedItem = item;
1344                         }
1345                 });
1346
1347                 this.liveRegion = $( "<span>", {
1348                                 role: "status",
1349                                 "aria-live": "polite"
1350                         })
1351                         .addClass( "ui-helper-hidden-accessible" )
1352                         .insertBefore( this.element );
1353
1354                 // turning off autocomplete prevents the browser from remembering the
1355                 // value when navigating through history, so we re-enable autocomplete
1356                 // if the page is unloaded before the widget is destroyed. #7790
1357                 this._on( this.window, {
1358                         beforeunload: function() {
1359                                 this.element.removeAttr( "autocomplete" );
1360                         }
1361                 });
1362         },
1363
1364         _destroy: function() {
1365                 clearTimeout( this.searching );
1366                 this.element
1367                         .removeClass( "ui-autocomplete-input" )
1368                         .removeAttr( "autocomplete" );
1369                 this.menu.element.remove();
1370                 this.liveRegion.remove();
1371         },
1372
1373         _setOption: function( key, value ) {
1374                 this._super( key, value );
1375                 if ( key === "source" ) {
1376                         this._initSource();
1377                 }
1378                 if ( key === "appendTo" ) {
1379                         this.menu.element.appendTo( this._appendTo() );
1380                 }
1381                 if ( key === "disabled" && value && this.xhr ) {
1382                         this.xhr.abort();
1383                 }
1384         },
1385
1386         _appendTo: function() {
1387                 var element = this.options.appendTo;
1388
1389                 if ( element ) {
1390                         element = element.jquery || element.nodeType ?
1391                                 $( element ) :
1392                                 this.document.find( element ).eq( 0 );
1393                 }
1394
1395                 if ( !element ) {
1396                         element = this.element.closest( ".ui-front" );
1397                 }
1398
1399                 if ( !element.length ) {
1400                         element = this.document[0].body;
1401                 }
1402
1403                 return element;
1404         },
1405
1406         _initSource: function() {
1407                 var array, url,
1408                         that = this;
1409                 if ( $.isArray(this.options.source) ) {
1410                         array = this.options.source;
1411                         this.source = function( request, response ) {
1412                                 response( $.ui.autocomplete.filter( array, request.term ) );
1413                         };
1414                 } else if ( typeof this.options.source === "string" ) {
1415                         url = this.options.source;
1416                         this.source = function( request, response ) {
1417                                 if ( that.xhr ) {
1418                                         that.xhr.abort();
1419                                 }
1420                                 that.xhr = $.ajax({
1421                                         url: url,
1422                                         data: request,
1423                                         dataType: "json",
1424                                         success: function( data ) {
1425                                                 response( data );
1426                                         },
1427                                         error: function() {
1428                                                 response( [] );
1429                                         }
1430                                 });
1431                         };
1432                 } else {
1433                         this.source = this.options.source;
1434                 }
1435         },
1436
1437         _searchTimeout: function( event ) {
1438                 clearTimeout( this.searching );
1439                 this.searching = this._delay(function() {
1440                         // only search if the value has changed
1441                         if ( this.term !== this._value() ) {
1442                                 this.selectedItem = null;
1443                                 this.search( null, event );
1444                         }
1445                 }, this.options.delay );
1446         },
1447
1448         search: function( value, event ) {
1449                 value = value != null ? value : this._value();
1450
1451                 // always save the actual value, not the one passed as an argument
1452                 this.term = this._value();
1453
1454                 if ( value.length < this.options.minLength ) {
1455                         return this.close( event );
1456                 }
1457
1458                 if ( this._trigger( "search", event ) === false ) {
1459                         return;
1460                 }
1461
1462                 return this._search( value );
1463         },
1464
1465         _search: function( value ) {
1466                 this.pending++;
1467                 this.element.addClass( "ui-autocomplete-loading" );
1468                 this.cancelSearch = false;
1469
1470                 this.source( { term: value }, this._response() );
1471         },
1472
1473         _response: function() {
1474                 var index = ++this.requestIndex;
1475
1476                 return $.proxy(function( content ) {
1477                         if ( index === this.requestIndex ) {
1478                                 this.__response( content );
1479                         }
1480
1481                         this.pending--;
1482                         if ( !this.pending ) {
1483                                 this.element.removeClass( "ui-autocomplete-loading" );
1484                         }
1485                 }, this );
1486         },
1487
1488         __response: function( content ) {
1489                 if ( content ) {
1490                         content = this._normalize( content );
1491                 }
1492                 this._trigger( "response", null, { content: content } );
1493                 if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
1494                         this._suggest( content );
1495                         this._trigger( "open" );
1496                 } else {
1497                         // use ._close() instead of .close() so we don't cancel future searches
1498                         this._close();
1499                 }
1500         },
1501
1502         close: function( event ) {
1503                 this.cancelSearch = true;
1504                 this._close( event );
1505         },
1506
1507         _close: function( event ) {
1508                 if ( this.menu.element.is( ":visible" ) ) {
1509                         this.menu.element.hide();
1510                         this.menu.blur();
1511                         this.isNewMenu = true;
1512                         this._trigger( "close", event );
1513                 }
1514         },
1515
1516         _change: function( event ) {
1517                 if ( this.previous !== this._value() ) {
1518                         this._trigger( "change", event, { item: this.selectedItem } );
1519                 }
1520         },
1521
1522         _normalize: function( items ) {
1523                 // assume all items have the right format when the first item is complete
1524                 if ( items.length && items[0].label && items[0].value ) {
1525                         return items;
1526                 }
1527                 return $.map( items, function( item ) {
1528                         if ( typeof item === "string" ) {
1529                                 return {
1530                                         label: item,
1531                                         value: item
1532                                 };
1533                         }
1534                         return $.extend({
1535                                 label: item.label || item.value,
1536                                 value: item.value || item.label
1537                         }, item );
1538                 });
1539         },
1540
1541         _suggest: function( items ) {
1542                 var ul = this.menu.element.empty();
1543                 this._renderMenu( ul, items );
1544                 this.isNewMenu = true;
1545                 this.menu.refresh();
1546
1547                 // size and position menu
1548                 ul.show();
1549                 this._resizeMenu();
1550                 ul.position( $.extend({
1551                         of: this.element
1552                 }, this.options.position ));
1553
1554                 if ( this.options.autoFocus ) {
1555                         this.menu.next();
1556                 }
1557         },
1558
1559         _resizeMenu: function() {
1560                 var ul = this.menu.element;
1561                 ul.outerWidth( Math.max(
1562                         // Firefox wraps long text (possibly a rounding bug)
1563                         // so we add 1px to avoid the wrapping (#7513)
1564                         ul.width( "" ).outerWidth() + 1,
1565                         this.element.outerWidth()
1566                 ) );
1567         },
1568
1569         _renderMenu: function( ul, items ) {
1570                 var that = this;
1571                 $.each( items, function( index, item ) {
1572                         that._renderItemData( ul, item );
1573                 });
1574         },
1575
1576         _renderItemData: function( ul, item ) {
1577                 return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
1578         },
1579
1580         _renderItem: function( ul, item ) {
1581                 return $( "<li>" )
1582                         .append( $( "<a>" ).text( item.label ) )
1583                         .appendTo( ul );
1584         },
1585
1586         _move: function( direction, event ) {
1587                 if ( !this.menu.element.is( ":visible" ) ) {
1588                         this.search( null, event );
1589                         return;
1590                 }
1591                 if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
1592                                 this.menu.isLastItem() && /^next/.test( direction ) ) {
1593                         this._value( this.term );
1594                         this.menu.blur();
1595                         return;
1596                 }
1597                 this.menu[ direction ]( event );
1598         },
1599
1600         widget: function() {
1601                 return this.menu.element;
1602         },
1603
1604         _value: function() {
1605                 return this.valueMethod.apply( this.element, arguments );
1606         },
1607
1608         _keyEvent: function( keyEvent, event ) {
1609                 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
1610                         this._move( keyEvent, event );
1611
1612                         // prevents moving cursor to beginning/end of the text field in some browsers
1613                         event.preventDefault();
1614                 }
1615         }
1616 });
1617
1618 $.extend( $.ui.autocomplete, {
1619         escapeRegex: function( value ) {
1620                 return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
1621         },
1622         filter: function(array, term) {
1623                 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
1624                 return $.grep( array, function(value) {
1625                         return matcher.test( value.label || value.value || value );
1626                 });
1627         }
1628 });
1629
1630
1631 // live region extension, adding a `messages` option
1632 // NOTE: This is an experimental API. We are still investigating
1633 // a full solution for string manipulation and internationalization.
1634 $.widget( "ui.autocomplete", $.ui.autocomplete, {
1635         options: {
1636                 messages: {
1637                         noResults: "No search results.",
1638                         results: function( amount ) {
1639                                 return amount + ( amount > 1 ? " results are" : " result is" ) +
1640                                         " available, use up and down arrow keys to navigate.";
1641                         }
1642                 }
1643         },
1644
1645         __response: function( content ) {
1646                 var message;
1647                 this._superApply( arguments );
1648                 if ( this.options.disabled || this.cancelSearch ) {
1649                         return;
1650                 }
1651                 if ( content && content.length ) {
1652                         message = this.options.messages.results( content.length );
1653                 } else {
1654                         message = this.options.messages.noResults;
1655                 }
1656                 this.liveRegion.text( message );
1657         }
1658 });
1659
1660 }( jQuery ));
1661
1662 }catch (e) {
1663 System.out.println("coremenu failed to load jQuery.ui.autocomplete -- jQuery version conflict?");
1664 }
1665