123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- require({cache:{
- 'url:dojox/form/resources/Uploader.html':"<span class=\"dijit dijitReset dijitInline\"\n\t><span class=\"dijitReset dijitInline dijitButtonNode\"\n\t\tdojoAttachEvent=\"ondijitclick:_onClick\"\n\t\t><span class=\"dijitReset dijitStretch dijitButtonContents\"\n\t\t\tdojoAttachPoint=\"titleNode,focusNode\"\n\t\t\trole=\"button\" aria-labelledby=\"${id}_label\"\n\t\t\t><span class=\"dijitReset dijitInline dijitIcon\" dojoAttachPoint=\"iconNode\"></span\n\t\t\t><span class=\"dijitReset dijitToggleButtonIconChar\">●</span\n\t\t\t><span class=\"dijitReset dijitInline dijitButtonText\"\n\t\t\t\tid=\"${id}_label\"\n\t\t\t\tdojoAttachPoint=\"containerNode\"\n\t\t\t></span\n\t\t></span\n\t></span\n\t><!--no need to have this for Uploader \n\t<input ${!nameAttrSetting} type=\"${type}\" value=\"${value}\" class=\"dijitOffScreen\" tabIndex=\"-1\"\n\t\tdojoAttachPoint=\"valueNode\"\n/--></span>\n"}});
- define("dojox/form/Uploader", [
- "dojo/_base/kernel",
- "dojo/_base/declare",
- "dojo/_base/lang",
- "dojo/_base/array",
- "dojo/_base/connect",
- "dojo/_base/window",
- "dojo/dom-style",
- "dojo/dom-geometry",
- "dojo/dom-attr",
- "dojo/dom-construct",
- "dojo/dom-form",
- "dijit",
- "dijit/form/Button",
- "dojox/form/uploader/Base",
- "dojo/i18n!./nls/Uploader",
- "dojo/text!./resources/Uploader.html"
- ],function(kernel, declare, lang, array, connect, win, domStyle, domGeometry, domAttr, domConstruct, domForm, dijit, Button, uploader, res, template){
- kernel.experimental("dojox.form.Uploader");
-
-
-
-
-
-
-
-
-
-
-
-
- declare("dojox.form.Uploader", [uploader, Button], {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- uploadOnSelect:false,
-
-
- tabIndex:0,
-
-
- multiple:false,
-
-
-
- label:res.label,
-
-
-
-
- url:"",
-
-
-
-
-
- name:"uploadedfile",
-
-
-
-
- flashFieldName:"",
-
-
-
-
-
- uploadType:"form",
-
-
-
-
-
-
-
-
- showInput: "",
- _nameIndex:0,
- templateString: template,
- baseClass: 'dijitUploader '+Button.prototype.baseClass,
- postMixInProperties: function(){
- this._inputs = [];
- this._cons = [];
- this.inherited(arguments);
- },
- buildRendering: function(){
- console.warn("buildRendering", this.id)
- this.inherited(arguments);
- domStyle.set(this.domNode, {
- overflow:"hidden",
- position:"relative"
- });
- this._buildDisplay();
-
-
- domAttr.set(this.titleNode, 'tabIndex', -1);
- },
- _buildDisplay: function(){
- if(this.showInput){
- this.displayInput = dojo.create('input', {
- 'class':'dijitUploadDisplayInput',
- 'tabIndex':-1, 'autocomplete':'off'},
- this.containerNode, this.showInput);
-
- this._attachPoints.push('displayInput');
- this.connect(this,'onChange', function(files){
- var i=0,l=files.length, f, r=[];
- while((f=files[i++])){
- if(f && f.name){
- r.push(f.name);
- }
- }
- this.displayInput.value = r.join(', ');
- });
- this.connect(this,'reset', function(){
- this.displayInput.value = '';
- });
- }
- },
- startup: function(){
- if(this._buildInitialized){
- return;
- }
- this._buildInitialized = true;
- this._getButtonStyle(this.domNode);
- this._setButtonStyle();
- this.inherited(arguments);
- },
-
- onChange: function(/* Array */fileArray){
-
-
-
-
- },
- onBegin: function(/* Array */dataArray){
-
-
- },
- onProgress: function(/* Object */customEvent){
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- onComplete: function(/* Object */customEvent){
-
-
-
-
- this.reset();
- },
- onCancel: function(){
-
-
-
-
- },
- onAbort: function(){
-
-
-
- },
- onError: function(/* Object or String */evtObject){
-
-
-
-
- },
-
- upload: function(/*Object ? */formData){
-
-
- },
- submit: function(/* form Node ? */form){
-
-
-
- form = !!form ? form.tagName ? form : this.getForm() : this.getForm();
- var data = domForm.toObject(form);
- this.upload(data);
- },
- reset: function(){
-
-
-
-
-
-
-
-
- delete this._files;
- this._disconnectButton();
- array.forEach(this._inputs, domConstruct.destroy, dojo);
- this._inputs = [];
- this._nameIndex = 0;
- this._createInput();
- },
- getFileList: function(){
-
-
-
- var fileArray = [];
- if(this.supports("multiple")){
- array.forEach(this._files, function(f, i){
- fileArray.push({
- index:i,
- name:f.name,
- size:f.size,
- type:f.type
- });
- }, this);
- }else{
- array.forEach(this._inputs, function(n, i){
- if(n.value){
- fileArray.push({
- index:i,
- name:n.value.substring(n.value.lastIndexOf("\\")+1),
- size:0,
- type:n.value.substring(n.value.lastIndexOf(".")+1)
- });
- }
- }, this);
- }
- return fileArray;
- },
-
- _getValueAttr: function(){
-
-
- return this.getFileList();
- },
- _setValueAttr: function(disabled){
- console.error("Uploader value is read only");
- },
- _setDisabledAttr: function(disabled){
-
-
- if(this._disabled == disabled){ return; }
- this.inherited(arguments);
- domStyle.set(this.inputNode, "display", disabled ? "none" : "");
- },
- _getButtonStyle: function(node){
- this.btnSize = {w:domStyle.get(node,'width'), h:domStyle.get(node,'height')};
- },
- _setButtonStyle: function(){
- this.inputNodeFontSize = Math.max(2, Math.max(Math.ceil(this.btnSize.w / 60), Math.ceil(this.btnSize.h / 15)));
- this._createInput();
- },
- _createInput: function(){
- if(this._inputs.length){
- domStyle.set(this.inputNode, {
- top:"500px"
- });
- this._disconnectButton();
- this._nameIndex++;
- }
- var name;
- if(this.supports("multiple")){
-
- name = this.name+"s[]";
- }else{
-
- name = this.name + (this.multiple ? this._nameIndex : "");
- }
-
-
- this.focusNode = this.inputNode = domConstruct.create("input", {type:"file", name:name}, this.domNode, "first");
- if(this.supports("multiple") && this.multiple){
- domAttr.set(this.inputNode, "multiple", true);
- }
- this._inputs.push(this.inputNode);
- domStyle.set(this.inputNode, {
- position:"absolute",
- fontSize:this.inputNodeFontSize+"em",
- top:"-3px",
- right:"-3px",
- opacity:0
- });
- this._connectButton();
- },
- _connectButton: function(){
- this._cons.push(connect.connect(this.inputNode, "change", this, function(evt){
- this._files = this.inputNode.files;
- this.onChange(this.getFileList(evt));
- if(!this.supports("multiple") && this.multiple) this._createInput();
- }));
- if(this.tabIndex > -1){
- this.inputNode.tabIndex = this.tabIndex;
- this._cons.push(connect.connect(this.inputNode, "focus", this, function(){
- this.titleNode.style.outline= "1px dashed #ccc";
- }));
- this._cons.push(connect.connect(this.inputNode, "blur", this, function(){
- this.titleNode.style.outline = "";
- }));
- }
- },
- _disconnectButton: function(){
- array.forEach(this._cons, connect.disconnect);
- this._cons.splice(0,this._cons.length);
- }
- });
- dojox.form.UploaderOrg = dojox.form.Uploader;
- var extensions = [dojox.form.UploaderOrg];
- dojox.form.addUploaderPlugin = function(plug){
-
-
-
-
- extensions.push(plug);
- declare("dojox.form.Uploader", extensions, {});
- }
- return dojox.form.Uploader;
- });
|