Comparing version 1.0.1 to 1.0.2
@@ -0,1 +1,2 @@ | ||
var coachmarks = | ||
/******/ (function(modules) { // webpackBootstrap | ||
@@ -63,3 +64,3 @@ /******/ // The module cache | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 23); | ||
/******/ return __webpack_require__(__webpack_require__.s = 27); | ||
/******/ }) | ||
@@ -83,4 +84,4 @@ /************************************************************************/ | ||
var store = __webpack_require__(19)('wks'); | ||
var uid = __webpack_require__(20); | ||
var store = __webpack_require__(22)('wks'); | ||
var uid = __webpack_require__(23); | ||
var Symbol = __webpack_require__(0).Symbol; | ||
@@ -99,7 +100,15 @@ var USE_SYMBOL = typeof Symbol == 'function'; | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
var core = module.exports = { version: '2.5.0' }; | ||
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var dP = __webpack_require__(10); | ||
var createDesc = __webpack_require__(18); | ||
module.exports = __webpack_require__(5) ? function (object, key, value) { | ||
var createDesc = __webpack_require__(20); | ||
module.exports = __webpack_require__(6) ? function (object, key, value) { | ||
return dP.f(object, key, createDesc(1, value)); | ||
@@ -113,3 +122,3 @@ } : function (object, key, value) { | ||
/***/ }), | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
@@ -121,3 +130,3 @@ | ||
/***/ }), | ||
/* 4 */ | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -133,7 +142,7 @@ | ||
/***/ }), | ||
/* 5 */ | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// Thank's IE8 for his funny defineProperty | ||
module.exports = !__webpack_require__(16)(function () { | ||
module.exports = !__webpack_require__(12)(function () { | ||
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; | ||
@@ -144,3 +153,3 @@ }); | ||
/***/ }), | ||
/* 6 */ | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
@@ -155,8 +164,8 @@ | ||
/***/ }), | ||
/* 7 */ | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// to indexed object, toObject with fallback for non-array-like ES3 strings | ||
var IObject = __webpack_require__(32); | ||
var defined = __webpack_require__(8); | ||
var IObject = __webpack_require__(34); | ||
var defined = __webpack_require__(9); | ||
module.exports = function (it) { | ||
@@ -168,3 +177,3 @@ return IObject(defined(it)); | ||
/***/ }), | ||
/* 8 */ | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
@@ -180,19 +189,11 @@ | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
var core = module.exports = { version: '2.5.0' }; | ||
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var anObject = __webpack_require__(4); | ||
var IE8_DOM_DEFINE = __webpack_require__(37); | ||
var toPrimitive = __webpack_require__(38); | ||
var anObject = __webpack_require__(5); | ||
var IE8_DOM_DEFINE = __webpack_require__(38); | ||
var toPrimitive = __webpack_require__(39); | ||
var dP = Object.defineProperty; | ||
exports.f = __webpack_require__(5) ? Object.defineProperty : function defineProperty(O, P, Attributes) { | ||
exports.f = __webpack_require__(6) ? Object.defineProperty : function defineProperty(O, P, Attributes) { | ||
anObject(O); | ||
@@ -223,2 +224,15 @@ P = toPrimitive(P, true); | ||
module.exports = function (exec) { | ||
try { | ||
return !!exec(); | ||
} catch (e) { | ||
return true; | ||
} | ||
}; | ||
/***/ }), | ||
/* 13 */ | ||
/***/ (function(module, exports) { | ||
// 7.1.4 ToInteger | ||
@@ -233,7 +247,7 @@ var ceil = Math.ceil; | ||
/***/ }), | ||
/* 13 */ | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var shared = __webpack_require__(19)('keys'); | ||
var uid = __webpack_require__(20); | ||
var shared = __webpack_require__(22)('keys'); | ||
var uid = __webpack_require__(23); | ||
module.exports = function (key) { | ||
@@ -245,3 +259,109 @@ return shared[key] || (shared[key] = uid(key)); | ||
/***/ }), | ||
/* 14 */ | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var _getIterator2 = __webpack_require__(28); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function cache() { | ||
return cache.addOrGet.apply(cache, arguments); | ||
} | ||
cache.init = function () { | ||
if (!cache.cache) { | ||
cache.cache = {}; | ||
} | ||
}; | ||
cache.addOrGet = function (name, obj) { | ||
cache.init(); | ||
if (typeof obj === 'undefined') { | ||
// Get | ||
return cache.get(name); | ||
} | ||
// Set | ||
cache.add(name, obj); | ||
return obj; | ||
}; | ||
cache.get = function (name) { | ||
cache.init(); | ||
return cache.cache[name]; | ||
}; | ||
cache.add = function (name, obj) { | ||
cache.init(); | ||
cache.cache[name] = obj; | ||
return obj; | ||
}; | ||
cache.remove = function (name) { | ||
cache.init(); | ||
if (name) cache.cache[name] = undefined; | ||
}; | ||
cache.clear = function () { | ||
cache.init(); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = (0, _getIterator3.default)(cache.cache), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var c = _step.value; | ||
cache.cache[c] = undefined; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
}; | ||
cache.default = function (name, defaultFn) { | ||
var obj = cache(name); | ||
if (obj === undefined) return cache(name, defaultFn.call()); | ||
return obj; | ||
}; | ||
cache.all = function () { | ||
cache.init(); | ||
return cache.cache; | ||
}; | ||
cache.allArray = function () { | ||
cache.init(); | ||
var elms = []; | ||
for (var key in cache) { | ||
if (Object.prototype.hasOwnProperty.call(cache.cache, key)) { | ||
elms.push({ key: cache.cache[key] }); | ||
} | ||
} | ||
return elms; | ||
}; | ||
module.exports = cache; | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports) { | ||
@@ -257,3 +377,3 @@ | ||
/***/ }), | ||
/* 15 */ | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -263,10 +383,10 @@ | ||
var LIBRARY = __webpack_require__(33); | ||
var $export = __webpack_require__(34); | ||
var redefine = __webpack_require__(39); | ||
var hide = __webpack_require__(2); | ||
var has = __webpack_require__(6); | ||
var Iterators = __webpack_require__(3); | ||
var $iterCreate = __webpack_require__(40); | ||
var setToStringTag = __webpack_require__(22); | ||
var LIBRARY = __webpack_require__(35); | ||
var $export = __webpack_require__(18); | ||
var redefine = __webpack_require__(40); | ||
var hide = __webpack_require__(3); | ||
var has = __webpack_require__(7); | ||
var Iterators = __webpack_require__(4); | ||
var $iterCreate = __webpack_require__(41); | ||
var setToStringTag = __webpack_require__(25); | ||
var getPrototypeOf = __webpack_require__(49); | ||
@@ -336,16 +456,70 @@ var ITERATOR = __webpack_require__(1)('iterator'); | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports) { | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = function (exec) { | ||
try { | ||
return !!exec(); | ||
} catch (e) { | ||
return true; | ||
var global = __webpack_require__(0); | ||
var core = __webpack_require__(2); | ||
var ctx = __webpack_require__(36); | ||
var hide = __webpack_require__(3); | ||
var PROTOTYPE = 'prototype'; | ||
var $export = function (type, name, source) { | ||
var IS_FORCED = type & $export.F; | ||
var IS_GLOBAL = type & $export.G; | ||
var IS_STATIC = type & $export.S; | ||
var IS_PROTO = type & $export.P; | ||
var IS_BIND = type & $export.B; | ||
var IS_WRAP = type & $export.W; | ||
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); | ||
var expProto = exports[PROTOTYPE]; | ||
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; | ||
var key, own, out; | ||
if (IS_GLOBAL) source = name; | ||
for (key in source) { | ||
// contains in native | ||
own = !IS_FORCED && target && target[key] !== undefined; | ||
if (own && key in exports) continue; | ||
// export native or passed | ||
out = own ? target[key] : source[key]; | ||
// prevent global pollution for namespaces | ||
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] | ||
// bind timers to global for call from export context | ||
: IS_BIND && own ? ctx(out, global) | ||
// wrap global constructors for prevent change them in library | ||
: IS_WRAP && target[key] == out ? (function (C) { | ||
var F = function (a, b, c) { | ||
if (this instanceof C) { | ||
switch (arguments.length) { | ||
case 0: return new C(); | ||
case 1: return new C(a); | ||
case 2: return new C(a, b); | ||
} return new C(a, b, c); | ||
} return C.apply(this, arguments); | ||
}; | ||
F[PROTOTYPE] = C[PROTOTYPE]; | ||
return F; | ||
// make static versions for prototype methods | ||
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; | ||
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME% | ||
if (IS_PROTO) { | ||
(exports.virtual || (exports.virtual = {}))[key] = out; | ||
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% | ||
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); | ||
} | ||
} | ||
}; | ||
// type bitmap | ||
$export.F = 1; // forced | ||
$export.G = 2; // global | ||
$export.S = 4; // static | ||
$export.P = 8; // proto | ||
$export.B = 16; // bind | ||
$export.W = 32; // wrap | ||
$export.U = 64; // safe | ||
$export.R = 128; // real proto method for `library` | ||
module.exports = $export; | ||
/***/ }), | ||
/* 17 */ | ||
/* 19 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -363,3 +537,3 @@ | ||
/***/ }), | ||
/* 18 */ | ||
/* 20 */ | ||
/***/ (function(module, exports) { | ||
@@ -378,5 +552,18 @@ | ||
/***/ }), | ||
/* 19 */ | ||
/* 21 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.14 / 15.2.3.14 Object.keys(O) | ||
var $keys = __webpack_require__(44); | ||
var enumBugKeys = __webpack_require__(24); | ||
module.exports = Object.keys || function keys(O) { | ||
return $keys(O, enumBugKeys); | ||
}; | ||
/***/ }), | ||
/* 22 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var global = __webpack_require__(0); | ||
@@ -391,3 +578,3 @@ var SHARED = '__core-js_shared__'; | ||
/***/ }), | ||
/* 20 */ | ||
/* 23 */ | ||
/***/ (function(module, exports) { | ||
@@ -403,3 +590,3 @@ | ||
/***/ }), | ||
/* 21 */ | ||
/* 24 */ | ||
/***/ (function(module, exports) { | ||
@@ -414,7 +601,7 @@ | ||
/***/ }), | ||
/* 22 */ | ||
/* 25 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var def = __webpack_require__(10).f; | ||
var has = __webpack_require__(6); | ||
var has = __webpack_require__(7); | ||
var TAG = __webpack_require__(1)('toStringTag'); | ||
@@ -428,49 +615,615 @@ | ||
/***/ }), | ||
/* 23 */ | ||
/* 26 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.13 ToObject(argument) | ||
var defined = __webpack_require__(9); | ||
module.exports = function (it) { | ||
return Object(defined(it)); | ||
}; | ||
/***/ }), | ||
/* 27 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
// const isElement = require('iselement'); | ||
// const filter = require('lodash/filter'); | ||
var SvgPath = __webpack_require__(24); | ||
var cache = __webpack_require__(25); | ||
var _cache2 = __webpack_require__(15); | ||
// TODO: for positioning choose biggest delta between x and y, it will be one of two (i.e. bottom or left), so choose the one that's the largest delta from the other point's (maybe) | ||
var _cache3 = _interopRequireDefault(_cache2); | ||
var target = '#btn'; | ||
var _draw = __webpack_require__(55); | ||
// Distance from line to | ||
var lineOffset = 20; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Options for arrows | ||
// const arrowOpts = { | ||
// textPos: 'middle'; | ||
// } | ||
// Run on module load | ||
init(); | ||
document.addEventListener('DOMContentLoaded', function () { | ||
draw(); | ||
}); | ||
module.exports = { | ||
// Add a coachmark | ||
add: function add(name) { | ||
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
window.addEventListener('resize', function () { | ||
requestAnimationFrame(function () { | ||
draw(); | ||
if (!(typeof name === 'string')) { | ||
config = name; | ||
name = Math.random().toString(36).substr(2); | ||
} | ||
(0, _cache3.default)(name, config); | ||
}, | ||
// Show a coachmark given a name | ||
show: function show(name) { | ||
(0, _draw.clear)(); | ||
(0, _draw.draw)(name); | ||
}, | ||
cache: function cache() { | ||
return _cache3.default.cache; | ||
}, | ||
draw: _draw.draw, | ||
redrawAll: _draw.redrawAll | ||
}; | ||
function init() { | ||
document.addEventListener('DOMContentLoaded', function () { | ||
addListeners(); | ||
}); | ||
} | ||
function addListeners() { | ||
window.addEventListener('resize', function () { | ||
requestAnimationFrame(function () { | ||
(0, _draw.redrawAll)(); | ||
}); | ||
}); | ||
window.addEventListener('resize', function () { | ||
requestAnimationFrame(function () { | ||
(0, _draw.redrawAll)(); | ||
}); | ||
}); | ||
} | ||
/***/ }), | ||
/* 28 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = { "default": __webpack_require__(29), __esModule: true }; | ||
/***/ }), | ||
/* 29 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(30); | ||
__webpack_require__(50); | ||
module.exports = __webpack_require__(52); | ||
/***/ }), | ||
/* 30 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(31); | ||
var global = __webpack_require__(0); | ||
var hide = __webpack_require__(3); | ||
var Iterators = __webpack_require__(4); | ||
var TO_STRING_TAG = __webpack_require__(1)('toStringTag'); | ||
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + | ||
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + | ||
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + | ||
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + | ||
'TextTrackList,TouchList').split(','); | ||
for (var i = 0; i < DOMIterables.length; i++) { | ||
var NAME = DOMIterables[i]; | ||
var Collection = global[NAME]; | ||
var proto = Collection && Collection.prototype; | ||
if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); | ||
Iterators[NAME] = Iterators.Array; | ||
} | ||
/***/ }), | ||
/* 31 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var addToUnscopables = __webpack_require__(32); | ||
var step = __webpack_require__(33); | ||
var Iterators = __webpack_require__(4); | ||
var toIObject = __webpack_require__(8); | ||
// 22.1.3.4 Array.prototype.entries() | ||
// 22.1.3.13 Array.prototype.keys() | ||
// 22.1.3.29 Array.prototype.values() | ||
// 22.1.3.30 Array.prototype[@@iterator]() | ||
module.exports = __webpack_require__(17)(Array, 'Array', function (iterated, kind) { | ||
this._t = toIObject(iterated); // target | ||
this._i = 0; // next index | ||
this._k = kind; // kind | ||
// 22.1.5.2.1 %ArrayIteratorPrototype%.next() | ||
}, function () { | ||
var O = this._t; | ||
var kind = this._k; | ||
var index = this._i++; | ||
if (!O || index >= O.length) { | ||
this._t = undefined; | ||
return step(1); | ||
} | ||
if (kind == 'keys') return step(0, index); | ||
if (kind == 'values') return step(0, O[index]); | ||
return step(0, [index, O[index]]); | ||
}, 'values'); | ||
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) | ||
Iterators.Arguments = Iterators.Array; | ||
addToUnscopables('keys'); | ||
addToUnscopables('values'); | ||
addToUnscopables('entries'); | ||
/***/ }), | ||
/* 32 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function () { /* empty */ }; | ||
/***/ }), | ||
/* 33 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function (done, value) { | ||
return { value: value, done: !!done }; | ||
}; | ||
/***/ }), | ||
/* 34 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// fallback for non-array-like ES3 and non-enumerable old V8 strings | ||
var cof = __webpack_require__(16); | ||
// eslint-disable-next-line no-prototype-builtins | ||
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { | ||
return cof(it) == 'String' ? it.split('') : Object(it); | ||
}; | ||
/***/ }), | ||
/* 35 */ | ||
/***/ (function(module, exports) { | ||
module.exports = true; | ||
/***/ }), | ||
/* 36 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// optional / simple context binding | ||
var aFunction = __webpack_require__(37); | ||
module.exports = function (fn, that, length) { | ||
aFunction(fn); | ||
if (that === undefined) return fn; | ||
switch (length) { | ||
case 1: return function (a) { | ||
return fn.call(that, a); | ||
}; | ||
case 2: return function (a, b) { | ||
return fn.call(that, a, b); | ||
}; | ||
case 3: return function (a, b, c) { | ||
return fn.call(that, a, b, c); | ||
}; | ||
} | ||
return function (/* ...args */) { | ||
return fn.apply(that, arguments); | ||
}; | ||
}; | ||
/***/ }), | ||
/* 37 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function (it) { | ||
if (typeof it != 'function') throw TypeError(it + ' is not a function!'); | ||
return it; | ||
}; | ||
/***/ }), | ||
/* 38 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = !__webpack_require__(6) && !__webpack_require__(12)(function () { | ||
return Object.defineProperty(__webpack_require__(19)('div'), 'a', { get: function () { return 7; } }).a != 7; | ||
}); | ||
function draw() { | ||
var coached = coach(); | ||
var text = addText('Click this button to do stuff!'); | ||
arrow( | ||
// middleOfEdge(text, 'bottom'), | ||
// middleOfEdge(coached, 'right'), | ||
coached, text); | ||
/***/ }), | ||
/* 39 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.1 ToPrimitive(input [, PreferredType]) | ||
var isObject = __webpack_require__(11); | ||
// instead of the ES6 spec version, we didn't implement @@toPrimitive case | ||
// and the second argument - flag - preferred type is a string | ||
module.exports = function (it, S) { | ||
if (!isObject(it)) return it; | ||
var fn, val; | ||
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; | ||
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; | ||
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; | ||
throw TypeError("Can't convert object to primitive value"); | ||
}; | ||
/***/ }), | ||
/* 40 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(3); | ||
/***/ }), | ||
/* 41 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var create = __webpack_require__(42); | ||
var descriptor = __webpack_require__(20); | ||
var setToStringTag = __webpack_require__(25); | ||
var IteratorPrototype = {}; | ||
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() | ||
__webpack_require__(3)(IteratorPrototype, __webpack_require__(1)('iterator'), function () { return this; }); | ||
module.exports = function (Constructor, NAME, next) { | ||
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); | ||
setToStringTag(Constructor, NAME + ' Iterator'); | ||
}; | ||
/***/ }), | ||
/* 42 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) | ||
var anObject = __webpack_require__(5); | ||
var dPs = __webpack_require__(43); | ||
var enumBugKeys = __webpack_require__(24); | ||
var IE_PROTO = __webpack_require__(14)('IE_PROTO'); | ||
var Empty = function () { /* empty */ }; | ||
var PROTOTYPE = 'prototype'; | ||
// Create object with fake `null` prototype: use iframe Object with cleared prototype | ||
var createDict = function () { | ||
// Thrash, waste and sodomy: IE GC bug | ||
var iframe = __webpack_require__(19)('iframe'); | ||
var i = enumBugKeys.length; | ||
var lt = '<'; | ||
var gt = '>'; | ||
var iframeDocument; | ||
iframe.style.display = 'none'; | ||
__webpack_require__(48).appendChild(iframe); | ||
iframe.src = 'javascript:'; // eslint-disable-line no-script-url | ||
// createDict = iframe.contentWindow.Object; | ||
// html.removeChild(iframe); | ||
iframeDocument = iframe.contentWindow.document; | ||
iframeDocument.open(); | ||
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); | ||
iframeDocument.close(); | ||
createDict = iframeDocument.F; | ||
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; | ||
return createDict(); | ||
}; | ||
module.exports = Object.create || function create(O, Properties) { | ||
var result; | ||
if (O !== null) { | ||
Empty[PROTOTYPE] = anObject(O); | ||
result = new Empty(); | ||
Empty[PROTOTYPE] = null; | ||
// add "__proto__" for Object.getPrototypeOf polyfill | ||
result[IE_PROTO] = O; | ||
} else result = createDict(); | ||
return Properties === undefined ? result : dPs(result, Properties); | ||
}; | ||
/***/ }), | ||
/* 43 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var dP = __webpack_require__(10); | ||
var anObject = __webpack_require__(5); | ||
var getKeys = __webpack_require__(21); | ||
module.exports = __webpack_require__(6) ? Object.defineProperties : function defineProperties(O, Properties) { | ||
anObject(O); | ||
var keys = getKeys(Properties); | ||
var length = keys.length; | ||
var i = 0; | ||
var P; | ||
while (length > i) dP.f(O, P = keys[i++], Properties[P]); | ||
return O; | ||
}; | ||
/***/ }), | ||
/* 44 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var has = __webpack_require__(7); | ||
var toIObject = __webpack_require__(8); | ||
var arrayIndexOf = __webpack_require__(45)(false); | ||
var IE_PROTO = __webpack_require__(14)('IE_PROTO'); | ||
module.exports = function (object, names) { | ||
var O = toIObject(object); | ||
var i = 0; | ||
var result = []; | ||
var key; | ||
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); | ||
// Don't enum bug & hidden keys | ||
while (names.length > i) if (has(O, key = names[i++])) { | ||
~arrayIndexOf(result, key) || result.push(key); | ||
} | ||
return result; | ||
}; | ||
/***/ }), | ||
/* 45 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// false -> Array#indexOf | ||
// true -> Array#includes | ||
var toIObject = __webpack_require__(8); | ||
var toLength = __webpack_require__(46); | ||
var toAbsoluteIndex = __webpack_require__(47); | ||
module.exports = function (IS_INCLUDES) { | ||
return function ($this, el, fromIndex) { | ||
var O = toIObject($this); | ||
var length = toLength(O.length); | ||
var index = toAbsoluteIndex(fromIndex, length); | ||
var value; | ||
// Array#includes uses SameValueZero equality algorithm | ||
// eslint-disable-next-line no-self-compare | ||
if (IS_INCLUDES && el != el) while (length > index) { | ||
value = O[index++]; | ||
// eslint-disable-next-line no-self-compare | ||
if (value != value) return true; | ||
// Array#indexOf ignores holes, Array#includes - not | ||
} else for (;length > index; index++) if (IS_INCLUDES || index in O) { | ||
if (O[index] === el) return IS_INCLUDES || index || 0; | ||
} return !IS_INCLUDES && -1; | ||
}; | ||
}; | ||
/***/ }), | ||
/* 46 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.15 ToLength | ||
var toInteger = __webpack_require__(13); | ||
var min = Math.min; | ||
module.exports = function (it) { | ||
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 | ||
}; | ||
/***/ }), | ||
/* 47 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var toInteger = __webpack_require__(13); | ||
var max = Math.max; | ||
var min = Math.min; | ||
module.exports = function (index, length) { | ||
index = toInteger(index); | ||
return index < 0 ? max(index + length, 0) : min(index, length); | ||
}; | ||
/***/ }), | ||
/* 48 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var document = __webpack_require__(0).document; | ||
module.exports = document && document.documentElement; | ||
/***/ }), | ||
/* 49 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) | ||
var has = __webpack_require__(7); | ||
var toObject = __webpack_require__(26); | ||
var IE_PROTO = __webpack_require__(14)('IE_PROTO'); | ||
var ObjectProto = Object.prototype; | ||
module.exports = Object.getPrototypeOf || function (O) { | ||
O = toObject(O); | ||
if (has(O, IE_PROTO)) return O[IE_PROTO]; | ||
if (typeof O.constructor == 'function' && O instanceof O.constructor) { | ||
return O.constructor.prototype; | ||
} return O instanceof Object ? ObjectProto : null; | ||
}; | ||
/***/ }), | ||
/* 50 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var $at = __webpack_require__(51)(true); | ||
// 21.1.3.27 String.prototype[@@iterator]() | ||
__webpack_require__(17)(String, 'String', function (iterated) { | ||
this._t = String(iterated); // target | ||
this._i = 0; // next index | ||
// 21.1.5.2.1 %StringIteratorPrototype%.next() | ||
}, function () { | ||
var O = this._t; | ||
var index = this._i; | ||
var point; | ||
if (index >= O.length) return { value: undefined, done: true }; | ||
point = $at(O, index); | ||
this._i += point.length; | ||
return { value: point, done: false }; | ||
}); | ||
/***/ }), | ||
/* 51 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var toInteger = __webpack_require__(13); | ||
var defined = __webpack_require__(9); | ||
// true -> String#at | ||
// false -> String#codePointAt | ||
module.exports = function (TO_STRING) { | ||
return function (that, pos) { | ||
var s = String(defined(that)); | ||
var i = toInteger(pos); | ||
var l = s.length; | ||
var a, b; | ||
if (i < 0 || i >= l) return TO_STRING ? '' : undefined; | ||
a = s.charCodeAt(i); | ||
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff | ||
? TO_STRING ? s.charAt(i) : a | ||
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; | ||
}; | ||
}; | ||
/***/ }), | ||
/* 52 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var anObject = __webpack_require__(5); | ||
var get = __webpack_require__(53); | ||
module.exports = __webpack_require__(2).getIterator = function (it) { | ||
var iterFn = get(it); | ||
if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); | ||
return anObject(iterFn.call(it)); | ||
}; | ||
/***/ }), | ||
/* 53 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var classof = __webpack_require__(54); | ||
var ITERATOR = __webpack_require__(1)('iterator'); | ||
var Iterators = __webpack_require__(4); | ||
module.exports = __webpack_require__(2).getIteratorMethod = function (it) { | ||
if (it != undefined) return it[ITERATOR] | ||
|| it['@@iterator'] | ||
|| Iterators[classof(it)]; | ||
}; | ||
/***/ }), | ||
/* 54 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// getting tag from 19.1.3.6 Object.prototype.toString() | ||
var cof = __webpack_require__(16); | ||
var TAG = __webpack_require__(1)('toStringTag'); | ||
// ES3 wrong here | ||
var ARG = cof(function () { return arguments; }()) == 'Arguments'; | ||
// fallback for IE11 Script Access Denied error | ||
var tryGet = function (it, key) { | ||
try { | ||
return it[key]; | ||
} catch (e) { /* empty */ } | ||
}; | ||
module.exports = function (it) { | ||
var O, T, B; | ||
return it === undefined ? 'Undefined' : it === null ? 'Null' | ||
// @@toStringTag case | ||
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T | ||
// builtinTag case | ||
: ARG ? cof(O) | ||
// ES3 arguments fallback | ||
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; | ||
}; | ||
/***/ }), | ||
/* 55 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _keys = __webpack_require__(56); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
exports.clear = clear; | ||
exports.redrawAll = redrawAll; | ||
exports.draw = draw; | ||
exports.addText = addText; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var SvgPath = __webpack_require__(60); | ||
var cache = __webpack_require__(15); | ||
// TODO: for positioning choose biggest delta between x and y, it will be one of two (i.e. bottom or left), so choose the one that's the largest delta from the other point's (maybe) | ||
var elmNames = ['elm', 'text', 'coachTop', 'coachLeft', 'coachRight', 'coachBottom', 'glow', 'svg', 'path']; | ||
function clear() { | ||
elmNames.forEach(function (node) { | ||
if (node instanceof Node) node.remove(); | ||
}); | ||
} | ||
window.draw = draw; | ||
function coach() { | ||
function redrawAll() { | ||
var all = cache.all(); | ||
(0, _keys2.default)(all).forEach(function (key) { | ||
var item = cache(key); | ||
if (!(item instanceof Node)) { | ||
draw(key); | ||
} | ||
}); | ||
} | ||
function draw(name) { | ||
var mark = cache(name); | ||
if (!mark) throw new Error('Coachmark with name \'' + name + '\' not found'); | ||
var coached = coach(mark); | ||
var text = addText(mark.text); | ||
arrow(coached, text); | ||
} | ||
function coach(mark) { | ||
if (!mark) throw new Error('Coachmark with name \'' + name + '\' not found'); | ||
var elm = cache.default('elm', function () { | ||
return document.querySelector(target); | ||
return document.querySelector(mark.target); | ||
}); | ||
@@ -481,3 +1234,2 @@ | ||
elm.style.position = 'absolute'; | ||
// elm.style['box-shadow'] = '0 0 150px 30px #fff'; | ||
elm.style['z-index'] = 102; | ||
@@ -521,4 +1273,2 @@ | ||
// const longDim = height > width ? height : width; | ||
var glow = cache.default('glow', function () { | ||
@@ -529,6 +1279,2 @@ return document.createElement('div'); | ||
glow.className = 'coachmark-glow'; | ||
// glow.style.top = (top + height / 4) + 'px'; | ||
// glow.style.left = (left + width / 4) + 'px'; | ||
// glow.style.width = width - width / 2 + 'px'; | ||
// glow.style.height = height - height / 2 + 'px'; | ||
glow.style.top = top + 'px'; | ||
@@ -577,3 +1323,3 @@ glow.style.left = left + 'px'; | ||
console.log(fromEdge, toEdge, fromPos, toPos); | ||
// console.log(fromEdge, toEdge, fromPos, toPos); | ||
@@ -642,2 +1388,5 @@ // const s = slope(fromPos[0], fromPos[1], toPos[0], toPos[1]); | ||
function middleOfEdge(node, edge) { | ||
// Spacing between line and node | ||
var lineOffset = 20; | ||
var rect = elementRect(node); | ||
@@ -689,3 +1438,2 @@ | ||
} | ||
window.elementRect = elementRect; | ||
@@ -777,5 +1525,50 @@ function midPoint(x1, y1, x2, y2) { | ||
/***/ }), | ||
/* 24 */ | ||
/* 56 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = { "default": __webpack_require__(57), __esModule: true }; | ||
/***/ }), | ||
/* 57 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(58); | ||
module.exports = __webpack_require__(2).Object.keys; | ||
/***/ }), | ||
/* 58 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.14 Object.keys(O) | ||
var toObject = __webpack_require__(26); | ||
var $keys = __webpack_require__(21); | ||
__webpack_require__(59)('keys', function () { | ||
return function keys(it) { | ||
return $keys(toObject(it)); | ||
}; | ||
}); | ||
/***/ }), | ||
/* 59 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// most Object methods by ES6 should accept primitives | ||
var $export = __webpack_require__(18); | ||
var core = __webpack_require__(2); | ||
var fails = __webpack_require__(12); | ||
module.exports = function (KEY, exec) { | ||
var fn = (core.Object || {})[KEY] || Object[KEY]; | ||
var exp = {}; | ||
exp[KEY] = exec(fn); | ||
$export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); | ||
}; | ||
/***/ }), | ||
/* 60 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** | ||
@@ -1026,648 +1819,4 @@ * SvgPath | ||
/***/ }), | ||
/* 25 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var _getIterator2 = __webpack_require__(26); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function cache(name, obj) { | ||
if (typeof obj === 'undefined') { | ||
// Get | ||
return cache[name]; | ||
} | ||
// Set | ||
cache[name] = obj; | ||
return obj; | ||
} | ||
cache.remove = function (name) { | ||
if (name) cache[name] = undefined; | ||
}; | ||
cache.clear = function () { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = (0, _getIterator3.default)(cache), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var c = _step.value; | ||
cache[c] = undefined; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
}; | ||
cache.default = function (name, defaultFn) { | ||
var obj = cache(name); | ||
if (obj === undefined) return cache(name, defaultFn.call()); | ||
return obj; | ||
}; | ||
cache.all = function () { | ||
var elms = []; | ||
for (var key in cache) { | ||
if (Object.prototype.hasOwnProperty.call(cache, key)) { | ||
elms.push({ key: cache[key] }); | ||
} | ||
} | ||
return elms; | ||
}; | ||
module.exports = cache; | ||
/***/ }), | ||
/* 26 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = { "default": __webpack_require__(27), __esModule: true }; | ||
/***/ }), | ||
/* 27 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(28); | ||
__webpack_require__(51); | ||
module.exports = __webpack_require__(53); | ||
/***/ }), | ||
/* 28 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(29); | ||
var global = __webpack_require__(0); | ||
var hide = __webpack_require__(2); | ||
var Iterators = __webpack_require__(3); | ||
var TO_STRING_TAG = __webpack_require__(1)('toStringTag'); | ||
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + | ||
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + | ||
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + | ||
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + | ||
'TextTrackList,TouchList').split(','); | ||
for (var i = 0; i < DOMIterables.length; i++) { | ||
var NAME = DOMIterables[i]; | ||
var Collection = global[NAME]; | ||
var proto = Collection && Collection.prototype; | ||
if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); | ||
Iterators[NAME] = Iterators.Array; | ||
} | ||
/***/ }), | ||
/* 29 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var addToUnscopables = __webpack_require__(30); | ||
var step = __webpack_require__(31); | ||
var Iterators = __webpack_require__(3); | ||
var toIObject = __webpack_require__(7); | ||
// 22.1.3.4 Array.prototype.entries() | ||
// 22.1.3.13 Array.prototype.keys() | ||
// 22.1.3.29 Array.prototype.values() | ||
// 22.1.3.30 Array.prototype[@@iterator]() | ||
module.exports = __webpack_require__(15)(Array, 'Array', function (iterated, kind) { | ||
this._t = toIObject(iterated); // target | ||
this._i = 0; // next index | ||
this._k = kind; // kind | ||
// 22.1.5.2.1 %ArrayIteratorPrototype%.next() | ||
}, function () { | ||
var O = this._t; | ||
var kind = this._k; | ||
var index = this._i++; | ||
if (!O || index >= O.length) { | ||
this._t = undefined; | ||
return step(1); | ||
} | ||
if (kind == 'keys') return step(0, index); | ||
if (kind == 'values') return step(0, O[index]); | ||
return step(0, [index, O[index]]); | ||
}, 'values'); | ||
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) | ||
Iterators.Arguments = Iterators.Array; | ||
addToUnscopables('keys'); | ||
addToUnscopables('values'); | ||
addToUnscopables('entries'); | ||
/***/ }), | ||
/* 30 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function () { /* empty */ }; | ||
/***/ }), | ||
/* 31 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function (done, value) { | ||
return { value: value, done: !!done }; | ||
}; | ||
/***/ }), | ||
/* 32 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// fallback for non-array-like ES3 and non-enumerable old V8 strings | ||
var cof = __webpack_require__(14); | ||
// eslint-disable-next-line no-prototype-builtins | ||
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { | ||
return cof(it) == 'String' ? it.split('') : Object(it); | ||
}; | ||
/***/ }), | ||
/* 33 */ | ||
/***/ (function(module, exports) { | ||
module.exports = true; | ||
/***/ }), | ||
/* 34 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var global = __webpack_require__(0); | ||
var core = __webpack_require__(9); | ||
var ctx = __webpack_require__(35); | ||
var hide = __webpack_require__(2); | ||
var PROTOTYPE = 'prototype'; | ||
var $export = function (type, name, source) { | ||
var IS_FORCED = type & $export.F; | ||
var IS_GLOBAL = type & $export.G; | ||
var IS_STATIC = type & $export.S; | ||
var IS_PROTO = type & $export.P; | ||
var IS_BIND = type & $export.B; | ||
var IS_WRAP = type & $export.W; | ||
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); | ||
var expProto = exports[PROTOTYPE]; | ||
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; | ||
var key, own, out; | ||
if (IS_GLOBAL) source = name; | ||
for (key in source) { | ||
// contains in native | ||
own = !IS_FORCED && target && target[key] !== undefined; | ||
if (own && key in exports) continue; | ||
// export native or passed | ||
out = own ? target[key] : source[key]; | ||
// prevent global pollution for namespaces | ||
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] | ||
// bind timers to global for call from export context | ||
: IS_BIND && own ? ctx(out, global) | ||
// wrap global constructors for prevent change them in library | ||
: IS_WRAP && target[key] == out ? (function (C) { | ||
var F = function (a, b, c) { | ||
if (this instanceof C) { | ||
switch (arguments.length) { | ||
case 0: return new C(); | ||
case 1: return new C(a); | ||
case 2: return new C(a, b); | ||
} return new C(a, b, c); | ||
} return C.apply(this, arguments); | ||
}; | ||
F[PROTOTYPE] = C[PROTOTYPE]; | ||
return F; | ||
// make static versions for prototype methods | ||
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; | ||
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME% | ||
if (IS_PROTO) { | ||
(exports.virtual || (exports.virtual = {}))[key] = out; | ||
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% | ||
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); | ||
} | ||
} | ||
}; | ||
// type bitmap | ||
$export.F = 1; // forced | ||
$export.G = 2; // global | ||
$export.S = 4; // static | ||
$export.P = 8; // proto | ||
$export.B = 16; // bind | ||
$export.W = 32; // wrap | ||
$export.U = 64; // safe | ||
$export.R = 128; // real proto method for `library` | ||
module.exports = $export; | ||
/***/ }), | ||
/* 35 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// optional / simple context binding | ||
var aFunction = __webpack_require__(36); | ||
module.exports = function (fn, that, length) { | ||
aFunction(fn); | ||
if (that === undefined) return fn; | ||
switch (length) { | ||
case 1: return function (a) { | ||
return fn.call(that, a); | ||
}; | ||
case 2: return function (a, b) { | ||
return fn.call(that, a, b); | ||
}; | ||
case 3: return function (a, b, c) { | ||
return fn.call(that, a, b, c); | ||
}; | ||
} | ||
return function (/* ...args */) { | ||
return fn.apply(that, arguments); | ||
}; | ||
}; | ||
/***/ }), | ||
/* 36 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function (it) { | ||
if (typeof it != 'function') throw TypeError(it + ' is not a function!'); | ||
return it; | ||
}; | ||
/***/ }), | ||
/* 37 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = !__webpack_require__(5) && !__webpack_require__(16)(function () { | ||
return Object.defineProperty(__webpack_require__(17)('div'), 'a', { get: function () { return 7; } }).a != 7; | ||
}); | ||
/***/ }), | ||
/* 38 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.1 ToPrimitive(input [, PreferredType]) | ||
var isObject = __webpack_require__(11); | ||
// instead of the ES6 spec version, we didn't implement @@toPrimitive case | ||
// and the second argument - flag - preferred type is a string | ||
module.exports = function (it, S) { | ||
if (!isObject(it)) return it; | ||
var fn, val; | ||
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; | ||
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; | ||
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; | ||
throw TypeError("Can't convert object to primitive value"); | ||
}; | ||
/***/ }), | ||
/* 39 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(2); | ||
/***/ }), | ||
/* 40 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var create = __webpack_require__(41); | ||
var descriptor = __webpack_require__(18); | ||
var setToStringTag = __webpack_require__(22); | ||
var IteratorPrototype = {}; | ||
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() | ||
__webpack_require__(2)(IteratorPrototype, __webpack_require__(1)('iterator'), function () { return this; }); | ||
module.exports = function (Constructor, NAME, next) { | ||
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); | ||
setToStringTag(Constructor, NAME + ' Iterator'); | ||
}; | ||
/***/ }), | ||
/* 41 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) | ||
var anObject = __webpack_require__(4); | ||
var dPs = __webpack_require__(42); | ||
var enumBugKeys = __webpack_require__(21); | ||
var IE_PROTO = __webpack_require__(13)('IE_PROTO'); | ||
var Empty = function () { /* empty */ }; | ||
var PROTOTYPE = 'prototype'; | ||
// Create object with fake `null` prototype: use iframe Object with cleared prototype | ||
var createDict = function () { | ||
// Thrash, waste and sodomy: IE GC bug | ||
var iframe = __webpack_require__(17)('iframe'); | ||
var i = enumBugKeys.length; | ||
var lt = '<'; | ||
var gt = '>'; | ||
var iframeDocument; | ||
iframe.style.display = 'none'; | ||
__webpack_require__(48).appendChild(iframe); | ||
iframe.src = 'javascript:'; // eslint-disable-line no-script-url | ||
// createDict = iframe.contentWindow.Object; | ||
// html.removeChild(iframe); | ||
iframeDocument = iframe.contentWindow.document; | ||
iframeDocument.open(); | ||
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); | ||
iframeDocument.close(); | ||
createDict = iframeDocument.F; | ||
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; | ||
return createDict(); | ||
}; | ||
module.exports = Object.create || function create(O, Properties) { | ||
var result; | ||
if (O !== null) { | ||
Empty[PROTOTYPE] = anObject(O); | ||
result = new Empty(); | ||
Empty[PROTOTYPE] = null; | ||
// add "__proto__" for Object.getPrototypeOf polyfill | ||
result[IE_PROTO] = O; | ||
} else result = createDict(); | ||
return Properties === undefined ? result : dPs(result, Properties); | ||
}; | ||
/***/ }), | ||
/* 42 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var dP = __webpack_require__(10); | ||
var anObject = __webpack_require__(4); | ||
var getKeys = __webpack_require__(43); | ||
module.exports = __webpack_require__(5) ? Object.defineProperties : function defineProperties(O, Properties) { | ||
anObject(O); | ||
var keys = getKeys(Properties); | ||
var length = keys.length; | ||
var i = 0; | ||
var P; | ||
while (length > i) dP.f(O, P = keys[i++], Properties[P]); | ||
return O; | ||
}; | ||
/***/ }), | ||
/* 43 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.14 / 15.2.3.14 Object.keys(O) | ||
var $keys = __webpack_require__(44); | ||
var enumBugKeys = __webpack_require__(21); | ||
module.exports = Object.keys || function keys(O) { | ||
return $keys(O, enumBugKeys); | ||
}; | ||
/***/ }), | ||
/* 44 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var has = __webpack_require__(6); | ||
var toIObject = __webpack_require__(7); | ||
var arrayIndexOf = __webpack_require__(45)(false); | ||
var IE_PROTO = __webpack_require__(13)('IE_PROTO'); | ||
module.exports = function (object, names) { | ||
var O = toIObject(object); | ||
var i = 0; | ||
var result = []; | ||
var key; | ||
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); | ||
// Don't enum bug & hidden keys | ||
while (names.length > i) if (has(O, key = names[i++])) { | ||
~arrayIndexOf(result, key) || result.push(key); | ||
} | ||
return result; | ||
}; | ||
/***/ }), | ||
/* 45 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// false -> Array#indexOf | ||
// true -> Array#includes | ||
var toIObject = __webpack_require__(7); | ||
var toLength = __webpack_require__(46); | ||
var toAbsoluteIndex = __webpack_require__(47); | ||
module.exports = function (IS_INCLUDES) { | ||
return function ($this, el, fromIndex) { | ||
var O = toIObject($this); | ||
var length = toLength(O.length); | ||
var index = toAbsoluteIndex(fromIndex, length); | ||
var value; | ||
// Array#includes uses SameValueZero equality algorithm | ||
// eslint-disable-next-line no-self-compare | ||
if (IS_INCLUDES && el != el) while (length > index) { | ||
value = O[index++]; | ||
// eslint-disable-next-line no-self-compare | ||
if (value != value) return true; | ||
// Array#indexOf ignores holes, Array#includes - not | ||
} else for (;length > index; index++) if (IS_INCLUDES || index in O) { | ||
if (O[index] === el) return IS_INCLUDES || index || 0; | ||
} return !IS_INCLUDES && -1; | ||
}; | ||
}; | ||
/***/ }), | ||
/* 46 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.15 ToLength | ||
var toInteger = __webpack_require__(12); | ||
var min = Math.min; | ||
module.exports = function (it) { | ||
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 | ||
}; | ||
/***/ }), | ||
/* 47 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var toInteger = __webpack_require__(12); | ||
var max = Math.max; | ||
var min = Math.min; | ||
module.exports = function (index, length) { | ||
index = toInteger(index); | ||
return index < 0 ? max(index + length, 0) : min(index, length); | ||
}; | ||
/***/ }), | ||
/* 48 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var document = __webpack_require__(0).document; | ||
module.exports = document && document.documentElement; | ||
/***/ }), | ||
/* 49 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) | ||
var has = __webpack_require__(6); | ||
var toObject = __webpack_require__(50); | ||
var IE_PROTO = __webpack_require__(13)('IE_PROTO'); | ||
var ObjectProto = Object.prototype; | ||
module.exports = Object.getPrototypeOf || function (O) { | ||
O = toObject(O); | ||
if (has(O, IE_PROTO)) return O[IE_PROTO]; | ||
if (typeof O.constructor == 'function' && O instanceof O.constructor) { | ||
return O.constructor.prototype; | ||
} return O instanceof Object ? ObjectProto : null; | ||
}; | ||
/***/ }), | ||
/* 50 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// 7.1.13 ToObject(argument) | ||
var defined = __webpack_require__(8); | ||
module.exports = function (it) { | ||
return Object(defined(it)); | ||
}; | ||
/***/ }), | ||
/* 51 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var $at = __webpack_require__(52)(true); | ||
// 21.1.3.27 String.prototype[@@iterator]() | ||
__webpack_require__(15)(String, 'String', function (iterated) { | ||
this._t = String(iterated); // target | ||
this._i = 0; // next index | ||
// 21.1.5.2.1 %StringIteratorPrototype%.next() | ||
}, function () { | ||
var O = this._t; | ||
var index = this._i; | ||
var point; | ||
if (index >= O.length) return { value: undefined, done: true }; | ||
point = $at(O, index); | ||
this._i += point.length; | ||
return { value: point, done: false }; | ||
}); | ||
/***/ }), | ||
/* 52 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var toInteger = __webpack_require__(12); | ||
var defined = __webpack_require__(8); | ||
// true -> String#at | ||
// false -> String#codePointAt | ||
module.exports = function (TO_STRING) { | ||
return function (that, pos) { | ||
var s = String(defined(that)); | ||
var i = toInteger(pos); | ||
var l = s.length; | ||
var a, b; | ||
if (i < 0 || i >= l) return TO_STRING ? '' : undefined; | ||
a = s.charCodeAt(i); | ||
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff | ||
? TO_STRING ? s.charAt(i) : a | ||
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; | ||
}; | ||
}; | ||
/***/ }), | ||
/* 53 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var anObject = __webpack_require__(4); | ||
var get = __webpack_require__(54); | ||
module.exports = __webpack_require__(9).getIterator = function (it) { | ||
var iterFn = get(it); | ||
if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); | ||
return anObject(iterFn.call(it)); | ||
}; | ||
/***/ }), | ||
/* 54 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var classof = __webpack_require__(55); | ||
var ITERATOR = __webpack_require__(1)('iterator'); | ||
var Iterators = __webpack_require__(3); | ||
module.exports = __webpack_require__(9).getIteratorMethod = function (it) { | ||
if (it != undefined) return it[ITERATOR] | ||
|| it['@@iterator'] | ||
|| Iterators[classof(it)]; | ||
}; | ||
/***/ }), | ||
/* 55 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// getting tag from 19.1.3.6 Object.prototype.toString() | ||
var cof = __webpack_require__(14); | ||
var TAG = __webpack_require__(1)('toStringTag'); | ||
// ES3 wrong here | ||
var ARG = cof(function () { return arguments; }()) == 'Arguments'; | ||
// fallback for IE11 Script Access Denied error | ||
var tryGet = function (it, key) { | ||
try { | ||
return it[key]; | ||
} catch (e) { /* empty */ } | ||
}; | ||
module.exports = function (it) { | ||
var O, T, B; | ||
return it === undefined ? 'Undefined' : it === null ? 'Null' | ||
// @@toStringTag case | ||
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T | ||
// builtinTag case | ||
: ARG ? cof(O) | ||
// ES3 arguments fallback | ||
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; | ||
}; | ||
/***/ }) | ||
/******/ ]); | ||
//# sourceMappingURL=coachmarks.js.map |
{ | ||
"name": "coachmarks", | ||
"version": "1.0.1", | ||
"description": "On-board new users and introduce new features with explanatory coachmarks", | ||
"version": "1.0.2", | ||
"description": "On-board new users to your app and introduce new features with SVG sketches (coachmarks)", | ||
"main": "dist/coachmarks.js", | ||
@@ -11,3 +11,3 @@ "browser": "dist/coachmarks.js", | ||
"watch": "npm run test -- --watch", | ||
"build": "webpack", | ||
"build": "webpack && NODE_ENV=prod webpack", | ||
"dev": "webpack-dev-server", | ||
@@ -30,2 +30,3 @@ "build:watch": "onchange src/** -- webpack", | ||
"babel-preset-es2017": "^6.24.1", | ||
"browser-env": "^3.2.4", | ||
"cypress": "^1.0.2", | ||
@@ -70,2 +71,8 @@ "doctoc": "^1.3.0", | ||
{ | ||
"files": "test/**", | ||
"rules": { | ||
"import/default": "off" | ||
} | ||
}, | ||
{ | ||
"files": "cypress/**", | ||
@@ -109,3 +116,4 @@ "globals": [ | ||
"require": [ | ||
"babel-register" | ||
"babel-register", | ||
"./test/helpers/setup-browser-env.js" | ||
] | ||
@@ -112,0 +120,0 @@ }, |
@@ -12,9 +12,20 @@ | ||
const coachmarks = require('coachmarks'); | ||
```javascript | ||
const coachmarks = require('coachmarks'); | ||
``` | ||
or | ||
import coachmarks from 'coachmarks'; | ||
```javascript | ||
import coachmarks from 'coachmarks'; | ||
coachmarks.add('start-button', { | ||
target: '#start-button', | ||
content: 'Click this button to get started!'. | ||
}); | ||
document.addEventListener('DOMContentLoaded', () => { | ||
coachmarks.show('start-button'); | ||
}); | ||
``` | ||
@@ -28,6 +39,8 @@ # Notes | ||
- [ ] Make script a node module | ||
- [ ] | ||
- [ ] Allow configuring targets and text via JSON. (Multiple targets) | ||
- [ ] Allow configuring trigger events, or API | ||
- [ ] Add close button | ||
- [ ] Append CSS to page from inside module | ||
- [x] SVG path getting clipped when it's mostly horizontal (chalk filter causing it). (Fixed in a very hacky way (5000px...)) | ||
- [x] BUG: when text is on right side of button, arrowhead is on left side of button instead of right side. | ||
And the start of the line is from the right side of the text, not left side. | ||
- [x] BUG: when text is on right side of button, arrowhead is on left side of button instead of right side. And the start of the line is from the right side of the text, not left side. | ||
- [ ] Turn SVG stuff into content that gets appended to page on script load | ||
@@ -41,1 +54,3 @@ - [ ] If text is just a little bit above or below the button vertically, it will anchor to the top position when it should still be the side | ||
- [ ] Handle rezizing, orientation changes, and media query changes | ||
# Idea |
function cache(name, obj) { | ||
function cache(...args) { | ||
return cache.addOrGet(...args); | ||
} | ||
cache.init = () => { | ||
if (!cache.cache) { | ||
cache.cache = {}; | ||
} | ||
}; | ||
cache.addOrGet = (name, obj) => { | ||
cache.init(); | ||
if (typeof obj === 'undefined') { | ||
// Get | ||
return cache[name]; | ||
return cache.get(name); | ||
} | ||
// Set | ||
cache[name] = obj; | ||
cache.add(name, obj); | ||
return obj; | ||
} | ||
}; | ||
cache.get = name => { | ||
cache.init(); | ||
return cache.cache[name]; | ||
}; | ||
cache.add = (name, obj) => { | ||
cache.init(); | ||
cache.cache[name] = obj; | ||
return obj; | ||
}; | ||
cache.remove = name => { | ||
if (name) cache[name] = undefined; | ||
cache.init(); | ||
if (name) cache.cache[name] = undefined; | ||
}; | ||
cache.clear = () => { | ||
for (const c of cache) { | ||
cache[c] = undefined; | ||
cache.init(); | ||
for (const c of cache.cache) { | ||
cache.cache[c] = undefined; | ||
} | ||
@@ -31,8 +56,15 @@ }; | ||
cache.all = () => { | ||
cache.init(); | ||
return cache.cache; | ||
}; | ||
cache.allArray = () => { | ||
cache.init(); | ||
const elms = []; | ||
for (const key in cache) { | ||
if (Object.prototype.hasOwnProperty.call(cache, key)) { | ||
elms.push({ key: cache[key] }); | ||
if (Object.prototype.hasOwnProperty.call(cache.cache, key)) { | ||
elms.push({ key: cache.cache[key] }); | ||
} | ||
} | ||
return elms; | ||
@@ -39,0 +71,0 @@ }; |
347
src/index.js
@@ -0,324 +1,45 @@ | ||
import cache from './cache'; | ||
import { clear, draw, redrawAll } from './draw'; | ||
// const isElement = require('iselement'); | ||
// const filter = require('lodash/filter'); | ||
const SvgPath = require('path-svg/svg-path'); | ||
const cache = require('./cache'); | ||
// Run on module load | ||
init(); | ||
// TODO: for positioning choose biggest delta between x and y, it will be one of two (i.e. bottom or left), so choose the one that's the largest delta from the other point's (maybe) | ||
module.exports = { | ||
// Add a coachmark | ||
add(name, config = {}) { | ||
if (!(typeof name === 'string')) { | ||
config = name; | ||
name = Math.random().toString(36).substr(2); | ||
} | ||
const target = '#btn'; | ||
cache(name, config); | ||
}, | ||
// Show a coachmark given a name | ||
show(name) { | ||
clear(); | ||
draw(name); | ||
}, | ||
cache: () => cache.cache, | ||
draw, | ||
redrawAll, | ||
}; | ||
// Distance from line to | ||
const lineOffset = 20; | ||
// Options for arrows | ||
// const arrowOpts = { | ||
// textPos: 'middle'; | ||
// } | ||
document.addEventListener('DOMContentLoaded', () => { | ||
draw(); | ||
}); | ||
window.addEventListener('resize', () => { | ||
requestAnimationFrame(() => { | ||
draw(); | ||
function init() { | ||
document.addEventListener('DOMContentLoaded', () => { | ||
addListeners(); | ||
}); | ||
}); | ||
function draw() { | ||
const coached = coach(); | ||
const text = addText('Click this button to do stuff!'); | ||
arrow( | ||
// middleOfEdge(text, 'bottom'), | ||
// middleOfEdge(coached, 'right'), | ||
coached, | ||
text, | ||
); | ||
} | ||
window.draw = draw; | ||
function coach() { | ||
const elm = cache.default('elm', () => document.querySelector(target)); | ||
if (elm.className.indexOf('draggable-source') === -1) elm.className += ' draggable-source'; | ||
elm.style.position = 'absolute'; | ||
// elm.style['box-shadow'] = '0 0 150px 30px #fff'; | ||
elm.style['z-index'] = 102; | ||
const borderRadius = window.getComputedStyle(elm).getPropertyValue('border-radius'); | ||
// borderRadius = parseInt(borderRadius, 10); | ||
const top = elm.offsetTop; | ||
const left = elm.offsetLeft; | ||
const width = elm.offsetWidth; | ||
const height = elm.offsetHeight; | ||
const right = left + width; | ||
const bottom = top + height; | ||
const coachTop = cache.default('coachTop', () => document.createElement('div')); | ||
coachTop.className = 'coachmark-top'; | ||
const coachLeft = cache.default('coachLeft', () => document.createElement('div')); | ||
coachLeft.className = 'coachmark-left'; | ||
const coachRight = cache.default('coachRight', () => document.createElement('div')); | ||
coachRight.className = 'coachmark-right'; | ||
const coachBottom = cache.default('coachBottom', () => document.createElement('div')); | ||
coachBottom.className = 'coachmark-bottom'; | ||
coachTop.style.height = top + 'px'; | ||
coachLeft.style.top = top + 'px'; | ||
coachRight.style.top = coachLeft.style.top; | ||
coachLeft.style.height = height + 'px'; | ||
coachRight.style.height = coachLeft.style.height; | ||
coachLeft.style.width = left + 'px'; | ||
coachRight.style.left = right + 'px'; | ||
coachBottom.style.top = bottom + 'px'; | ||
// const longDim = height > width ? height : width; | ||
const glow = cache.default('glow', () => document.createElement('div')); | ||
glow.className = 'coachmark-glow'; | ||
// glow.style.top = (top + height / 4) + 'px'; | ||
// glow.style.left = (left + width / 4) + 'px'; | ||
// glow.style.width = width - width / 2 + 'px'; | ||
// glow.style.height = height - height / 2 + 'px'; | ||
glow.style.top = (top) + 'px'; | ||
glow.style.left = (left) + 'px'; | ||
glow.style.width = (width) + 'px'; | ||
glow.style.height = (height) + 'px'; | ||
glow.style['border-radius'] = borderRadius; | ||
glow.style['box-shadow'] = '0 0 ' + 20 + 'px ' + 10 + 'px #fff'; | ||
[coachTop, coachLeft, coachRight, coachBottom, glow].forEach(c => { | ||
if (!c.parentNode) { | ||
document.body.appendChild(c); | ||
} | ||
function addListeners() { | ||
window.addEventListener('resize', () => { | ||
requestAnimationFrame(() => { | ||
redrawAll(); | ||
}); | ||
}); | ||
return elm; | ||
} | ||
function addText(textStr) { | ||
const text = cache.default('text', () => { | ||
const text = document.createElement('div'); | ||
document.body.appendChild(text); | ||
return text; | ||
window.addEventListener('resize', () => { | ||
requestAnimationFrame(() => { | ||
redrawAll(); | ||
}); | ||
}); | ||
text.className = 'coachmark-text draggable-source'; | ||
// const ref = (text.innerText || text.textContent); | ||
text.textContent = textStr; | ||
return text; | ||
} | ||
// Draw arrow from one node to another | ||
function arrow(from, to) { | ||
const fromRect = elementRect(from); | ||
const toRect = elementRect(to); | ||
const toMiddle = middleOf(to); | ||
const fromEdge = intersectionEdge({ x: toMiddle[0], y: toMiddle[1] }, fromRect); | ||
const fromPos = middleOfEdge(to, fromEdge); | ||
const fromMiddle = middleOf(from); | ||
const toEdge = intersectionEdge({ x: fromMiddle[0], y: fromMiddle[1] }, toRect); | ||
const toPos = middleOfEdge(from, toEdge); | ||
console.log(fromEdge, toEdge, fromPos, toPos); | ||
// const s = slope(fromPos[0], fromPos[1], toPos[0], toPos[1]); | ||
// const recipS = (1 / s) * -1; | ||
// const arrowDist = lineDist(fromPos[0], fromPos[1], toPos[0], toPos[1]); | ||
const mid = midPoint(fromPos[0], fromPos[1], toPos[0], toPos[1]); | ||
// const r = Math.sqrt(1 + (recipS ** recipS)); | ||
// let ctrlX = mid[0] + (arrowDist / r); | ||
// let ctrlY = mid[1] + (arrowDist * recipS / r); | ||
// const dir = dirToViewportMid(mid[0], mid[1]); | ||
// ctrlX *= dir[0]; | ||
// ctrlY *= dir[1]; | ||
// console.log(recipS, arrowDist, mid, r, ctrlX, ctrlY); | ||
// const c1x = mid[0]; | ||
// const c1y = toPos[1]; | ||
const c2x = fromPos[0]; | ||
const c2y = mid[1]; | ||
// const pathStr = SvgPath().M(fromPos[0], fromPos[1]).C(c2x, c2y, c1x, c1y, toPos[0], toPos[1]).str(); | ||
// NOTE: quadratic curve using these args looks better. Also arrowhead orients right | ||
const pathStr = SvgPath().M(fromPos[0], fromPos[1]).Q(c2x, c2y, toPos[0], toPos[1]).str(); | ||
const svg = cache.default('svg', () => createSVG()); | ||
const path = cache.default('path', () => document.createElementNS('http://www.w3.org/2000/svg', 'path')); | ||
path.setAttribute('d', pathStr); | ||
path.setAttribute('stroke', '#fff'); | ||
path.setAttribute('stroke-width', '5'); | ||
path.setAttribute('fill', 'none'); | ||
path.setAttribute('filter', 'url(#coachmark-chalk)'); | ||
path.setAttribute('marker-end', 'url(#arrow)'); | ||
if (!path.parentNode) { | ||
svg.appendChild(path); | ||
} | ||
if (!svg.parentNode) { | ||
document.body.insertBefore(svg, document.body.firstChild); | ||
} | ||
} | ||
function createSVG() { | ||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); | ||
svg.setAttribute('height', '100%'); | ||
svg.setAttribute('width', '100%'); | ||
svg.setAttribute('class', 'coachmark-svg'); | ||
return svg; | ||
} | ||
function middleOf(node) { | ||
const rect = elementRect(node); | ||
return [rect.left + (rect.width / 2), rect.top + (rect.height / 2)]; | ||
} | ||
function middleOfEdge(node, edge) { | ||
const rect = elementRect(node); | ||
const width = rect.width; | ||
const height = rect.height; | ||
const middleX = rect.width / 2; | ||
const middleY = rect.height / 2; | ||
let x = rect.left + middleX; | ||
let y = rect.top + middleY; | ||
switch (edge) { | ||
case 'top': | ||
x = rect.left + middleX; | ||
y = rect.top - lineOffset; | ||
break; | ||
case 'right': | ||
x = rect.left + width + lineOffset; | ||
y = rect.top + middleY; | ||
break; | ||
case 'bottom': | ||
x = rect.left + middleX; | ||
y = rect.top + height + lineOffset; | ||
break; | ||
case 'left': | ||
x = rect.left - lineOffset; | ||
y = rect.top + middleY; | ||
break; | ||
default: | ||
// do nothing | ||
} | ||
return [x, y]; | ||
} | ||
function elementRect(node, offsetParent) { | ||
if (offsetParent === true) offsetParent = node.offsetParent; | ||
const rect = node.getBoundingClientRect(); | ||
const prect = offsetParent ? | ||
offsetParent.getBoundingClientRect() : | ||
{ left: 0, top: 0 }; | ||
return { | ||
left: rect.left - prect.left, | ||
top: rect.top - prect.top, | ||
width: rect.width, | ||
height: rect.height, | ||
}; | ||
} | ||
window.elementRect = elementRect; | ||
function midPoint(x1, y1, x2, y2) { | ||
return [(x1 + x2) / 2, (y1 + y2) / 2]; | ||
} | ||
// function lineDist(x1, y1, x2, y2) { | ||
// return Math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2)); | ||
// } | ||
// | ||
// function slope(x1, y1, x2, y2) { | ||
// return (y2 - y1) / (x2 - x1); | ||
// } | ||
// | ||
// function viewportMid() { | ||
// return [ | ||
// Math.max(document.documentElement.clientWidth, window.innerWidth || 0) / 2, | ||
// Math.max(document.documentElement.clientHeight, window.innerHeight || 0) / 2, | ||
// ]; | ||
// } | ||
// function dirToViewportMid(pos) { | ||
// const mid = viewportMid(); | ||
// return [ | ||
// pos[0] > mid[0] ? -1 : 1, | ||
// pos[1] > mid[1] ? -1 : 1, | ||
// ]; | ||
// } | ||
function intersectionEdge(point, rect) { | ||
const slope = (rect.top - point.y) / (rect.left - point.x); | ||
const hsw = slope * rect.width / 2; | ||
const hsh = (rect.height / 2) / slope; | ||
const hh = rect.height / 2; | ||
const hw = rect.width / 2; | ||
// const TOPLEFT = {x: rect.x - hw, y: rect.y + hh}; | ||
// const BOTTOMLEFT = {x: rect.x - hw, y: rect.y - hh}; | ||
// const BOTTOMRIGHT = {x: rect.x + hw, y: rect.y - hh}; | ||
// const TOPRIGHT = {x: rect.x + hw, y: rect.y + hh}; | ||
if (-hh <= hsw && hsw <= hh) { | ||
// line intersects | ||
if (rect.left >= point.x) { | ||
// right edge; | ||
return 'right'; // [TOPRIGHT, BOTTOMRIGHT]; | ||
} else if (rect.left < point.x) { | ||
// left edge | ||
return 'left'; // [TOPLEFT, BOTTOMLEFT]; | ||
} | ||
} | ||
if (-hw <= hsh && hsh <= hw) { | ||
if (rect.top < point.y) { | ||
// top edge | ||
return 'top'; // [TOPLEFT, TOPRIGHT]; | ||
} else if (rect.top > point.y) { | ||
// bottom edge | ||
return 'bottom'; // [BOTTOMLEFT, BOTTOMRIGHT]; | ||
} | ||
} | ||
} | ||
// function clear() { | ||
// const vals = cache.all(); | ||
// | ||
// for (const key in vals) { | ||
// if (Object.hasOwnProperty.call(vals, key)) { | ||
// const val = vals[key]; | ||
// if (isElement(val)) { | ||
// val.remove(); | ||
// cache.remove(key); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// function controlPointLength(x1, y1, x2, y2) { | ||
// | ||
// } | ||
// | ||
// function controlPointPos() { | ||
// | ||
// } | ||
// | ||
// function intersection(point, box) { | ||
// const s = (Ay - By) / (Ax - Bx); | ||
// } |
import test from 'ava'; | ||
import c from '../src'; | ||
test('foo', t => { | ||
t.pass(); | ||
test('Can load coachmarks', t => { | ||
t.truthy(c); | ||
}); | ||
test('Can add coachmark', t => { | ||
c.add('frooby', {}); | ||
const cache = c.cache(); | ||
t.truthy(cache.frooby); | ||
}); |
@@ -11,3 +11,4 @@ /* eslint new-cap: "off" */ | ||
const env = process.env.NODE_ENV || ''; | ||
if (env.indexOf('prod') > -1) { | ||
const isProd = env.indexOf('prod') > -1; | ||
if (isProd) { | ||
plugins.push(new UglifyJSPlugin({ | ||
@@ -36,3 +37,5 @@ uglifyOptions: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'coachmarks.js', | ||
filename: isProd ? 'coachmarks.min.js' : 'coachmarks.js', | ||
library: 'coachmarks', | ||
libraryTarget: 'var', | ||
}, | ||
@@ -39,0 +42,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9608677
30
3440
54
22