Commit 27a96d0b authored by Vincent Bechu's avatar Vincent Bechu

erp5_officejs: add codemirror app

parent 533089a8
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Codemirror Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<link rel="stylesheet" href="codemirror/lib/codemirror.css">
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="codemirror/addon/search/matchesonscrollbar.css">
<script src="codemirror/lib/codemirror.js"></script>
<script src="codemirror/mode/css/css.js"></script>
<script src="codemirror/mode/xml/xml.js"></script>
<script src="codemirror/mode/javascript/javascript.js"></script>
<script src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="codemirror/addon/dialog/dialog.js"></script>
<script src="codemirror/addon/search/searchcursor.js"></script>
<script src="codemirror/addon/search/search.js"></script>
<script src="codemirror/addon/scroll/annotatescrollbar.js"></script>
<script src="codemirror/addon/search/matchesonscrollbar.js"></script>
<script src="gadget_officejs_codemirror.js" type="text/javascript"></script>
</head>
<body>
<div class="codemirror_gadget"><textarea name="code"></textarea></div>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, CodeMirror, RSVP */
(function (window, rJS, CodeMirror, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("saveContent", "triggerSubmit")
.declareMethod('render', function (options) {
this.props.key = options.key || {};
this.props.editor.setOption("mode", options.mode || "htmlmixed");
this.props.editor.setValue(options.value || "");
})
.declareMethod('getContent', function () {
var result = {};
result[this.props.key || "text_content"] = this.props.editor.getValue();
return result;
})
.declareService(function () {
this.props.editor.refresh();
this.props.editor.focus();
})
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
CodeMirror.commands.save = function () {
return new RSVP.Queue()
.push(function () {
return g.saveContent();
});
};
g.props.editor = CodeMirror.fromTextArea(g.props.element.querySelector("textarea"), {
lineNumbers: true,
mode: "text/html",
matchBrackets: true,
showCursorWhenSelecting: true,
extraKeys: {"Alt-F": "findPersistent"}
});
// XXX custom styling for CribJS, should be put somewhere else-
g.props.element.querySelector('.CodeMirror').setAttribute('style', 'min-height: 800px;');
});
});
}(window, rJS, CodeMirror, RSVP));
\ No newline at end of file
erp5_officejs_connector erp5_officejs_connector
erp5_web_renderjs_ui erp5_web_renderjs_ui
\ No newline at end of file erp5_code_mirror
\ No newline at end of file
...@@ -17,4 +17,6 @@ web_site_module/officejs_svg_editor/** ...@@ -17,4 +17,6 @@ web_site_module/officejs_svg_editor/**
web_site_module/officejs_svg_editor_gadget web_site_module/officejs_svg_editor_gadget
web_site_module/officejs_svg_editor_gadget/** web_site_module/officejs_svg_editor_gadget/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
web_site_module/officejs_pdf_viewer_gadget/** web_site_module/officejs_pdf_viewer_gadget/**
\ No newline at end of file web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/**
\ No newline at end of file
...@@ -17,4 +17,6 @@ web_site_module/officejs_setting_gadget/** ...@@ -17,4 +17,6 @@ web_site_module/officejs_setting_gadget/**
web_site_module/officejs_ckeditor_gadget web_site_module/officejs_ckeditor_gadget
web_site_module/officejs_ckeditor_gadget/** web_site_module/officejs_ckeditor_gadget/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
web_site_module/officejs_pdf_viewer_gadget/** web_site_module/officejs_pdf_viewer_gadget/**
\ No newline at end of file web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/**
\ No newline at end of file
...@@ -6,6 +6,8 @@ web_site_module/officejs_bookmark_manager ...@@ -6,6 +6,8 @@ web_site_module/officejs_bookmark_manager
web_site_module/officejs_bookmark_manager/** web_site_module/officejs_bookmark_manager/**
web_site_module/officejs_ckeditor_gadget web_site_module/officejs_ckeditor_gadget
web_site_module/officejs_ckeditor_gadget/** web_site_module/officejs_ckeditor_gadget/**
web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/**
web_site_module/officejs_pdf_viewer web_site_module/officejs_pdf_viewer
web_site_module/officejs_pdf_viewer/** web_site_module/officejs_pdf_viewer/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment