diff --git a/src/_h5ai/client/js/inc/core/event.js b/src/_h5ai/client/js/inc/core/event.js index ad94b3cb..1873a5ca 100644 --- a/src/_h5ai/client/js/inc/core/event.js +++ b/src/_h5ai/client/js/inc/core/event.js @@ -1,7 +1,8 @@ modulejs.define('core/event', ['_'], function (_) { - var subscriptions = {}, + var slice = Array.prototype.slice, + subscriptions = {}, sub = function (topic, callback) { @@ -24,7 +25,7 @@ modulejs.define('core/event', ['_'], function (_) { pub = function (topic, data) { - var args = Array.prototype.slice.call(arguments, 1); + var args = slice.call(arguments, 1); // console.log('EVENT PUB', topic, args); if (_.isString(topic) && subscriptions[topic]) { diff --git a/src/_h5ai/client/js/inc/core/format.js b/src/_h5ai/client/js/inc/core/format.js index d2267d5c..9d6cc225 100644 --- a/src/_h5ai/client/js/inc/core/format.js +++ b/src/_h5ai/client/js/inc/core/format.js @@ -14,15 +14,9 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { defaultMetric = decimalMetric, defaultDateFormat = 'YYYY-MM-DD HH:mm', - setDefaultMetric = function (metric) { + setDefaultMetric = function (useBinaryMetric) { - if (!metric) { - defaultMetric = decimalMetric; - } else if (metric === true) { - defaultMetric = binaryMetric; - } else { - defaultMetric = metric; - } + defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric; }, formatSize = function (size, metric) { @@ -48,13 +42,9 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { defaultDateFormat = dateFormat; }, - formatDate = function (millis, dateFormat) { + formatDate = function (millis) { - if (!_.isNumber(millis) || !millis) { - return ''; - } - - return moment(millis).format(dateFormat || defaultDateFormat); + return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : ''; }; return { diff --git a/src/_h5ai/client/js/inc/ext/sort.js b/src/_h5ai/client/js/inc/ext/sort.js index 485497c3..268f6a43 100644 --- a/src/_h5ai/client/js/inc/ext/sort.js +++ b/src/_h5ai/client/js/inc/ext/sort.js @@ -65,7 +65,14 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e $all.removeClass('ascending').removeClass('descending'); order.head.addClass(order.clas); - $('#items .item').detach().sort(order.fn).appendTo('#items'); + var current = $('#items .item'); + var sorted = $('#items .item').sort(order.fn); + for (var i = 0, l = current.length; i < l; i += 1) { + if (current[i] !== sorted[i]) { + sorted.detach().sort(order.fn).appendTo('#items'); + break; + } + } }, onContentChanged = function (item) { diff --git a/src/_h5ai/client/js/inc/view/items.js b/src/_h5ai/client/js/inc/view/items.js index 5e3a99de..b2b2acbd 100644 --- a/src/_h5ai/client/js/inc/view/items.js +++ b/src/_h5ai/client/js/inc/view/items.js @@ -16,7 +16,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core '' + '', hintTemplate = '', - itemsTemplate = '