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' ) ;
79
810var SafeHTMLElement = ExecutionEnvironment . canUseDOM ? window . HTMLElement : { } ;
911
@@ -49,6 +51,12 @@ var Modal = module.exports = React.createClass({
4951 } ,
5052
5153 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+
5260 if ( props . ariaHideApp ) {
5361 ariaAppHider . toggle ( props . isOpen , props . appElement ) ;
5462 }
@@ -68,12 +76,14 @@ function sanitizeProps(props) {
6876 delete props . ref ;
6977}
7078
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 ) ;
7383var 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' ) ;
7787
7888// so that our CSS is statically analyzable
7989var CLASS_NAMES = {
@@ -231,7 +241,8 @@ var ModalPortal = module.exports = React.createClass({
231241 }
232242} ) ;
233243
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 ) {
235246var _element = null ;
236247
237248function setElement ( element ) {
@@ -270,9 +281,8 @@ exports.show = show;
270281exports . hide = hide ;
271282exports . resetForTesting = resetForTesting ;
272283
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' ) ;
276286var modalElement = null ;
277287var focusLaterElement = null ;
278288var needToFocus = false ;
@@ -339,9 +349,7 @@ exports.teardownScopedFocus = function() {
339349 }
340350} ;
341351
342-
343-
344- } , { "../helpers/tabbable" :7 } ] , 5 :[ function ( _dereq_ , module , exports ) {
352+ } , { "../helpers/tabbable" :7 } ] , 5 :[ function ( require , module , exports ) {
345353module . exports = function ( ) {
346354 injectStyle ( [
347355 '.ReactModal__Overlay {' ,
@@ -378,15 +386,20 @@ function injectStyle(css) {
378386 if ( ! style ) {
379387 style = document . createElement ( 'style' ) ;
380388 style . setAttribute ( 'id' , 'rackt-style' ) ;
381- var head = document . getElementsByTagName ( 'head' ) [ 0 ] ;
382- head . insertBefore ( style , head . firstChild ) ;
389+ style . setAttribute ( "type" , "text/css" ) ;
383390 }
384- style . innerHTML = style . innerHTML + '\n' + css ;
385- }
386391
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+ }
387400
388- } , { } ] , 6 :[ function ( _dereq_ , module , exports ) {
389- var findTabbable = _dereq_ ( '../helpers/tabbable' ) ;
401+ } , { } ] , 6 :[ function ( require , module , exports ) {
402+ var findTabbable = require ( '../helpers/tabbable' ) ;
390403
391404module . exports = function ( node , event ) {
392405 var tabbable = findTabbable ( node ) ;
@@ -402,7 +415,7 @@ module.exports = function(node, event) {
402415 target . focus ( ) ;
403416} ;
404417
405- } , { "../helpers/tabbable" :7 } ] , 7 :[ function ( _dereq_ , module , exports ) {
418+ } , { "../helpers/tabbable" :7 } ] , 7 :[ function ( require , module , exports ) {
406419/*!
407420 * Adapted from jQuery UI core
408421 *
@@ -453,59 +466,117 @@ function findTabbableDescendants(element) {
453466
454467module . exports = findTabbableDescendants ;
455468
469+ } , { } ] , 8 :[ function ( require , module , exports ) {
470+ module . exports = require ( './components/Modal' ) ;
456471
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 ) {
462473/*!
463474 Copyright (c) 2015 Jed Watson.
464475 Licensed under the MIT License (MIT), see
465476 http://jedwatson.github.io/classnames
466477*/
467478
468- function classNames ( ) {
469- var classes = '' ;
470- var arg ;
479+ ( function ( ) {
480+ 'use strict' ;
471481
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 ;
477491
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+ }
486503 }
487- classes += ' ' + key ;
488504 }
489505 }
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 ;
490519 }
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
492557}
493558
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
497568}
498569
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
504575}
505576
506- } , { } ] , 10 :[ function ( _dereq_ , module , exports ) {
577+ } , { } ] , 11 :[ function ( require , module , exports ) {
507578/**
508- * Copyright 2013-2014 , Facebook, Inc.
579+ * Copyright 2013-2015 , Facebook, Inc.
509580 * All rights reserved.
510581 *
511582 * This source code is licensed under the BSD-style license found in the
@@ -520,9 +591,8 @@ if (typeof define !== 'undefined' && define.amd) {
520591"use strict" ;
521592
522593var canUseDOM = ! ! (
523- typeof window !== 'undefined' &&
524- window . document &&
525- window . document . createElement
594+ ( typeof window !== 'undefined' &&
595+ window . document && window . document . createElement )
526596) ;
527597
528598/**
@@ -548,6 +618,5 @@ var ExecutionEnvironment = {
548618
549619module . exports = ExecutionEnvironment ;
550620
551- } , { } ] } , { } , [ 8 ] )
552- ( 8 )
621+ } , { } ] } , { } , [ 8 ] ) ( 8 )
553622} ) ;
0 commit comments