BaseHtmlAttr.js
2 years ago
FileExtensionHtmlAttr.js
2 years ago
MaxFileSizeHtmlAttr.js
2 years ago
MaxFilesHtmlAttr.js
2 years ago
RemainingCalcAttr.js
2 years ago
MaxFilesHtmlAttr.js
36 lines
| 1 | import BaseHtmlAttr from './BaseHtmlAttr'; |
| 2 | |
| 3 | function MaxFilesHtmlAttr() { |
| 4 | BaseHtmlAttr.call( this ); |
| 5 | |
| 6 | this.attrName = 'max_files'; |
| 7 | |
| 8 | /** |
| 9 | * @param input {InputData} |
| 10 | * @return {boolean} |
| 11 | */ |
| 12 | this.isSupported = function ( input ) { |
| 13 | const [ node ] = input.nodes; |
| 14 | |
| 15 | return 'file' === node.type; |
| 16 | }; |
| 17 | |
| 18 | /** |
| 19 | * @param input {FileData|InputData} |
| 20 | */ |
| 21 | this.setInput = function ( input ) { |
| 22 | BaseHtmlAttr.prototype.setInput.call( this, input ); |
| 23 | |
| 24 | const { max_files = 1 } = JSON.parse( |
| 25 | input.previewsContainer.dataset.args, |
| 26 | ); |
| 27 | |
| 28 | this.initial = +max_files; |
| 29 | }; |
| 30 | |
| 31 | this.addWatcherAttr = () => {}; |
| 32 | } |
| 33 | |
| 34 | MaxFilesHtmlAttr.prototype = Object.create( BaseHtmlAttr.prototype ); |
| 35 | |
| 36 | export default MaxFilesHtmlAttr; |