forked from Akryum/floating-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v-tooltip.browser.js
1 lines (1 loc) · 11.3 KB
/
v-tooltip.browser.js
1
!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("Tooltip")):"function"==typeof define&&define.amd?define(["Tooltip"],factory):"object"==typeof exports?exports.VTooltip=factory(require("Tooltip")):root.VTooltip=factory(root.Tooltip)}(this,function(__WEBPACK_EXTERNAL_MODULE_3__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=4)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function getOptions(options){return{placement:options.placement||directive.options.defaultPlacement,delay:options.delay||directive.options.defaultDelay,template:options.template||directive.options.defaultTemplate,trigger:options.trigger||directive.options.defaultTrigger,offset:options.offset||directive.options.defaultOffset,container:options.container||directive.options.defaultContainer}}function getPlacement(value,modifiers){var placement=value.placement,_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=positions[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var pos=_step.value;modifiers[pos]&&(placement=pos)}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}return placement}function createTooltip(el,value,modifiers){var content=value.content||value,classes=value.classes||directive.options.defaultClass,tooltip=el._tooltip=new SuperTooltip(el,_extends({title:content,html:!0},getOptions(_extends({},value,{placement:getPlacement(value,modifiers)}))));tooltip.setClasses(classes)}function destroyTooltip(el){el._tooltip&&(el._tooltip.dispose(),delete el._tooltip)}var __WEBPACK_IMPORTED_MODULE_0_tooltip_js__=__webpack_require__(3),__WEBPACK_IMPORTED_MODULE_0_tooltip_js___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_tooltip_js__),__WEBPACK_IMPORTED_MODULE_1__utils__=__webpack_require__(2);__webpack_require__.d(__webpack_exports__,"c",function(){return state}),__webpack_require__.d(__webpack_exports__,"a",function(){return defaultOptions});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},state={enabled:!0},positions=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],defaultOptions={defaultPlacement:"top",defaultClass:"vue-tooltip-theme",defaultTemplate:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',defaultDelay:0,defaultTrigger:"hover focus",defaultOffset:0,defaultContainer:"body"},SuperTooltip=function(_Tooltip){function SuperTooltip(){return _classCallCheck(this,SuperTooltip),_possibleConstructorReturn(this,(SuperTooltip.__proto__||Object.getPrototypeOf(SuperTooltip)).apply(this,arguments))}return _inherits(SuperTooltip,_Tooltip),_createClass(SuperTooltip,[{key:"setClasses",value:function(classes){var el=this._tooltipNode;if(el){var oldClasses=this._oldClasses;classes?oldClasses?__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__utils__.a)(el,classes,oldClasses):__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__utils__.b)(el,classes):oldClasses&&__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__utils__.c)(el,oldClasses),this._oldClasses=classes}else this._pendingClasses=classes;this._classes=classes}},{key:"setContent",value:function(content){if(this.options.title=content,this._tooltipNode){var el=this._tooltipNode.querySelector(this.innerSelector);el&&(content?el.innerHTML=content:el.innerHTML="",this.popperInstance.update())}}},{key:"setOptions",value:function(options){options=getOptions(options);var needPopperUpdate=!1,needRestart=!1;this.options.offset===options.offset&&this.options.placement===options.placement||(needPopperUpdate=!0),this.options.template===options.template&&this.options.trigger===options.trigger&&this.options.container===options.container||(needRestart=!0);for(var key in options)this.options[key]=options[key];if(this._tooltipNode)if(needRestart){var isOpen=this._isOpen;this.dispose();var events="string"==typeof this.options.trigger?options.trigger.split(" ").filter(function(trigger){return["click","hover","focus"].indexOf(trigger)!==-1}):[];this._setEventListeners(this.reference,events,this.options),this.setClasses(this._classes),isOpen&&this.show()}else needPopperUpdate&&this.popperInstance.update()}},{key:"_create",value:function(){for(var _get2,_len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];var result=(_get2=_get(SuperTooltip.prototype.__proto__||Object.getPrototypeOf(SuperTooltip.prototype),"_create",this)).call.apply(_get2,[this].concat(args));return this.options.trigger.indexOf("hover")!==-1&&(result.addEventListener("mouseenter",this.hide),result.addEventListener("click",this.hide)),result}},{key:"_dispose",value:function(){var _this2=this;return this._tooltipNode&&(this._tooltipNode.removeEventListener("mouseenter",this.hide),this._tooltipNode.removeEventListener("click",this.hide)),this._events.forEach(function(_ref){var func=_ref.func,event=_ref.event;_this2.reference.removeEventListener(event,func)}),this._events=[],_get(SuperTooltip.prototype.__proto__||Object.getPrototypeOf(SuperTooltip.prototype),"_dispose",this).call(this)}},{key:"_show",value:function(){for(var _get3,_this3=this,_len2=arguments.length,args=Array(_len2),_key2=0;_key2<_len2;_key2++)args[_key2]=arguments[_key2];var result=(_get3=_get(SuperTooltip.prototype.__proto__||Object.getPrototypeOf(SuperTooltip.prototype),"_show",this)).call.apply(_get3,[this].concat(args));return this._pendingClasses&&(this.setClasses(this._pendingClasses),this._pendingClasses=null),setTimeout(function(){_this3.popperInstance.update()},0),result}}]),SuperTooltip}(__WEBPACK_IMPORTED_MODULE_0_tooltip_js___default.a),directive={options:defaultOptions,bind:function(el,_ref2){var value=_ref2.value,modifiers=_ref2.modifiers,content=value&&value.content||value;destroyTooltip(el),content&&state.enabled&&createTooltip(el,value,modifiers)},update:function(el,_ref3){var value=_ref3.value,modifiers=(_ref3.oldValue,_ref3.modifiers),content=value&&value.content||value;if(content&&state.enabled)if(el._tooltip){var tooltip=el._tooltip;tooltip.setContent(content),tooltip.setClasses(value&&value.classes||directive.options.defaultClass),tooltip.setOptions(_extends({},value,{placement:getPlacement(value,modifiers)}))}else createTooltip(el,value,modifiers);else destroyTooltip(el)},unbind:function(el){destroyTooltip(el)}};__webpack_exports__.b=directive},function(module,exports){var g,_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};g=function(){return this}();try{g=g||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":_typeof(window))&&(g=window)}module.exports=g},function(module,__webpack_exports__,__webpack_require__){"use strict";function convertToArray(value){return"string"==typeof value&&(value=value.split(" ")),value}function addClasses(el,classes){classes=convertToArray(classes),classes.forEach(function(c){el.classList.add(c)})}function removeClasses(el,classes){classes=convertToArray(classes),classes.forEach(function(c){el.classList.remove(c)})}function replaceClasses(el,newClasses,oldClasses){removeClasses(el,oldClasses),addClasses(el,newClasses)}__webpack_exports__.b=addClasses,__webpack_exports__.c=removeClasses,__webpack_exports__.a=replaceClasses},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE_3__},function(module,__webpack_exports__,__webpack_require__){"use strict";(function(global){function install(Vue,options){install.installed||(install.installed=!0,options=Object.assign({},__WEBPACK_IMPORTED_MODULE_0__v_tooltip__.a,options||{}),__WEBPACK_IMPORTED_MODULE_0__v_tooltip__.b.options=options,Vue.directive("tooltip",__WEBPACK_IMPORTED_MODULE_0__v_tooltip__.b))}Object.defineProperty(__webpack_exports__,"__esModule",{value:!0});var __WEBPACK_IMPORTED_MODULE_0__v_tooltip__=__webpack_require__(0);__webpack_exports__.install=install,__webpack_require__.d(__webpack_exports__,"VTooltip",function(){return VTooltip});var VTooltip=__WEBPACK_IMPORTED_MODULE_0__v_tooltip__.b,plugin={install:install,get enabled(){return __WEBPACK_IMPORTED_MODULE_0__v_tooltip__.c.enabled},set enabled(value){__WEBPACK_IMPORTED_MODULE_0__v_tooltip__.c.enabled=value}},GlobalVue=null;"undefined"!=typeof window?GlobalVue=window.Vue:"undefined"!=typeof global&&(GlobalVue=global.Vue),GlobalVue&&GlobalVue.use(plugin),__webpack_exports__.default=plugin}).call(__webpack_exports__,__webpack_require__(1))}])});