visualsearch-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +4 -0
  3. data/Changelog.md +4 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +5 -0
  6. data/Readme.md +24 -0
  7. data/app/assets/css/icons.css +19 -0
  8. data/app/assets/css/reset.css +30 -0
  9. data/app/assets/css/workspace.css +290 -0
  10. data/app/assets/images/cancel_search.png +0 -0
  11. data/app/assets/images/search_glyph.png +0 -0
  12. data/app/assets/javascripts/backbone-0.9.10.js +1498 -0
  13. data/app/assets/javascripts/dependencies.js +14843 -0
  14. data/app/assets/javascripts/jquery.ui.autocomplete.js +614 -0
  15. data/app/assets/javascripts/jquery.ui.core.js +324 -0
  16. data/app/assets/javascripts/jquery.ui.datepicker.js +5 -0
  17. data/app/assets/javascripts/jquery.ui.menu.js +621 -0
  18. data/app/assets/javascripts/jquery.ui.position.js +497 -0
  19. data/app/assets/javascripts/jquery.ui.widget.js +521 -0
  20. data/app/assets/javascripts/underscore-1.4.3.js +1221 -0
  21. data/app/assets/javascripts/visualsearch/js/models/search_facets.js +67 -0
  22. data/app/assets/javascripts/visualsearch/js/models/search_query.js +70 -0
  23. data/app/assets/javascripts/visualsearch/js/templates/search_box.jst +8 -0
  24. data/app/assets/javascripts/visualsearch/js/templates/search_facet.jst +9 -0
  25. data/app/assets/javascripts/visualsearch/js/templates/search_input.jst +1 -0
  26. data/app/assets/javascripts/visualsearch/js/templates/templates.js +7 -0
  27. data/app/assets/javascripts/visualsearch/js/utils/backbone_extensions.js +17 -0
  28. data/app/assets/javascripts/visualsearch/js/utils/hotkeys.js +99 -0
  29. data/app/assets/javascripts/visualsearch/js/utils/inflector.js +21 -0
  30. data/app/assets/javascripts/visualsearch/js/utils/jquery_extensions.js +197 -0
  31. data/app/assets/javascripts/visualsearch/js/utils/search_parser.js +87 -0
  32. data/app/assets/javascripts/visualsearch/js/views/search_box.js +447 -0
  33. data/app/assets/javascripts/visualsearch/js/views/search_facet.js +444 -0
  34. data/app/assets/javascripts/visualsearch/js/views/search_input.js +409 -0
  35. data/app/assets/javascripts/visualsearch/js/visualsearch.js +77 -0
  36. data/lib/generators/visual_search_install.rb +30 -0
  37. data/lib/visualsearch-rails.rb +2 -0
  38. data/lib/visualsearch/rails.rb +6 -0
  39. data/lib/visualsearch/version.rb +3 -0
  40. data/visualsearch-rails.gemspec +26 -0
  41. metadata +165 -0
