1
- ! function ( e ) { if ( "object" == typeof exports && "undefined" != typeof module ) module . exports = e ( ) ; else if ( "function" == typeof define && define . amd ) define ( [ ] , e ) ; else { var f ; "undefined" != typeof window ?f = window :"undefined" != typeof global ?f = global :"undefined" != typeof self && ( f = self ) , f . ReactModal = e ( ) } } ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; throw new Error ( "Cannot find module '" + o + "'" ) } var f = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( f . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , f , f . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( _dereq_ , module , exports ) {
2
- var React = ( typeof window !== "undefined" ? window . React : typeof global !== "undefined" ? global . React : null ) ;
3
- var ExecutionEnvironment = _dereq_ ( 'react/lib/ExecutionEnvironment' ) ;
4
- var ModalPortal = React . createFactory ( _dereq_ ( './ModalPortal' ) ) ;
5
- var ariaAppHider = _dereq_ ( '../helpers/ariaAppHider' ) ;
6
- var injectCSS = _dereq_ ( '../helpers/injectCSS' ) ;
1
+ ( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . ReactModal = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
2
+ ( function ( global ) {
3
+ var React = ( typeof window !== "undefined" ? window [ 'React' ] : typeof global !== "undefined" ? global [ 'React' ] : null ) ;
4
+ var ExecutionEnvironment = require ( 'react/lib/ExecutionEnvironment' ) ;
5
+ var ModalPortal = React . createFactory ( require ( './ModalPortal' ) ) ;
6
+ var ariaAppHider = require ( '../helpers/ariaAppHider' ) ;
7
+ var injectCSS = require ( '../helpers/injectCSS' ) ;
8
+ var elementClass = require ( 'element-class' ) ;
7
9
8
10
var SafeHTMLElement = ExecutionEnvironment . canUseDOM ? window . HTMLElement : { } ;
9
11
@@ -49,6 +51,12 @@ var Modal = module.exports = React.createClass({
49
51
} ,
50
52
51
53
renderPortal : function ( props ) {
54
+ if ( props . isOpen ) {
55
+ elementClass ( document . body ) . add ( 'ReactModal__Body--open' ) ;
56
+ } else {
57
+ elementClass ( document . body ) . remove ( 'ReactModal__Body--open' ) ;
58
+ }
59
+
52
60
if ( props . ariaHideApp ) {
53
61
ariaAppHider . toggle ( props . isOpen , props . appElement ) ;
54
62
}
@@ -68,12 +76,14 @@ function sanitizeProps(props) {
68
76
delete props . ref ;
69
77
}
70
78
71
- } , { "../helpers/ariaAppHider" :3 , "../helpers/injectCSS" :5 , "./ModalPortal" :2 , "react/lib/ExecutionEnvironment" :10 } ] , 2 :[ function ( _dereq_ , module , exports ) {
72
- var React = ( typeof window !== "undefined" ? window . React : typeof global !== "undefined" ? global . React : null ) ;
79
+ } ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
80
+ } , { "../helpers/ariaAppHider" :3 , "../helpers/injectCSS" :5 , "./ModalPortal" :2 , "element-class" :10 , "react/lib/ExecutionEnvironment" :11 } ] , 2 :[ function ( require , module , exports ) {
81
+ ( function ( global ) {
82
+ var React = ( typeof window !== "undefined" ? window [ 'React' ] : typeof global !== "undefined" ? global [ 'React' ] : null ) ;
73
83
var div = React . DOM . div ;
74
- var focusManager = _dereq_ ( '../helpers/focusManager' ) ;
75
- var scopeTab = _dereq_ ( '../helpers/scopeTab' ) ;
76
- var cx = _dereq_ ( 'classnames' ) ;
84
+ var focusManager = require ( '../helpers/focusManager' ) ;
85
+ var scopeTab = require ( '../helpers/scopeTab' ) ;
86
+ var cx = require ( 'classnames' ) ;
77
87
78
88
// so that our CSS is statically analyzable
79
89
var CLASS_NAMES = {
@@ -231,7 +241,8 @@ var ModalPortal = module.exports = React.createClass({
231
241
}
232
242
} ) ;
233
243
234
- } , { "../helpers/focusManager" :4 , "../helpers/scopeTab" :6 , "classnames" :9 } ] , 3 :[ function ( _dereq_ , module , exports ) {
244
+ } ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
245
+ } , { "../helpers/focusManager" :4 , "../helpers/scopeTab" :6 , "classnames" :9 } ] , 3 :[ function ( require , module , exports ) {
235
246
var _element = null ;
236
247
237
248
function setElement ( element ) {
@@ -270,9 +281,8 @@ exports.show = show;
270
281
exports . hide = hide ;
271
282
exports . resetForTesting = resetForTesting ;
272
283
273
-
274
- } , { } ] , 4 :[ function ( _dereq_ , module , exports ) {
275
- var findTabbable = _dereq_ ( '../helpers/tabbable' ) ;
284
+ } , { } ] , 4 :[ function ( require , module , exports ) {
285
+ var findTabbable = require ( '../helpers/tabbable' ) ;
276
286
var modalElement = null ;
277
287
var focusLaterElement = null ;
278
288
var needToFocus = false ;
@@ -339,9 +349,7 @@ exports.teardownScopedFocus = function() {
339
349
}
340
350
} ;
341
351
342
-
343
-
344
- } , { "../helpers/tabbable" :7 } ] , 5 :[ function ( _dereq_ , module , exports ) {
352
+ } , { "../helpers/tabbable" :7 } ] , 5 :[ function ( require , module , exports ) {
345
353
module . exports = function ( ) {
346
354
injectStyle ( [
347
355
'.ReactModal__Overlay {' ,
@@ -378,15 +386,20 @@ function injectStyle(css) {
378
386
if ( ! style ) {
379
387
style = document . createElement ( 'style' ) ;
380
388
style . setAttribute ( 'id' , 'rackt-style' ) ;
381
- var head = document . getElementsByTagName ( 'head' ) [ 0 ] ;
382
- head . insertBefore ( style , head . firstChild ) ;
389
+ style . setAttribute ( "type" , "text/css" ) ;
383
390
}
384
- style . innerHTML = style . innerHTML + '\n' + css ;
385
- }
386
391
392
+ if ( style . styleSheet ) {
393
+ style . styleSheet . cssText = css ;
394
+ document . body . appendChild ( style ) ;
395
+ } else {
396
+ style . innerHTML = css ;
397
+ document . head . appendChild ( style ) ;
398
+ }
399
+ }
387
400
388
- } , { } ] , 6 :[ function ( _dereq_ , module , exports ) {
389
- var findTabbable = _dereq_ ( '../helpers/tabbable' ) ;
401
+ } , { } ] , 6 :[ function ( require , module , exports ) {
402
+ var findTabbable = require ( '../helpers/tabbable' ) ;
390
403
391
404
module . exports = function ( node , event ) {
392
405
var tabbable = findTabbable ( node ) ;
@@ -402,7 +415,7 @@ module.exports = function(node, event) {
402
415
target . focus ( ) ;
403
416
} ;
404
417
405
- } , { "../helpers/tabbable" :7 } ] , 7 :[ function ( _dereq_ , module , exports ) {
418
+ } , { "../helpers/tabbable" :7 } ] , 7 :[ function ( require , module , exports ) {
406
419
/*!
407
420
* Adapted from jQuery UI core
408
421
*
@@ -453,59 +466,117 @@ function findTabbableDescendants(element) {
453
466
454
467
module . exports = findTabbableDescendants ;
455
468
469
+ } , { } ] , 8 :[ function ( require , module , exports ) {
470
+ module . exports = require ( './components/Modal' ) ;
456
471
457
- } , { } ] , 8 :[ function ( _dereq_ , module , exports ) {
458
- module . exports = _dereq_ ( './components/Modal' ) ;
459
-
460
-
461
- } , { "./components/Modal" :1 } ] , 9 :[ function ( _dereq_ , module , exports ) {
472
+ } , { "./components/Modal" :1 } ] , 9 :[ function ( require , module , exports ) {
462
473
/*!
463
474
Copyright (c) 2015 Jed Watson.
464
475
Licensed under the MIT License (MIT), see
465
476
http://jedwatson.github.io/classnames
466
477
*/
467
478
468
- function classNames ( ) {
469
- var classes = '' ;
470
- var arg ;
479
+ ( function ( ) {
480
+ 'use strict' ;
471
481
472
- for ( var i = 0 ; i < arguments . length ; i ++ ) {
473
- arg = arguments [ i ] ;
474
- if ( ! arg ) {
475
- continue ;
476
- }
482
+ function classNames ( ) {
483
+
484
+ var classes = '' ;
485
+
486
+ for ( var i = 0 ; i < arguments . length ; i ++ ) {
487
+ var arg = arguments [ i ] ;
488
+ if ( ! arg ) continue ;
489
+
490
+ var argType = typeof arg ;
477
491
478
- if ( 'string' === typeof arg || 'number' === typeof arg ) {
479
- classes += ' ' + arg ;
480
- } else if ( Object . prototype . toString . call ( arg ) === '[object Array]' ) {
481
- classes += ' ' + classNames . apply ( null , arg ) ;
482
- } else if ( 'object' === typeof arg ) {
483
- for ( var key in arg ) {
484
- if ( ! arg . hasOwnProperty ( key ) || ! arg [ key ] ) {
485
- continue ;
492
+ if ( 'string' === argType || 'number' === argType ) {
493
+ classes += ' ' + arg ;
494
+
495
+ } else if ( Array . isArray ( arg ) ) {
496
+ classes += ' ' + classNames . apply ( null , arg ) ;
497
+
498
+ } else if ( 'object' === argType ) {
499
+ for ( var key in arg ) {
500
+ if ( arg . hasOwnProperty ( key ) && arg [ key ] ) {
501
+ classes += ' ' + key ;
502
+ }
486
503
}
487
- classes += ' ' + key ;
488
504
}
489
505
}
506
+
507
+ return classes . substr ( 1 ) ;
508
+ }
509
+
510
+ if ( typeof module !== 'undefined' && module . exports ) {
511
+ module . exports = classNames ;
512
+ } else if ( typeof define === 'function' && typeof define . amd === 'object' && define . amd ) {
513
+ // AMD. Register as an anonymous module.
514
+ define ( function ( ) {
515
+ return classNames ;
516
+ } ) ;
517
+ } else {
518
+ window . classNames = classNames ;
490
519
}
491
- return classes . substr ( 1 ) ;
520
+
521
+ } ( ) ) ;
522
+
523
+ } , { } ] , 10 :[ function ( require , module , exports ) {
524
+ module . exports = function ( opts ) {
525
+ return new ElementClass ( opts )
526
+ }
527
+
528
+ function indexOf ( arr , prop ) {
529
+ if ( arr . indexOf ) return arr . indexOf ( prop )
530
+ for ( var i = 0 , len = arr . length ; i < len ; i ++ )
531
+ if ( arr [ i ] === prop ) return i
532
+ return - 1
533
+ }
534
+
535
+ function ElementClass ( opts ) {
536
+ if ( ! ( this instanceof ElementClass ) ) return new ElementClass ( opts )
537
+ var self = this
538
+ if ( ! opts ) opts = { }
539
+
540
+ // similar doing instanceof HTMLElement but works in IE8
541
+ if ( opts . nodeType ) opts = { el : opts }
542
+
543
+ this . opts = opts
544
+ this . el = opts . el || document . body
545
+ if ( typeof this . el !== 'object' ) this . el = document . querySelector ( this . el )
546
+ }
547
+
548
+ ElementClass . prototype . add = function ( className ) {
549
+ var el = this . el
550
+ if ( ! el ) return
551
+ if ( el . className === "" ) return el . className = className
552
+ var classes = el . className . split ( ' ' )
553
+ if ( indexOf ( classes , className ) > - 1 ) return classes
554
+ classes . push ( className )
555
+ el . className = classes . join ( ' ' )
556
+ return classes
492
557
}
493
558
494
- // safely export classNames for node / browserify
495
- if ( typeof module !== 'undefined' && module . exports ) {
496
- module . exports = classNames ;
559
+ ElementClass . prototype . remove = function ( className ) {
560
+ var el = this . el
561
+ if ( ! el ) return
562
+ if ( el . className === "" ) return
563
+ var classes = el . className . split ( ' ' )
564
+ var idx = indexOf ( classes , className )
565
+ if ( idx > - 1 ) classes . splice ( idx , 1 )
566
+ el . className = classes . join ( ' ' )
567
+ return classes
497
568
}
498
569
499
- // safely export classNames for RequireJS
500
- if ( typeof define !== 'undefined' && define . amd ) {
501
- define ( 'classnames' , [ ] , function ( ) {
502
- return classNames ;
503
- } ) ;
570
+ ElementClass . prototype . has = function ( className ) {
571
+ var el = this . el
572
+ if ( ! el ) return
573
+ var classes = el . className . split ( ' ' )
574
+ return indexOf ( classes , className ) > - 1
504
575
}
505
576
506
- } , { } ] , 10 :[ function ( _dereq_ , module , exports ) {
577
+ } , { } ] , 11 :[ function ( require , module , exports ) {
507
578
/**
508
- * Copyright 2013-2014 , Facebook, Inc.
579
+ * Copyright 2013-2015 , Facebook, Inc.
509
580
* All rights reserved.
510
581
*
511
582
* This source code is licensed under the BSD-style license found in the
@@ -520,9 +591,8 @@ if (typeof define !== 'undefined' && define.amd) {
520
591
"use strict" ;
521
592
522
593
var canUseDOM = ! ! (
523
- typeof window !== 'undefined' &&
524
- window . document &&
525
- window . document . createElement
594
+ ( typeof window !== 'undefined' &&
595
+ window . document && window . document . createElement )
526
596
) ;
527
597
528
598
/**
@@ -548,6 +618,5 @@ var ExecutionEnvironment = {
548
618
549
619
module . exports = ExecutionEnvironment ;
550
620
551
- } , { } ] } , { } , [ 8 ] )
552
- ( 8 )
621
+ } , { } ] } , { } , [ 8 ] ) ( 8 )
553
622
} ) ;
0 commit comments