Skip to content

Commit 525e651

Browse files
committed
use master for deploy
1 parent f4649dd commit 525e651

12 files changed

+1203
-1
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
# files
1212
node_modules/
1313
example/dist/
14-
dist/

dist/constant.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = {
7+
8+
GLOBAL: {
9+
HIDE: '__react_tooltip_hide_event',
10+
REBUILD: '__react_tooltip_rebuild_event',
11+
SHOW: '__react_tooltip_show_event'
12+
}
13+
};

dist/decorators/customEvent.js

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (target) {
8+
target.prototype.isCustomEvent = function (ele) {
9+
var event = this.state.event;
10+
11+
return event || !!ele.getAttribute('data-event');
12+
};
13+
14+
/* Bind listener for custom event */
15+
target.prototype.customBindListener = function (ele) {
16+
var _this = this;
17+
18+
var _state = this.state,
19+
event = _state.event,
20+
eventOff = _state.eventOff;
21+
22+
var dataEvent = ele.getAttribute('data-event') || event;
23+
var dataEventOff = ele.getAttribute('data-event-off') || eventOff;
24+
25+
dataEvent.split(' ').forEach(function (event) {
26+
ele.removeEventListener(event, customListener);
27+
customListener = checkStatus.bind(_this, dataEventOff);
28+
ele.addEventListener(event, customListener, false);
29+
});
30+
if (dataEventOff) {
31+
dataEventOff.split(' ').forEach(function (event) {
32+
ele.removeEventListener(event, _this.hideTooltip);
33+
ele.addEventListener(event, _this.hideTooltip, false);
34+
});
35+
}
36+
};
37+
38+
/* Unbind listener for custom event */
39+
target.prototype.customUnbindListener = function (ele) {
40+
var _state2 = this.state,
41+
event = _state2.event,
42+
eventOff = _state2.eventOff;
43+
44+
var dataEvent = event || ele.getAttribute('data-event');
45+
var dataEventOff = eventOff || ele.getAttribute('data-event-off');
46+
47+
ele.removeEventListener(dataEvent, customListener);
48+
if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip);
49+
};
50+
};
51+
52+
/**
53+
* Custom events to control showing and hiding of tooltip
54+
*
55+
* @attributes
56+
* - `event` {String}
57+
* - `eventOff` {String}
58+
*/
59+
60+
var checkStatus = function checkStatus(dataEventOff, e) {
61+
var show = this.state.show;
62+
var id = this.props.id;
63+
64+
var dataIsCapture = e.currentTarget.getAttribute('data-iscapture');
65+
var isCapture = dataIsCapture && dataIsCapture === 'true' || this.props.isCapture;
66+
var currentItem = e.currentTarget.getAttribute('currentItem');
67+
68+
if (!isCapture) e.stopPropagation();
69+
if (show && currentItem === 'true') {
70+
if (!dataEventOff) this.hideTooltip(e);
71+
} else {
72+
e.currentTarget.setAttribute('currentItem', 'true');
73+
setUntargetItems(e.currentTarget, this.getTargetArray(id));
74+
this.showTooltip(e);
75+
}
76+
};
77+
78+
var setUntargetItems = function setUntargetItems(currentTarget, targetArray) {
79+
for (var i = 0; i < targetArray.length; i++) {
80+
if (currentTarget !== targetArray[i]) {
81+
targetArray[i].setAttribute('currentItem', 'false');
82+
} else {
83+
targetArray[i].setAttribute('currentItem', 'true');
84+
}
85+
}
86+
};
87+
88+
var customListener = void 0;

dist/decorators/getEffect.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (target) {
8+
target.prototype.getEffect = function (currentTarget) {
9+
var dataEffect = currentTarget.getAttribute('data-effect');
10+
return dataEffect || this.props.effect || 'float';
11+
};
12+
};

dist/decorators/isCapture.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (target) {
8+
target.prototype.isCapture = function (currentTarget) {
9+
var dataIsCapture = currentTarget.getAttribute('data-iscapture');
10+
return dataIsCapture && dataIsCapture === 'true' || this.props.isCapture || false;
11+
};
12+
};

dist/decorators/staticMethods.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (target) {
8+
/**
9+
* Hide all tooltip
10+
* @trigger ReactTooltip.hide()
11+
*/
12+
target.hide = function (target) {
13+
dispatchGlobalEvent(_constant2.default.GLOBAL.HIDE, { target: target });
14+
};
15+
16+
/**
17+
* Rebuild all tooltip
18+
* @trigger ReactTooltip.rebuild()
19+
*/
20+
target.rebuild = function () {
21+
dispatchGlobalEvent(_constant2.default.GLOBAL.REBUILD);
22+
};
23+
24+
/**
25+
* Show specific tooltip
26+
* @trigger ReactTooltip.show()
27+
*/
28+
target.show = function (target) {
29+
dispatchGlobalEvent(_constant2.default.GLOBAL.SHOW, { target: target });
30+
};
31+
32+
target.prototype.globalRebuild = function () {
33+
if (this.mount) {
34+
this.unbindListener();
35+
this.bindListener();
36+
}
37+
};
38+
39+
target.prototype.globalShow = function (event) {
40+
if (this.mount) {
41+
// Create a fake event, specific show will limit the type to `solid`
42+
// only `float` type cares e.clientX e.clientY
43+
var e = { currentTarget: event.detail.target };
44+
this.showTooltip(e, true);
45+
}
46+
};
47+
48+
target.prototype.globalHide = function (event) {
49+
if (this.mount) {
50+
var hasTarget = event && event.detail && event.detail.target && true || false;
51+
this.hideTooltip({ currentTarget: hasTarget && event.detail.target }, hasTarget);
52+
}
53+
};
54+
};
55+
56+
var _constant = require('../constant');
57+
58+
var _constant2 = _interopRequireDefault(_constant);
59+
60+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61+
62+
var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
63+
// Compatibale with IE
64+
// @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
65+
var event = void 0;
66+
67+
if (typeof window.CustomEvent === 'function') {
68+
event = new window.CustomEvent(eventName, { detail: opts });
69+
} else {
70+
event = document.createEvent('Event');
71+
event.initEvent(eventName, false, true);
72+
event.detail = opts;
73+
}
74+
75+
window.dispatchEvent(event);
76+
}; /**
77+
* Static methods for react-tooltip
78+
*/

dist/decorators/windowListener.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (target) {
8+
target.prototype.bindWindowEvents = function (resizeHide) {
9+
// ReactTooltip.hide
10+
window.removeEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide);
11+
window.addEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide, false);
12+
13+
// ReactTooltip.rebuild
14+
window.removeEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild);
15+
window.addEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild, false);
16+
17+
// ReactTooltip.show
18+
window.removeEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow);
19+
window.addEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow, false);
20+
21+
// Resize
22+
if (resizeHide) {
23+
window.removeEventListener('resize', this.onWindowResize);
24+
window.addEventListener('resize', this.onWindowResize, false);
25+
}
26+
};
27+
28+
target.prototype.unbindWindowEvents = function () {
29+
window.removeEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide);
30+
window.removeEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild);
31+
window.removeEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow);
32+
window.removeEventListener('resize', this.onWindowResize);
33+
};
34+
35+
/**
36+
* invoked by resize event of window
37+
*/
38+
target.prototype.onWindowResize = function () {
39+
if (!this.mount) return;
40+
this.hideTooltip();
41+
};
42+
};
43+
44+
var _constant = require('../constant');
45+
46+
var _constant2 = _interopRequireDefault(_constant);
47+
48+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

0 commit comments

Comments
 (0)