|
@@ -1546,3 +1546,140 @@ $(function () {
|
|
|
if ($('.user.signin').length > 0) return;
|
|
|
$('form').areYouSure();
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+function OdmlEditor() {
|
|
|
+ var docSpec = {
|
|
|
+ allowModeSwitching: true,
|
|
|
+ elements: {
|
|
|
+ "value": {
|
|
|
+ collapsible: false,
|
|
|
+ menu: [{
|
|
|
+ caption: "Delete this <value>",
|
|
|
+ action: Xonomy.deleteElement
|
|
|
+ }, {
|
|
|
+ caption: "Add <unit>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<unit>...</unit>"
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ "unit": {
|
|
|
+ collapsible: false
|
|
|
+ },
|
|
|
+ "name": {
|
|
|
+ mustBeBefore: ["value"],
|
|
|
+ collapsible: false
|
|
|
+ },
|
|
|
+ "property": {
|
|
|
+ oneliner: true,
|
|
|
+ collapsible: true,
|
|
|
+ collapsed: true,
|
|
|
+ collapsoid: function (jsElement) {
|
|
|
+ return jsElement.getChildElements("name")[0].getText() + ": " + jsElement.getChildElements("value")[0].getText();
|
|
|
+ },
|
|
|
+
|
|
|
+ menu: [{
|
|
|
+ caption: "Delete this <property>",
|
|
|
+ action: Xonomy.deleteElement
|
|
|
+ }, {
|
|
|
+ caption: "New <property> before this",
|
|
|
+ action: Xonomy.newElementBefore,
|
|
|
+ actionParameter: "<property><name>...</name><value>...</value></property>"
|
|
|
+ }, {
|
|
|
+ caption: "New <property> after this",
|
|
|
+ action: Xonomy.newElementAfter,
|
|
|
+ actionParameter: "<property><name>...</name><value>...</value></property>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <uncertainty>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<uncertainty>...</uncertainty>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <type>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<type>...</type>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <reference>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<reference>...</reference>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <definition>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<definition>...</definition>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <dependency>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<dependency>...</dependency>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <value_origin>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<value_origin>...</value_origin>"
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ "section": {
|
|
|
+ oneliner: false,
|
|
|
+ collapsible: true,
|
|
|
+ collapsed: true,
|
|
|
+ collapsoid: function (jsElement) {
|
|
|
+ return jsElement.getChildElements("name")[0].getText();
|
|
|
+ },
|
|
|
+ menu: [{
|
|
|
+ caption: "Delete this <section>",
|
|
|
+ action: Xonomy.deleteElement
|
|
|
+ }, {
|
|
|
+ caption: "New <section> before this",
|
|
|
+ action: Xonomy.newElementBefore,
|
|
|
+ actionParameter: "<section/>"
|
|
|
+ }, {
|
|
|
+ caption: "New <section> after this",
|
|
|
+ action: Xonomy.newElementAfter,
|
|
|
+ actionParameter: "<section/>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <name>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<name>...</name>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <type>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<type>...</type>"
|
|
|
+ }, {
|
|
|
+ caption: "Add <reference>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<reference>...</reference>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <definition>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<definition>...</definition>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <link>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<link>...</link>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <repository>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<repository>...</link>"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ caption: "Add <property>",
|
|
|
+ action: Xonomy.newElementChild,
|
|
|
+ actionParameter: "<property><name>...</name><value>...</value></property>"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onchange: function () {
|
|
|
+ var ct = Xonomy.harvest();
|
|
|
+ ct = ct.replace(/ xml:space='preserve'/g, "");
|
|
|
+ $('#edit_area').val(ct);
|
|
|
+ codeMirrorEditor.setValue(ct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var xml = $('#edit_area').val();
|
|
|
+ var editor = document.getElementById("xonomy_edit");
|
|
|
+ Xonomy.render(xml, editor, docSpec);
|
|
|
+}
|