|
@@ -1,73 +1,72 @@
|
|
|
/**
|
|
/**
|
|
|
* @author: Dennis Hernández
|
|
* @author: Dennis Hernández
|
|
|
* @webSite: http://djhvscf.github.io/Blog
|
|
* @webSite: http://djhvscf.github.io/Blog
|
|
|
- * @version: v1.1.1
|
|
|
|
|
|
|
+ * @version: v2.0.0
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-(function ($) {
|
|
|
|
|
- 'use strict';
|
|
|
|
|
|
|
+(function($) {
|
|
|
|
|
+ "use strict";
|
|
|
|
|
|
|
|
- var initResizable = function (that) {
|
|
|
|
|
- //Deletes the plugin to re-create it
|
|
|
|
|
- that.$el.colResizable({disable: true});
|
|
|
|
|
|
|
+ var initResizable = function(that) {
|
|
|
|
|
+ if (that.options.resizable && !that.options.cardView && !isInit(that)) {
|
|
|
|
|
+ that.$el.resizableColumns();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var reInitResizable = function(that) {
|
|
|
|
|
+ destroy(that);
|
|
|
|
|
+ initResizable(that);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var destroy = function(that) {
|
|
|
|
|
+ if (isInit(that)) {
|
|
|
|
|
+ that.$el.data("resizableColumns").destroy();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var isInit = function(that) {
|
|
|
|
|
+ return that.$el.data("resizableColumns") !== undefined;
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- //Creates the plugin
|
|
|
|
|
- that.$el.colResizable({
|
|
|
|
|
- liveDrag: that.options.liveDrag,
|
|
|
|
|
- headerOnly: that.options.headerOnly,
|
|
|
|
|
- minWidth: that.options.minWidth,
|
|
|
|
|
- hoverCursor: that.options.hoverCursor,
|
|
|
|
|
- dragCursor: that.options.dragCursor,
|
|
|
|
|
- onResize: that.onResize,
|
|
|
|
|
- onDrag: that.options.onResizableDrag,
|
|
|
|
|
- resizeMode: that.options.resizeMode
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ $.extend($.fn.bootstrapTable.defaults, {
|
|
|
|
|
+ resizable: false
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- $.extend($.fn.bootstrapTable.defaults, {
|
|
|
|
|
- resizable: false,
|
|
|
|
|
- liveDrag: false,
|
|
|
|
|
- headerOnly: false,
|
|
|
|
|
- minWidth: 15,
|
|
|
|
|
- hoverCursor: 'e-resize',
|
|
|
|
|
- dragCursor: 'e-resize',
|
|
|
|
|
- onResizableResize: function (e) {
|
|
|
|
|
- return false;
|
|
|
|
|
- },
|
|
|
|
|
- onResizableDrag: function (e) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
|
|
|
|
+ _initBody = BootstrapTable.prototype.initBody,
|
|
|
|
|
+ _toggleView = BootstrapTable.prototype.toggleView,
|
|
|
|
|
+ _resetView = BootstrapTable.prototype.resetView;
|
|
|
|
|
|
|
|
- var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
|
|
|
|
- _toggleView = BootstrapTable.prototype.toggleView,
|
|
|
|
|
- _resetView = BootstrapTable.prototype.resetView;
|
|
|
|
|
|
|
+ BootstrapTable.prototype.initBody = function() {
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ _initBody.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
|
|
- BootstrapTable.prototype.toggleView = function () {
|
|
|
|
|
- _toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
|
+ that.$el
|
|
|
|
|
+ .off("column-switch.bs.table, page-change.bs.table")
|
|
|
|
|
+ .on("column-switch.bs.table, page-change.bs.table", function() {
|
|
|
|
|
+ reInitResizable(that);
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- if (this.options.resizable && this.options.cardView) {
|
|
|
|
|
- //Deletes the plugin
|
|
|
|
|
- $(this.$el).colResizable({disable: true});
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ BootstrapTable.prototype.toggleView = function() {
|
|
|
|
|
+ _toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
|
|
- BootstrapTable.prototype.resetView = function () {
|
|
|
|
|
- var that = this;
|
|
|
|
|
|
|
+ if (this.options.resizable && this.options.cardView) {
|
|
|
|
|
+ //Destroy the plugin
|
|
|
|
|
+ destroy(this);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- _resetView.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
|
+ BootstrapTable.prototype.resetView = function() {
|
|
|
|
|
+ var that = this;
|
|
|
|
|
|
|
|
- if (this.options.resizable) {
|
|
|
|
|
- // because in fitHeader function, we use setTimeout(func, 100);
|
|
|
|
|
- setTimeout(function () {
|
|
|
|
|
- initResizable(that);
|
|
|
|
|
- }, 100);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ _resetView.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
|
|
- BootstrapTable.prototype.onResize = function (e) {
|
|
|
|
|
- var that = $(e.currentTarget);
|
|
|
|
|
- that.bootstrapTable('resetView');
|
|
|
|
|
- that.data('bootstrap.table').options.onResizableResize.apply(e);
|
|
|
|
|
|
|
+ if (this.options.resizable) {
|
|
|
|
|
+ // because in fitHeader function, we use setTimeout(func, 100);
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ initResizable(that);
|
|
|
|
|
+ }, 100);
|
|
|
}
|
|
}
|
|
|
|
|
+ };
|
|
|
})(jQuery);
|
|
})(jQuery);
|