仓库初始化
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
.multiple-select-row-selected {
|
||||
background: lightBlue
|
||||
}
|
||||
|
||||
.table tbody tr:hover td,
|
||||
.table tbody tr:hover th {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
.table-striped tbody tr:nth-child(odd):hover td {
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
|
||||
.fixed-table-container tbody .selected td {
|
||||
background: lightBlue;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @version: v1.0.0
|
||||
*/
|
||||
|
||||
!function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
document.onselectstart = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
var getTableObjectFromCurrentTarget = function (currentTarget) {
|
||||
currentTarget = $(currentTarget);
|
||||
return currentTarget.is("table") ? currentTarget : currentTarget.parents().find(".table");
|
||||
};
|
||||
|
||||
var getRow = function (target) {
|
||||
target = $(target);
|
||||
return target.parent().parent();
|
||||
};
|
||||
|
||||
var onRowClick = function (e) {
|
||||
var that = getTableObjectFromCurrentTarget(e.currentTarget);
|
||||
|
||||
if (window.event.ctrlKey) {
|
||||
toggleRow(e.currentTarget, that, false, false);
|
||||
}
|
||||
|
||||
if (window.event.button === 0) {
|
||||
if (!window.event.ctrlKey && !window.event.shiftKey) {
|
||||
clearAll(that);
|
||||
toggleRow(e.currentTarget, that, false, false);
|
||||
}
|
||||
|
||||
if (window.event.shiftKey) {
|
||||
selectRowsBetweenIndexes([that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow.rowIndex, e.currentTarget.rowIndex], that)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var onCheckboxChange = function (e) {
|
||||
var that = getTableObjectFromCurrentTarget(e.currentTarget);
|
||||
clearAll(that);
|
||||
toggleRow(getRow(e.currentTarget), that, false, false);
|
||||
};
|
||||
|
||||
var toggleRow = function (row, that, clearAll, useShift) {
|
||||
if (clearAll) {
|
||||
row = $(row);
|
||||
that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow = undefined;
|
||||
row.removeClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
||||
that.bootstrapTable("uncheck", row.data("index"));
|
||||
} else {
|
||||
that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow = row;
|
||||
row = $(row);
|
||||
if (useShift) {
|
||||
row.addClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
||||
that.bootstrapTable("check", row.data("index"));
|
||||
} else {
|
||||
if(row.hasClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass)) {
|
||||
row.removeClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass)
|
||||
that.bootstrapTable("uncheck", row.data("index"));
|
||||
} else {
|
||||
row.addClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
||||
that.bootstrapTable("check", row.data("index"));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var selectRowsBetweenIndexes = function (indexes, that) {
|
||||
indexes.sort(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
for (var i = indexes[0]; i <= indexes[1]; i++) {
|
||||
toggleRow(that.bootstrapTable("getOptions").multipleSelectRowRows[i-1], that, false, true);
|
||||
}
|
||||
};
|
||||
|
||||
var clearAll = function (that) {
|
||||
for (var i = 0; i < that.bootstrapTable("getOptions").multipleSelectRowRows.length; i++) {
|
||||
toggleRow(that.bootstrapTable("getOptions").multipleSelectRowRows[i], that, true, false);
|
||||
}
|
||||
};
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
multipleSelectRow: false,
|
||||
multipleSelectRowCssClass: 'multiple-select-row-selected',
|
||||
//internal variables used by the extension
|
||||
multipleSelectRowLastSelectedRow: undefined,
|
||||
multipleSelectRowRows: []
|
||||
});
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_init = BootstrapTable.prototype.init,
|
||||
_initBody = BootstrapTable.prototype.initBody;
|
||||
|
||||
BootstrapTable.prototype.init = function () {
|
||||
if (this.options.multipleSelectRow) {
|
||||
var that = this;
|
||||
|
||||
//Make sure that the internal variables have the correct value
|
||||
this.options.multipleSelectRowLastSelectedRow = undefined;
|
||||
this.options.multipleSelectRowRows = [];
|
||||
|
||||
this.$el.on("post-body.bs.table", function (e) {
|
||||
setTimeout(function () {
|
||||
that.options.multipleSelectRowRows = that.$body.children();
|
||||
that.options.multipleSelectRowRows.click(onRowClick);
|
||||
that.options.multipleSelectRowRows.find("input[type=checkbox]").change(onCheckboxChange);
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
_init.apply(this, Array.prototype.slice.apply(arguments));
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.clearAllMultipleSelectionRow = function () {
|
||||
clearAll(this);
|
||||
};
|
||||
|
||||
$.fn.bootstrapTable.methods.push('clearAllMultipleSelectionRow');
|
||||
}(jQuery);
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* bootstrap-table - v1.11.1 - 2017-02-22
|
||||
* https://github.com/wenzhixin/bootstrap-table
|
||||
* Copyright (c) 2017 zhixin wen
|
||||
* Licensed MIT License
|
||||
*/
|
||||
!function(a){"use strict";document.onselectstart=function(){return!1};var b=function(b){return b=a(b),b.is("table")?b:b.parents().find(".table")},c=function(b){return b=a(b),b.parent().parent()},d=function(a){var c=b(a.currentTarget);window.event.ctrlKey&&f(a.currentTarget,c,!1,!1),0===window.event.button&&(window.event.ctrlKey||window.event.shiftKey||(h(c),f(a.currentTarget,c,!1,!1)),window.event.shiftKey&&g([c.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow.rowIndex,a.currentTarget.rowIndex],c))},e=function(a){var d=b(a.currentTarget);h(d),f(c(a.currentTarget),d,!1,!1)},f=function(b,c,d,e){d?(b=a(b),c.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow=void 0,b.removeClass(c.bootstrapTable("getOptions").multipleSelectRowCssClass),c.bootstrapTable("uncheck",b.data("index"))):(c.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow=b,b=a(b),e?(b.addClass(c.bootstrapTable("getOptions").multipleSelectRowCssClass),c.bootstrapTable("check",b.data("index"))):b.hasClass(c.bootstrapTable("getOptions").multipleSelectRowCssClass)?(b.removeClass(c.bootstrapTable("getOptions").multipleSelectRowCssClass),c.bootstrapTable("uncheck",b.data("index"))):(b.addClass(c.bootstrapTable("getOptions").multipleSelectRowCssClass),c.bootstrapTable("check",b.data("index"))))},g=function(a,b){a.sort(function(a,b){return a-b});for(var c=a[0];c<=a[1];c++)f(b.bootstrapTable("getOptions").multipleSelectRowRows[c-1],b,!1,!0)},h=function(a){for(var b=0;b<a.bootstrapTable("getOptions").multipleSelectRowRows.length;b++)f(a.bootstrapTable("getOptions").multipleSelectRowRows[b],a,!0,!1)};a.extend(a.fn.bootstrapTable.defaults,{multipleSelectRow:!1,multipleSelectRowCssClass:"multiple-select-row-selected",multipleSelectRowLastSelectedRow:void 0,multipleSelectRowRows:[]});{var i=a.fn.bootstrapTable.Constructor,j=i.prototype.init;i.prototype.initBody}i.prototype.init=function(){if(this.options.multipleSelectRow){var a=this;this.options.multipleSelectRowLastSelectedRow=void 0,this.options.multipleSelectRowRows=[],this.$el.on("post-body.bs.table",function(){setTimeout(function(){a.options.multipleSelectRowRows=a.$body.children(),a.options.multipleSelectRowRows.click(d),a.options.multipleSelectRowRows.find("input[type=checkbox]").change(e)},1)})}j.apply(this,Array.prototype.slice.apply(arguments))},i.prototype.clearAllMultipleSelectionRow=function(){h(this)},a.fn.bootstrapTable.methods.push("clearAllMultipleSelectionRow")}(jQuery);
|
||||
Reference in New Issue
Block a user