Update to latest pullbox branch

Noticable changes:
* focus returns to canvas after paragraph style selection
This commit is contained in:
Friedrich W. H. Kossebau 2013-09-17 17:04:22 +02:00
parent 70ad7f824b
commit ff5c0ec6ff
10 changed files with 479 additions and 456 deletions

View File

@ -17,7 +17,7 @@ html, body, #mainContainer {
#editor { #editor {
border: none; border: none;
box-shadow: 0px 0px 14px black; box-shadow: 0px 0px 14px #555;
overflow: hidden; overflow: hidden;
padding: 0px !important; padding: 0px !important;
z-index: 4; z-index: 4;
@ -29,8 +29,9 @@ html, body, #mainContainer {
#container { #container {
text-align: center; text-align: center;
background-color: #FAFAFA; background-color: #ddd;
overflow: auto; overflow: auto;
position: absolute; position: absolute;
top: 30px; top: 30px;
bottom: 0; bottom: 0;

View File

@ -172,16 +172,11 @@
padding-top: 3em !important; padding-top: 3em !important;
} }
#editor {
box-shadow: 0px 0px 14px #555 !important;
}
#toolbar { #toolbar {
border-bottom: none !important; border-bottom: none !important;
padding: 6px 0 !important; padding: 6px 0 !important;
} }
#container { #container {
background-color: #ddd !important;
top: 38px !important; top: 38px !important;
} }

View File

