Commit 381dafb4 authored by Romain Courteaud's avatar Romain Courteaud

JSLint examples.

parent 90a54b2f
...@@ -3,6 +3,8 @@ RENDERJS = renderjs.js ...@@ -3,6 +3,8 @@ RENDERJS = renderjs.js
RENDERJS_MIN = renderjs.min.js RENDERJS_MIN = renderjs.min.js
BUILDDIR = tmp BUILDDIR = tmp
LINT_OPTS = --maxlen 79 --indent 2 --maxerr 3
include config.mk include config.mk
all: external lint test build doc all: external lint test build doc
...@@ -67,10 +69,11 @@ lib/jio/complex_queries.js: ...@@ -67,10 +69,11 @@ lib/jio/complex_queries.js:
$(RENDERJS_MIN): $(RENDERJS) $(RENDERJS_MIN): $(RENDERJS)
$(UGLIFY_CMD) "$<" > "$@" $(UGLIFY_CMD) "$<" > "$@"
${BUILDDIR}/$(RENDERJS).lint: $(RENDERJS) test/renderjs_test.js ${BUILDDIR}/$(RENDERJS).lint: $(RENDERJS) test/renderjs_test.js examples/officejs/*.js
@mkdir -p $(@D) @mkdir -p $(@D)
$(LINT_CMD) "$(RENDERJS)" $(LINT_CMD) $(LINT_OPTS) "$(RENDERJS)"
$(LINT_CMD) "test/renderjs_test.js" $(LINT_CMD) $(LINT_OPTS) "test/renderjs_test.js"
$(LINT_CMD) $(LINT_OPTS) examples/officejs/*.js
touch $@ touch $@
${BUILDDIR}/index.html.ok: test/index.html ${BUILDDIR}/index.html.ok: test/index.html
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
rJS(this).editor.getSession().setValue(value); rJS(this).editor.getSession().setValue(value);
// return rJS(this).context.find('textarea').val(escape_text(value)); // return rJS(this).context.find('textarea').val(escape_text(value));
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return rJS(this).editor.getSession().getValue(); return rJS(this).editor.getSession().getValue();
// return rJS(this).context.find('textarea').val(); // return rJS(this).context.find('textarea').val();
}); });
gk.ready(function () { gk.ready(function () {
var g = rJS(this); var g = rJS(this);
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
// editor.getSession().setMode("ace/mode/javascript"); // editor.getSession().setMode("ace/mode/javascript");
}); });
}(window, jQuery, rJS, ace)) }(window, jQuery, rJS, ace));
...@@ -4,25 +4,25 @@ ...@@ -4,25 +4,25 @@
var gk = rJS(window), var gk = rJS(window),
io_dict = { io_dict = {
"path" : "./io.html", "path" : "./io.html",
"title" : "IO", "title" : "IO",
"interface" : "http://www.renderjs.org/interface/io", "interface" : "http://www.renderjs.org/interface/io",
}, },
editor_1_dict = { editor_1_dict = {
"path" : "./editor.html", "path" : "./editor.html",
"title" : "Simple Text Editor Gadget", "title" : "Simple Text Editor Gadget",
"interface" : "http://www.renderjs.org/interface/editor", "interface" : "http://www.renderjs.org/interface/editor",
}, },
editor_2_dict = { editor_2_dict = {
"path" : "./jqteditor.html", "path" : "./jqteditor.html",
"title" : "JQuery Text Editor Gadget", "title" : "JQuery Text Editor Gadget",
"interface" : "http://www.renderjs.org/interface/editor", "interface" : "http://www.renderjs.org/interface/editor",
}, },
editor_3_dict = { editor_3_dict = {
"path" : "./aceeditor.html", "path" : "./aceeditor.html",
"title" : "Ace Editor Gadget", "title" : "Ace Editor Gadget",
"interface" : "http://www.renderjs.org/interface/editor", "interface" : "http://www.renderjs.org/interface/editor",
}, },
catalog_list = [ catalog_list = [
{ {
"path" : "./officejs.html", "path" : "./officejs.html",
...@@ -52,4 +52,4 @@ ...@@ -52,4 +52,4 @@
return deferred.promise(); return deferred.promise();
}); });
}(window, $, rJS)) }(window, jQuery, rJS));
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
return text.replace(/&/g, "&amp;") return text.replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;"); .replace(/>/g, "&gt;");
}; }
var gk = rJS(window); var gk = rJS(window);
gk.declareMethod('setContent', function (value) { gk.declareMethod('setContent', function (value) {
return rJS(this).context.find('textarea').val(escape_text(value)); return rJS(this).context.find('textarea').val(escape_text(value));
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return rJS(this).context.find('textarea').val(); return rJS(this).context.find('textarea').val();
}); });
}(window, $, rJS)) }(window, jQuery, rJS));
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
rJS(this).jio_key = key; rJS(this).jio_key = key;
}) })
.declareMethod('getIO', function () { .declareMethod('getIO', function () {
var deferred = $.Deferred(), var deferred = $.Deferred(),
default_value = "", default_value = "",
gadget = rJS(this); gadget = rJS(this);
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
}); });
return deferred.promise(); return deferred.promise();
}) })
.declareMethod('setIO', function (value) { .declareMethod('setIO', function (value) {
var deferred = $.Deferred(), var deferred = $.Deferred(),
default_value = "", default_value = "",
...@@ -60,17 +60,17 @@ ...@@ -60,17 +60,17 @@
} }
}); });
} }
}); });
return deferred.promise(); return deferred.promise();
}) })
.declareMethod('configureDataSourceCallback', function (that, callback) { .declareMethod('configureDataSourceCallback', function (that, callback) {
var g = rJS(this); var g = rJS(this);
g.context.find('a').unbind('click').click(function () { g.context.find('a').unbind('click').click(function () {
callback.apply(that).done(function (value) { callback.apply(that).done(function (value) {
g.setIO(value); g.setIO(value);
}); });
}); });
}); });
}(window, $, jIO, rJS)) }(window, jQuery, jIO, rJS));
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
// return rJS(this).context.find('textarea').val(escape_text(value)); // return rJS(this).context.find('textarea').val(escape_text(value));
return rJS(this).context.find('#textarea-b').jqteVal(value); return rJS(this).context.find('#textarea-b').jqteVal(value);
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
return rJS(this).context.find('#textarea-b').val(); return rJS(this).context.find('#textarea-b').val();
}); });
gk.ready(function () { gk.ready(function () {
var g = rJS(this); var g = rJS(this);
g.context.find("#textarea-b").jqte(); g.context.find("#textarea-b").jqte();
}); });
}(window, $, rJS)) }(window, jQuery, rJS));
...@@ -21,43 +21,49 @@ ...@@ -21,43 +21,49 @@
io_a_context = g.context.find(".editor_a_safe").last(); io_a_context = g.context.find(".editor_a_safe").last();
// editor_b_context = g.context.find(".editor_b").last(), // editor_b_context = g.context.find(".editor_b").last(),
// io_b_context = g.context.find(".editor_b_safe").last(); // io_b_context = g.context.find(".editor_b_safe").last();
;
// First, load the catalog gadget // First, load the catalog gadget
g.declareGadget('./catalog.html', catalog_context).done(function (catalog) { g.declareGadget('./catalog.html', catalog_context).done(
// Fetch the list of editor and io gadgets function (catalog) {
// This is done in 2 different queries to the catalog // Fetch the list of editor and io gadgets
$.when( // This is done in 2 different queries to the catalog
catalog.allDocs( $.when(
{query: 'interface: "http://www.renderjs.org/interface/editor"'}), catalog.allDocs(
catalog.allDocs( {query: 'interface: "http://www.renderjs.org/interface/editor"'}
{query: 'interface: "http://www.renderjs.org/interface/io"'})) ),
.done(function (editor_list, io_list) { catalog.allDocs(
var panel_context = g.context.find(".bare_panel"); {query: 'interface: "http://www.renderjs.org/interface/io"'}
)
).done(function (editor_list, io_list) {
var panel_context = g.context.find(".bare_panel");
// Load 1 editor and 1 IO and plug them // Load 1 editor and 1 IO and plug them
$.when( $.when(
g.declareIframedGadget(editor_list[0].path, editor_a_context), g.declareIframedGadget(editor_list[0].path, editor_a_context),
g.declareGadget(io_list[0].path, io_a_context), g.declareGadget(io_list[0].path, io_a_context),
"officejs").done(attachIOToEditor); "officejs"
).done(attachIOToEditor);
// Fill the panel // Fill the panel
$.each(editor_list, function(i, editor_definition) { $.each(editor_list, function (i, editor_definition) {
panel_context.append( panel_context.append(
'<a href="#" data-role="button" data-icon="edit" ' + '<a href="#" data-role="button" data-icon="edit" ' +
'data-iconpos="left">' + editor_definition.title + '</a>'); 'data-iconpos="left">' + editor_definition.title + '</a>'
panel_context.find('a').last().click(function () { );
$.when( panel_context.find('a').last().click(function () {
g.declareIframedGadget(editor_definition.path, editor_a_context), $.when(
g.declareGadget(io_list[0].path, io_a_context), g.declareIframedGadget(editor_definition.path,
"officejs").done(attachIOToEditor); editor_a_context),
}); g.declareGadget(io_list[0].path, io_a_context),
}); "officejs"
panel_context.trigger('create'); ).done(attachIOToEditor);
}); });
});
}); panel_context.trigger('create');
});
}
);
// $.when( // $.when(
// g.declareGadget('./jqteditor.html', editor_a_context), // g.declareGadget('./jqteditor.html', editor_a_context),
...@@ -70,4 +76,4 @@ ...@@ -70,4 +76,4 @@
// "officejs_b").done(attachIOToEditor); // "officejs_b").done(attachIOToEditor);
}); });
}(window, $, rJS)) }(window, jQuery, rJS));
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