3 Clazz.declarePackage ("swingjs.jquery");
\r
4 c$ = Clazz.declareType (swingjs.jquery, "JQuery_UI_Core2");
\r
5 Clazz.makeConstructor (c$,
\r
11 // menu button autocomplete
\r
13 if (!jQuery.ui.menu)
\r
17 * jQuery UI Menu 1.10.4
\r
18 * http://jqueryui.com
\r
20 * Copyright 2014 jQuery Foundation and other contributors
\r
21 * Released under the MIT license.
\r
22 * http://jquery.org/license
\r
24 * http://api.jqueryui.com/menu/
\r
28 * jquery.ui.widget.js
\r
29 * jquery.ui.position.js
\r
31 (function( $, undefined ) {
\r
33 $.widget( "ui.menu", {
\r
35 defaultElement: "<ul>",
\r
39 submenu: "ui-icon-carat-1-e"
\r
54 _create: function() {
\r
55 this.activeMenu = this.element;
\r
56 // flag used to prevent firing of the click handler
\r
57 // as the event bubbles up through nested menus
\r
58 this.mouseHandled = false;
\r
61 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
\r
62 .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
\r
64 role: this.options.role,
\r
67 // need to catch all clicks on disabled menu
\r
68 // not possible through _on
\r
69 .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
\r
70 if ( this.options.disabled ) {
\r
71 event.preventDefault();
\r
75 if ( this.options.disabled ) {
\r
77 .addClass( "ui-state-disabled" )
\r
78 .attr( "aria-disabled", "true" );
\r
82 // Prevent focus from sticking to links inside menu after clicking
\r
83 // them (focus should always stay on UL during navigation).
\r
84 "mousedown .ui-menu-item > a": function( event ) {
\r
85 event.preventDefault();
\r
87 "click .ui-state-disabled > a": function( event ) {
\r
88 event.preventDefault();
\r
90 "click .ui-menu-item:has(a)": function( event ) {
\r
91 var target = $( event.target ).closest( ".ui-menu-item" );
\r
92 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
\r
93 this.select( event );
\r
95 // Only set the mouseHandled flag if the event will bubble, see #9469.
\r
96 if ( !event.isPropagationStopped() ) {
\r
97 this.mouseHandled = true;
\r
100 // Open submenu on click
\r
101 if ( target.has( ".ui-menu" ).length ) {
\r
102 this.expand( event );
\r
103 } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
\r
105 // Redirect focus to the menu
\r
106 this.element.trigger( "focus", [ true ] );
\r
108 // If the active item is on the top level, let it stay active.
\r
109 // Otherwise, blur the active item since it is no longer visible.
\r
110 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
\r
111 clearTimeout( this.timer );
\r
116 "mouseenter .ui-menu-item": function( event ) {
\r
117 var target = $( event.currentTarget );
\r
118 // Remove ui-state-active class from siblings of the newly focused menu item
\r
119 // to avoid a jump caused by adjacent elements both having a class with a border
\r
120 target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
\r
121 this.focus( event, target );
\r
123 mouseleave: "collapseAll",
\r
124 "mouseleave .ui-menu": "collapseAll",
\r
125 focus: function( event, keepActiveItem ) {
\r
126 // If there's already an active item, keep it active
\r
127 // If not, activate the first item
\r
128 var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
\r
130 if ( !keepActiveItem ) {
\r
131 this.focus( event, item );
\r
134 blur: function( event ) {
\r
135 this._delay(function() {
\r
136 if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
\r
137 this.collapseAll( event );
\r
141 keydown: "_keydown"
\r
146 // Clicks outside of a menu collapse any open menus
\r
147 this._on( this.document, {
\r
148 click: function( event ) {
\r
149 if ( !$( event.target ).closest( ".ui-menu" ).length ) {
\r
150 this.collapseAll( event );
\r
153 // Reset the mouseHandled flag
\r
154 this.mouseHandled = false;
\r
159 _destroy: function() {
\r
160 // Destroy (sub)menus
\r
162 .removeAttr( "aria-activedescendant" )
\r
163 .find( ".ui-menu" ).addBack()
\r
164 .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
\r
165 .removeAttr( "role" )
\r
166 .removeAttr( "tabIndex" )
\r
167 .removeAttr( "aria-labelledby" )
\r
168 .removeAttr( "aria-expanded" )
\r
169 .removeAttr( "aria-hidden" )
\r
170 .removeAttr( "aria-disabled" )
\r
174 // Destroy menu items
\r
175 this.element.find( ".ui-menu-item" )
\r
176 .removeClass( "ui-menu-item" )
\r
177 .removeAttr( "role" )
\r
178 .removeAttr( "aria-disabled" )
\r
181 .removeClass( "ui-corner-all ui-state-hover" )
\r
182 .removeAttr( "tabIndex" )
\r
183 .removeAttr( "role" )
\r
184 .removeAttr( "aria-haspopup" )
\r
185 .children().each( function() {
\r
186 var elem = $( this );
\r
187 if ( elem.data( "ui-menu-submenu-carat" ) ) {
\r
192 // Destroy menu dividers
\r
193 this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
\r
196 _keydown: function( event ) {
\r
197 var match, prev, character, skip, regex,
\r
198 preventDefault = true;
\r
200 function escape( value ) {
\r
201 return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
\r
204 switch ( event.keyCode ) {
\r
205 case $.ui.keyCode.PAGE_UP:
\r
206 this.previousPage( event );
\r
208 case $.ui.keyCode.PAGE_DOWN:
\r
209 this.nextPage( event );
\r
211 case $.ui.keyCode.HOME:
\r
212 this._move( "first", "first", event );
\r
214 case $.ui.keyCode.END:
\r
215 this._move( "last", "last", event );
\r
217 case $.ui.keyCode.UP:
\r
218 this.previous( event );
\r
220 case $.ui.keyCode.DOWN:
\r
221 this.next( event );
\r
223 case $.ui.keyCode.LEFT:
\r
224 this.collapse( event );
\r
226 case $.ui.keyCode.RIGHT:
\r
227 if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
\r
228 this.expand( event );
\r
231 case $.ui.keyCode.ENTER:
\r
232 case $.ui.keyCode.SPACE:
\r
233 this._activate( event );
\r
235 case $.ui.keyCode.ESCAPE:
\r
236 this.collapse( event );
\r
239 preventDefault = false;
\r
240 prev = this.previousFilter || "";
\r
241 character = String.fromCharCode( event.keyCode );
\r
244 clearTimeout( this.filterTimer );
\r
246 if ( character === prev ) {
\r
249 character = prev + character;
\r
252 regex = new RegExp( "^" + escape( character ), "i" );
\r
253 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
\r
254 return regex.test( $( this ).children( "a" ).text() );
\r
256 match = skip && match.index( this.active.next() ) !== -1 ?
\r
257 this.active.nextAll( ".ui-menu-item" ) :
\r
260 // If no matches on the current filter, reset to the last character pressed
\r
261 // to move down the menu to the first item that starts with that character
\r
262 if ( !match.length ) {
\r
263 character = String.fromCharCode( event.keyCode );
\r
264 regex = new RegExp( "^" + escape( character ), "i" );
\r
265 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
\r
266 return regex.test( $( this ).children( "a" ).text() );
\r
270 if ( match.length ) {
\r
271 this.focus( event, match );
\r
272 if ( match.length > 1 ) {
\r
273 this.previousFilter = character;
\r
274 this.filterTimer = this._delay(function() {
\r
275 delete this.previousFilter;
\r
278 delete this.previousFilter;
\r
281 delete this.previousFilter;
\r
285 if ( preventDefault ) {
\r
286 event.preventDefault();
\r
290 _activate: function( event ) {
\r
291 if ( !this.active.is( ".ui-state-disabled" ) ) {
\r
292 if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
\r
293 this.expand( event );
\r
295 this.select( event );
\r
300 refresh: function() {
\r
302 icon = this.options.icons.submenu,
\r
303 submenus = this.element.find( this.options.menus );
\r
305 this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
\r
307 // Initialize nested menus
\r
308 submenus.filter( ":not(.ui-menu)" )
\r
309 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
\r
312 role: this.options.role,
\r
313 "aria-hidden": "true",
\r
314 "aria-expanded": "false"
\r
317 var menu = $( this ),
\r
318 item = menu.prev( "a" ),
\r
319 submenuCarat = $( "<span>" )
\r
320 .addClass( "ui-menu-icon ui-icon " + icon )
\r
321 .data( "ui-menu-submenu-carat", true );
\r
324 .attr( "aria-haspopup", "true" )
\r
325 .prepend( submenuCarat );
\r
326 menu.attr( "aria-labelledby", item.attr( "id" ) );
\r
329 menus = submenus.add( this.element );
\r
331 // Don't refresh list items that are already adapted
\r
332 menus.children( ":not(.ui-menu-item):has(a)" )
\r
333 .addClass( "ui-menu-item" )
\r
334 .attr( "role", "presentation" )
\r
337 .addClass( "ui-corner-all" )
\r
340 role: this._itemRole()
\r
343 // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
\r
344 menus.children( ":not(.ui-menu-item)" ).each(function() {
\r
345 var item = $( this );
\r
346 // hyphen, em dash, en dash
\r
347 if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
\r
348 item.addClass( "ui-widget-content ui-menu-divider" );
\r
352 // Add aria-disabled attribute to any disabled menu item
\r
353 menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
\r
355 // If the active item has been removed, blur the menu
\r
356 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
\r
361 _itemRole: function() {
\r
365 }[ this.options.role ];
\r
368 _setOption: function( key, value ) {
\r
369 if ( key === "icons" ) {
\r
370 this.element.find( ".ui-menu-icon" )
\r
371 .removeClass( this.options.icons.submenu )
\r
372 .addClass( value.submenu );
\r
374 this._super( key, value );
\r
377 focus: function( event, item ) {
\r
378 var nested, focused;
\r
379 this.blur( event, event && event.type === "focus" );
\r
381 this._scrollIntoView( item );
\r
383 this.active = item.first();
\r
384 focused = this.active.children( "a" ).addClass( "ui-state-focus" );
\r
385 // Only update aria-activedescendant if there's a role
\r
386 // otherwise we assume focus is managed elsewhere
\r
387 if ( this.options.role ) {
\r
388 this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
\r
391 // Highlight active parent menu item, if any
\r
394 .closest( ".ui-menu-item" )
\r
395 .children( "a:first" )
\r
396 .addClass( "ui-state-active" );
\r
398 if ( event && event.type === "keydown" ) {
\r
401 this.timer = this._delay(function() {
\r
406 nested = item.children( ".ui-menu" );
\r
407 if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
\r
408 this._startOpening(nested);
\r
410 this.activeMenu = item.parent();
\r
412 this._trigger( "focus", event, { item: item } );
\r
415 _scrollIntoView: function( item ) {
\r
416 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
\r
417 if ( this._hasScroll() ) {
\r
418 borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
\r
419 paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
\r
420 offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
\r
421 scroll = this.activeMenu.scrollTop();
\r
422 elementHeight = this.activeMenu.height();
\r
423 itemHeight = item.height();
\r
425 if ( offset < 0 ) {
\r
426 this.activeMenu.scrollTop( scroll + offset );
\r
427 } else if ( offset + itemHeight > elementHeight ) {
\r
428 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
\r
433 blur: function( event, fromFocus ) {
\r
434 if ( !fromFocus ) {
\r
435 clearTimeout( this.timer );
\r
438 if ( !this.active ) {
\r
442 this.active.children( "a" ).removeClass( "ui-state-focus" );
\r
443 this.active = null;
\r
445 this._trigger( "blur", event, { item: this.active } );
\r
448 _startOpening: function( submenu ) {
\r
449 clearTimeout( this.timer );
\r
451 // Don't open if already open fixes a Firefox bug that caused a .5 pixel
\r
452 // shift in the submenu position when mousing over the carat icon
\r
453 if ( submenu.attr( "aria-hidden" ) !== "true" ) {
\r
457 this.timer = this._delay(function() {
\r
459 this._open( submenu );
\r
463 _open: function( submenu ) {
\r
464 var position = $.extend({
\r
466 }, this.options.position );
\r
468 clearTimeout( this.timer );
\r
469 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
\r
471 .attr( "aria-hidden", "true" );
\r
475 .removeAttr( "aria-hidden" )
\r
476 .attr( "aria-expanded", "true" )
\r
477 .position( position );
\r
480 collapseAll: function( event, all ) {
\r
481 clearTimeout( this.timer );
\r
482 this.timer = this._delay(function() {
\r
483 // If we were passed an event, look for the submenu that contains the event
\r
484 var currentMenu = all ? this.element :
\r
485 $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
\r
487 // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
\r
488 if ( !currentMenu.length ) {
\r
489 currentMenu = this.element;
\r
492 this._close( currentMenu );
\r
494 this.blur( event );
\r
495 this.activeMenu = currentMenu;
\r
499 // With no arguments, closes the currently active menu - if nothing is active
\r
500 // it closes all menus. If passed an argument, it will search for menus BELOW
\r
501 _close: function( startMenu ) {
\r
502 if ( !startMenu ) {
\r
503 startMenu = this.active ? this.active.parent() : this.element;
\r
507 .find( ".ui-menu" )
\r
509 .attr( "aria-hidden", "true" )
\r
510 .attr( "aria-expanded", "false" )
\r
512 .find( "a.ui-state-active" )
\r
513 .removeClass( "ui-state-active" );
\r
516 collapse: function( event ) {
\r
517 var newItem = this.active &&
\r
518 this.active.parent().closest( ".ui-menu-item", this.element );
\r
519 if ( newItem && newItem.length ) {
\r
521 this.focus( event, newItem );
\r
525 expand: function( event ) {
\r
526 var newItem = this.active &&
\r
528 .children( ".ui-menu " )
\r
529 .children( ".ui-menu-item" )
\r
532 if ( newItem && newItem.length ) {
\r
533 this._open( newItem.parent() );
\r
535 // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
\r
536 this._delay(function() {
\r
537 this.focus( event, newItem );
\r
542 next: function( event ) {
\r
543 this._move( "next", "first", event );
\r
546 previous: function( event ) {
\r
547 this._move( "prev", "last", event );
\r
550 isFirstItem: function() {
\r
551 return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
\r
554 isLastItem: function() {
\r
555 return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
\r
558 _move: function( direction, filter, event ) {
\r
560 if ( this.active ) {
\r
561 if ( direction === "first" || direction === "last" ) {
\r
563 [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
\r
567 [ direction + "All" ]( ".ui-menu-item" )
\r
571 if ( !next || !next.length || !this.active ) {
\r
572 next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
\r
575 this.focus( event, next );
\r
578 nextPage: function( event ) {
\r
579 var item, base, height;
\r
581 if ( !this.active ) {
\r
582 this.next( event );
\r
585 if ( this.isLastItem() ) {
\r
588 if ( this._hasScroll() ) {
\r
589 base = this.active.offset().top;
\r
590 height = this.element.height();
\r
591 this.active.nextAll( ".ui-menu-item" ).each(function() {
\r
593 return item.offset().top - base - height < 0;
\r
596 this.focus( event, item );
\r
598 this.focus( event, this.activeMenu.children( ".ui-menu-item" )
\r
599 [ !this.active ? "first" : "last" ]() );
\r
603 previousPage: function( event ) {
\r
604 var item, base, height;
\r
605 if ( !this.active ) {
\r
606 this.next( event );
\r
609 if ( this.isFirstItem() ) {
\r
612 if ( this._hasScroll() ) {
\r
613 base = this.active.offset().top;
\r
614 height = this.element.height();
\r
615 this.active.prevAll( ".ui-menu-item" ).each(function() {
\r
617 return item.offset().top - base + height > 0;
\r
620 this.focus( event, item );
\r
622 this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
\r
626 _hasScroll: function() {
\r
627 return this.element.outerHeight() < this.element.prop( "scrollHeight" );
\r
630 select: function( event ) {
\r
631 // TODO: It should never be possible to not have an active item at this
\r
632 // point, but the tests don't trigger mouseenter before click.
\r
633 this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
\r
634 var ui = { item: this.active };
\r
635 if ( !this.active.has( ".ui-menu" ).length ) {
\r
636 this.collapseAll( event, true );
\r
638 this._trigger( "select", event, ui );
\r
646 System.out.println("coremenu failed to load jQuery.ui.menu -- jQuery version conflict?");
\r
649 if (!jQuery.ui.button)
\r
653 * jQuery UI Button 1.10.4
\r
654 * http://jqueryui.com
\r
656 * Copyright 2014 jQuery Foundation and other contributors
\r
657 * Released under the MIT license.
\r
658 * http://jquery.org/license
\r
660 * http://api.jqueryui.com/button/
\r
663 * jquery.ui.core.js
\r
664 * jquery.ui.widget.js
\r
666 (function( $, undefined ) {
\r
669 baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
\r
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",
\r
671 formResetHandler = function() {
\r
672 var form = $( this );
\r
673 setTimeout(function() {
\r
674 form.find( ":ui-button" ).button( "refresh" );
\r
677 radioGroup = function( radio ) {
\r
678 var name = radio.name,
\r
682 name = name.replace( /'/g, "\\'" );
\r
684 radios = $( form ).find( "[name='" + name + "']" );
\r
686 radios = $( "[name='" + name + "']", radio.ownerDocument )
\r
687 .filter(function() {
\r
695 $.widget( "ui.button", {
\r
697 defaultElement: "<button>",
\r
707 _create: function() {
\r
708 this.element.closest( "form" )
\r
709 .unbind( "reset" + this.eventNamespace )
\r
710 .bind( "reset" + this.eventNamespace, formResetHandler );
\r
712 if ( typeof this.options.disabled !== "boolean" ) {
\r
713 this.options.disabled = !!this.element.prop( "disabled" );
\r
715 this.element.prop( "disabled", this.options.disabled );
\r
718 this._determineButtonType();
\r
719 this.hasTitle = !!this.buttonElement.attr( "title" );
\r
722 options = this.options,
\r
723 toggleButton = this.type === "checkbox" || this.type === "radio",
\r
724 activeClass = !toggleButton ? "ui-state-active" : "";
\r
726 if ( options.label === null ) {
\r
727 options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
\r
730 this._hoverable( this.buttonElement );
\r
733 .addClass( baseClasses )
\r
734 .attr( "role", "button" )
\r
735 .bind( "mouseenter" + this.eventNamespace, function() {
\r
736 if ( options.disabled ) {
\r
739 if ( this === lastActive ) {
\r
740 $( this ).addClass( "ui-state-active" );
\r
743 .bind( "mouseleave" + this.eventNamespace, function() {
\r
744 if ( options.disabled ) {
\r
747 $( this ).removeClass( activeClass );
\r
749 .bind( "click" + this.eventNamespace, function( event ) {
\r
750 if ( options.disabled ) {
\r
751 event.preventDefault();
\r
752 event.stopImmediatePropagation();
\r
756 // Can't use _focusable() because the element that receives focus
\r
757 // and the element that gets the ui-state-focus class are different
\r
759 focus: function() {
\r
760 this.buttonElement.addClass( "ui-state-focus" );
\r
763 this.buttonElement.removeClass( "ui-state-focus" );
\r
767 if ( toggleButton ) {
\r
768 this.element.bind( "change" + this.eventNamespace, function() {
\r
773 if ( this.type === "checkbox" ) {
\r
774 this.buttonElement.bind( "click" + this.eventNamespace, function() {
\r
775 if ( options.disabled ) {
\r
779 } else if ( this.type === "radio" ) {
\r
780 this.buttonElement.bind( "click" + this.eventNamespace, function() {
\r
781 if ( options.disabled ) {
\r
784 $( this ).addClass( "ui-state-active" );
\r
785 that.buttonElement.attr( "aria-pressed", "true" );
\r
787 var radio = that.element[ 0 ];
\r
788 radioGroup( radio )
\r
791 return $( this ).button( "widget" )[ 0 ];
\r
793 .removeClass( "ui-state-active" )
\r
794 .attr( "aria-pressed", "false" );
\r
798 .bind( "mousedown" + this.eventNamespace, function() {
\r
799 if ( options.disabled ) {
\r
802 $( this ).addClass( "ui-state-active" );
\r
804 that.document.one( "mouseup", function() {
\r
808 .bind( "mouseup" + this.eventNamespace, function() {
\r
809 if ( options.disabled ) {
\r
812 $( this ).removeClass( "ui-state-active" );
\r
814 .bind( "keydown" + this.eventNamespace, function(event) {
\r
815 if ( options.disabled ) {
\r
818 if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
\r
819 $( this ).addClass( "ui-state-active" );
\r
822 // see #8559, we bind to blur here in case the button element loses
\r
823 // focus between keydown and keyup, it would be left in an "active" state
\r
824 .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
\r
825 $( this ).removeClass( "ui-state-active" );
\r
828 if ( this.buttonElement.is("a") ) {
\r
829 this.buttonElement.keyup(function(event) {
\r
830 if ( event.keyCode === $.ui.keyCode.SPACE ) {
\r
831 // TODO pass through original event correctly (just as 2nd argument doesn't work)
\r
838 // TODO: pull out $.Widget's handling for the disabled option into
\r
839 // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
\r
840 // be overridden by individual plugins
\r
841 this._setOption( "disabled", options.disabled );
\r
842 this._resetButton();
\r
845 _determineButtonType: function() {
\r
846 var ancestor, labelSelector, checked;
\r
848 if ( this.element.is("[type=checkbox]") ) {
\r
849 this.type = "checkbox";
\r
850 } else if ( this.element.is("[type=radio]") ) {
\r
851 this.type = "radio";
\r
852 } else if ( this.element.is("input") ) {
\r
853 this.type = "input";
\r
855 this.type = "button";
\r
858 if ( this.type === "checkbox" || this.type === "radio" ) {
\r
859 // we don't search against the document in case the element
\r
860 // is disconnected from the DOM
\r
861 ancestor = this.element.parents().last();
\r
862 labelSelector = "label[for='" + this.element.attr("id") + "']";
\r
863 this.buttonElement = ancestor.find( labelSelector );
\r
864 if ( !this.buttonElement.length ) {
\r
865 ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
\r
866 this.buttonElement = ancestor.filter( labelSelector );
\r
867 if ( !this.buttonElement.length ) {
\r
868 this.buttonElement = ancestor.find( labelSelector );
\r
871 this.element.addClass( "ui-helper-hidden-accessible" );
\r
873 checked = this.element.is( ":checked" );
\r
875 this.buttonElement.addClass( "ui-state-active" );
\r
877 this.buttonElement.prop( "aria-pressed", checked );
\r
879 this.buttonElement = this.element;
\r
883 widget: function() {
\r
884 return this.buttonElement;
\r
887 _destroy: function() {
\r
889 .removeClass( "ui-helper-hidden-accessible" );
\r
891 .removeClass( baseClasses + " ui-state-active " + typeClasses )
\r
892 .removeAttr( "role" )
\r
893 .removeAttr( "aria-pressed" )
\r
894 .html( this.buttonElement.find(".ui-button-text").html() );
\r
896 if ( !this.hasTitle ) {
\r
897 this.buttonElement.removeAttr( "title" );
\r
901 _setOption: function( key, value ) {
\r
902 this._super( key, value );
\r
903 if ( key === "disabled" ) {
\r
904 this.element.prop( "disabled", !!value );
\r
906 this.buttonElement.removeClass( "ui-state-focus" );
\r
910 this._resetButton();
\r
913 refresh: function() {
\r
914 //See #8237 & #8828
\r
915 var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
\r
917 if ( isDisabled !== this.options.disabled ) {
\r
918 this._setOption( "disabled", isDisabled );
\r
920 if ( this.type === "radio" ) {
\r
921 radioGroup( this.element[0] ).each(function() {
\r
922 if ( $( this ).is( ":checked" ) ) {
\r
923 $( this ).button( "widget" )
\r
924 .addClass( "ui-state-active" )
\r
925 .attr( "aria-pressed", "true" );
\r
927 $( this ).button( "widget" )
\r
928 .removeClass( "ui-state-active" )
\r
929 .attr( "aria-pressed", "false" );
\r
932 } else if ( this.type === "checkbox" ) {
\r
933 if ( this.element.is( ":checked" ) ) {
\r
935 .addClass( "ui-state-active" )
\r
936 .attr( "aria-pressed", "true" );
\r
939 .removeClass( "ui-state-active" )
\r
940 .attr( "aria-pressed", "false" );
\r
945 _resetButton: function() {
\r
946 if ( this.type === "input" ) {
\r
947 if ( this.options.label ) {
\r
948 this.element.val( this.options.label );
\r
952 var buttonElement = this.buttonElement.removeClass( typeClasses ),
\r
953 buttonText = $( "<span></span>", this.document[0] )
\r
954 .addClass( "ui-button-text" )
\r
955 .html( this.options.label )
\r
956 .appendTo( buttonElement.empty() )
\r
958 icons = this.options.icons,
\r
959 multipleIcons = icons.primary && icons.secondary,
\r
960 buttonClasses = [];
\r
962 if ( icons.primary || icons.secondary ) {
\r
963 if ( this.options.text ) {
\r
964 buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
\r
967 if ( icons.primary ) {
\r
968 buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
\r
971 if ( icons.secondary ) {
\r
972 buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
\r
975 if ( !this.options.text ) {
\r
976 buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
\r
978 if ( !this.hasTitle ) {
\r
979 buttonElement.attr( "title", $.trim( buttonText ) );
\r
983 buttonClasses.push( "ui-button-text-only" );
\r
985 buttonElement.addClass( buttonClasses.join( " " ) );
\r
989 $.widget( "ui.buttonset", {
\r
992 items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
\r
995 _create: function() {
\r
996 this.element.addClass( "ui-buttonset" );
\r
999 _init: function() {
\r
1003 _setOption: function( key, value ) {
\r
1004 if ( key === "disabled" ) {
\r
1005 this.buttons.button( "option", key, value );
\r
1008 this._super( key, value );
\r
1011 refresh: function() {
\r
1012 var rtl = this.element.css( "direction" ) === "rtl";
\r
1014 this.buttons = this.element.find( this.options.items )
\r
1015 .filter( ":ui-button" )
\r
1016 .button( "refresh" )
\r
1018 .not( ":ui-button" )
\r
1022 return $( this ).button( "widget" )[ 0 ];
\r
1024 .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
\r
1025 .filter( ":first" )
\r
1026 .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
\r
1028 .filter( ":last" )
\r
1029 .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
\r
1034 _destroy: function() {
\r
1035 this.element.removeClass( "ui-buttonset" );
\r
1038 return $( this ).button( "widget" )[ 0 ];
\r
1040 .removeClass( "ui-corner-left ui-corner-right" )
\r
1042 .button( "destroy" );
\r
1049 System.out.println("coremenu failed to load jQuery.ui.button -- jQuery version conflict?");
\r
1052 if (!jQuery.ui.autocomplete)
\r
1056 * jQuery UI Autocomplete 1.10.4
\r
1057 * http://jqueryui.com
\r
1059 * Copyright 2014 jQuery Foundation and other contributors
\r
1060 * Released under the MIT license.
\r
1061 * http://jquery.org/license
\r
1063 * http://api.jqueryui.com/autocomplete/
\r
1066 * jquery.ui.core.js
\r
1067 * jquery.ui.widget.js
\r
1068 * jquery.ui.position.js
\r
1069 * jquery.ui.menu.js
\r
1071 (function( $, undefined ) {
\r
1073 $.widget( "ui.autocomplete", {
\r
1074 version: "1.10.4",
\r
1075 defaultElement: "<input>",
\r
1083 at: "left bottom",
\r
1101 _create: function() {
\r
1102 // Some browsers only repeat keydown events, not keypress events,
\r
1103 // so we use the suppressKeyPress flag to determine if we've already
\r
1104 // handled the keydown event. #7269
\r
1105 // Unfortunately the code for & in keypress is the same as the up arrow,
\r
1106 // so we use the suppressKeyPressRepeat flag to avoid handling keypress
\r
1107 // events when we know the keydown event was used to modify the
\r
1108 // search term. #7799
\r
1109 var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
\r
1110 nodeName = this.element[0].nodeName.toLowerCase(),
\r
1111 isTextarea = nodeName === "textarea",
\r
1112 isInput = nodeName === "input";
\r
1114 this.isMultiLine =
\r
1115 // Textareas are always multi-line
\r
1116 isTextarea ? true :
\r
1117 // Inputs are always single-line, even if inside a contentEditable element
\r
1118 // IE also treats inputs as contentEditable
\r
1120 // All other element types are determined by whether or not they're contentEditable
\r
1121 this.element.prop( "isContentEditable" );
\r
1123 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
\r
1124 this.isNewMenu = true;
\r
1127 .addClass( "ui-autocomplete-input" )
\r
1128 .attr( "autocomplete", "off" );
\r
1130 this._on( this.element, {
\r
1131 keydown: function( event ) {
\r
1132 if ( this.element.prop( "readOnly" ) ) {
\r
1133 suppressKeyPress = true;
\r
1134 suppressInput = true;
\r
1135 suppressKeyPressRepeat = true;
\r
1139 suppressKeyPress = false;
\r
1140 suppressInput = false;
\r
1141 suppressKeyPressRepeat = false;
\r
1142 var keyCode = $.ui.keyCode;
\r
1143 switch( event.keyCode ) {
\r
1144 case keyCode.PAGE_UP:
\r
1145 suppressKeyPress = true;
\r
1146 this._move( "previousPage", event );
\r
1148 case keyCode.PAGE_DOWN:
\r
1149 suppressKeyPress = true;
\r
1150 this._move( "nextPage", event );
\r
1153 suppressKeyPress = true;
\r
1154 this._keyEvent( "previous", event );
\r
1156 case keyCode.DOWN:
\r
1157 suppressKeyPress = true;
\r
1158 this._keyEvent( "next", event );
\r
1160 case keyCode.ENTER:
\r
1161 case keyCode.NUMPAD_ENTER:
\r
1162 // when menu is open and has focus
\r
1163 if ( this.menu.active ) {
\r
1164 // #6055 - Opera still allows the keypress to occur
\r
1165 // which causes forms to submit
\r
1166 suppressKeyPress = true;
\r
1167 event.preventDefault();
\r
1168 this.menu.select( event );
\r
1172 if ( this.menu.active ) {
\r
1173 this.menu.select( event );
\r
1176 case keyCode.ESCAPE:
\r
1177 if ( this.menu.element.is( ":visible" ) ) {
\r
1178 this._value( this.term );
\r
1179 this.close( event );
\r
1180 // Different browsers have different default behavior for escape
\r
1181 // Single press can mean undo or clear
\r
1182 // Double press in IE means clear the whole form
\r
1183 event.preventDefault();
\r
1187 suppressKeyPressRepeat = true;
\r
1188 // search timeout should be triggered before the input value is changed
\r
1189 this._searchTimeout( event );
\r
1193 keypress: function( event ) {
\r
1194 if ( suppressKeyPress ) {
\r
1195 suppressKeyPress = false;
\r
1196 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
\r
1197 event.preventDefault();
\r
1201 if ( suppressKeyPressRepeat ) {
\r
1205 // replicate some key handlers to allow them to repeat in Firefox and Opera
\r
1206 var keyCode = $.ui.keyCode;
\r
1207 switch( event.keyCode ) {
\r
1208 case keyCode.PAGE_UP:
\r
1209 this._move( "previousPage", event );
\r
1211 case keyCode.PAGE_DOWN:
\r
1212 this._move( "nextPage", event );
\r
1215 this._keyEvent( "previous", event );
\r
1217 case keyCode.DOWN:
\r
1218 this._keyEvent( "next", event );
\r
1222 input: function( event ) {
\r
1223 if ( suppressInput ) {
\r
1224 suppressInput = false;
\r
1225 event.preventDefault();
\r
1228 this._searchTimeout( event );
\r
1230 focus: function() {
\r
1231 this.selectedItem = null;
\r
1232 this.previous = this._value();
\r
1234 blur: function( event ) {
\r
1235 if ( this.cancelBlur ) {
\r
1236 delete this.cancelBlur;
\r
1240 clearTimeout( this.searching );
\r
1241 this.close( event );
\r
1242 this._change( event );
\r
1246 this._initSource();
\r
1247 this.menu = $( "<ul>" )
\r
1248 .addClass( "ui-autocomplete ui-front" )
\r
1249 .appendTo( this._appendTo() )
\r
1251 // disable ARIA support, the live region takes care of that
\r
1255 .data( "ui-menu" );
\r
1257 this._on( this.menu.element, {
\r
1258 mousedown: function( event ) {
\r
1259 // prevent moving focus out of the text field
\r
1260 event.preventDefault();
\r
1262 // IE doesn't prevent moving focus even with event.preventDefault()
\r
1263 // so we set a flag to know when we should ignore the blur event
\r
1264 this.cancelBlur = true;
\r
1265 this._delay(function() {
\r
1266 delete this.cancelBlur;
\r
1269 // clicking on the scrollbar causes focus to shift to the body
\r
1270 // but we can't detect a mouseup or a click immediately afterward
\r
1271 // so we have to track the next mousedown and close the menu if
\r
1272 // the user clicks somewhere outside of the autocomplete
\r
1273 var menuElement = this.menu.element[ 0 ];
\r
1274 if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
\r
1275 this._delay(function() {
\r
1277 this.document.one( "mousedown", function( event ) {
\r
1278 if ( event.target !== that.element[ 0 ] &&
\r
1279 event.target !== menuElement &&
\r
1280 !$.contains( menuElement, event.target ) ) {
\r
1287 menufocus: function( event, ui ) {
\r
1288 // support: Firefox
\r
1289 // Prevent accidental activation of menu items in Firefox (#7024 #9118)
\r
1290 if ( this.isNewMenu ) {
\r
1291 this.isNewMenu = false;
\r
1292 if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
\r
1295 this.document.one( "mousemove", function() {
\r
1296 $( event.target ).trigger( event.originalEvent );
\r
1303 var item = ui.item.data( "ui-autocomplete-item" );
\r
1304 if ( false !== this._trigger( "focus", event, { item: item } ) ) {
\r
1305 // use value to match what will end up in the input, if it was a key event
\r
1306 if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
\r
1307 this._value( item.value );
\r
1310 // Normally the input is populated with the item's value as the
\r
1311 // menu is navigated, causing screen readers to notice a change and
\r
1312 // announce the item. Since the focus event was canceled, this doesn't
\r
1313 // happen, so we update the live region so that screen readers can
\r
1314 // still notice the change and announce it.
\r
1315 this.liveRegion.text( item.value );
\r
1318 menuselect: function( event, ui ) {
\r
1319 var item = ui.item.data( "ui-autocomplete-item" ),
\r
1320 previous = this.previous;
\r
1322 // only trigger when focus was lost (click on menu)
\r
1323 if ( this.element[0] !== this.document[0].activeElement ) {
\r
1324 this.element.focus();
\r
1325 this.previous = previous;
\r
1326 // #6109 - IE triggers two focus events and the second
\r
1327 // is asynchronous, so we need to reset the previous
\r
1328 // term synchronously and asynchronously :-(
\r
1329 this._delay(function() {
\r
1330 this.previous = previous;
\r
1331 this.selectedItem = item;
\r
1335 if ( false !== this._trigger( "select", event, { item: item } ) ) {
\r
1336 this._value( item.value );
\r
1338 // reset the term after the select event
\r
1339 // this allows custom select handling to work properly
\r
1340 this.term = this._value();
\r
1342 this.close( event );
\r
1343 this.selectedItem = item;
\r
1347 this.liveRegion = $( "<span>", {
\r
1349 "aria-live": "polite"
\r
1351 .addClass( "ui-helper-hidden-accessible" )
\r
1352 .insertBefore( this.element );
\r
1354 // turning off autocomplete prevents the browser from remembering the
\r
1355 // value when navigating through history, so we re-enable autocomplete
\r
1356 // if the page is unloaded before the widget is destroyed. #7790
\r
1357 this._on( this.window, {
\r
1358 beforeunload: function() {
\r
1359 this.element.removeAttr( "autocomplete" );
\r
1364 _destroy: function() {
\r
1365 clearTimeout( this.searching );
\r
1367 .removeClass( "ui-autocomplete-input" )
\r
1368 .removeAttr( "autocomplete" );
\r
1369 this.menu.element.remove();
\r
1370 this.liveRegion.remove();
\r
1373 _setOption: function( key, value ) {
\r
1374 this._super( key, value );
\r
1375 if ( key === "source" ) {
\r
1376 this._initSource();
\r
1378 if ( key === "appendTo" ) {
\r
1379 this.menu.element.appendTo( this._appendTo() );
\r
1381 if ( key === "disabled" && value && this.xhr ) {
\r
1386 _appendTo: function() {
\r
1387 var element = this.options.appendTo;
\r
1390 element = element.jquery || element.nodeType ?
\r
1392 this.document.find( element ).eq( 0 );
\r
1396 element = this.element.closest( ".ui-front" );
\r
1399 if ( !element.length ) {
\r
1400 element = this.document[0].body;
\r
1406 _initSource: function() {
\r
1409 if ( $.isArray(this.options.source) ) {
\r
1410 array = this.options.source;
\r
1411 this.source = function( request, response ) {
\r
1412 response( $.ui.autocomplete.filter( array, request.term ) );
\r
1414 } else if ( typeof this.options.source === "string" ) {
\r
1415 url = this.options.source;
\r
1416 this.source = function( request, response ) {
\r
1420 that.xhr = $.ajax({
\r
1424 success: function( data ) {
\r
1427 error: function() {
\r
1433 this.source = this.options.source;
\r
1437 _searchTimeout: function( event ) {
\r
1438 clearTimeout( this.searching );
\r
1439 this.searching = this._delay(function() {
\r
1440 // only search if the value has changed
\r
1441 if ( this.term !== this._value() ) {
\r
1442 this.selectedItem = null;
\r
1443 this.search( null, event );
\r
1445 }, this.options.delay );
\r
1448 search: function( value, event ) {
\r
1449 value = value != null ? value : this._value();
\r
1451 // always save the actual value, not the one passed as an argument
\r
1452 this.term = this._value();
\r
1454 if ( value.length < this.options.minLength ) {
\r
1455 return this.close( event );
\r
1458 if ( this._trigger( "search", event ) === false ) {
\r
1462 return this._search( value );
\r
1465 _search: function( value ) {
\r
1467 this.element.addClass( "ui-autocomplete-loading" );
\r
1468 this.cancelSearch = false;
\r
1470 this.source( { term: value }, this._response() );
\r
1473 _response: function() {
\r
1474 var index = ++this.requestIndex;
\r
1476 return $.proxy(function( content ) {
\r
1477 if ( index === this.requestIndex ) {
\r
1478 this.__response( content );
\r
1482 if ( !this.pending ) {
\r
1483 this.element.removeClass( "ui-autocomplete-loading" );
\r
1488 __response: function( content ) {
\r
1490 content = this._normalize( content );
\r
1492 this._trigger( "response", null, { content: content } );
\r
1493 if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
\r
1494 this._suggest( content );
\r
1495 this._trigger( "open" );
\r
1497 // use ._close() instead of .close() so we don't cancel future searches
\r
1502 close: function( event ) {
\r
1503 this.cancelSearch = true;
\r
1504 this._close( event );
\r
1507 _close: function( event ) {
\r
1508 if ( this.menu.element.is( ":visible" ) ) {
\r
1509 this.menu.element.hide();
\r
1511 this.isNewMenu = true;
\r
1512 this._trigger( "close", event );
\r
1516 _change: function( event ) {
\r
1517 if ( this.previous !== this._value() ) {
\r
1518 this._trigger( "change", event, { item: this.selectedItem } );
\r
1522 _normalize: function( items ) {
\r
1523 // assume all items have the right format when the first item is complete
\r
1524 if ( items.length && items[0].label && items[0].value ) {
\r
1527 return $.map( items, function( item ) {
\r
1528 if ( typeof item === "string" ) {
\r
1535 label: item.label || item.value,
\r
1536 value: item.value || item.label
\r
1541 _suggest: function( items ) {
\r
1542 var ul = this.menu.element.empty();
\r
1543 this._renderMenu( ul, items );
\r
1544 this.isNewMenu = true;
\r
1545 this.menu.refresh();
\r
1547 // size and position menu
\r
1549 this._resizeMenu();
\r
1550 ul.position( $.extend({
\r
1552 }, this.options.position ));
\r
1554 if ( this.options.autoFocus ) {
\r
1559 _resizeMenu: function() {
\r
1560 var ul = this.menu.element;
\r
1561 ul.outerWidth( Math.max(
\r
1562 // Firefox wraps long text (possibly a rounding bug)
\r
1563 // so we add 1px to avoid the wrapping (#7513)
\r
1564 ul.width( "" ).outerWidth() + 1,
\r
1565 this.element.outerWidth()
\r
1569 _renderMenu: function( ul, items ) {
\r
1571 $.each( items, function( index, item ) {
\r
1572 that._renderItemData( ul, item );
\r
1576 _renderItemData: function( ul, item ) {
\r
1577 return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
\r
1580 _renderItem: function( ul, item ) {
\r
1581 return $( "<li>" )
\r
1582 .append( $( "<a>" ).text( item.label ) )
\r
1586 _move: function( direction, event ) {
\r
1587 if ( !this.menu.element.is( ":visible" ) ) {
\r
1588 this.search( null, event );
\r
1591 if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
\r
1592 this.menu.isLastItem() && /^next/.test( direction ) ) {
\r
1593 this._value( this.term );
\r
1597 this.menu[ direction ]( event );
\r
1600 widget: function() {
\r
1601 return this.menu.element;
\r
1604 _value: function() {
\r
1605 return this.valueMethod.apply( this.element, arguments );
\r
1608 _keyEvent: function( keyEvent, event ) {
\r
1609 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
\r
1610 this._move( keyEvent, event );
\r
1612 // prevents moving cursor to beginning/end of the text field in some browsers
\r
1613 event.preventDefault();
\r
1618 $.extend( $.ui.autocomplete, {
\r
1619 escapeRegex: function( value ) {
\r
1620 return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
\r
1622 filter: function(array, term) {
\r
1623 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
\r
1624 return $.grep( array, function(value) {
\r
1625 return matcher.test( value.label || value.value || value );
\r
1631 // live region extension, adding a `messages` option
\r
1632 // NOTE: This is an experimental API. We are still investigating
\r
1633 // a full solution for string manipulation and internationalization.
\r
1634 $.widget( "ui.autocomplete", $.ui.autocomplete, {
\r
1637 noResults: "No search results.",
\r
1638 results: function( amount ) {
\r
1639 return amount + ( amount > 1 ? " results are" : " result is" ) +
\r
1640 " available, use up and down arrow keys to navigate.";
\r
1645 __response: function( content ) {
\r
1647 this._superApply( arguments );
\r
1648 if ( this.options.disabled || this.cancelSearch ) {
\r
1651 if ( content && content.length ) {
\r
1652 message = this.options.messages.results( content.length );
\r
1654 message = this.options.messages.noResults;
\r
1656 this.liveRegion.text( message );
\r
1663 System.out.println("coremenu failed to load jQuery.ui.autocomplete -- jQuery version conflict?");
\r