pageflow 17.0.1 → 17.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,621 @@
1
+
2
+
3
+
4
+
5
+
6
+ /*!
7
+ * jQuery UI Selectmenu 1.11.4
8
+ * http://jqueryui.com
9
+ *
10
+ * Copyright jQuery Foundation and other contributors
11
+ * Released under the MIT license.
12
+ * http://jquery.org/license
13
+ *
14
+ * http://api.jqueryui.com/selectmenu
15
+ */
16
+
17
+ (function( factory ) {
18
+ if ( typeof define === "function" && define.amd ) {
19
+
20
+ // AMD. Register as an anonymous module.
21
+ define([
22
+ "jquery",
23
+ "./core",
24
+ "./widget",
25
+ "./position",
26
+ "./menu"
27
+ ], factory );
28
+ } else {
29
+
30
+ // Browser globals
31
+ factory( require('jquery') );
32
+ }
33
+ }(function( $ ) {
34
+
35
+ return $.widget( "ui.selectmenu", {
36
+ version: "1.11.4",
37
+ defaultElement: "<select>",
38
+ options: {
39
+ appendTo: null,
40
+ disabled: null,
41
+ icons: {
42
+ button: "ui-icon-triangle-1-s"
43
+ },
44
+ position: {
45
+ my: "left top",
46
+ at: "left bottom",
47
+ collision: "none"
48
+ },
49
+ width: null,
50
+
51
+ // callbacks
52
+ change: null,
53
+ close: null,
54
+ focus: null,
55
+ open: null,
56
+ select: null
57
+ },
58
+
59
+ _create: function() {
60
+ var selectmenuId = this.element.uniqueId().attr( "id" );
61
+ this.ids = {
62
+ element: selectmenuId,
63
+ button: selectmenuId + "-button",
64
+ menu: selectmenuId + "-menu"
65
+ };
66
+
67
+ this._drawButton();
68
+ this._drawMenu();
69
+
70
+ if ( this.options.disabled ) {
71
+ this.disable();
72
+ }
73
+ },
74
+
75
+ _drawButton: function() {
76
+ var that = this;
77
+
78
+ // Associate existing label with the new button
79
+ this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
80
+ this._on( this.label, {
81
+ click: function( event ) {
82
+ this.button.focus();
83
+ event.preventDefault();
84
+ }
85
+ });
86
+
87
+ // Hide original select element
88
+ this.element.hide();
89
+
90
+ // Create button
91
+ this.button = $( "<span>", {
92
+ "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
93
+ tabindex: this.options.disabled ? -1 : 0,
94
+ id: this.ids.button,
95
+ role: "combobox",
96
+ "aria-expanded": "false",
97
+ "aria-autocomplete": "list",
98
+ "aria-owns": this.ids.menu,
99
+ "aria-haspopup": "true"
100
+ })
101
+ .insertAfter( this.element );
102
+
103
+ $( "<span>", {
104
+ "class": "ui-icon " + this.options.icons.button
105
+ })
106
+ .prependTo( this.button );
107
+
108
+ this.buttonText = $( "<span>", {
109
+ "class": "ui-selectmenu-text"
110
+ })
111
+ .appendTo( this.button );
112
+
113
+ this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
114
+ this._resizeButton();
115
+
116
+ this._on( this.button, this._buttonEvents );
117
+ this.button.one( "focusin", function() {
118
+
119
+ // Delay rendering the menu items until the button receives focus.
120
+ // The menu may have already been rendered via a programmatic open.
121
+ if ( !that.menuItems ) {
122
+ that._refreshMenu();
123
+ }
124
+ });
125
+ this._hoverable( this.button );
126
+ this._focusable( this.button );
127
+ },
128
+
129
+ _drawMenu: function() {
130
+ var that = this;
131
+
132
+ // Create menu
133
+ this.menu = $( "<ul>", {
134
+ "aria-hidden": "true",
135
+ "aria-labelledby": this.ids.button,
136
+ id: this.ids.menu
137
+ });
138
+
139
+ // Wrap menu
140
+ this.menuWrap = $( "<div>", {
141
+ "class": "ui-selectmenu-menu ui-front"
142
+ })
143
+ .append( this.menu )
144
+ .appendTo( this._appendTo() );
145
+
146
+ // Initialize menu widget
147
+ this.menuInstance = this.menu
148
+ .menu({
149
+ role: "listbox",
150
+ select: function( event, ui ) {
151
+ event.preventDefault();
152
+
153
+ // support: IE8
154
+ // If the item was selected via a click, the text selection
155
+ // will be destroyed in IE
156
+ that._setSelection();
157
+
158
+ that._select( ui.item.data( "ui-selectmenu-item" ), event );
159
+ },
160
+ focus: function( event, ui ) {
161
+ var item = ui.item.data( "ui-selectmenu-item" );
162
+
163
+ // Prevent inital focus from firing and check if its a newly focused item
164
+ if ( that.focusIndex != null && item.index !== that.focusIndex ) {
165
+ that._trigger( "focus", event, { item: item } );
166
+ if ( !that.isOpen ) {
167
+ that._select( item, event );
168
+ }
169
+ }
170
+ that.focusIndex = item.index;
171
+
172
+ that.button.attr( "aria-activedescendant",
173
+ that.menuItems.eq( item.index ).attr( "id" ) );
174
+ }
175
+ })
176
+ .menu( "instance" );
177
+
178
+ // Adjust menu styles to dropdown
179
+ this.menu
180
+ .addClass( "ui-corner-bottom" )
181
+ .removeClass( "ui-corner-all" );
182
+
183
+ // Don't close the menu on mouseleave
184
+ this.menuInstance._off( this.menu, "mouseleave" );
185
+
186
+ // Cancel the menu's collapseAll on document click
187
+ this.menuInstance._closeOnDocumentClick = function() {
188
+ return false;
189
+ };
190
+
191
+ // Selects often contain empty items, but never contain dividers
192
+ this.menuInstance._isDivider = function() {
193
+ return false;
194
+ };
195
+ },
196
+
197
+ refresh: function() {
198
+ this._refreshMenu();
199
+ this._setText( this.buttonText, this._getSelectedItem().text() );
200
+ if ( !this.options.width ) {
201
+ this._resizeButton();
202
+ }
203
+ },
204
+
205
+ _refreshMenu: function() {
206
+ this.menu.empty();
207
+
208
+ var item,
209
+ options = this.element.find( "option" );
210
+
211
+ if ( !options.length ) {
212
+ return;
213
+ }
214
+
215
+ this._parseOptions( options );
216
+ this._renderMenu( this.menu, this.items );
217
+
218
+ this.menuInstance.refresh();
219
+ this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
220
+
221
+ item = this._getSelectedItem();
222
+
223
+ // Update the menu to have the correct item focused
224
+ this.menuInstance.focus( null, item );
225
+ this._setAria( item.data( "ui-selectmenu-item" ) );
226
+
227
+ // Set disabled state
228
+ this._setOption( "disabled", this.element.prop( "disabled" ) );
229
+ },
230
+
231
+ open: function( event ) {
232
+ if ( this.options.disabled ) {
233
+ return;
234
+ }
235
+
236
+ // If this is the first time the menu is being opened, render the items
237
+ if ( !this.menuItems ) {
238
+ this._refreshMenu();
239
+ } else {
240
+
241
+ // Menu clears focus on close, reset focus to selected item
242
+ this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
243
+ this.menuInstance.focus( null, this._getSelectedItem() );
244
+ }
245
+
246
+ this.isOpen = true;
247
+ this._toggleAttr();
248
+ this._resizeMenu();
249
+ this._position();
250
+
251
+ this._on( this.document, this._documentClick );
252
+
253
+ this._trigger( "open", event );
254
+ },
255
+
256
+ _position: function() {
257
+ this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
258
+ },
259
+
260
+ close: function( event ) {
261
+ if ( !this.isOpen ) {
262
+ return;
263
+ }
264
+
265
+ this.isOpen = false;
266
+ this._toggleAttr();
267
+
268
+ this.range = null;
269
+ this._off( this.document );
270
+
271
+ this._trigger( "close", event );
272
+ },
273
+
274
+ widget: function() {
275
+ return this.button;
276
+ },
277
+
278
+ menuWidget: function() {
279
+ return this.menu;
280
+ },
281
+
282
+ _renderMenu: function( ul, items ) {
283
+ var that = this,
284
+ currentOptgroup = "";
285
+
286
+ $.each( items, function( index, item ) {
287
+ if ( item.optgroup !== currentOptgroup ) {
288
+ $( "<li>", {
289
+ "class": "ui-selectmenu-optgroup ui-menu-divider" +
290
+ ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
291
+ " ui-state-disabled" :
292
+ "" ),
293
+ text: item.optgroup
294
+ })
295
+ .appendTo( ul );
296
+
297
+ currentOptgroup = item.optgroup;
298
+ }
299
+
300
+ that._renderItemData( ul, item );
301
+ });
302
+ },
303
+
304
+ _renderItemData: function( ul, item ) {
305
+ return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
306
+ },
307
+
308
+ _renderItem: function( ul, item ) {
309
+ var li = $( "<li>" );
310
+
311
+ if ( item.disabled ) {
312
+ li.addClass( "ui-state-disabled" );
313
+ }
314
+ this._setText( li, item.label );
315
+
316
+ return li.appendTo( ul );
317
+ },
318
+
319
+ _setText: function( element, value ) {
320
+ if ( value ) {
321
+ element.text( value );
322
+ } else {
323
+ element.html( "&#160;" );
324
+ }
325
+ },
326
+
327
+ _move: function( direction, event ) {
328
+ var item, next,
329
+ filter = ".ui-menu-item";
330
+
331
+ if ( this.isOpen ) {
332
+ item = this.menuItems.eq( this.focusIndex );
333
+ } else {
334
+ item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
335
+ filter += ":not(.ui-state-disabled)";
336
+ }
337
+
338
+ if ( direction === "first" || direction === "last" ) {
339
+ next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
340
+ } else {
341
+ next = item[ direction + "All" ]( filter ).eq( 0 );
342
+ }
343
+
344
+ if ( next.length ) {
345
+ this.menuInstance.focus( event, next );
346
+ }
347
+ },
348
+
349
+ _getSelectedItem: function() {
350
+ return this.menuItems.eq( this.element[ 0 ].selectedIndex );
351
+ },
352
+
353
+ _toggle: function( event ) {
354
+ this[ this.isOpen ? "close" : "open" ]( event );
355
+ },
356
+
357
+ _setSelection: function() {
358
+ var selection;
359
+
360
+ if ( !this.range ) {
361
+ return;
362
+ }
363
+
364
+ if ( window.getSelection ) {
365
+ selection = window.getSelection();
366
+ selection.removeAllRanges();
367
+ selection.addRange( this.range );
368
+
369
+ // support: IE8
370
+ } else {
371
+ this.range.select();
372
+ }
373
+
374
+ // support: IE
375
+ // Setting the text selection kills the button focus in IE, but
376
+ // restoring the focus doesn't kill the selection.
377
+ this.button.focus();
378
+ },
379
+
380
+ _documentClick: {
381
+ mousedown: function( event ) {
382
+ if ( !this.isOpen ) {
383
+ return;
384
+ }
385
+
386
+ if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
387
+ this.close( event );
388
+ }
389
+ }
390
+ },
391
+
392
+ _buttonEvents: {
393
+
394
+ // Prevent text selection from being reset when interacting with the selectmenu (#10144)
395
+ mousedown: function() {
396
+ var selection;
397
+
398
+ if ( window.getSelection ) {
399
+ selection = window.getSelection();
400
+ if ( selection.rangeCount ) {
401
+ this.range = selection.getRangeAt( 0 );
402
+ }
403
+
404
+ // support: IE8
405
+ } else {
406
+ this.range = document.selection.createRange();
407
+ }
408
+ },
409
+
410
+ click: function( event ) {
411
+ this._setSelection();
412
+ this._toggle( event );
413
+ },
414
+
415
+ keydown: function( event ) {
416
+ var preventDefault = true;
417
+ switch ( event.keyCode ) {
418
+ case $.ui.keyCode.TAB:
419
+ case $.ui.keyCode.ESCAPE:
420
+ this.close( event );
421
+ preventDefault = false;
422
+ break;
423
+ case $.ui.keyCode.ENTER:
424
+ if ( this.isOpen ) {
425
+ this._selectFocusedItem( event );
426
+ }
427
+ break;
428
+ case $.ui.keyCode.UP:
429
+ if ( event.altKey ) {
430
+ this._toggle( event );
431
+ } else {
432
+ this._move( "prev", event );
433
+ }
434
+ break;
435
+ case $.ui.keyCode.DOWN:
436
+ if ( event.altKey ) {
437
+ this._toggle( event );
438
+ } else {
439
+ this._move( "next", event );
440
+ }
441
+ break;
442
+ case $.ui.keyCode.SPACE:
443
+ if ( this.isOpen ) {
444
+ this._selectFocusedItem( event );
445
+ } else {
446
+ this._toggle( event );
447
+ }
448
+ break;
449
+ case $.ui.keyCode.LEFT:
450
+ this._move( "prev", event );
451
+ break;
452
+ case $.ui.keyCode.RIGHT:
453
+ this._move( "next", event );
454
+ break;
455
+ case $.ui.keyCode.HOME:
456
+ case $.ui.keyCode.PAGE_UP:
457
+ this._move( "first", event );
458
+ break;
459
+ case $.ui.keyCode.END:
460
+ case $.ui.keyCode.PAGE_DOWN:
461
+ this._move( "last", event );
462
+ break;
463
+ default:
464
+ this.menu.trigger( event );
465
+ preventDefault = false;
466
+ }
467
+
468
+ if ( preventDefault ) {
469
+ event.preventDefault();
470
+ }
471
+ }
472
+ },
473
+
474
+ _selectFocusedItem: function( event ) {
475
+ var item = this.menuItems.eq( this.focusIndex );
476
+ if ( !item.hasClass( "ui-state-disabled" ) ) {
477
+ this._select( item.data( "ui-selectmenu-item" ), event );
478
+ }
479
+ },
480
+
481
+ _select: function( item, event ) {
482
+ var oldIndex = this.element[ 0 ].selectedIndex;
483
+
484
+ // Change native select element
485
+ this.element[ 0 ].selectedIndex = item.index;
486
+ this._setText( this.buttonText, item.label );
487
+ this._setAria( item );
488
+ this._trigger( "select", event, { item: item } );
489
+
490
+ if ( item.index !== oldIndex ) {
491
+ this._trigger( "change", event, { item: item } );
492
+ }
493
+
494
+ this.close( event );
495
+ },
496
+
497
+ _setAria: function( item ) {
498
+ var id = this.menuItems.eq( item.index ).attr( "id" );
499
+
500
+ this.button.attr({
501
+ "aria-labelledby": id,
502
+ "aria-activedescendant": id
503
+ });
504
+ this.menu.attr( "aria-activedescendant", id );
505
+ },
506
+
507
+ _setOption: function( key, value ) {
508
+ if ( key === "icons" ) {
509
+ this.button.find( "span.ui-icon" )
510
+ .removeClass( this.options.icons.button )
511
+ .addClass( value.button );
512
+ }
513
+
514
+ this._super( key, value );
515
+
516
+ if ( key === "appendTo" ) {
517
+ this.menuWrap.appendTo( this._appendTo() );
518
+ }
519
+
520
+ if ( key === "disabled" ) {
521
+ this.menuInstance.option( "disabled", value );
522
+ this.button
523
+ .toggleClass( "ui-state-disabled", value )
524
+ .attr( "aria-disabled", value );
525
+
526
+ this.element.prop( "disabled", value );
527
+ if ( value ) {
528
+ this.button.attr( "tabindex", -1 );
529
+ this.close();
530
+ } else {
531
+ this.button.attr( "tabindex", 0 );
532
+ }
533
+ }
534
+
535
+ if ( key === "width" ) {
536
+ this._resizeButton();
537
+ }
538
+ },
539
+
540
+ _appendTo: function() {
541
+ var element = this.options.appendTo;
542
+
543
+ if ( element ) {
544
+ element = element.jquery || element.nodeType ?
545
+ $( element ) :
546
+ this.document.find( element ).eq( 0 );
547
+ }
548
+
549
+ if ( !element || !element[ 0 ] ) {
550
+ element = this.element.closest( ".ui-front" );
551
+ }
552
+
553
+ if ( !element.length ) {
554
+ element = this.document[ 0 ].body;
555
+ }
556
+
557
+ return element;
558
+ },
559
+
560
+ _toggleAttr: function() {
561
+ this.button
562
+ .toggleClass( "ui-corner-top", this.isOpen )
563
+ .toggleClass( "ui-corner-all", !this.isOpen )
564
+ .attr( "aria-expanded", this.isOpen );
565
+ this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
566
+ this.menu.attr( "aria-hidden", !this.isOpen );
567
+ },
568
+
569
+ _resizeButton: function() {
570
+ var width = this.options.width;
571
+
572
+ if ( !width ) {
573
+ width = this.element.show().outerWidth();
574
+ this.element.hide();
575
+ }
576
+
577
+ this.button.outerWidth( width );
578
+ },
579
+
580
+ _resizeMenu: function() {
581
+ this.menu.outerWidth( Math.max(
582
+ this.button.outerWidth(),
583
+
584
+ // support: IE10
585
+ // IE10 wraps long text (possibly a rounding bug)
586
+ // so we add 1px to avoid the wrapping
587
+ this.menu.width( "" ).outerWidth() + 1
588
+ ) );
589
+ },
590
+
591
+ _getCreateOptions: function() {
592
+ return { disabled: this.element.prop( "disabled" ) };
593
+ },
594
+
595
+ _parseOptions: function( options ) {
596
+ var data = [];
597
+ options.each(function( index, item ) {
598
+ var option = $( item ),
599
+ optgroup = option.parent( "optgroup" );
600
+ data.push({
601
+ element: option,
602
+ index: index,
603
+ value: option.val(),
604
+ label: option.text(),
605
+ optgroup: optgroup.attr( "label" ) || "",
606
+ disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
607
+ });
608
+ });
609
+ this.items = data;
610
+ },
611
+
612
+ _destroy: function() {
613
+ this.menuWrap.remove();
614
+ this.button.remove();
615
+ this.element.show();
616
+ this.element.removeUniqueId();
617
+ this.label.attr( "for", this.ids.element );
618
+ }
619
+ });
620
+
621
+ }));