default-image-viewer.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. exports.ids = [6];
  2. exports.modules = {
  3. /***/ 156:
  4. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5. "use strict";
  6. // ESM COMPAT FLAG
  7. __webpack_require__.r(__webpack_exports__);
  8. // CONCATENATED MODULE: ./node_modules/_vue-loader@15.9.8@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_@nuxt_components@2.2.1@@nuxt/components/dist/loader.js??ref--0-0!./node_modules/_vue-loader@15.9.8@vue-loader/lib??vue-loader-options!./components/default/image-viewer.vue?vue&type=template&id=35230f64&
  9. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"viewer-fade"}},[_c('div',{ref:"el-image-viewer__wrapper",staticClass:"el-image-viewer__wrapper",style:({ 'z-index': _vm.zIndex }),attrs:{"tabindex":"-1"}},[_c('div',{staticClass:"el-image-viewer__mask",on:{"click":_vm.hide}}),_vm._v(" "),_c('span',{staticClass:"el-image-viewer__btn el-image-viewer__close",on:{"click":function($event){$event.stopPropagation();return _vm.hide.apply(null, arguments)}}},[_c('i',{staticClass:"el-icon-circle-close",staticStyle:{"color":"white"}})]),_vm._v(" "),(!_vm.isSingle)?[_c('span',{staticClass:"el-image-viewer__btn el-image-viewer__prev",class:{ 'is-disabled': !_vm.infinite && _vm.isFirst },on:{"click":function($event){$event.stopPropagation();return _vm.prev.apply(null, arguments)}}},[_c('i',{staticClass:"el-icon-arrow-left"})]),_vm._v(" "),_c('span',{staticClass:"el-image-viewer__btn el-image-viewer__next",class:{ 'is-disabled': !_vm.infinite && _vm.isLast },on:{"click":function($event){$event.stopPropagation();return _vm.next.apply(null, arguments)}}},[_c('i',{staticClass:"el-icon-arrow-right"})])]:_vm._e(),_vm._v(" "),_c('div',{staticClass:"el-image-viewer__btn el-image-viewer__actions"},[_c('div',{staticClass:"el-image-viewer__actions__inner"},[_c('i',{staticClass:"el-icon-zoom-out",on:{"click":function($event){$event.stopPropagation();return _vm.handleActions('zoomOut')}}}),_vm._v(" "),_c('i',{staticClass:"el-icon-zoom-in",on:{"click":function($event){$event.stopPropagation();return _vm.handleActions('zoomIn')}}}),_vm._v(" "),_c('i',{staticClass:"el-image-viewer__actions__divider"}),_vm._v(" "),_c('i',{class:_vm.mode.icon,on:{"click":function($event){$event.stopPropagation();return _vm.toggleMode.apply(null, arguments)}}}),_vm._v(" "),_c('i',{staticClass:"el-image-viewer__actions__divider"}),_vm._v(" "),_c('i',{staticClass:"el-icon-refresh-left",on:{"click":function($event){$event.stopPropagation();return _vm.handleActions('anticlocelise')}}}),_vm._v(" "),_c('i',{staticClass:"el-icon-refresh-right",on:{"click":function($event){$event.stopPropagation();return _vm.handleActions('clocelise')}}})])]),_vm._v(" "),_c('div',{staticClass:"el-image-viewer__canvas",on:{"click":_vm.hide}},_vm._l((_vm.urlList),function(url,i){return (i === _vm.index)?_c('img',{key:url,ref:"img",refInFor:true,staticClass:"el-image-viewer__img",style:(_vm.imgStyle),attrs:{"src":_vm.currentImg},on:{"load":_vm.handleImgLoad,"error":_vm.handleImgError,"mousedown":_vm.handleMouseDown}}):_vm._e()}),0)],2)])}
  10. var staticRenderFns = []
  11. // CONCATENATED MODULE: ./components/default/image-viewer.vue?vue&type=template&id=35230f64&
  12. // EXTERNAL MODULE: ./node_modules/_element-ui@2.14.1@element-ui/src/utils/dom.js
  13. var dom = __webpack_require__(159);
  14. // EXTERNAL MODULE: ./node_modules/_element-ui@2.14.1@element-ui/src/utils/util.js + 1 modules
  15. var util = __webpack_require__(160);
  16. // CONCATENATED MODULE: ./node_modules/_babel-loader@8.2.3@babel-loader/lib??ref--2-0!./node_modules/_@nuxt_components@2.2.1@@nuxt/components/dist/loader.js??ref--0-0!./node_modules/_vue-loader@15.9.8@vue-loader/lib??vue-loader-options!./components/default/image-viewer.vue?vue&type=script&lang=js&
  17. //
  18. //
  19. //
  20. //
  21. //
  22. //
  23. //
  24. //
  25. //
  26. //
  27. //
  28. //
  29. //
  30. //
  31. //
  32. //
  33. //
  34. //
  35. //
  36. //
  37. //
  38. //
  39. //
  40. //
  41. //
  42. //
  43. //
  44. //
  45. //
  46. //
  47. //
  48. //
  49. //
  50. //
  51. //
  52. //
  53. //
  54. //
  55. //
  56. //
  57. //
  58. //
  59. //
  60. //
  61. //
  62. //
  63. //
  64. //
  65. //
  66. //
  67. //
  68. //
  69. //
  70. const Mode = {
  71. CONTAIN: {
  72. name: 'contain',
  73. icon: 'el-icon-full-screen'
  74. },
  75. ORIGINAL: {
  76. name: 'original',
  77. icon: 'el-icon-c-scale-to-original'
  78. }
  79. };
  80. const mousewheelEventName = Object(util["a" /* isFirefox */])() ? 'DOMMouseScroll' : 'mousewheel';
  81. /* harmony default export */ var image_viewervue_type_script_lang_js_ = ({
  82. name: 'elImageViewer',
  83. props: {
  84. urlList: {
  85. type: Array,
  86. default: () => []
  87. },
  88. zIndex: {
  89. type: Number,
  90. default: 2000
  91. },
  92. onSwitch: {
  93. type: Function,
  94. default: () => {}
  95. },
  96. onClose: {
  97. type: Function,
  98. default: () => {}
  99. },
  100. initialIndex: {
  101. type: Number,
  102. default: 0
  103. }
  104. },
  105. data() {
  106. return {
  107. index: this.initialIndex,
  108. isShow: false,
  109. infinite: true,
  110. loading: false,
  111. mode: Mode.CONTAIN,
  112. transform: {
  113. scale: 1,
  114. deg: 0,
  115. offsetX: 0,
  116. offsetY: 0,
  117. enableTransition: false
  118. }
  119. };
  120. },
  121. computed: {
  122. isSingle() {
  123. return this.urlList.length <= 1;
  124. },
  125. isFirst() {
  126. return this.index === 0;
  127. },
  128. isLast() {
  129. return this.index === this.urlList.length - 1;
  130. },
  131. currentImg() {
  132. return this.urlList[this.index];
  133. },
  134. imgStyle() {
  135. const {
  136. scale,
  137. deg,
  138. offsetX,
  139. offsetY,
  140. enableTransition
  141. } = this.transform;
  142. const style = {
  143. transform: `scale(${scale}) rotate(${deg}deg)`,
  144. transition: enableTransition ? 'transform .3s' : '',
  145. 'margin-left': `${offsetX}px`,
  146. 'margin-top': `${offsetY}px`
  147. };
  148. if (this.mode === Mode.CONTAIN) {
  149. style.maxWidth = style.maxHeight = '100%';
  150. }
  151. return style;
  152. }
  153. },
  154. watch: {
  155. index: {
  156. handler: function (val) {
  157. this.reset();
  158. this.onSwitch(val);
  159. }
  160. },
  161. currentImg(val) {
  162. this.$nextTick(_ => {
  163. const $img = this.$refs.img[0];
  164. if (!$img.complete) {
  165. this.loading = true;
  166. }
  167. });
  168. }
  169. },
  170. methods: {
  171. hide() {
  172. this.deviceSupportUninstall(); // this.onClose();
  173. this.$emit('onClose');
  174. },
  175. deviceSupportInstall() {
  176. this._keyDownHandler = Object(util["b" /* rafThrottle */])(e => {
  177. const keyCode = e.keyCode;
  178. switch (keyCode) {
  179. // ESC
  180. case 27:
  181. this.hide();
  182. break;
  183. // SPACE
  184. case 32:
  185. this.toggleMode();
  186. break;
  187. // LEFT_ARROW
  188. case 37:
  189. this.prev();
  190. break;
  191. // UP_ARROW
  192. case 38:
  193. this.handleActions('zoomIn');
  194. break;
  195. // RIGHT_ARROW
  196. case 39:
  197. this.next();
  198. break;
  199. // DOWN_ARROW
  200. case 40:
  201. this.handleActions('zoomOut');
  202. break;
  203. }
  204. });
  205. this._mouseWheelHandler = Object(util["b" /* rafThrottle */])(e => {
  206. const delta = e.wheelDelta ? e.wheelDelta : -e.detail;
  207. if (delta > 0) {
  208. this.handleActions('zoomIn', {
  209. zoomRate: 0.015,
  210. enableTransition: false
  211. });
  212. } else {
  213. this.handleActions('zoomOut', {
  214. zoomRate: 0.015,
  215. enableTransition: false
  216. });
  217. }
  218. });
  219. Object(dom["b" /* on */])(document, 'keydown', this._keyDownHandler);
  220. Object(dom["b" /* on */])(document, mousewheelEventName, this._mouseWheelHandler);
  221. },
  222. deviceSupportUninstall() {
  223. Object(dom["a" /* off */])(document, 'keydown', this._keyDownHandler);
  224. Object(dom["a" /* off */])(document, mousewheelEventName, this._mouseWheelHandler);
  225. this._keyDownHandler = null;
  226. this._mouseWheelHandler = null;
  227. },
  228. handleImgLoad(e) {
  229. this.loading = false;
  230. },
  231. handleImgError(e) {
  232. this.loading = false;
  233. e.target.alt = '加载失败';
  234. },
  235. handleMouseDown(e) {
  236. if (this.loading || e.button !== 0) return;
  237. const {
  238. offsetX,
  239. offsetY
  240. } = this.transform;
  241. const startX = e.pageX;
  242. const startY = e.pageY;
  243. this._dragHandler = Object(util["b" /* rafThrottle */])(ev => {
  244. this.transform.offsetX = offsetX + ev.pageX - startX;
  245. this.transform.offsetY = offsetY + ev.pageY - startY;
  246. });
  247. Object(dom["b" /* on */])(document, 'mousemove', this._dragHandler);
  248. Object(dom["b" /* on */])(document, 'mouseup', ev => {
  249. Object(dom["a" /* off */])(document, 'mousemove', this._dragHandler);
  250. });
  251. e.preventDefault();
  252. },
  253. reset() {
  254. this.transform = {
  255. scale: 1,
  256. deg: 0,
  257. offsetX: 0,
  258. offsetY: 0,
  259. enableTransition: false
  260. };
  261. },
  262. toggleMode() {
  263. if (this.loading) return;
  264. const modeNames = Object.keys(Mode);
  265. const modeValues = Object.values(Mode);
  266. const index = modeValues.indexOf(this.mode);
  267. const nextIndex = (index + 1) % modeNames.length;
  268. this.mode = Mode[modeNames[nextIndex]];
  269. this.reset();
  270. },
  271. prev() {
  272. if (this.isFirst && !this.infinite) return;
  273. const len = this.urlList.length;
  274. this.index = (this.index - 1 + len) % len;
  275. },
  276. next() {
  277. if (this.isLast && !this.infinite) return;
  278. const len = this.urlList.length;
  279. this.index = (this.index + 1) % len;
  280. },
  281. handleActions(action, options = {}) {
  282. if (this.loading) return;
  283. const {
  284. zoomRate,
  285. rotateDeg,
  286. enableTransition
  287. } = {
  288. zoomRate: 0.2,
  289. rotateDeg: 90,
  290. enableTransition: true,
  291. ...options
  292. };
  293. const {
  294. transform
  295. } = this;
  296. switch (action) {
  297. case 'zoomOut':
  298. if (transform.scale > 0.2) {
  299. transform.scale = parseFloat((transform.scale - zoomRate).toFixed(3));
  300. }
  301. break;
  302. case 'zoomIn':
  303. transform.scale = parseFloat((transform.scale + zoomRate).toFixed(3));
  304. break;
  305. case 'clocelise':
  306. transform.deg += rotateDeg;
  307. break;
  308. case 'anticlocelise':
  309. transform.deg -= rotateDeg;
  310. break;
  311. }
  312. transform.enableTransition = enableTransition;
  313. }
  314. },
  315. mounted() {
  316. this.deviceSupportInstall(); // add tabindex then wrapper can be focusable via Javascript
  317. // focus wrapper so arrow key can't cause inner scroll behavior underneath
  318. this.$refs['el-image-viewer__wrapper'].focus();
  319. }
  320. });
  321. // CONCATENATED MODULE: ./components/default/image-viewer.vue?vue&type=script&lang=js&
  322. /* harmony default export */ var default_image_viewervue_type_script_lang_js_ = (image_viewervue_type_script_lang_js_);
  323. // EXTERNAL MODULE: ./node_modules/_vue-loader@15.9.8@vue-loader/lib/runtime/componentNormalizer.js
  324. var componentNormalizer = __webpack_require__(2);
  325. // CONCATENATED MODULE: ./components/default/image-viewer.vue
  326. /* normalize component */
  327. var component = Object(componentNormalizer["a" /* default */])(
  328. default_image_viewervue_type_script_lang_js_,
  329. render,
  330. staticRenderFns,
  331. false,
  332. null,
  333. null,
  334. "ef95725e"
  335. )
  336. /* harmony default export */ var image_viewer = __webpack_exports__["default"] = (component.exports);
  337. /***/ }),
  338. /***/ 159:
  339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  340. "use strict";
  341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return on; });
  342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return off; });
  343. /* unused harmony export once */
  344. /* unused harmony export hasClass */
  345. /* unused harmony export addClass */
  346. /* unused harmony export removeClass */
  347. /* unused harmony export getStyle */
  348. /* unused harmony export setStyle */
  349. /* unused harmony export isScroll */
  350. /* unused harmony export getScrollContainer */
  351. /* unused harmony export isInContainer */
  352. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
  353. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
  354. /* istanbul ignore next */
  355. const isServer = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer;
  356. const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
  357. const MOZ_HACK_REGEXP = /^moz([A-Z])/;
  358. const ieVersion = isServer ? 0 : Number(document.documentMode);
  359. /* istanbul ignore next */
  360. const trim = function(string) {
  361. return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
  362. };
  363. /* istanbul ignore next */
  364. const camelCase = function(name) {
  365. return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
  366. return offset ? letter.toUpperCase() : letter;
  367. }).replace(MOZ_HACK_REGEXP, 'Moz$1');
  368. };
  369. /* istanbul ignore next */
  370. const on = (function() {
  371. if (!isServer && document.addEventListener) {
  372. return function(element, event, handler) {
  373. if (element && event && handler) {
  374. element.addEventListener(event, handler, false);
  375. }
  376. };
  377. } else {
  378. return function(element, event, handler) {
  379. if (element && event && handler) {
  380. element.attachEvent('on' + event, handler);
  381. }
  382. };
  383. }
  384. })();
  385. /* istanbul ignore next */
  386. const off = (function() {
  387. if (!isServer && document.removeEventListener) {
  388. return function(element, event, handler) {
  389. if (element && event) {
  390. element.removeEventListener(event, handler, false);
  391. }
  392. };
  393. } else {
  394. return function(element, event, handler) {
  395. if (element && event) {
  396. element.detachEvent('on' + event, handler);
  397. }
  398. };
  399. }
  400. })();
  401. /* istanbul ignore next */
  402. const once = function(el, event, fn) {
  403. var listener = function() {
  404. if (fn) {
  405. fn.apply(this, arguments);
  406. }
  407. off(el, event, listener);
  408. };
  409. on(el, event, listener);
  410. };
  411. /* istanbul ignore next */
  412. function hasClass(el, cls) {
  413. if (!el || !cls) return false;
  414. if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
  415. if (el.classList) {
  416. return el.classList.contains(cls);
  417. } else {
  418. return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
  419. }
  420. };
  421. /* istanbul ignore next */
  422. function addClass(el, cls) {
  423. if (!el) return;
  424. var curClass = el.className;
  425. var classes = (cls || '').split(' ');
  426. for (var i = 0, j = classes.length; i < j; i++) {
  427. var clsName = classes[i];
  428. if (!clsName) continue;
  429. if (el.classList) {
  430. el.classList.add(clsName);
  431. } else if (!hasClass(el, clsName)) {
  432. curClass += ' ' + clsName;
  433. }
  434. }
  435. if (!el.classList) {
  436. el.className = curClass;
  437. }
  438. };
  439. /* istanbul ignore next */
  440. function removeClass(el, cls) {
  441. if (!el || !cls) return;
  442. var classes = cls.split(' ');
  443. var curClass = ' ' + el.className + ' ';
  444. for (var i = 0, j = classes.length; i < j; i++) {
  445. var clsName = classes[i];
  446. if (!clsName) continue;
  447. if (el.classList) {
  448. el.classList.remove(clsName);
  449. } else if (hasClass(el, clsName)) {
  450. curClass = curClass.replace(' ' + clsName + ' ', ' ');
  451. }
  452. }
  453. if (!el.classList) {
  454. el.className = trim(curClass);
  455. }
  456. };
  457. /* istanbul ignore next */
  458. const getStyle = ieVersion < 9 ? function(element, styleName) {
  459. if (isServer) return;
  460. if (!element || !styleName) return null;
  461. styleName = camelCase(styleName);
  462. if (styleName === 'float') {
  463. styleName = 'styleFloat';
  464. }
  465. try {
  466. switch (styleName) {
  467. case 'opacity':
  468. try {
  469. return element.filters.item('alpha').opacity / 100;
  470. } catch (e) {
  471. return 1.0;
  472. }
  473. default:
  474. return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
  475. }
  476. } catch (e) {
  477. return element.style[styleName];
  478. }
  479. } : function(element, styleName) {
  480. if (isServer) return;
  481. if (!element || !styleName) return null;
  482. styleName = camelCase(styleName);
  483. if (styleName === 'float') {
  484. styleName = 'cssFloat';
  485. }
  486. try {
  487. var computed = document.defaultView.getComputedStyle(element, '');
  488. return element.style[styleName] || computed ? computed[styleName] : null;
  489. } catch (e) {
  490. return element.style[styleName];
  491. }
  492. };
  493. /* istanbul ignore next */
  494. function setStyle(element, styleName, value) {
  495. if (!element || !styleName) return;
  496. if (typeof styleName === 'object') {
  497. for (var prop in styleName) {
  498. if (styleName.hasOwnProperty(prop)) {
  499. setStyle(element, prop, styleName[prop]);
  500. }
  501. }
  502. } else {
  503. styleName = camelCase(styleName);
  504. if (styleName === 'opacity' && ieVersion < 9) {
  505. element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
  506. } else {
  507. element.style[styleName] = value;
  508. }
  509. }
  510. };
  511. const isScroll = (el, vertical) => {
  512. if (isServer) return;
  513. const determinedDirection = vertical !== null || vertical !== undefined;
  514. const overflow = determinedDirection
  515. ? vertical
  516. ? getStyle(el, 'overflow-y')
  517. : getStyle(el, 'overflow-x')
  518. : getStyle(el, 'overflow');
  519. return overflow.match(/(scroll|auto)/);
  520. };
  521. const getScrollContainer = (el, vertical) => {
  522. if (isServer) return;
  523. let parent = el;
  524. while (parent) {
  525. if ([window, document, document.documentElement].includes(parent)) {
  526. return window;
  527. }
  528. if (isScroll(parent, vertical)) {
  529. return parent;
  530. }
  531. parent = parent.parentNode;
  532. }
  533. return parent;
  534. };
  535. const isInContainer = (el, container) => {
  536. if (isServer || !el || !container) return false;
  537. const elRect = el.getBoundingClientRect();
  538. let containerRect;
  539. if ([window, document, document.documentElement, null, undefined].includes(container)) {
  540. containerRect = {
  541. top: 0,
  542. right: window.innerWidth,
  543. bottom: window.innerHeight,
  544. left: 0
  545. };
  546. } else {
  547. containerRect = container.getBoundingClientRect();
  548. }
  549. return elRect.top < containerRect.bottom &&
  550. elRect.bottom > containerRect.top &&
  551. elRect.right > containerRect.left &&
  552. elRect.left < containerRect.right;
  553. };
  554. /***/ }),
  555. /***/ 160:
  556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  557. "use strict";
  558. // EXPORTS
  559. __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ isFirefox; });
  560. __webpack_require__.d(__webpack_exports__, "b", function() { return /* binding */ rafThrottle; });
  561. // UNUSED EXPORTS: noop, hasOwn, toObject, getValueByPath, getPropByPath, generateId, valueEquals, escapeRegexpString, arrayFindIndex, arrayFind, coerceTruthyValueToArray, isIE, isEdge, autoprefixer, kebabCase, capitalize, looseEqual, arrayEquals, isEqual, isEmpty, objToArray
  562. // EXTERNAL MODULE: external "vue"
  563. var external_vue_ = __webpack_require__(0);
  564. var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
  565. // CONCATENATED MODULE: ./node_modules/_element-ui@2.14.1@element-ui/src/utils/types.js
  566. function isString(obj) {
  567. return Object.prototype.toString.call(obj) === '[object String]';
  568. }
  569. function isObject(obj) {
  570. return Object.prototype.toString.call(obj) === '[object Object]';
  571. }
  572. function isHtmlElement(node) {
  573. return node && node.nodeType === Node.ELEMENT_NODE;
  574. }
  575. const isFunction = (functionToCheck) => {
  576. var getType = {};
  577. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  578. };
  579. const isUndefined = (val)=> {
  580. return val === void 0;
  581. };
  582. const isDefined = (val) => {
  583. return val !== undefined && val !== null;
  584. };
  585. // CONCATENATED MODULE: ./node_modules/_element-ui@2.14.1@element-ui/src/utils/util.js
  586. const util_hasOwnProperty = Object.prototype.hasOwnProperty;
  587. function noop() {};
  588. function hasOwn(obj, key) {
  589. return util_hasOwnProperty.call(obj, key);
  590. };
  591. function extend(to, _from) {
  592. for (let key in _from) {
  593. to[key] = _from[key];
  594. }
  595. return to;
  596. };
  597. function toObject(arr) {
  598. var res = {};
  599. for (let i = 0; i < arr.length; i++) {
  600. if (arr[i]) {
  601. extend(res, arr[i]);
  602. }
  603. }
  604. return res;
  605. };
  606. const getValueByPath = function(object, prop) {
  607. prop = prop || '';
  608. const paths = prop.split('.');
  609. let current = object;
  610. let result = null;
  611. for (let i = 0, j = paths.length; i < j; i++) {
  612. const path = paths[i];
  613. if (!current) break;
  614. if (i === j - 1) {
  615. result = current[path];
  616. break;
  617. }
  618. current = current[path];
  619. }
  620. return result;
  621. };
  622. function getPropByPath(obj, path, strict) {
  623. let tempObj = obj;
  624. path = path.replace(/\[(\w+)\]/g, '.$1');
  625. path = path.replace(/^\./, '');
  626. let keyArr = path.split('.');
  627. let i = 0;
  628. for (let len = keyArr.length; i < len - 1; ++i) {
  629. if (!tempObj && !strict) break;
  630. let key = keyArr[i];
  631. if (key in tempObj) {
  632. tempObj = tempObj[key];
  633. } else {
  634. if (strict) {
  635. throw new Error('please transfer a valid prop path to form item!');
  636. }
  637. break;
  638. }
  639. }
  640. return {
  641. o: tempObj,
  642. k: keyArr[i],
  643. v: tempObj ? tempObj[keyArr[i]] : null
  644. };
  645. };
  646. const generateId = function() {
  647. return Math.floor(Math.random() * 10000);
  648. };
  649. const valueEquals = (a, b) => {
  650. // see: https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
  651. if (a === b) return true;
  652. if (!(a instanceof Array)) return false;
  653. if (!(b instanceof Array)) return false;
  654. if (a.length !== b.length) return false;
  655. for (let i = 0; i !== a.length; ++i) {
  656. if (a[i] !== b[i]) return false;
  657. }
  658. return true;
  659. };
  660. const escapeRegexpString = (value = '') => String(value).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
  661. // TODO: use native Array.find, Array.findIndex when IE support is dropped
  662. const arrayFindIndex = function(arr, pred) {
  663. for (let i = 0; i !== arr.length; ++i) {
  664. if (pred(arr[i])) {
  665. return i;
  666. }
  667. }
  668. return -1;
  669. };
  670. const arrayFind = function(arr, pred) {
  671. const idx = arrayFindIndex(arr, pred);
  672. return idx !== -1 ? arr[idx] : undefined;
  673. };
  674. // coerce truthy value to array
  675. const coerceTruthyValueToArray = function(val) {
  676. if (Array.isArray(val)) {
  677. return val;
  678. } else if (val) {
  679. return [val];
  680. } else {
  681. return [];
  682. }
  683. };
  684. const isIE = function() {
  685. return !external_vue_default.a.prototype.$isServer && !isNaN(Number(document.documentMode));
  686. };
  687. const isEdge = function() {
  688. return !external_vue_default.a.prototype.$isServer && navigator.userAgent.indexOf('Edge') > -1;
  689. };
  690. const isFirefox = function() {
  691. return !external_vue_default.a.prototype.$isServer && !!window.navigator.userAgent.match(/firefox/i);
  692. };
  693. const autoprefixer = function(style) {
  694. if (typeof style !== 'object') return style;
  695. const rules = ['transform', 'transition', 'animation'];
  696. const prefixes = ['ms-', 'webkit-'];
  697. rules.forEach(rule => {
  698. const value = style[rule];
  699. if (rule && value) {
  700. prefixes.forEach(prefix => {
  701. style[prefix + rule] = value;
  702. });
  703. }
  704. });
  705. return style;
  706. };
  707. const kebabCase = function(str) {
  708. const hyphenateRE = /([^-])([A-Z])/g;
  709. return str
  710. .replace(hyphenateRE, '$1-$2')
  711. .replace(hyphenateRE, '$1-$2')
  712. .toLowerCase();
  713. };
  714. const capitalize = function(str) {
  715. if (!isString(str)) return str;
  716. return str.charAt(0).toUpperCase() + str.slice(1);
  717. };
  718. const looseEqual = function(a, b) {
  719. const isObjectA = isObject(a);
  720. const isObjectB = isObject(b);
  721. if (isObjectA && isObjectB) {
  722. return JSON.stringify(a) === JSON.stringify(b);
  723. } else if (!isObjectA && !isObjectB) {
  724. return String(a) === String(b);
  725. } else {
  726. return false;
  727. }
  728. };
  729. const arrayEquals = function(arrayA, arrayB) {
  730. arrayA = arrayA || [];
  731. arrayB = arrayB || [];
  732. if (arrayA.length !== arrayB.length) {
  733. return false;
  734. }
  735. for (let i = 0; i < arrayA.length; i++) {
  736. if (!looseEqual(arrayA[i], arrayB[i])) {
  737. return false;
  738. }
  739. }
  740. return true;
  741. };
  742. const isEqual = function(value1, value2) {
  743. if (Array.isArray(value1) && Array.isArray(value2)) {
  744. return arrayEquals(value1, value2);
  745. }
  746. return looseEqual(value1, value2);
  747. };
  748. const isEmpty = function(val) {
  749. // null or undefined
  750. if (val == null) return true;
  751. if (typeof val === 'boolean') return false;
  752. if (typeof val === 'number') return !val;
  753. if (val instanceof Error) return val.message === '';
  754. switch (Object.prototype.toString.call(val)) {
  755. // String or Array
  756. case '[object String]':
  757. case '[object Array]':
  758. return !val.length;
  759. // Map or Set or File
  760. case '[object File]':
  761. case '[object Map]':
  762. case '[object Set]': {
  763. return !val.size;
  764. }
  765. // Plain Object
  766. case '[object Object]': {
  767. return !Object.keys(val).length;
  768. }
  769. }
  770. return false;
  771. };
  772. function rafThrottle(fn) {
  773. let locked = false;
  774. return function(...args) {
  775. if (locked) return;
  776. locked = true;
  777. window.requestAnimationFrame(_ => {
  778. fn.apply(this, args);
  779. locked = false;
  780. });
  781. };
  782. }
  783. function objToArray(obj) {
  784. if (Array.isArray(obj)) {
  785. return obj;
  786. }
  787. return isEmpty(obj) ? [] : [obj];
  788. }
  789. /***/ })
  790. };;
  791. //# sourceMappingURL=default-image-viewer.js.map