diff --git a/Controller.js b/Controller.js
index e69de29..1b2b02f 100644
--- a/Controller.js
+++ b/Controller.js
@@ -0,0 +1,39 @@
+(function (jsOMS)
+{
+ "use strict";
+
+ jsOMS.Modules.Editor = function(app)
+ {
+ this.app = app;
+ this.editors = {};
+ };
+
+ jsOMS.Modules.Editor.prototype.bind = function(id)
+ {
+ const e = typeof id === 'undefined' ? document.getElementsByClassName('editor') : [document.getElementById(id)],
+ length = e.length;
+
+ for(let i = 0; i < length; i++) {
+ this.bindElement(e[i]);
+ }
+ };
+
+ jsOMS.Modules.Editor.prototype.bindElement = function(editor)
+ {
+ if(typeof editor === 'undefined' || !editor) {
+ // todo: do logging
+
+ return;
+ }
+
+ this.editors[editor.id] = new jsOMS.Modules.Editor.Editor(this.app);
+ this.editors[editor.id].bind();
+ };
+}(window.jsOMS = window.jsOMS || {}));
+
+jsOMS.ready(function ()
+{
+ "use strict";
+
+ window.omsApp.moduleManager.get('Editor').bind();
+});
diff --git a/Controller.php b/Controller.php
index 3b37274..a9d3093 100644
--- a/Controller.php
+++ b/Controller.php
@@ -93,6 +93,7 @@ class Controller extends ModuleAbstract implements WebInterface
public function setUpEditorEditor(RequestAbstract $request, ResponseAbstract $response, $data = null)
{
$head = $response->get('Content')->getData('head');
+ $head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Editor/Models/Editor.js');
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Editor/Controller.js');
}
diff --git a/Models/Editor.js b/Models/Editor.js
index 9ffd623..79a00ad 100644
--- a/Models/Editor.js
+++ b/Models/Editor.js
@@ -1,28 +1,45 @@
(function (jsOMS)
+{
+ "use strict";
+
+ jsOMS.Modules.Editor.Editor = function (editor)
{
- "use strict";
+ this.editor = editor;
+ };
- jsOMS.Modules.Editor.Editor = function (editor)
- {
+ jsOMS.Modules.Editor.prototype.bind = function()
+ {
+ const editorButtons = this.editor.getElementsByClassName('editor-button'),
+ editorTitle = this.editor.getElementsByClassName('editor-title')[0],
+ editorContent = this.editor.getElementsByClassName('editor-content')[0],
+ editorPreview = this.editor.getElementsByClassName('editor-preview')[0],
+ length = editorButtons.length,
+ self = this;
- };
+ for(let i = 0; i < length; i++) {
+ editorButtons[i].addEventListener('click', function(event) {
+ console.log('button clicked');
+ // todo: identify button by class and then call function for this class.
+ });
+ }
+ };
- jsOMS.Modules.Editor.prototype.getSelectedText = function()
- {
- var text = '';
- var activeEl = document.activeElement;
- var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null;
- if (
- (activeElTagName === 'textarea' || activeElTagName === 'input') &&
- /^(?:text|search|password|tel|url)$/i.test(activeEl.type) &&
- (typeof activeEl.selectionStart === 'number')
- ) {
- text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd);
- } else if (window.getSelection) {
- text = window.getSelection().toString();
- }
- return text;
- };
+ jsOMS.Modules.Editor.prototype.getSelectedText = function()
+ {
+ var text = '';
+ var activeEl = document.activeElement;
+ var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null;
- }(window.jsOMS = window.jsOMS || {})
-);
\ No newline at end of file
+ if (
+ (activeElTagName === 'textarea' || activeElTagName === 'input') &&
+ /^(?:text|search|password|tel|url)$/i.test(activeEl.type) &&
+ (typeof activeEl.selectionStart === 'number')
+ ) {
+ text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd);
+ } else if (window.getSelection) {
+ text = window.getSelection().toString();
+ }
+
+ return text;
+ };
+}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
diff --git a/Theme/Backend/editor.tpl.php b/Theme/Backend/editor.tpl.php
index f13435e..6092476 100644
--- a/Theme/Backend/editor.tpl.php
+++ b/Theme/Backend/editor.tpl.php
@@ -17,47 +17,18 @@
$doc = $this->getData('doc') ?? null;
?>
-