mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-10-24 01:49:10 +08:00
*
This commit is contained in:
68
static/element-ui/lib/utils/clickoutside.js
Normal file
68
static/element-ui/lib/utils/clickoutside.js
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
var _dom = require('element-ui/lib/utils/dom');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var nodeList = [];
|
||||
var ctx = '@@clickoutsideContext';
|
||||
|
||||
var startClick = void 0;
|
||||
|
||||
!_vue2.default.prototype.$isServer && (0, _dom.on)(document, 'mousedown', function (e) {
|
||||
return startClick = e;
|
||||
});
|
||||
|
||||
!_vue2.default.prototype.$isServer && (0, _dom.on)(document, 'mouseup', function (e) {
|
||||
nodeList.forEach(function (node) {
|
||||
return node[ctx].documentHandler(e, startClick);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* v-clickoutside
|
||||
* @desc 点击元素外面才会触发的事件
|
||||
* @example
|
||||
* ```vue
|
||||
* <div v-element-clickoutside="handleClose">
|
||||
* ```
|
||||
*/
|
||||
exports.default = {
|
||||
bind: function bind(el, binding, vnode) {
|
||||
var id = nodeList.push(el) - 1;
|
||||
var documentHandler = function documentHandler(mouseup, mousedown) {
|
||||
if (!vnode.context || el.contains(mouseup.target) || vnode.context.popperElm && (vnode.context.popperElm.contains(mouseup.target) || vnode.context.popperElm.contains(mousedown.target))) return;
|
||||
|
||||
if (binding.expression && el[ctx].methodName && vnode.context[el[ctx].methodName]) {
|
||||
vnode.context[el[ctx].methodName]();
|
||||
} else {
|
||||
el[ctx].bindingFn && el[ctx].bindingFn();
|
||||
}
|
||||
};
|
||||
el[ctx] = {
|
||||
id: id,
|
||||
documentHandler: documentHandler,
|
||||
methodName: binding.expression,
|
||||
bindingFn: binding.value
|
||||
};
|
||||
},
|
||||
update: function update(el, binding) {
|
||||
el[ctx].methodName = binding.expression;
|
||||
el[ctx].bindingFn = binding.value;
|
||||
},
|
||||
unbind: function unbind(el) {
|
||||
var len = nodeList.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (nodeList[i][ctx].id === el[ctx].id) {
|
||||
nodeList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
345
static/element-ui/lib/utils/date.js
Normal file
345
static/element-ui/lib/utils/date.js
Normal file
@@ -0,0 +1,345 @@
|
||||
'use strict';
|
||||
|
||||
/* Modified from https://github.com/taylorhakes/fecha
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Taylor Hakes
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*eslint-disable*/
|
||||
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
||||
(function (main) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Parse or format dates
|
||||
* @class fecha
|
||||
*/
|
||||
|
||||
var fecha = {};
|
||||
var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
||||
var twoDigits = /\d\d?/;
|
||||
var threeDigits = /\d{3}/;
|
||||
var fourDigits = /\d{4}/;
|
||||
var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
|
||||
var noop = function noop() {};
|
||||
|
||||
function shorten(arr, sLen) {
|
||||
var newArr = [];
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
newArr.push(arr[i].substr(0, sLen));
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
function monthUpdate(arrName) {
|
||||
return function (d, v, i18n) {
|
||||
var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
|
||||
if (~index) {
|
||||
d.month = index;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function pad(val, len) {
|
||||
val = String(val);
|
||||
len = len || 2;
|
||||
while (val.length < len) {
|
||||
val = '0' + val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
var monthNamesShort = shorten(monthNames, 3);
|
||||
var dayNamesShort = shorten(dayNames, 3);
|
||||
fecha.i18n = {
|
||||
dayNamesShort: dayNamesShort,
|
||||
dayNames: dayNames,
|
||||
monthNamesShort: monthNamesShort,
|
||||
monthNames: monthNames,
|
||||
amPm: ['am', 'pm'],
|
||||
DoFn: function DoFn(D) {
|
||||
return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
|
||||
}
|
||||
};
|
||||
|
||||
var formatFlags = {
|
||||
D: function D(dateObj) {
|
||||
return dateObj.getDay();
|
||||
},
|
||||
DD: function DD(dateObj) {
|
||||
return pad(dateObj.getDay());
|
||||
},
|
||||
Do: function Do(dateObj, i18n) {
|
||||
return i18n.DoFn(dateObj.getDate());
|
||||
},
|
||||
d: function d(dateObj) {
|
||||
return dateObj.getDate();
|
||||
},
|
||||
dd: function dd(dateObj) {
|
||||
return pad(dateObj.getDate());
|
||||
},
|
||||
ddd: function ddd(dateObj, i18n) {
|
||||
return i18n.dayNamesShort[dateObj.getDay()];
|
||||
},
|
||||
dddd: function dddd(dateObj, i18n) {
|
||||
return i18n.dayNames[dateObj.getDay()];
|
||||
},
|
||||
M: function M(dateObj) {
|
||||
return dateObj.getMonth() + 1;
|
||||
},
|
||||
MM: function MM(dateObj) {
|
||||
return pad(dateObj.getMonth() + 1);
|
||||
},
|
||||
MMM: function MMM(dateObj, i18n) {
|
||||
return i18n.monthNamesShort[dateObj.getMonth()];
|
||||
},
|
||||
MMMM: function MMMM(dateObj, i18n) {
|
||||
return i18n.monthNames[dateObj.getMonth()];
|
||||
},
|
||||
yy: function yy(dateObj) {
|
||||
return String(dateObj.getFullYear()).substr(2);
|
||||
},
|
||||
yyyy: function yyyy(dateObj) {
|
||||
return dateObj.getFullYear();
|
||||
},
|
||||
h: function h(dateObj) {
|
||||
return dateObj.getHours() % 12 || 12;
|
||||
},
|
||||
hh: function hh(dateObj) {
|
||||
return pad(dateObj.getHours() % 12 || 12);
|
||||
},
|
||||
H: function H(dateObj) {
|
||||
return dateObj.getHours();
|
||||
},
|
||||
HH: function HH(dateObj) {
|
||||
return pad(dateObj.getHours());
|
||||
},
|
||||
m: function m(dateObj) {
|
||||
return dateObj.getMinutes();
|
||||
},
|
||||
mm: function mm(dateObj) {
|
||||
return pad(dateObj.getMinutes());
|
||||
},
|
||||
s: function s(dateObj) {
|
||||
return dateObj.getSeconds();
|
||||
},
|
||||
ss: function ss(dateObj) {
|
||||
return pad(dateObj.getSeconds());
|
||||
},
|
||||
S: function S(dateObj) {
|
||||
return Math.round(dateObj.getMilliseconds() / 100);
|
||||
},
|
||||
SS: function SS(dateObj) {
|
||||
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
||||
},
|
||||
SSS: function SSS(dateObj) {
|
||||
return pad(dateObj.getMilliseconds(), 3);
|
||||
},
|
||||
a: function a(dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
||||
},
|
||||
A: function A(dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
|
||||
},
|
||||
ZZ: function ZZ(dateObj) {
|
||||
var o = dateObj.getTimezoneOffset();
|
||||
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
||||
}
|
||||
};
|
||||
|
||||
var parseFlags = {
|
||||
d: [twoDigits, function (d, v) {
|
||||
d.day = v;
|
||||
}],
|
||||
M: [twoDigits, function (d, v) {
|
||||
d.month = v - 1;
|
||||
}],
|
||||
yy: [twoDigits, function (d, v) {
|
||||
var da = new Date(),
|
||||
cent = +('' + da.getFullYear()).substr(0, 2);
|
||||
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
||||
}],
|
||||
h: [twoDigits, function (d, v) {
|
||||
d.hour = v;
|
||||
}],
|
||||
m: [twoDigits, function (d, v) {
|
||||
d.minute = v;
|
||||
}],
|
||||
s: [twoDigits, function (d, v) {
|
||||
d.second = v;
|
||||
}],
|
||||
yyyy: [fourDigits, function (d, v) {
|
||||
d.year = v;
|
||||
}],
|
||||
S: [/\d/, function (d, v) {
|
||||
d.millisecond = v * 100;
|
||||
}],
|
||||
SS: [/\d{2}/, function (d, v) {
|
||||
d.millisecond = v * 10;
|
||||
}],
|
||||
SSS: [threeDigits, function (d, v) {
|
||||
d.millisecond = v;
|
||||
}],
|
||||
D: [twoDigits, noop],
|
||||
ddd: [word, noop],
|
||||
MMM: [word, monthUpdate('monthNamesShort')],
|
||||
MMMM: [word, monthUpdate('monthNames')],
|
||||
a: [word, function (d, v, i18n) {
|
||||
var val = v.toLowerCase();
|
||||
if (val === i18n.amPm[0]) {
|
||||
d.isPm = false;
|
||||
} else if (val === i18n.amPm[1]) {
|
||||
d.isPm = true;
|
||||
}
|
||||
}],
|
||||
ZZ: [/[\+\-]\d\d:?\d\d/, function (d, v) {
|
||||
var parts = (v + '').match(/([\+\-]|\d\d)/gi),
|
||||
minutes;
|
||||
|
||||
if (parts) {
|
||||
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
||||
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
||||
}
|
||||
}]
|
||||
};
|
||||
parseFlags.DD = parseFlags.D;
|
||||
parseFlags.dddd = parseFlags.ddd;
|
||||
parseFlags.Do = parseFlags.dd = parseFlags.d;
|
||||
parseFlags.mm = parseFlags.m;
|
||||
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
||||
parseFlags.MM = parseFlags.M;
|
||||
parseFlags.ss = parseFlags.s;
|
||||
parseFlags.A = parseFlags.a;
|
||||
|
||||
// Some common format strings
|
||||
fecha.masks = {
|
||||
'default': 'ddd MMM dd yyyy HH:mm:ss',
|
||||
shortDate: 'M/D/yy',
|
||||
mediumDate: 'MMM d, yyyy',
|
||||
longDate: 'MMMM d, yyyy',
|
||||
fullDate: 'dddd, MMMM d, yyyy',
|
||||
shortTime: 'HH:mm',
|
||||
mediumTime: 'HH:mm:ss',
|
||||
longTime: 'HH:mm:ss.SSS'
|
||||
};
|
||||
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
*/
|
||||
fecha.format = function (dateObj, mask, i18nSettings) {
|
||||
var i18n = i18nSettings || fecha.i18n;
|
||||
|
||||
if (typeof dateObj === 'number') {
|
||||
dateObj = new Date(dateObj);
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
||||
throw new Error('Invalid Date in fecha.format');
|
||||
}
|
||||
|
||||
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
||||
|
||||
return mask.replace(token, function ($0) {
|
||||
return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a date string into an object, changes - into /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @returns {Date|boolean}
|
||||
*/
|
||||
fecha.parse = function (dateStr, format, i18nSettings) {
|
||||
var i18n = i18nSettings || fecha.i18n;
|
||||
|
||||
if (typeof format !== 'string') {
|
||||
throw new Error('Invalid format in fecha.parse');
|
||||
}
|
||||
|
||||
format = fecha.masks[format] || format;
|
||||
|
||||
// Avoid regular expression denial of service, fail early for really long strings
|
||||
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
||||
if (dateStr.length > 1000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
var dateInfo = {};
|
||||
format.replace(token, function ($0) {
|
||||
if (parseFlags[$0]) {
|
||||
var info = parseFlags[$0];
|
||||
var index = dateStr.search(info[0]);
|
||||
if (!~index) {
|
||||
isValid = false;
|
||||
} else {
|
||||
dateStr.replace(info[0], function (result) {
|
||||
info[1](dateInfo, result, i18n);
|
||||
dateStr = dateStr.substr(index + result.length);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
|
||||
});
|
||||
|
||||
if (!isValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var today = new Date();
|
||||
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
||||
dateInfo.hour = +dateInfo.hour + 12;
|
||||
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
||||
dateInfo.hour = 0;
|
||||
}
|
||||
|
||||
var date;
|
||||
if (dateInfo.timezoneOffset != null) {
|
||||
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
||||
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
||||
} else {
|
||||
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
||||
}
|
||||
return date;
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = fecha;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(function () {
|
||||
return fecha;
|
||||
});
|
||||
} else {
|
||||
main.fecha = fecha;
|
||||
}
|
||||
})(undefined);
|
||||
192
static/element-ui/lib/utils/dom.js
Normal file
192
static/element-ui/lib/utils/dom.js
Normal file
@@ -0,0 +1,192 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.getStyle = exports.once = exports.off = exports.on = undefined;
|
||||
|
||||
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; }; /* istanbul ignore next */
|
||||
|
||||
exports.hasClass = hasClass;
|
||||
exports.addClass = addClass;
|
||||
exports.removeClass = removeClass;
|
||||
exports.setStyle = setStyle;
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var isServer = _vue2.default.prototype.$isServer;
|
||||
var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
|
||||
var MOZ_HACK_REGEXP = /^moz([A-Z])/;
|
||||
var ieVersion = isServer ? 0 : Number(document.documentMode);
|
||||
|
||||
/* istanbul ignore next */
|
||||
var trim = function trim(string) {
|
||||
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
|
||||
};
|
||||
/* istanbul ignore next */
|
||||
var camelCase = function camelCase(name) {
|
||||
return name.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
|
||||
return offset ? letter.toUpperCase() : letter;
|
||||
}).replace(MOZ_HACK_REGEXP, 'Moz$1');
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var on = exports.on = function () {
|
||||
if (!isServer && document.addEventListener) {
|
||||
return function (element, event, handler) {
|
||||
if (element && event && handler) {
|
||||
element.addEventListener(event, handler, false);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return function (element, event, handler) {
|
||||
if (element && event && handler) {
|
||||
element.attachEvent('on' + event, handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
}();
|
||||
|
||||
/* istanbul ignore next */
|
||||
var off = exports.off = function () {
|
||||
if (!isServer && document.removeEventListener) {
|
||||
return function (element, event, handler) {
|
||||
if (element && event) {
|
||||
element.removeEventListener(event, handler, false);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return function (element, event, handler) {
|
||||
if (element && event) {
|
||||
element.detachEvent('on' + event, handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
}();
|
||||
|
||||
/* istanbul ignore next */
|
||||
var once = exports.once = function once(el, event, fn) {
|
||||
var listener = function listener() {
|
||||
if (fn) {
|
||||
fn.apply(this, arguments);
|
||||
}
|
||||
off(el, event, listener);
|
||||
};
|
||||
on(el, event, listener);
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
function hasClass(el, cls) {
|
||||
if (!el || !cls) return false;
|
||||
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
|
||||
if (el.classList) {
|
||||
return el.classList.contains(cls);
|
||||
} else {
|
||||
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
function addClass(el, cls) {
|
||||
if (!el) return;
|
||||
var curClass = el.className;
|
||||
var classes = (cls || '').split(' ');
|
||||
|
||||
for (var i = 0, j = classes.length; i < j; i++) {
|
||||
var clsName = classes[i];
|
||||
if (!clsName) continue;
|
||||
|
||||
if (el.classList) {
|
||||
el.classList.add(clsName);
|
||||
} else {
|
||||
if (!hasClass(el, clsName)) {
|
||||
curClass += ' ' + clsName;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!el.classList) {
|
||||
el.className = curClass;
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
function removeClass(el, cls) {
|
||||
if (!el || !cls) return;
|
||||
var classes = cls.split(' ');
|
||||
var curClass = ' ' + el.className + ' ';
|
||||
|
||||
for (var i = 0, j = classes.length; i < j; i++) {
|
||||
var clsName = classes[i];
|
||||
if (!clsName) continue;
|
||||
|
||||
if (el.classList) {
|
||||
el.classList.remove(clsName);
|
||||
} else {
|
||||
if (hasClass(el, clsName)) {
|
||||
curClass = curClass.replace(' ' + clsName + ' ', ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!el.classList) {
|
||||
el.className = trim(curClass);
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var getStyle = exports.getStyle = ieVersion < 9 ? function (element, styleName) {
|
||||
if (isServer) return;
|
||||
if (!element || !styleName) return null;
|
||||
styleName = camelCase(styleName);
|
||||
if (styleName === 'float') {
|
||||
styleName = 'styleFloat';
|
||||
}
|
||||
try {
|
||||
switch (styleName) {
|
||||
case 'opacity':
|
||||
try {
|
||||
return element.filters.item('alpha').opacity / 100;
|
||||
} catch (e) {
|
||||
return 1.0;
|
||||
}
|
||||
default:
|
||||
return element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null;
|
||||
}
|
||||
} catch (e) {
|
||||
return element.style[styleName];
|
||||
}
|
||||
} : function (element, styleName) {
|
||||
if (isServer) return;
|
||||
if (!element || !styleName) return null;
|
||||
styleName = camelCase(styleName);
|
||||
if (styleName === 'float') {
|
||||
styleName = 'cssFloat';
|
||||
}
|
||||
try {
|
||||
var computed = document.defaultView.getComputedStyle(element, '');
|
||||
return element.style[styleName] || computed ? computed[styleName] : null;
|
||||
} catch (e) {
|
||||
return element.style[styleName];
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
function setStyle(element, styleName, value) {
|
||||
if (!element || !styleName) return;
|
||||
|
||||
if ((typeof styleName === 'undefined' ? 'undefined' : _typeof(styleName)) === 'object') {
|
||||
for (var prop in styleName) {
|
||||
if (styleName.hasOwnProperty(prop)) {
|
||||
setStyle(element, prop, styleName[prop]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
styleName = camelCase(styleName);
|
||||
if (styleName === 'opacity' && ieVersion < 9) {
|
||||
element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
|
||||
} else {
|
||||
element.style[styleName] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
21
static/element-ui/lib/utils/merge.js
Normal file
21
static/element-ui/lib/utils/merge.js
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
exports.default = function (target) {
|
||||
for (var i = 1, j = arguments.length; i < j; i++) {
|
||||
var source = arguments[i] || {};
|
||||
for (var prop in source) {
|
||||
if (source.hasOwnProperty(prop)) {
|
||||
var value = source[prop];
|
||||
if (value !== undefined) {
|
||||
target[prop] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
;
|
||||
1260
static/element-ui/lib/utils/popper.js
Normal file
1260
static/element-ui/lib/utils/popper.js
Normal file
File diff suppressed because it is too large
Load Diff
296
static/element-ui/lib/utils/popup/index.js
Normal file
296
static/element-ui/lib/utils/popup/index.js
Normal file
@@ -0,0 +1,296 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.PopupManager = undefined;
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
var _merge = require('element-ui/lib/utils/merge');
|
||||
|
||||
var _merge2 = _interopRequireDefault(_merge);
|
||||
|
||||
var _popupManager = require('element-ui/lib/utils/popup/popup-manager');
|
||||
|
||||
var _popupManager2 = _interopRequireDefault(_popupManager);
|
||||
|
||||
var _scrollbarWidth = require('../scrollbar-width');
|
||||
|
||||
var _scrollbarWidth2 = _interopRequireDefault(_scrollbarWidth);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var idSeed = 1;
|
||||
var transitions = [];
|
||||
|
||||
var hookTransition = function hookTransition(transition) {
|
||||
if (transitions.indexOf(transition) !== -1) return;
|
||||
|
||||
var getVueInstance = function getVueInstance(element) {
|
||||
var instance = element.__vue__;
|
||||
if (!instance) {
|
||||
var textNode = element.previousSibling;
|
||||
if (textNode.__vue__) {
|
||||
instance = textNode.__vue__;
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
|
||||
_vue2.default.transition(transition, {
|
||||
afterEnter: function afterEnter(el) {
|
||||
var instance = getVueInstance(el);
|
||||
|
||||
if (instance) {
|
||||
instance.doAfterOpen && instance.doAfterOpen();
|
||||
}
|
||||
},
|
||||
afterLeave: function afterLeave(el) {
|
||||
var instance = getVueInstance(el);
|
||||
|
||||
if (instance) {
|
||||
instance.doAfterClose && instance.doAfterClose();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var scrollBarWidth = void 0;
|
||||
|
||||
var getDOM = function getDOM(dom) {
|
||||
if (dom.nodeType === 3) {
|
||||
dom = dom.nextElementSibling || dom.nextSibling;
|
||||
getDOM(dom);
|
||||
}
|
||||
return dom;
|
||||
};
|
||||
|
||||
exports.default = {
|
||||
props: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
transition: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
openDelay: {},
|
||||
closeDelay: {},
|
||||
zIndex: {},
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
modalFade: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
modalClass: {},
|
||||
modalAppendToBody: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
lockScroll: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
closeOnPressEscape: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
closeOnClickModal: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
created: function created() {
|
||||
if (this.transition) {
|
||||
hookTransition(this.transition);
|
||||
}
|
||||
},
|
||||
beforeMount: function beforeMount() {
|
||||
this._popupId = 'popup-' + idSeed++;
|
||||
_popupManager2.default.register(this._popupId, this);
|
||||
},
|
||||
beforeDestroy: function beforeDestroy() {
|
||||
_popupManager2.default.deregister(this._popupId);
|
||||
_popupManager2.default.closeModal(this._popupId);
|
||||
if (this.modal && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
|
||||
document.body.style.overflow = this.bodyOverflow;
|
||||
document.body.style.paddingRight = this.bodyPaddingRight;
|
||||
}
|
||||
this.bodyOverflow = null;
|
||||
this.bodyPaddingRight = null;
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
opened: false,
|
||||
bodyOverflow: null,
|
||||
bodyPaddingRight: null,
|
||||
rendered: false
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
watch: {
|
||||
value: function value(val) {
|
||||
var _this = this;
|
||||
|
||||
if (val) {
|
||||
if (this._opening) return;
|
||||
if (!this.rendered) {
|
||||
this.rendered = true;
|
||||
_vue2.default.nextTick(function () {
|
||||
_this.open();
|
||||
});
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
} else {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
open: function open(options) {
|
||||
var _this2 = this;
|
||||
|
||||
if (!this.rendered) {
|
||||
this.rendered = true;
|
||||
this.$emit('input', true);
|
||||
}
|
||||
|
||||
var props = (0, _merge2.default)({}, this.$props || this, options);
|
||||
|
||||
if (this._closeTimer) {
|
||||
clearTimeout(this._closeTimer);
|
||||
this._closeTimer = null;
|
||||
}
|
||||
clearTimeout(this._openTimer);
|
||||
|
||||
var openDelay = Number(props.openDelay);
|
||||
if (openDelay > 0) {
|
||||
this._openTimer = setTimeout(function () {
|
||||
_this2._openTimer = null;
|
||||
_this2.doOpen(props);
|
||||
}, openDelay);
|
||||
} else {
|
||||
this.doOpen(props);
|
||||
}
|
||||
},
|
||||
doOpen: function doOpen(props) {
|
||||
if (this.$isServer) return;
|
||||
if (this.willOpen && !this.willOpen()) return;
|
||||
if (this.opened) return;
|
||||
|
||||
this._opening = true;
|
||||
|
||||
// 使用 vue-popup 的组件,如果需要和父组件通信显示的状态,应该使用 value,它是一个 prop,
|
||||
// 这样在父组件中用 v-model 即可;否则可以使用 visible,它是一个 data
|
||||
this.visible = true;
|
||||
this.$emit('input', true);
|
||||
|
||||
var dom = getDOM(this.$el);
|
||||
|
||||
var modal = props.modal;
|
||||
|
||||
var zIndex = props.zIndex;
|
||||
if (zIndex) {
|
||||
_popupManager2.default.zIndex = zIndex;
|
||||
}
|
||||
|
||||
if (modal) {
|
||||
if (this._closing) {
|
||||
_popupManager2.default.closeModal(this._popupId);
|
||||
this._closing = false;
|
||||
}
|
||||
_popupManager2.default.openModal(this._popupId, _popupManager2.default.nextZIndex(), this.modalAppendToBody ? undefined : dom, props.modalClass, props.modalFade);
|
||||
if (props.lockScroll) {
|
||||
if (!this.bodyOverflow) {
|
||||
this.bodyPaddingRight = document.body.style.paddingRight;
|
||||
this.bodyOverflow = document.body.style.overflow;
|
||||
}
|
||||
scrollBarWidth = (0, _scrollbarWidth2.default)();
|
||||
var bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
|
||||
if (scrollBarWidth > 0 && bodyHasOverflow) {
|
||||
document.body.style.paddingRight = scrollBarWidth + 'px';
|
||||
}
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
if (getComputedStyle(dom).position === 'static') {
|
||||
dom.style.position = 'absolute';
|
||||
}
|
||||
|
||||
dom.style.zIndex = _popupManager2.default.nextZIndex();
|
||||
this.opened = true;
|
||||
|
||||
this.onOpen && this.onOpen();
|
||||
|
||||
if (!this.transition) {
|
||||
this.doAfterOpen();
|
||||
}
|
||||
},
|
||||
doAfterOpen: function doAfterOpen() {
|
||||
this._opening = false;
|
||||
},
|
||||
close: function close() {
|
||||
var _this3 = this;
|
||||
|
||||
if (this.willClose && !this.willClose()) return;
|
||||
|
||||
if (this._openTimer !== null) {
|
||||
clearTimeout(this._openTimer);
|
||||
this._openTimer = null;
|
||||
}
|
||||
clearTimeout(this._closeTimer);
|
||||
|
||||
var closeDelay = Number(this.closeDelay);
|
||||
|
||||
if (closeDelay > 0) {
|
||||
this._closeTimer = setTimeout(function () {
|
||||
_this3._closeTimer = null;
|
||||
_this3.doClose();
|
||||
}, closeDelay);
|
||||
} else {
|
||||
this.doClose();
|
||||
}
|
||||
},
|
||||
doClose: function doClose() {
|
||||
var _this4 = this;
|
||||
|
||||
this.visible = false;
|
||||
this.$emit('input', false);
|
||||
this._closing = true;
|
||||
|
||||
this.onClose && this.onClose();
|
||||
|
||||
if (this.lockScroll) {
|
||||
setTimeout(function () {
|
||||
if (_this4.modal && _this4.bodyOverflow !== 'hidden') {
|
||||
document.body.style.overflow = _this4.bodyOverflow;
|
||||
document.body.style.paddingRight = _this4.bodyPaddingRight;
|
||||
}
|
||||
_this4.bodyOverflow = null;
|
||||
_this4.bodyPaddingRight = null;
|
||||
}, 200);
|
||||
}
|
||||
|
||||
this.opened = false;
|
||||
|
||||
if (!this.transition) {
|
||||
this.doAfterClose();
|
||||
}
|
||||
},
|
||||
doAfterClose: function doAfterClose() {
|
||||
_popupManager2.default.closeModal(this._popupId);
|
||||
this._closing = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.PopupManager = _popupManager2.default;
|
||||
179
static/element-ui/lib/utils/popup/popup-manager.js
Normal file
179
static/element-ui/lib/utils/popup/popup-manager.js
Normal file
@@ -0,0 +1,179 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
var _dom = require('element-ui/lib/utils/dom');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var hasModal = false;
|
||||
|
||||
var getModal = function getModal() {
|
||||
if (_vue2.default.prototype.$isServer) return;
|
||||
var modalDom = PopupManager.modalDom;
|
||||
if (modalDom) {
|
||||
hasModal = true;
|
||||
} else {
|
||||
hasModal = false;
|
||||
modalDom = document.createElement('div');
|
||||
PopupManager.modalDom = modalDom;
|
||||
|
||||
modalDom.addEventListener('touchmove', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
modalDom.addEventListener('click', function () {
|
||||
PopupManager.doOnModalClick && PopupManager.doOnModalClick();
|
||||
});
|
||||
}
|
||||
|
||||
return modalDom;
|
||||
};
|
||||
|
||||
var instances = {};
|
||||
|
||||
var PopupManager = {
|
||||
zIndex: 2000,
|
||||
|
||||
modalFade: true,
|
||||
|
||||
getInstance: function getInstance(id) {
|
||||
return instances[id];
|
||||
},
|
||||
|
||||
register: function register(id, instance) {
|
||||
if (id && instance) {
|
||||
instances[id] = instance;
|
||||
}
|
||||
},
|
||||
|
||||
deregister: function deregister(id) {
|
||||
if (id) {
|
||||
instances[id] = null;
|
||||
delete instances[id];
|
||||
}
|
||||
},
|
||||
|
||||
nextZIndex: function nextZIndex() {
|
||||
return PopupManager.zIndex++;
|
||||
},
|
||||
|
||||
modalStack: [],
|
||||
|
||||
doOnModalClick: function doOnModalClick() {
|
||||
var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
|
||||
if (!topItem) return;
|
||||
|
||||
var instance = PopupManager.getInstance(topItem.id);
|
||||
if (instance && instance.closeOnClickModal) {
|
||||
instance.close();
|
||||
}
|
||||
},
|
||||
|
||||
openModal: function openModal(id, zIndex, dom, modalClass, modalFade) {
|
||||
if (_vue2.default.prototype.$isServer) return;
|
||||
if (!id || zIndex === undefined) return;
|
||||
this.modalFade = modalFade;
|
||||
|
||||
var modalStack = this.modalStack;
|
||||
|
||||
for (var i = 0, j = modalStack.length; i < j; i++) {
|
||||
var item = modalStack[i];
|
||||
if (item.id === id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var modalDom = getModal();
|
||||
|
||||
(0, _dom.addClass)(modalDom, 'v-modal');
|
||||
if (this.modalFade && !hasModal) {
|
||||
(0, _dom.addClass)(modalDom, 'v-modal-enter');
|
||||
}
|
||||
if (modalClass) {
|
||||
var classArr = modalClass.trim().split(/\s+/);
|
||||
classArr.forEach(function (item) {
|
||||
return (0, _dom.addClass)(modalDom, item);
|
||||
});
|
||||
}
|
||||
setTimeout(function () {
|
||||
(0, _dom.removeClass)(modalDom, 'v-modal-enter');
|
||||
}, 200);
|
||||
|
||||
if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
|
||||
dom.parentNode.appendChild(modalDom);
|
||||
} else {
|
||||
document.body.appendChild(modalDom);
|
||||
}
|
||||
|
||||
if (zIndex) {
|
||||
modalDom.style.zIndex = zIndex;
|
||||
}
|
||||
modalDom.style.display = '';
|
||||
|
||||
this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass });
|
||||
},
|
||||
|
||||
closeModal: function closeModal(id) {
|
||||
var modalStack = this.modalStack;
|
||||
var modalDom = getModal();
|
||||
|
||||
if (modalStack.length > 0) {
|
||||
var topItem = modalStack[modalStack.length - 1];
|
||||
if (topItem.id === id) {
|
||||
if (topItem.modalClass) {
|
||||
var classArr = topItem.modalClass.trim().split(/\s+/);
|
||||
classArr.forEach(function (item) {
|
||||
return (0, _dom.removeClass)(modalDom, item);
|
||||
});
|
||||
}
|
||||
|
||||
modalStack.pop();
|
||||
if (modalStack.length > 0) {
|
||||
modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
|
||||
}
|
||||
} else {
|
||||
for (var i = modalStack.length - 1; i >= 0; i--) {
|
||||
if (modalStack[i].id === id) {
|
||||
modalStack.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modalStack.length === 0) {
|
||||
if (this.modalFade) {
|
||||
(0, _dom.addClass)(modalDom, 'v-modal-leave');
|
||||
}
|
||||
setTimeout(function () {
|
||||
if (modalStack.length === 0) {
|
||||
if (modalDom.parentNode) modalDom.parentNode.removeChild(modalDom);
|
||||
modalDom.style.display = 'none';
|
||||
PopupManager.modalDom = undefined;
|
||||
}
|
||||
(0, _dom.removeClass)(modalDom, 'v-modal-leave');
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
};
|
||||
!_vue2.default.prototype.$isServer && window.addEventListener('keydown', function (event) {
|
||||
if (event.keyCode === 27) {
|
||||
// ESC
|
||||
if (PopupManager.modalStack.length > 0) {
|
||||
var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
|
||||
if (!topItem) return;
|
||||
var instance = PopupManager.getInstance(topItem.id);
|
||||
if (instance.closeOnPressEscape) {
|
||||
instance.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = PopupManager;
|
||||
189
static/element-ui/lib/utils/resize-event.js
Normal file
189
static/element-ui/lib/utils/resize-event.js
Normal file
@@ -0,0 +1,189 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
/* Modified from https://github.com/sdecima/javascript-detect-element-resize
|
||||
* version: 0.5.3
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Sebastián Décima
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
var isServer = typeof window === 'undefined';
|
||||
|
||||
/* istanbul ignore next */
|
||||
var requestFrame = function () {
|
||||
if (isServer) return;
|
||||
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
|
||||
return window.setTimeout(fn, 20);
|
||||
};
|
||||
return function (fn) {
|
||||
return raf(fn);
|
||||
};
|
||||
}();
|
||||
|
||||
/* istanbul ignore next */
|
||||
var cancelFrame = function () {
|
||||
if (isServer) return;
|
||||
var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.clearTimeout;
|
||||
return function (id) {
|
||||
return cancel(id);
|
||||
};
|
||||
}();
|
||||
|
||||
/* istanbul ignore next */
|
||||
var resetTrigger = function resetTrigger(element) {
|
||||
var trigger = element.__resizeTrigger__;
|
||||
var expand = trigger.firstElementChild;
|
||||
var contract = trigger.lastElementChild;
|
||||
var expandChild = expand.firstElementChild;
|
||||
|
||||
contract.scrollLeft = contract.scrollWidth;
|
||||
contract.scrollTop = contract.scrollHeight;
|
||||
expandChild.style.width = expand.offsetWidth + 1 + 'px';
|
||||
expandChild.style.height = expand.offsetHeight + 1 + 'px';
|
||||
expand.scrollLeft = expand.scrollWidth;
|
||||
expand.scrollTop = expand.scrollHeight;
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var checkTriggers = function checkTriggers(element) {
|
||||
return element.offsetWidth !== element.__resizeLast__.width || element.offsetHeight !== element.__resizeLast__.height;
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var scrollListener = function scrollListener(event) {
|
||||
var _this = this;
|
||||
|
||||
resetTrigger(this);
|
||||
if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
|
||||
this.__resizeRAF__ = requestFrame(function () {
|
||||
if (checkTriggers(_this)) {
|
||||
_this.__resizeLast__.width = _this.offsetWidth;
|
||||
_this.__resizeLast__.height = _this.offsetHeight;
|
||||
_this.__resizeListeners__.forEach(function (fn) {
|
||||
fn.call(_this, event);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* Detect CSS Animations support to detect element display/re-attach */
|
||||
var attachEvent = isServer ? {} : document.attachEvent;
|
||||
var DOM_PREFIXES = 'Webkit Moz O ms'.split(' ');
|
||||
var START_EVENTS = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' ');
|
||||
var RESIZE_ANIMATION_NAME = 'resizeanim';
|
||||
var animation = false;
|
||||
var keyFramePrefix = '';
|
||||
var animationStartEvent = 'animationstart';
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (!attachEvent && !isServer) {
|
||||
var testElement = document.createElement('fakeelement');
|
||||
if (testElement.style.animationName !== undefined) {
|
||||
animation = true;
|
||||
}
|
||||
|
||||
if (animation === false) {
|
||||
var prefix = '';
|
||||
for (var i = 0; i < DOM_PREFIXES.length; i++) {
|
||||
if (testElement.style[DOM_PREFIXES[i] + 'AnimationName'] !== undefined) {
|
||||
prefix = DOM_PREFIXES[i];
|
||||
keyFramePrefix = '-' + prefix.toLowerCase() + '-';
|
||||
animationStartEvent = START_EVENTS[i];
|
||||
animation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var stylesCreated = false;
|
||||
/* istanbul ignore next */
|
||||
var createStyles = function createStyles() {
|
||||
if (!stylesCreated && !isServer) {
|
||||
var animationKeyframes = '@' + keyFramePrefix + 'keyframes ' + RESIZE_ANIMATION_NAME + ' { from { opacity: 0; } to { opacity: 0; } } ';
|
||||
var animationStyle = keyFramePrefix + 'animation: 1ms ' + RESIZE_ANIMATION_NAME + ';';
|
||||
|
||||
// opacity: 0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
|
||||
var css = animationKeyframes + '\n .resize-triggers { ' + animationStyle + ' visibility: hidden; opacity: 0; }\n .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; }\n .resize-triggers > div { background: #eee; overflow: auto; }\n .contract-trigger:before { width: 200%; height: 200%; }';
|
||||
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
var style = document.createElement('style');
|
||||
|
||||
style.type = 'text/css';
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = css;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(css));
|
||||
}
|
||||
|
||||
head.appendChild(style);
|
||||
stylesCreated = true;
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var addResizeListener = exports.addResizeListener = function addResizeListener(element, fn) {
|
||||
if (isServer) return;
|
||||
if (attachEvent) {
|
||||
element.attachEvent('onresize', fn);
|
||||
} else {
|
||||
if (!element.__resizeTrigger__) {
|
||||
if (getComputedStyle(element).position === 'static') {
|
||||
element.style.position = 'relative';
|
||||
}
|
||||
createStyles();
|
||||
element.__resizeLast__ = {};
|
||||
element.__resizeListeners__ = [];
|
||||
|
||||
var resizeTrigger = element.__resizeTrigger__ = document.createElement('div');
|
||||
resizeTrigger.className = 'resize-triggers';
|
||||
resizeTrigger.innerHTML = '<div class="expand-trigger"><div></div></div><div class="contract-trigger"></div>';
|
||||
element.appendChild(resizeTrigger);
|
||||
|
||||
resetTrigger(element);
|
||||
element.addEventListener('scroll', scrollListener, true);
|
||||
|
||||
/* Listen for a css animation to detect element display/re-attach */
|
||||
if (animationStartEvent) {
|
||||
resizeTrigger.addEventListener(animationStartEvent, function (event) {
|
||||
if (event.animationName === RESIZE_ANIMATION_NAME) {
|
||||
resetTrigger(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
element.__resizeListeners__.push(fn);
|
||||
}
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
var removeResizeListener = exports.removeResizeListener = function removeResizeListener(element, fn) {
|
||||
if (attachEvent) {
|
||||
element.detachEvent('onresize', fn);
|
||||
} else {
|
||||
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
|
||||
if (!element.__resizeListeners__.length) {
|
||||
element.removeEventListener('scroll', scrollListener);
|
||||
element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__);
|
||||
}
|
||||
}
|
||||
};
|
||||
38
static/element-ui/lib/utils/scrollbar-width.js
Normal file
38
static/element-ui/lib/utils/scrollbar-width.js
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
exports.default = function () {
|
||||
if (_vue2.default.prototype.$isServer) return 0;
|
||||
if (scrollBarWidth !== undefined) return scrollBarWidth;
|
||||
|
||||
var outer = document.createElement('div');
|
||||
outer.className = 'el-scrollbar__wrap';
|
||||
outer.style.visibility = 'hidden';
|
||||
outer.style.width = '100px';
|
||||
outer.style.position = 'absolute';
|
||||
outer.style.top = '-9999px';
|
||||
document.body.appendChild(outer);
|
||||
|
||||
var widthNoScroll = outer.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
|
||||
var inner = document.createElement('div');
|
||||
inner.style.width = '100%';
|
||||
outer.appendChild(inner);
|
||||
|
||||
var widthWithScroll = inner.offsetWidth;
|
||||
outer.parentNode.removeChild(outer);
|
||||
|
||||
return widthNoScroll - widthWithScroll;
|
||||
};
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var scrollBarWidth = void 0;
|
||||
|
||||
;
|
||||
59
static/element-ui/lib/utils/sync.js
Normal file
59
static/element-ui/lib/utils/sync.js
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
var SYNC_HOOK_PROP = '$v-sync';
|
||||
|
||||
/**
|
||||
* v-sync directive
|
||||
*
|
||||
* Usage:
|
||||
* v-sync:component-prop="context prop name"
|
||||
*
|
||||
* If your want to sync component's prop "visible" to context prop "myVisible", use like this:
|
||||
* v-sync:visible="myVisible"
|
||||
*/
|
||||
exports.default = {
|
||||
bind: function bind(el, binding, vnode) {
|
||||
var context = vnode.context;
|
||||
var component = vnode.child;
|
||||
var expression = binding.expression;
|
||||
var prop = binding.arg;
|
||||
|
||||
if (!expression || !prop) {
|
||||
console.warn('v-sync should specify arg & expression, for example: v-sync:visible="myVisible"');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component || !component.$watch) {
|
||||
console.warn('v-sync is only available on Vue Component');
|
||||
return;
|
||||
}
|
||||
|
||||
var unwatchContext = context.$watch(expression, function (val) {
|
||||
component[prop] = val;
|
||||
});
|
||||
|
||||
var unwatchComponent = component.$watch(prop, function (val) {
|
||||
context[expression] = val;
|
||||
});
|
||||
|
||||
Object.defineProperty(component, SYNC_HOOK_PROP, {
|
||||
value: {
|
||||
unwatchContext: unwatchContext,
|
||||
unwatchComponent: unwatchComponent
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
},
|
||||
unbind: function unbind(el, binding, vnode) {
|
||||
var component = vnode.child;
|
||||
if (component && component[SYNC_HOOK_PROP]) {
|
||||
var _component$SYNC_HOOK_ = component[SYNC_HOOK_PROP],
|
||||
unwatchContext = _component$SYNC_HOOK_.unwatchContext,
|
||||
unwatchComponent = _component$SYNC_HOOK_.unwatchComponent;
|
||||
|
||||
unwatchContext && unwatchContext();
|
||||
unwatchComponent && unwatchComponent();
|
||||
}
|
||||
}
|
||||
};
|
||||
26
static/element-ui/lib/utils/util.js
Normal file
26
static/element-ui/lib/utils/util.js
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.hasOwn = hasOwn;
|
||||
exports.toObject = toObject;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function hasOwn(obj, key) {
|
||||
return hasOwnProperty.call(obj, key);
|
||||
};
|
||||
|
||||
function extend(to, _from) {
|
||||
for (var key in _from) {
|
||||
to[key] = _from[key];
|
||||
}
|
||||
return to;
|
||||
};
|
||||
|
||||
function toObject(arr) {
|
||||
var res = {};
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (arr[i]) {
|
||||
extend(res, arr[i]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
20
static/element-ui/lib/utils/vdom.js
Normal file
20
static/element-ui/lib/utils/vdom.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = 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; };
|
||||
|
||||
exports.isVNode = isVNode;
|
||||
exports.getFirstComponentChild = getFirstComponentChild;
|
||||
|
||||
var _util = require('element-ui/lib/utils/util');
|
||||
|
||||
function isVNode(node) {
|
||||
return (typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object' && (0, _util.hasOwn)(node, 'componentOptions');
|
||||
};
|
||||
|
||||
function getFirstComponentChild(children) {
|
||||
return children && children.filter(function (c) {
|
||||
return c && c.tag;
|
||||
})[0];
|
||||
};
|
||||
184
static/element-ui/lib/utils/vue-popper.js
Normal file
184
static/element-ui/lib/utils/vue-popper.js
Normal file
@@ -0,0 +1,184 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _vue = require('vue');
|
||||
|
||||
var _vue2 = _interopRequireDefault(_vue);
|
||||
|
||||
var _popup = require('element-ui/lib/utils/popup');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var PopperJS = _vue2.default.prototype.$isServer ? function () {} : require('./popper');
|
||||
var stop = function stop(e) {
|
||||
return e.stopPropagation();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} [reference=$refs.reference] - The reference element used to position the popper.
|
||||
* @param {HTMLElement} [popper=$refs.popper] - The HTML element used as popper, or a configuration used to generate the popper.
|
||||
* @param {String} [placement=button] - Placement of the popper accepted values: top(-start, -end), right(-start, -end), bottom(-start, -end), left(-start, -end)
|
||||
* @param {Number} [offset=0] - Amount of pixels the popper will be shifted (can be negative).
|
||||
* @param {Boolean} [visible=false] Visibility of the popup element.
|
||||
* @param {Boolean} [visible-arrow=false] Visibility of the arrow, no style.
|
||||
*/
|
||||
exports.default = {
|
||||
props: {
|
||||
placement: {
|
||||
type: String,
|
||||
default: 'bottom'
|
||||
},
|
||||
boundariesPadding: {
|
||||
type: Number,
|
||||
default: 5
|
||||
},
|
||||
reference: {},
|
||||
popper: {},
|
||||
offset: {
|
||||
default: 0
|
||||
},
|
||||
value: Boolean,
|
||||
visibleArrow: Boolean,
|
||||
transition: String,
|
||||
appendToBody: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
popperOptions: {
|
||||
type: Object,
|
||||
default: function _default() {
|
||||
return {
|
||||
gpuAcceleration: false
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data: function data() {
|
||||
return {
|
||||
showPopper: false,
|
||||
currentPlacement: ''
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
watch: {
|
||||
value: {
|
||||
immediate: true,
|
||||
handler: function handler(val) {
|
||||
this.showPopper = val;
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
|
||||
showPopper: function showPopper(val) {
|
||||
val ? this.updatePopper() : this.destroyPopper();
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
createPopper: function createPopper() {
|
||||
var _this = this;
|
||||
|
||||
if (this.$isServer) return;
|
||||
this.currentPlacement = this.currentPlacement || this.placement;
|
||||
if (!/^(top|bottom|left|right)(-start|-end)?$/g.test(this.currentPlacement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var options = this.popperOptions;
|
||||
var popper = this.popperElm = this.popperElm || this.popper || this.$refs.popper;
|
||||
var reference = this.referenceElm = this.referenceElm || this.reference || this.$refs.reference;
|
||||
|
||||
if (!reference && this.$slots.reference && this.$slots.reference[0]) {
|
||||
reference = this.referenceElm = this.$slots.reference[0].elm;
|
||||
}
|
||||
|
||||
if (!popper || !reference) return;
|
||||
if (this.visibleArrow) this.appendArrow(popper);
|
||||
if (this.appendToBody) document.body.appendChild(this.popperElm);
|
||||
if (this.popperJS && this.popperJS.destroy) {
|
||||
this.popperJS.destroy();
|
||||
}
|
||||
|
||||
options.placement = this.currentPlacement;
|
||||
options.offset = this.offset;
|
||||
this.popperJS = new PopperJS(reference, popper, options);
|
||||
this.popperJS.onCreate(function (_) {
|
||||
_this.$emit('created', _this);
|
||||
_this.resetTransformOrigin();
|
||||
_this.$nextTick(_this.updatePopper);
|
||||
});
|
||||
if (typeof options.onUpdate === 'function') {
|
||||
this.popperJS.onUpdate(options.onUpdate);
|
||||
}
|
||||
this.popperJS._popper.style.zIndex = _popup.PopupManager.nextZIndex();
|
||||
this.popperElm.addEventListener('click', stop);
|
||||
},
|
||||
updatePopper: function updatePopper() {
|
||||
this.popperJS ? this.popperJS.update() : this.createPopper();
|
||||
},
|
||||
doDestroy: function doDestroy() {
|
||||
/* istanbul ignore if */
|
||||
if (this.showPopper || !this.popperJS) return;
|
||||
this.popperJS.destroy();
|
||||
this.popperJS = null;
|
||||
},
|
||||
destroyPopper: function destroyPopper() {
|
||||
if (this.popperJS) {
|
||||
this.resetTransformOrigin();
|
||||
}
|
||||
},
|
||||
resetTransformOrigin: function resetTransformOrigin() {
|
||||
var placementMap = {
|
||||
top: 'bottom',
|
||||
bottom: 'top',
|
||||
left: 'right',
|
||||
right: 'left'
|
||||
};
|
||||
var placement = this.popperJS._popper.getAttribute('x-placement').split('-')[0];
|
||||
var origin = placementMap[placement];
|
||||
this.popperJS._popper.style.transformOrigin = ['top', 'bottom'].indexOf(placement) > -1 ? 'center ' + origin : origin + ' center';
|
||||
},
|
||||
appendArrow: function appendArrow(element) {
|
||||
var hash = void 0;
|
||||
if (this.appended) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.appended = true;
|
||||
|
||||
for (var item in element.attributes) {
|
||||
if (/^_v-/.test(element.attributes[item].name)) {
|
||||
hash = element.attributes[item].name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var arrow = document.createElement('div');
|
||||
|
||||
if (hash) {
|
||||
arrow.setAttribute(hash, '');
|
||||
}
|
||||
arrow.setAttribute('x-arrow', '');
|
||||
arrow.className = 'popper__arrow';
|
||||
element.appendChild(arrow);
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy: function beforeDestroy() {
|
||||
this.doDestroy();
|
||||
if (this.popperElm && this.popperElm.parentNode === document.body) {
|
||||
this.popperElm.removeEventListener('click', stop);
|
||||
document.body.removeChild(this.popperElm);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// call destroy in keep-alive mode
|
||||
deactivated: function deactivated() {
|
||||
this.$options.beforeDestroy[0].call(this);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user