summaryrefslogtreecommitdiff
path: root/lib/viewers/odf/editor/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'lib/viewers/odf/editor/widgets')
-rw-r--r--lib/viewers/odf/editor/widgets/aboutDialog.js65
-rw-r--r--lib/viewers/odf/editor/widgets/annotation.js63
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.html20
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.js57
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.html30
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.js103
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.html24
-rw-r--r--lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.js45
-rw-r--r--lib/viewers/odf/editor/widgets/editHyperlinks.js215
-rw-r--r--lib/viewers/odf/editor/widgets/fontPicker.js53
-rw-r--r--lib/viewers/odf/editor/widgets/imageInserter.js87
-rw-r--r--lib/viewers/odf/editor/widgets/paragraphAlignment.js108
-rw-r--r--lib/viewers/odf/editor/widgets/paragraphStyles.js132
-rw-r--r--lib/viewers/odf/editor/widgets/paragraphStylesDialog.js185
-rw-r--r--lib/viewers/odf/editor/widgets/simpleStyles.js115
-rw-r--r--lib/viewers/odf/editor/widgets/toolbarWidgets/currentStyle.js38
-rw-r--r--lib/viewers/odf/editor/widgets/undoRedoMenu.js137
-rw-r--r--lib/viewers/odf/editor/widgets/zoomSlider.js123
18 files changed, 958 insertions, 642 deletions
diff --git a/lib/viewers/odf/editor/widgets/aboutDialog.js b/lib/viewers/odf/editor/widgets/aboutDialog.js
new file mode 100644
index 0000000..071280d
--- /dev/null
+++ b/lib/viewers/odf/editor/widgets/aboutDialog.js
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2014 KO GmbH <copyright@kogmbh.com>
+ *
+ * @licstart
+ * This file is part of WebODF.
+ *
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
+ * @licend
+ *
+ * @source: http://www.webodf.org/
+ * @source: https://github.com/kogmbh/WebODF/
+ */
+
+/*global define,require,webodf */
+
+define("webodf/editor/widgets/aboutDialog", ["dijit/Dialog"], function (Dialog) {
+ "use strict";
+
+ var editorBase = dojo.config && dojo.config.paths && dojo.config.paths["webodf/editor"],
+ kogmbhImageUrl = editorBase+ "/images/kogmbh.png";
+
+ runtime.assert(editorBase, "webodf/editor path not defined in dojoConfig");
+
+ return function AboutDialog(callback) {
+ var self = this;
+
+ this.onToolDone = function () {};
+
+ function init() {
+ // TODO: translation, once the the about text has been decided about
+ var tr = runtime.tr,
+ dialog;
+
+ // Dialog
+ dialog = new Dialog({
+ style: "width: 400px",
+ title: "WebODF Text Editor",
+ autofocus: false,
+ content: "<p>The WebODF Text Editor is an easy to use Javascript-based plugin for webpages. " +
+ "It provides a stand-alone editor for text documents in the OpenDocument Format.</p>" +
+ //TODO: add proper link directly to page about the component
+ "<p>Learn more on the <a href=\"http://webodf.org/\" target=\"_blank\">WebODF website</a>.</p>" +
+ "<p>Version " + webodf.Version + "</p>" +
+ "<p>Made by <a href=\"http://kogmbh.com\" target=\"_blank\"><img src=\""+kogmbhImageUrl+"\" width=\"172\" height=\"40\" alt=\"KO GmbH\" style=\"vertical-align: top;\"></a>.</p>"
+ });
+ dialog.onHide = function() { self.onToolDone(); };
+
+ callback(dialog);
+ }
+
+ init();
+ };
+
+});
diff --git a/lib/viewers/odf/editor/widgets/annotation.js b/lib/viewers/odf/editor/widgets/annotation.js
index 8cfabd2..5d09b28 100644
--- a/lib/viewers/odf/editor/widgets/annotation.js
+++ b/lib/viewers/odf/editor/widgets/annotation.js
@@ -1,37 +1,23 @@
/**
- * @license
* Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
@@ -46,19 +32,20 @@ define("webodf/editor/widgets/annotation", [
var AnnotationControl = function (callback) {
var self = this,
+ editorSession,
widget = {},
addAnnotationButton,
- annotationManager;
+ annotationController;
addAnnotationButton = new Button({
- label: document.translator('annotate'),
+ label: runtime.tr('Annotate'),
disabled: true,
showLabel: false,
iconClass: 'dijitIconBookmark',
onClick: function () {
- if (annotationManager) {
- annotationManager.addAnnotation();
+ if (annotationController) {
+ annotationController.addAnnotation();
self.onToolDone();
}
}
@@ -83,14 +70,18 @@ define("webodf/editor/widgets/annotation", [
}
this.setEditorSession = function (session) {
- if (annotationManager) {
- annotationManager.unsubscribe(gui.AnnotationManager.annotatableChanged, onAnnotatableChanged);
+ if (editorSession) {
+ annotationController.unsubscribe(gui.AnnotationController.annotatableChanged, onAnnotatableChanged);
}
- annotationManager = session && session.sessionController.getAnnotationManager();
- if (annotationManager) {
- annotationManager.subscribe(gui.AnnotationManager.annotatableChanged, onAnnotatableChanged);
+
+ editorSession = session;
+ if (editorSession) {
+ annotationController = editorSession.sessionController.getAnnotationController();
+ annotationController.subscribe(gui.AnnotationController.annotatableChanged, onAnnotatableChanged);
+ onAnnotatableChanged(annotationController.isAnnotatable());
+ } else {
+ addAnnotationButton.setAttribute('disabled', true);
}
- onAnnotatableChanged(annotationManager && annotationManager.isAnnotatable());
};
this.onToolDone = function () {};
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.html b/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.html
index 8829fa5..56d9dea 100644
--- a/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.html
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.html
@@ -4,22 +4,22 @@
<body>
<div data-dojo-type="dijit/form/Form" id="alignmentPaneForm" data-dojo-id="alignmentPaneForm">
- <h3 text-i18n="options">Options</h3>
+ <h3 text-i18n="Options">Options</h3>
<input type="radio" data-dojo-type="dijit/form/RadioButton" name="textAlign" id="radioLeft" checked value="left"/>
- <label text-i18n="left" for="radioLeft">Left</label> <br/>
+ <label text-i18n="Left" for="radioLeft"></label> <br/>
<input type="radio" data-dojo-type="dijit/form/RadioButton" name="textAlign" id="radioCenter" value="center"/>
- <label text-i18n="center" for="radioCenter">Center</label> <br/>
+ <label text-i18n="Center" for="radioCenter"></label> <br/>
<input type="radio" data-dojo-type="dijit/form/RadioButton" name="textAlign" id="radioRight" value="right"/>
- <label text-i18n="right" for="radioRight">Right</label> <br/>
+ <label text-i18n="Right" for="radioRight"></label> <br/>
<input type="radio" data-dojo-type="dijit/form/RadioButton" name="textAlign" id="radioJustified" value="justify"/>
- <label text-i18n="justified" for="radioJustified">Justified</label> <br/>
+ <label text-i18n="Justified" for="radioJustified"></label> <br/>
- <h3><span text-i18n="spacing">Spacing</span> <small>(mm)</small></h3>
+ <h3><span text-i18n="Spacing"></span> <small>(mm)</small></h3>
<div style = "margin-top: 10px;">
<div style = "float: right; margin-right: 200px;">
- <label text-i18n="top" for="topMargin">Top</label>
+ <label text-i18n="Top" for="topMargin"></label>
<input data-dojo-type="dijit/form/NumberSpinner" id="topMargin"
value="0"
data-dojo-props="smallDelta:1, constraints:{min:0,max:100}"
@@ -28,7 +28,7 @@
</div>
<br><br>
<div style = "float: left;">
- <label text-i18n="left" for="leftMargin">Left</label>
+ <label text-i18n="Left" for="leftMargin"></label>
<input data-dojo-type="dijit/form/NumberSpinner" id="leftMargin"
value="0"
data-dojo-props="smallDelta:1, constraints:{min:0,max:100}"
@@ -36,7 +36,7 @@
/>
</div>
<div style = "float: right; margin-right: 50px;">
- <label text-i18n="right" for="rightMargin">Right</label>
+ <label text-i18n="Right" for="rightMargin"></label>
<input data-dojo-type="dijit/form/NumberSpinner" id="rightMargin"
value="0"
data-dojo-props="smallDelta:1, constraints:{min:0,max:100}"
@@ -45,7 +45,7 @@
</div>
<br/><br>
<div style = "float: right; margin-right: 200px;">
- <label text-i18n="bottom" for="bottomMargin">Bottom</label>
+ <label text-i18n="Bottom" for="bottomMargin"></label>
<input data-dojo-type="dijit/form/NumberSpinner" id="bottomMargin"
value="0"
data-dojo-props="smallDelta:1, constraints:{min:0,max:100}"
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.js b/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.js
index 5cb79e5..e17d1cf 100644
--- a/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.js
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/alignmentPane.js
@@ -1,47 +1,34 @@
/**
- * @license
* Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global runtime,core,define,require,document,dijit */
-
-runtime.loadClass("core.CSSUnits");
+/*global runtime,core,define,require,dijit */
define("webodf/editor/widgets/dialogWidgets/alignmentPane", [], function () {
"use strict";
+
+ runtime.loadClass("core.CSSUnits");
+
var AlignmentPane = function (callback) {
var self = this,
editorSession,
@@ -66,10 +53,10 @@ define("webodf/editor/widgets/dialogWidgets/alignmentPane", [], function () {
s_textAlign;
if (style !== undefined) {
- s_topMargin = parseFloat(cssUnits.convertMeasure(style['fo:margin-top'], 'mm'));
- s_leftMargin = parseFloat(cssUnits.convertMeasure(style['fo:margin-left'], 'mm'));
- s_rightMargin = parseFloat(cssUnits.convertMeasure(style['fo:margin-right'], 'mm'));
- s_bottomMargin = parseFloat(cssUnits.convertMeasure(style['fo:margin-bottom'], 'mm'));
+ s_topMargin = cssUnits.convertMeasure(style['fo:margin-top'], 'mm');
+ s_leftMargin = cssUnits.convertMeasure(style['fo:margin-left'], 'mm');
+ s_rightMargin = cssUnits.convertMeasure(style['fo:margin-right'], 'mm');
+ s_bottomMargin = cssUnits.convertMeasure(style['fo:margin-bottom'], 'mm');
s_textAlign = style['fo:text-align'];
form.attr('value', {
@@ -106,13 +93,13 @@ define("webodf/editor/widgets/dialogWidgets/alignmentPane", [], function () {
runtime.assert(editorBase, "webodf/editor path not defined in dojoConfig");
ready(function () {
contentPane = new ContentPane({
- title: document.translator("alignment"),
+ title: runtime.tr("Alignment"),
href: editorBase+"/widgets/dialogWidgets/alignmentPane.html",
preload: true
});
contentPane.onLoad = function () {
form = dijit.byId('alignmentPaneForm');
- document.translateContent(form.domNode);
+ runtime.translateContent(form.domNode);
};
return cb();
});
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.html b/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.html
new file mode 100644
index 0000000..49bb1fa
--- /dev/null
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.html
@@ -0,0 +1,30 @@
+<html>
+ <head></head>
+ <body>
+ <div data-dojo-type="dijit/form/Form" id="editHyperlinkPaneForm" data-dojo-id="editHyperlinkPaneForm">
+ <div>
+ <label text-i18n="Display Text" for="linkDisplayText"></label><br/>
+ <input data-dojo-type="dijit/form/TextBox" id="linkDisplayText"
+ value=""
+ data-dojo-props="trim:true"
+ name="linkDisplayText" />
+ <input data-dojo-type="dijit/form/TextBox" id="isReadOnlyText"
+ type ="hidden"
+ value=""
+ data-dojo-props="trim:true"
+ name="isReadOnlyText" />
+ </div>
+ <div>
+ <label text-i18n="URL" for="linkUrl"></label><br/>
+ <input data-dojo-type="dijit/form/TextBox" id="linkUrl"
+ value="http://"
+ data-dojo-props="trim:true, intermediateChanges:true"
+ name="linkUrl" />
+ </div>
+ <div>
+ <button data-dojo-type="dijit/form/Button" id="saveHyperlinkChangeButton" type="submit">Ok</button>
+ <button data-dojo-type="dijit/form/Button" id="cancelHyperlinkChangeButton" data-dojo-id="cancelHyperlinkChangeButton">Cancel</button>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.js b/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.js
new file mode 100644
index 0000000..6037828
--- /dev/null
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/editHyperlinkPane.js
@@ -0,0 +1,103 @@
+/**
+ * Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
+ *
+ * @licstart
+ * This file is part of WebODF.
+ *
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
+ * @licend
+ *
+ * @source: http://www.webodf.org/
+ * @source: https://github.com/kogmbh/WebODF/
+ */
+
+/*global runtime,core,define,require,document,dijit */
+
+define("webodf/editor/widgets/dialogWidgets/editHyperlinkPane", [
+ "dojo",
+ "dijit/layout/ContentPane"],
+
+ function (dojo, ContentPane) {
+ "use strict";
+
+ runtime.loadClass("core.CSSUnits");
+
+ var EditHyperlinkPane = function () {
+ var self = this,
+ editorBase = dojo.config && dojo.config.paths && dojo.config.paths['webodf/editor'],
+ contentPane,
+ form,
+ displayTextField,
+ linkField,
+ initialValue;
+
+ runtime.assert(editorBase, "webodf/editor path not defined in dojoConfig");
+
+ function onSave() {
+ if (self.onSave) {
+ self.onSave();
+ }
+ return false;
+ }
+
+ function onCancel() {
+ form.set('value', initialValue);
+ if (self.onCancel) {
+ self.onCancel();
+ }
+ }
+
+ contentPane = new ContentPane({
+ title: runtime.tr("editLink"),
+ href: editorBase+"/widgets/dialogWidgets/editHyperlinkPane.html",
+ preload: true,
+ onLoad : function () {
+ form = dijit.byId('editHyperlinkPaneForm');
+ form.onSubmit = onSave;
+ dijit.byId('cancelHyperlinkChangeButton').onClick = onCancel;
+ displayTextField = dijit.byId('linkDisplayText');
+ linkField = dijit.byId('linkUrl');
+ linkField.on("change", function(value) {
+ displayTextField.set('placeHolder', value);
+ });
+
+ runtime.translateContent(form.domNode);
+ if (initialValue) {
+ form.set('value', initialValue);
+ displayTextField.set('disabled', initialValue.isReadOnlyText);
+ initialValue = undefined;
+ }
+ displayTextField.set('placeHolder', linkField.value);
+ }
+ });
+
+ this.widget = function () {
+ return contentPane;
+ };
+
+ this.value = function () {
+ return form && form.get('value');
+ };
+
+ this.set = function (value) {
+ initialValue = value;
+ if (form) {
+ form.set('value', value);
+ displayTextField.set('disabled', value.isReadOnlyText);
+ }
+ };
+ };
+
+ return EditHyperlinkPane;
+});
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.html b/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.html
index 5a0c899..4978583 100644
--- a/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.html
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.html
@@ -4,23 +4,23 @@
<body>
<div data-dojo-type="dijit/form/Form" id="fontEffectsPaneForm" data-dojo-id="fontEffectsPaneForm">
- <h3 text-i18n="style">Style</h3>
+ <h3 text-i18n="Style"></h3>
<input data-dojo-type="dijit/form/CheckBox" name="textStyle" id="radioBold" value="bold"/>
- <label text-i18n="bold" for="radioBold">Bold</label> <br/>
+ <label text-i18n="Bold" for="radioBold"></label> <br/>
<input data-dojo-type="dijit/form/CheckBox" name="textStyle" id="radioItalic" value="italic"/>
- <label text-i18n="italic" for="radioItalic">Italic</label> <br/>
+ <label text-i18n="Italic" for="radioItalic"></label> <br/>
<input data-dojo-type="dijit/form/CheckBox" name="textStyle" id="radioUnderline" value="underline"/>
- <label text-i18n="underline" for="radioUnderline">Underline</label> <br/>
+ <label text-i18n="Underline" for="radioUnderline"></label> <br/>
- <h3 text-i18n="font">Font</h3>
+ <h3 text-i18n="Font"></h3>
<br>
<div id = 'fontPicker' class="labeledSelect" style = "float: left;">
- <label text-i18n="family" for="fontName">Family:</label>
+ <label text-i18n="Family" for="fontName"></label>
</div>
<div style = "float: left; margin-left: 30px;">
- <label for="fontSize"><span text-i18n="size">Size</span> (pt) </label>
+ <label for="fontSize"><span text-i18n="Size"></span> (pt) </label>
<input data-dojo-type="dijit/form/NumberSpinner" id="fontSize"
value="12"
data-dojo-props="smallDelta:1, constraints:{min:6,max:96}"
@@ -29,13 +29,11 @@
</div>
<br /><br />
- <h3 text-i18n="color">Color</h3>
+ <h3 text-i18n="Color"></h3>
<br>
<input data-dojo-type="dijit/form/TextBox" name = "color" id = "textColorTB" style="display: none;"/>
<div data-dojo-type="dijit/form/DropDownButton">
- <span><span text-i18n="text" id = "textColor">
- Text
- </span></span>
+ <span><span text-i18n="Text" id = "textColor"></span></span>
<div data-dojo-type="dijit/TooltipDialog">
<div data-dojo-type="dojox.widget.ColorPicker" id="textColorPicker"></div>
</div>
@@ -43,9 +41,7 @@
<input data-dojo-type="dijit/form/TextBox" name = "backgroundColor" id = "backgroundColorTB" style="display: none;"/>
<div data-dojo-type="dijit/form/DropDownButton">
- <span><span text-i18n="background" id = "backgroundColor">
- Background
- </span></span>
+ <span><span text-i18n="Background" id = "backgroundColor"></span></span>
<div data-dojo-type="dijit/TooltipDialog">
<div data-dojo-type="dojox.widget.ColorPicker" id="backgroundColorPicker"></div>
</div>
diff --git a/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.js b/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.js
index 292dda0..b4281e7 100644
--- a/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.js
+++ b/lib/viewers/odf/editor/widgets/dialogWidgets/fontEffectsPane.js
@@ -1,37 +1,23 @@
/**
- * @license
* Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
@@ -126,13 +112,12 @@ define("webodf/editor/widgets/dialogWidgets/fontEffectsPane", [], function () {
"dojox/widget/ColorPicker",
"webodf/editor/widgets/fontPicker"
], function (dojo, ready, domConstruct, ContentPane, ColorPicker, FontPicker) {
- var translator = document.translator,
- editorBase = dojo.config && dojo.config.paths &&
+ var editorBase = dojo.config && dojo.config.paths &&
dojo.config.paths['webodf/editor'];
runtime.assert(editorBase, "webodf/editor path not defined in dojoConfig");
ready(function () {
contentPane = new ContentPane({
- title: translator("fontEffects"),
+ title: runtime.tr("Font Effects"),
href: editorBase+"/widgets/dialogWidgets/fontEffectsPane.html",
preload: true
});
@@ -142,7 +127,7 @@ define("webodf/editor/widgets/dialogWidgets/fontEffectsPane", [], function () {
backgroundColorTB = dijit.byId('backgroundColorTB');
form = dijit.byId('fontEffectsPaneForm');
- document.translateContent(form.domNode);
+ runtime.translateContent(form.domNode);
preview = document.getElementById('previewText');
textColorPicker = dijit.byId('textColorPicker');
diff --git a/lib/viewers/odf/editor/widgets/editHyperlinks.js b/lib/viewers/odf/editor/widgets/editHyperlinks.js
new file mode 100644
index 0000000..d890fbe
--- /dev/null
+++ b/lib/viewers/odf/editor/widgets/editHyperlinks.js
@@ -0,0 +1,215 @@
+/**
+ * Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
+ *
+ * @licstart
+ * This file is part of WebODF.
+ *
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
+ * @licend
+ *
+ * @source: http://www.webodf.org/
+ * @source: https://github.com/kogmbh/WebODF/
+ */
+
+/*global define,require,document,odf */
+
+define("webodf/editor/widgets/editHyperlinks", [
+ "webodf/editor/EditorSession",
+ "webodf/editor/widgets/dialogWidgets/editHyperlinkPane",
+ "dijit/form/Button",
+ "dijit/form/DropDownButton",
+ "dijit/TooltipDialog"],
+
+ function (EditorSession, EditHyperlinkPane, Button, DropDownButton, TooltipDialog) {
+ "use strict";
+
+ runtime.loadClass("odf.OdfUtils");
+
+ var EditHyperlinks = function (callback) {
+ var self = this,
+ widget = {},
+ editorSession,
+ hyperlinkController,
+ linkEditorContent,
+ editHyperlinkButton,
+ removeHyperlinkButton,
+ odfUtils = new odf.OdfUtils(),
+ textSerializer = new odf.TextSerializer(),
+ dialog;
+
+ /**
+ * @param {!Range} selection
+ * @return {!string}
+ */
+ function getTextContent(selection) {
+ var document = selection.startContainer.ownerDocument,
+ fragmentContainer = document.createElement('span');
+ fragmentContainer.appendChild(selection.cloneContents());
+ return textSerializer.writeToString(fragmentContainer);
+ }
+
+ function updateLinkEditorContent() {
+ var selection = editorSession.getSelectedRange(),
+ linksInSelection = editorSession.getSelectedHyperlinks(),
+ linkTarget = linksInSelection[0] ? odfUtils.getHyperlinkTarget(linksInSelection[0]) : "http://";
+
+ if (selection && selection.collapsed && linksInSelection.length === 1) {
+ // Selection is collapsed within a single hyperlink. Assume user is modifying the hyperlink
+ linkEditorContent.set({
+ linkDisplayText: textSerializer.writeToString(linksInSelection[0]),
+ linkUrl: linkTarget,
+ isReadOnlyText: true
+ });
+ } else if (selection && !selection.collapsed) {
+ // User has selected part of a hyperlink or a block of text. Assume user is attempting to modify the
+ // existing hyperlink, or wants to convert the selection into a hyperlink
+ linkEditorContent.set({
+ linkDisplayText: getTextContent(selection),
+ linkUrl: linkTarget,
+ isReadOnlyText: true
+ });
+ } else {
+ // Selection is collapsed and is not in an existing hyperlink
+ linkEditorContent.set({
+ linkDisplayText: "",
+ linkUrl: linkTarget,
+ isReadOnlyText: false
+ });
+ }
+ }
+
+ function checkHyperlinkButtons() {
+ var linksInSelection = editorSession.getSelectedHyperlinks();
+
+ // The 3rd parameter is false to avoid firing onChange when setting the value programmatically.
+ removeHyperlinkButton.set('disabled', linksInSelection.length === 0, false);
+ }
+
+ function enableHyperlinkButtons(isEnabled) {
+ widget.children.forEach(function (element) {
+ element.setAttribute('disabled', !isEnabled);
+ });
+ }
+
+ function updateSelectedLink(hyperlinkData) {
+ var selection = editorSession.getSelectedRange(),
+ selectionController = editorSession.sessionController.getSelectionController(),
+ selectedLinkRange,
+ linksInSelection = editorSession.getSelectedHyperlinks();
+
+ if (hyperlinkData.isReadOnlyText == "true") {
+ if (selection && selection.collapsed && linksInSelection.length === 1) {
+ // Editing the single link the cursor is currently within
+ selectedLinkRange = selection.cloneRange();
+ selectedLinkRange.selectNode(linksInSelection[0]);
+ selectionController.selectRange(selectedLinkRange, true)
+ }
+ hyperlinkController.removeHyperlinks();
+ hyperlinkController.addHyperlink(hyperlinkData.linkUrl);
+ } else {
+ hyperlinkController.addHyperlink(hyperlinkData.linkUrl, hyperlinkData.linkDisplayText);
+ linksInSelection = editorSession.getSelectedHyperlinks();
+ selectedLinkRange = selection.cloneRange();
+ selectedLinkRange.selectNode(linksInSelection[0]);
+ selectionController.selectRange(selectedLinkRange, true)
+ }
+ }
+
+ this.setEditorSession = function (session) {
+ if (editorSession) {
+ editorSession.unsubscribe(EditorSession.signalCursorMoved, checkHyperlinkButtons);
+ editorSession.unsubscribe(EditorSession.signalParagraphChanged, checkHyperlinkButtons);
+ editorSession.unsubscribe(EditorSession.signalParagraphStyleModified, checkHyperlinkButtons);
+ hyperlinkController.unsubscribe(gui.HyperlinkController.enabledChanged, enableHyperlinkButtons);
+ }
+
+ editorSession = session;
+ if (editorSession) {
+ hyperlinkController = editorSession.sessionController.getHyperlinkController();
+
+ editorSession.subscribe(EditorSession.signalCursorMoved, checkHyperlinkButtons);
+ editorSession.subscribe(EditorSession.signalParagraphChanged, checkHyperlinkButtons);
+ editorSession.subscribe(EditorSession.signalParagraphStyleModified, checkHyperlinkButtons);
+ hyperlinkController.subscribe(gui.HyperlinkController.enabledChanged, enableHyperlinkButtons);
+
+ enableHyperlinkButtons(hyperlinkController.isEnabled());
+ checkHyperlinkButtons();
+ } else {
+ enableHyperlinkButtons( false );
+ }
+ };
+
+ this.onToolDone = function () {};
+
+ function init() {
+ textSerializer.filter = new odf.OdfNodeFilter();
+
+ linkEditorContent = new EditHyperlinkPane();
+ dialog = new TooltipDialog({
+ title: runtime.tr("Edit link"),
+ content: linkEditorContent.widget(),
+ onShow: updateLinkEditorContent
+ });
+
+ editHyperlinkButton = new DropDownButton({
+ label: runtime.tr('Edit link'),
+ showLabel: false,
+ disabled: true,
+ iconClass: 'dijitEditorIcon dijitEditorIconCreateLink',
+ dropDown: dialog
+ });
+
+ removeHyperlinkButton = new Button({
+ label: runtime.tr('Remove link'),
+ showLabel: false,
+ disabled: true,
+ iconClass: 'dijitEditorIcon dijitEditorIconUnlink',
+ onClick: function () {
+ hyperlinkController.removeHyperlinks();
+ self.onToolDone();
+ }
+ });
+
+ linkEditorContent.onSave = function () {
+ var hyperlinkData = linkEditorContent.value();
+ editHyperlinkButton.closeDropDown(false);
+ updateSelectedLink(hyperlinkData);
+ self.onToolDone();
+ };
+
+ linkEditorContent.onCancel = function () {
+ editHyperlinkButton.closeDropDown(false);
+ self.onToolDone();
+ };
+
+ widget.children = [editHyperlinkButton, removeHyperlinkButton];
+ widget.startup = function () {
+ widget.children.forEach(function (element) {
+ element.startup();
+ });
+ };
+
+ widget.placeAt = function (container) {
+ widget.children.forEach(function (element) {
+ element.placeAt(container);
+ });
+ return widget;
+ };
+ callback(widget);
+ }
+ init();
+ };
+
+ return EditHyperlinks;
+});
diff --git a/lib/viewers/odf/editor/widgets/fontPicker.js b/lib/viewers/odf/editor/widgets/fontPicker.js
index 039c21b..fd3e606 100644
--- a/lib/viewers/odf/editor/widgets/fontPicker.js
+++ b/lib/viewers/odf/editor/widgets/fontPicker.js
@@ -2,35 +2,22 @@
* Copyright (C) 2012 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
@@ -48,12 +35,11 @@ define("webodf/editor/widgets/fontPicker", [
var self = this,
editorSession,
select,
- editorFonts = [],
- documentFonts = [],
- selectionList = [];
+ documentFonts = [];
select = new Select({
name: 'FontPicker',
+ disabled: true,
maxHeight: 200,
style: {
width: '150px'
@@ -92,8 +78,12 @@ define("webodf/editor/widgets/fontPicker", [
this.onRemove = null;
function populateFonts() {
- var i, name, family;
- editorFonts = editorSession ? editorSession.availableFonts : [];
+ var i,
+ name,
+ family,
+ editorFonts = editorSession ? editorSession.availableFonts : [],
+ selectionList = [];
+
documentFonts = editorSession ? editorSession.getDeclaredFonts() : [];
// First populate the fonts used in the document
@@ -126,9 +116,10 @@ define("webodf/editor/widgets/fontPicker", [
this.setEditorSession = function(session) {
editorSession = session;
populateFonts();
+ select.setAttribute('disabled', !editorSession);
};
-
populateFonts();
+
callback(self);
};
diff --git a/lib/viewers/odf/editor/widgets/imageInserter.js b/lib/viewers/odf/editor/widgets/imageInserter.js
index 9b52b8e..5c6f991 100644
--- a/lib/viewers/odf/editor/widgets/imageInserter.js
+++ b/lib/viewers/odf/editor/widgets/imageInserter.js
@@ -1,37 +1,23 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
@@ -50,8 +36,21 @@ define("webodf/editor/widgets/imageInserter", [
widget = {},
insertImageButton,
editorSession,
- fileLoader;
+ fileLoader,
+ textController,
+ imageController;
+ /**
+ *
+ * @param {!string} mimetype
+ * @param {!string} content base64 encoded string
+ * @param {!number} width
+ * @param {!number} height
+ */
+ function insertImage(mimetype, content, width, height) {
+ textController.removeCurrentSelection();
+ imageController.insertImage(mimetype, content, width, height);
+ };
/**
* @param {!string} content as datauri
@@ -67,9 +66,7 @@ define("webodf/editor/widgets/imageInserter", [
hiddenImage.onload = function () {
// remove the data:image/jpg;base64, bit
content = content.substring(content.indexOf(",") + 1);
- if (editorSession) {
- editorSession.insertImage(mimetype, content, hiddenImage.width, hiddenImage.height);
- }
+ insertImage(mimetype, content, hiddenImage.width, hiddenImage.height);
// clean up
document.body.removeChild(hiddenImage);
self.onToolDone();
@@ -110,7 +107,7 @@ define("webodf/editor/widgets/imageInserter", [
}
insertImageButton = new Button({
- label: document.translator("insertImage"),
+ label: runtime.tr("Insert Image"),
disabled: true,
showLabel: false,
iconClass: "dijitEditorIcon dijitEditorIconInsertImage",
@@ -137,24 +134,38 @@ define("webodf/editor/widgets/imageInserter", [
return widget;
};
+ function enableButtons(isEnabled) {
+ widget.children.forEach(function (element) {
+ element.setAttribute('disabled', !isEnabled);
+ });
+ }
function handleCursorMoved(cursor) {
- var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
- // LO/AOO pops up the picture/frame option dialog if image is selected when pressing the button
- // Since we only support inline images, disable the button for now.
- insertImageButton.setAttribute('disabled', disabled);
+ if (imageController.isEnabled()) {
+ var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
+ // LO/AOO pops up the picture/frame option dialog if image is selected when pressing the button
+ // Since we only support inline images, disable the button for now.
+ insertImageButton.setAttribute('disabled', disabled);
+ }
}
this.setEditorSession = function (session) {
if (editorSession) {
editorSession.unsubscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ imageController.unsubscribe(gui.ImageController.enabledChanged, enableButtons);
}
+
editorSession = session;
if (editorSession) {
+ textController = editorSession.sessionController.getTextController();
+ imageController = editorSession.sessionController.getImageController();
+
editorSession.subscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ imageController.subscribe(gui.ImageController.enabledChanged, enableButtons);
+
+ enableButtons(imageController.isEnabled());
+ } else {
+ enableButtons(false);
}
- widget.children.forEach(function (element) {
- element.setAttribute("disabled", !session);
- });
};
this.onToolDone = function () {};
diff --git a/lib/viewers/odf/editor/widgets/paragraphAlignment.js b/lib/viewers/odf/editor/widgets/paragraphAlignment.js
index 30fa422..ecebf1b 100644
--- a/lib/viewers/odf/editor/widgets/paragraphAlignment.js
+++ b/lib/viewers/odf/editor/widgets/paragraphAlignment.js
@@ -1,42 +1,28 @@
/**
- * @license
* Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global define,require,document,ops,gui */
+/*global define,require,ops,gui */
define("webodf/editor/widgets/paragraphAlignment", [
"dijit/form/ToggleButton",
@@ -50,7 +36,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
var self = this,
editorSession,
widget = {},
- directParagraphStyler,
+ directFormattingController,
justifyLeft,
justifyCenter,
justifyRight,
@@ -59,71 +45,71 @@ define("webodf/editor/widgets/paragraphAlignment", [
outdent;
justifyLeft = new ToggleButton({
- label: document.translator('justifyLeft'),
+ label: runtime.tr('Align Left'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft",
onChange: function () {
- directParagraphStyler.alignParagraphLeft();
+ directFormattingController.alignParagraphLeft();
self.onToolDone();
}
});
justifyCenter = new ToggleButton({
- label: document.translator('justifyCenter'),
+ label: runtime.tr('Center'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter",
onChange: function () {
- directParagraphStyler.alignParagraphCenter();
+ directFormattingController.alignParagraphCenter();
self.onToolDone();
}
});
justifyRight = new ToggleButton({
- label: document.translator('justifyRight'),
+ label: runtime.tr('Align Right'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconJustifyRight",
onChange: function () {
- directParagraphStyler.alignParagraphRight();
+ directFormattingController.alignParagraphRight();
self.onToolDone();
}
});
justifyFull = new ToggleButton({
- label: document.translator('justifyFull'),
+ label: runtime.tr('Justify'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconJustifyFull",
onChange: function () {
- directParagraphStyler.alignParagraphJustified();
+ directFormattingController.alignParagraphJustified();
self.onToolDone();
}
});
outdent = new Button({
- label: document.translator('outdent'),
+ label: runtime.tr('Decrease Indent'),
disabled: true,
showLabel: false,
iconClass: "dijitEditorIcon dijitEditorIconOutdent",
onClick: function () {
- directParagraphStyler.outdent();
+ directFormattingController.outdent();
self.onToolDone();
}
});
indent = new Button({
- label: document.translator('indent'),
+ label: runtime.tr('Increase Indent'),
disabled: true,
showLabel: false,
iconClass: "dijitEditorIcon dijitEditorIconIndent",
onClick: function () {
- directParagraphStyler.indent();
+ directFormattingController.indent();
self.onToolDone();
}
});
@@ -166,38 +152,36 @@ define("webodf/editor/widgets/paragraphAlignment", [
});
}
- function handleCursorMoved(cursor) {
- var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
+ function enableStyleButtons(enabledFeatures) {
widget.children.forEach(function (element) {
- element.setAttribute('disabled', disabled);
+ element.setAttribute('disabled', !enabledFeatures.directParagraphStyling);
});
}
this.setEditorSession = function (session) {
- if (directParagraphStyler) {
- directParagraphStyler.unsubscribe(gui.DirectParagraphStyler.paragraphStylingChanged, updateStyleButtons);
- }
- directParagraphStyler = session && session.sessionController.getDirectParagraphStyler();
- if (directParagraphStyler) {
- directParagraphStyler.subscribe(gui.DirectParagraphStyler.paragraphStylingChanged, updateStyleButtons);
- }
- widget.children.forEach(function (element) {
- element.setAttribute('disabled', !directParagraphStyler);
- });
- updateStyleButtons({
- isAlignedLeft: directParagraphStyler ? directParagraphStyler.isAlignedLeft() : false,
- isAlignedCenter: directParagraphStyler ? directParagraphStyler.isAlignedCenter() : false,
- isAlignedRight: directParagraphStyler ? directParagraphStyler.isAlignedRight() : false,
- isAlignedJustified: directParagraphStyler ? directParagraphStyler.isAlignedJustified() : false
- });
-
if (editorSession) {
- editorSession.unsubscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ directFormattingController.unsubscribe(gui.DirectFormattingController.paragraphStylingChanged, updateStyleButtons);
+ directFormattingController.unsubscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
}
+
editorSession = session;
if (editorSession) {
- editorSession.subscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ directFormattingController = editorSession.sessionController.getDirectFormattingController();
+
+ directFormattingController.subscribe(gui.DirectFormattingController.paragraphStylingChanged, updateStyleButtons);
+ directFormattingController.subscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
+
+ enableStyleButtons(directFormattingController.enabledFeatures());
+ } else {
+ enableStyleButtons({directParagraphStyling: false});
}
+
+ updateStyleButtons({
+ isAlignedLeft: editorSession ? directFormattingController.isAlignedLeft() : false,
+ isAlignedCenter: editorSession ? directFormattingController.isAlignedCenter() : false,
+ isAlignedRight: editorSession ? directFormattingController.isAlignedRight() : false,
+ isAlignedJustified: editorSession ? directFormattingController.isAlignedJustified() : false
+ });
};
this.onToolDone = function () {};
diff --git a/lib/viewers/odf/editor/widgets/paragraphStyles.js b/lib/viewers/odf/editor/widgets/paragraphStyles.js
index c7fddd0..5956931 100644
--- a/lib/viewers/odf/editor/widgets/paragraphStyles.js
+++ b/lib/viewers/odf/editor/widgets/paragraphStyles.js
@@ -1,48 +1,36 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
/*global define,require */
-define("webodf/editor/widgets/paragraphStyles",
- ["webodf/editor/EditorSession"],
+define("webodf/editor/widgets/paragraphStyles", [
+ "dijit/form/Select",
+ "webodf/editor/EditorSession"],
+
+ function (Select, EditorSession) {
+ "use strict"
- function (EditorSession) {
- "use strict";
/**
* @constructor
*/
@@ -50,7 +38,6 @@ define("webodf/editor/widgets/paragraphStyles",
var self = this,
editorSession,
select,
- translator = document.translator,
defaultStyleUIId = ":default";
this.widget = function () {
@@ -76,7 +63,7 @@ define("webodf/editor/widgets/paragraphStyles",
if (value === "") {
value = defaultStyleUIId;
}
- select.set('value', value);
+ select.set('value', value, false);
};
// events
@@ -87,20 +74,16 @@ define("webodf/editor/widgets/paragraphStyles",
function populateStyles() {
var i, selectionList, availableStyles;
- if (! select) {
- return;
- }
-
// Populate the Default Style always
selectionList = [{
- label: translator("defaultStyle"),
+ label: runtime.tr("Default Style"),
value: defaultStyleUIId
}];
availableStyles = editorSession ? editorSession.getAvailableParagraphStyles() : [];
for (i = 0; i < availableStyles.length; i += 1) {
selectionList.push({
- label: availableStyles[i].displayName,
+ label: availableStyles[i].displayName || availableStyles[i].name,
value: availableStyles[i].name
});
}
@@ -118,12 +101,10 @@ define("webodf/editor/widgets/paragraphStyles",
}
newStyleElement = editorSession.getParagraphStyleElement(styleInfo.name);
- if (select) {
- select.addOption({
- value: styleInfo.name,
- label: newStyleElement.getAttributeNS(stylens, 'display-name')
- });
- }
+ select.addOption({
+ value: styleInfo.name,
+ label: newStyleElement.getAttributeNS(stylens, 'display-name')
+ });
if (self.onAdd) {
self.onAdd(styleInfo.name);
@@ -135,45 +116,16 @@ define("webodf/editor/widgets/paragraphStyles",
return;
}
- if (select) {
- select.removeOption(styleInfo.name);
- }
+ select.removeOption(styleInfo.name);
if (self.onRemove) {
self.onRemove(styleInfo.name);
}
}
- function init(cb) {
- require(["dijit/form/Select"], function (Select) {
- select = new Select({
- name: 'ParagraphStyles',
- maxHeight: 200,
- style: {
- width: '100px'
- }
- });
-
- populateStyles();
-
- // Call ParagraphStyles's onChange handler every time
- // the select's onchange is called, and pass the value
- // as reported by ParagraphStyles.value(), because we do not
- // want to expose the internal naming like ":default" outside this
- // class.
- select.onChange = function () {
- self.onChange(self.value());
- };
-
- return cb();
- });
- }
-
function handleCursorMoved(cursor) {
var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
- if (select) {
- select.setAttribute('disabled', disabled);
- }
+ select.setAttribute('disabled', disabled);
}
this.setEditorSession = function(session) {
@@ -182,19 +134,43 @@ define("webodf/editor/widgets/paragraphStyles",
editorSession.unsubscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
editorSession.unsubscribe(EditorSession.signalCursorMoved, handleCursorMoved);
}
+
editorSession = session;
if (editorSession) {
editorSession.subscribe(EditorSession.signalCommonStyleCreated, addStyle);
editorSession.subscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
editorSession.subscribe(EditorSession.signalCursorMoved, handleCursorMoved);
- populateStyles();
}
+ select.setAttribute('disabled', !editorSession);
+
+ populateStyles();
};
// init
- init(function () {
+ function init() {
+ select = new Select({
+ name: 'ParagraphStyles',
+ maxHeight: 200,
+ style: {
+ width: '100px'
+ }
+ });
+
+ populateStyles();
+
+ // Call ParagraphStyles's onChange handler every time
+ // the select's onchange is called, and pass the value
+ // as reported by ParagraphStyles.value(), because we do not
+ // want to expose the internal naming like ":default" outside this
+ // class.
+ select.onChange = function () {
+ self.onChange(self.value());
+ };
+
return callback(self);
- });
+ }
+
+ init();
};
return ParagraphStyles;
diff --git a/lib/viewers/odf/editor/widgets/paragraphStylesDialog.js b/lib/viewers/odf/editor/widgets/paragraphStylesDialog.js
index 2b64860..0ca9adf 100644
--- a/lib/viewers/odf/editor/widgets/paragraphStylesDialog.js
+++ b/lib/viewers/odf/editor/widgets/paragraphStylesDialog.js
@@ -1,42 +1,28 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global define,require,document,dojo,dijit */
+/*global define,require,dojo,dijit */
define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
"use strict";
@@ -51,21 +37,16 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
"dijit/Dialog",
"dijit/TooltipDialog",
"dijit/popup",
+ "dijit/layout/LayoutContainer",
"dijit/layout/TabContainer",
"dijit/layout/ContentPane",
"dijit/form/Button",
- "dijit/form/DropDownButton",
- "dijit/form/RadioButton"], function (Dialog, TooltipDialog, popup, TabContainer, ContentPane, Button, DropDownButton, RadioButton) {
+ "dijit/form/DropDownButton"], function (Dialog, TooltipDialog, popup, LayoutContainer, TabContainer, ContentPane, Button, DropDownButton) {
var i,
- translator = document.translator,
+ tr = runtime.tr,
+ mainLayoutContainer,
tabContainer,
- flowPane,
- numberingPane,
- tabsPane,
- capsPane,
- bordersPane,
- backgroundPane,
- indentsPane,
+ topBar,
actionBar,
okButton,
cancelButton,
@@ -73,7 +54,6 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
deleteButton,
cloneTooltip,
cloneDropDown,
- newStyleName = null,
/**
* Mapping of the properties from edit pane properties to the attributes of style:text-properties
* @const@type{Array.<!{propertyName:string,attributeName:string,unit:string}>}
@@ -129,14 +109,16 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
}, {
propertyName: 'textAlign',
attributeName: 'fo:text-align'
- }];
+ }],
+ originalFontEffectsPaneValue,
+ originalAlignmentPaneValue;
/**
* Sets attributes of a node by the properties of the object properties,
* based on the mapping defined in propertyMapping.
* @param {!Object} properties
* @param {!Array.<!{propertyName:string,attributeName:string,unit:string}>} propertyMapping
- * @return {undefined}
+ * @return {!Object}
*/
function mappedProperties(properties, propertyMapping) {
var i, m, value,
@@ -153,10 +135,33 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
return result;
}
+ /**
+ * Returns an flat object containing only the key-value mappings
+ * from the 'new' flat object which are different from the 'old' object's.
+ * @param {!Object} oldProperties
+ * @param {!Object} newProperties
+ * @return {!Object}
+ */
+ function updatedProperties(oldProperties, newProperties) {
+ var properties = {};
+ Object.keys(newProperties).forEach(function (key) {
+ if (newProperties[key] !== oldProperties[key]) {
+ properties[key] = newProperties[key];
+ }
+ });
+ return properties;
+ }
+
function accept() {
editorSession.updateParagraphStyle(stylePicker.value(), {
- "style:paragraph-properties": mappedProperties(alignmentPane.value(), paragraphPropertyMapping),
- "style:text-properties": mappedProperties(fontEffectsPane.value(), textPropertyMapping)
+ "style:paragraph-properties": mappedProperties(
+ updatedProperties(originalAlignmentPaneValue, alignmentPane.value()),
+ paragraphPropertyMapping
+ ),
+ "style:text-properties": mappedProperties(
+ updatedProperties(originalFontEffectsPaneValue, fontEffectsPane.value()),
+ textPropertyMapping
+ )
});
dialog.hide();
@@ -166,6 +171,24 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
dialog.hide();
}
+ function setStyle(value) {
+ if (value !== stylePicker.value()) {
+ stylePicker.setValue(value);
+ }
+
+ alignmentPane.setStyle(value);
+ fontEffectsPane.setStyle(value);
+ originalAlignmentPaneValue = alignmentPane.value();
+ originalFontEffectsPaneValue = fontEffectsPane.value();
+
+ // If it is a default (nameless) style or is used, make it undeletable.
+ if (value === "" || editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) {
+ deleteButton.domNode.style.display = 'none';
+ } else {
+ deleteButton.domNode.style.display = 'block';
+ }
+ }
+
/**
* Creates and enqueues a paragraph-style cloning operation.
* Remembers the id of the created style in newStyleName, so the
@@ -174,7 +197,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
* @param {!string} newStyleDisplayName display name of the new style
*/
function cloneStyle(styleName, newStyleDisplayName) {
- newStyleName = editorSession.cloneParagraphStyle(styleName, newStyleDisplayName);
+ var newStyleName = editorSession.cloneParagraphStyle(styleName, newStyleDisplayName);
+ setStyle(newStyleName);
}
function deleteStyle(styleName) {
@@ -182,17 +206,27 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
}
// Dialog
dialog = new Dialog({
- title: translator("paragraphStyles")
+ title: tr("Paragraph Styles")
+ });
+
+ mainLayoutContainer = new LayoutContainer({
+ style: "height: 520px; width: 450px;"
+ });
+
+ topBar = new ContentPane({
+ region: "top",
+ style: "margin: 0; padding: 0"
});
+ mainLayoutContainer.addChild(topBar);
cloneTooltip = new TooltipDialog({
content:
- '<h2 style="margin: 0;">'+translator("cloneThisStyle")+'</h2><br/>' +
- '<label for="name">'+translator("newName_C")+'</label> <input data-dojo-type="dijit/form/TextBox" id="name" name="name"><br/><br/>',
+ '<h2 style="margin: 0;">'+tr("Clone this Style")+'</h2><br/>' +
+ '<label for="name">'+tr("New Name:")+'</label> <input data-dojo-type="dijit/form/TextBox" id="name" name="name"><br/><br/>',
style: "width: 300px;"
});
cloneButton = new Button({
- label: translator("create"),
+ label: tr("Create"),
onClick: function () {
cloneStyle(stylePicker.value(), cloneTooltip.get('value').name);
cloneTooltip.reset();
@@ -201,16 +235,16 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
});
cloneTooltip.addChild(cloneButton);
cloneDropDown = new DropDownButton({
- label: translator("clone"),
+ label: tr("Clone"),
showLabel: false,
iconClass: 'dijitEditorIcon dijitEditorIconCopy',
dropDown: cloneTooltip,
style: "float: right; margin-bottom: 5px;"
});
- dialog.addChild(cloneDropDown, 1);
+ topBar.addChild(cloneDropDown, 1);
deleteButton = new Button({
- label: translator("delete"),
+ label: tr("Delete"),
showLabel: false,
iconClass: 'dijitEditorIcon dijitEditorIconDelete',
style: "float: right; margin-bottom: 5px;",
@@ -218,23 +252,23 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
deleteStyle(stylePicker.value());
}
});
- dialog.addChild(deleteButton, 2);
+ topBar.addChild(deleteButton, 2);
// Tab Container
tabContainer = new TabContainer({
- style: "height: 100%; width: 100%;"
+ region: "center"
});
- dialog.addChild(tabContainer, 3);
+ mainLayoutContainer.addChild(tabContainer);
actionBar = dojo.create("div", {
"class": "dijitDialogPaneActionBar"
});
okButton = new dijit.form.Button({
- label: translator("ok"),
+ label: tr("OK"),
onClick: accept
}).placeAt(actionBar);
cancelButton = new dijit.form.Button({
- label: translator("cancel"),
+ label: tr("Cancel"),
onClick: cancel
}).placeAt(actionBar);
dialog.domNode.appendChild(actionBar);
@@ -247,38 +281,23 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
], function (ParagraphStyles, AlignmentPane, FontEffectsPane) {
var p, a, f;
- function openStyle(value) {
- alignmentPane.setStyle(value);
- fontEffectsPane.setStyle(value);
- // If it is a default (nameless) style or is used, make it undeletable.
- if (value === "" || editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) {
- deleteButton.domNode.style.display = 'none';
- } else {
- deleteButton.domNode.style.display = 'block';
- }
- }
-
p = new ParagraphStyles(function (paragraphStyles) {
stylePicker = paragraphStyles;
stylePicker.widget().startup();
stylePicker.widget().domNode.style.float = "left";
stylePicker.widget().domNode.style.width = "350px";
stylePicker.widget().domNode.style.marginTop = "5px";
- dialog.addChild(stylePicker.widget(), 0);
-
- stylePicker.onAdd = function (name) {
- if (newStyleName === name) {
- stylePicker.setValue(name);
- newStyleName = null; // reset 'flag' name
- }
- };
+ topBar.addChild(stylePicker.widget(), 0);
stylePicker.onRemove = function (name) {
- // Set the first style name as current
- stylePicker.setValue(stylePicker.widget().getOptions(0));
+ // The style picker automatically falls back
+ // to the first entry if the currently selected
+ // entry is deleted. So it is safe to simply
+ // open the new auto-selected entry after removal.
+ setStyle(stylePicker.value());
};
- stylePicker.onChange = openStyle;
+ stylePicker.onChange = setStyle;
stylePicker.setEditorSession(editorSession);
});
a = new AlignmentPane(function (pane) {
@@ -296,20 +315,14 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
dialog.onShow = function () {
var currentStyle = editorSession.getCurrentParagraphStyle();
- // setting the stylepicker value if the style name is the same
- // will not trigger onChange, so specifically open the style in
- // the panes.
- if (stylePicker.value() === currentStyle) {
- openStyle(currentStyle);
- } else {
- stylePicker.setValue(currentStyle);
- }
+ setStyle(currentStyle);
};
dialog.onHide = self.onToolDone;
});
- tabContainer.startup();
+ dialog.addChild(mainLayoutContainer);
+ mainLayoutContainer.startup();
return callback(dialog);
});
diff --git a/lib/viewers/odf/editor/widgets/simpleStyles.js b/lib/viewers/odf/editor/widgets/simpleStyles.js
index 37e03a5..faa2bde 100644
--- a/lib/viewers/odf/editor/widgets/simpleStyles.js
+++ b/lib/viewers/odf/editor/widgets/simpleStyles.js
@@ -1,42 +1,28 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global define,require,document,gui,ops */
+/*global define,require,gui,ops */
define("webodf/editor/widgets/simpleStyles", [
"webodf/editor/widgets/fontPicker",
@@ -51,7 +37,7 @@ define("webodf/editor/widgets/simpleStyles", [
var self = this,
editorSession,
widget = {},
- directTextStyler,
+ directFormattingController,
boldButton,
italicButton,
underlineButton,
@@ -61,55 +47,55 @@ define("webodf/editor/widgets/simpleStyles", [
fontPickerWidget;
boldButton = new ToggleButton({
- label: document.translator('bold'),
+ label: runtime.tr('Bold'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconBold",
onChange: function (checked) {
- directTextStyler.setBold(checked);
+ directFormattingController.setBold(checked);
self.onToolDone();
}
});
italicButton = new ToggleButton({
- label: document.translator('italic'),
+ label: runtime.tr('Italic'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconItalic",
onChange: function (checked) {
- directTextStyler.setItalic(checked);
+ directFormattingController.setItalic(checked);
self.onToolDone();
}
});
underlineButton = new ToggleButton({
- label: document.translator('underline'),
+ label: runtime.tr('Underline'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconUnderline",
onChange: function (checked) {
- directTextStyler.setHasUnderline(checked);
+ directFormattingController.setHasUnderline(checked);
self.onToolDone();
}
});
strikethroughButton = new ToggleButton({
- label: document.translator('strikethrough'),
+ label: runtime.tr('Strikethrough'),
disabled: true,
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
onChange: function (checked) {
- directTextStyler.setHasStrikethrough(checked);
+ directFormattingController.setHasStrikethrough(checked);
self.onToolDone();
}
});
fontSizeSpinner = new NumberSpinner({
- label: document.translator('size'),
+ label: runtime.tr('Size'),
disabled: true,
showLabel: false,
value: 12,
@@ -117,7 +103,7 @@ define("webodf/editor/widgets/simpleStyles", [
constraints: {min:6, max:96},
intermediateChanges: true,
onChange: function (value) {
- directTextStyler.setFontSize(value);
+ directFormattingController.setFontSize(value);
},
onClick: function () {
self.onToolDone();
@@ -134,7 +120,7 @@ define("webodf/editor/widgets/simpleStyles", [
fontPickerWidget = fontPicker.widget();
fontPickerWidget.setAttribute('disabled', true);
fontPickerWidget.onChange = function(value) {
- directTextStyler.setFontName(value);
+ directFormattingController.setFontName(value);
self.onToolDone();
};
@@ -175,41 +161,48 @@ define("webodf/editor/widgets/simpleStyles", [
});
}
- function handleCursorMoved(cursor) {
- var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
+ function enableStyleButtons(enabledFeatures) {
widget.children.forEach(function (element) {
- element.setAttribute('disabled', disabled);
+ element.setAttribute('disabled', !enabledFeatures.directTextStyling);
});
}
- this.setEditorSession = function(session) {
- if (directTextStyler) {
- directTextStyler.unsubscribe(gui.DirectTextStyler.textStylingChanged, updateStyleButtons);
- }
- directTextStyler = session && session.sessionController.getDirectTextStyler();
- fontPicker.setEditorSession(session);
- if (directTextStyler) {
- directTextStyler.subscribe(gui.DirectTextStyler.textStylingChanged, updateStyleButtons);
+ function handleCursorMoved(cursor) {
+ if (directFormattingController.enabledFeatures().directTextStyling) {
+ var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
+ enableStyleButtons({ directTextStyling: !disabled });
}
- widget.children.forEach(function (element) {
- element.setAttribute('disabled', !directTextStyler);
- });
- updateStyleButtons({
- isBold: directTextStyler ? directTextStyler.isBold() : false,
- isItalic: directTextStyler ? directTextStyler.isItalic() : false,
- hasUnderline: directTextStyler ? directTextStyler.hasUnderline() : false,
- hasStrikeThrough: directTextStyler ? directTextStyler.hasStrikeThrough() : false,
- fontSize: directTextStyler ? directTextStyler.fontSize() : undefined,
- fontName: directTextStyler ? directTextStyler.fontName() : undefined
- });
+ }
+ this.setEditorSession = function(session) {
if (editorSession) {
editorSession.unsubscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ directFormattingController.unsubscribe(gui.DirectFormattingController.textStylingChanged, updateStyleButtons);
+ directFormattingController.unsubscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
}
+
editorSession = session;
+ fontPicker.setEditorSession(editorSession);
if (editorSession) {
+ directFormattingController = editorSession.sessionController.getDirectFormattingController();
+
editorSession.subscribe(EditorSession.signalCursorMoved, handleCursorMoved);
+ directFormattingController.subscribe(gui.DirectFormattingController.textStylingChanged, updateStyleButtons);
+ directFormattingController.subscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
+
+ enableStyleButtons(directFormattingController.enabledFeatures());
+ } else {
+ enableStyleButtons({ directTextStyling: false});
}
+
+ updateStyleButtons({
+ isBold: editorSession ? directFormattingController.isBold() : false,
+ isItalic: editorSession ? directFormattingController.isItalic() : false,
+ hasUnderline: editorSession ? directFormattingController.hasUnderline() : false,
+ hasStrikeThrough: editorSession ? directFormattingController.hasStrikeThrough() : false,
+ fontSize: editorSession ? directFormattingController.fontSize() : undefined,
+ fontName: editorSession ? directFormattingController.fontName() : undefined
+ });
};
this.onToolDone = function () {};
diff --git a/lib/viewers/odf/editor/widgets/toolbarWidgets/currentStyle.js b/lib/viewers/odf/editor/widgets/toolbarWidgets/currentStyle.js
index 7d86484..26eae6c 100644
--- a/lib/viewers/odf/editor/widgets/toolbarWidgets/currentStyle.js
+++ b/lib/viewers/odf/editor/widgets/toolbarWidgets/currentStyle.js
@@ -1,37 +1,23 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
diff --git a/lib/viewers/odf/editor/widgets/undoRedoMenu.js b/lib/viewers/odf/editor/widgets/undoRedoMenu.js
index 32f3e4a..6fe66c8 100644
--- a/lib/viewers/odf/editor/widgets/undoRedoMenu.js
+++ b/lib/viewers/odf/editor/widgets/undoRedoMenu.js
@@ -1,99 +1,81 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global define,require,document */
+/*global define,require*/
define("webodf/editor/widgets/undoRedoMenu",
- ["webodf/editor/EditorSession"],
+ ["webodf/editor/EditorSession", "dijit/form/Button"],
- function (EditorSession) {
+ function (EditorSession, Button) {
"use strict";
return function UndoRedoMenu(callback) {
- var editorSession,
+ var self = this,
+ editorSession,
undoButton,
- redoButton;
-
- function makeWidget(callback) {
- require(["dijit/form/Button"], function (Button) {
- var widget = {};
+ redoButton,
+ widget = {};
- undoButton = new Button({
- label: document.translator('undo'),
- showLabel: false,
- disabled: true, // TODO: get current session state
- iconClass: "dijitEditorIcon dijitEditorIconUndo",
- onClick: function () {
- if (editorSession) {
- editorSession.undo();
- }
- }
- });
-
- redoButton = new Button({
- label: document.translator('redo'),
- showLabel: false,
- disabled: true, // TODO: get current session state
- iconClass: "dijitEditorIcon dijitEditorIconRedo",
- onClick: function () {
- if (editorSession) {
- editorSession.redo();
- }
- }
- });
+ undoButton = new Button({
+ label: runtime.tr('Undo'),
+ showLabel: false,
+ disabled: true, // TODO: get current session state
+ iconClass: "dijitEditorIcon dijitEditorIconUndo",
+ onClick: function () {
+ if (editorSession) {
+ editorSession.undo();
+ self.onToolDone();
+ }
+ }
+ });
- widget.children = [undoButton, redoButton];
- widget.startup = function () {
- widget.children.forEach(function (element) {
- element.startup();
- });
- };
+ redoButton = new Button({
+ label: runtime.tr('Redo'),
+ showLabel: false,
+ disabled: true, // TODO: get current session state
+ iconClass: "dijitEditorIcon dijitEditorIconRedo",
+ onClick: function () {
+ if (editorSession) {
+ editorSession.redo();
+ self.onToolDone();
+ }
+ }
+ });
- widget.placeAt = function (container) {
- widget.children.forEach(function (element) {
- element.placeAt(container);
- });
- return widget;
- };
+ widget.children = [undoButton, redoButton];
+ widget.startup = function () {
+ widget.children.forEach(function (element) {
+ element.startup();
+ });
+ };
- return callback(widget);
+ widget.placeAt = function (container) {
+ widget.children.forEach(function (element) {
+ element.placeAt(container);
});
- }
+ return widget;
+ };
function checkUndoButtons(e) {
if (undoButton) {
@@ -108,16 +90,21 @@ define("webodf/editor/widgets/undoRedoMenu",
if (editorSession) {
editorSession.unsubscribe(EditorSession.signalUndoStackChanged, checkUndoButtons);
}
+
editorSession = session;
if (editorSession) {
editorSession.subscribe(EditorSession.signalUndoStackChanged, checkUndoButtons);
// TODO: checkUndoButtons(editorSession.getundoredoavailablalalo());
+ } else {
+ widget.children.forEach(function (element) {
+ element.setAttribute('disabled', true);
+ });
}
};
+ this.onToolDone = function () {};
+
// init
- makeWidget(function (widget) {
- return callback(widget);
- });
+ callback(widget);
};
});
diff --git a/lib/viewers/odf/editor/widgets/zoomSlider.js b/lib/viewers/odf/editor/widgets/zoomSlider.js
index 40fcfdc..82f258f 100644
--- a/lib/viewers/odf/editor/widgets/zoomSlider.js
+++ b/lib/viewers/odf/editor/widgets/zoomSlider.js
@@ -1,90 +1,93 @@
/**
- * @license
* Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com>
*
* @licstart
- * The JavaScript code in this page is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version. The code is distributed
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
+ * This file is part of WebODF.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this code. If not, see <http://www.gnu.org/licenses/>.
- *
- * As additional permission under GNU AGPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
+ * WebODF is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License (GNU AGPL)
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
*
- * As a special exception to the AGPL, any HTML file which merely makes function
- * calls to this code, and for that purpose includes it by reference shall be
- * deemed a separate work for copyright law purposes. In addition, the copyright
- * holders of this code give you permission to combine this code with free
- * software libraries that are released under the GNU LGPL. You may copy and
- * distribute such a system following the terms of the GNU AGPL for this code
- * and the LGPL for the libraries. If you modify this code, you may extend this
- * exception to your version of the code, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your
- * version.
+ * WebODF is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * This license applies to this entire compilation.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
+ *
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
-/*global define,require,document */
+/*global define,require*/
-define("webodf/editor/widgets/zoomSlider", [], function () {
+define("webodf/editor/widgets/zoomSlider", [
+ "dijit/form/HorizontalSlider",
+ "dijit/form/NumberTextBox",
+ "webodf/editor/EditorSession"],
+
+ function (HorizontalSlider, NumberTextBox, EditorSession) {
"use strict";
+ // The slider zooms from -1 to +1, which corresponds
+ // to zoom levels of 1/extremeZoomFactor to extremeZoomFactor.
return function ZoomSlider(callback) {
var self = this,
editorSession,
- slider;
-
- function makeWidget(callback) {
- require(["dijit/form/HorizontalSlider", "dijit/form/NumberTextBox", "dojo"], function (HorizontalSlider, NumberTextBox, dojo) {
- var widget = {};
-
- slider = new HorizontalSlider({
- name: 'zoomSlider',
- value: 100,
- minimum: 30,
- maximum: 150,
- discreteValues: 100,
- intermediateChanges: true,
- style: {
- width: '150px',
- height: '25px',
- float: 'right'
- }
- });
+ slider,
+ extremeZoomFactor = 4;
- slider.onChange = function (value) {
- if (editorSession) {
- editorSession.getOdfCanvas().setZoomLevel(value / 100.0);
- }
- self.onToolDone();
- };
-
- return callback(slider);
- });
+ function updateSlider(zoomLevel) {
+ slider.set('value', Math.log(zoomLevel) / Math.log(extremeZoomFactor), false);
}
this.setEditorSession = function(session) {
+ var zoomHelper;
+ if (editorSession) {
+ editorSession.getOdfCanvas().getZoomHelper().unsubscribe(gui.ZoomHelper.signalZoomChanged, updateSlider);
+ }
+
editorSession = session;
-// if (slider) { slider.setValue(editorSession.getOdfCanvas().getZoomLevel() ); TODO!
+ if (editorSession) {
+ zoomHelper = editorSession.getOdfCanvas().getZoomHelper();
+ zoomHelper.subscribe(gui.ZoomHelper.signalZoomChanged, updateSlider);
+ updateSlider(zoomHelper.getZoomLevel());
+ }
+ slider.setAttribute('disabled', !editorSession);
};
this.onToolDone = function () {};
// init
- makeWidget(function (widget) {
- return callback(widget);
- });
+ function init() {
+ slider = new HorizontalSlider({
+ name: 'zoomSlider',
+ disabled: true,
+ value: 0,
+ minimum: -1,
+ maximum: 1,
+ discreteValues: 0.01,
+ intermediateChanges: true,
+ style: {
+ width: '150px',
+ height: '25px',
+ float: 'right'
+ }
+ });
+
+ slider.onChange = function (value) {
+ if (editorSession) {
+ editorSession.getOdfCanvas().getZoomHelper().setZoomLevel(Math.pow(extremeZoomFactor, value));
+ }
+ self.onToolDone();
+ };
+
+ return callback(slider);
+ }
+
+ init();
};
});