|
1 | 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.simpleModal = 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 | 2 | (function (global){ |
3 | | -"use strict"; |
| 3 | +'use strict'; |
4 | 4 |
|
5 | | -Object.defineProperty(exports, "__esModule", { |
| 5 | +Object.defineProperty(exports, '__esModule', { |
6 | 6 | value: true |
7 | 7 | }); |
8 | 8 |
|
9 | 9 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
10 | 10 |
|
11 | | -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
| 11 | +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
12 | 12 |
|
13 | | -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; |
| 13 | +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; |
14 | 14 |
|
15 | | -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
| 15 | +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
16 | 16 |
|
17 | | -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 17 | +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } |
18 | 18 |
|
19 | | -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
| 19 | +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
20 | 20 |
|
21 | 21 | var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); |
22 | 22 |
|
23 | 23 | var _react2 = _interopRequireDefault(_react); |
24 | 24 |
|
| 25 | +var modalClass = { |
| 26 | + position: 'fixed', |
| 27 | + 'font-family': 'Arial, Helvetica, sans-serif', |
| 28 | + top: 0, |
| 29 | + right: 0, |
| 30 | + bottom: 0, |
| 31 | + left: 0, |
| 32 | + background: 'rgba(0, 0, 0, 0.8)', |
| 33 | + 'z-index': 99999, |
| 34 | + opacity: 0, |
| 35 | + transition: 'opacity 400ms ease-in', |
| 36 | + opacity: 1, |
| 37 | + 'pointer-events': 'auto' |
| 38 | +}; |
| 39 | + |
| 40 | +exports.modalClass = modalClass; |
| 41 | +var containerClass = { |
| 42 | + width: '400px', |
| 43 | + position: 'relative', |
| 44 | + margin: '10% auto', |
| 45 | + padding: '5px 20px 13px 20px', |
| 46 | + background: '#fff' |
| 47 | +}; |
| 48 | + |
| 49 | +exports.containerClass = containerClass; |
| 50 | +var closeClass = { |
| 51 | + background: '#606061', |
| 52 | + color: '#FFFFFF', |
| 53 | + 'line-height': '25px', |
| 54 | + position: 'absolute', |
| 55 | + right: '-12px', |
| 56 | + 'text-align': 'center', |
| 57 | + top: '-10px', |
| 58 | + width: '24px', |
| 59 | + 'text-decoration': 'none', |
| 60 | + 'font-weight': 'bold', |
| 61 | + borderRadius: '12px', |
| 62 | + boxDhadow: '1px 1px 3px #000', |
| 63 | + cursor: 'pointer' |
| 64 | +}; |
| 65 | + |
| 66 | +exports.closeClass = closeClass; |
| 67 | + |
25 | 68 | var Modal = (function (_React$Component) { |
26 | 69 | _inherits(Modal, _React$Component); |
27 | 70 |
|
28 | 71 | function Modal(props) { |
29 | 72 | _classCallCheck(this, Modal); |
30 | 73 |
|
31 | | - _get(Object.getPrototypeOf(Modal.prototype), "constructor", this).call(this); |
| 74 | + _get(Object.getPrototypeOf(Modal.prototype), 'constructor', this).call(this); |
32 | 75 | this.hideOnOuterClick = this.hideOnOuterClick.bind(this); |
33 | 76 | } |
34 | 77 |
|
35 | 78 | _createClass(Modal, [{ |
36 | | - key: "hideOnOuterClick", |
| 79 | + key: 'hideOnOuterClick', |
37 | 80 | value: function hideOnOuterClick(event) { |
38 | 81 | if (!this.props.closeOnOuterClick) return; |
39 | 82 | if (event.target.dataset.modal) this.props.onClose(event); |
40 | 83 | } |
41 | 84 | }, { |
42 | | - key: "render", |
| 85 | + key: 'render', |
43 | 86 | value: function render() { |
44 | 87 | if (!this.props.show) return null; |
45 | | - return _react2["default"].createElement( |
46 | | - "div", |
47 | | - _extends({}, this.props, { onClick: this.hideOnOuterClick, "data-modal": "true" }), |
48 | | - _react2["default"].createElement( |
49 | | - "div", |
50 | | - null, |
| 88 | + var modal = modalClass; |
| 89 | + var container = containerClass; |
| 90 | + |
| 91 | + if (this.props.className) { |
| 92 | + modal = null; |
| 93 | + container = null; |
| 94 | + } |
| 95 | + |
| 96 | + return _react2['default'].createElement( |
| 97 | + 'div', |
| 98 | + _extends({}, this.props, { style: modal, onClick: this.hideOnOuterClick, 'data-modal': "true" }), |
| 99 | + _react2['default'].createElement( |
| 100 | + 'div', |
| 101 | + { style: container }, |
51 | 102 | this.props.children |
52 | 103 | ) |
53 | 104 | ); |
54 | 105 | } |
55 | 106 | }]); |
56 | 107 |
|
57 | 108 | return Modal; |
58 | | -})(_react2["default"].Component); |
| 109 | +})(_react2['default'].Component); |
59 | 110 |
|
60 | | -exports["default"] = Modal; |
61 | | -module.exports = exports["default"]; |
| 111 | +exports['default'] = Modal; |
62 | 112 |
|
63 | 113 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
64 | 114 | },{}]},{},[1])(1) |
|
0 commit comments