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();
|
||||
}, 1000);
|
||||
};
|
||||
var oneClickSelect = function oneClickSelect(e) {
|
||||
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.currentTarget;
|
||||
// In here, "this" is the element
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
// const oneClickSelect = (e, t = e.currentTarget) => {
|
||||
// // In here, "this" is the element
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
|
||||
var getURLVars = function getURLVars() {
|
||||
var oResult = {};
|
||||
if (location.search.length > 0) {
|
||||
@ -148,6 +149,23 @@ module.exports = {
|
||||
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: {
|
||||
copy: function copy(w, t) {
|
||||
var c = t.parentNode.getAttribute("data-" + (w == "var" ? "token" : w));
|
||||
@ -243,7 +261,7 @@ module.exports = {
|
||||
Prism.highlightAll();
|
||||
a.querySelectorAll("code").forEach(function (c) {
|
||||
c.onclick = function (e) {
|
||||
oneClickSelect(e);
|
||||
module.exports.oneClickSelect(e);
|
||||
};
|
||||
});
|
||||
module.exports.colour.positionTooltip();
|
||||
|
@ -71,21 +71,21 @@ const showMessage = (m, s) => {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
const oneClickSelect = (e, t = e.currentTarget) => {
|
||||
// In here, "this" is the element
|
||||
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();
|
||||
}
|
||||
}
|
||||
// const oneClickSelect = (e, t = e.currentTarget) => {
|
||||
// // In here, "this" is the element
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
|
||||
const getURLVars = () => {
|
||||
var oResult = {};
|
||||
@ -149,8 +149,23 @@ module.exports = {
|
||||
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: {
|
||||
|
||||
copy: (w, t) => {
|
||||
let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w));
|
||||
c = w == "var" ? `var(${c})` : c;
|
||||
@ -255,7 +270,7 @@ module.exports = {
|
||||
|
||||
a.querySelectorAll("code").forEach((c)=> {
|
||||
c.onclick = (e) => {
|
||||
oneClickSelect(e);
|
||||
module.exports.oneClickSelect(e);
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user