@@ -77,15 +77,17 @@ var CLASS_NAMES = {
77
77
overlay : {
78
78
base : 'ReactModal__Overlay' ,
79
79
afterOpen : 'ReactModal__Overlay--after-open' ,
80
- beforeClose : 'ReactModal__Overlay--before-close' ,
80
+ beforeClose : 'ReactModal__Overlay--before-close'
81
81
} ,
82
82
content : {
83
83
base : 'ReactModal__Content' ,
84
84
afterOpen : 'ReactModal__Content--after-open' ,
85
- beforeClose : 'ReactModal__Content--before-close' ,
85
+ beforeClose : 'ReactModal__Content--before-close'
86
86
}
87
87
} ;
88
88
89
+ var OVERLAY_STYLES = { position : 'fixed' , left : 0 , right : 0 , top : 0 , bottom : 0 } ;
90
+
89
91
function stopPropagation ( event ) {
90
92
event . stopPropagation ( ) ;
91
93
}
@@ -170,7 +172,7 @@ var ModalPortal = module.exports = React.createClass({
170
172
} ,
171
173
172
174
handleKeyDown : function ( event ) {
173
- if ( event . keyCode == 9 /*tab*/ ) scopeTab ( this . getDOMNode ( ) , event ) ;
175
+ if ( event . keyCode == 9 /*tab*/ ) scopeTab ( this . refs . content . getDOMNode ( ) , event ) ;
174
176
if ( event . keyCode == 27 /*esc*/ ) this . requestClose ( ) ;
175
177
} ,
176
178
@@ -194,8 +196,6 @@ var ModalPortal = module.exports = React.createClass({
194
196
return ! this . props . isOpen && ! this . state . beforeClose ;
195
197
} ,
196
198
197
- overlayStyles : { position : 'fixed' , left : 0 , right : 0 , top : 0 , bottom : 0 } ,
198
-
199
199
buildClassName : function ( which ) {
200
200
var className = CLASS_NAMES [ which ] . base ;
201
201
if ( this . state . afterOpen )
@@ -210,7 +210,7 @@ var ModalPortal = module.exports = React.createClass({
210
210
div ( {
211
211
ref : "overlay" ,
212
212
className : cx ( this . buildClassName ( 'overlay' ) , this . props . overlayClassName ) ,
213
- style : this . overlayStyles ,
213
+ style : OVERLAY_STYLES ,
214
214
onClick : this . handleOverlayClick
215
215
} ,
216
216
div ( {
@@ -310,17 +310,30 @@ exports.returnFocus = function() {
310
310
311
311
exports . setupScopedFocus = function ( element ) {
312
312
modalElement = element ;
313
- window . addEventListener ( 'blur' , handleBlur , false ) ;
314
- document . addEventListener ( 'focus' , handleFocus , true ) ;
313
+
314
+ if ( window . addEventListener ) {
315
+ window . addEventListener ( 'blur' , handleBlur , false ) ;
316
+ document . addEventListener ( 'focus' , handleFocus , true ) ;
317
+ } else {
318
+ window . attachEvent ( 'onBlur' , handleBlur ) ;
319
+ document . attachEvent ( 'onFocus' , handleFocus ) ;
320
+ }
315
321
} ;
316
322
317
323
exports . teardownScopedFocus = function ( ) {
318
324
modalElement = null ;
319
- window . removeEventListener ( 'blur' , handleBlur ) ;
320
- document . removeEventListener ( 'focus' , handleFocus ) ;
325
+
326
+ if ( window . addEventListener ) {
327
+ window . removeEventListener ( 'blur' , handleBlur ) ;
328
+ document . removeEventListener ( 'focus' , handleFocus ) ;
329
+ } else {
330
+ window . detachEvent ( 'onBlur' , handleBlur ) ;
331
+ document . detachEvent ( 'onFocus' , handleFocus ) ;
332
+ }
321
333
} ;
322
334
323
335
336
+
324
337
} , { "../helpers/tabbable" :7 } ] , 5 :[ function ( _dereq_ , module , exports ) {
325
338
module . exports = function ( ) {
326
339
injectStyle ( [
@@ -440,7 +453,7 @@ module.exports = _dereq_('./components/Modal');
440
453
441
454
} , { "./components/Modal" :1 } ] , 9 :[ function ( _dereq_ , module , exports ) {
442
455
/**
443
- * Copyright 2013-2014 , Facebook, Inc.
456
+ * Copyright 2013-2015 , Facebook, Inc.
444
457
* All rights reserved.
445
458
*
446
459
* This source code is licensed under the BSD-style license found in the
@@ -465,7 +478,22 @@ module.exports = _dereq_('./components/Modal');
465
478
* @param [string ...] Variable list of classNames in the string case.
466
479
* @return string Renderable space-separated CSS className.
467
480
*/
481
+
482
+ 'use strict' ;
483
+ var warning = _dereq_ ( "./warning" ) ;
484
+
485
+ var warned = false ;
486
+
468
487
function cx ( classNames ) {
488
+ if ( "production" !== "production" ) {
489
+ ( "production" !== "production" ? warning (
490
+ warned ,
491
+ 'React.addons.classSet will be deprecated in a future version. See ' +
492
+ 'http://fb.me/react-addons-classset'
493
+ ) : null ) ;
494
+ warned = true ;
495
+ }
496
+
469
497
if ( typeof classNames == 'object' ) {
470
498
return Object . keys ( classNames ) . filter ( function ( className ) {
471
499
return classNames [ className ] ;
@@ -477,6 +505,101 @@ function cx(classNames) {
477
505
478
506
module . exports = cx ;
479
507
480
- } , { } ] } , { } , [ 8 ] )
508
+ } , { "./warning" :11 } ] , 10 :[ function ( _dereq_ , module , exports ) {
509
+ /**
510
+ * Copyright 2013-2015, Facebook, Inc.
511
+ * All rights reserved.
512
+ *
513
+ * This source code is licensed under the BSD-style license found in the
514
+ * LICENSE file in the root directory of this source tree. An additional grant
515
+ * of patent rights can be found in the PATENTS file in the same directory.
516
+ *
517
+ * @providesModule emptyFunction
518
+ */
519
+
520
+ function makeEmptyFunction ( arg ) {
521
+ return function ( ) {
522
+ return arg ;
523
+ } ;
524
+ }
525
+
526
+ /**
527
+ * This function accepts and discards inputs; it has no side effects. This is
528
+ * primarily useful idiomatically for overridable function endpoints which
529
+ * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
530
+ */
531
+ function emptyFunction ( ) { }
532
+
533
+ emptyFunction . thatReturns = makeEmptyFunction ;
534
+ emptyFunction . thatReturnsFalse = makeEmptyFunction ( false ) ;
535
+ emptyFunction . thatReturnsTrue = makeEmptyFunction ( true ) ;
536
+ emptyFunction . thatReturnsNull = makeEmptyFunction ( null ) ;
537
+ emptyFunction . thatReturnsThis = function ( ) { return this ; } ;
538
+ emptyFunction . thatReturnsArgument = function ( arg ) { return arg ; } ;
539
+
540
+ module . exports = emptyFunction ;
541
+
542
+ } , { } ] , 11 :[ function ( _dereq_ , module , exports ) {
543
+ /**
544
+ * Copyright 2014-2015, Facebook, Inc.
545
+ * All rights reserved.
546
+ *
547
+ * This source code is licensed under the BSD-style license found in the
548
+ * LICENSE file in the root directory of this source tree. An additional grant
549
+ * of patent rights can be found in the PATENTS file in the same directory.
550
+ *
551
+ * @providesModule warning
552
+ */
553
+
554
+ "use strict" ;
555
+
556
+ var emptyFunction = _dereq_ ( "./emptyFunction" ) ;
557
+
558
+ /**
559
+ * Similar to invariant but only logs a warning if the condition is not met.
560
+ * This can be used to log issues in development environments in critical
561
+ * paths. Removing the logging code for production environments will keep the
562
+ * same logic and follow the same code paths.
563
+ */
564
+
565
+ var warning = emptyFunction ;
566
+
567
+ if ( "production" !== "production" ) {
568
+ warning = function ( condition , format ) { for ( var args = [ ] , $__0 = 2 , $__1 = arguments . length ; $__0 < $__1 ; $__0 ++ ) args . push ( arguments [ $__0 ] ) ;
569
+ if ( format === undefined ) {
570
+ throw new Error (
571
+ '`warning(condition, format, ...args)` requires a warning ' +
572
+ 'message argument'
573
+ ) ;
574
+ }
575
+
576
+ if ( format . length < 10 || / ^ [ s \W ] * $ / . test ( format ) ) {
577
+ throw new Error (
578
+ 'The warning format should be able to uniquely identify this ' +
579
+ 'warning. Please, use a more descriptive format than: ' + format
580
+ ) ;
581
+ }
582
+
583
+ if ( format . indexOf ( 'Failed Composite propType: ' ) === 0 ) {
584
+ return ; // Ignore CompositeComponent proptype check.
585
+ }
586
+
587
+ if ( ! condition ) {
588
+ var argIndex = 0 ;
589
+ var message = 'Warning: ' + format . replace ( / % s / g, function ( ) { return args [ argIndex ++ ] ; } ) ;
590
+ console . warn ( message ) ;
591
+ try {
592
+ // --- Welcome to debugging React ---
593
+ // This error was thrown as a convenience so that you can use this stack
594
+ // to find the callsite that caused this warning to fire.
595
+ throw new Error ( message ) ;
596
+ } catch ( x ) { }
597
+ }
598
+ } ;
599
+ }
600
+
601
+ module . exports = warning ;
602
+
603
+ } , { "./emptyFunction" :10 } ] } , { } , [ 8 ] )
481
604
( 8 )
482
605
} ) ;
0 commit comments