| Total Complexity | 12 |
| Complexity/F | 12 |
| Lines of Code | 52 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { |
||
| 2 | Hooks |
||
| 3 | } from '../../' |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Get All attributes from a Abe tag |
||
| 7 | * @return {Object} parsed attributes |
||
| 8 | */ |
||
| 9 | export function getAll(str, json) { |
||
| 10 | str = Hooks.instance.trigger('beforeAbeAttributes', str, json) |
||
| 11 | |||
| 12 | //This regex analyzes all attributes of a Abe tag |
||
| 13 | var re = /\b([a-z][a-z0-9\-]*)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig |
||
| 14 | |||
| 15 | var attrs = { |
||
| 16 | autocomplete: null, |
||
| 17 | desc: '', |
||
| 18 | display: null, |
||
| 19 | editable: true, |
||
| 20 | key: '', |
||
| 21 | 'max-length': null, |
||
| 22 | 'min-length': 0, |
||
| 23 | order: 0, |
||
| 24 | prefill: false, |
||
| 25 | 'prefill-quantity': null, |
||
| 26 | reload: false, |
||
| 27 | required: false, |
||
| 28 | source: null, |
||
| 29 | tab: 'default', |
||
| 30 | type: 'text', |
||
| 31 | value: '', |
||
| 32 | file: '', |
||
| 33 | visible: true |
||
| 34 | } |
||
| 35 | |||
| 36 | for (var match; match = re.exec(str); ){ |
||
| 37 | attrs[match[1]] = match[3] || match[4] || match[5] |
||
| 38 | } |
||
| 39 | |||
| 40 | attrs.sourceString = attrs.source |
||
| 41 | attrs.source = (typeof attrs.source !== 'undefined' && attrs.source !== null && attrs.source !== '')? |
||
| 42 | ((typeof json['abe_source'] !== 'undefined' && json['abe_source'] !== null && json['abe_source'] !== '')? |
||
| 43 | json['abe_source'][attrs.key] : |
||
| 44 | null |
||
| 45 | ) : |
||
| 46 | null |
||
| 47 | attrs.editable = (typeof attrs.editable === 'undefined' || attrs.editable === null || attrs.editable === '' || attrs.editable === 'false') ? false : true |
||
| 48 | |||
| 49 | attrs = Hooks.instance.trigger('afterAbeAttributes', attrs, str, json) |
||
| 50 | |||
| 51 | return attrs |
||
| 52 | } |