client/js/controls/uploader/uploader.coffee in rsence-pre-3.0.0.5 vs client/js/controls/uploader/uploader.coffee in rsence-pre-3.0.0.6
- old
+ new
@@ -20,36 +20,39 @@
HUploader = HControl.extend
componentName: 'uploader'
uploadState: false
uploadKey: false
markupElemNames: [
+ 'bg',
'form',
'file',
'iframe',
'upload_progress',
'progress_label',
'progress_indicator',
'button',
'button_label',
'value',
- 'ack_button'
+ 'ack_button',
+ 'ack_bg',
+ 'ack_button_label'
]
defaultEvents:
click: true
-
+
setUploadKey: (_uploadKey, _label)->
@setStyleOfPart( 'upload_progress', 'visibility', 'hidden' )
@setStyleOfPart( 'progress_indicator', 'visibility', 'hidden' )
@setStyleOfPart( 'ack_button', 'visibility', 'hidden' )
@setMarkupOfPart( 'button_label', _label )
@setStyleOfPart( 'button', 'visibility', 'inherit' )
@setStyleOfPart( 'form', 'visibility', 'inherit' )
@setAttrOfPart( 'form', 'action', '/U/'+_uploadKey, true )
@setAttrOfPart( 'file', 'value', '', true )
@uploadKey = _uploadKey
-
+
setProgressState: (_state, _label)->
@setStyleOfPart( 'upload_progress', 'visibility', 'inherit' )
if _state == 3
@setStyleOfPart( 'progress_indicator', 'visibility', 'hidden' )
@setStyleOfPart( 'ack_button', 'visibility', 'inherit' )
@@ -59,11 +62,11 @@
@setMarkupOfPart( 'progress_label', _label )
@setStyleOfPart( 'button', 'visibility', 'hidden' )
@setStyleOfPart( 'form', 'visibility', 'hidden' )
if _state == 1
@elemOfPart( 'form' ).submit()
-
+
setErrorState: (_label)->
@setStyleOfPart( 'progress_indicator', 'visibility', 'hidden' )
@setStyleOfPart( 'ack_button', 'visibility', 'inherit' )
@setMarkupOfPart( 'progress_label', '<span style="color:red;">'+_label+'</span>' )
@setStyleOfPart( 'button', 'visibility', 'hidden' )
@@ -81,11 +84,11 @@
@setUploadKey( _uploadKey, _label )
else if _state >= 1 and _state <= 4
@setProgressState( _state, _label )
else if _state < 0
@setErrorState( _label )
-
+
refreshValue: ->
return unless typeof @value == 'string'
return unless ~@value.indexOf(':::')
_stateAndKey = @value.split(':::')
return unless _stateAndKey.length == 2
@@ -93,11 +96,11 @@
parseInt( _stateAndKey[0], 10),
_stateAndKey[1]
)
upload: ->
@setValue( '1:::'+@uploadKey )
-
+
getNewUploadKey: ->
@setValue( '4:::'+@uploadKey )
-
+
click: ->
@getNewUploadKey() if @uploadState == 3 or @uploadState < 0