isso/isso/js/app/lib/editor.js
Martin Zimmermann ccf59fba2a initial support for jade
Replace Markup.js with Jade [1] for real templating (like expression
evaluation and sane syntax). Jade compiles directly to JavaScript which
makes it possible to only have Jade as build dependency with a tiny
runtime wrapper for the client (around 40% of Markup.js's size).

Templates are rewritten for Jade but do not use all features from Jade
(such as filters, mixins and includes) for now.

A simple requirejs-jade wrapper to compile Jade during runtime is
already included.

i18n
----

I also rewrote the i18n module and moved translation and pluralization
functions back into the module, thus decoupling it from the previous
markup language. The module now exposes:

  * i18n.translate(msgid) -> string
  * i18n.pluralize(msgid, n) -> string

I18n depends on app/config and thus has access to the user's prefered
language and exposes both function with `i18n.lang` already set. If the
msgid was not found, it returns "???" (like Markup.js).

The pluralization function replaces `{{ n }}` with the function argument
just like with Markup.js (to keep the diffs clean).

[1] http://jade-lang.com/
2014-05-25 23:46:26 +02:00

25 lines
608 B
JavaScript

define(["app/dom", "app/i18n"], function($, i18n) {
"use strict";
return function(el) {
el.setAttribute("contentEditable", true);
el.on("focus", function() {
if (el.classList.contains("placeholder")) {
el.innerHTML = "";
el.classList.remove("placeholder");
}
});
el.on("blur", function() {
if (el.textContent.length === 0) {
el.textContent = i18n.translate("postbox-text");
el.classList.add("placeholder");
}
});
return el;
};
});