From 7b1c39dfa721f7acc539548266019b0326ef9656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=93=E6=96=87=E7=90=86?= <531840344@qq.com> Date: Mon, 17 Jul 2017 10:41:18 +0800 Subject: [PATCH] :bug: fixed #11, dialog issue --- dist/vue-clipboards.js | 1448 ++++++++++++++++++++++++++++++++++++++-- package.json | 11 +- src/vue-clipboards.js | 24 +- vbuild.example.js | 1 + 4 files changed, 1438 insertions(+), 46 deletions(-) diff --git a/dist/vue-clipboards.js b/dist/vue-clipboards.js index fc326b4..c68836f 100644 --- a/dist/vue-clipboards.js +++ b/dist/vue-clipboards.js @@ -16,9 +16,9 @@ return /******/ (function(modules) { // webpackBootstrap /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) +/******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; -/******/ +/******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, @@ -73,16 +73,573 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = "/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 9); +/******/ return __webpack_require__(__webpack_require__.s = 81); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ +/***/ (function(module, exports) { + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function(it, key){ + return hasOwnProperty.call(it, key); +}; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +// to indexed object, toObject with fallback for non-array-like ES3 strings +var IObject = __webpack_require__(53) + , defined = __webpack_require__(14); +module.exports = function(it){ + return IObject(defined(it)); +}; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +// Thank's IE8 for his funny defineProperty +module.exports = !__webpack_require__(8)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; +}); + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +var dP = __webpack_require__(5) + , createDesc = __webpack_require__(12); +module.exports = __webpack_require__(3) ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); +} : function(object, key, value){ + object[key] = value; + return object; +}; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +var anObject = __webpack_require__(10) + , IE8_DOM_DEFINE = __webpack_require__(29) + , toPrimitive = __webpack_require__(24) + , dP = Object.defineProperty; + +exports.f = __webpack_require__(3) ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)try { + return dP(O, P, Attributes); + } catch(e){ /* empty */ } + if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); + if('value' in Attributes)O[P] = Attributes.value; + return O; +}; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +var store = __webpack_require__(22)('wks') + , uid = __webpack_require__(13) + , Symbol = __webpack_require__(0).Symbol + , USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function(name){ + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); +}; + +$exports.store = store; + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + +var core = module.exports = {version: '2.4.0'}; +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + +module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } +}; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = __webpack_require__(34) + , enumBugKeys = __webpack_require__(15); + +module.exports = Object.keys || function keys(O){ + return $keys(O, enumBugKeys); +}; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(11); +module.exports = function(it){ + if(!isObject(it))throw TypeError(it + ' is not an object!'); + return it; +}; + +/***/ }), +/* 11 */ +/***/ (function(module, exports) { + +module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +/***/ }), +/* 12 */ +/***/ (function(module, exports) { + +module.exports = function(bitmap, value){ + return { + enumerable : !(bitmap & 1), + configurable: !(bitmap & 2), + writable : !(bitmap & 4), + value : value + }; +}; + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + +var id = 0 + , px = Math.random(); +module.exports = function(key){ + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); +}; + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function(it){ + if(it == undefined)throw TypeError("Can't call method on " + it); + return it; +}; + +/***/ }), +/* 15 */ +/***/ (function(module, exports) { + +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(0) + , core = __webpack_require__(7) + , ctx = __webpack_require__(50) + , hide = __webpack_require__(4) + , PROTOTYPE = 'prototype'; + +var $export = function(type, name, source){ + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , IS_WRAP = type & $export.W + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] + , 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 */ +/***/ (function(module, exports) { + +module.exports = {}; + +/***/ }), +/* 18 */ +/***/ (function(module, exports) { + +module.exports = true; + +/***/ }), +/* 19 */ +/***/ (function(module, exports) { + +exports.f = {}.propertyIsEnumerable; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +var def = __webpack_require__(5).f + , has = __webpack_require__(1) + , TAG = __webpack_require__(6)('toStringTag'); + +module.exports = function(it, tag, stat){ + if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); +}; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +var shared = __webpack_require__(22)('keys') + , uid = __webpack_require__(13); +module.exports = function(key){ + return shared[key] || (shared[key] = uid(key)); +}; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(0) + , SHARED = '__core-js_shared__' + , store = global[SHARED] || (global[SHARED] = {}); +module.exports = function(key){ + return store[key] || (store[key] = {}); +}; + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + +// 7.1.4 ToInteger +var ceil = Math.ceil + , floor = Math.floor; +module.exports = function(it){ + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; + +/***/ }), +/* 24 */ +/***/ (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"); +}; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(0) + , core = __webpack_require__(7) + , LIBRARY = __webpack_require__(18) + , wksExt = __webpack_require__(26) + , defineProperty = __webpack_require__(5).f; +module.exports = function(name){ + var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); + if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)}); +}; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +exports.f = __webpack_require__(6); + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = function(it){ + return toString.call(it).slice(8, -1); +}; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(11) + , document = __webpack_require__(0).document + // in old IE typeof document.createElement is 'object' + , is = isObject(document) && isObject(document.createElement); +module.exports = function(it){ + return is ? document.createElement(it) : {}; +}; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = !__webpack_require__(3) && !__webpack_require__(8)(function(){ + return Object.defineProperty(__webpack_require__(28)('div'), 'a', {get: function(){ return 7; }}).a != 7; +}); + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var LIBRARY = __webpack_require__(18) + , $export = __webpack_require__(16) + , redefine = __webpack_require__(35) + , hide = __webpack_require__(4) + , has = __webpack_require__(1) + , Iterators = __webpack_require__(17) + , $iterCreate = __webpack_require__(55) + , setToStringTag = __webpack_require__(20) + , getPrototypeOf = __webpack_require__(62) + , ITERATOR = __webpack_require__(6)('iterator') + , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` + , FF_ITERATOR = '@@iterator' + , KEYS = 'keys' + , VALUES = 'values'; + +var returnThis = function(){ return this; }; + +module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ + $iterCreate(Constructor, NAME, next); + var getMethod = function(kind){ + if(!BUGGY && kind in proto)return proto[kind]; + switch(kind){ + case KEYS: return function keys(){ return new Constructor(this, kind); }; + case VALUES: return function values(){ return new Constructor(this, kind); }; + } return function entries(){ return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator' + , DEF_VALUES = DEFAULT == VALUES + , VALUES_BUG = false + , proto = Base.prototype + , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] + , $default = $native || getMethod(DEFAULT) + , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined + , $anyNative = NAME == 'Array' ? proto.entries || $native : $native + , methods, key, IteratorPrototype; + // Fix native + if($anyNative){ + IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); + if(IteratorPrototype !== Object.prototype){ + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if(DEF_VALUES && $native && $native.name !== VALUES){ + VALUES_BUG = true; + $default = function values(){ return $native.call(this); }; + } + // Define iterator + if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if(DEFAULT){ + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if(FORCED)for(key in methods){ + if(!(key in proto))redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; +}; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = __webpack_require__(10) + , dPs = __webpack_require__(59) + , enumBugKeys = __webpack_require__(15) + , IE_PROTO = __webpack_require__(21)('IE_PROTO') + , Empty = function(){ /* empty */ } + , 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__(28)('iframe') + , i = enumBugKeys.length + , lt = '<' + , gt = '>' + , iframeDocument; + iframe.style.display = 'none'; + __webpack_require__(52).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); +}; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) +var $keys = __webpack_require__(34) + , hiddenKeys = __webpack_require__(15).concat('length', 'prototype'); + +exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){ + return $keys(O, hiddenKeys); +}; + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +exports.f = Object.getOwnPropertySymbols; + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +var has = __webpack_require__(1) + , toIObject = __webpack_require__(2) + , arrayIndexOf = __webpack_require__(49)(false) + , IE_PROTO = __webpack_require__(21)('IE_PROTO'); + +module.exports = function(object, names){ + var O = toIObject(object) + , i = 0 + , result = [] + , 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; +}; + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(4); + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.13 ToObject(argument) +var defined = __webpack_require__(14); +module.exports = function(it){ + return Object(defined(it)); +}; + +/***/ }), +/* 37 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_core_js_object_keys__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_core_js_object_keys___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_core_js_object_keys__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof__); + /** * @author: 卓文理 @@ -90,28 +647,48 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol * @desc : VueClipboard */ -var Clipboard = __webpack_require__(2); +var Clipboard = __webpack_require__(43); if (!Clipboard) { throw new Error('[vue-clipboards] cannot locate Clipboard.'); } +function isDom(obj) { + return __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof___default()(window.HTMLElement) === 'object' ? obj instanceof window.HTMLElement : obj && (typeof obj === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof___default()(obj)) === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string'; +} + /* harmony default export */ __webpack_exports__["default"] = (function (Vue) { - var clipboards = void 0; + var clipboards = {}; + var def = 'DEFAULT_KEY'; Vue.directive('clipboard', { - bind: function bind(container, binding, vnode) { - var value = binding.value; + bind: function bind(container, _ref, vnode) { + var value = _ref.value; var option = {}; + var key = vnode.key || vnode.key === 0 ? vnode.key : def; + var $parent = null; - if (value && typeof value === 'string') { + if (value && /(string|number)/.test(typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof___default()(value))) { option.text = function () { return value; }; } - clipboards = new Clipboard(container, option); + if (vnode.data.attrs && vnode.data.attrs.model) { + $parent = isDom(vnode.data.attrs.model) ? vnode.data.attrs.model : document.querySelector(vnode.data.attrs.model); + } + + // 修复按钮脱离文档流时,clipboard监听失败问题 + if (vnode.elm.offsetParent) { + option.container = vnode.elm.offsetParent; + } else if (isDom($parent)) { + option.container = $parent; + } else { + option.container = container.parentElement; + } + + clipboards[key] = new Clipboard(container, option); var componentOptions = vnode.componentOptions, data = vnode.data; @@ -120,32 +697,80 @@ if (!Clipboard) { var on = data ? data.on : null; var events = listeners && listeners || on && on; - if (events && (typeof events === 'undefined' ? 'undefined' : _typeof(events)) === 'object' && Object.keys(events).length) { + if (events && (typeof events === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_1__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_helpers_typeof___default()(events)) === 'object' && __WEBPACK_IMPORTED_MODULE_0__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_core_js_object_keys___default()(events).length) { // fixed with Vue 2.2.x, event object `fn` rename to `fns` - Object.keys(events).map(function (cb) { - return clipboards.on(cb, events[cb].fn || events[cb].fns); + __WEBPACK_IMPORTED_MODULE_0__Users_zhuowenli_github_vue_clipboards_node_modules_babel_runtime_core_js_object_keys___default()(events).map(function (cb) { + return clipboards[key].on(cb, events[cb].fn || events[cb].fns); }); } }, - unbind: function unbind() { - if (clipboards && clipboards.destroy) { - clipboards.destroy(); + unbind: function unbind(vnode) { + var key = vnode.key || vnode.key === 0 ? vnode.key : def; + + if (clipboards[key] && clipboards[key].destroy) { + clipboards[key].destroy(); + clipboards[key] = null; } }, update: function update(container, binding, vnode) { - binding.def.unbind(); + binding.def.unbind(vnode); binding.def.bind(container, binding, vnode); } }); }); /***/ }), -/* 1 */ +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(44), __esModule: true }; + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(45), __esModule: true }; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(46), __esModule: true }; + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _iterator = __webpack_require__(40); + +var _iterator2 = _interopRequireDefault(_iterator); + +var _symbol = __webpack_require__(39); + +var _symbol2 = _interopRequireDefault(_symbol); + +var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof(obj); +} : function (obj) { + return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); +}; + +/***/ }), +/* 42 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(7)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(79)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); @@ -222,6 +847,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = options.action; + this.container = options.container; this.emitter = options.emitter; this.target = options.target; this.text = options.text; @@ -250,7 +876,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ this.fakeHandlerCallback = function () { return _this.removeFake(); }; - this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true; + this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS @@ -269,7 +895,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text; - document.body.appendChild(this.fakeElem); + this.container.appendChild(this.fakeElem); this.selectedText = (0, _select2.default)(this.fakeElem); this.copyText(); @@ -278,13 +904,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ key: 'removeFake', value: function removeFake() { if (this.fakeHandler) { - document.body.removeEventListener('click', this.fakeHandlerCallback); + this.container.removeEventListener('click', this.fakeHandlerCallback); this.fakeHandler = null; this.fakeHandlerCallback = null; } if (this.fakeElem) { - document.body.removeChild(this.fakeElem); + this.container.removeChild(this.fakeElem); this.fakeElem = null; } } @@ -320,8 +946,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ }, { key: 'clearSelection', value: function clearSelection() { - if (this.target) { - this.target.blur(); + if (this.trigger) { + this.trigger.focus(); } window.getSelection().removeAllRanges(); @@ -376,12 +1002,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ }); /***/ }), -/* 2 */ +/* 43 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(1), __webpack_require__(8), __webpack_require__(6)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(42), __webpack_require__(80), __webpack_require__(78)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); @@ -409,6 +1035,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ }; } + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); @@ -489,6 +1121,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ this.action = typeof options.action === 'function' ? options.action : this.defaultAction; this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; this.text = typeof options.text === 'function' ? options.text : this.defaultText; + this.container = _typeof(options.container) === 'object' ? options.container : document.body; } }, { key: 'listenClick', @@ -512,6 +1145,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ action: this.action(trigger), target: this.target(trigger), text: this.text(trigger), + container: this.container, trigger: trigger, emitter: this }); @@ -583,7 +1217,740 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ }); /***/ }), -/* 3 */ +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(68); +module.exports = __webpack_require__(7).Object.keys; + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(71); +__webpack_require__(69); +__webpack_require__(72); +__webpack_require__(73); +module.exports = __webpack_require__(7).Symbol; + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(70); +__webpack_require__(74); +module.exports = __webpack_require__(26).f('iterator'); + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +module.exports = function(it){ + if(typeof it != 'function')throw TypeError(it + ' is not a function!'); + return it; +}; + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + +module.exports = function(){ /* empty */ }; + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +// false -> Array#indexOf +// true -> Array#includes +var toIObject = __webpack_require__(2) + , toLength = __webpack_require__(66) + , toIndex = __webpack_require__(65); +module.exports = function(IS_INCLUDES){ + return function($this, el, fromIndex){ + var O = toIObject($this) + , length = toLength(O.length) + , index = toIndex(fromIndex, length) + , value; + // Array#includes uses SameValueZero equality algorithm + if(IS_INCLUDES && el != el)while(length > index){ + value = O[index++]; + if(value != value)return true; + // Array#toIndex 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; + }; +}; + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +// optional / simple context binding +var aFunction = __webpack_require__(47); +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); + }; +}; + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +// all enumerable object keys, includes symbols +var getKeys = __webpack_require__(9) + , gOPS = __webpack_require__(33) + , pIE = __webpack_require__(19); +module.exports = function(it){ + var result = getKeys(it) + , getSymbols = gOPS.f; + if(getSymbols){ + var symbols = getSymbols(it) + , isEnum = pIE.f + , i = 0 + , key; + while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key); + } return result; +}; + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(0).document && document.documentElement; + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = __webpack_require__(27); +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ + return cof(it) == 'String' ? it.split('') : Object(it); +}; + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.2.2 IsArray(argument) +var cof = __webpack_require__(27); +module.exports = Array.isArray || function isArray(arg){ + return cof(arg) == 'Array'; +}; + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var create = __webpack_require__(31) + , descriptor = __webpack_require__(12) + , setToStringTag = __webpack_require__(20) + , IteratorPrototype = {}; + +// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() +__webpack_require__(4)(IteratorPrototype, __webpack_require__(6)('iterator'), function(){ return this; }); + +module.exports = function(Constructor, NAME, next){ + Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); + setToStringTag(Constructor, NAME + ' Iterator'); +}; + +/***/ }), +/* 56 */ +/***/ (function(module, exports) { + +module.exports = function(done, value){ + return {value: value, done: !!done}; +}; + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +var getKeys = __webpack_require__(9) + , toIObject = __webpack_require__(2); +module.exports = function(object, el){ + var O = toIObject(object) + , keys = getKeys(O) + , length = keys.length + , index = 0 + , key; + while(length > index)if(O[key = keys[index++]] === el)return key; +}; + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +var META = __webpack_require__(13)('meta') + , isObject = __webpack_require__(11) + , has = __webpack_require__(1) + , setDesc = __webpack_require__(5).f + , id = 0; +var isExtensible = Object.isExtensible || function(){ + return true; +}; +var FREEZE = !__webpack_require__(8)(function(){ + return isExtensible(Object.preventExtensions({})); +}); +var setMeta = function(it){ + setDesc(it, META, {value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + }}); +}; +var fastKey = function(it, create){ + // return primitive with prefix + if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return 'F'; + // not necessary to add metadata + if(!create)return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; +}; +var getWeak = function(it, create){ + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return true; + // not necessary to add metadata + if(!create)return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; +}; +// add metadata on freeze-family methods calling +var onFreeze = function(it){ + if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it); + return it; +}; +var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze +}; + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +var dP = __webpack_require__(5) + , anObject = __webpack_require__(10) + , getKeys = __webpack_require__(9); + +module.exports = __webpack_require__(3) ? Object.defineProperties : function defineProperties(O, Properties){ + anObject(O); + var keys = getKeys(Properties) + , length = keys.length + , i = 0 + , P; + while(length > i)dP.f(O, P = keys[i++], Properties[P]); + return O; +}; + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +var pIE = __webpack_require__(19) + , createDesc = __webpack_require__(12) + , toIObject = __webpack_require__(2) + , toPrimitive = __webpack_require__(24) + , has = __webpack_require__(1) + , IE8_DOM_DEFINE = __webpack_require__(29) + , gOPD = Object.getOwnPropertyDescriptor; + +exports.f = __webpack_require__(3) ? gOPD : function getOwnPropertyDescriptor(O, P){ + O = toIObject(O); + P = toPrimitive(P, true); + if(IE8_DOM_DEFINE)try { + return gOPD(O, P); + } catch(e){ /* empty */ } + if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]); +}; + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window +var toIObject = __webpack_require__(2) + , gOPN = __webpack_require__(32).f + , toString = {}.toString; + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function(it){ + try { + return gOPN(it); + } catch(e){ + return windowNames.slice(); + } +}; + +module.exports.f = function getOwnPropertyNames(it){ + return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); +}; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) +var has = __webpack_require__(1) + , toObject = __webpack_require__(36) + , IE_PROTO = __webpack_require__(21)('IE_PROTO') + , 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; +}; + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +// most Object methods by ES6 should accept primitives +var $export = __webpack_require__(16) + , core = __webpack_require__(7) + , fails = __webpack_require__(8); +module.exports = function(KEY, exec){ + var fn = (core.Object || {})[KEY] || Object[KEY] + , exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); +}; + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +var toInteger = __webpack_require__(23) + , defined = __webpack_require__(14); +// true -> String#at +// false -> String#codePointAt +module.exports = function(TO_STRING){ + return function(that, pos){ + var s = String(defined(that)) + , i = toInteger(pos) + , l = s.length + , 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; + }; +}; + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +var toInteger = __webpack_require__(23) + , max = Math.max + , min = Math.min; +module.exports = function(index, length){ + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.15 ToLength +var toInteger = __webpack_require__(23) + , min = Math.min; +module.exports = function(it){ + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var addToUnscopables = __webpack_require__(48) + , step = __webpack_require__(56) + , Iterators = __webpack_require__(17) + , toIObject = __webpack_require__(2); + +// 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__(30)(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 + , kind = this._k + , 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'); + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.14 Object.keys(O) +var toObject = __webpack_require__(36) + , $keys = __webpack_require__(9); + +__webpack_require__(63)('keys', function(){ + return function keys(it){ + return $keys(toObject(it)); + }; +}); + +/***/ }), +/* 69 */ +/***/ (function(module, exports) { + + + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var $at = __webpack_require__(64)(true); + +// 21.1.3.27 String.prototype[@@iterator]() +__webpack_require__(30)(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 + , index = this._i + , point; + if(index >= O.length)return {value: undefined, done: true}; + point = $at(O, index); + this._i += point.length; + return {value: point, done: false}; +}); + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// ECMAScript 6 symbols shim +var global = __webpack_require__(0) + , has = __webpack_require__(1) + , DESCRIPTORS = __webpack_require__(3) + , $export = __webpack_require__(16) + , redefine = __webpack_require__(35) + , META = __webpack_require__(58).KEY + , $fails = __webpack_require__(8) + , shared = __webpack_require__(22) + , setToStringTag = __webpack_require__(20) + , uid = __webpack_require__(13) + , wks = __webpack_require__(6) + , wksExt = __webpack_require__(26) + , wksDefine = __webpack_require__(25) + , keyOf = __webpack_require__(57) + , enumKeys = __webpack_require__(51) + , isArray = __webpack_require__(54) + , anObject = __webpack_require__(10) + , toIObject = __webpack_require__(2) + , toPrimitive = __webpack_require__(24) + , createDesc = __webpack_require__(12) + , _create = __webpack_require__(31) + , gOPNExt = __webpack_require__(61) + , $GOPD = __webpack_require__(60) + , $DP = __webpack_require__(5) + , $keys = __webpack_require__(9) + , gOPD = $GOPD.f + , dP = $DP.f + , gOPN = gOPNExt.f + , $Symbol = global.Symbol + , $JSON = global.JSON + , _stringify = $JSON && $JSON.stringify + , PROTOTYPE = 'prototype' + , HIDDEN = wks('_hidden') + , TO_PRIMITIVE = wks('toPrimitive') + , isEnum = {}.propertyIsEnumerable + , SymbolRegistry = shared('symbol-registry') + , AllSymbols = shared('symbols') + , OPSymbols = shared('op-symbols') + , ObjectProto = Object[PROTOTYPE] + , USE_NATIVE = typeof $Symbol == 'function' + , QObject = global.QObject; +// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 +var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; + +// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 +var setSymbolDesc = DESCRIPTORS && $fails(function(){ + return _create(dP({}, 'a', { + get: function(){ return dP(this, 'a', {value: 7}).a; } + })).a != 7; +}) ? function(it, key, D){ + var protoDesc = gOPD(ObjectProto, key); + if(protoDesc)delete ObjectProto[key]; + dP(it, key, D); + if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc); +} : dP; + +var wrap = function(tag){ + var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); + sym._k = tag; + return sym; +}; + +var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){ + return typeof it == 'symbol'; +} : function(it){ + return it instanceof $Symbol; +}; + +var $defineProperty = function defineProperty(it, key, D){ + if(it === ObjectProto)$defineProperty(OPSymbols, key, D); + anObject(it); + key = toPrimitive(key, true); + anObject(D); + if(has(AllSymbols, key)){ + if(!D.enumerable){ + if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; + D = _create(D, {enumerable: createDesc(0, false)}); + } return setSymbolDesc(it, key, D); + } return dP(it, key, D); +}; +var $defineProperties = function defineProperties(it, P){ + anObject(it); + var keys = enumKeys(P = toIObject(P)) + , i = 0 + , l = keys.length + , key; + while(l > i)$defineProperty(it, key = keys[i++], P[key]); + return it; +}; +var $create = function create(it, P){ + return P === undefined ? _create(it) : $defineProperties(_create(it), P); +}; +var $propertyIsEnumerable = function propertyIsEnumerable(key){ + var E = isEnum.call(this, key = toPrimitive(key, true)); + if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false; + return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; +}; +var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){ + it = toIObject(it); + key = toPrimitive(key, true); + if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return; + var D = gOPD(it, key); + if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true; + return D; +}; +var $getOwnPropertyNames = function getOwnPropertyNames(it){ + var names = gOPN(toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key); + } return result; +}; +var $getOwnPropertySymbols = function getOwnPropertySymbols(it){ + var IS_OP = it === ObjectProto + , names = gOPN(IS_OP ? OPSymbols : toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]); + } return result; +}; + +// 19.4.1.1 Symbol([description]) +if(!USE_NATIVE){ + $Symbol = function Symbol(){ + if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!'); + var tag = uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function(value){ + if(this === ObjectProto)$set.call(OPSymbols, value); + if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, createDesc(1, value)); + }; + if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set}); + return wrap(tag); + }; + redefine($Symbol[PROTOTYPE], 'toString', function toString(){ + return this._k; + }); + + $GOPD.f = $getOwnPropertyDescriptor; + $DP.f = $defineProperty; + __webpack_require__(32).f = gOPNExt.f = $getOwnPropertyNames; + __webpack_require__(19).f = $propertyIsEnumerable; + __webpack_require__(33).f = $getOwnPropertySymbols; + + if(DESCRIPTORS && !__webpack_require__(18)){ + redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + wksExt.f = function(name){ + return wrap(wks(name)); + } +} + +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol}); + +for(var symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' +).split(','), i = 0; symbols.length > i; )wks(symbols[i++]); + +for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]); + +$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function(key){ + return has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(key){ + if(isSymbol(key))return keyOf(SymbolRegistry, key); + throw TypeError(key + ' is not a symbol!'); + }, + useSetter: function(){ setter = true; }, + useSimple: function(){ setter = false; } +}); + +$export($export.S + $export.F * !USE_NATIVE, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols +}); + +// 24.3.2 JSON.stringify(value [, replacer [, space]]) +$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){ + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}'; +})), 'JSON', { + stringify: function stringify(it){ + if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined + var args = [it] + , i = 1 + , replacer, $replacer; + while(arguments.length > i)args.push(arguments[i++]); + replacer = args[1]; + if(typeof replacer == 'function')$replacer = replacer; + if($replacer || !isArray(replacer))replacer = function(key, value){ + if($replacer)value = $replacer.call(this, key, value); + if(!isSymbol(value))return value; + }; + args[1] = replacer; + return _stringify.apply($JSON, args); + } +}); + +// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) +$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(4)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); +// 19.4.3.5 Symbol.prototype[@@toStringTag] +setToStringTag($Symbol, 'Symbol'); +// 20.2.1.9 Math[@@toStringTag] +setToStringTag(Math, 'Math', true); +// 24.3.3 JSON[@@toStringTag] +setToStringTag(global.JSON, 'JSON', true); + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(25)('asyncIterator'); + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(25)('observable'); + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(67); +var global = __webpack_require__(0) + , hide = __webpack_require__(4) + , Iterators = __webpack_require__(17) + , TO_STRING_TAG = __webpack_require__(6)('toStringTag'); + +for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){ + var NAME = collections[i] + , Collection = global[NAME] + , proto = Collection && Collection.prototype; + if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; +} + +/***/ }), +/* 75 */ /***/ (function(module, exports) { var DOCUMENT_NODE_TYPE = 9; @@ -610,7 +1977,10 @@ if (typeof Element !== 'undefined' && !Element.prototype.matches) { */ function closest (element, selector) { while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { - if (element.matches(selector)) return element; + if (typeof element.matches === 'function' && + element.matches(selector)) { + return element; + } element = element.parentNode; } } @@ -619,10 +1989,10 @@ module.exports = closest; /***/ }), -/* 4 */ +/* 76 */ /***/ (function(module, exports, __webpack_require__) { -var closest = __webpack_require__(3); +var closest = __webpack_require__(75); /** * Delegates event to a selector. @@ -669,7 +2039,7 @@ module.exports = delegate; /***/ }), -/* 5 */ +/* 77 */ /***/ (function(module, exports) { /** @@ -724,11 +2094,11 @@ exports.fn = function(value) { /***/ }), -/* 6 */ +/* 78 */ /***/ (function(module, exports, __webpack_require__) { -var is = __webpack_require__(5); -var delegate = __webpack_require__(4); +var is = __webpack_require__(77); +var delegate = __webpack_require__(76); /** * Validates all params and calls the right @@ -825,7 +2195,7 @@ module.exports = listen; /***/ }), -/* 7 */ +/* 79 */ /***/ (function(module, exports) { function select(element) { @@ -874,7 +2244,7 @@ module.exports = select; /***/ }), -/* 8 */ +/* 80 */ /***/ (function(module, exports) { function E () { @@ -946,10 +2316,10 @@ module.exports = E; /***/ }), -/* 9 */ +/* 81 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(0); +module.exports = __webpack_require__(37); /***/ }) diff --git a/package.json b/package.json index 6249854..78fcab3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-clipboards", - "version": "1.0.2", + "version": "1.0.3", "description": "Vue2.0 directive to copy or cut text to clipboard.", "main": "dist/vue-clipboards.js", "files": [ @@ -15,7 +15,6 @@ "scripts": { "test": "echo lol", "test:unit": "vbuild -c vbuild.unit.js", - "lint": "vbuild -c vbuild.example.js --eslint", "build": "npm run build:cjs && npm run build:umd", "build:cjs": "vbuild -c vbuild.component.js --format cjs", "build:umd": "vbuild -c vbuild.component.js --format umd", @@ -30,16 +29,16 @@ "eslint-plugin-import": "^2.2.0", "eslint-plugin-vue": "^2.0.1", "gh-pages": "^0.12.0", + "highlightjs": "^9.10.0", "node-sass": "^4.5.2", + "primer-css": "^6.0.0", "pug": "^2.0.0-rc.2", "sass-loader": "^6.0.5", "sweetalert": "^1.1.3", "vbuild": "^6.0.0", - "vbuild-karma": "^1.0.0", - "highlightjs": "^9.10.0", - "primer-css": "^6.0.0" + "vbuild-karma": "^1.0.0" }, "dependencies": { - "clipboard": "^1.5.15" + "clipboard": "^1.7.1" } } diff --git a/src/vue-clipboards.js b/src/vue-clipboards.js index c2ef6e8..638ef51 100644 --- a/src/vue-clipboards.js +++ b/src/vue-clipboards.js @@ -10,6 +10,12 @@ if (!Clipboard) { throw new Error('[vue-clipboards] cannot locate Clipboard.'); } +function isDom (obj) { + return typeof window.HTMLElement === 'object' + ? obj instanceof window.HTMLElement + : obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string'; +} + export default function (Vue) { const clipboards = {}; const def = 'DEFAULT_KEY'; @@ -18,11 +24,27 @@ export default function (Vue) { bind (container, { value }, vnode) { const option = {}; const key = (vnode.key || vnode.key === 0) ? vnode.key : def; + let $parent = null; - if (value && typeof value === 'string') { + if (value && /(string|number)/.test(typeof value)) { option.text = () => value; } + if (vnode.data.attrs && vnode.data.attrs.model) { + $parent = isDom(vnode.data.attrs.model) + ? vnode.data.attrs.model + : document.querySelector(vnode.data.attrs.model); + } + + // 修复按钮脱离文档流时,clipboard监听失败问题 + if (vnode.elm.offsetParent) { + option.container = vnode.elm.offsetParent; + } else if (isDom($parent)) { + option.container = $parent; + } else { + option.container = container.parentElement; + } + clipboards[key] = new Clipboard(container, option); const { componentOptions, data } = vnode; diff --git a/vbuild.example.js b/vbuild.example.js index 0543c96..7b47277 100644 --- a/vbuild.example.js +++ b/vbuild.example.js @@ -10,6 +10,7 @@ module.exports = options => ({ html: { title: 'vue-clipboards' }, + port: 4444, copy: true, webpack (cfg) { if (!options.dev) {