Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/TextAreaUtils.js
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | setSelectionText : function(area, text, select) { | ||||
if (!select) { | if (!select) { | ||||
start = end; | start = end; | ||||
} | } | ||||
JX.TextAreaUtils.setSelectionRange(area, start, end); | JX.TextAreaUtils.setSelectionRange(area, start, end); | ||||
}, | }, | ||||
/** | |||||
* Insert a reference to a given uploaded file into a textarea. | |||||
*/ | |||||
insertFileReference: function(area, file) { | |||||
var ref = '{F' + file.getID() + '}'; | |||||
// If we're inserting immediately after a "}" (usually, another file | |||||
// reference), put some newlines before our token so that multiple file | |||||
// uploads get laid out more nicely. | |||||
var range = JX.TextAreaUtils.getSelectionRange(area); | |||||
var before = area.value.substring(0, range.start); | |||||
if (before.match(/\}$/)) { | |||||
ref = '\n\n' + ref; | |||||
} | |||||
JX.TextAreaUtils.setSelectionText(area, ref, false); | |||||
}, | |||||
/** | /** | ||||
* Get the document pixel positions of the beginning and end of a character | * Get the document pixel positions of the beginning and end of a character | ||||
* range in a textarea. | * range in a textarea. | ||||
*/ | */ | ||||
getPixelDimensions: function(area, start, end) { | getPixelDimensions: function(area, start, end) { | ||||
var v = area.value; | var v = area.value; | ||||
// We're using zero-width spaces to make sure the spans get some | // We're using zero-width spaces to make sure the spans get some | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |