[#340] jshint cleanup of view.slickgrid.js
This commit is contained in:
@@ -39,7 +39,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
this.model.records.bind('add', this.render);
|
this.model.records.bind('add', this.render);
|
||||||
this.model.records.bind('reset', this.render);
|
this.model.records.bind('reset', this.render);
|
||||||
this.model.records.bind('remove', this.render);
|
this.model.records.bind('remove', this.render);
|
||||||
this.model.records.bind('change', this.onRecordChanged, this)
|
this.model.records.bind('change', this.onRecordChanged, this);
|
||||||
|
|
||||||
var state = _.extend({
|
var state = _.extend({
|
||||||
hiddenColumns: [],
|
hiddenColumns: [],
|
||||||
@@ -52,7 +52,6 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
}, modelEtc.state
|
}, modelEtc.state
|
||||||
|
|
||||||
);
|
);
|
||||||
// this.grid_options = modelEtc.options;
|
|
||||||
this.state = new recline.Model.ObjectState(state);
|
this.state = new recline.Model.ObjectState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -95,25 +94,25 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
_.each(this.model.fields.toJSON(),function(field){
|
_.each(this.model.fields.toJSON(),function(field){
|
||||||
var column = {
|
var column = {
|
||||||
id:field['id'],
|
id:field.id,
|
||||||
name:field['label'],
|
name:field.label,
|
||||||
field:field['id'],
|
field:field.id,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
minWidth: 80,
|
minWidth: 80,
|
||||||
formatter: formatter
|
formatter: formatter
|
||||||
};
|
};
|
||||||
|
|
||||||
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column == field.id});
|
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column == field.id;});
|
||||||
if (widthInfo){
|
if (widthInfo){
|
||||||
column['width'] = widthInfo.width;
|
column.width = widthInfo.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column == field.id});
|
var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column == field.id;});
|
||||||
if (editInfo){
|
if (editInfo){
|
||||||
column['editor'] = editInfo.editor;
|
column.editor = editInfo.editor;
|
||||||
}
|
}
|
||||||
columns.push(column);
|
columns.push(column);
|
||||||
});
|
});
|
||||||
@@ -159,18 +158,18 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
this.push = function(model, row) {
|
this.push = function(model, row) {
|
||||||
models.push(model);
|
models.push(model);
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getLength = function() { return rows.length; }
|
this.getLength = function() {return rows.length; };
|
||||||
this.getItem = function(index) { return rows[index];}
|
this.getItem = function(index) {return rows[index];};
|
||||||
this.getItemMetadata= function(index) { return {};}
|
this.getItemMetadata= function(index) {return {};};
|
||||||
this.getModel= function(index) { return models[index]; }
|
this.getModel= function(index) {return models[index];};
|
||||||
this.getModelRow = function(m) { return models.indexOf(m);}
|
this.getModelRow = function(m) {return models.indexOf(m);};
|
||||||
this.updateItem = function(m,i) {
|
this.updateItem = function(m,i) {
|
||||||
rows[i] = toRow(m);
|
rows[i] = toRow(m);
|
||||||
models[i] = m
|
models[i] = m;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var data = new RowSet();
|
var data = new RowSet();
|
||||||
|
|
||||||
@@ -184,7 +183,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
var sortInfo = this.model.queryState.get('sort');
|
var sortInfo = this.model.queryState.get('sort');
|
||||||
if (sortInfo){
|
if (sortInfo){
|
||||||
var column = sortInfo[0].field;
|
var column = sortInfo[0].field;
|
||||||
var sortAsc = !(sortInfo[0].order == 'desc');
|
var sortAsc = sortInfo[0].order !== 'desc';
|
||||||
this.grid.setSortColumn(column, sortAsc);
|
this.grid.setSortColumn(column, sortAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +217,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
//
|
//
|
||||||
var grid = args.grid;
|
var grid = args.grid;
|
||||||
var model = data.getModel(args.row);
|
var model = data.getModel(args.row);
|
||||||
var field = grid.getColumns()[args.cell]['id'];
|
var field = grid.getColumns()[args.cell].id;
|
||||||
var v = {};
|
var v = {};
|
||||||
v[field] = args.item[field];
|
v[field] = args.item[field];
|
||||||
model.set(v);
|
model.set(v);
|
||||||
@@ -279,7 +278,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
$menu = $('<ul class="dropdown-menu slick-contextmenu" style="display:none;position:absolute;z-index:20;" />').appendTo(document.body);
|
$menu = $('<ul class="dropdown-menu slick-contextmenu" style="display:none;position:absolute;z-index:20;" />').appendTo(document.body);
|
||||||
|
|
||||||
$menu.bind('mouseleave', function (e) {
|
$menu.bind('mouseleave', function (e) {
|
||||||
$(this).fadeOut(options.fadeSpeed)
|
$(this).fadeOut(options.fadeSpeed);
|
||||||
});
|
});
|
||||||
$menu.bind('click', updateColumn);
|
$menu.bind('click', updateColumn);
|
||||||
|
|
||||||
@@ -296,7 +295,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
$input = $('<input type="checkbox" />').data('column-id', columns[i].id).attr('id','slick-column-vis-'+columns[i].id);
|
$input = $('<input type="checkbox" />').data('column-id', columns[i].id).attr('id','slick-column-vis-'+columns[i].id);
|
||||||
columnCheckboxes.push($input);
|
columnCheckboxes.push($input);
|
||||||
|
|
||||||
if (grid.getColumnIndex(columns[i].id) != null) {
|
if (grid.getColumnIndex(columns[i].id) !== null) {
|
||||||
$input.attr('checked', 'checked');
|
$input.attr('checked', 'checked');
|
||||||
}
|
}
|
||||||
$input.appendTo($li);
|
$input.appendTo($li);
|
||||||
@@ -323,10 +322,12 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateColumn(e) {
|
function updateColumn(e) {
|
||||||
|
var checkbox;
|
||||||
|
|
||||||
if ($(e.target).data('option') == 'autoresize') {
|
if ($(e.target).data('option') == 'autoresize') {
|
||||||
var checked;
|
var checked;
|
||||||
if ($(e.target).is('li')){
|
if ($(e.target).is('li')){
|
||||||
var checkbox = $(e.target).find('input').first();
|
checkbox = $(e.target).find('input').first();
|
||||||
checked = !checkbox.is(':checked');
|
checked = !checkbox.is(':checked');
|
||||||
checkbox.attr('checked',checked);
|
checkbox.attr('checked',checked);
|
||||||
} else {
|
} else {
|
||||||
@@ -346,7 +347,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
if (($(e.target).is('li') && !$(e.target).hasClass('divider')) ||
|
if (($(e.target).is('li') && !$(e.target).hasClass('divider')) ||
|
||||||
$(e.target).is('input')) {
|
$(e.target).is('input')) {
|
||||||
if ($(e.target).is('li')){
|
if ($(e.target).is('li')){
|
||||||
var checkbox = $(e.target).find('input').first();
|
checkbox = $(e.target).find('input').first();
|
||||||
checkbox.attr('checked',!checkbox.is(':checked'));
|
checkbox.attr('checked',!checkbox.is(':checked'));
|
||||||
}
|
}
|
||||||
var visibleColumns = [];
|
var visibleColumns = [];
|
||||||
@@ -359,7 +360,6 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (!visibleColumns.length) {
|
if (!visibleColumns.length) {
|
||||||
$(e.target).attr('checked', 'checked');
|
$(e.target).attr('checked', 'checked');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user