Update to current WebODF pullbox branch. Closes #13

pull/1/head
Friedrich W. H. Kossebau 11 years ago
parent 3614295e1e
commit dd4d49d408

@ -44,8 +44,10 @@ define("webodf/editor/EditorSession", [
return [ "../../webodf/lib" ];
};
runtime.loadClass("core.DomUtils");
runtime.loadClass("ops.OdtDocument");
runtime.loadClass("ops.Session");
runtime.loadClass("odf.Namespaces");
runtime.loadClass("odf.OdfCanvas");
runtime.loadClass("gui.CaretManager");
runtime.loadClass("gui.Caret");
@ -69,10 +71,11 @@ define("webodf/editor/EditorSession", [
currentStyleName = null,
caretManager,
odtDocument = session.getOdtDocument(),
textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
textns = odf.Namespaces.textns,
fontStyles = document.createElement('style'),
formatting = odtDocument.getFormatting(),
styleHelper = new gui.StyleHelper(formatting),
domUtils = new core.DomUtils(),
eventNotifier = new core.EventNotifier([
EditorSession.signalMemberAdded,
EditorSession.signalMemberRemoved,
@ -89,6 +92,15 @@ define("webodf/editor/EditorSession", [
this.sessionView = new gui.SessionView(config.viewOptions, session, caretManager);
this.availableFonts = [];
function isTrueForSelection(predicate) {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return predicate(cursor.getSelectedRange());
}
/*
* @return {Array.{!string}}
*/
@ -192,11 +204,15 @@ define("webodf/editor/EditorSession", [
}
function trackCurrentParagraph(info) {
if (info.paragraphElement !== currentParagraphNode) {
return;
var cursor = odtDocument.getCursor(localMemberId),
range = cursor && cursor.getSelectedRange(),
paragraphRange = odtDocument.getDOM().createRange();
paragraphRange.selectNode(info.paragraphElement);
if ((range && domUtils.rangesIntersect(range, paragraphRange)) || info.paragraphElement === currentParagraphNode) {
self.emit(EditorSession.signalParagraphChanged, info);
checkParagraphStyleName();
}
self.emit(EditorSession.signalParagraphChanged, info);
checkParagraphStyleName();
paragraphRange.detach();
}
function onCursorAdded(cursor) {
@ -283,41 +299,15 @@ define("webodf/editor/EditorSession", [
return formatting.getAvailableParagraphStyles();
};
this.isBold = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.isBold(cursor.getSelectedRange());
};
this.isBold = isTrueForSelection.bind(self, styleHelper.isBold);
this.isItalic = isTrueForSelection.bind(self, styleHelper.isItalic);
this.hasUnderline = isTrueForSelection.bind(self, styleHelper.hasUnderline);
this.hasStrikeThrough = isTrueForSelection.bind(self, styleHelper.hasStrikeThrough);
this.isItalic = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.isItalic(cursor.getSelectedRange());
};
this.hasUnderline = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.hasUnderline(cursor.getSelectedRange());
};
this.hasStrikeThrough = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.hasStrikeThrough(cursor.getSelectedRange());
};
this.isAlignedLeft = isTrueForSelection.bind(self, styleHelper.isAlignedLeft);
this.isAlignedCenter = isTrueForSelection.bind(self, styleHelper.isAlignedCenter);
this.isAlignedRight = isTrueForSelection.bind(self, styleHelper.isAlignedRight);
this.isAlignedJustified = isTrueForSelection.bind(self, styleHelper.isAlignedJustified);
this.getCurrentParagraphStyle = function () {
return currentNamedStyleName;

@ -56,14 +56,14 @@ define("webodf/editor/MemberListView",
*/
function updateAvatarButton(memberId, memberDetails) {
var node = memberListDiv.firstChild;
if (memberDetails === null) {
// 'null' here means finally unknown member
// (and not that the data is still loading)
memberDetails = {
memberid: memberId, fullname: "Unknown",
color: "black", imageurl: "avatar-joe.png"
};
// this takes care of incorrectly implemented MemberModels,
// which might end up returning undefined member data
if (!memberDetails) {
runtime.log("MemberModel sent undefined data for member \"" + memberId + "\".");
return;
}
while (node) {
if (node.memberId === memberId) {
node = node.firstChild;

@ -41,12 +41,13 @@ define("webodf/editor/Tools", [
"dijit/form/Button",
"dijit/form/DropDownButton",
"dijit/Toolbar",
"webodf/editor/widgets/paragraphAlignment",
"webodf/editor/widgets/simpleStyles",
"webodf/editor/widgets/undoRedoMenu",
"webodf/editor/widgets/toolbarWidgets/currentStyle",
"webodf/editor/widgets/paragraphStylesDialog",
"webodf/editor/widgets/zoomSlider"],
function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, SimpleStyles, UndoRedoMenu, CurrentStyle, ParagraphStylesDialog, ZoomSlider) {
function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, ParagraphStylesDialog, ZoomSlider) {
"use strict";
return function Tools(args) {
@ -60,26 +61,18 @@ define("webodf/editor/Tools", [
paragraphStylesMenuItem, paragraphStylesDialog, simpleStyles, currentStyle,
zoomSlider,
undoRedoMenu,
editorSession;
editorSession,
paragraphAlignment,
sessionSubscribers = [];
this.setEditorSession = function(session) {
function setEditorSession(session) {
editorSession = session;
if (undoRedoMenu) {
undoRedoMenu.setEditorSession(session);
}
if (simpleStyles) {
simpleStyles.setEditorSession(session);
}
if (currentStyle) {
currentStyle.setEditorSession(session);
}
if (zoomSlider) {
zoomSlider.setEditorSession(session);
}
if (paragraphStylesDialog) {
paragraphStylesDialog.setEditorSession(session);
}
};
sessionSubscribers.forEach(function (subscriber) {
subscriber.setEditorSession(editorSession);
});
}
this.setEditorSession = setEditorSession;
/**
* @param {!function(!Object=)} callback, passing an error object in case of error
@ -101,7 +94,7 @@ define("webodf/editor/Tools", [
widget.placeAt(toolbar);
widget.startup();
});
undoRedoMenu.setEditorSession(editorSession);
sessionSubscribers.push(undoRedoMenu);
}
// Simple Style Selector [B, I, U, S]
@ -110,22 +103,32 @@ define("webodf/editor/Tools", [
widget.placeAt(toolbar);
widget.startup();
});
simpleStyles.setEditorSession(editorSession);
sessionSubscribers.push(simpleStyles);
}
// Paragraph direct alignment buttons
if (args.directStylingEnabled) {
paragraphAlignment = new ParagraphAlignment(function (widget) {
widget.placeAt(toolbar);
widget.startup();
});
sessionSubscribers.push(paragraphAlignment);
}
// Paragraph Style Selector
currentStyle = new CurrentStyle(function (widget) {
widget.placeAt(toolbar);
widget.startup();
});
currentStyle.setEditorSession(editorSession);
sessionSubscribers.push(currentStyle);
// Zoom Level Selector
zoomSlider = new ZoomSlider(function (widget) {
widget.placeAt(toolbar);
widget.startup();
});
zoomSlider.setEditorSession(editorSession);
sessionSubscribers.push(zoomSlider);
// Load
if (loadOdtFile) {
@ -174,7 +177,7 @@ define("webodf/editor/Tools", [
}
};
});
paragraphStylesDialog.setEditorSession(editorSession);
sessionSubscribers.push(paragraphStylesDialog);
formatMenuButton = new DropDownButton({
dropDown: formatDropDownMenu,
@ -215,6 +218,8 @@ define("webodf/editor/Tools", [
});
closeButton.placeAt(toolbar);
}
setEditorSession(editorSession);
});
};

@ -41,6 +41,12 @@ define({
edit: "Bearbeiten",
view: "Ansicht",
annotate: "Kommentieren",
justifyLeft: "Linksbündig",
justifyCenter: "Zentriert",
justifyRight: "Rechtsbündig",
justifyFull: "Blocksatz",
indent: "Einzug erhöhen",
outdent: "Einzug vermindern",
clone: "Kopiere",
create: "Erzeuge",
delete: "Entferne",

@ -40,6 +40,12 @@ define({
edit: "Edit",
view: "View",
annotate: "Annotate",
justifyLeft: "Align Left",
justifyCenter: "Centered",
justifyRight: "Align Right",
justifyFull: "Justified",
indent: "Increase Indent",
outdent: "Decrease Indent",
clone: "Clone",
create: "Create",
delete: "Delete",

@ -226,6 +226,14 @@ define("webodf/editor/server/pullbox/MemberModel", [], function () {
if (memberData) {
// data available from cache
subscriber(memberId, memberData);
} else {
// pass temporary data
subscriber(memberId, {
memberid: memberId,
fullname: "Unknown",
color: "black",
imageurl: ""
});
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save