diff --git a/apps/common/main/lib/component/ListView.js b/apps/common/main/lib/component/ListView.js index c23ff7584b..7cc118100a 100644 --- a/apps/common/main/lib/component/ListView.js +++ b/apps/common/main/lib/component/ListView.js @@ -66,39 +66,52 @@ define([ ].join('')), initialize : function(options) { - Common.UI.DataView.prototype.initialize.call(this, options); - if(this.options.initSort != null) { this.activeSortType = this.options.initSort.type; this.sortDirection = this.options.initSort.direction; } + Common.UI.DataView.prototype.initialize.call(this, options); }, + render: function() { + Common.UI.DataView.prototype.render.call(this); + this.insertHeaders(); + }, + insertHeaders: function() { if(this.options.headers.length == 0) return; var template = _.template([ - '
', - '<% _.each(headers, function(header){ %>', - '<%if (header.sortType) { %>', - '
', - '', - '', - '
', - '', - '
', - '
', - '<%} else { %>', - '', - '<%}%>', - '<% }); %>', + '
', + '
', + '<% _.each(headers, function(header){ %>', + '<%if (header.sortType) { %>', + '
', + '', + '', + '
', + '', + '
', + '
', + '<%} else { %>', + '', + '<%}%>', + '<% }); %>', + '
', '
' - ].join(''))({headers: this.options.headers, activeSortType: this.activeSortType, sortDirection: this.sortDirection}); - this.$el.find('.listview').prepend(template); + ].join(''))({ + headers: this.options.headers, + activeSortType: this.options.initSort ? this.options.initSort.type : null, + sortDirection: this.options.initSort ? this.options.initSort.direction : null + }); + this.$el.before(template); - var me = this; - this.$el.find('.table-header-item .header-sorted').on('click', function(e) { - var selectedSortType = $(e.currentTarget).parent().attr('sort-type'); + var me = this, + headerEl = this.$el.prev(); + + headerEl.find('.table-header-item .header-sorted').on('click', function(e) { + var selectedSortType = $(e.currentTarget).parent().attr('sort-type'), + curCaretEl = $(e.currentTarget).find('.caret'); if(me.activeSortType === selectedSortType){ me.sortDirection = -me.sortDirection @@ -108,8 +121,16 @@ define([ me.sortDirection = 1; } + headerEl.find('.caret').addClass('hidden'); + + if(curCaretEl.removeClass('hidden')); + if(me.sortDirection == -1) + curCaretEl.addClass('sort-desc'); + else + curCaretEl.removeClass('sort-desc'); + + me.trigger('header:click', me.activeSortType, me.sortDirection); - me.focus(); }); }, @@ -141,7 +162,6 @@ define([ this.innerEl = null; Common.UI.DataView.prototype.onResetItems.call(this); this.trigger('items:reset', this); - this.insertHeaders(); }, createNewItem: function(record) { diff --git a/apps/common/main/resources/less/listview.less b/apps/common/main/resources/less/listview.less index b23a3b7336..3b69b40f02 100644 --- a/apps/common/main/resources/less/listview.less +++ b/apps/common/main/resources/less/listview.less @@ -3,6 +3,7 @@ border: @scaled-one-px-value solid @border-regular-control; .border-radius(@border-radius-small); line-height: 15px; + padding-top: 21px; &.inner { width: 100%; @@ -28,25 +29,8 @@ border-color: @border-control-focus; } - .table-header { - border-bottom: @scaled-one-px-value-ie solid @border-regular-control-ie; - border-bottom: @scaled-one-px-value solid @border-regular-control; - padding: 3px 6px; - - .table-header-item { - color: @text-tertiary-ie; - color: @text-tertiary; - display: inline-block; - - .caret { - border-color: @text-tertiary-ie; - border-color: @text-tertiary; - } - } - } - & > .item { -// display: block; + // display: block; text-overflow: ellipsis; padding: 3px 6px; cursor: pointer; @@ -103,6 +87,35 @@ } } +.listview-table-header-wrapper { + width: 100%; + position: relative; + + .listview-table-header { + z-index: 1; + background-color: @background-normal-ie; + background-color: @background-normal; + border-bottom: @scaled-one-px-value-ie solid @border-regular-control-ie; + border-bottom: @scaled-one-px-value solid @border-regular-control; + padding: 3px 6px; + position: absolute; + margin: @scaled-one-px-value; + width: calc(100% - 2 * @scaled-one-px-value); + + .table-header-item { + color: @text-tertiary-ie; + color: @text-tertiary; + display: inline-block; + + .caret { + border-color: @text-tertiary-ie; + border-color: @text-tertiary; + } + } + } +} + + .no-borders > .listview .item { border-color: transparent; border-top-color: transparent; diff --git a/apps/spreadsheeteditor/main/app/template/NameManagerDlg.template b/apps/spreadsheeteditor/main/app/template/NameManagerDlg.template index f31bc01d04..8e650a1c18 100644 --- a/apps/spreadsheeteditor/main/app/template/NameManagerDlg.template +++ b/apps/spreadsheeteditor/main/app/template/NameManagerDlg.template @@ -9,7 +9,7 @@ -
+
diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template index d0b4f3e3c3..3ed8e4a7fb 100644 --- a/apps/spreadsheeteditor/main/app/template/SortDialog.template +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -13,7 +13,7 @@ -
+