corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 19  →  ?path2? @ 20
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/docs/dist/extensions/select2-filter/bootstrap-table-select2-filter.js
@@ -0,0 +1,303 @@
/**
* @author: Jewway
* @version: v1.0.0
*/
 
!function ($) {
'use strict';
 
function getCurrentHeader(that) {
var header = that.$header;
if (that.options.height) {
header = that.$tableHeader;
}
 
return header;
}
 
function getFilterFields(that) {
return getCurrentHeader(that).find('[data-filter-field]');
}
 
function setFilterValues(that) {
var $filterElms = getFilterFields(that);
if (!$.isEmptyObject(that.filterColumnsPartial)) {
$filterElms.each(function (index, ele) {
var $ele = $(ele),
field = $ele.attr('data-filter-field'),
value = that.filterColumnsPartial[field];
 
if ($ele.is("select")) {
$ele.val(value).trigger('change');
}
else {
$ele.val(value);
}
});
}
}
 
function createFilter(that, header) {
var enableFilter = false,
isVisible,
html,
timeoutId = 0;
 
$.each(that.columns, function (i, column) {
isVisible = 'hidden';
html = [];
 
if (!column.visible) {
return;
}
 
if (!column.filter) {
html.push('<div class="no-filter"></div>');
} else {
var filterClass = column.filter.class ? ' ' + column.filter.class : '';
html.push('<div style="margin: 0px 2px 2px 2px;" class="filter' + filterClass + '">');
 
if (column.searchable) {
enableFilter = true;
isVisible = 'visible'
}
 
switch (column.filter.type.toLowerCase()) {
case 'input' :
html.push('<input type="text" data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '">');
break;
case 'select':
html.push('<select data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '"></select>');
break;
}
}
 
$.each(header.children().children(), function (i, tr) {
tr = $(tr);
if (tr.data('field') === column.field) {
tr.find('.fht-cell').append(html.join(''));
return false;
}
});
});
 
if (enableFilter) {
var $inputs = header.find('input'),
$selects = header.find('select');
 
 
if ($inputs.length > 0) {
$inputs.off('keyup').on('keyup', function (event) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnSearch(event);
}, that.options.searchTimeOut);
});
 
 
$inputs.off('mouseup').on('mouseup', function (event) {
var $input = $(this),
oldValue = $input.val();
 
if (oldValue === "") {
return;
}
 
setTimeout(function () {
var newValue = $input.val();
 
if (newValue === "") {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnSearch(event);
}, that.options.searchTimeOut);
}
}, 1);
});
}
 
if ($selects.length > 0) {
$selects.on('select2:select', function (event) {
that.onColumnSearch(event);
});
}
} else {
header.find('.filter').hide();
}
}
 
function initSelect2(that) {
var $header = getCurrentHeader(that);
 
$.each(that.columns, function (idx, column) {
if (column.filter && column.filter.type === 'select') {
var $selectEle = $header.find('select[data-filter-field=' + column.field + ']');
 
if ($selectEle.length > 0 && !$selectEle.data().select2) {
column.filter.data.unshift("");
 
var select2Opts = {
placeholder: "",
allowClear: true,
data: column.filter.data,
dropdownParent: that.$el.closest(".bootstrap-table")
};
 
$selectEle.select2(select2Opts);
$selectEle.on("select2:unselecting", function (event) {
event.preventDefault();
$selectEle.val(null).trigger('change');
that.searchText = undefined;
that.onColumnSearch(event);
});
}
}
});
}
 
$.extend($.fn.bootstrapTable.defaults, {
filter: false,
filterValues: {}
});
 
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
filter: undefined
});
 
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_init = BootstrapTable.prototype.init,
_initHeader = BootstrapTable.prototype.initHeader,
_initSearch = BootstrapTable.prototype.initSearch;
 
BootstrapTable.prototype.init = function () {
//Make sure that the filtercontrol option is set
if (this.options.filter) {
var that = this;
 
if (!$.isEmptyObject(that.options.filterValues)) {
that.filterColumnsPartial = that.options.filterValues;
that.options.filterValues = {};
}
 
this.$el.on('reset-view.bs.table', function () {
//Create controls on $tableHeader if the height is set
if (!that.options.height) {
return;
}
 
//Avoid recreate the controls
if (that.$tableHeader.find('select').length > 0 || that.$tableHeader.find('input').length > 0) {
return;
}
 
createFilter(that, that.$tableHeader);
}).on('post-header.bs.table', function () {
var timeoutId = 0;
 
initSelect2(that);
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
setFilterValues(that);
}, that.options.searchTimeOut - 1000);
}).on('column-switch.bs.table', function (field, checked) {
setFilterValues(that);
});
}
 
