[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

api[www,FileAPIWriter] code

NativeObject
	subclass: #FileAPIWriterObject
	category: #FileAPIWriter!
FileAPIWriterObject comment: '
	Provides an API for writing to files from web applications.
	http://www.w3.org/TR/file-writer-api/
	@2013 Alejandro Reimondo [email protected]
'!

#(	#BlobBuilder #FileWriterSync 
) do: [:each| FileAPIWriterObject subclass: each ].

DOM subclass: #FileSaver category: #FileAPIWriter!
FileSaver subclass: #FileWriter category: #FileAPIWriter!

BlobBuilder buildFunctions: #(
	#( #getBlob: #( #contentType ) )
	#( #append:endings: #( #text #endings ) )
	#( #append: #( #data ) )
)!

FileSaver buildAccessors: #(
	#onwritestart #onprogress #onwrite
	#onabort #onerror #onwriteend
)!

FileSaver buildGetters: #( #readyState #error )!
FileSaver buildFunctions: #( #abort )!

! FileSaver class methodsFor: #constants !
init
	" Return the constant value INIT "

	^0! !

! FileSaver class methodsFor: #constants !
writing
	" Return the constant value WRITING "

	^1! !

! FileSaver class methodsFor: #constants !
done
	" Return the constant value DONE "

	^2! !

FileWriter buildGetters: #( #position #length )!
FileWriter buildFunctions: #(
	#( #write: #( #data ) )
	#( #seek: #( #offset ) )
	#( #truncate: #( #size ) )
)!

FileWriterSync buildGetters: #( #position #length )!
FileWriterSync buildFunctions: #(
	#( #write: #( #data ) )
	#( #seek: #( #offset ) )
	#( #truncate: #( #size ) )
)!

! FileSaver class methodsFor: #events !
selectorForHTML5Event: anEvent
	" Private - Return the on... selector to use to register binding to anEvent. "

	^#on , (anEvent upTo: $:) asLowercase! !

! FileSaver class methodsFor: #events !
html5Events
	" Private - Return the html5 events managed by instances of the receiver. "

	^#(
	#progress: #write
	#abort #error
	#writestart #writeend
	) , super html5Events! !