Commit a32ad74c authored by Xiaowu Zhang's avatar Xiaowu Zhang

upload ace editor with gadget's new getContent API

parent 16dd8493
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
/*jslint nomen: true*/ /*jslint nomen: true*/
(function(window, rJS) { (function(window, rJS) {
"use strict"; "use strict";
var gk = rJS(window); rJS(window).ready(function(g) {
gk.declareMethod("setContent", function(value) { g.props = {};
this.editor.getSession().setValue(value);
}).declareMethod("getContent", function() {
return this.editor.getSession().getValue();
});
gk.ready(function(g) {
g.editor = ace.edit(g.__element.getElementsByTagName("div")[0]); g.editor = ace.edit(g.__element.getElementsByTagName("div")[0]);
g.editor.setTheme("ace/theme/monokai"); g.editor.setTheme("ace/theme/monokai");
}).ready(function(g) {
return g.getElement().push(function(element) {
g.props.element = element;
});
}).declareMethod("render", function(options) {
this.props.key = options.key || "";
this.editor.getSession().setValue(options.value);
}).declareMethod("getContent", function() {
var form_gadget = this, result = {};
result[form_gadget.props.key] = form_gadget.editor.getSession().getValue();
return result;
}); });
})(window, rJS, ace); })(window, rJS, ace);
\ No newline at end of file
...@@ -3,18 +3,27 @@ ...@@ -3,18 +3,27 @@
(function (window, rJS) { (function (window, rJS) {
"use strict"; "use strict";
var gk = rJS(window); rJS(window)
.ready(function (g) {
gk.declareMethod('setContent', function (value) { g.props = {};
this.editor.getSession().setValue(value); g.editor = ace.edit(g.__element.getElementsByTagName('div')[0]);
}) g.editor.setTheme("ace/theme/monokai");
})
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareMethod('render', function (options) {
this.props.key = options.key || "";
this.editor.getSession().setValue(options.value);
})
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return this.editor.getSession().getValue(); var form_gadget = this,
result = {};
result[form_gadget.props.key] =
form_gadget.editor.getSession().getValue();
return result;
}); });
gk.ready(function (g) {
g.editor = ace.edit(g.__element.getElementsByTagName('div')[0]);
g.editor.setTheme("ace/theme/monokai");
});
}(window, rJS, ace)); }(window, rJS, ace));
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