ajout app
This commit is contained in:
121
SNIPE-IT/public/js/extensions/reorder-columns/bootstrap-table-reorder-columns.js
vendored
Normal file
121
SNIPE-IT/public/js/extensions/reorder-columns/bootstrap-table-reorder-columns.js
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @version: v1.1.0
|
||||
*/
|
||||
|
||||
!function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
reorderableColumns: false,
|
||||
maxMovingRows: 10,
|
||||
onReorderColumn: function (headerFields) {
|
||||
return false;
|
||||
},
|
||||
dragaccept: null
|
||||
});
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
'reorder-column.bs.table': 'onReorderColumn'
|
||||
});
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_initHeader = BootstrapTable.prototype.initHeader,
|
||||
_toggleColumn = BootstrapTable.prototype.toggleColumn,
|
||||
_toggleView = BootstrapTable.prototype.toggleView,
|
||||
_resetView = BootstrapTable.prototype.resetView;
|
||||
|
||||
BootstrapTable.prototype.initHeader = function () {
|
||||
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!this.options.reorderableColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.makeRowsReorderable();
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.toggleColumn = function () {
|
||||
_toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!this.options.reorderableColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.makeRowsReorderable();
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.toggleView = function () {
|
||||
_toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!this.options.reorderableColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.options.cardView) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.makeRowsReorderable();
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.resetView = function () {
|
||||
_resetView.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!this.options.reorderableColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.makeRowsReorderable();
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.makeRowsReorderable = function () {
|
||||
var that = this;
|
||||
try {
|
||||
$(this.$el).dragtable('destroy');
|
||||
} catch (e) {}
|
||||
$(this.$el).dragtable({
|
||||
maxMovingRows: that.options.maxMovingRows,
|
||||
dragaccept: that.options.dragaccept,
|
||||
clickDelay:200,
|
||||
beforeStop: function() {
|
||||
var ths = [],
|
||||
formatters = [],
|
||||
columns = [],
|
||||
columnsHidden = [],
|
||||
columnIndex = -1;
|
||||
that.$header.find('th').each(function (i) {
|
||||
ths.push($(this).data('field'));
|
||||
formatters.push($(this).data('formatter'));
|
||||
});
|
||||
|
||||
//Exist columns not shown
|
||||
if (ths.length < that.columns.length) {
|
||||
columnsHidden = $.grep(that.columns, function (column) {
|
||||
return !column.visible;
|
||||
});
|
||||
for (var i = 0; i < columnsHidden.length; i++) {
|
||||
ths.push(columnsHidden[i].field);
|
||||
formatters.push(columnsHidden[i].formatter);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < ths.length; i++ ) {
|
||||
columnIndex = $.fn.bootstrapTable.utils.getFieldIndex(that.columns, ths[i]);
|
||||
if (columnIndex !== -1) {
|
||||
columns.push(that.columns[columnIndex]);
|
||||
that.columns.splice(columnIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
that.columns = that.columns.concat(columns);
|
||||
that.header.fields = ths;
|
||||
that.header.formatters = formatters;
|
||||
that.resetView();
|
||||
that.trigger('reorder-column', ths);
|
||||
}
|
||||
});
|
||||
};
|
||||
}(jQuery);
|
7
SNIPE-IT/public/js/extensions/reorder-columns/bootstrap-table-reorder-columns.min.js
vendored
Normal file
7
SNIPE-IT/public/js/extensions/reorder-columns/bootstrap-table-reorder-columns.min.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/*
|
||||
* bootstrap-table - v1.9.1 - 2015-10-25
|
||||
* https://github.com/wenzhixin/bootstrap-table
|
||||
* Copyright (c) 2015 zhixin wen
|
||||
* Licensed MIT License
|
||||
*/
|
||||
!function(a){"use strict";a.extend(a.fn.bootstrapTable.defaults,{reorderableColumns:!1,maxMovingRows:10,onReorderColumn:function(){return!1},dragaccept:null}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"reorder-column.bs.table":"onReorderColumn"});var b=a.fn.bootstrapTable.Constructor,c=b.prototype.initHeader,d=b.prototype.toggleColumn,e=b.prototype.toggleView,f=b.prototype.resetView;b.prototype.initHeader=function(){c.apply(this,Array.prototype.slice.apply(arguments)),this.options.reorderableColumns&&this.makeRowsReorderable()},b.prototype.toggleColumn=function(){d.apply(this,Array.prototype.slice.apply(arguments)),this.options.reorderableColumns&&this.makeRowsReorderable()},b.prototype.toggleView=function(){e.apply(this,Array.prototype.slice.apply(arguments)),this.options.reorderableColumns&&(this.options.cardView||this.makeRowsReorderable())},b.prototype.resetView=function(){f.apply(this,Array.prototype.slice.apply(arguments)),this.options.reorderableColumns&&this.makeRowsReorderable()},b.prototype.makeRowsReorderable=function(){var b=this;try{a(this.$el).dragtable("destroy")}catch(c){}a(this.$el).dragtable({maxMovingRows:b.options.maxMovingRows,dragaccept:b.options.dragaccept,clickDelay:200,beforeStop:function(){var c=[],d=[],e=[],f=[],g=-1;if(b.$header.find("th").each(function(){c.push(a(this).data("field")),d.push(a(this).data("formatter"))}),c.length<b.columns.length){f=a.grep(b.columns,function(a){return!a.visible});for(var h=0;h<f.length;h++)c.push(f[h].field),d.push(f[h].formatter)}for(var h=0;h<c.length;h++)g=a.fn.bootstrapTable.utils.getFieldIndex(b.columns,c[h]),-1!==g&&(e.push(b.columns[g]),b.columns.splice(g,1));b.columns=b.columns.concat(e),b.header.fields=c,b.header.formatters=d,b.resetView(),b.trigger("reorder-column",c)}})}}(jQuery);
|
Reference in New Issue
Block a user