Commit 31cb3d4b authored by JC Brand's avatar JC Brand

Fix the non-AMD case.

parent 0a1a98d2
......@@ -4,6 +4,7 @@ module.exports = function(grunt) {
jst: {
compile: {
options: {
namespace: 'templates',
templateSettings: {
evaluate : /\{\[([\s\S]+?)\]\}/g,
interpolate : /\{\{([\s\S]+?)\}\}/g
......@@ -20,6 +21,20 @@ module.exports = function(grunt) {
}
},
json: {
main: {
options: {
namespace: 'locales',
includePath: true,
processName: function(filename) {
return filename.toLowerCase().match(/^locale\/(.*)\/lc_messages/)[1];
}
},
src: ['locale/**/LC_MESSAGES/*.json'],
dest: 'builds/locales.js'
}
},
jshint: {
options: {
trailing: true
......@@ -52,6 +67,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-json');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('test', 'Run Tests', function () {
......
This diff is collapsed.
This diff is collapsed.
......@@ -37,7 +37,7 @@
}
);
} else {
root.converse = factory(jQuery, _, OTR, DSA, JST, moment, utils);
root.converse = factory(jQuery, _, OTR, DSA, templates, moment, utils);
}
}(this, function ($, _, OTR, DSA, templates, moment, utils) {
// "use strict";
......@@ -282,6 +282,8 @@
// Allow only whitelisted configuration attributes to be overwritten
_.extend(this, _.pick(settings, Object.keys(default_settings)));
this.jed = new Jed(this.i18n);
if (settings.visible_toolbar_buttons) {
_.extend(
this.visible_toolbar_buttons,
......
......@@ -13,7 +13,6 @@
<link type="text/css" rel="stylesheet" media="screen" href="components/fontawesome/css/font-awesome.min.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script type="text/javascript" src="analytics.js"></script>
<script data-main="main" src="components/requirejs/require.js"></script>
</head>
......
......@@ -7,40 +7,6 @@
(function (root, factory) {
define("locales", ['jquery', 'jed',
'text!af',
'text!de',
'text!en',
'text!es',
'text!fr',
'text!he',
'text!hu',
'text!id',
'text!it',
'text!ja',
'text!nb',
'text!nl',
'text!pl',
'text!pt_BR',
'text!ru',
'text!zh'
], function ($, Jed, af, de, en, es, fr, he, hu, id, it, ja, nb, nl, pl, pt_BR, ru, zh) {
root.locales = {
'af': new Jed($.parseJSON(af)),
'de': new Jed($.parseJSON(de)),
'en': new Jed($.parseJSON(en)),
'es': new Jed($.parseJSON(es)),
'fr': new Jed($.parseJSON(fr)),
'he': new Jed($.parseJSON(he)),
'hu': new Jed($.parseJSON(hu)),
'id': new Jed($.parseJSON(id)),
'it': new Jed($.parseJSON(it)),
'ja': new Jed($.parseJSON(ja)),
'nb': new Jed($.parseJSON(nb)),
'nl': new Jed($.parseJSON(nl)),
'pl': new Jed($.parseJSON(pl)),
'pt-br': new Jed($.parseJSON(pt_BR)),
'ru': new Jed($.parseJSON(ru)),
'zh': new Jed($.parseJSON(zh))
};
});
})(this);
This diff is collapsed.
......@@ -40,6 +40,7 @@
"po2json": "^0.3.0"
},
"dependencies": {
"grunt-json": "^0.1.3",
"requirejs": "~2.1.11"
}
}
define(["jquery", "converse-templates"], function ($, templates) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(["jquery", "converse-templates", "locales"], factory);
} else {
root.utils = factory(jQuery, templates);
}
}(this, function ($, templates) {
"use strict";
var XFORM_TYPE_MAP = {
......@@ -49,10 +55,13 @@ define(["jquery", "converse-templates"], function ($, templates) {
// ---------------------
__: function (str) {
// Translation factory
if (this.i18n === undefined) {
if (typeof this.i18n === "undefined") {
this.i18n = locales.en;
}
var t = this.i18n.translate(str);
if (typeof this.jed === "undefined") {
this.jed = new Jed(this.i18n);
}
var t = this.jed.translate(str);
if (arguments.length>1) {
return t.fetch.apply(t, [].slice.call(arguments,1));
} else {
......@@ -73,10 +82,10 @@ define(["jquery", "converse-templates"], function ($, templates) {
webForm2xForm: function (field) {
/* Takes an HTML DOM and turns it into an XForm field.
*
* Parameters:
* (DOMElement) field - the field to convert
*/
*
* Parameters:
* (DOMElement) field - the field to convert
*/
var $input = $(field), value;
if ($input.is('[type=checkbox]')) {
value = $input.is(':checked') && 1 || 0;
......@@ -100,11 +109,11 @@ define(["jquery", "converse-templates"], function ($, templates) {
xForm2webForm: function ($field, $stanza) {
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format
* and turns it into a HTML DOM field.
*
* Parameters:
* (XMLElement) field - the field to convert
*/
* and turns it into a HTML DOM field.
*
* Parameters:
* (XMLElement) field - the field to convert
*/
// FIXME: take <required> into consideration
var options = [], j, $options, $values, value, values;
......@@ -186,4 +195,4 @@ define(["jquery", "converse-templates"], function ($, templates) {
}
};
return utils;
});
}));
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