@ -285,6 +285,12 @@ define("webodf/editor/Editor", [
}); });
}; };
function setFocusToOdfCanvas() {
if (odfCanvas) {
odfCanvas.getElement().focus();
}
}
// init // init
function init() { function init() {
var editorPane, memberListPane, var editorPane, memberListPane,
@ -363,6 +369,7 @@ define("webodf/editor/Editor", [
} }
tools = new Tools({ tools = new Tools({
onToolDone: setFocusToOdfCanvas,
loadOdtFile: loadOdtFile, loadOdtFile: loadOdtFile,
saveOdtFile: saveOdtFile, saveOdtFile: saveOdtFile,
close: close, close: close,

View File

@ -114,11 +114,6 @@ define("webodf/editor/MemberListView",
} }
}; };
memberListDiv.appendChild(avatarDiv); memberListDiv.appendChild(avatarDiv);
// preset bogus data
// TODO: indicate loading state
// (instead of setting the final 'unknown identity' data)
updateAvatarButton(memberId, null);
} }
/** /**

View File

@ -52,6 +52,7 @@ define("webodf/editor/Tools", [
return function Tools(args) { return function Tools(args) {
var translator = document.translator, var translator = document.translator,
onToolDone = args.onToolDone,
loadOdtFile = args.loadOdtFile, loadOdtFile = args.loadOdtFile,
saveOdtFile = args.saveOdtFile, saveOdtFile = args.saveOdtFile,
close = args.close, close = args.close,
@ -106,6 +107,7 @@ define("webodf/editor/Tools", [
onClick: function () { onClick: function () {
if (editorSession) { if (editorSession) {
editorSession.addAnnotation(); editorSession.addAnnotation();
onToolDone();
} }
} }
}); });
@ -114,7 +116,7 @@ define("webodf/editor/Tools", [
// Simple Style Selector [B, I, U, S] // Simple Style Selector [B, I, U, S]
if (args.directStylingEnabled) { if (args.directStylingEnabled) {
simpleStyles = new SimpleStyles(function (widget) { simpleStyles = new SimpleStyles(onToolDone, function (widget) {
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
@ -123,7 +125,7 @@ define("webodf/editor/Tools", [
// Paragraph direct alignment buttons // Paragraph direct alignment buttons
if (args.directStylingEnabled) { if (args.directStylingEnabled) {
paragraphAlignment = new ParagraphAlignment(function (widget) { paragraphAlignment = new ParagraphAlignment(onToolDone, function (widget) {
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
@ -132,7 +134,7 @@ define("webodf/editor/Tools", [
// Paragraph Style Selector // Paragraph Style Selector
currentStyle = new CurrentStyle(function (widget) { currentStyle = new CurrentStyle(onToolDone, function (widget) {
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });

View File

@ -42,7 +42,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
function (ToggleButton, Button) { function (ToggleButton, Button) {
"use strict"; "use strict";
var ParagraphAlignment = function (callback) { var ParagraphAlignment = function (onToolDone, callback) {
var widget = {}, var widget = {},
directParagraphStyler, directParagraphStyler,
justifyLeft, justifyLeft,
@ -60,6 +60,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft", iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft",
onChange: function () { onChange: function () {
directParagraphStyler.alignParagraphLeft(); directParagraphStyler.alignParagraphLeft();
onToolDone();
} }
}); });
@ -71,6 +72,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter", iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter",
onChange: function () { onChange: function () {
directParagraphStyler.alignParagraphCenter(); directParagraphStyler.alignParagraphCenter();
onToolDone();
} }
}); });
@ -82,6 +84,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconJustifyRight", iconClass: "dijitEditorIcon dijitEditorIconJustifyRight",
onChange: function () { onChange: function () {
directParagraphStyler.alignParagraphRight(); directParagraphStyler.alignParagraphRight();
onToolDone();
} }
}); });
@ -93,6 +96,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconJustifyFull", iconClass: "dijitEditorIcon dijitEditorIconJustifyFull",
onChange: function () { onChange: function () {
directParagraphStyler.alignParagraphJustified(); directParagraphStyler.alignParagraphJustified();
onToolDone();
} }
}); });
@ -103,6 +107,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconOutdent", iconClass: "dijitEditorIcon dijitEditorIconOutdent",
onClick: function () { onClick: function () {
directParagraphStyler.outdent(); directParagraphStyler.outdent();
onToolDone();
} }
}); });
@ -113,6 +118,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
iconClass: "dijitEditorIcon dijitEditorIconIndent", iconClass: "dijitEditorIcon dijitEditorIconIndent",
onClick: function () { onClick: function () {
directParagraphStyler.indent(); directParagraphStyler.indent();
onToolDone();
} }
}); });

View File

@ -43,7 +43,7 @@ define("webodf/editor/widgets/simpleStyles", [
function (FontPicker, ToggleButton, NumberSpinner) { function (FontPicker, ToggleButton, NumberSpinner) {
"use strict"; "use strict";
var SimpleStyles = function(callback) { var SimpleStyles = function(onToolDone, callback) {
var widget = {}, var widget = {},
directTextStyler, directTextStyler,
boldButton, boldButton,
@ -62,6 +62,7 @@ define("webodf/editor/widgets/simpleStyles", [
iconClass: "dijitEditorIcon dijitEditorIconBold", iconClass: "dijitEditorIcon dijitEditorIconBold",
onChange: function (checked) { onChange: function (checked) {
directTextStyler.setBold(checked); directTextStyler.setBold(checked);
onToolDone();
} }
}); });
@ -73,6 +74,7 @@ define("webodf/editor/widgets/simpleStyles", [
iconClass: "dijitEditorIcon dijitEditorIconItalic", iconClass: "dijitEditorIcon dijitEditorIconItalic",
onChange: function (checked) { onChange: function (checked) {
directTextStyler.setItalic(checked); directTextStyler.setItalic(checked);
onToolDone();
} }
}); });
@ -84,6 +86,7 @@ define("webodf/editor/widgets/simpleStyles", [
iconClass: "dijitEditorIcon dijitEditorIconUnderline", iconClass: "dijitEditorIcon dijitEditorIconUnderline",
onChange: function (checked) { onChange: function (checked) {
directTextStyler.setHasUnderline(checked); directTextStyler.setHasUnderline(checked);
onToolDone();
} }
}); });
@ -95,6 +98,7 @@ define("webodf/editor/widgets/simpleStyles", [
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough", iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
onChange: function (checked) { onChange: function (checked) {
directTextStyler.setHasStrikethrough(checked); directTextStyler.setHasStrikethrough(checked);
onToolDone();
} }
}); });
@ -116,6 +120,7 @@ define("webodf/editor/widgets/simpleStyles", [
fontPickerWidget.setAttribute('disabled', true); fontPickerWidget.setAttribute('disabled', true);
fontPickerWidget.onChange = function(value) { fontPickerWidget.onChange = function(value) {
directTextStyler.setFontName(value); directTextStyler.setFontName(value);
onToolDone();
}; };
widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner]; widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner];

View File

@ -41,7 +41,7 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
function (EditorSession) { function (EditorSession) {
"use strict"; "use strict";
return function CurrentStyle(callback) { return function CurrentStyle(onToolDone, callback) {
var editorSession, var editorSession,
paragraphStyles; paragraphStyles;
@ -56,6 +56,7 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
function setParagraphStyle(value) { function setParagraphStyle(value) {
if (editorSession) { if (editorSession) {
editorSession.setCurrentParagraphStyle(value); editorSession.setCurrentParagraphStyle(value);
onToolDone();
} }
} }

View File

@ -2993,12 +2993,12 @@ core.Utils = function Utils() {
} }
this.hashString = hashString; this.hashString = hashString;
function mergeObjects(destination, source) { function mergeObjects(destination, source) {
if(Array.isArray(source)) { if(source && Array.isArray(source)) {
destination = (destination || []).concat(source.map(function(obj) { destination = (destination || []).concat(source.map(function(obj) {
return mergeObjects({}, obj) return mergeObjects({}, obj)
})) }))
}else { }else {
if(typeof source === "object") { if(source && typeof source === "object") {
destination = destination || {}; destination = destination || {};
Object.keys(source).forEach(function(p) { Object.keys(source).forEach(function(p) {
destination[p] = mergeObjects(destination[p], source[p]) destination[p] = mergeObjects(destination[p], source[p])
@ -3340,6 +3340,17 @@ core.UnitTest.cleanupTestAreaDiv = function() {
runtime.assert(!!testarea && testarea.parentNode === maindoc.body, 'Test environment broken, found no div with id "testarea" below body.'); runtime.assert(!!testarea && testarea.parentNode === maindoc.body, 'Test environment broken, found no div with id "testarea" below body.');
maindoc.body.removeChild(testarea) maindoc.body.removeChild(testarea)
}; };
core.UnitTest.createOdtDocument = function(xml, namespaceMap) {
var xmlDoc = "<?xml version='1.0' encoding='UTF-8'?>";
xmlDoc += "<office:document";
Object.keys(namespaceMap).forEach(function(key) {
xmlDoc += " xmlns:" + key + '="' + namespaceMap[key] + '"'
});
xmlDoc += ">";
xmlDoc += xml;
xmlDoc += "</office:document>";
return runtime.parseXML(xmlDoc)
};
core.UnitTestRunner = function UnitTestRunner() { core.UnitTestRunner = function UnitTestRunner() {
var failedTests = 0, areObjectsEqual; var failedTests = 0, areObjectsEqual;
function debug(msg) { function debug(msg) {
@ -9435,10 +9446,12 @@ odf.OdfCanvas = function() {
}; };
this.destroy = function(callback) { this.destroy = function(callback) {
var head = doc.getElementsByTagName("head")[0]; var head = doc.getElementsByTagName("head")[0];
if(annotationsPane.parentNode) { if(annotationsPane && annotationsPane.parentNode) {
annotationsPane.parentNode.removeChild(annotationsPane) annotationsPane.parentNode.removeChild(annotationsPane)
} }
element.removeChild(sizer); if(sizer) {
element.removeChild(sizer)
}
head.removeChild(webodfcss); head.removeChild(webodfcss);
head.removeChild(fontcss); head.removeChild(fontcss);
head.removeChild(stylesxmlcss); head.removeChild(stylesxmlcss);
@ -11751,23 +11764,23 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) {
} }
return comparison return comparison
} }
function countStepsToPosition(posElement, posOffset, filter) { function countStepsToPosition(targetNode, targetOffset, filter) {
runtime.assert(posElement !== null, "SelectionMover.countStepsToPosition called with element===null"); runtime.assert(targetNode !== null, "SelectionMover.countStepsToPosition called with element===null");
var iterator = getIteratorAtCursor(), c = iterator.container(), o = iterator.unfilteredDomOffset(), steps = 0, watch = new core.LoopWatchDog(1E3), comparison; var iterator = getIteratorAtCursor(), c = iterator.container(), o = iterator.unfilteredDomOffset(), steps = 0, watch = new core.LoopWatchDog(1E3), comparison;
iterator.setUnfilteredPosition(posElement, posOffset); iterator.setUnfilteredPosition(targetNode, targetOffset);
posElement = (iterator.container()); targetNode = iterator.container();
runtime.assert(Boolean(posElement), "SelectionMover.countStepsToPosition: positionIterator.container() returned null"); runtime.assert(Boolean(targetNode), "SelectionMover.countStepsToPosition: positionIterator.container() returned null");
posOffset = iterator.unfilteredDomOffset(); targetOffset = iterator.unfilteredDomOffset();
iterator.setUnfilteredPosition(c, o); iterator.setUnfilteredPosition(c, o);
comparison = comparePoints(posElement, posOffset, iterator.container(), iterator.unfilteredDomOffset()); comparison = comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset());
if(comparison < 0) { if(comparison < 0) {
while(iterator.nextPosition()) { while(iterator.nextPosition()) {
watch.check(); watch.check();
if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { if(filter.acceptPosition(iterator) === FILTER_ACCEPT) {
steps += 1 steps += 1
} }
if(iterator.container() === posElement) { if(iterator.container() === targetNode) {
if(iterator.unfilteredDomOffset() === posOffset) { if(iterator.unfilteredDomOffset() === targetOffset) {
return steps return steps
} }
} }
@ -11777,11 +11790,9 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) {
while(iterator.previousPosition()) { while(iterator.previousPosition()) {
watch.check(); watch.check();
if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { if(filter.acceptPosition(iterator) === FILTER_ACCEPT) {
steps -= 1 steps -= 1;
} if(comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset()) <= 0) {
if(iterator.container() === posElement) { break
if(iterator.unfilteredDomOffset() === posOffset) {
return steps
} }
} }
} }

File diff suppressed because one or more lines are too long