1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /*******************************************************************************
- * IBM Confidential
- *
- * OCO Source Materials
- *
- * A and PM: PD
- *
- * (c) Copyright IBM Corp. 2014, 2015
- *
- * The source code for this program is not published or otherwise divested of
- * its trade secrets, irrespective of what has been deposited with the U.S.
- * Copyright Office.
- ******************************************************************************/
- define([
- "dojo/_base/declare",
- "dojox/form/Uploader",
- "pd/widgets/uploader/HTML5",
- "pd/widgets/uploader/IFrame",
- "dojo/dom-form",
- "dojo/dom-attr"
- ],function(declare, dojoUploader, HTML5, IFrame, domForm, domAttr){
- var INPUT_BOX_SIZE = 43;
- var Uploader = declare("pd/widgets/Uploader", [dojoUploader, HTML5, IFrame], {
- handleAs: "html",
- postMixInProperties: function(){
- this.force = this.force.toLowerCase();
- if(this.supports("multiple")){
- this.uploadType = this.force === 'form' ? 'form' : 'html5';
- }else{
- this.uploadType = 'iframe';
- }
-
- this.inherited(arguments);
- },
-
- upload: function(formData){
- formData = formData || {};
- formData.uploadType = this.uploadType;
- this.inherited(arguments);
- },
-
- submit: function(form){
- form = !!form ? form.tagName ? form : this.getForm() : this.getForm();
- var data = domForm.toObject(form);
- data.uploadType = this.uploadType;
- this.upload(data);
- },
- pdResize: function(size) {
- domAttr.set(this.displayInput, "size", size);
- },
-
- buildRendering: function(){
- this.inherited(arguments);
- this.pdResize(INPUT_BOX_SIZE);
- },
-
- _setDisabledAttr: function(disabled){
- this.inherited(arguments);
- this.inputNode.disabled = disabled;
- this.displayInput.disabled = disabled;
- },
-
- onComplete: function(response, isGovernorCheck) {
- //overwrite dojo default event handler to block the reset for governor check request.
- if (!isGovernorCheck){
- this.reset();
- }
- }
- });
-
- return Uploader;
- });
|