From c408801447a497ecc192aec8eb3c2e4900d987c0 Mon Sep 17 00:00:00 2001 From: deranjer Date: Sun, 17 Dec 2017 21:40:00 -0500 Subject: [PATCH] seperating react files, starting to fix top menu. --- main.go | 8 + public/static/js/bundle.js | 3066 +++++++++-------- .../src/BackendComm/backendWebsocket.js | 124 + .../src/BottomMenu/Tabs/generalTab.js | 18 + torrent-project/src/BottomMenu/bottomMenu.js | 4 +- torrent-project/src/CSS/topMenu.css | 9 + torrent-project/src/store/actions.js | 2 + torrent-project/src/store/reducer.js | 21 +- torrent-project/src/topMenu.js | 57 +- torrent-project/src/torrentlist.js | 167 +- 10 files changed, 1851 insertions(+), 1625 deletions(-) create mode 100644 torrent-project/src/BackendComm/backendWebsocket.js create mode 100644 torrent-project/src/CSS/topMenu.css diff --git a/main.go b/main.go index 3833fb51..d1c26973 100644 --- a/main.go +++ b/main.go @@ -395,6 +395,14 @@ func main() { startTorrent(clientTorrent, torrentLocalStorage, db, Config.DataDir, "magnet", "") //starting the torrent and creating local DB entry + } else if string(msg) == "torrentFileListRequest" { //client requested a filelist update + fmt.Println("client Requested Filelist update") + err = conn.WriteMessage(msgType, []byte("fileListUpdate")) + if err != nil { + fmt.Println("Websocket Write err", err) + return + } + } else { conn.Close() fmt.Println(string(msg)) diff --git a/public/static/js/bundle.js b/public/static/js/bundle.js index 93765b65..47e90128 100644 --- a/public/static/js/bundle.js +++ b/public/static/js/bundle.js @@ -433,7 +433,7 @@ var _contextTypes = __webpack_require__(459); var _contextTypes2 = _interopRequireDefault(_contextTypes); -var _jss = __webpack_require__(118); +var _jss = __webpack_require__(119); var _jssPresetDefault = __webpack_require__(226); @@ -443,11 +443,11 @@ var _ns = __webpack_require__(227); var ns = _interopRequireWildcard(_ns); -var _createMuiTheme = __webpack_require__(124); +var _createMuiTheme = __webpack_require__(125); var _createMuiTheme2 = _interopRequireDefault(_createMuiTheme); -var _themeListener = __webpack_require__(117); +var _themeListener = __webpack_require__(118); var _themeListener2 = _interopRequireDefault(_themeListener); @@ -792,7 +792,7 @@ exports.default = withStyles; exports.__esModule = true; -var _defineProperty = __webpack_require__(107); +var _defineProperty = __webpack_require__(108); var _defineProperty2 = _interopRequireDefault(_defineProperty); @@ -898,7 +898,7 @@ exports.default = function (instance, Constructor) { exports.__esModule = true; -var _defineProperty = __webpack_require__(107); +var _defineProperty = __webpack_require__(108); var _defineProperty2 = _interopRequireDefault(_defineProperty); @@ -1010,11 +1010,11 @@ if (process.env.NODE_ENV !== 'production') { // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; - module.exports = __webpack_require__(614)(isValidElement, throwOnDirectAccess); + module.exports = __webpack_require__(617)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod - module.exports = __webpack_require__(617)(); + module.exports = __webpack_require__(620)(); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) @@ -1582,7 +1582,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! /* 25 */ /***/ (function(module, exports, __webpack_require__) { -var store = __webpack_require__(104)('wks'); +var store = __webpack_require__(105)('wks'); var uid = __webpack_require__(68); var Symbol = __webpack_require__(29).Symbol; var USE_SYMBOL = typeof Symbol == 'function'; @@ -1601,7 +1601,7 @@ $exports.store = store; var anObject = __webpack_require__(41); var IE8_DOM_DEFINE = __webpack_require__(193); -var toPrimitive = __webpack_require__(98); +var toPrimitive = __webpack_require__(99); var dP = Object.defineProperty; exports.f = __webpack_require__(30) ? Object.defineProperty : function defineProperty(O, P, Attributes) { @@ -2218,7 +2218,7 @@ Object.defineProperty(exports, 'withStyles', { } }); -var _withTheme = __webpack_require__(60); +var _withTheme = __webpack_require__(62); Object.defineProperty(exports, 'withTheme', { enumerable: true, @@ -2227,7 +2227,7 @@ Object.defineProperty(exports, 'withTheme', { } }); -var _createMuiTheme = __webpack_require__(124); +var _createMuiTheme = __webpack_require__(125); Object.defineProperty(exports, 'createMuiTheme', { enumerable: true, @@ -2243,7 +2243,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de /***/ (function(module, exports, __webpack_require__) { var dP = __webpack_require__(26); -var createDesc = __webpack_require__(57); +var createDesc = __webpack_require__(59); module.exports = __webpack_require__(30) ? function (object, key, value) { return dP.f(object, key, createDesc(1, value)); } : function (object, key, value) { @@ -2439,7 +2439,7 @@ module.exports = exports['default']; /* 47 */ /***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(130), +var isObject = __webpack_require__(131), now = __webpack_require__(515), toNumber = __webpack_require__(517); @@ -2691,8 +2691,8 @@ if (process.env.NODE_ENV !== 'production') { /***/ (function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = __webpack_require__(99); -var defined = __webpack_require__(101); +var IObject = __webpack_require__(100); +var defined = __webpack_require__(102); module.exports = function (it) { return IObject(defined(it)); }; @@ -2703,7 +2703,7 @@ module.exports = function (it) { /***/ (function(module, exports, __webpack_require__) { // 7.1.13 ToObject(argument) -var defined = __webpack_require__(101); +var defined = __webpack_require__(102); module.exports = function (it) { return Object(defined(it)); }; @@ -3071,7 +3071,7 @@ exports.synchronizeLayoutWithChildren = synchronizeLayoutWithChildren; exports.validateLayout = validateLayout; exports.autoBindHandlers = autoBindHandlers; -var _lodash = __webpack_require__(88); +var _lodash = __webpack_require__(89); var _lodash2 = _interopRequireDefault(_lodash); @@ -3556,6 +3556,41 @@ function autoBindHandlers(el, fns) { /***/ }), /* 57 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_Provider__ = __webpack_require__(348); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_connectAdvanced__ = __webpack_require__(187); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__connect_connect__ = __webpack_require__(356); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Provider", function() { return __WEBPACK_IMPORTED_MODULE_0__components_Provider__["b"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "createProvider", function() { return __WEBPACK_IMPORTED_MODULE_0__components_Provider__["a"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "connectAdvanced", function() { return __WEBPACK_IMPORTED_MODULE_1__components_connectAdvanced__["a"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "connect", function() { return __WEBPACK_IMPORTED_MODULE_2__connect_connect__["a"]; }); + + + + + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var SORTLIST = exports.SORTLIST = 'SORTLIST'; +var CHANGE_SELECTION = exports.CHANGE_SELECTION = 'CHANGE_SELECTION'; +var CHANGE_FILTER = exports.CHANGE_FILTER = 'CHANGE_FILTER'; +var TORRENT_LIST = exports.TORRENT_LIST = 'TORRENT_LIST'; +var SET_BUTTON_STATE = exports.SET_BUTTON_STATE = 'BUTTON_STATE'; + +/***/ }), +/* 59 */ /***/ (function(module, exports) { module.exports = function (bitmap, value) { @@ -3569,12 +3604,12 @@ module.exports = function (bitmap, value) { /***/ }), -/* 58 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(195); -var enumBugKeys = __webpack_require__(105); +var enumBugKeys = __webpack_require__(106); module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); @@ -3582,14 +3617,14 @@ module.exports = Object.keys || function keys(O) { /***/ }), -/* 59 */ +/* 61 */ /***/ (function(module, exports) { module.exports = {}; /***/ }), -/* 60 */ +/* 62 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3631,11 +3666,11 @@ var _wrapDisplayName = __webpack_require__(52); var _wrapDisplayName2 = _interopRequireDefault(_wrapDisplayName); -var _createMuiTheme = __webpack_require__(124); +var _createMuiTheme = __webpack_require__(125); var _createMuiTheme2 = _interopRequireDefault(_createMuiTheme); -var _themeListener = __webpack_require__(117); +var _themeListener = __webpack_require__(118); var _themeListener2 = _interopRequireDefault(_themeListener); @@ -3723,7 +3758,7 @@ var withTheme = function withTheme() { exports.default = withTheme; /***/ }), -/* 61 */ +/* 63 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3733,7 +3768,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Input = __webpack_require__(129); +var _Input = __webpack_require__(130); Object.defineProperty(exports, 'default', { enumerable: true, @@ -3763,7 +3798,7 @@ Object.defineProperty(exports, 'InputLabel', { function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), -/* 62 */ +/* 64 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3805,7 +3840,7 @@ emptyFunction.thatReturnsArgument = function (arg) { module.exports = emptyFunction; /***/ }), -/* 63 */ +/* 65 */ /***/ (function(module, exports) { /* @@ -3887,7 +3922,7 @@ function toComment(sourceMap) { /***/ }), -/* 64 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { /* @@ -4258,45 +4293,12 @@ function updateLink (link, options, obj) { } -/***/ }), -/* 65 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_Provider__ = __webpack_require__(348); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_connectAdvanced__ = __webpack_require__(187); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__connect_connect__ = __webpack_require__(356); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Provider", function() { return __WEBPACK_IMPORTED_MODULE_0__components_Provider__["b"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "createProvider", function() { return __WEBPACK_IMPORTED_MODULE_0__components_Provider__["a"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "connectAdvanced", function() { return __WEBPACK_IMPORTED_MODULE_1__components_connectAdvanced__["a"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "connect", function() { return __WEBPACK_IMPORTED_MODULE_2__connect_connect__["a"]; }); - - - - - - -/***/ }), -/* 66 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var SORTLIST = exports.SORTLIST = 'SORTLIST'; -var CHANGE_SELECTION = exports.CHANGE_SELECTION = 'CHANGE_SELECTION'; -var CHANGE_FILTER = exports.CHANGE_FILTER = 'CHANGE_FILTER'; - /***/ }), /* 67 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.15 ToLength -var toInteger = __webpack_require__(102); +var toInteger = __webpack_require__(103); var min = Math.min; module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 @@ -4355,8 +4357,8 @@ exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.d // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = __webpack_require__(41); var dPs = __webpack_require__(413); -var enumBugKeys = __webpack_require__(105); -var IE_PROTO = __webpack_require__(103)('IE_PROTO'); +var enumBugKeys = __webpack_require__(106); +var IE_PROTO = __webpack_require__(104)('IE_PROTO'); var Empty = function () { /* empty */ }; var PROTOTYPE = 'prototype'; @@ -4466,7 +4468,7 @@ var _linkRule = __webpack_require__(219); var _linkRule2 = _interopRequireDefault(_linkRule); -var _StyleRule = __webpack_require__(119); +var _StyleRule = __webpack_require__(120); var _StyleRule2 = _interopRequireDefault(_StyleRule); @@ -5755,40 +5757,598 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de "use strict"; -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * - */ +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; }; -function makeEmptyFunction(arg) { - return function () { - return arg; - }; -} +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; }; }(); -/** - * This function accepts and discards inputs; it has no side effects. This is - * primarily useful idiomatically for overridable function endpoints which - * always need to be callable, since JS lacks a null-call idiom ala Cocoa. - */ -var emptyFunction = function emptyFunction() {}; +var _class, _class2, _temp; -emptyFunction.thatReturns = makeEmptyFunction; -emptyFunction.thatReturnsFalse = makeEmptyFunction(false); -emptyFunction.thatReturnsTrue = makeEmptyFunction(true); -emptyFunction.thatReturnsNull = makeEmptyFunction(null); -emptyFunction.thatReturnsThis = function () { - return this; -}; -emptyFunction.thatReturnsArgument = function (arg) { - return arg; -}; +/* Decoraters */ -module.exports = emptyFunction; + +/* Utils */ + + +/* CSS */ + + +var _react = __webpack_require__(1); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = __webpack_require__(565); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _reactDom = __webpack_require__(16); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _classnames = __webpack_require__(570); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _staticMethods = __webpack_require__(571); + +var _staticMethods2 = _interopRequireDefault(_staticMethods); + +var _windowListener = __webpack_require__(572); + +var _windowListener2 = _interopRequireDefault(_windowListener); + +var _customEvent = __webpack_require__(573); + +var _customEvent2 = _interopRequireDefault(_customEvent); + +var _isCapture = __webpack_require__(574); + +var _isCapture2 = _interopRequireDefault(_isCapture); + +var _getEffect = __webpack_require__(575); + +var _getEffect2 = _interopRequireDefault(_getEffect); + +var _trackRemoval = __webpack_require__(576); + +var _trackRemoval2 = _interopRequireDefault(_trackRemoval); + +var _getPosition = __webpack_require__(577); + +var _getPosition2 = _interopRequireDefault(_getPosition); + +var _getTipContent = __webpack_require__(578); + +var _getTipContent2 = _interopRequireDefault(_getTipContent); + +var _aria = __webpack_require__(579); + +var _nodeListToArray = __webpack_require__(580); + +var _nodeListToArray2 = _interopRequireDefault(_nodeListToArray); + +var _style = __webpack_require__(581); + +var _style2 = _interopRequireDefault(_style); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +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; } + +var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.default)(_class = (0, _customEvent2.default)(_class = (0, _isCapture2.default)(_class = (0, _getEffect2.default)(_class = (0, _trackRemoval2.default)(_class = (_temp = _class2 = function (_Component) { + _inherits(ReactTooltip, _Component); + + function ReactTooltip(props) { + _classCallCheck(this, ReactTooltip); + + var _this = _possibleConstructorReturn(this, (ReactTooltip.__proto__ || Object.getPrototypeOf(ReactTooltip)).call(this, props)); + + _this.state = { + place: 'top', // Direction of tooltip + type: 'dark', // Color theme of tooltip + effect: 'float', // float or fixed + show: false, + border: false, + placeholder: '', + offset: {}, + extraClass: '', + html: false, + delayHide: 0, + delayShow: 0, + event: props.event || null, + eventOff: props.eventOff || null, + currentEvent: null, // Current mouse event + currentTarget: null, // Current target of mouse event + ariaProps: (0, _aria.parseAria)(props), // aria- and role attributes + isEmptyTip: false, + disable: false + }; + + _this.bind(['showTooltip', 'updateTooltip', 'hideTooltip', 'globalRebuild', 'globalShow', 'globalHide', 'onWindowResize']); + + _this.mount = true; + _this.delayShowLoop = null; + _this.delayHideLoop = null; + _this.intervalUpdateContent = null; + return _this; + } + + /** + * For unify the bind and unbind listener + */ + + + _createClass(ReactTooltip, [{ + key: 'bind', + value: function bind(methodArray) { + var _this2 = this; + + methodArray.forEach(function (method) { + _this2[method] = _this2[method].bind(_this2); + }); + } + }, { + key: 'componentDidMount', + value: function componentDidMount() { + var _props = this.props, + insecure = _props.insecure, + resizeHide = _props.resizeHide; + + if (insecure) { + this.setStyleHeader(); // Set the style to the + } + this.bindListener(); // Bind listener for tooltip + this.bindWindowEvents(resizeHide); // Bind global event for static method + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(props) { + var ariaProps = this.state.ariaProps; + + var newAriaProps = (0, _aria.parseAria)(props); + + var isChanged = Object.keys(newAriaProps).some(function (props) { + return newAriaProps[props] !== ariaProps[props]; + }); + if (isChanged) { + this.setState({ ariaProps: newAriaProps }); + } + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + this.mount = false; + + this.clearTimer(); + + this.unbindListener(); + this.removeScrollListener(); + this.unbindWindowEvents(); + } + + /** + * Pick out corresponded target elements + */ + + }, { + key: 'getTargetArray', + value: function getTargetArray(id) { + var targetArray = void 0; + if (!id) { + targetArray = document.querySelectorAll('[data-tip]:not([data-for])'); + } else { + var escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); + targetArray = document.querySelectorAll('[data-tip][data-for="' + escaped + '"]'); + } + // targetArray is a NodeList, convert it to a real array + return (0, _nodeListToArray2.default)(targetArray); + } + + /** + * Bind listener to the target elements + * These listeners used to trigger showing or hiding the tooltip + */ + + }, { + key: 'bindListener', + value: function bindListener() { + var _this3 = this; + + var _props2 = this.props, + id = _props2.id, + globalEventOff = _props2.globalEventOff; + + var targetArray = this.getTargetArray(id); + + targetArray.forEach(function (target) { + var isCaptureMode = _this3.isCapture(target); + var effect = _this3.getEffect(target); + if (target.getAttribute('currentItem') === null) { + target.setAttribute('currentItem', 'false'); + } + _this3.unbindBasicListener(target); + + if (_this3.isCustomEvent(target)) { + _this3.customBindListener(target); + return; + } + + target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode); + if (effect === 'float') { + target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode); + } + target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode); + }); + + // Global event to hide tooltip + if (globalEventOff) { + window.removeEventListener(globalEventOff, this.hideTooltip); + window.addEventListener(globalEventOff, this.hideTooltip, false); + } + + // Track removal of targetArray elements from DOM + this.bindRemovalTracker(); + } + + /** + * Unbind listeners on target elements + */ + + }, { + key: 'unbindListener', + value: function unbindListener() { + var _this4 = this; + + var _props3 = this.props, + id = _props3.id, + globalEventOff = _props3.globalEventOff; + + var targetArray = this.getTargetArray(id); + targetArray.forEach(function (target) { + _this4.unbindBasicListener(target); + if (_this4.isCustomEvent(target)) _this4.customUnbindListener(target); + }); + + if (globalEventOff) window.removeEventListener(globalEventOff, this.hideTooltip); + this.unbindRemovalTracker(); + } + + /** + * Invoke this before bind listener and ummount the compont + * it is necessary to invloke this even when binding custom event + * so that the tooltip can switch between custom and default listener + */ + + }, { + key: 'unbindBasicListener', + value: function unbindBasicListener(target) { + var isCaptureMode = this.isCapture(target); + target.removeEventListener('mouseenter', this.showTooltip, isCaptureMode); + target.removeEventListener('mousemove', this.updateTooltip, isCaptureMode); + target.removeEventListener('mouseleave', this.hideTooltip, isCaptureMode); + } + + /** + * When mouse enter, show the tooltip + */ + + }, { + key: 'showTooltip', + value: function showTooltip(e, isGlobalCall) { + var _this5 = this; + + if (isGlobalCall) { + // Don't trigger other elements belongs to other ReactTooltip + var targetArray = this.getTargetArray(this.props.id); + var isMyElement = targetArray.some(function (ele) { + return ele === e.currentTarget; + }); + if (!isMyElement || this.state.show) return; + } + // Get the tooltip content + // calculate in this phrase so that tip width height can be detected + var _props4 = this.props, + children = _props4.children, + multiline = _props4.multiline, + getContent = _props4.getContent; + + var originTooltip = e.currentTarget.getAttribute('data-tip'); + var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false; + + // Generate tootlip content + var content = void 0; + if (getContent) { + if (Array.isArray(getContent)) { + content = getContent[0] && getContent[0](); + } else { + content = getContent(); + } + } + var placeholder = (0, _getTipContent2.default)(originTooltip, children, content, isMultiline); + var isEmptyTip = typeof placeholder === 'string' && placeholder === '' || placeholder === null; + + // If it is focus event or called by ReactTooltip.show, switch to `solid` effect + var switchToSolid = e instanceof window.FocusEvent || isGlobalCall; + + // if it needs to skip adding hide listener to scroll + var scrollHide = true; + if (e.currentTarget.getAttribute('data-scroll-hide')) { + scrollHide = e.currentTarget.getAttribute('data-scroll-hide') === 'true'; + } else if (this.props.scrollHide != null) { + scrollHide = this.props.scrollHide; + } + + // To prevent previously created timers from triggering + this.clearTimer(); + + this.setState({ + placeholder: placeholder, + isEmptyTip: isEmptyTip, + place: e.currentTarget.getAttribute('data-place') || this.props.place || 'top', + type: e.currentTarget.getAttribute('data-type') || this.props.type || 'dark', + effect: switchToSolid && 'solid' || this.getEffect(e.currentTarget), + offset: e.currentTarget.getAttribute('data-offset') || this.props.offset || {}, + html: e.currentTarget.getAttribute('data-html') ? e.currentTarget.getAttribute('data-html') === 'true' : this.props.html || false, + delayShow: e.currentTarget.getAttribute('data-delay-show') || this.props.delayShow || 0, + delayHide: e.currentTarget.getAttribute('data-delay-hide') || this.props.delayHide || 0, + border: e.currentTarget.getAttribute('data-border') ? e.currentTarget.getAttribute('data-border') === 'true' : this.props.border || false, + extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || this.props.className || '', + disable: e.currentTarget.getAttribute('data-tip-disable') ? e.currentTarget.getAttribute('data-tip-disable') === 'true' : this.props.disable || false + }, function () { + if (scrollHide) _this5.addScrollListener(e); + _this5.updateTooltip(e); + + if (getContent && Array.isArray(getContent)) { + _this5.intervalUpdateContent = setInterval(function () { + if (_this5.mount) { + var _getContent = _this5.props.getContent; + + var _placeholder = (0, _getTipContent2.default)(originTooltip, _getContent[0](), isMultiline); + var _isEmptyTip = typeof _placeholder === 'string' && _placeholder === ''; + _this5.setState({ + placeholder: _placeholder, + isEmptyTip: _isEmptyTip + }); + } + }, getContent[1]); + } + }); + } + + /** + * When mouse hover, updatetooltip + */ + + }, { + key: 'updateTooltip', + value: function updateTooltip(e) { + var _this6 = this; + + var _state = this.state, + delayShow = _state.delayShow, + show = _state.show, + isEmptyTip = _state.isEmptyTip, + disable = _state.disable; + var afterShow = this.props.afterShow; + var placeholder = this.state.placeholder; + + var delayTime = show ? 0 : parseInt(delayShow, 10); + var eventTarget = e.currentTarget; + + if (isEmptyTip || disable) return; // if the tooltip is empty, disable the tooltip + var updateState = function updateState() { + if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) { + var isInvisible = !_this6.state.show; + _this6.setState({ + currentEvent: e, + currentTarget: eventTarget, + show: true + }, function () { + _this6.updatePosition(); + if (isInvisible && afterShow) afterShow(); + }); + } + }; + + clearTimeout(this.delayShowLoop); + if (delayShow) { + this.delayShowLoop = setTimeout(updateState, delayTime); + } else { + updateState(); + } + } + + /** + * When mouse leave, hide tooltip + */ + + }, { + key: 'hideTooltip', + value: function hideTooltip(e, hasTarget) { + var _this7 = this; + + var _state2 = this.state, + delayHide = _state2.delayHide, + isEmptyTip = _state2.isEmptyTip, + disable = _state2.disable; + var afterHide = this.props.afterHide; + + if (!this.mount) return; + if (isEmptyTip || disable) return; // if the tooltip is empty, disable the tooltip + if (hasTarget) { + // Don't trigger other elements belongs to other ReactTooltip + var targetArray = this.getTargetArray(this.props.id); + var isMyElement = targetArray.some(function (ele) { + return ele === e.currentTarget; + }); + if (!isMyElement || !this.state.show) return; + } + var resetState = function resetState() { + var isVisible = _this7.state.show; + _this7.setState({ + show: false + }, function () { + _this7.removeScrollListener(); + if (isVisible && afterHide) afterHide(); + }); + }; + + this.clearTimer(); + if (delayHide) { + this.delayHideLoop = setTimeout(resetState, parseInt(delayHide, 10)); + } else { + resetState(); + } + } + + /** + * Add scroll eventlistener when tooltip show + * automatically hide the tooltip when scrolling + */ + + }, { + key: 'addScrollListener', + value: function addScrollListener(e) { + var isCaptureMode = this.isCapture(e.currentTarget); + window.addEventListener('scroll', this.hideTooltip, isCaptureMode); + } + }, { + key: 'removeScrollListener', + value: function removeScrollListener() { + window.removeEventListener('scroll', this.hideTooltip); + } + + // Calculation the position + + }, { + key: 'updatePosition', + value: function updatePosition() { + var _this8 = this; + + var _state3 = this.state, + currentEvent = _state3.currentEvent, + currentTarget = _state3.currentTarget, + place = _state3.place, + effect = _state3.effect, + offset = _state3.offset; + + var node = _reactDom2.default.findDOMNode(this); + var result = (0, _getPosition2.default)(currentEvent, currentTarget, node, place, effect, offset); + + if (result.isNewState) { + // Switch to reverse placement + return this.setState(result.newState, function () { + _this8.updatePosition(); + }); + } + // Set tooltip position + node.style.left = result.position.left + 'px'; + node.style.top = result.position.top + 'px'; + } + + /** + * Set style tag in header + * in this way we can insert default css + */ + + }, { + key: 'setStyleHeader', + value: function setStyleHeader() { + if (!document.getElementsByTagName('head')[0].querySelector('style[id="react-tooltip"]')) { + var tag = document.createElement('style'); + tag.id = 'react-tooltip'; + tag.innerHTML = _style2.default; + document.getElementsByTagName('head')[0].appendChild(tag); + } + } + + /** + * CLear all kinds of timeout of interval + */ + + }, { + key: 'clearTimer', + value: function clearTimer() { + clearTimeout(this.delayShowLoop); + clearTimeout(this.delayHideLoop); + clearInterval(this.intervalUpdateContent); + } + }, { + key: 'render', + value: function render() { + var _state4 = this.state, + placeholder = _state4.placeholder, + extraClass = _state4.extraClass, + html = _state4.html, + ariaProps = _state4.ariaProps, + disable = _state4.disable, + isEmptyTip = _state4.isEmptyTip; + + var tooltipClass = (0, _classnames2.default)('__react_component_tooltip', { 'show': this.state.show && !disable && !isEmptyTip }, { 'border': this.state.border }, { 'place-top': this.state.place === 'top' }, { 'place-bottom': this.state.place === 'bottom' }, { 'place-left': this.state.place === 'left' }, { 'place-right': this.state.place === 'right' }, { 'type-dark': this.state.type === 'dark' }, { 'type-success': this.state.type === 'success' }, { 'type-warning': this.state.type === 'warning' }, { 'type-error': this.state.type === 'error' }, { 'type-info': this.state.type === 'info' }, { 'type-light': this.state.type === 'light' }); + + var Wrapper = this.props.wrapper; + if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) { + Wrapper = ReactTooltip.defaultProps.wrapper; + } + + if (html) { + return _react2.default.createElement(Wrapper, _extends({ className: tooltipClass + ' ' + extraClass + }, ariaProps, { + 'data-id': 'tooltip', + dangerouslySetInnerHTML: { __html: placeholder } })); + } else { + return _react2.default.createElement( + Wrapper, + _extends({ className: tooltipClass + ' ' + extraClass + }, ariaProps, { + 'data-id': 'tooltip' }), + placeholder + ); + } + } + }]); + + return ReactTooltip; +}(_react.Component), _class2.propTypes = { + children: _propTypes2.default.any, + place: _propTypes2.default.string, + type: _propTypes2.default.string, + effect: _propTypes2.default.string, + offset: _propTypes2.default.object, + multiline: _propTypes2.default.bool, + border: _propTypes2.default.bool, + insecure: _propTypes2.default.bool, + class: _propTypes2.default.string, + className: _propTypes2.default.string, + id: _propTypes2.default.string, + html: _propTypes2.default.bool, + delayHide: _propTypes2.default.number, + delayShow: _propTypes2.default.number, + event: _propTypes2.default.string, + eventOff: _propTypes2.default.string, + watchWindow: _propTypes2.default.bool, + isCapture: _propTypes2.default.bool, + globalEventOff: _propTypes2.default.string, + getContent: _propTypes2.default.any, + afterShow: _propTypes2.default.func, + afterHide: _propTypes2.default.func, + disable: _propTypes2.default.bool, + scrollHide: _propTypes2.default.bool, + resizeHide: _propTypes2.default.bool, + wrapper: _propTypes2.default.string +}, _class2.defaultProps = { + insecure: true, + resizeHide: true, + wrapper: 'div' +}, _class2.supportedWrappers = ['div', 'span'], _temp)) || _class) || _class) || _class) || _class) || _class) || _class; + +/* export default not fit for standalone, it will exports {default:...} */ + + +module.exports = ReactTooltip; /***/ }), /* 85 */ @@ -5836,6 +6396,48 @@ module.exports = emptyFunction; /* 86 */ /***/ (function(module, exports, __webpack_require__) { +"use strict"; + + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * + */ + +function makeEmptyFunction(arg) { + return function () { + return arg; + }; +} + +/** + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. + */ +var emptyFunction = function emptyFunction() {}; + +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; +}; + +module.exports = emptyFunction; + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. @@ -5893,7 +6495,7 @@ module.exports = invariant; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) /***/ }), -/* 87 */ +/* 88 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5912,7 +6514,7 @@ module.exports = ReactPropTypesSecret; /***/ }), -/* 88 */ +/* 89 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global, module) {/** @@ -7764,10 +8366,10 @@ function stubFalse() { module.exports = isEqual; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(17), __webpack_require__(89)(module))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(17), __webpack_require__(90)(module))) /***/ }), -/* 89 */ +/* 90 */ /***/ (function(module, exports) { module.exports = function(module) { @@ -7795,7 +8397,7 @@ module.exports = function(module) { /***/ }), -/* 90 */ +/* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7836,70 +8438,70 @@ emptyFunction.thatReturnsArgument = function (arg) { module.exports = emptyFunction; -/***/ }), -/* 91 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - - - -/** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - -var validateFormat = function validateFormat(format) {}; - -if (process.env.NODE_ENV !== 'production') { - validateFormat = function validateFormat(format) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - }; -} - -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error; - if (format === undefined) { - error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error(format.replace(/%s/g, function () { - return args[argIndex++]; - })); - error.name = 'Invariant Violation'; - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } -} - -module.exports = invariant; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) - /***/ }), /* 92 */ /***/ (function(module, exports, __webpack_require__) { +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) {/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + + + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var validateFormat = function validateFormat(format) {}; + +if (process.env.NODE_ENV !== 'production') { + validateFormat = function validateFormat(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} + +module.exports = invariant; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. @@ -7916,7 +8518,7 @@ module.exports = ReactPropTypesSecret; /***/ }), -/* 93 */ +/* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7958,7 +8560,7 @@ emptyFunction.thatReturnsArgument = function (arg) { module.exports = emptyFunction; /***/ }), -/* 94 */ +/* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8018,7 +8620,7 @@ module.exports = invariant; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) /***/ }), -/* 95 */ +/* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8037,7 +8639,7 @@ module.exports = ReactPropTypesSecret; /***/ }), -/* 96 */ +/* 97 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -8065,7 +8667,7 @@ function warning(message) { } /***/ }), -/* 97 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a