[js] remove 3.9 bw compat (where apparently unused)
- cubicweb.ajax.js
- loadxhtml: form.callback support removal
- removal of top-level functions: preprocessAjaxLoad, reloadBox,
replacePageChunk, loadxhtml
- cubicweb.compat.js:
- map is undeprecated (jquery.map being not an acceptable
replacement)
- removal of noop, contains, findValue, filter, addElementClass,
removeElementClass, hasElementClass, KEYS mapping
- htmlhelpers.js: use non-deprecated functions cw.urlEncode
- cubicweb.js:
- removal of startsWith and endsWith monkeypatches
- note deprecated but still used stuff (for action)
- test_utils.js: use cw.utils.sliceList instead of global function
Closes #2782004.
--- a/doc/3.18.rst Mon Aug 26 11:36:19 2013 +0200
+++ b/doc/3.18.rst Mon Aug 26 16:16:22 2013 +0200
@@ -29,4 +29,4 @@
* all 3.8 backward compat is gone
-* all 3.9 backward compat (except javascript side) is gone
+* all 3.9 backward compat (including the javascript side) is gone
--- a/web/data/cubicweb.ajax.js Mon Aug 26 11:36:19 2013 +0200
+++ b/web/data/cubicweb.ajax.js Mon Aug 26 16:16:22 2013 +0200
@@ -339,11 +339,6 @@
cw.log('loadxhtml called without an element');
}
var callback = null;
- if (form && form.callback) {
- cw.log('[3.9] callback given through form.callback is deprecated, add ' + 'callback on the defered');
- callback = form.callback;
- delete form.callback;
- }
var node = this.get(0); // only consider the first element
if (cursor) {
setProgressCursor();
@@ -734,13 +729,7 @@
/* DEPRECATED *****************************************************************/
-preprocessAjaxLoad = cw.utils.deprecatedFunction(
- '[3.9] preprocessAjaxLoad() is deprecated, use loadAjaxHtmlHead instead',
- function(node, newdomnode) {
- return loadAjaxHtmlHead(newdomnode);
- }
-);
-
+// still used in cwo and keyword cubes at least
reloadComponent = cw.utils.deprecatedFunction(
'[3.9] reloadComponent() is deprecated, use loadxhtml instead',
function(compid, rql, registry, nodeid, extraargs) {
@@ -754,52 +743,6 @@
}
);
-reloadBox = cw.utils.deprecatedFunction(
- '[3.9] reloadBox() is deprecated, use loadxhtml instead',
- function(boxid, rql) {
- return reloadComponent(boxid, rql, 'ctxcomponents', boxid);
- }
-);
-
-replacePageChunk = cw.utils.deprecatedFunction(
- '[3.9] replacePageChunk() is deprecated, use loadxhtml instead',
- function(nodeId, rql, vid, extraparams, /* ... */ swap, callback) {
- var params = null;
- if (callback) {
- params = {
- callback: callback
- };
- }
- var node = jQuery('#' + nodeId)[0];
- var props = {};
- if (node) {
- props['rql'] = rql;
- props['fname'] = 'view';
- props['pageid'] = pageid;
- if (vid) {
- props['vid'] = vid;
- }
- if (extraparams) {
- jQuery.extend(props, extraparams);
- }
- // FIXME we need to do asURL(props) manually instead of
- // passing `props` directly to loadxml because replacePageChunk
- // is sometimes called (abusively) with some extra parameters in `vid`
- var mode = swap ? 'swap': 'replace';
- var url = AJAX_BASE_URL + asURL(props);
- jQuery(node).loadxhtml(url, params, 'get', mode);
- } else {
- cw.log('Node', nodeId, 'not found');
- }
- }
-);
-
-loadxhtml = cw.utils.deprecatedFunction(
- '[3.9] loadxhtml() function is deprecated, use loadxhtml method instead',
- function(nodeid, url, /* ... */ replacemode) {
- jQuery('#' + nodeid).loadxhtml(url, null, 'post', replacemode);
- }
-);
function remoteExec(fname /* ... */) {
setProgressCursor();
--- a/web/data/cubicweb.compat.js Mon Aug 26 11:36:19 2013 +0200
+++ b/web/data/cubicweb.compat.js Mon Aug 26 16:16:22 2013 +0200
@@ -1,34 +1,3 @@
-cw.utils.movedToNamespace(['log', 'jqNode', 'getNode', 'evalJSON', 'urlEncode',
- 'swapDOM'], cw);
-cw.utils.movedToNamespace(['nodeWalkDepthFirst', 'formContents', 'isArray',
- 'isString', 'isArrayLike', 'sliceList',
- 'toISOTimestamp'], cw.utils);
-
-
-if ($.noop === undefined) {
- function noop() {}
-} else {
- noop = cw.utils.deprecatedFunction(
- '[3.9] noop() is deprecated, use $.noop() instead (XXX requires jQuery 1.4)',
- $.noop);
-}
-
-// ========== ARRAY EXTENSIONS ========== ///
-Array.prototype.contains = cw.utils.deprecatedFunction(
- '[3.9] array.contains(elt) is deprecated, use $.inArray(elt, array)!=-1 instead',
- function(element) {
- return jQuery.inArray(element, this) != - 1;
- }
-);
-
-// ========== END OF ARRAY EXTENSIONS ========== ///
-forEach = cw.utils.deprecatedFunction(
- '[3.9] forEach() is deprecated, use $.each() instead',
- function(array, func) {
- return $.each(array, func);
- }
-);
-
/**
* .. function:: cw.utils.deprecatedFunction(msg, function)
*
@@ -41,64 +10,20 @@
* [ ["a", "b", "c"], ["d", "e"] ]
*/
// XXX why not the same argument order as $.map and forEach ?
-map = cw.utils.deprecatedFunction(
- '[3.9] map() is deprecated, use $.map instead',
- function(func, array) {
- var result = [];
- for (var i = 0, length = array.length; i < length; i++) {
- result.push(func(array[i]));
- }
- return result;
- }
-);
-findValue = cw.utils.deprecatedFunction(
- '[3.9] findValue(array, elt) is deprecated, use $.inArray(elt, array) instead',
- function(array, element) {
- return jQuery.inArray(element, array);
- }
-);
-
-filter = cw.utils.deprecatedFunction(
- '[3.9] filter(func, array) is deprecated, use $.grep(array, f) instead',
- function(func, array) {
- return $.grep(array, func);
+function map(func, array) {
+ var result = [];
+ for (var i = 0, length = array.length; i < length; i++) {
+ result.push(func(array[i]));
}
-);
-
-addElementClass = cw.utils.deprecatedFunction(
- '[3.9] addElementClass(node, cls) is deprecated, use $(node).addClass(cls) instead',
- function(node, klass) {
- $(node).addClass(klass);
- }
-);
+ return result;
+}
-removeElementClass = cw.utils.deprecatedFunction(
- '[3.9] removeElementClass(node, cls) is deprecated, use $(node).removeClass(cls) instead',
- function(node, klass) {
- $(node).removeClass(klass);
- }
-);
-hasElementClass = cw.utils.deprecatedFunction(
- '[3.9] hasElementClass(node, cls) is deprecated, use $(node).hasClass(cls)',
- function(node, klass) {
- return $(node).hasClass(klass);
- }
-);
-
+// skm cube still uses this
getNodeAttribute = cw.utils.deprecatedFunction(
'[3.9] getNodeAttribute(node, attr) is deprecated, use $(node).attr(attr)',
function(node, attribute) {
return $(node).attr(attribute);
}
);
-
-/**
- * The only known usage of KEYS is in the tag cube. Once cubicweb-tag 1.7.0 is out,
- * this current definition can be removed.
- */
-var KEYS = {
- KEY_ESC: 27,
- KEY_ENTER: 13
-};
--- a/web/data/cubicweb.htmlhelpers.js Mon Aug 26 11:36:19 2013 +0200
+++ b/web/data/cubicweb.htmlhelpers.js Mon Aug 26 16:16:22 2013 +0200
@@ -78,10 +78,10 @@
// generate a list of couple key=value if key is multivalued
if (cw.utils.isArrayLike(value)) {
for (var i = 0; i < value.length; i++) {
- chunks.push(key + '=' + urlEncode(value[i]));
+ chunks.push(key + '=' + cw.urlEncode(value[i]));
}
} else {
- chunks.push(key + '=' + urlEncode(value));
+ chunks.push(key + '=' + cw.urlEncode(value));
}
}
return chunks.join('&');
--- a/web/data/cubicweb.js Mon Aug 26 11:36:19 2013 +0200
+++ b/web/data/cubicweb.js Mon Aug 26 16:16:22 2013 +0200
@@ -105,15 +105,6 @@
};
},
- movedToNamespace: function (funcnames, namespace) {
- for (var i = 0; i < funcnames.length; i++) {
- var funcname = funcnames[i];
- var msg = ('[3.9] ' + funcname + ' is deprecated, use ' +
- namespace.__name__ + '.' + funcname + ' instead');
- window[funcname] = cw.utils.deprecatedFunction(msg, namespace[funcname]);
- }
- },
-
createDomFunction: function (tag) {
function builddom(params, children) {
var node = document.createElement(tag);
@@ -388,14 +379,6 @@
});
-String.prototype.startsWith = cw.utils.deprecatedFunction('[3.9] str.startsWith() is deprecated, use str.startswith() instead', function (prefix) {
- return this.startswith(prefix);
-});
-
-String.prototype.endsWith = cw.utils.deprecatedFunction('[3.9] str.endsWith() is deprecated, use str.endswith() instead', function (suffix) {
- return this.endswith(prefix);
-});
-
/** DOM factories ************************************************************/
A = cw.utils.createDomFunction('a');
BUTTON = cw.utils.createDomFunction('button');
@@ -472,7 +455,8 @@
return node;
}
-// XXX avoid crashes / backward compat
+// cubes: tag, keyword and apycot seem to use this, including require/provide
+// backward compat
CubicWeb = cw;
jQuery.extend(cw, {
--- a/web/test/jstests/test_utils.js Mon Aug 26 11:36:19 2013 +0200
+++ b/web/test/jstests/test_utils.js Mon Aug 26 16:16:22 2013 +0200
@@ -47,11 +47,11 @@
module("sliceList");
test("test slicelist", function() {
var list = ['a', 'b', 'c', 'd', 'e', 'f'];
- same(sliceList(list, 2), ['c', 'd', 'e', 'f']);
- same(sliceList(list, 2, -2), ['c', 'd']);
- same(sliceList(list, -3), ['d', 'e', 'f']);
- same(sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
- same(sliceList(list), list);
+ same(cw.utils.sliceList(list, 2), ['c', 'd', 'e', 'f']);
+ same(cw.utils.sliceList(list, 2, -2), ['c', 'd']);
+ same(cw.utils.sliceList(list, -3), ['d', 'e', 'f']);
+ same(cw.utils.sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
+ same(cw.utils.sliceList(list), list);
});
module("formContents", {
@@ -83,7 +83,7 @@
'value="one" />');
$('#test-form').append('<input name="unchecked-choice" type="radio" ' +
'value="two"/>');
- same(formContents($('#test-form')[0]), [
+ same(cw.utils.formContents($('#test-form')[0]), [
['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
['toto', 'Hello World!', 'no', 'no', 'foo']
]);