corrade-nucleus-nucleons
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/flat-json/README.md |
@@ -0,0 +1,23 @@ |
# Table flat-json |
|
Use Plugin: [bootstrap-table-flat-json](https://github.com/djhvscf/bootstrap-table-flat-json) |
|
## Usage |
|
```html |
<script src="extensions/flat-json/bootstrap-table-flat-json.js"></script> |
``` |
|
## Options |
|
### flat |
|
* type: Boolean |
* description: Set true to flat the JSON object. |
* default: `false` |
|
### flatSeparator |
|
* type: String |
* description: Set the default separator between object levels. |
* default: `.` |
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/flat-json/bootstrap-table-flat-json.js |
@@ -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); |
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/flat-json/extension.json |
@@ -0,0 +1,17 @@ |
{ |
"name": "Flat JSON", |
"version": "1.3.0", |
"description": "Plugin to flat the JSON object.", |
"url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/flat-json", |
"example": "http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/flat-json.html", |
|
"plugins": [{ |
"name": "bootstrap-table-flat-json", |
"url": "https://github.com/djhvscf/bootstrap-table-flat-json" |
}], |
|
"author": { |
"name": "djhvscf", |
"image": "https://avatars1.githubusercontent.com/u/4496763" |
} |
} |