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