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

JSLint examples.

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