Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xCss committed Aug 29, 2019
1 parent 01211c0 commit 2529c49
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions dist/Valine.Pure.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/Valine.min.js

Large diffs are not rendered by default.

28 changes: 9 additions & 19 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,8 @@ ValineFactory.prototype.ErrorHandler = function (ex) {
let code = ex.code || '',
t = root.locale['error'][code],
msg = t || ex.message || ex.error || '';
if (code == 101) {
root.nodata.show()
} else root.el && root.nodata.show(`<pre style="text-align:left;">Code ${code}: ${msg}</pre>`) ||
if (code == 101) root.nodata.show()
else root.el && root.nodata.show(`<pre style="text-align:left;">Code ${code}: ${msg}</pre>`) ||
console && console.error(`Code ${code}: ${msg}`)
} else {
root.el && root.nodata.show(`<pre style="text-align:left;">${JSON.stringify(ex)}</pre>`) ||
Expand Down Expand Up @@ -610,20 +609,14 @@ ValineFactory.prototype.bind = function (option) {
// 显示/隐藏 Emojis
Utils.on('click', _emojiCtrl, (e) => {
let _vi = Utils.attr(_emojiCtrl, 'v');
if (_vi) {
root.emoji.hide()
} else {
root.emoji.show();
}
if (_vi) root.emoji.hide()
else root.emoji.show();
});

Utils.on('click', _vpreviewCtrl, function (e) {
let _vi = Utils.attr(_vpreviewCtrl, 'v');
if (_vi) {
root.preview.hide();
} else {
root.preview.show();
}
if (_vi) root.preview.hide();
else root.preview.show();
});

let meta = root.config.meta;
Expand All @@ -642,11 +635,8 @@ ValineFactory.prototype.bind = function (option) {
let _el = Utils.find(root.el, `.${i}`);
inputs[_v] = _el;
_el && Utils.on('input change blur', _el, (e) => {
if (_v === 'comment') {
syncContentEvt(_el)
} else {
defaultComment[_v] = Utils.escape(_el.value.replace(/(^\s*)|(\s*$)/g, ""));
}
if (_v === 'comment') syncContentEvt(_el)
else defaultComment[_v] = Utils.escape(_el.value.replace(/(^\s*)|(\s*$)/g, ""));
});
}
}
Expand Down Expand Up @@ -800,7 +790,7 @@ ValineFactory.prototype.bind = function (option) {
} catch (error) {

}
}, 20)
}, 200)
}

let _activeHLJS = () => {}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/deepClone.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function isCyclic (data) {
seenObjects.push(data);

// Begin iterating through the data passed to the method
for (var key in data) {
for (let key in data) {
// Recall this method with the objects key
if (data.hasOwnProperty(key) === true && detect(data[key])) {
return true;
Expand Down Expand Up @@ -75,7 +75,7 @@ const deepClone = function (data) {
// Create a new array that will have no references to the one we want to copy
let copiedArray = [];
// Iterate over the arrays elements
for (var i = 0; i < data.length; i++) {
for (let i = 0; i < data.length; i++) {
// Push the arrays elements to this new array
// First recall this method with the elements
// This is so arrays of objects and other nested data structures get correctly cloned.
Expand Down
12 changes: 6 additions & 6 deletions src/utils/domUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ const utils = {
/**
* 动态加载资源库
* @param {String} sourceName 资源名 script/link
* @param {String} sourceURI 需要加载的资源库链接
* @param {Object} attrs 需要加载属性/值
* @param {Function} callback 回调函数
*/
dynamicLoadSource(sourceName, sourceURI, callback) {
dynamicLoadSource(sourceName, attrs, callback) {
let attrNameMap = {'script':'src','link':'href'};
let attr = attrNameMap[sourceName]
if (utils.find(doc, `${sourceName}[${attr}="${sourceURI}"]`)) {
let attr = attrNameMap[sourceName];
if (utils.find(doc, `${sourceName}[${attr}="${attrs[attr]}"]`)) {
typeof (callback) === 'function' && callback()
} else {
let s = utils.create(sourceName, attr, sourceURI);
let s = utils.create(sourceName, attrs);
let h = doc.getElementsByTagName("head")[0];
h.appendChild(s);
s.onload = s.onreadystatechange = function () {
Expand Down Expand Up @@ -192,7 +192,7 @@ const utils = {
if (el.nodeName == 'CODE') return false
let clazz = attr.value
if (clazz.indexOf('at') > -1) utils.attr(el, 'class', 'at');
if (clazz.indexOf('vemoji') > -1) utils.attr(el,'class','vemoji');
else if (clazz.indexOf('vemoji') > -1) utils.attr(el,'class','vemoji');
else utils.removeAttr(el, 'class')
break;
default:
Expand Down

0 comments on commit 2529c49

Please sign in to comment.