summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Bartelmeß <mba@fourplusone.de>2012-04-05 15:22:22 +0200
committerMatthias Bartelmeß <mba@fourplusone.de>2012-04-05 15:22:22 +0200
commit5833cb1037c6e52fb2537765acc4014c6feb6a09 (patch)
tree3c5686fa6f0ce0dccf268cfa4ab43471048366b0 /src
parent093b7ab4bfd20ff1d276bd194bbad7ba51d022d7 (diff)
downloadetherpad-lite-5833cb1037c6e52fb2537765acc4014c6feb6a09.zip
renamed performDocumentApplyAttributesToRange to setAttributesOnRange and moved it to AttributeManager
Diffstat (limited to 'src')
-rw-r--r--src/static/js/AttributeManager.js14
-rw-r--r--src/static/js/ace2_inner.js22
2 files changed, 19 insertions, 17 deletions
diff --git a/src/static/js/AttributeManager.js b/src/static/js/AttributeManager.js
index 3ea2b6da..2f40c4f4 100644
--- a/src/static/js/AttributeManager.js
+++ b/src/static/js/AttributeManager.js
@@ -43,6 +43,20 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({
return changeset;
},
+ /*
+ Sets attributes on a range
+ @param start [row, col] tuple pointing to the start of the range
+ @param end [row, col] tuple pointing to the end of the range
+ @param attribute: an array of attributes
+ */
+ setAttributesOnRange: function(start, end, attribs)
+ {
+ var builder = Changeset.builder(rep.lines.totalWidth());
+ ChangesetUtils.buildKeepToStartOfRange(rep, builder, start);
+ ChangesetUtils.buildKeepRange(this.rep, builder, start, end, attribs, this.rep.apool);
+ return this.applyChangeset(builder);
+ },
+
/*
Returns if the line already has a line marker
@param lineNum: the number of the line
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index c89ed700..e57ee15f 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -2276,25 +2276,13 @@ function Ace2Inner(){
performDocumentApplyAttributesToRange(lineAndColumnFromChar(start), lineAndColumnFromChar(end), attribs);
}
editorInfo.ace_performDocumentApplyAttributesToCharRange = performDocumentApplyAttributesToCharRange;
-
- function performDocumentApplyAttributesToRange(start, end, attribs)
- {
- var builder = Changeset.builder(rep.lines.totalWidth());
- ChangesetUtils.buildKeepToStartOfRange(rep, builder, start);
- ChangesetUtils.buildKeepRange(rep, builder, start, end, attribs, rep.apool);
- var cs = builder.toString();
- performDocumentApplyChangeset(cs);
- }
- editorInfo.ace_performDocumentApplyAttributesToRange = performDocumentApplyAttributesToRange;
-
-
- // TODO move to AttributeManager
+
function setAttributeOnSelection(attributeName, attributeValue)
{
if (!(rep.selStart && rep.selEnd)) return;
- performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
+ documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
[attributeName, attributeValue]
]);
}
@@ -2355,13 +2343,13 @@ function Ace2Inner(){
if (selectionAllHasIt)
{
- performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
+ documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
[attributeName, '']
]);
}
else
{
- performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
+ documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
[attributeName, 'true']
]);
}
@@ -5400,8 +5388,8 @@ function Ace2Inner(){
// Init documentAttributeManager
-
documentAttributeManager = new AttributeManager(rep, performDocumentApplyChangeset);
+ editorInfo.ace_performDocumentApplyAttributesToRange = documentAttributeManager.setAttributesOnRange;
$(document).ready(function(){
doc = document; // defined as a var in scope outside