pageflow 17.0.1 → 17.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ require('./core');
2
+ require('./widget');
3
+ require('./mouse');
4
+ require('./menu');
5
+ require('./selectmenu');
6
+ require('./slider');
7
+ require('./sortable');
8
+ require('./datepicker');
@@ -0,0 +1,651 @@
1
+
2
+
3
+
4
+
5
+ /*!
6
+ * jQuery UI Menu 1.11.4
7
+ * http://jqueryui.com
8
+ *
9
+ * Copyright jQuery Foundation and other contributors
10
+ * Released under the MIT license.
11
+ * http://jquery.org/license
12
+ *
13
+ * http://api.jqueryui.com/menu/
14
+ */
15
+
16
+ (function( factory ) {
17
+ if ( typeof define === "function" && define.amd ) {
18
+
19
+ // AMD. Register as an anonymous module.
20
+ define([
21
+ "jquery",
22
+ "./core",
23
+ "./widget",
24
+ "./position"
25
+ ], factory );
26
+ } else {
27
+
28
+ // Browser globals
29
+ factory( require('jquery') );
30
+ }
31
+ }(function( $ ) {
32
+
33
+ return $.widget( "ui.menu", {
34
+ version: "1.11.4",
35
+ defaultElement: "<ul>",
36
+ delay: 300,
37
+ options: {
38
+ icons: {
39
+ submenu: "ui-icon-carat-1-e"
40
+ },
41
+ items: "> *",
42
+ menus: "ul",
43
+ position: {
44
+ my: "left-1 top",
45
+ at: "right top"
46
+ },
47
+ role: "menu",
48
+
49
+ // callbacks
50
+ blur: null,
51
+ focus: null,
52
+ select: null
53
+ },
54
+
55
+ _create: function() {
56
+ this.activeMenu = this.element;
57
+
58
+ // Flag used to prevent firing of the click handler
59
+ // as the event bubbles up through nested menus
60
+ this.mouseHandled = false;
61
+ this.element
62
+ .uniqueId()
63
+ .addClass( "ui-menu ui-widget ui-widget-content" )
64
+ .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
65
+ .attr({
66
+ role: this.options.role,
67
+ tabIndex: 0
68
+ });
69
+
70
+ if ( this.options.disabled ) {
71
+ this.element
72
+ .addClass( "ui-state-disabled" )
73
+ .attr( "aria-disabled", "true" );
74
+ }
75
+
76
+ this._on({
77
+ // Prevent focus from sticking to links inside menu after clicking
78
+ // them (focus should always stay on UL during navigation).
79
+ "mousedown .ui-menu-item": function( event ) {
80
+ event.preventDefault();
81
+ },
82
+ "click .ui-menu-item": function( event ) {
83
+ var target = $( event.target );
84
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
85
+ this.select( event );
86
+
87
+ // Only set the mouseHandled flag if the event will bubble, see #9469.
88
+ if ( !event.isPropagationStopped() ) {
89
+ this.mouseHandled = true;
90
+ }
91
+
92
+ // Open submenu on click
93
+ if ( target.has( ".ui-menu" ).length ) {
94
+ this.expand( event );
95
+ } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
96
+
97
+ // Redirect focus to the menu
98
+ this.element.trigger( "focus", [ true ] );
99
+
100
+ // If the active item is on the top level, let it stay active.
101
+ // Otherwise, blur the active item since it is no longer visible.
102
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
103
+ clearTimeout( this.timer );
104
+ }
105
+ }
106
+ }
107
+ },
108
+ "mouseenter .ui-menu-item": function( event ) {
109
+ // Ignore mouse events while typeahead is active, see #10458.
110
+ // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
111
+ // is over an item in the menu
112
+ if ( this.previousFilter ) {
113
+ return;
114
+ }
115
+ var target = $( event.currentTarget );
116
+ // Remove ui-state-active class from siblings of the newly focused menu item
117
+ // to avoid a jump caused by adjacent elements both having a class with a border
118
+ target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
119
+ this.focus( event, target );
120
+ },
121
+ mouseleave: "collapseAll",
122
+ "mouseleave .ui-menu": "collapseAll",
123
+ focus: function( event, keepActiveItem ) {
124
+ // If there's already an active item, keep it active
125
+ // If not, activate the first item
126
+ var item = this.active || this.element.find( this.options.items ).eq( 0 );
127
+
128
+ if ( !keepActiveItem ) {
129
+ this.focus( event, item );
130
+ }
131
+ },
132
+ blur: function( event ) {
133
+ this._delay(function() {
134
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
135
+ this.collapseAll( event );
136
+ }
137
+ });
138
+ },
139
+ keydown: "_keydown"
140
+ });
141
+
142
+ this.refresh();
143
+
144
+ // Clicks outside of a menu collapse any open menus
145
+ this._on( this.document, {
146
+ click: function( event ) {
147
+ if ( this._closeOnDocumentClick( event ) ) {
148
+ this.collapseAll( event );
149
+ }
150
+
151
+ // Reset the mouseHandled flag
152
+ this.mouseHandled = false;
153
+ }
154
+ });
155
+ },
156
+
157
+ _destroy: function() {
158
+ // Destroy (sub)menus
159
+ this.element
160
+ .removeAttr( "aria-activedescendant" )
161
+ .find( ".ui-menu" ).addBack()
162
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
163
+ .removeAttr( "role" )
164
+ .removeAttr( "tabIndex" )
165
+ .removeAttr( "aria-labelledby" )
166
+ .removeAttr( "aria-expanded" )
167
+ .removeAttr( "aria-hidden" )
168
+ .removeAttr( "aria-disabled" )
169
+ .removeUniqueId()
170
+ .show();
171
+
172
+ // Destroy menu items
173
+ this.element.find( ".ui-menu-item" )
174
+ .removeClass( "ui-menu-item" )
175
+ .removeAttr( "role" )
176
+ .removeAttr( "aria-disabled" )
177
+ .removeUniqueId()
178
+ .removeClass( "ui-state-hover" )
179
+ .removeAttr( "tabIndex" )
180
+ .removeAttr( "role" )
181
+ .removeAttr( "aria-haspopup" )
182
+ .children().each( function() {
183
+ var elem = $( this );
184
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
185
+ elem.remove();
186
+ }
187
+ });
188
+
189
+ // Destroy menu dividers
190
+ this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
191
+ },
192
+
193
+ _keydown: function( event ) {
194
+ var match, prev, character, skip,
195
+ preventDefault = true;
196
+
197
+ switch ( event.keyCode ) {
198
+ case $.ui.keyCode.PAGE_UP:
199
+ this.previousPage( event );
200
+ break;
201
+ case $.ui.keyCode.PAGE_DOWN:
202
+ this.nextPage( event );
203
+ break;
204
+ case $.ui.keyCode.HOME:
205
+ this._move( "first", "first", event );
206
+ break;
207
+ case $.ui.keyCode.END:
208
+ this._move( "last", "last", event );
209
+ break;
210
+ case $.ui.keyCode.UP:
211
+ this.previous( event );
212
+ break;
213
+ case $.ui.keyCode.DOWN:
214
+ this.next( event );
215
+ break;
216
+ case $.ui.keyCode.LEFT:
217
+ this.collapse( event );
218
+ break;
219
+ case $.ui.keyCode.RIGHT:
220
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
221
+ this.expand( event );
222
+ }
223
+ break;
224
+ case $.ui.keyCode.ENTER:
225
+ case $.ui.keyCode.SPACE:
226
+ this._activate( event );
227
+ break;
228
+ case $.ui.keyCode.ESCAPE:
229
+ this.collapse( event );
230
+ break;
231
+ default:
232
+ preventDefault = false;
233
+ prev = this.previousFilter || "";
234
+ character = String.fromCharCode( event.keyCode );
235
+ skip = false;
236
+
237
+ clearTimeout( this.filterTimer );
238
+
239
+ if ( character === prev ) {
240
+ skip = true;
241
+ } else {
242
+ character = prev + character;
243
+ }
244
+
245
+ match = this._filterMenuItems( character );
246
+ match = skip && match.index( this.active.next() ) !== -1 ?
247
+ this.active.nextAll( ".ui-menu-item" ) :
248
+ match;
249
+
250
+ // If no matches on the current filter, reset to the last character pressed
251
+ // to move down the menu to the first item that starts with that character
252
+ if ( !match.length ) {
253
+ character = String.fromCharCode( event.keyCode );
254
+ match = this._filterMenuItems( character );
255
+ }
256
+
257
+ if ( match.length ) {
258
+ this.focus( event, match );
259
+ this.previousFilter = character;
260
+ this.filterTimer = this._delay(function() {
261
+ delete this.previousFilter;
262
+ }, 1000 );
263
+ } else {
264
+ delete this.previousFilter;
265
+ }
266
+ }
267
+
268
+ if ( preventDefault ) {
269
+ event.preventDefault();
270
+ }
271
+ },
272
+
273
+ _activate: function( event ) {
274
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
275
+ if ( this.active.is( "[aria-haspopup='true']" ) ) {
276
+ this.expand( event );
277
+ } else {
278
+ this.select( event );
279
+ }
280
+ }
281
+ },
282
+
283
+ refresh: function() {
284
+ var menus, items,
285
+ that = this,
286
+ icon = this.options.icons.submenu,
287
+ submenus = this.element.find( this.options.menus );
288
+
289
+ this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
290
+
291
+ // Initialize nested menus
292
+ submenus.filter( ":not(.ui-menu)" )
293
+ .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
294
+ .hide()
295
+ .attr({
296
+ role: this.options.role,
297
+ "aria-hidden": "true",
298
+ "aria-expanded": "false"
299
+ })
300
+ .each(function() {
301
+ var menu = $( this ),
302
+ item = menu.parent(),
303
+ submenuCarat = $( "<span>" )
304
+ .addClass( "ui-menu-icon ui-icon " + icon )
305
+ .data( "ui-menu-submenu-carat", true );
306
+
307
+ item
308
+ .attr( "aria-haspopup", "true" )
309
+ .prepend( submenuCarat );
310
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
311
+ });
312
+
313
+ menus = submenus.add( this.element );
314
+ items = menus.find( this.options.items );
315
+
316
+ // Initialize menu-items containing spaces and/or dashes only as dividers
317
+ items.not( ".ui-menu-item" ).each(function() {
318
+ var item = $( this );
319
+ if ( that._isDivider( item ) ) {
320
+ item.addClass( "ui-widget-content ui-menu-divider" );
321
+ }
322
+ });
323
+
324
+ // Don't refresh list items that are already adapted
325
+ items.not( ".ui-menu-item, .ui-menu-divider" )
326
+ .addClass( "ui-menu-item" )
327
+ .uniqueId()
328
+ .attr({
329
+ tabIndex: -1,
330
+ role: this._itemRole()
331
+ });
332
+
333
+ // Add aria-disabled attribute to any disabled menu item
334
+ items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
335
+
336
+ // If the active item has been removed, blur the menu
337
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
338
+ this.blur();
339
+ }
340
+ },
341
+
342
+ _itemRole: function() {
343
+ return {
344
+ menu: "menuitem",
345
+ listbox: "option"
346
+ }[ this.options.role ];
347
+ },
348
+
349
+ _setOption: function( key, value ) {
350
+ if ( key === "icons" ) {
351
+ this.element.find( ".ui-menu-icon" )
352
+ .removeClass( this.options.icons.submenu )
353
+ .addClass( value.submenu );
354
+ }
355
+ if ( key === "disabled" ) {
356
+ this.element
357
+ .toggleClass( "ui-state-disabled", !!value )
358
+ .attr( "aria-disabled", value );
359
+ }
360
+ this._super( key, value );
361
+ },
362
+
363
+ focus: function( event, item ) {
364
+ var nested, focused;
365
+ this.blur( event, event && event.type === "focus" );
366
+
367
+ this._scrollIntoView( item );
368
+
369
+ this.active = item.first();
370
+ focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
371
+ // Only update aria-activedescendant if there's a role
372
+ // otherwise we assume focus is managed elsewhere
373
+ if ( this.options.role ) {
374
+ this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
375
+ }
376
+
377
+ // Highlight active parent menu item, if any
378
+ this.active
379
+ .parent()
380
+ .closest( ".ui-menu-item" )
381
+ .addClass( "ui-state-active" );
382
+
383
+ if ( event && event.type === "keydown" ) {
384
+ this._close();
385
+ } else {
386
+ this.timer = this._delay(function() {
387
+ this._close();
388
+ }, this.delay );
389
+ }
390
+
391
+ nested = item.children( ".ui-menu" );
392
+ if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
393
+ this._startOpening(nested);
394
+ }
395
+ this.activeMenu = item.parent();
396
+
397
+ this._trigger( "focus", event, { item: item } );
398
+ },
399
+
400
+ _scrollIntoView: function( item ) {
401
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
402
+ if ( this._hasScroll() ) {
403
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
404
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
405
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
406
+ scroll = this.activeMenu.scrollTop();
407
+ elementHeight = this.activeMenu.height();
408
+ itemHeight = item.outerHeight();
409
+
410
+ if ( offset < 0 ) {
411
+ this.activeMenu.scrollTop( scroll + offset );
412
+ } else if ( offset + itemHeight > elementHeight ) {
413
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
414
+ }
415
+ }
416
+ },
417
+
418
+ blur: function( event, fromFocus ) {
419
+ if ( !fromFocus ) {
420
+ clearTimeout( this.timer );
421
+ }
422
+
423
+ if ( !this.active ) {
424
+ return;
425
+ }
426
+
427
+ this.active.removeClass( "ui-state-focus" );
428
+ this.active = null;
429
+
430
+ this._trigger( "blur", event, { item: this.active } );
431
+ },
432
+
433
+ _startOpening: function( submenu ) {
434
+ clearTimeout( this.timer );
435
+
436
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
437
+ // shift in the submenu position when mousing over the carat icon
438
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
439
+ return;
440
+ }
441
+
442
+ this.timer = this._delay(function() {
443
+ this._close();
444
+ this._open( submenu );
445
+ }, this.delay );
446
+ },
447
+
448
+ _open: function( submenu ) {
449
+ var position = $.extend({
450
+ of: this.active
451
+ }, this.options.position );
452
+
453
+ clearTimeout( this.timer );
454
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
455
+ .hide()
456
+ .attr( "aria-hidden", "true" );
457
+
458
+ submenu
459
+ .show()
460
+ .removeAttr( "aria-hidden" )
461
+ .attr( "aria-expanded", "true" )
462
+ .position( position );
463
+ },
464
+
465
+ collapseAll: function( event, all ) {
466
+ clearTimeout( this.timer );
467
+ this.timer = this._delay(function() {
468
+ // If we were passed an event, look for the submenu that contains the event
469
+ var currentMenu = all ? this.element :
470
+ $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
471
+
472
+ // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
473
+ if ( !currentMenu.length ) {
474
+ currentMenu = this.element;
475
+ }
476
+
477
+ this._close( currentMenu );
478
+
479
+ this.blur( event );
480
+ this.activeMenu = currentMenu;
481
+ }, this.delay );
482
+ },
483
+
484
+ // With no arguments, closes the currently active menu - if nothing is active
485
+ // it closes all menus. If passed an argument, it will search for menus BELOW
486
+ _close: function( startMenu ) {
487
+ if ( !startMenu ) {
488
+ startMenu = this.active ? this.active.parent() : this.element;
489
+ }
490
+
491
+ startMenu
492
+ .find( ".ui-menu" )
493
+ .hide()
494
+ .attr( "aria-hidden", "true" )
495
+ .attr( "aria-expanded", "false" )
496
+ .end()
497
+ .find( ".ui-state-active" ).not( ".ui-state-focus" )
498
+ .removeClass( "ui-state-active" );
499
+ },
500
+
501
+ _closeOnDocumentClick: function( event ) {
502
+ return !$( event.target ).closest( ".ui-menu" ).length;
503
+ },
504
+
505
+ _isDivider: function( item ) {
506
+
507
+ // Match hyphen, em dash, en dash
508
+ return !/[^\-\u2014\u2013\s]/.test( item.text() );
509
+ },
510
+
511
+ collapse: function( event ) {
512
+ var newItem = this.active &&
513
+ this.active.parent().closest( ".ui-menu-item", this.element );
514
+ if ( newItem && newItem.length ) {
515
+ this._close();
516
+ this.focus( event, newItem );
517
+ }
518
+ },
519
+
520
+ expand: function( event ) {
521
+ var newItem = this.active &&
522
+ this.active
523
+ .children( ".ui-menu " )
524
+ .find( this.options.items )
525
+ .first();
526
+
527
+ if ( newItem && newItem.length ) {
528
+ this._open( newItem.parent() );
529
+
530
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
531
+ this._delay(function() {
532
+ this.focus( event, newItem );
533
+ });
534
+ }
535
+ },
536
+
537
+ next: function( event ) {
538
+ this._move( "next", "first", event );
539
+ },
540
+
541
+ previous: function( event ) {
542
+ this._move( "prev", "last", event );
543
+ },
544
+
545
+ isFirstItem: function() {
546
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
547
+ },
548
+
549
+ isLastItem: function() {
550
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
551
+ },
552
+
553
+ _move: function( direction, filter, event ) {
554
+ var next;
555
+ if ( this.active ) {
556
+ if ( direction === "first" || direction === "last" ) {
557
+ next = this.active
558
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
559
+ .eq( -1 );
560
+ } else {
561
+ next = this.active
562
+ [ direction + "All" ]( ".ui-menu-item" )
563
+ .eq( 0 );
564
+ }
565
+ }
566
+ if ( !next || !next.length || !this.active ) {
567
+ next = this.activeMenu.find( this.options.items )[ filter ]();
568
+ }
569
+
570
+ this.focus( event, next );
571
+ },
572
+
573
+ nextPage: function( event ) {
574
+ var item, base, height;
575
+
576
+ if ( !this.active ) {
577
+ this.next( event );
578
+ return;
579
+ }
580
+ if ( this.isLastItem() ) {
581
+ return;
582
+ }
583
+ if ( this._hasScroll() ) {
584
+ base = this.active.offset().top;
585
+ height = this.element.height();
586
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
587
+ item = $( this );
588
+ return item.offset().top - base - height < 0;
589
+ });
590
+
591
+ this.focus( event, item );
592
+ } else {
593
+ this.focus( event, this.activeMenu.find( this.options.items )
594
+ [ !this.active ? "first" : "last" ]() );
595
+ }
596
+ },
597
+
598
+ previousPage: function( event ) {
599
+ var item, base, height;
600
+ if ( !this.active ) {
601
+ this.next( event );
602
+ return;
603
+ }
604
+ if ( this.isFirstItem() ) {
605
+ return;
606
+ }
607
+ if ( this._hasScroll() ) {
608
+ base = this.active.offset().top;
609
+ height = this.element.height();
610
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
611
+ item = $( this );
612
+ return item.offset().top - base + height > 0;
613
+ });
614
+
615
+ this.focus( event, item );
616
+ } else {
617
+ this.focus( event, this.activeMenu.find( this.options.items ).first() );
618
+ }
619
+ },
620
+
621
+ _hasScroll: function() {
622
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
623
+ },
624
+
625
+ select: function( event ) {
626
+ // TODO: It should never be possible to not have an active item at this
627
+ // point, but the tests don't trigger mouseenter before click.
628
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
629
+ var ui = { item: this.active };
630
+ if ( !this.active.has( ".ui-menu" ).length ) {
631
+ this.collapseAll( event, true );
632
+ }
633
+ this._trigger( "select", event, ui );
634
+ },
635
+
636
+ _filterMenuItems: function(character) {
637
+ var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
638
+ regex = new RegExp( "^" + escapedCharacter, "i" );
639
+
640
+ return this.activeMenu
641
+ .find( this.options.items )
642
+
643
+ // Only match on items, not dividers or other content (#10571)
644
+ .filter( ".ui-menu-item" )
645
+ .filter(function() {
646
+ return regex.test( $.trim( $( this ).text() ) );
647
+ });
648
+ }
649
+ });
650
+
651
+ }));