|
81 |
|
81 |
|
82 |
// value: String |
82 |
// value: String |
83 |
// The content of the base64 encoded file data. |
83 |
// The content of the base64 encoded file data. |
84 |
value: "", |
84 |
value: null, |
85 |
|
85 |
|
86 |
// maxSize: Number |
86 |
// maxSize: Number |
87 |
// A size limit for the uploaded file. |
87 |
// A size limit for the uploaded file. |
|
116 |
postMixInProperties: function() { |
116 |
postMixInProperties: function() { |
117 |
this.inherited(arguments); |
117 |
this.inherited(arguments); |
118 |
|
118 |
|
|
|
119 |
if (this.multiFile) { |
120 |
this.value = []; |
121 |
} else { |
122 |
this.value = ''; |
123 |
} |
124 |
|
119 |
// save the original label |
125 |
// save the original label |
120 |
this._origButtonLabel = this.buttonLabel; |
126 |
this._origButtonLabel = this.buttonLabel; |
121 |
}, |
127 |
}, |
|
193 |
lang.mixin(params, { |
199 |
lang.mixin(params, { |
194 |
iframe: (this._uploader.uploadType === 'iframe') ? true : false |
200 |
iframe: (this._uploader.uploadType === 'iframe') ? true : false |
195 |
}); |
201 |
}); |
196 |
|
202 |
|
197 |
this._uploader.upload(params); |
203 |
this._uploader.upload(params); |
198 |
this._updateLabel(); |
204 |
this._updateLabel(); |
199 |
this.onUploadStarted(_data); |
205 |
this.onUploadStarted(_data); |
|
239 |
this.set('value', this.value); |
245 |
this.set('value', this.value); |
240 |
}, |
246 |
}, |
241 |
|
247 |
|
242 |
_setDataAttr: function(newVal) { |
248 |
_setDataAttr: function(data) { |
243 |
this.data = newVal; |
249 |
this._set('data', data); |
244 |
this._settingData = true; |
250 |
this._settingData = true; |
245 |
this.set( 'value', newVal && 'content' in newVal ? newVal.content : '' ); |
251 |
var value = ''; |
|
|
252 |
if (!this.multiFile && data && 'content' in data) { |
253 |
// single file upload with data containing content |
254 |
value = data.content; |
255 |
} else if (this.multiFile && data instanceof Array) { |
256 |
// multi file upload -> handle array accordingly |
257 |
value = array.map(data, function(idata) { |
258 |
return idata && 'content' in idata ? idata.content : ''; |
259 |
}); |
260 |
} else if (this.multiFile) { |
261 |
// multi file fallback if data is not an array |
262 |
value = []; |
263 |
} |
264 |
this.set('value', value); |
246 |
this._settingData = false; |
265 |
this._settingData = false; |
247 |
}, |
266 |
}, |
248 |
|
267 |
|
|
250 |
if (!this._settingData) { |
269 |
if (!this._settingData) { |
251 |
this.data = null; |
270 |
this.data = null; |
252 |
} |
271 |
} |
253 |
this.value = newVal; |
|
|
254 |
|
272 |
|
255 |
if ( this.showClearButton ) { |
273 |
if (this.showClearButton) { |
256 |
// decide whether to show/hide remove button |
274 |
// decide whether to show/hide remove button |
257 |
domClass.toggle(this._clearButton.domNode, 'dijitHidden', !(typeof this.value == "string" && this.value !== "")); |
275 |
var isVisible = false; |
|
|
276 |
if (!this.multiFile) { |
277 |
isVisible = typeof newVal == "string" && newVal !== ""; |
278 |
} else { |
279 |
isVisible = newVal instanceof Array && newVal.length; |
280 |
} |
281 |
domClass.toggle(this._clearButton.domNode, 'dijitHidden', !isVisible); |
258 |
} |
282 |
} |
259 |
|
283 |
|
260 |
// send events |
284 |
// send events |
|
|
285 |
this._set('value', newVal); |
261 |
this.onChange(newVal); |
286 |
this.onChange(newVal); |
262 |
this.updateView(this.value, this.data); |
287 |
this.updateView(this.value, this.data); |
263 |
}, |
288 |
}, |