|
|
@@ -3,22 +3,22 @@
|
|
|
* extensions: https://github.com/vitalets/x-editable
|
|
|
*/
|
|
|
|
|
|
-!function ($) {
|
|
|
+(function($) {
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
$.extend($.fn.bootstrapTable.defaults, {
|
|
|
editable: true,
|
|
|
- onEditableInit: function () {
|
|
|
+ onEditableInit: function() {
|
|
|
return false;
|
|
|
},
|
|
|
- onEditableSave: function (field, row, oldValue, $el) {
|
|
|
+ onEditableSave: function(field, row, oldValue, $el) {
|
|
|
return false;
|
|
|
},
|
|
|
- onEditableShown: function (field, row, $el, editable) {
|
|
|
+ onEditableShown: function(field, row, $el, editable) {
|
|
|
return false;
|
|
|
},
|
|
|
- onEditableHidden: function (field, row, $el, reason) {
|
|
|
+ onEditableHidden: function(field, row, $el, reason) {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
@@ -34,7 +34,7 @@
|
|
|
_initTable = BootstrapTable.prototype.initTable,
|
|
|
_initBody = BootstrapTable.prototype.initBody;
|
|
|
|
|
|
- BootstrapTable.prototype.initTable = function () {
|
|
|
+ BootstrapTable.prototype.initTable = function() {
|
|
|
var that = this;
|
|
|
_initTable.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
@@ -42,42 +42,46 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- $.each(this.columns, function (i, column) {
|
|
|
+ $.each(this.columns, function(i, column) {
|
|
|
if (!column.editable) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- var editableOptions = {}, editableDataMarkup = [], editableDataPrefix = 'editable-';
|
|
|
+ var editableOptions = {},
|
|
|
+ editableDataMarkup = [],
|
|
|
+ editableDataPrefix = 'editable-';
|
|
|
|
|
|
var processDataOptions = function(key, value) {
|
|
|
- // Replace camel case with dashes.
|
|
|
- var dashKey = key.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
|
|
|
- if (dashKey.slice(0, editableDataPrefix.length) == editableDataPrefix) {
|
|
|
- var dataKey = dashKey.replace(editableDataPrefix, 'data-');
|
|
|
- editableOptions[dataKey] = value;
|
|
|
- }
|
|
|
+ // Replace camel case with dashes.
|
|
|
+ var dashKey = key.replace(/([A-Z])/g, function($1) {
|
|
|
+ return "-" + $1.toLowerCase();
|
|
|
+ });
|
|
|
+ if (dashKey.slice(0, editableDataPrefix.length) == editableDataPrefix) {
|
|
|
+ var dataKey = dashKey.replace(editableDataPrefix, 'data-');
|
|
|
+ editableOptions[dataKey] = value;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
$.each(that.options, processDataOptions);
|
|
|
|
|
|
- column.formatter || column.formatter = function (value, row, index) {
|
|
|
+ column.formatter = column.formatter || function(value, row, index) {
|
|
|
return value;
|
|
|
};
|
|
|
- column._formatter = column._formatter? column._formatter: column.formatter;
|
|
|
- column.formatter = function (value, row, index) {
|
|
|
- var result = column._formatter? column._formatter(value, row, index): value;
|
|
|
+ column._formatter = column._formatter ? column._formatter : column.formatter;
|
|
|
+ column.formatter = function(value, row, index) {
|
|
|
+ var result = column._formatter ? column._formatter(value, row, index) : value;
|
|
|
|
|
|
$.each(column, processDataOptions);
|
|
|
|
|
|
- $.each(editableOptions, function (key, value) {
|
|
|
+ $.each(editableOptions, function(key, value) {
|
|
|
editableDataMarkup.push(' ' + key + '="' + value + '"');
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
var _dont_edit_formatter = false;
|
|
|
if (column.editable.hasOwnProperty('noeditFormatter')) {
|
|
|
_dont_edit_formatter = column.editable.noeditFormatter(value, row, index);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (_dont_edit_formatter === false) {
|
|
|
return ['<a href="javascript:void(0)"',
|
|
|
' data-name="' + column.field + '"',
|
|
|
@@ -94,7 +98,7 @@
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- BootstrapTable.prototype.initBody = function () {
|
|
|
+ BootstrapTable.prototype.initBody = function() {
|
|
|
var that = this;
|
|
|
_initBody.apply(this, Array.prototype.slice.apply(arguments));
|
|
|
|
|
|
@@ -102,13 +106,13 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- $.each(this.columns, function (i, column) {
|
|
|
+ $.each(this.columns, function(i, column) {
|
|
|
if (!column.editable) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
|
|
- .off('save').on('save', function (e, params) {
|
|
|
+ .off('save').on('save', function(e, params) {
|
|
|
var data = that.getData(),
|
|
|
index = $(this).parents('tr[data-index]').data('index'),
|
|
|
row = data[index],
|
|
|
@@ -120,23 +124,23 @@
|
|
|
that.resetFooter();
|
|
|
});
|
|
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
|
|
- .off('shown').on('shown', function (e, editable) {
|
|
|
+ .off('shown').on('shown', function(e, editable) {
|
|
|
var data = that.getData(),
|
|
|
index = $(this).parents('tr[data-index]').data('index'),
|
|
|
row = data[index];
|
|
|
-
|
|
|
+
|
|
|
that.trigger('editable-shown', column.field, row, $(this), editable);
|
|
|
});
|
|
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
|
|
- .off('hidden').on('hidden', function (e, reason) {
|
|
|
+ .off('hidden').on('hidden', function(e, reason) {
|
|
|
var data = that.getData(),
|
|
|
index = $(this).parents('tr[data-index]').data('index'),
|
|
|
row = data[index];
|
|
|
-
|
|
|
+
|
|
|
that.trigger('editable-hidden', column.field, row, $(this), reason);
|
|
|
});
|
|
|
});
|
|
|
this.trigger('editable-init');
|
|
|
};
|
|
|
|
|
|
-}(jQuery);
|
|
|
+})(jQuery);
|