mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
UI Cleanup - Updated Shared and Shims subtrees.
This commit is contained in:
@@ -1,116 +1,144 @@
|
||||
module.exports = function() {
|
||||
var backgrid = this;
|
||||
var Backgrid = this;
|
||||
|
||||
backgrid.SonarrHeaderCell = backgrid.HeaderCell.extend({
|
||||
events : {
|
||||
Backgrid.SonarrHeaderCell = Backgrid.HeaderCell.extend({
|
||||
events : {
|
||||
'click' : 'onClick'
|
||||
},
|
||||
_originalInit : backgrid.HeaderCell.prototype.initialize,
|
||||
initialize : function(options){
|
||||
|
||||
_originalInit : Backgrid.HeaderCell.prototype.initialize,
|
||||
|
||||
initialize : function(options) {
|
||||
this._originalInit.call(this, options);
|
||||
|
||||
this.listenTo(this.collection, 'drone:sort', this.render);
|
||||
},
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
this.$el.append(this.column.get('label'));
|
||||
|
||||
var column = this.column;
|
||||
var sortable = backgrid.callByNeed(column.sortable(), column, this.collection);
|
||||
if(sortable) {
|
||||
var sortable = Backgrid.callByNeed(column.sortable(), column, this.collection);
|
||||
|
||||
if (sortable) {
|
||||
this.$el.addClass('sortable');
|
||||
this.$el.append(' <i class="pull-right"></i>');
|
||||
}
|
||||
|
||||
//Do we need this?
|
||||
this.$el.addClass(column.get('name'));
|
||||
if(column.has('className')) {
|
||||
|
||||
if (column.has('className')) {
|
||||
this.$el.addClass(column.get('className'));
|
||||
}
|
||||
|
||||
this.delegateEvents();
|
||||
this.direction(column.get('direction'));
|
||||
if(this.collection.state) {
|
||||
|
||||
if (this.collection.state) {
|
||||
var name = this._getSortMapping().name;
|
||||
var order = this.collection.state.order;
|
||||
if(name === column.get('name')) {
|
||||
|
||||
if (name === column.get('name')) {
|
||||
this._setSortIcon(order);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._removeSortIcon();
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
direction : function(dir){
|
||||
|
||||
direction : function(dir) {
|
||||
this.$el.children('i').removeClass('icon-sort-up icon-sort-down');
|
||||
if(arguments.length) {
|
||||
if(dir) {
|
||||
|
||||
if (arguments.length) {
|
||||
if (dir) {
|
||||
this._setSortIcon(dir);
|
||||
}
|
||||
|
||||
this.column.set('direction', dir);
|
||||
}
|
||||
|
||||
var columnDirection = this.column.get('direction');
|
||||
if(!columnDirection && this.collection.state) {
|
||||
|
||||
if (!columnDirection && this.collection.state) {
|
||||
var name = this._getSortMapping().name;
|
||||
var order = this.collection.state.order;
|
||||
if(name === this.column.get('name')) {
|
||||
|
||||
if (name === this.column.get('name')) {
|
||||
columnDirection = order;
|
||||
}
|
||||
}
|
||||
|
||||
return columnDirection;
|
||||
},
|
||||
_getSortMapping : function(){
|
||||
|
||||
_getSortMapping : function() {
|
||||
var sortKey = this.collection.state.sortKey;
|
||||
if(this.collection._getSortMapping) {
|
||||
|
||||
if (this.collection._getSortMapping) {
|
||||
return this.collection._getSortMapping(sortKey);
|
||||
}
|
||||
|
||||
return {
|
||||
name : sortKey,
|
||||
sortKey : sortKey
|
||||
};
|
||||
},
|
||||
onClick : function(e){
|
||||
|
||||
onClick : function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var collection = this.collection;
|
||||
var event = 'backgrid:sort';
|
||||
|
||||
var column = this.column;
|
||||
var sortable = backgrid.callByNeed(column.sortable(), column, collection);
|
||||
if(sortable) {
|
||||
var sortable = Backgrid.callByNeed(column.sortable(), column, collection);
|
||||
if (sortable) {
|
||||
var direction = collection.state.order;
|
||||
if(direction === 'ascending' || direction === -1) {
|
||||
if (direction === 'ascending' || direction === -1) {
|
||||
direction = 'descending';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
direction = 'ascending';
|
||||
}
|
||||
if(collection.setSorting) {
|
||||
|
||||
if (collection.setSorting) {
|
||||
collection.setSorting(column.get('name'), direction);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
collection.state.sortKey = column.get('name');
|
||||
collection.state.order = direction;
|
||||
}
|
||||
collection.trigger(event, column, direction);
|
||||
}
|
||||
},
|
||||
_resetCellDirection : function(columnToSort, direction){
|
||||
if(columnToSort !== this.column) {
|
||||
|
||||
_resetCellDirection : function(columnToSort, direction) {
|
||||
if (columnToSort !== this.column) {
|
||||
this.direction(null);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.direction(direction);
|
||||
}
|
||||
},
|
||||
_convertDirectionToIcon : function(dir){
|
||||
if(dir === 'ascending' || dir === -1) {
|
||||
|
||||
_convertDirectionToIcon : function(dir) {
|
||||
if (dir === 'ascending' || dir === -1) {
|
||||
return 'icon-sort-up';
|
||||
}
|
||||
|
||||
return 'icon-sort-down';
|
||||
},
|
||||
_setSortIcon : function(dir){
|
||||
|
||||
_setSortIcon : function(dir) {
|
||||
this._removeSortIcon();
|
||||
this.$el.children('i').addClass(this._convertDirectionToIcon(dir));
|
||||
},
|
||||
_removeSortIcon : function(){
|
||||
|
||||
_removeSortIcon : function() {
|
||||
this.$el.children('i').removeClass('icon-sort-up icon-sort-down');
|
||||
}
|
||||
});
|
||||
|
||||
return backgrid.SonarrHeaderCell;
|
||||
return Backgrid.SonarrHeaderCell;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user