From: Mike Taylor Date: Fri, 17 Oct 2014 16:35:41 +0000 (+0100) Subject: The selectorForAllWidgets function looks for elements whose classes X-Git-Tag: 1.0.0~155^2~11 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=033c287ec63e95848ef6b5f637b07cc20d5016db The selectorForAllWidgets function looks for elements whose classes match either old- or new-style widget-type names. --- diff --git a/src/mkws-core.js b/src/mkws-core.js index df7382f..36323af 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -296,6 +296,14 @@ mkws.log("Using window.name '" + window.name + "'"); 'Perpage': 'per-page', 'SearchForm': 'search-form', }; + // Annoyingly, there is no built-in way to invert a hash + var _new2old = {}; + for (var key in _old2new) { + if(_old2new.hasOwnProperty(key)) { + _new2old[_old2new[key]] = key; + } + } + function handleNodeWithTeam(node, callback) { // First branch for DOM objects; second branch for jQuery objects @@ -461,7 +469,11 @@ mkws.log("Using window.name '" + window.name + "'"); s += '.mkws-' + type; s += ',.mkws-' + type + "-container-wide"; s += ',.mkws-' + type + "-container-narrow"; - // ### Do we need to do something about old-style names? + // Annoyingly, we also need to recognise old-style names + var oldtype = _new2old[type] || type.charAt(0).toUpperCase() + type.slice(1); + s += ',.mkws' + oldtype; + s += ',.mkws' + oldtype + "-Container-wide"; + s += ',.mkws' + oldtype + "-Container-narrow"; } return s; }