diff --git a/src/DebugBar/Resources/widgets.js b/src/DebugBar/Resources/widgets.js index 99e8b17..bbc6a09 100644 --- a/src/DebugBar/Resources/widgets.js +++ b/src/DebugBar/Resources/widgets.js @@ -667,6 +667,7 @@ if (typeof(PhpDebugBar) == 'undefined') { } this.set(options); this.set('autoshow', null); + this.set('sort', localStorage.getItem('debugbar-history-sort') || 'asc'); this.$el.addClass(csscls('dataset-history')) this.renderHead(); @@ -715,12 +716,20 @@ if (typeof(PhpDebugBar) == 'undefined') { this.$table = $(''); - $('' + - '' + - '' + - '' + - '' + - '
DateMethodURLData
') + + $('') + .append($('') + .append($('') + .append($('').css('width', '20px')) + .append($('').css('width', '175px').click(function() { + self.set('sort', self.get('sort') === 'asc' ? 'desc' : 'asc') + localStorage.setItem('debugbar-history-sort', self.get('sort')) + console.log('set sort', self.get('sort')) + })) + .append($('').css('width', '80px')) + .append($('')) + .append($(''))) + ) .append(this.$table) .appendTo(this.$el); @@ -762,7 +771,7 @@ if (typeof(PhpDebugBar) == 'undefined') { this.$table.find('.' + csscls('active')).removeClass(csscls('active')); this.$table.find('tr[data-id=' + this.get('debugbar').activeDatasetId+']').addClass(csscls('active')); }); - this.bindAttr(['itemRenderer', 'search', 'method'], function() { + this.bindAttr(['itemRenderer', 'search', 'method', 'sort'], function() { this.renderDatasets(); }) this.bindAttr(['autoshow'], function() { @@ -780,9 +789,16 @@ if (typeof(PhpDebugBar) == 'undefined') { var meta = data.__meta; var $badges = $('') - .appendTo(widget.$table) - .attr('data-id', meta['id']) + var tr = $(''); + console.log('sorting ' , widget.get('sort')); + if (widget.get('sort') === 'asc') { + tr.appendTo(widget.$table); + } else { + console.log('prepend'); + tr.prependTo(widget.$table); + } + + tr.attr('data-id', meta['id']) .append('') .append('') .append('')
Date ↕MethodURLData'); - var tr = $('
#' + meta['nb'] + '' + meta['datetime'] + '' + meta['method'] + '