Commit e1ab9098 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core/rjs] Move functions unrelated to ERP5JS

parent 1e3f897f
......@@ -64,7 +64,6 @@
{{/each}}
</script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_ojs_appstore_panel.js" type="text/javascript"></script>
</head>
......
......@@ -261,7 +261,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.40404.23731.64460</string> </value>
<value> <string>974.49722.57911.23261</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -279,7 +279,7 @@
</tuple>
<state>
<tuple>
<float>1549966400.8</float>
<float>1554193742.32</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,6 +10,8 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_list_sr.js" type="text/javascript"></script>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.15770.42024.56900</string> </value>
<value> <string>974.28140.2414.14967</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1506095929.53</float>
<float>1554190473.4</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -11,6 +11,8 @@
<!-- custom script -->
<script src="handlebars.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_view_discussable.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="gadget_erp5_pt_form_view_discussable.css">
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.25925.39167.29235</string> </value>
<value> <string>974.28140.2414.14967</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,8 +250,8 @@
</tuple>
<state>
<tuple>
<float>1539136980.8</float>
<string>GMT+9</string>
<float>1554190620.27</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -11,7 +11,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_field_checkbox.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41948.43293.53384</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536676292.86</float>
<float>1554190747.8</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, RSVP, Array, isNaN */
/*global window, RSVP */
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true */
(function (window, RSVP, Array, isNaN) {
(function (window, RSVP) {
"use strict";
window.calculatePageTitle = function (gadget, erp5_document) {
......@@ -15,62 +15,4 @@
});
};
/** Return true if the value truly represents an empty value.
Calling isEmpty(x) is more robust than expression !x.
*/
function isEmpty(value) {
return (value === undefined ||
value === null ||
value.length === 0 ||
(typeof value === "number" && isNaN(value)));
}
window.isEmpty = isEmpty;
/** Make sure that returned object is an Array instance.
*/
function ensureArray(obj) {
if (Array.isArray(obj)) {return obj; }
if (isEmpty(obj)) {return []; }
return [obj];
}
window.ensureArray = ensureArray;
/** Return first non-empty variable or the last one.
Calling getNonEmpy(a, b, "") is more robust way of writing a || b || "".
Variables coercing to false (e.g 0) do not get skipped anymore.
*/
function getFirstNonEmpty() {
var i;
if (arguments.length === 0) {
return null;
}
for (i = 0; i < arguments.length; i++) {
if (!isEmpty(arguments[i])) {
return arguments[i];
}
}
if (arguments.length === 1) {
return arguments[0];
}
return arguments[arguments.length - 1];
}
window.getFirstNonEmpty = getFirstNonEmpty;
/** Convert anything to boolean value correctly (even "false" will be false)*/
function asBoolean(obj) {
if (typeof obj === "boolean") {
return obj;
}
if (typeof obj === "string") {
return obj.toLowerCase() === "true" || obj === "1";
}
if (typeof obj === "number") {
return obj !== 0;
}
return Boolean(obj);
}
window.asBoolean = asBoolean;
}(window, RSVP, Array, isNaN));
\ No newline at end of file
}(window, RSVP));
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.21896.64692.61286</string> </value>
<value> <string>974.44086.53634.17646</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1517998628.97</float>
<float>1553855476.61</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -11,7 +11,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_field_integer.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41950.24275.12441</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536676423.04</float>
<float>1554190792.13</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_field_list.js" type="text/javascript"></script>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41950.36963.1058</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536676455.68</float>
<float>1554190834.99</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_field_multilist.js" type="text/javascript"></script>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41951.3609.45158</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536676574.3</float>
<float>1554190875.69</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,7 +21,7 @@ data-i18n=Data received.
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_form.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536847739.65</float>
<float>1554191060.89</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -25,7 +25,6 @@
<script src="gadget_global.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_panel.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.20312.1477.42820</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1540979971.49</float>
<float>1554191121.16</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -22,6 +22,7 @@
</script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_dialog.js" type="text/javascript"></script>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.21379.40755.25053</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1537196435.99</float>
<float>1554191174.22</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -17,6 +17,8 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_list.js" type="text/javascript"></script>
......
......@@ -12,6 +12,8 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_view_editable.js" type="text/javascript"></script>
......
......@@ -12,7 +12,6 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_embedded_form_render.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1537194949.32</float>
<float>1554191324.36</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,8 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_pt_form_view.js" type="text/javascript"></script>
......
......@@ -11,7 +11,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_html5_element.js" type="text/javascript"></script>
</head>
<body></body>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.56687.10652.34269</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536678959.03</float>
<float>1554191432.29</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,7 +12,7 @@
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_html5_input.js" type="text/javascript"></script>
</head>
<body><input /></body>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41878.18586.48810</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1536678950.48</float>
<float>1554191455.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_html5_select.js" type="text/javascript"></script>
</head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.18802.57121.64187</string> </value>
<value> <string>973.40657.63647.56780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1540889118.86</float>
<float>1554191494.27</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,6 +3,65 @@
(function (window, RSVP, FileReader) {
"use strict";
/** Return true if the value truly represents an empty value.
Calling isEmpty(x) is more robust than expression !x.
*/
function isEmpty(value) {
return (value === undefined ||
value === null ||
value.length === 0 ||
(typeof value === "number" && isNaN(value)));
}
window.isEmpty = isEmpty;
/** Make sure that returned object is an Array instance.
*/
function ensureArray(obj) {
if (Array.isArray(obj)) {return obj; }
if (isEmpty(obj)) {return []; }
return [obj];
}
window.ensureArray = ensureArray;
/** Return first non-empty variable or the last one.
Calling getNonEmpy(a, b, "") is more robust way of writing a || b || "".
Variables coercing to false (e.g 0) do not get skipped anymore.
*/
function getFirstNonEmpty(first_argument) {
var i;
if (arguments.length === 0) {
return null;
}
for (i = 0; i < arguments.length; i += 1) {
if (!isEmpty(arguments[i])) {
return arguments[i];
}
}
if (arguments.length === 1) {
return first_argument;
}
return arguments[arguments.length - 1];
}
window.getFirstNonEmpty = getFirstNonEmpty;
/** Convert anything to boolean value correctly (even "false" will be false)*/
function asBoolean(obj) {
if (typeof obj === "boolean") {
return obj;
}
if (typeof obj === "string") {
return obj.toLowerCase() === "true" || obj === "1";
}
if (typeof obj === "number") {
return obj !== 0;
}
return Boolean(obj);
}
window.asBoolean = asBoolean;
window.loopEventListener = function (target, type, useCapture, callback,
prevent_default) {
//////////////////////////
......
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