ajout app
This commit is contained in:
62
SNIPE-IT/resources/assets/js/extensions/flat-json/bootstrap-table-flat-json.js
vendored
Normal file
62
SNIPE-IT/resources/assets/js/extensions/flat-json/bootstrap-table-flat-json.js
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @version: v1.3.0
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
var flat = function (element, that) {
|
||||
var result = {};
|
||||
|
||||
function recurse(cur, prop) {
|
||||
if (Object(cur) !== cur) {
|
||||
result[prop] = cur;
|
||||
} else if ($.isArray(cur)) {
|
||||
for (var i = 0, l = cur.length; i < l; i++) {
|
||||
recurse(cur[i], prop ? prop + that.options.flatSeparator + i : "" + i);
|
||||
if (l == 0) {
|
||||
result[prop] = [];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var isEmpty = true;
|
||||
for (var p in cur) {
|
||||
isEmpty = false;
|
||||
recurse(cur[p], prop ? prop + that.options.flatSeparator + p : p);
|
||||
}
|
||||
if (isEmpty) {
|
||||
result[prop] = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recurse(element, "");
|
||||
return result;
|
||||
};
|
||||
|
||||
var flatHelper = function (data, that) {
|
||||
var flatArray = [];
|
||||
|
||||
$.each(!$.isArray(data) ? [data] : data, function (i, element) {
|
||||
flatArray.push(flat(element, that));
|
||||
});
|
||||
return flatArray;
|
||||
};
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
flat: false,
|
||||
flatSeparator: '.'
|
||||
});
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_initData = BootstrapTable.prototype.initData;
|
||||
|
||||
BootstrapTable.prototype.initData = function (data, type) {
|
||||
if (this.options.flat) {
|
||||
data = flatHelper(data ? data : this.options.data, this);
|
||||
}
|
||||
_initData.apply(this, [data, type]);
|
||||
};
|
||||
})(jQuery);
|
7
SNIPE-IT/resources/assets/js/extensions/flat-json/bootstrap-table-flat-json.min.js
vendored
Normal file
7
SNIPE-IT/resources/assets/js/extensions/flat-json/bootstrap-table-flat-json.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";var b=function(b,c){function d(b,f){if(Object(b)!==b)e[f]=b;else if(a.isArray(b))for(var g=0,h=b.length;h>g;g++)d(b[g],f?f+c.options.flatSeparator+g:""+g),0==h&&(e[f]=[]);else{var i=!0;for(var j in b)i=!1,d(b[j],f?f+c.options.flatSeparator+j:j);i&&(e[f]={})}}var e={};return d(b,""),e},c=function(c,d){var e=[];return a.each(a.isArray(c)?c:[c],function(a,c){e.push(b(c,d))}),e};a.extend(a.fn.bootstrapTable.defaults,{flat:!1,flatSeparator:"."});var d=a.fn.bootstrapTable.Constructor,e=d.prototype.initData;d.prototype.initData=function(a,b){this.options.flat&&(a=c(a?a:this.options.data,this)),e.apply(this,[a,b])}}(jQuery);
|
Reference in New Issue
Block a user