_init.apply(this, Array.prototype.slice.apply(arguments));
};
 
BootstrapTable.prototype.initHeader = function () {
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
if (this.options.filter) {
createFilter(this, this.$header);
}
};
 
BootstrapTable.prototype.initSearch = function () {
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
 
var that = this,
filterValues = that.filterColumnsPartial;
 
// Filter for client
if (that.options.sidePagination === 'client') {
this.data = $.grep(this.data, function (row, idx) {
for (var field in filterValues) {
var column = that.columns[$.fn.bootstrapTable.utils.getFieldIndex(that.columns, field)],
filterValue = filterValues[field].toLowerCase(),
rowValue = row[field];
 
rowValue = $.fn.bootstrapTable.utils.calculateObjectValue(
that.header,
that.header.formatters[$.inArray(field, that.header.fields)],
[rowValue, row, idx], rowValue);
 
if (column.filterStrictSearch) {
if (!($.inArray(field, that.header.fields) !== -1 &&
(typeof rowValue === 'string' || typeof rowValue === 'number') &&
rowValue.toString().toLowerCase() === filterValue.toString().toLowerCase())) {
return false;
}
} else {
if (!($.inArray(field, that.header.fields) !== -1 &&
(typeof rowValue === 'string' || typeof rowValue === 'number') &&
(rowValue + '').toLowerCase().indexOf(filterValue) !== -1)) {
return false;
}
}
}
 
return true;
});
}
};
 
BootstrapTable.prototype.onColumnSearch = function (event) {
var field = $(event.currentTarget).attr('data-filter-field'),
value = $.trim($(event.currentTarget).val());
 
if ($.isEmptyObject(this.filterColumnsPartial)) {
this.filterColumnsPartial = {};
}
 
if (value) {
this.filterColumnsPartial[field] = value;
} else {
delete this.filterColumnsPartial[field];
}
 
this.options.pageNumber = 1;
this.onSearch(event);
};
 
BootstrapTable.prototype.setFilterData = function (field, data) {
var that = this,
$header = getCurrentHeader(that),
$selectEle = $header.find('select[data-filter-field=\"' + field + '\"]');
 
data.unshift("");
$selectEle.empty();
$selectEle.select2({
data: data,
placeholder: "",
allowClear: true,
dropdownParent: that.$el.closest(".bootstrap-table")
});
 
$.each(this.columns, function (idx, column) {
if (column.field === field) {
column.filter.data = data;
return false;
}
});
};
 
BootstrapTable.prototype.setFilterValues = function (values) {
this.filterColumnsPartial = values;
};
 
