Fixes #24 - Expose oneClickSelect
This commit is contained in:
parent
f70d94ea67
commit
7dcc72d5a0
52
public/assets/scaffolding-min.js
vendored
52
public/assets/scaffolding-min.js
vendored
@ -75,22 +75,23 @@ var showMessage = function showMessage(m, s) {
|
|||||||
status.remove();
|
status.remove();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
var oneClickSelect = function oneClickSelect(e) {
|
|
||||||
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.currentTarget;
|
// const oneClickSelect = (e, t = e.currentTarget) => {
|
||||||
// In here, "this" is the element
|
// // In here, "this" is the element
|
||||||
var range, selection;
|
// var range, selection;
|
||||||
if (window.getSelection) {
|
// if (window.getSelection) {
|
||||||
selection = window.getSelection();
|
// selection = window.getSelection();
|
||||||
range = document.createRange();
|
// range = document.createRange();
|
||||||
range.selectNodeContents(t);
|
// range.selectNodeContents(t);
|
||||||
selection.removeAllRanges();
|
// selection.removeAllRanges();
|
||||||
selection.addRange(range);
|
// selection.addRange(range);
|
||||||
} else if (document.body.createTextRange) {
|
// } else if (document.body.createTextRange) {
|
||||||
range = document.body.createTextRange();
|
// range = document.body.createTextRange();
|
||||||
range.moveToElementText(t);
|
// range.moveToElementText(t);
|
||||||
range.select();
|
// range.select();
|
||||||
}
|
// }
|
||||||
};
|
// }
|
||||||
|
|
||||||
var getURLVars = function getURLVars() {
|
var getURLVars = function getURLVars() {
|
||||||
var oResult = {};
|
var oResult = {};
|
||||||
if (location.search.length > 0) {
|
if (location.search.length > 0) {
|
||||||
@ -148,6 +149,23 @@ module.exports = {
|
|||||||
module.exports.cookie.set(cname, "", -1);
|
module.exports.cookie.set(cname, "", -1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
oneClickSelect: function oneClickSelect(e) {
|
||||||
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.currentTarget;
|
||||||
|
// In here, "this" is the element
|
||||||
|
alert("here");
|
||||||
|
var range, selection;
|
||||||
|
if (window.getSelection) {
|
||||||
|
selection = window.getSelection();
|
||||||
|
range = document.createRange();
|
||||||
|
range.selectNodeContents(t);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
} else if (document.body.createTextRange) {
|
||||||
|
range = document.body.createTextRange();
|
||||||
|
range.moveToElementText(t);
|
||||||
|
range.select();
|
||||||
|
}
|
||||||
|
},
|
||||||
colour: {
|
colour: {
|
||||||
copy: function copy(w, t) {
|
copy: function copy(w, t) {
|
||||||
var c = t.parentNode.getAttribute("data-" + (w == "var" ? "token" : w));
|
var c = t.parentNode.getAttribute("data-" + (w == "var" ? "token" : w));
|
||||||
@ -243,7 +261,7 @@ module.exports = {
|
|||||||
Prism.highlightAll();
|
Prism.highlightAll();
|
||||||
a.querySelectorAll("code").forEach(function (c) {
|
a.querySelectorAll("code").forEach(function (c) {
|
||||||
c.onclick = function (e) {
|
c.onclick = function (e) {
|
||||||
oneClickSelect(e);
|
module.exports.oneClickSelect(e);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
module.exports.colour.positionTooltip();
|
module.exports.colour.positionTooltip();
|
||||||
|
@ -71,21 +71,21 @@ const showMessage = (m, s) => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const oneClickSelect = (e, t = e.currentTarget) => {
|
// const oneClickSelect = (e, t = e.currentTarget) => {
|
||||||
// In here, "this" is the element
|
// // In here, "this" is the element
|
||||||
var range, selection;
|
// var range, selection;
|
||||||
if (window.getSelection) {
|
// if (window.getSelection) {
|
||||||
selection = window.getSelection();
|
// selection = window.getSelection();
|
||||||
range = document.createRange();
|
// range = document.createRange();
|
||||||
range.selectNodeContents(t);
|
// range.selectNodeContents(t);
|
||||||
selection.removeAllRanges();
|
// selection.removeAllRanges();
|
||||||
selection.addRange(range);
|
// selection.addRange(range);
|
||||||
} else if (document.body.createTextRange) {
|
// } else if (document.body.createTextRange) {
|
||||||
range = document.body.createTextRange();
|
// range = document.body.createTextRange();
|
||||||
range.moveToElementText(t);
|
// range.moveToElementText(t);
|
||||||
range.select();
|
// range.select();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
const getURLVars = () => {
|
const getURLVars = () => {
|
||||||
var oResult = {};
|
var oResult = {};
|
||||||
@ -149,8 +149,23 @@ module.exports = {
|
|||||||
module.exports.cookie.set(cname, "", -1);
|
module.exports.cookie.set(cname, "", -1);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
oneClickSelect: (e, t = e.currentTarget) => {
|
||||||
|
// In here, "this" is the element
|
||||||
|
alert("here");
|
||||||
|
var range, selection;
|
||||||
|
if (window.getSelection) {
|
||||||
|
selection = window.getSelection();
|
||||||
|
range = document.createRange();
|
||||||
|
range.selectNodeContents(t);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
} else if (document.body.createTextRange) {
|
||||||
|
range = document.body.createTextRange();
|
||||||
|
range.moveToElementText(t);
|
||||||
|
range.select();
|
||||||
|
}
|
||||||
|
},
|
||||||
colour: {
|
colour: {
|
||||||
|
|
||||||
copy: (w, t) => {
|
copy: (w, t) => {
|
||||||
let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w));
|
let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w));
|
||||||
c = w == "var" ? `var(${c})` : c;
|
c = w == "var" ? `var(${c})` : c;
|
||||||
@ -255,7 +270,7 @@ module.exports = {
|
|||||||
|
|
||||||
a.querySelectorAll("code").forEach((c)=> {
|
a.querySelectorAll("code").forEach((c)=> {
|
||||||
c.onclick = (e) => {
|
c.onclick = (e) => {
|
||||||
oneClickSelect(e);
|
module.exports.oneClickSelect(e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user