`
lalanicer
  • 浏览: 28888 次
社区版块
存档分类
最新评论

Uploadify 3.1将英文提示改成中文提示

 
阅读更多

今天测试报了个bug.使用Uploadify上传时。如果把空文件放到上传队列的时候,出现了以下提示框

 

 

觉得这提示框实在太专业了。需要修改下提示语。网上翻了几个地方,都没有找到解决办法。只有查看源码了,发现jquery.uploadify-3.1.js有这么一句

 

 

onSelectError : function(file, errorCode, errorMsg) {

// Load the swfupload settings

var settings = this.settings;

 

// Run the default event handler

if ($.inArray('onSelectError', settings.overrideEvents) < 0) {

switch(errorCode) {

case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:

if (settings.queueSizeLimit > errorMsg) {

this.queueData.errorMsg += '\nThe number of files selected exceeds the remaining upload limit (' + errorMsg + ').';

} else {

this.queueData.errorMsg += '\nThe number of files selected exceeds the queue size limit (' + settings.queueSizeLimit + ').';

}

break;

case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:

this.queueData.errorMsg += '\nThe file "' + file.name + '" exceeds the size limit (' + settings.fileSizeLimit + ').';

break;

case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:

this.queueData.errorMsg += '\nThe file "' + file.name + '" is empty.';

break;

case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:

this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';

break;

}

}

if (errorCode != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {

delete this.queueData.files[file.id];

}

 

// Call the user-defined event handler

if (settings.onSelectError) settings.onSelectError.apply(this, arguments);

}

 

没错了,就是在onSelectError 事件里面,提示语的内容依赖于queueData.errorMsg。于是在定义uoloadify的时候重写了该方法。

 

 

            'onSelectError' : function (file, errorCode, errorMsg) {

            //返回码。文件为空

            if(errorCode == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){

            this.queueData.errorMsg = "不能传空文件!!"

            }

            }

 

这样就可以在选择空文件后,返回自定义的提示语。

  • 大小: 7.4 KB
分享到:
评论
1 楼 kobe1029 2013-08-15  
很好的文章!!!!!!!!!!!!

相关推荐

Global site tag (gtag.js) - Google Analytics