$.fn.bootstrapTable.methods.push('setFilterData');
$.fn.bootstrapTable.methods.push('setFilterValues');
 
}(jQuery);
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/docs/dist/extensions/select2-filter/bootstrap-table-select2-filter.min.js
@@ -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";function b(a){var b=a.$header;return a.options.height&&(b=a.$tableHeader),b}function c(a){return b(a).find("[data-filter-field]")}function d(b){var d=c(b);a.isEmptyObject(b.filterColumnsPartial)||d.each(function(c,d){var e=a(d),f=e.attr("data-filter-field"),g=b.filterColumnsPartial[f];e.is("select")?e.val(g).trigger("change"):e.val(g)})}function e(b,c){var d,e,f=!1,g=0;if(a.each(b.columns,function(b,g){if(d="hidden",e=[],g.visible){if(g.filter){var h=g.filter["class"]?" "+g.filter["class"]:"";switch(e.push('<div style="margin: 0px 2px 2px 2px;" class="filter'+h+'">'),g.searchable&&(f=!0,d="visible"),g.filter.type.toLowerCase()){case"input":e.push('<input type="text" data-filter-field="'+g.field+'" style="width: 100%; visibility:'+d+'">');break;case"select":e.push('<select data-filter-field="'+g.field+'" style="width: 100%; visibility:'+d+'"></select>')}}else e.push('<div class="no-filter"></div>');a.each(c.children().children(),function(b,c){return c=a(c),c.data("field")===g.field?(c.find(".fht-cell").append(e.join("")),!1):void 0})}}),f){var h=c.find("input"),i=c.find("select");h.length>0&&(h.off("keyup").on("keyup",function(a){clearTimeout(g),g=setTimeout(function(){b.onColumnSearch(a)},b.options.searchTimeOut)}),h.off("mouseup").on("mouseup",function(c){var d=a(this),e=d.val();""!==e&&setTimeout(function(){var a=d.val();""===a&&(clearTimeout(g),g=setTimeout(function(){b.onColumnSearch(c)},b.options.searchTimeOut))},1)})),i.length>0&&i.on("select2:select",function(a){b.onColumnSearch(a)})}else c.find(".filter").hide()}function f(c){var d=b(c);a.each(c.columns,function(a,b){if(b.filter&&"select"===b.filter.type){var e=d.find("select[data-filter-field="+b.field+"]");if(e.length>0&&!e.data().select2){b.filter.data.unshift("");var f={placeholder:"",allowClear:!0,data:b.filter.data,dropdownParent:c.$el.closest(".bootstrap-table")};e.select2(f),e.on("select2:unselecting",function(a){a.preventDefault(),e.val(null).trigger("change"),c.searchText=void 0,c.onColumnSearch(a)})}}})}a.extend(a.fn.bootstrapTable.defaults,{filter:!1,filterValues:{}}),a.extend(a.fn.bootstrapTable.COLUMN_DEFAULTS,{filter:void 0});var g=a.fn.bootstrapTable.Constructor,h=g.prototype.init,i=g.prototype.initHeader,j=g.prototype.initSearch;g.prototype.init=function(){if(this.options.filter){var b=this;a.isEmptyObject(b.options.filterValues)||(b.filterColumnsPartial=b.options.filterValues,b.options.filterValues={}),this.$el.on("reset-view.bs.table",function(){b.options.height&&(b.$tableHeader.find("select").length>0||b.$tableHeader.find("input").length>0||e(b,b.$tableHeader))}).on("post-header.bs.table",function(){var a=0;f(b),clearTimeout(a),a=setTimeout(function(){d(b)},b.options.searchTimeOut-1e3)}).on("column-switch.bs.table",function(){d(b)})}h.apply(this,Array.prototype.slice.apply(arguments))},g.prototype.initHeader=function(){i.apply(this,Array.prototype.slice.apply(arguments)),this.options.filter&&e(this,this.$header)},g.prototype.initSearch=function(){j.apply(this,Array.prototype.slice.apply(arguments));var b=this,c=b.filterColumnsPartial;"client"===b.options.sidePagination&&(this.data=a.grep(this.data,function(d,e){for(var f in c){var g=b.columns[a.fn.bootstrapTable.utils.getFieldIndex(b.columns,f)],h=c[f].toLowerCase(),i=d[f];if(i=a.fn.bootstrapTable.utils.calculateObjectValue(b.header,b.header.formatters[a.inArray(f,b.header.fields)],[i,d,e],i),g.filterStrictSearch){if(-1===a.inArray(f,b.header.fields)||"string"!=typeof i&&"number"!=typeof i||i.toString().toLowerCase()!==h.toString().toLowerCase())return!1}else if(-1===a.inArray(f,b.header.fields)||"string"!=typeof i&&"number"!=typeof i||-1===(i+"").toLowerCase().indexOf(h))return!1}return!0}))},g.prototype.onColumnSearch=function(b){var c=a(b.currentTarget).attr("data-filter-field"),d=a.trim(a(b.currentTarget).val());a.isEmptyObject(this.filterColumnsPartial)&&(this.filterColumnsPartial={}),d?this.filterColumnsPartial[c]=d:delete this.filterColumnsPartial[c],this.options.pageNumber=1,this.onSearch(b)},g.prototype.setFilterData=function(c,d){var e=this,f=b(e),g=f.find('select[data-filter-field="'+c+'"]');d.unshift(""),g.empty(),g.select2({data:d,placeholder:"",allowClear:!0,dropdownParent:e.$el.closest(".bootstrap-table")}),a.each(this.columns,function(a,b){return b.field===c?(b.filter.data=d,!1):void 0})},g.prototype.setFilterValues=function(a){this.filterColumnsPartial=a},a.fn.bootstrapTable.methods.push("setFilterData"),a.fn.bootstrapTable.methods.push("setFilterValues")}(jQuery);