@@ -0,0 +1,324 @@
1
+ /*!
2
+ * jQuery UI Core 1.10.0
3
+ * http://jqueryui.com
4
+ *
5
+ * Copyright 2013 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
7
+ * http://jquery.org/license
8
+ *
9
+ * http://api.jqueryui.com/category/ui-core/
10
+ */
11
+ (function( $, undefined ) {
12
+
13
+ var uuid = 0,
14
+ runiqueId = /^ui-id-\d+$/;
15
+
16
+ // prevent duplicate loading
17
+ // this is only a problem because we proxy existing functions
18
+ // and we don't want to double proxy them
19
+ $.ui = $.ui || {};
20
+ if ( $.ui.version ) {
21
+ return;
22
+ }
23
+
24
+ $.extend( $.ui, {
25
+ version: "1.10.0",
26
+
27
+ keyCode: {
28
+ BACKSPACE: 8,
29
+ COMMA: 188,
30
+ DELETE: 46,
31
+ DOWN: 40,
32
+ END: 35,
33
+ ENTER: 13,
34
+ ESCAPE: 27,
35
+ HOME: 36,
36
+ LEFT: 37,
37
+ NUMPAD_ADD: 107,
38
+ NUMPAD_DECIMAL: 110,
39
+ NUMPAD_DIVIDE: 111,
40
+ NUMPAD_ENTER: 108,
41
+ NUMPAD_MULTIPLY: 106,
42
+ NUMPAD_SUBTRACT: 109,
43
+ PAGE_DOWN: 34,
44
+ PAGE_UP: 33,
45
+ PERIOD: 190,
46
+ RIGHT: 39,
47
+ SPACE: 32,
48
+ TAB: 9,
49
+ UP: 38
50
+ }
51
+ });
52
+
53
+ // plugins
54
+ $.fn.extend({
55
+ _focus: $.fn.focus,
56
+ focus: function( delay, fn ) {
57
+ return typeof delay === "number" ?
58
+ this.each(function() {
59
+ var elem = this;
60
+ setTimeout(function() {
61
+ $( elem ).focus();
62
+ if ( fn ) {
63
+ fn.call( elem );
64
+ }
65
+ }, delay );
66
+ }) :
67
+ this._focus.apply( this, arguments );
68
+ },
69
+
70
+ scrollParent: function() {
71
+ var scrollParent;
72
+ if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
73
+ scrollParent = this.parents().filter(function() {
74
+ return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
75
+ }).eq(0);
76
+ } else {
77
+ scrollParent = this.parents().filter(function() {
78
+ return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
79
+ }).eq(0);
80
+ }
81
+
82
+ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
83
+ },
84
+
85
+ zIndex: function( zIndex ) {
86
+ if ( zIndex !== undefined ) {
87
+ return this.css( "zIndex", zIndex );
88
+ }
89
+
90
+ if ( this.length ) {
91
+ var elem = $( this[ 0 ] ), position, value;
92
+ while ( elem.length && elem[ 0 ] !== document ) {
93
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
94
+ // This makes behavior of this function consistent across browsers
95
+ // WebKit always returns auto if the element is positioned
96
+ position = elem.css( "position" );
97
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
98
+ // IE returns 0 when zIndex is not specified
99
+ // other browsers return a string
100
+ // we ignore the case of nested elements with an explicit value of 0
101
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
102
+ value = parseInt( elem.css( "zIndex" ), 10 );
103
+ if ( !isNaN( value ) && value !== 0 ) {
104
+ return value;
105
+ }
106
+ }
107
+ elem = elem.parent();
108
+ }
109
+ }
110
+
111
+ return 0;
112
+ },
113
+
114
+ uniqueId: function() {
115
+ return this.each(function() {
116
+ if ( !this.id ) {
117
+ this.id = "ui-id-" + (++uuid);
118
+ }
119
+ });
120
+ },
121
+
122
+ removeUniqueId: function() {
123
+ return this.each(function() {
124
+ if ( runiqueId.test( this.id ) ) {
125
+ $( this ).removeAttr( "id" );
126
+ }
127
+ });
128
+ }
129
+ });
130
+
131
+ // selectors
132
+ function focusable( element, isTabIndexNotNaN ) {
133
+ var map, mapName, img,
134
+ nodeName = element.nodeName.toLowerCase();
135
+ if ( "area" === nodeName ) {
136
+ map = element.parentNode;
137
+ mapName = map.name;
138
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
139
+ return false;
140
+ }
141
+ img = $( "img[usemap=#" + mapName + "]" )[0];
142
+ return !!img && visible( img );
143
+ }
144
+ return ( /input|select|textarea|button|object/.test( nodeName ) ?
145
+ !element.disabled :
146
+ "a" === nodeName ?
147
+ element.href || isTabIndexNotNaN :
148
+ isTabIndexNotNaN) &&
149
+ // the element and all of its ancestors must be visible
150
+ visible( element );
151
+ }
152
+
153
+ function visible( element ) {
154
+ return $.expr.filters.visible( element ) &&
155
+ !$( element ).parents().addBack().filter(function() {
156
+ return $.css( this, "visibility" ) === "hidden";
157
+ }).length;
158
+ }
159
+
160
+ $.extend( $.expr[ ":" ], {
161
+ data: $.expr.createPseudo ?
162
+ $.expr.createPseudo(function( dataName ) {
163
+ return function( elem ) {
164
+ return !!$.data( elem, dataName );
165
+ };
166
+ }) :
167
+ // support: jQuery <1.8
168
+ function( elem, i, match ) {
169
+ return !!$.data( elem, match[ 3 ] );
170
+ },
171
+
172
+ focusable: function( element ) {
173
+ return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
174
+ },
175
+
176
+ tabbable: function( element ) {
177
+ var tabIndex = $.attr( element, "tabindex" ),
178
+ isTabIndexNaN = isNaN( tabIndex );
179
+ return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
180
+ }
181
+ });
182
+
183
+ // support: jQuery <1.8
184
+ if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
185
+ $.each( [ "Width", "Height" ], function( i, name ) {
186
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
187
+ type = name.toLowerCase(),
188
+ orig = {
189
+ innerWidth: $.fn.innerWidth,
190
+ innerHeight: $.fn.innerHeight,
191
+ outerWidth: $.fn.outerWidth,
192
+ outerHeight: $.fn.outerHeight
193
+ };
194
+
195
+ function reduce( elem, size, border, margin ) {
196
+ $.each( side, function() {
197
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
198
+ if ( border ) {
199
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
200
+ }
201
+ if ( margin ) {
202
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
203
+ }
204
+ });
205
+ return size;
206
+ }
207
+
208
+ $.fn[ "inner" + name ] = function( size ) {
209
+ if ( size === undefined ) {
210
+ return orig[ "inner" + name ].call( this );
211
+ }
212
+
213
+ return this.each(function() {
214
+ $( this ).css( type, reduce( this, size ) + "px" );
215
+ });
216
+ };
217
+
218
+ $.fn[ "outer" + name] = function( size, margin ) {
219
+ if ( typeof size !== "number" ) {
220
+ return orig[ "outer" + name ].call( this, size );
221
+ }
222
+
223
+ return this.each(function() {
224
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
225
+ });
226
+ };
227
+ });
228
+ }
229
+
230
+ // support: jQuery <1.8
231
+ if ( !$.fn.addBack ) {
232
+ $.fn.addBack = function( selector ) {
233
+ return this.add( selector == null ?
234
+ this.prevObject : this.prevObject.filter( selector )
235
+ );
236
+ };
237
+ }
238
+
239
+ // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
240
+ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
241
+ $.fn.removeData = (function( removeData ) {
242
+ return function( key ) {
243
+ if ( arguments.length ) {
244
+ return removeData.call( this, $.camelCase( key ) );
245
+ } else {
246
+ return removeData.call( this );
247
+ }
248
+ };
249
+ })( $.fn.removeData );
250
+ }
251
+
252
+
253
+
254
+
255
+
256
+ // deprecated
257
+ $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
258
+
259
+ $.support.selectstart = "onselectstart" in document.createElement( "div" );
260
+ $.fn.extend({
261
+ disableSelection: function() {
262
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
263
+ ".ui-disableSelection", function( event ) {
264
+ event.preventDefault();
265
+ });
266
+ },
267
+
268
+ enableSelection: function() {
269
+ return this.unbind( ".ui-disableSelection" );
270
+ }
271
+ });
272
+
273
+ $.extend( $.ui, {
274
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
275
+ plugin: {
276
+ add: function( module, option, set ) {
277
+ var i,
278
+ proto = $.ui[ module ].prototype;
279
+ for ( i in set ) {
280
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
281
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
282
+ }
283
+ },
284
+ call: function( instance, name, args ) {
285
+ var i,
286
+ set = instance.plugins[ name ];
287
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
288
+ return;
289
+ }
290
+
291
+ for ( i = 0; i < set.length; i++ ) {
292
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
293
+ set[ i ][ 1 ].apply( instance.element, args );
294
+ }
295
+ }
296
+ }
297
+ },
298
+
299
+ // only used by resizable
300
+ hasScroll: function( el, a ) {
301
+
302
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
303
+ if ( $( el ).css( "overflow" ) === "hidden") {
304
+ return false;
305
+ }
306
+
307
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
308
+ has = false;
309
+
310
+ if ( el[ scroll ] > 0 ) {
311
+ return true;
312
+ }
313
+
314
+ // TODO: determine which cases actually cause this to happen
315
+ // if the element doesn't have the scroll set, see if it's possible to
316
+ // set the scroll
317
+ el[ scroll ] = 1;
318
+ has = ( el[ scroll ] > 0 );
319
+ el[ scroll ] = 0;
320
+ return has;
321
+ }
322
+ });
323
+
324
+ })( jQuery );
@@ -0,0 +1,5 @@
1
+ /*! jQuery UI - v1.10.3 - 2013-06-12
2
+ * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
4
+ (function(t,e){function i(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},t.extend(this._defaults,this.regional[""]),this.dpDiv=s(t("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function s(e){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.delegate(i,"mouseout",function(){t(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",function(){t.datepicker._isDisabledDatepicker(a.inline?e.parent()[0]:a.input[0])||(t(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),t(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).addClass("ui-datepicker-next-hover"))})}function n(e,i){t.extend(e,i);for(var s in i)null==i[s]&&(e[s]=i[s]);return e}t.extend(t.ui,{datepicker:{version:"1.10.3"}});var a,r="datepicker";t.extend(i.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(t){return n(this._defaults,t||{}),this},_attachDatepicker:function(e,i){var s,n,a;s=e.nodeName.toLowerCase(),n="div"===s||"span"===s,e.id||(this.uuid+=1,e.id="dp"+this.uuid),a=this._newInst(t(e),n),a.settings=t.extend({},i||{}),"input"===s?this._connectDatepicker(e,a):n&&this._inlineDatepicker(e,a)},_newInst:function(e,i){var n=e[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1");return{id:n,input:e,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:i,dpDiv:i?s(t("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(e,i){var s=t(e);i.append=t([]),i.trigger=t([]),s.hasClass(this.markerClassName)||(this._attachments(s,i),s.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp),this._autoSize(i),t.data(e,r,i),i.settings.disabled&&this._disableDatepicker(e))},_attachments:function(e,i){var s,n,a,r=this._get(i,"appendText"),o=this._get(i,"isRTL");i.append&&i.append.remove(),r&&(i.append=t("<span class='"+this._appendClass+"'>"+r+"</span>"),e[o?"before":"after"](i.append)),e.unbind("focus",this._showDatepicker),i.trigger&&i.trigger.remove(),s=this._get(i,"showOn"),("focus"===s||"both"===s)&&e.focus(this._showDatepicker),("button"===s||"both"===s)&&(n=this._get(i,"buttonText"),a=this._get(i,"buttonImage"),i.trigger=t(this._get(i,"buttonImageOnly")?t("<img/>").addClass(this._triggerClass).attr({src:a,alt:n,title:n}):t("<button type='button'></button>").addClass(this._triggerClass).html(a?t("<img/>").attr({src:a,alt:n,title:n}):n)),e[o?"before":"after"](i.trigger),i.trigger.click(function(){return t.datepicker._datepickerShowing&&t.datepicker._lastInput===e[0]?t.datepicker._hideDatepicker():t.datepicker._datepickerShowing&&t.datepicker._lastInput!==e[0]?(t.datepicker._hideDatepicker(),t.datepicker._showDatepicker(e[0])):t.datepicker._showDatepicker(e[0]),!1}))},_autoSize:function(t){if(this._get(t,"autoSize")&&!t.inline){var e,i,s,n,a=new Date(2009,11,20),r=this._get(t,"dateFormat");r.match(/[DM]/)&&(e=function(t){for(i=0,s=0,n=0;t.length>n;n++)t[n].length>i&&(i=t[n].length,s=n);return s},a.setMonth(e(this._get(t,r.match(/MM/)?"monthNames":"monthNamesShort"))),a.setDate(e(this._get(t,r.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())),t.input.attr("size",this._formatDate(t,a).length)}},_inlineDatepicker:function(e,i){var s=t(e);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),t.data(e,r,i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(e),i.dpDiv.css("display","block"))},_dialogDatepicker:function(e,i,s,a,o){var h,l,c,u,d,p=this._dialogInst;return p||(this.uuid+=1,h="dp"+this.uuid,this._dialogInput=t("<input type='text' id='"+h+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.keydown(this._doKeyDown),t("body").append(this._dialogInput),p=this._dialogInst=this._newInst(this._dialogInput,!1),p.settings={},t.data(this._dialogInput[0],r,p)),n(p.settings,a||{}),i=i&&i.constructor===Date?this._formatDate(p,i):i,this._dialogInput.val(i),this._pos=o?o.length?o:[o.pageX,o.pageY]:null,this._pos||(l=document.documentElement.clientWidth,c=document.documentElement.clientHeight,u=document.documentElement.scrollLeft||document.body.scrollLeft,d=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[l/2-100+u,c/2-150+d]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),p.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),t.blockUI&&t.blockUI(this.dpDiv),t.data(this._dialogInput[0],r,p),this},_destroyDatepicker:function(e){var i,s=t(e),n=t.data(e,r);s.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),t.removeData(e,r),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty())},_enableDatepicker:function(e){var i,s,n=t(e),a=t.data(e,r);n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!1,a.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}))},_disableDatepicker:function(e){var i,s,n=t(e),a=t.data(e,r);n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!0,a.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}),this._disabledInputs[this._disabledInputs.length]=e)},_isDisabledDatepicker:function(t){if(!t)return!1;for(var e=0;this._disabledInputs.length>e;e++)if(this._disabledInputs[e]===t)return!0;return!1},_getInst:function(e){try{return t.data(e,r)}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(i,s,a){var r,o,h,l,c=this._getInst(i);return 2===arguments.length&&"string"==typeof s?"defaults"===s?t.extend({},t.datepicker._defaults):c?"all"===s?t.extend({},c.settings):this._get(c,s):null:(r=s||{},"string"==typeof s&&(r={},r[s]=a),c&&(this._curInst===c&&this._hideDatepicker(),o=this._getDateDatepicker(i,!0),h=this._getMinMaxDate(c,"min"),l=this._getMinMaxDate(c,"max"),n(c.settings,r),null!==h&&r.dateFormat!==e&&r.minDate===e&&(c.settings.minDate=this._formatDate(c,h)),null!==l&&r.dateFormat!==e&&r.maxDate===e&&(c.settings.maxDate=this._formatDate(c,l)),"disabled"in r&&(r.disabled?this._disableDatepicker(i):this._enableDatepicker(i)),this._attachments(t(i),c),this._autoSize(c),this._setDate(c,o),this._updateAlternate(c),this._updateDatepicker(c)),e)},_changeDatepicker:function(t,e,i){this._optionDatepicker(t,e,i)},_refreshDatepicker:function(t){var e=this._getInst(t);e&&this._updateDatepicker(e)},_setDateDatepicker:function(t,e){var i=this._getInst(t);i&&(this._setDate(i,e),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(t,e){var i=this._getInst(t);return i&&!i.inline&&this._setDateFromField(i,e),i?this._getDate(i):null},_doKeyDown:function(e){var i,s,n,a=t.datepicker._getInst(e.target),r=!0,o=a.dpDiv.is(".ui-datepicker-rtl");if(a._keyEvent=!0,t.datepicker._datepickerShowing)switch(e.keyCode){case 9:t.datepicker._hideDatepicker(),r=!1;break;case 13:return n=t("td."+t.datepicker._dayOverClass+":not(."+t.datepicker._currentClass+")",a.dpDiv),n[0]&&t.datepicker._selectDay(e.target,a.selectedMonth,a.selectedYear,n[0]),i=t.datepicker._get(a,"onSelect"),i?(s=t.datepicker._formatDate(a),i.apply(a.input?a.input[0]:null,[s,a])):t.datepicker._hideDatepicker(),!1;case 27:t.datepicker._hideDatepicker();break;case 33:t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(a,"stepBigMonths"):-t.datepicker._get(a,"stepMonths"),"M");break;case 34:t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(a,"stepBigMonths"):+t.datepicker._get(a,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&t.datepicker._clearDate(e.target),r=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&t.datepicker._gotoToday(e.target),r=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,o?1:-1,"D"),r=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(a,"stepBigMonths"):-t.datepicker._get(a,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,-7,"D"),r=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,o?-1:1,"D"),r=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(a,"stepBigMonths"):+t.datepicker._get(a,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,7,"D"),r=e.ctrlKey||e.metaKey;break;default:r=!1}else 36===e.keyCode&&e.ctrlKey?t.datepicker._showDatepicker(this):r=!1;r&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(i){var s,n,a=t.datepicker._getInst(i.target);return t.datepicker._get(a,"constrainInput")?(s=t.datepicker._possibleChars(t.datepicker._get(a,"dateFormat")),n=String.fromCharCode(null==i.charCode?i.keyCode:i.charCode),i.ctrlKey||i.metaKey||" ">n||!s||s.indexOf(n)>-1):e},_doKeyUp:function(e){var i,s=t.datepicker._getInst(e.target);if(s.input.val()!==s.lastVal)try{i=t.datepicker.parseDate(t.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,t.datepicker._getFormatConfig(s)),i&&(t.datepicker._setDateFromField(s),t.datepicker._updateAlternate(s),t.datepicker._updateDatepicker(s))}catch(n){}return!0},_showDatepicker:function(e){if(e=e.target||e,"input"!==e.nodeName.toLowerCase()&&(e=t("input",e.parentNode)[0]),!t.datepicker._isDisabledDatepicker(e)&&t.datepicker._lastInput!==e){var i,s,a,r,o,h,l;i=t.datepicker._getInst(e),t.datepicker._curInst&&t.datepicker._curInst!==i&&(t.datepicker._curInst.dpDiv.stop(!0,!0),i&&t.datepicker._datepickerShowing&&t.datepicker._hideDatepicker(t.datepicker._curInst.input[0])),s=t.datepicker._get(i,"beforeShow"),a=s?s.apply(e,[e,i]):{},a!==!1&&(n(i.settings,a),i.lastVal=null,t.datepicker._lastInput=e,t.datepicker._setDateFromField(i),t.datepicker._inDialog&&(e.value=""),t.datepicker._pos||(t.datepicker._pos=t.datepicker._findPos(e),t.datepicker._pos[1]+=e.offsetHeight),r=!1,t(e).parents().each(function(){return r|="fixed"===t(this).css("position"),!r}),o={left:t.datepicker._pos[0],top:t.datepicker._pos[1]},t.datepicker._pos=null,i.dpDiv.empty(),i.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),t.datepicker._updateDatepicker(i),o=t.datepicker._checkOffset(i,o,r),i.dpDiv.css({position:t.datepicker._inDialog&&t.blockUI?"static":r?"fixed":"absolute",display:"none",left:o.left+"px",top:o.top+"px"}),i.inline||(h=t.datepicker._get(i,"showAnim"),l=t.datepicker._get(i,"duration"),i.dpDiv.zIndex(t(e).zIndex()+1),t.datepicker._datepickerShowing=!0,t.effects&&t.effects.effect[h]?i.dpDiv.show(h,t.datepicker._get(i,"showOptions"),l):i.dpDiv[h||"show"](h?l:null),t.datepicker._shouldFocusInput(i)&&i.input.focus(),t.datepicker._curInst=i))}},_updateDatepicker:function(e){this.maxRows=4,a=e,e.dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e),e.dpDiv.find("."+this._dayOverClass+" a").mouseover();var i,s=this._getNumberOfMonths(e),n=s[1],r=17;e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&e.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",r*n+"em"),e.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e===t.datepicker._curInst&&t.datepicker._datepickerShowing&&t.datepicker._shouldFocusInput(e)&&e.input.focus(),e.yearshtml&&(i=e.yearshtml,setTimeout(function(){i===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml),i=e.yearshtml=null},0))},_shouldFocusInput:function(t){return t.input&&t.input.is(":visible")&&!t.input.is(":disabled")&&!t.input.is(":focus")},_checkOffset:function(e,i,s){var n=e.dpDiv.outerWidth(),a=e.dpDiv.outerHeight(),r=e.input?e.input.outerWidth():0,o=e.input?e.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:t(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:t(document).scrollTop());return i.left-=this._get(e,"isRTL")?n-r:0,i.left-=s&&i.left===e.input.offset().left?t(document).scrollLeft():0,i.top-=s&&i.top===e.input.offset().top+o?t(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+a>l&&l>a?Math.abs(a+o):0),i},_findPos:function(e){for(var i,s=this._getInst(e),n=this._get(s,"isRTL");e&&("hidden"===e.type||1!==e.nodeType||t.expr.filters.hidden(e));)e=e[n?"previousSibling":"nextSibling"];return i=t(e).offset(),[i.left,i.top]},_hideDatepicker:function(e){var i,s,n,a,o=this._curInst;!o||e&&o!==t.data(e,r)||this._datepickerShowing&&(i=this._get(o,"showAnim"),s=this._get(o,"duration"),n=function(){t.datepicker._tidyDialog(o)},t.effects&&(t.effects.effect[i]||t.effects[i])?o.dpDiv.hide(i,t.datepicker._get(o,"showOptions"),s,n):o.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,a=this._get(o,"onClose"),a&&a.apply(o.input?o.input[0]:null,[o.input?o.input.val():"",o]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),t.blockUI&&(t.unblockUI(),t("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(t){t.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(e){if(t.datepicker._curInst){var i=t(e.target),s=t.datepicker._getInst(i[0]);(i[0].id!==t.datepicker._mainDivId&&0===i.parents("#"+t.datepicker._mainDivId).length&&!i.hasClass(t.datepicker.markerClassName)&&!i.closest("."+t.datepicker._triggerClass).length&&t.datepicker._datepickerShowing&&(!t.datepicker._inDialog||!t.blockUI)||i.hasClass(t.datepicker.markerClassName)&&t.datepicker._curInst!==s)&&t.datepicker._hideDatepicker()}},_adjustDate:function(e,i,s){var n=t(e),a=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(a,i+("M"===s?this._get(a,"showCurrentAtPos"):0),s),this._updateDatepicker(a))},_gotoToday:function(e){var i,s=t(e),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(e,i,s){var n=t(e),a=this._getInst(n[0]);a["selected"+("M"===s?"Month":"Year")]=a["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(a),this._adjustDate(n)},_selectDay:function(e,i,s,n){var a,r=t(e);t(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(r[0])||(a=this._getInst(r[0]),a.selectedDay=a.currentDay=t("a",n).html(),a.selectedMonth=a.currentMonth=i,a.selectedYear=a.currentYear=s,this._selectDate(e,this._formatDate(a,a.currentDay,a.currentMonth,a.currentYear)))},_clearDate:function(e){var i=t(e);this._selectDate(i,"")},_selectDate:function(e,i){var s,n=t(e),a=this._getInst(n[0]);i=null!=i?i:this._formatDate(a),a.input&&a.input.val(i),this._updateAlternate(a),s=this._get(a,"onSelect"),s?s.apply(a.input?a.input[0]:null,[i,a]):a.input&&a.input.trigger("change"),a.inline?this._updateDatepicker(a):(this._hideDatepicker(),this._lastInput=a.input[0],"object"!=typeof a.input[0]&&a.input.focus(),this._lastInput=null)},_updateAlternate:function(e){var i,s,n,a=this._get(e,"altField");a&&(i=this._get(e,"altFormat")||this._get(e,"dateFormat"),s=this._getDate(e),n=this.formatDate(i,s,this._getFormatConfig(e)),t(a).each(function(){t(this).val(n)}))},noWeekends:function(t){var e=t.getDay();return[e>0&&6>e,""]},iso8601Week:function(t){var e,i=new Date(t.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),e=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((e-i)/864e5)/7)+1},parseDate:function(i,s,n){if(null==i||null==s)throw"Invalid arguments";if(s="object"==typeof s?""+s:s+"",""===s)return null;var a,r,o,h,l=0,c=(n?n.shortYearCutoff:null)||this._defaults.shortYearCutoff,u="string"!=typeof c?c:(new Date).getFullYear()%100+parseInt(c,10),d=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,p=(n?n.dayNames:null)||this._defaults.dayNames,f=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,m=(n?n.monthNames:null)||this._defaults.monthNames,g=-1,v=-1,_=-1,b=-1,y=!1,x=function(t){var e=i.length>a+1&&i.charAt(a+1)===t;return e&&a++,e},k=function(t){var e=x(t),i="@"===t?14:"!"===t?20:"y"===t&&e?4:"o"===t?3:2,n=RegExp("^\\d{1,"+i+"}"),a=s.substring(l).match(n);if(!a)throw"Missing number at position "+l;return l+=a[0].length,parseInt(a[0],10)},w=function(i,n,a){var r=-1,o=t.map(x(i)?a:n,function(t,e){return[[e,t]]}).sort(function(t,e){return-(t[1].length-e[1].length)});if(t.each(o,function(t,i){var n=i[1];return s.substr(l,n.length).toLowerCase()===n.toLowerCase()?(r=i[0],l+=n.length,!1):e}),-1!==r)return r+1;throw"Unknown name at position "+l},D=function(){if(s.charAt(l)!==i.charAt(a))throw"Unexpected literal at position "+l;l++};for(a=0;i.length>a;a++)if(y)"'"!==i.charAt(a)||x("'")?D():y=!1;else switch(i.charAt(a)){case"d":_=k("d");break;case"D":w("D",d,p);break;case"o":b=k("o");break;case"m":v=k("m");break;case"M":v=w("M",f,m);break;case"y":g=k("y");break;case"@":h=new Date(k("@")),g=h.getFullYear(),v=h.getMonth()+1,_=h.getDate();break;case"!":h=new Date((k("!")-this._ticksTo1970)/1e4),g=h.getFullYear(),v=h.getMonth()+1,_=h.getDate();break;case"'":x("'")?D():y=!0;break;default:D()}if(s.length>l&&(o=s.substr(l),!/^\s+/.test(o)))throw"Extra/unparsed characters found in date: "+o;if(-1===g?g=(new Date).getFullYear():100>g&&(g+=(new Date).getFullYear()-(new Date).getFullYear()%100+(u>=g?0:-100)),b>-1)for(v=1,_=b;;){if(r=this._getDaysInMonth(g,v-1),r>=_)break;v++,_-=r}if(h=this._daylightSavingAdjust(new Date(g,v-1,_)),h.getFullYear()!==g||h.getMonth()+1!==v||h.getDate()!==_)throw"Invalid date";return h},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(t,e,i){if(!e)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,a=(i?i.dayNames:null)||this._defaults.dayNames,r=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,o=(i?i.monthNames:null)||this._defaults.monthNames,h=function(e){var i=t.length>s+1&&t.charAt(s+1)===e;return i&&s++,i},l=function(t,e,i){var s=""+e;if(h(t))for(;i>s.length;)s="0"+s;return s},c=function(t,e,i,s){return h(t)?s[e]:i[e]},u="",d=!1;if(e)for(s=0;t.length>s;s++)if(d)"'"!==t.charAt(s)||h("'")?u+=t.charAt(s):d=!1;else switch(t.charAt(s)){case"d":u+=l("d",e.getDate(),2);break;case"D":u+=c("D",e.getDay(),n,a);break;case"o":u+=l("o",Math.round((new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-new Date(e.getFullYear(),0,0).getTime())/864e5),3);break;case"m":u+=l("m",e.getMonth()+1,2);break;case"M":u+=c("M",e.getMonth(),r,o);break;case"y":u+=h("y")?e.getFullYear():(10>e.getYear()%100?"0":"")+e.getYear()%100;break;case"@":u+=e.getTime();break;case"!":u+=1e4*e.getTime()+this._ticksTo1970;break;case"'":h("'")?u+="'":d=!0;break;default:u+=t.charAt(s)}return u},_possibleChars:function(t){var e,i="",s=!1,n=function(i){var s=t.length>e+1&&t.charAt(e+1)===i;return s&&e++,s};for(e=0;t.length>e;e++)if(s)"'"!==t.charAt(e)||n("'")?i+=t.charAt(e):s=!1;else switch(t.charAt(e)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=t.charAt(e)}return i},_get:function(t,i){return t.settings[i]!==e?t.settings[i]:this._defaults[i]},_setDateFromField:function(t,e){if(t.input.val()!==t.lastVal){var i=this._get(t,"dateFormat"),s=t.lastVal=t.input?t.input.val():null,n=this._getDefaultDate(t),a=n,r=this._getFormatConfig(t);try{a=this.parseDate(i,s,r)||n}catch(o){s=e?"":s}t.selectedDay=a.getDate(),t.drawMonth=t.selectedMonth=a.getMonth(),t.drawYear=t.selectedYear=a.getFullYear(),t.currentDay=s?a.getDate():0,t.currentMonth=s?a.getMonth():0,t.currentYear=s?a.getFullYear():0,this._adjustInstDate(t)}},_getDefaultDate:function(t){return this._restrictMinMax(t,this._determineDate(t,this._get(t,"defaultDate"),new Date))},_determineDate:function(e,i,s){var n=function(t){var e=new Date;return e.setDate(e.getDate()+t),e},a=function(i){try{return t.datepicker.parseDate(t.datepicker._get(e,"dateFormat"),i,t.datepicker._getFormatConfig(e))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?t.datepicker._getDate(e):null)||new Date,a=n.getFullYear(),r=n.getMonth(),o=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":o+=parseInt(l[1],10);break;case"w":case"W":o+=7*parseInt(l[1],10);break;case"m":case"M":r+=parseInt(l[1],10),o=Math.min(o,t.datepicker._getDaysInMonth(a,r));break;case"y":case"Y":a+=parseInt(l[1],10),o=Math.min(o,t.datepicker._getDaysInMonth(a,r))}l=h.exec(i)}return new Date(a,r,o)},r=null==i||""===i?s:"string"==typeof i?a(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return r=r&&"Invalid Date"==""+r?s:r,r&&(r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0)),this._daylightSavingAdjust(r)},_daylightSavingAdjust:function(t){return t?(t.setHours(t.getHours()>12?t.getHours()+2:0),t):null},_setDate:function(t,e,i){var s=!e,n=t.selectedMonth,a=t.selectedYear,r=this._restrictMinMax(t,this._determineDate(t,e,new Date));t.selectedDay=t.currentDay=r.getDate(),t.drawMonth=t.selectedMonth=t.currentMonth=r.getMonth(),t.drawYear=t.selectedYear=t.currentYear=r.getFullYear(),n===t.selectedMonth&&a===t.selectedYear||i||this._notifyChange(t),this._adjustInstDate(t),t.input&&t.input.val(s?"":this._formatDate(t))},_getDate:function(t){var e=!t.currentYear||t.input&&""===t.input.val()?null:this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return e},_attachHandlers:function(e){var i=this._get(e,"stepMonths"),s="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){t.datepicker._adjustDate(s,-i,"M")},next:function(){t.datepicker._adjustDate(s,+i,"M")},hide:function(){t.datepicker._hideDatepicker()},today:function(){t.datepicker._gotoToday(s)},selectDay:function(){return t.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return t.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return t.datepicker._selectMonthYear(s,this,"Y"),!1}};t(this).bind(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(t){var e,i,s,n,a,r,o,h,l,c,u,d,p,f,m,g,v,_,b,y,x,k,w,D,T,C,M,S,N,I,P,A,z,H,E,F,O,W,j,R=new Date,L=this._daylightSavingAdjust(new Date(R.getFullYear(),R.getMonth(),R.getDate())),Y=this._get(t,"isRTL"),B=this._get(t,"showButtonPanel"),J=this._get(t,"hideIfNoPrevNext"),K=this._get(t,"navigationAsDateFormat"),Q=this._getNumberOfMonths(t),V=this._get(t,"showCurrentAtPos"),U=this._get(t,"stepMonths"),q=1!==Q[0]||1!==Q[1],X=this._daylightSavingAdjust(t.currentDay?new Date(t.currentYear,t.currentMonth,t.currentDay):new Date(9999,9,9)),G=this._getMinMaxDate(t,"min"),$=this._getMinMaxDate(t,"max"),Z=t.drawMonth-V,te=t.drawYear;if(0>Z&&(Z+=12,te--),$)for(e=this._daylightSavingAdjust(new Date($.getFullYear(),$.getMonth()-Q[0]*Q[1]+1,$.getDate())),e=G&&G>e?G:e;this._daylightSavingAdjust(new Date(te,Z,1))>e;)Z--,0>Z&&(Z=11,te--);for(t.drawMonth=Z,t.drawYear=te,i=this._get(t,"prevText"),i=K?this.formatDate(i,this._daylightSavingAdjust(new Date(te,Z-U,1)),this._getFormatConfig(t)):i,s=this._canAdjustMonth(t,-1,te,Z)?"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>":J?"":"<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>",n=this._get(t,"nextText"),n=K?this.formatDate(n,this._daylightSavingAdjust(new Date(te,Z+U,1)),this._getFormatConfig(t)):n,a=this._canAdjustMonth(t,1,te,Z)?"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>":J?"":"<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>",r=this._get(t,"currentText"),o=this._get(t,"gotoCurrent")&&t.currentDay?X:L,r=K?this.formatDate(r,o,this._getFormatConfig(t)):r,h=t.inline?"":"<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>"+this._get(t,"closeText")+"</button>",l=B?"<div class='ui-datepicker-buttonpane ui-widget-content'>"+(Y?h:"")+(this._isInRange(t,o)?"<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'>"+r+"</button>":"")+(Y?"":h)+"</div>":"",c=parseInt(this._get(t,"firstDay"),10),c=isNaN(c)?0:c,u=this._get(t,"showWeek"),d=this._get(t,"dayNames"),p=this._get(t,"dayNamesMin"),f=this._get(t,"monthNames"),m=this._get(t,"monthNamesShort"),g=this._get(t,"beforeShowDay"),v=this._get(t,"showOtherMonths"),_=this._get(t,"selectOtherMonths"),b=this._getDefaultDate(t),y="",k=0;Q[0]>k;k++){for(w="",this.maxRows=4,D=0;Q[1]>D;D++){if(T=this._daylightSavingAdjust(new Date(te,Z,t.selectedDay)),C=" ui-corner-all",M="",q){if(M+="<div class='ui-datepicker-group",Q[1]>1)switch(D){case 0:M+=" ui-datepicker-group-first",C=" ui-corner-"+(Y?"right":"left");break;case Q[1]-1:M+=" ui-datepicker-group-last",C=" ui-corner-"+(Y?"left":"right");break;default:M+=" ui-datepicker-group-middle",C=""}M+="'>"}for(M+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+C+"'>"+(/all|left/.test(C)&&0===k?Y?a:s:"")+(/all|right/.test(C)&&0===k?Y?s:a:"")+this._generateMonthYearHeader(t,Z,te,G,$,k>0||D>0,f,m)+"</div><table class='ui-datepicker-calendar'><thead>"+"<tr>",S=u?"<th class='ui-datepicker-week-col'>"+this._get(t,"weekHeader")+"</th>":"",x=0;7>x;x++)N=(x+c)%7,S+="<th"+((x+c+6)%7>=5?" class='ui-datepicker-week-end'":"")+">"+"<span title='"+d[N]+"'>"+p[N]+"</span></th>";for(M+=S+"</tr></thead><tbody>",I=this._getDaysInMonth(te,Z),te===t.selectedYear&&Z===t.selectedMonth&&(t.selectedDay=Math.min(t.selectedDay,I)),P=(this._getFirstDayOfMonth(te,Z)-c+7)%7,A=Math.ceil((P+I)/7),z=q?this.maxRows>A?this.maxRows:A:A,this.maxRows=z,H=this._daylightSavingAdjust(new Date(te,Z,1-P)),E=0;z>E;E++){for(M+="<tr>",F=u?"<td class='ui-datepicker-week-col'>"+this._get(t,"calculateWeek")(H)+"</td>":"",x=0;7>x;x++)O=g?g.apply(t.input?t.input[0]:null,[H]):[!0,""],W=H.getMonth()!==Z,j=W&&!_||!O[0]||G&&G>H||$&&H>$,F+="<td class='"+((x+c+6)%7>=5?" ui-datepicker-week-end":"")+(W?" ui-datepicker-other-month":"")+(H.getTime()===T.getTime()&&Z===t.selectedMonth&&t._keyEvent||b.getTime()===H.getTime()&&b.getTime()===T.getTime()?" "+this._dayOverClass:"")+(j?" "+this._unselectableClass+" ui-state-disabled":"")+(W&&!v?"":" "+O[1]+(H.getTime()===X.getTime()?" "+this._currentClass:"")+(H.getTime()===L.getTime()?" ui-datepicker-today":""))+"'"+(W&&!v||!O[2]?"":" title='"+O[2].replace(/'/g,"&#39;")+"'")+(j?"":" data-handler='selectDay' data-event='click' data-month='"+H.getMonth()+"' data-year='"+H.getFullYear()+"'")+">"+(W&&!v?"&#xa0;":j?"<span class='ui-state-default'>"+H.getDate()+"</span>":"<a class='ui-state-default"+(H.getTime()===L.getTime()?" ui-state-highlight":"")+(H.getTime()===X.getTime()?" ui-state-active":"")+(W?" ui-priority-secondary":"")+"' href='#'>"+H.getDate()+"</a>")+"</td>",H.setDate(H.getDate()+1),H=this._daylightSavingAdjust(H);M+=F+"</tr>"}Z++,Z>11&&(Z=0,te++),M+="</tbody></table>"+(q?"</div>"+(Q[0]>0&&D===Q[1]-1?"<div class='ui-datepicker-row-break'></div>":""):""),w+=M}y+=w}return y+=l,t._keyEvent=!1,y},_generateMonthYearHeader:function(t,e,i,s,n,a,r,o){var h,l,c,u,d,p,f,m,g=this._get(t,"changeMonth"),v=this._get(t,"changeYear"),_=this._get(t,"showMonthAfterYear"),b="<div class='ui-datepicker-title'>",y="";if(a||!g)y+="<span class='ui-datepicker-month'>"+r[e]+"</span>";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,y+="<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>",c=0;12>c;c++)(!h||c>=s.getMonth())&&(!l||n.getMonth()>=c)&&(y+="<option value='"+c+"'"+(c===e?" selected='selected'":"")+">"+o[c]+"</option>");y+="</select>"}if(_||(b+=y+(!a&&g&&v?"":"&#xa0;")),!t.yearshtml)if(t.yearshtml="",a||!v)b+="<span class='ui-datepicker-year'>"+i+"</span>";else{for(u=this._get(t,"yearRange").split(":"),d=(new Date).getFullYear(),p=function(t){var e=t.match(/c[+\-].*/)?i+parseInt(t.substring(1),10):t.match(/[+\-].*/)?d+parseInt(t,10):parseInt(t,10);
5
+ return isNaN(e)?d:e},f=p(u[0]),m=Math.max(f,p(u[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=n?Math.min(m,n.getFullYear()):m,t.yearshtml+="<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";m>=f;f++)t.yearshtml+="<option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+f+"</option>";t.yearshtml+="</select>",b+=t.yearshtml,t.yearshtml=null}return b+=this._get(t,"yearSuffix"),_&&(b+=(!a&&g&&v?"":"&#xa0;")+y),b+="</div>"},_adjustInstDate:function(t,e,i){var s=t.drawYear+("Y"===i?e:0),n=t.drawMonth+("M"===i?e:0),a=Math.min(t.selectedDay,this._getDaysInMonth(s,n))+("D"===i?e:0),r=this._restrictMinMax(t,this._daylightSavingAdjust(new Date(s,n,a)));t.selectedDay=r.getDate(),t.drawMonth=t.selectedMonth=r.getMonth(),t.drawYear=t.selectedYear=r.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(t)},_restrictMinMax:function(t,e){var i=this._getMinMaxDate(t,"min"),s=this._getMinMaxDate(t,"max"),n=i&&i>e?i:e;return s&&n>s?s:n},_notifyChange:function(t){var e=this._get(t,"onChangeMonthYear");e&&e.apply(t.input?t.input[0]:null,[t.selectedYear,t.selectedMonth+1,t])},_getNumberOfMonths:function(t){var e=this._get(t,"numberOfMonths");return null==e?[1,1]:"number"==typeof e?[1,e]:e},_getMinMaxDate:function(t,e){return this._determineDate(t,this._get(t,e+"Date"),null)},_getDaysInMonth:function(t,e){return 32-this._daylightSavingAdjust(new Date(t,e,32)).getDate()},_getFirstDayOfMonth:function(t,e){return new Date(t,e,1).getDay()},_canAdjustMonth:function(t,e,i,s){var n=this._getNumberOfMonths(t),a=this._daylightSavingAdjust(new Date(i,s+(0>e?e:n[0]*n[1]),1));return 0>e&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(t,a)},_isInRange:function(t,e){var i,s,n=this._getMinMaxDate(t,"min"),a=this._getMinMaxDate(t,"max"),r=null,o=null,h=this._get(t,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),r=parseInt(i[0],10),o=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(r+=s),i[1].match(/[+\-].*/)&&(o+=s)),(!n||e.getTime()>=n.getTime())&&(!a||e.getTime()<=a.getTime())&&(!r||e.getFullYear()>=r)&&(!o||o>=e.getFullYear())},_getFormatConfig:function(t){var e=this._get(t,"shortYearCutoff");return e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),{shortYearCutoff:e,dayNamesShort:this._get(t,"dayNamesShort"),dayNames:this._get(t,"dayNames"),monthNamesShort:this._get(t,"monthNamesShort"),monthNames:this._get(t,"monthNames")}},_formatDate:function(t,e,i,s){e||(t.currentDay=t.selectedDay,t.currentMonth=t.selectedMonth,t.currentYear=t.selectedYear);var n=e?"object"==typeof e?e:this._daylightSavingAdjust(new Date(s,i,e)):this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return this.formatDate(this._get(t,"dateFormat"),n,this._getFormatConfig(t))}}),t.fn.datepicker=function(e){if(!this.length)return this;t.datepicker.initialized||(t(document).mousedown(t.datepicker._checkExternalClick),t.datepicker.initialized=!0),0===t("#"+t.datepicker._mainDivId).length&&t("body").append(t.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof e||"isDisabled"!==e&&"getDate"!==e&&"widget"!==e?"option"===e&&2===arguments.length&&"string"==typeof arguments[1]?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof e?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this].concat(i)):t.datepicker._attachDatepicker(this,e)}):t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i))},t.datepicker=new i,t.datepicker.initialized=!1,t.datepicker.uuid=(new Date).getTime(),t.datepicker.version="1.10.3"})(jQuery);
@@ -0,0 +1,621 @@
1
+ /*!
2
+ * jQuery UI Menu 1.10.0
3
+ * http://jqueryui.com
4
+ *
5
+ * Copyright 2013 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
7
+ * http://jquery.org/license
8
+ *
9
+ * http://api.jqueryui.com/menu/
10
+ *
11
+ * Depends:
12
+ * jquery.ui.core.js
13
+ * jquery.ui.widget.js
14
+ * jquery.ui.position.js
15
+ */
16
+ (function( $, undefined ) {
17
+
18
+ $.widget( "ui.menu", {
19
+ version: "1.10.0",
20
+ defaultElement: "<ul>",
21
+ delay: 300,
22
+ options: {
23
+ icons: {
24
+ submenu: "ui-icon-carat-1-e"
25
+ },
26
+ menus: "ul",
27
+ position: {
28
+ my: "left top",
29
+ at: "right top"
30
+ },
31
+ role: "menu",
32
+
33
+ // callbacks
34
+ blur: null,
35
+ focus: null,
36
+ select: null
37
+ },
38
+
39
+ _create: function() {
40
+ this.activeMenu = this.element;
41
+ // flag used to prevent firing of the click handler
42
+ // as the event bubbles up through nested menus
43
+ this.mouseHandled = false;
44
+ this.element
45
+ .uniqueId()
46
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
47
+ .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
48
+ .attr({
49
+ role: this.options.role,
50
+ tabIndex: 0
51
+ })
52
+ // need to catch all clicks on disabled menu
53
+ // not possible through _on
54
+ .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
55
+ if ( this.options.disabled ) {
56
+ event.preventDefault();
57
+ }
58
+ }, this ));
59
+
60
+ if ( this.options.disabled ) {
61
+ this.element
62
+ .addClass( "ui-state-disabled" )
63
+ .attr( "aria-disabled", "true" );
64
+ }
65
+
66
+ this._on({
67
+ // Prevent focus from sticking to links inside menu after clicking
68
+ // them (focus should always stay on UL during navigation).
69
+ "mousedown .ui-menu-item > a": function( event ) {
70
+ event.preventDefault();
71
+ },
72
+ "click .ui-state-disabled > a": function( event ) {
73
+ event.preventDefault();
74
+ },
75
+ "click .ui-menu-item:has(a)": function( event ) {
76
+ var target = $( event.target ).closest( ".ui-menu-item" );
77
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
78
+ this.mouseHandled = true;
79
+
80
+ this.select( event );
81
+ // Open submenu on click
82
+ if ( target.has( ".ui-menu" ).length ) {
83
+ this.expand( event );
84
+ } else if ( !this.element.is( ":focus" ) ) {
85
+ // Redirect focus to the menu
86
+ this.element.trigger( "focus", [ true ] );
87
+
88
+ // If the active item is on the top level, let it stay active.
89
+ // Otherwise, blur the active item since it is no longer visible.
90
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
91
+ clearTimeout( this.timer );
92
+ }
93
+ }
94
+ }
95
+ },
96
+ "mouseenter .ui-menu-item": function( event ) {
97
+ var target = $( event.currentTarget );
98
+ // Remove ui-state-active class from siblings of the newly focused menu item
99
+ // to avoid a jump caused by adjacent elements both having a class with a border
100
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
101
+ this.focus( event, target );
102
+ },
103
+ mouseleave: "collapseAll",
104
+ "mouseleave .ui-menu": "collapseAll",
105
+ focus: function( event, keepActiveItem ) {
106
+ // If there's already an active item, keep it active
107
+ // If not, activate the first item
108
+ var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
109
+
110
+ if ( !keepActiveItem ) {
111
+ this.focus( event, item );
112
+ }
113
+ },
114
+ blur: function( event ) {
115
+ this._delay(function() {
116
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
117
+ this.collapseAll( event );
118
+ }
119
+ });
120
+ },
121
+ keydown: "_keydown"
122
+ });
123
+
124
+ this.refresh();
125
+
126
+ // Clicks outside of a menu collapse any open menus
127
+ this._on( this.document, {
128
+ click: function( event ) {
129
+ if ( !$( event.target ).closest( ".ui-menu" ).length ) {
130
+ this.collapseAll( event );
131
+ }
132
+
133
+ // Reset the mouseHandled flag
134
+ this.mouseHandled = false;
135
+ }
136
+ });
137
+ },
138
+
139
+ _destroy: function() {
140
+ // Destroy (sub)menus
141
+ this.element
142
+ .removeAttr( "aria-activedescendant" )
143
+ .find( ".ui-menu" ).addBack()
144
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
145
+ .removeAttr( "role" )
146
+ .removeAttr( "tabIndex" )
147
+ .removeAttr( "aria-labelledby" )
148
+ .removeAttr( "aria-expanded" )
149
+ .removeAttr( "aria-hidden" )
150
+ .removeAttr( "aria-disabled" )
151
+ .removeUniqueId()
152
+ .show();
153
+
154
+ // Destroy menu items
155
+ this.element.find( ".ui-menu-item" )
156
+ .removeClass( "ui-menu-item" )
157
+ .removeAttr( "role" )
158
+ .removeAttr( "aria-disabled" )
159
+ .children( "a" )
160
+ .removeUniqueId()
161
+ .removeClass( "ui-corner-all ui-state-hover" )
162
+ .removeAttr( "tabIndex" )
163
+ .removeAttr( "role" )
164
+ .removeAttr( "aria-haspopup" )
165
+ .children().each( function() {
166
+ var elem = $( this );
167
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
168
+ elem.remove();
169
+ }
170
+ });
171
+
172
+ // Destroy menu dividers
173
+ this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
174
+ },
175
+
176
+ _keydown: function( event ) {
177
+ /*jshint maxcomplexity:20*/
178
+ var match, prev, character, skip, regex,
179
+ preventDefault = true;
180
+
181
+ function escape( value ) {
182
+ return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
183
+ }
184
+
185
+ switch ( event.keyCode ) {
186
+ case $.ui.keyCode.PAGE_UP:
187
+ this.previousPage( event );
188
+ break;
189
+ case $.ui.keyCode.PAGE_DOWN:
190
+ this.nextPage( event );
191
+ break;
192
+ case $.ui.keyCode.HOME:
193
+ this._move( "first", "first", event );
194
+ break;
195
+ case $.ui.keyCode.END:
196
+ this._move( "last", "last", event );
197
+ break;
198
+ case $.ui.keyCode.UP:
199
+ this.previous( event );
200
+ break;
201
+ case $.ui.keyCode.DOWN:
202
+ this.next( event );
203
+ break;
204
+ case $.ui.keyCode.LEFT:
205
+ this.collapse( event );
206
+ break;
207
+ case $.ui.keyCode.RIGHT:
208
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
209
+ this.expand( event );
210
+ }
211
+ break;
212
+ case $.ui.keyCode.ENTER:
213
+ case $.ui.keyCode.SPACE:
214
+ this._activate( event );
215
+ break;
216
+ case $.ui.keyCode.ESCAPE:
217
+ this.collapse( event );
218
+ break;
219
+ default:
220
+ preventDefault = false;
221
+ prev = this.previousFilter || "";
222
+ character = String.fromCharCode( event.keyCode );
223
+ skip = false;
224
+
225
+ clearTimeout( this.filterTimer );
226
+
227
+ if ( character === prev ) {
228
+ skip = true;
229
+ } else {
230
+ character = prev + character;
231
+ }
232
+
233
+ regex = new RegExp( "^" + escape( character ), "i" );
234
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
235
+ return regex.test( $( this ).children( "a" ).text() );
236
+ });
237
+ match = skip && match.index( this.active.next() ) !== -1 ?
238
+ this.active.nextAll( ".ui-menu-item" ) :
239
+ match;
240
+
241
+ // If no matches on the current filter, reset to the last character pressed
242
+ // to move down the menu to the first item that starts with that character
243
+ if ( !match.length ) {
244
+ character = String.fromCharCode( event.keyCode );
245
+ regex = new RegExp( "^" + escape( character ), "i" );
246
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
247
+ return regex.test( $( this ).children( "a" ).text() );
248
+ });
249
+ }
250
+
251
+ if ( match.length ) {
252
+ this.focus( event, match );
253
+ if ( match.length > 1 ) {
254
+ this.previousFilter = character;
255
+ this.filterTimer = this._delay(function() {
256
+ delete this.previousFilter;
257
+ }, 1000 );
258
+ } else {
259
+ delete this.previousFilter;
260
+ }
261
+ } else {
262
+ delete this.previousFilter;
263
+ }
264
+ }
265
+
266
+ if ( preventDefault ) {
267
+ event.preventDefault();
268
+ }
269
+ },
270
+
271
+ _activate: function( event ) {
272
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
273
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
274
+ this.expand( event );
275
+ } else {
276
+ this.select( event );
277
+ }
278
+ }
279
+ },
280
+
281
+ refresh: function() {
282
+ var menus,
283
+ icon = this.options.icons.submenu,
284
+ submenus = this.element.find( this.options.menus );
285
+
286
+ // Initialize nested menus
287
+ submenus.filter( ":not(.ui-menu)" )
288
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
289
+ .hide()
290
+ .attr({
291
+ role: this.options.role,
292
+ "aria-hidden": "true",
293
+ "aria-expanded": "false"
294
+ })
295
+ .each(function() {
296
+ var menu = $( this ),
297
+ item = menu.prev( "a" ),
298
+ submenuCarat = $( "<span>" )
299
+ .addClass( "ui-menu-icon ui-icon " + icon )
300
+ .data( "ui-menu-submenu-carat", true );
301
+
302
+ item
303
+ .attr( "aria-haspopup", "true" )
304
+ .prepend( submenuCarat );
305
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
306
+ });
307
+
308
+ menus = submenus.add( this.element );
309
+
310
+ // Don't refresh list items that are already adapted
311
+ menus.children( ":not(.ui-menu-item):has(a)" )
312
+ .addClass( "ui-menu-item" )
313
+ .attr( "role", "presentation" )
314
+ .children( "a" )
315
+ .uniqueId()
316
+ .addClass( "ui-corner-all" )
317
+ .attr({
318
+ tabIndex: -1,
319
+ role: this._itemRole()
320
+ });
321
+
322
+ // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
323
+ menus.children( ":not(.ui-menu-item)" ).each(function() {
324
+ var item = $( this );
325
+ // hyphen, em dash, en dash
326
+ if ( !/[^\-—–\s]/.test( item.text() ) ) {
327
+ item.addClass( "ui-widget-content ui-menu-divider" );
328
+ }
329
+ });
330
+
331
+ // Add aria-disabled attribute to any disabled menu item
332
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
333
+
334
+ // If the active item has been removed, blur the menu
335
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
336
+ this.blur();
337
+ }
338
+ },
339
+
340
+ _itemRole: function() {
341
+ return {
342
+ menu: "menuitem",
343
+ listbox: "option"
344
+ }[ this.options.role ];
345
+ },
346
+
347
+ _setOption: function( key, value ) {
348
+ if ( key === "icons" ) {
349
+ this.element.find( ".ui-menu-icon" )
350
+ .removeClass( this.options.icons.submenu )
351
+ .addClass( value.submenu );
352
+ }
353
+ this._super( key, value );
354
+ },
355
+
356
+ focus: function( event, item ) {
357
+ var nested, focused;
358
+ this.blur( event, event && event.type === "focus" );
359
+
360
+ this._scrollIntoView( item );
361
+
362
+ this.active = item.first();
363
+ focused = this.active.children( "a" ).addClass( "ui-state-focus" );
364
+ // Only update aria-activedescendant if there's a role
365
+ // otherwise we assume focus is managed elsewhere
366
+ if ( this.options.role ) {
367
+ this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
368
+ }
369
+
370
+ // Highlight active parent menu item, if any
371
+ this.active
372
+ .parent()
373
+ .closest( ".ui-menu-item" )
374
+ .children( "a:first" )
375
+ .addClass( "ui-state-active" );
376
+
377
+ if ( event && event.type === "keydown" ) {
378
+ this._close();
379
+ } else {
380
+ this.timer = this._delay(function() {
381
+ this._close();
382
+ }, this.delay );
383
+ }
384
+
385
+ nested = item.children( ".ui-menu" );
386
+ if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
387
+ this._startOpening(nested);
388
+ }
389
+ this.activeMenu = item.parent();
390
+
391
+ this._trigger( "focus", event, { item: item } );
392
+ },
393
+
394
+ _scrollIntoView: function( item ) {
395
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
396
+ if ( this._hasScroll() ) {
397
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
398
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
399
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
400
+ scroll = this.activeMenu.scrollTop();
401
+ elementHeight = this.activeMenu.height();
402
+ itemHeight = item.height();
403
+
404
+ if ( offset < 0 ) {
405
+ this.activeMenu.scrollTop( scroll + offset );
406
+ } else if ( offset + itemHeight > elementHeight ) {
407
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
408
+ }
409
+ }
410
+ },
411
+
412
+ blur: function( event, fromFocus ) {
413
+ if ( !fromFocus ) {
414
+ clearTimeout( this.timer );
415
+ }
416
+
417
+ if ( !this.active ) {
418
+ return;
419
+ }
420
+
421
+ this.active.children( "a" ).removeClass( "ui-state-focus" );
422
+ this.active = null;
423
+
424
+ this._trigger( "blur", event, { item: this.active } );
425
+ },
426
+
427
+ _startOpening: function( submenu ) {
428
+ clearTimeout( this.timer );
429
+
430
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
431
+ // shift in the submenu position when mousing over the carat icon
432
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
433
+ return;
434
+ }
435
+
436
+ this.timer = this._delay(function() {
437
+ this._close();
438
+ this._open( submenu );
439
+ }, this.delay );
440
+ },
441
+
442
+ _open: function( submenu ) {
443
+ var position = $.extend({
444
+ of: this.active
445
+ }, this.options.position );
446
+
447
+ clearTimeout( this.timer );
448
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
449
+ .hide()
450
+ .attr( "aria-hidden", "true" );
451
+
452
+ submenu
453
+ .show()
454
+ .removeAttr( "aria-hidden" )
455
+ .attr( "aria-expanded", "true" )
456
+ .position( position );
457
+ },
458
+
459
+ collapseAll: function( event, all ) {
460
+ clearTimeout( this.timer );
461
+ this.timer = this._delay(function() {
462
+ // If we were passed an event, look for the submenu that contains the event
463
+ var currentMenu = all ? this.element :
464
+ $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
465
+
466
+ // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
467
+ if ( !currentMenu.length ) {
468
+ currentMenu = this.element;
469
+ }
470
+
471
+ this._close( currentMenu );
472
+
473
+ this.blur( event );
474
+ this.activeMenu = currentMenu;
475
+ }, this.delay );
476
+ },
477
+
478
+ // With no arguments, closes the currently active menu - if nothing is active
479
+ // it closes all menus. If passed an argument, it will search for menus BELOW
480
+ _close: function( startMenu ) {
481
+ if ( !startMenu ) {
482
+ startMenu = this.active ? this.active.parent() : this.element;
483
+ }
484
+
485
+ startMenu
486
+ .find( ".ui-menu" )
487
+ .hide()
488
+ .attr( "aria-hidden", "true" )
489
+ .attr( "aria-expanded", "false" )
490
+ .end()
491
+ .find( "a.ui-state-active" )
492
+ .removeClass( "ui-state-active" );
493
+ },
494
+
495
+ collapse: function( event ) {
496
+ var newItem = this.active &&
497
+ this.active.parent().closest( ".ui-menu-item", this.element );
498
+ if ( newItem && newItem.length ) {
499
+ this._close();
500
+ this.focus( event, newItem );
501
+ }
502
+ },
503
+
504
+ expand: function( event ) {
505
+ var newItem = this.active &&
506
+ this.active
507
+ .children( ".ui-menu " )
508
+ .children( ".ui-menu-item" )
509
+ .first();
510
+
511
+ if ( newItem && newItem.length ) {
512
+ this._open( newItem.parent() );
513
+
514
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
515
+ this._delay(function() {
516
+ this.focus( event, newItem );
517
+ });
518
+ }
519
+ },
520
+
521
+ next: function( event ) {
522
+ this._move( "next", "first", event );
523
+ },
524
+
525
+ previous: function( event ) {
526
+ this._move( "prev", "last", event );
527
+ },
528
+
529
+ isFirstItem: function() {
530
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
531
+ },
532
+
533
+ isLastItem: function() {
534
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
535
+ },
536
+
537
+ _move: function( direction, filter, event ) {
538
+ var next;
539
+ if ( this.active ) {
540
+ if ( direction === "first" || direction === "last" ) {
541
+ next = this.active
542
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
543
+ .eq( -1 );
544
+ } else {
545
+ next = this.active
546
+ [ direction + "All" ]( ".ui-menu-item" )
547
+ .eq( 0 );
548
+ }
549
+ }
550
+ if ( !next || !next.length || !this.active ) {
551
+ next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
552
+ }
553
+
554
+ this.focus( event, next );
555
+ },
556
+
557
+ nextPage: function( event ) {
558
+ var item, base, height;
559
+
560
+ if ( !this.active ) {
561
+ this.next( event );
562
+ return;
563
+ }
564
+ if ( this.isLastItem() ) {
565
+ return;
566
+ }
567
+ if ( this._hasScroll() ) {
568
+ base = this.active.offset().top;
569
+ height = this.element.height();
570
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
571
+ item = $( this );
572
+ return item.offset().top - base - height < 0;
573
+ });
574
+
575
+ this.focus( event, item );
576
+ } else {
577
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
578
+ [ !this.active ? "first" : "last" ]() );
579
+ }
580
+ },
581
+
582
+ previousPage: function( event ) {
583
+ var item, base, height;
584
+ if ( !this.active ) {
585
+ this.next( event );
586
+ return;
587
+ }
588
+ if ( this.isFirstItem() ) {
589
+ return;
590
+ }
591
+ if ( this._hasScroll() ) {
592
+ base = this.active.offset().top;
593
+ height = this.element.height();
594
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
595
+ item = $( this );
596
+ return item.offset().top - base + height > 0;
597
+ });
598
+
599
+ this.focus( event, item );
600
+ } else {
601
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
602
+ }
603
+ },
604
+
605
+ _hasScroll: function() {
606
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
607
+ },
608
+
609
+ select: function( event ) {
610
+ // TODO: It should never be possible to not have an active item at this
611
+ // point, but the tests don't trigger mouseenter before click.
612
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
613
+ var ui = { item: this.active };
614
+ if ( !this.active.has( ".ui-menu" ).length ) {
615
+ this.collapseAll( event, true );
616
+ }
617
+ this._trigger( "select", event, ui );
618
+ }
619
+ });
620
+
621
+ }( jQuery ));