From 42062ddcb82f2d372faafbe7bb1f9a27436f0bbd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 19 Feb 2014 13:02:16 +0100 Subject: [PATCH] editor: additional descriptions for some transactions --- .../modules/documentCanvas/canvas/keyboard.js | 14 +++++++++----- src/editor/modules/nodePane/nodePane.js | 13 ++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/editor/modules/documentCanvas/canvas/keyboard.js b/src/editor/modules/documentCanvas/canvas/keyboard.js index 383ca18..9be3dae 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -4,7 +4,7 @@ define([ ], function(documentElement, utils) { 'use strict'; - +/* globals gettext */ var KEYS = { ENTER: 13, @@ -50,7 +50,7 @@ handlers.push({key: KEYS.ENTER, if(Object.keys(cursor.getPosition()).length === 0) { var currentElement = canvas.getCurrentNodeElement(); if(currentElement) { - canvas.wlxmlDocument.startTransaction(); + canvas.wlxmlDocument.startTransaction(gettext('Splitting text')); added = currentElement.wlxmlNode.after({ tagName: currentElement.getWlxmlTag() || 'div', attrs: {'class': currentElement.getWlxmlClass() || 'p'} @@ -68,7 +68,7 @@ handlers.push({key: KEYS.ENTER, element = element.parent(); } - canvas.wlxmlDocument.startTransaction(); + canvas.wlxmlDocument.startTransaction(gettext('Splitting text')); added = element.wlxmlNode.after( {tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}} ); @@ -100,9 +100,13 @@ handlers.push({key: KEYS.ENTER, // goto = nodes.second; // gotoOptions = {caretTo: 'start'}; // } + var node = position.element.wlxmlNode, + result, goto, gotoOptions; + + node.document.transaction(function() { + result = position.element.wlxmlNode.breakContent({offset: position.offset}); + }, this, gettext('Splitting text')); - var result = position.element.wlxmlNode.breakContent({offset: position.offset}), - goto, gotoOptions; if(result.emptyText) { goto = result.emptyText; gotoOptions = {}; diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js index 85a6fdd..25e5ddb 100644 --- a/src/editor/modules/nodePane/nodePane.js +++ b/src/editor/modules/nodePane/nodePane.js @@ -12,13 +12,20 @@ return function(sandbox) { var view = $(_.template(templateSrc)({utils: wlxmlUtils})), listens = false, - currentNode; + currentNode, + msgs = { + Tag: gettext('Tag editing'), + Class: gettext('Class editing') + }; view.on('change', 'select', function(e) { var target = $(e.target); var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'Tag' : 'Class', - value = target.val().replace(/-/g, '.'); - currentNode['set' + attr](value); + value = target.val().replace(/-/g, '.'), + oldValue = attr === 'Tag' ? currentNode.getTagName() : currentNode.getClass(); + currentNode.document.transaction(function() { + currentNode['set' + attr](value); + }, this, msgs[attr] + ': ' + oldValue + ' -> ' + value); }); -- 2.20.1