/*!@license
* Infragistics.Web.ClientUI Upload localization resources 0.0.1
*
* Copyright (c) 2011-2022 Infragistics Inc.
*
* http://www.infragistics.com/
*
*/
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{return factory(jQuery)}})(function($){$.ig=$.ig||{};$.ig.Upload=$.ig.Upload||{};$.ig.locale=$.ig.locale||{};$.ig.locale.en=$.ig.locale.en||{};$.ig.locale.en.Upload={labelUploadButton:"Upload File",labelAddButton:"Add",labelClearAllButton:"Clear Uploaded",labelSummaryTemplate:"{0} of {1} uploaded",labelSummaryProgressBarTemplate:"{0}/{1}",labelShowDetails:"Show Details",labelHideDetails:"Hide Details",labelSummaryProgressButtonCancel:"Cancel",labelSummaryProgressButtonContinue:"Upload",labelSummaryProgressButtonDone:"Done",labelProgressBarFileNameContinue:"...",errorMessageFileSizeExceeded:"Max file size exceeded.",errorMessageGetFileStatus:"Could not get your current file status! Probably connection dropped.",errorMessageCancelUpload:"Could not send to server command to cancel upload! Probably connection dropped.",errorMessageNoSuchFile:"The file you requested could not be found. Probably this file is too big.",errorMessageOther:"There is internal error uploading file. Error code: {0}.",errorMessageValidatingFileExtension:"File extension validation failed.",errorMessageAJAXRequestFileSize:"AJAX error while trying to get file size.",errorMessageMaxUploadedFiles:"Maximum count of uploading files exceeded.",errorMessageMaxSimultaneousFiles:"Value of maxSimultaneousFilesUploads is incorrect. It should be more than 0 or null.",errorMessageTryToRemoveNonExistingFile:"You are trying to remove non-existing file with id {0}.",errorMessageTryToStartNonExistingFile:"You are trying to start non-existing file with id {0}.",errorMessageDropMultipleFilesWhenSingleModel:"It is not allowed to drop more than 1 file when mode is single",titleUploadFileButtonInit:"Upload File",titleAddFileButton:"Add",titleCancelUploadButton:"Cancel",titleSummaryProgressButtonContinue:"Upload",titleClearUploaded:"Clear Uploaded",titleShowDetailsButton:"Show Details",titleHideDetailsButton:"Hide Details",titleSummaryProgressButtonCancel:"Cancel",titleSummaryProgressButtonDone:"Done",titleSingleUploadButtonContinue:"Upload",titleClearAllButton:"Clear Uploaded"};$.ig.Upload.locale=$.ig.Upload.locale||$.ig.locale.en.Upload;return $.ig.locale.en.Upload});/*!@license
 * Infragistics.Web.ClientUI jQuery File Upload 0.0.1
 *
 * Copyright (c) 2011-2022 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 *  jquery.js
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	infragistics.util.js
 *  infragistics.util.jquery.js
 *  infragistics.ui.widget.js
 *  infragistics.ui.shared.js
 */
"use strict";(function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.ui.widget","./infragistics.ui.shared"],factory)}else{return factory(jQuery)}})(function($){$.widget("ui.igBrowseButton",$.ui.igButton,{_const:{filePickerWidth:"220px",filePickerHeight:"30px"},css:{filePickerClass:"ui-igbrowsebutton-filepicker"},options:{autoselect:true,multipleFiles:false,container:null},_id:function(id){return this.element[0].id+id},_create:function(){var filepickerId=this._id("_fp"),self=this;$.extend($.ui.igBrowseButton.prototype.options,$.ui.igButton.prototype.options);$.extend($.ui.igBrowseButton.prototype.css,$.ui.igButton.prototype.css);$.ui.igButton.prototype._create.apply(this);this._createFilePicker(filepickerId);this._attachBrowseButtonEvents();if(this.options.disabled===true){this._enableFilePicker(true)}else{this.element.bind({click:function(e){e.preventDefault()},drop:function(e){var files=e.originalEvent.dataTransfer.files;e.stopPropagation();e.preventDefault();if(files===null||files===undefined){return false}if(!self._trigger("fileselect",e,{files:files,multiple:true})){return}return false}})}},_createFilePicker:function(filepickerId){$("#"+filepickerId).remove();var multiple="",container=this.options.container;if(this.options.multipleFiles===true){multiple=' multiple=""'}if(!container){container=$(document.body)}this.filePicker=$('<input type="file" id="'+filepickerId+'"'+multiple+"/>").appendTo(container);this.filePicker.css({position:"absolute",margin:"-5px 0 0 -175px",padding:"0",width:"1px",height:"1px",fontSize:"14px",opacity:"0",cursor:"pointer",display:"block",zIndex:"1000000",filter:"alpha(opacity=0)"});this._setTitle(this.options.title)},_setTitle:function(title){var filePicker=$("#"+this._id("_fp"));if(title===false){filePicker.removeAttr("title")}else{filePicker.attr("title",title)}},_attachBrowseButtonEvents:function(){var self=this;this.mouseMoveEvent={mousemove:function(event){self._mousemove(event)}};this._internalEvents={mouseover:function(event){self._mousemove(event);self._attachMouseMove(true)}};self.element.bind(this._internalEvents);self._filePickerBindChange()},_filePickerBindChange:function(){var self=this,filePath,filePicker=$("#"+this._id("_fp"));self.tempClicked=false;self._filePickerEvents={change:function(event){var files=null,multiple=false;filePath=self._fileFromPath(filePicker.val());if(filePicker[0].files){files=filePicker[0].files;multiple=true}self._mousemove(event);if(!self._trigger("fileselect",event,{filePath:filePath,files:files,multiple:multiple})){return}},click:function(event){if(!self._trigger("click",event)){return false}}};filePicker.bind(self._filePickerEvents)},attachFilePicker:function(e,isHidden){var self=this,right,bottom,t,l,relativeOffset,fileUploadButton=self.element,filePicker=this.filePicker,offset=fileUploadButton.igOffset(),left=parseInt(offset.left,10),top=parseInt(offset.top,10),filePickerDOM=filePicker[0];right=parseInt(left+fileUploadButton[0].offsetWidth,10);bottom=parseInt(top+fileUploadButton[0].offsetHeight,10);if(e.pageX>=left&&e.pageX<=right&&e.pageY>=top&&e.pageY<=bottom){relativeOffset=$.ig.util.getRelativeOffset(filePicker);t=e.pageY;l=e.pageX;t-=relativeOffset.top;l-=relativeOffset.left;filePickerDOM.style.top=t+"px";filePickerDOM.style.left=l+"px";if(isHidden===true){filePicker.css({width:"1px",height:"1px"})}else{self.isVisibleFilePicker=true;filePicker.css({width:self._const.filePickerWidth,height:self._const.filePickerHeight})}filePickerDOM.style.display="block";self._onMouseOver(e)}},getFilePicker:function(){var filepickerId=this._id("_fp"),filePicker=$("#"+filepickerId);filePicker.attr("id","").css({display:"none"});this._createFilePicker(filepickerId);this._filePickerBindChange();return filePicker},_mousemove:function(e){var self=this,right,bottom,t,l,fileUploadButton=self.element,filePicker=this.filePicker,relativeOffset,left=$.ig.util.offset(fileUploadButton).left,top=$.ig.util.offset(fileUploadButton).top,filePickerDOM=filePicker[0];right=parseInt(left+fileUploadButton[0].offsetWidth,10);bottom=parseInt(top+fileUploadButton[0].offsetHeight,10);if(e.pageX>=left&&e.pageX<=right&&e.pageY>=top&&e.pageY<=bottom){relativeOffset=$.ig.util.getRelativeOffset(filePicker);t=e.pageY;l=e.pageX;t-=relativeOffset.top;l-=relativeOffset.left;filePickerDOM.style.top=t+"px";filePickerDOM.style.left=l+"px";if(!self.isVisibleFilePicker){filePicker.css({width:self._const.filePickerWidth,height:self._const.filePickerHeight});self.isVisibleFilePicker=true}filePickerDOM.style.display="block";self._onMouseOver(e)}else{if(self.isVisibleFilePicker){filePicker.css({width:"1px",height:"1px"});self.isVisibleFilePicker=false}self._attachMouseMove(false);self._onMouseOut(e)}},_attachMouseMove:function(isToAttach){if(isToAttach){$(document).bind(this.mouseMoveEvent)}else{$(document).unbind(this.mouseMoveEvent)}},_setOption:function(key,value){$.ui.igButton.prototype._setOption.apply(this,arguments);$.Widget.prototype._setOption.apply(this,arguments);switch(key){case"disabled":this._enableFilePicker(value);$.ui.igButton.prototype._setOption.apply(this,arguments);break;case"title":this._setTitle(value);break;default:break}},_enableFilePicker:function(isDisabled){var filePicker=$("#"+this._id("_fp"));if(isDisabled===false){this.isVisibleFilePicker=false;this._attachMouseMove(true);this.element.bind(this._internalEvents).mouseover()}else{this._attachMouseMove(false);filePicker.css({width:"1px",height:"1px"});this.element.unbind(this._internalEvents)}},destroy:function(){this.element.unbind(this._internalEvents);this.element.unbind(this.mouseMoveEvent);this._superApply(arguments);$.ui.igButton.prototype.destroy.apply(this);$("#"+this._id("_fp")).remove()},_fileFromPath:function(file){return file.replace(/(\/|\\)$/,"")}});$.extend($.ui.igBrowseButton,{version:"0.0.1"});$.widget("ui.igUpload",$.ui.igWidget,{_const:{fileNameLimit:100,AjaxQueueName:"uploadrequestsqueue",debug:true,isProgressBarAnimationEnabled:true,isProgressBarRange:false,timeoutGetFileSize:1e3,status:{NotStarted:0,Started:1,Finished:2,NoSuchFile:3,Canceled:4},errorCode:{MimeTypeValidation:1,FileSizeExceeded:2},clientSideErrorCode:{maxAllowedUploadingFiles:1,extensionValidation:2,startUpload:3,ajaxErrorGetFileStatus:4,ajaxErrorCancelUpload:5,removeFileUpload:6,ajaxErrorRequestFileSize:7,checkCanUpload:8,maxFileSizeExcceeded:9,dropMultipleFilesWhenSingleMode:10},fileStatusNoError:-1,progressUpdateInterval:800,animateProgressBarInterval:10,showHideDetailsAnimationTimeout:500,doubleCheckRequestInterval:1e3,removeSingleUploadAnimationTimeout:300,maxUploadFilesDefault:-1},defaultFileExtensionIcons:[{ext:[],css:"ui-icon ui-icon-document "+"ui-igupload-progressbar-icon "+"ui-igupload-progressbar-icon-default",def:true},{ext:["exe","app"],css:"ui-icon ui-icon-gear ui-igupload-progressbar-icon ui-igupload-progressbar-icon-exe",def:false},{ext:["gif","jpg","jpeg","png","bmp","yuv","tif","thm","psd"],css:"ui-icon ui-icon-image ui-igupload-progressbar-icon ui-igupload-progressbar-icon-images",def:false},{ext:["mp3","wav","mp4","aac","mid","wma","ra","iff","aif","m3u","mpa"],css:"ui-icon ui-icon-volume-on "+"ui-icon ui-icon-image "+"ui-igupload-progressbar-icon "+"ui-igupload-progressbar-icon-music",def:false},{ext:["doc","docx","xls","xlsx","txt","ppt","pptx","pdf"],css:"ui-icon ui-icon-document ui-igupload-progressbar-icon ui-igupload-progressbar-icon-docs",def:false},{ext:["3gp","asf","asx","avi","flv","mov","mp4","mpg","rm","swf","vob","wmv"],css:"ui-icon ui-icon-video ui-igupload-progressbar-icon ui-igupload-progressbar-icon-video",def:false}],css:{clearClass:"ui-helper-clearfix",hiddenClass:"ui-helper-hidden",baseClassIE6:"ui-ie6",baseClassIE7:"ui-ie7",baseClassMoz:"ui-moz",baseClassOpera:"ui-opera",baseClassWebkit:"ui-webkit",startupBrowseButtonClasses:"ui-igstartupbrowsebutton",baseClass:"ui-widget ui-widget ui-widget-content ui-corner-all ui-igupload",baseMainContainerClass:"ui-igupload-basemaincontainer",multipleDialogClasses:"ui-iguploadmultiple",singleDialogClass:"ui-iguploadsingle",browseButtonClass:"ui-igupload-browsebutton",containerClass:"ui-igupload-container ui-widget-content",uploadProgressClass:"ui-igupload-uploadprogress",fileInfoMainContainer:"ui-igupload-fimaincontainer",progressContainer:"ui-helper-clearfix",progressBarUploadClass:"ui-igupload-progressbar-upload ui-igupload-progressbar-upload-single ui-helper-clearfix",progressBarFileNameClass:"ui-igupload-progressbar-filename",progressBarFileSizeClass:"ui-igupload-progressbar-filesize",progressBarInnerHTMLContainerClass:"ui-igupload-progressbar-container ui-helper-clearfix",containerButtonCancelClass:"ui-container-button-cancel-class  ui-helper-clearfix",summaryProgressBarClass:"ui-igupload-summaryprogressbar",summaryProgressContainerClass:"ui-igupload-summaryprogresscontainer",summaryProgressbarLabelClass:"ui-igupload-summaryprogress-label",summaryInformationContainerClass:"ui-igupload-summaryinformation-container ui-helper-clearfix",summaryUploadedFilesLabelClass:"ui-igupload-summaryuploadedfiles-label",summaryShowHideDetailsButtonClass:"ui-igupload-showhidedetails-button",summaryButtonClass:"ui-igupload-summary-button",summaryProgressBarInnerProgress:"ui-igupload-summaryprogres_summpbar_progress",summaryProgressBarSecondaryLabel:"ui-igupload-summaryprogress-label ui-igupload-summaryprogress-secondary-label",containerFUS:"ui-widget-content ui-igupload-progress-container ui-corner-all ui-helper-clearfix"},options:{width:"",height:"",autostartupload:false,labelUploadButton:undefined,labelAddButton:undefined,labelClearAllButton:undefined,labelSummaryTemplate:undefined,labelSummaryProgressBarTemplate:undefined,labelShowDetails:undefined,labelHideDetails:undefined,labelSummaryProgressButtonCancel:undefined,labelSummaryProgressButtonContinue:undefined,labelSummaryProgressButtonDone:undefined,labelProgressBarFileNameContinue:undefined,errorMessageMaxFileSizeExceeded:undefined,errorMessageGetFileStatus:undefined,errorMessageCancelUpload:undefined,errorMessageNoSuchFile:undefined,errorMessageOther:undefined,errorMessageValidatingFileExtension:undefined,errorMessageAJAXRequestFileSize:undefined,errorMessageTryToRemoveNonExistingFile:undefined,errorMessageTryToStartNonExistingFile:undefined,errorMessageMaxUploadedFiles:undefined,errorMessageMaxSimultaneousFiles:undefined,errorMessageDropMultipleFilesWhenSingleModel:undefined,locale:{labelUploadButton:undefined,labelAddButton:undefined,labelClearAllButton:undefined,labelSummaryTemplate:undefined,labelSummaryProgressBarTemplate:undefined,labelShowDetails:undefined,labelHideDetails:undefined,labelSummaryProgressButtonCancel:undefined,labelSummaryProgressButtonContinue:undefined,labelSummaryProgressButtonDone:undefined,labelProgressBarFileNameContinue:undefined,errorMessageFileSizeExceeded:undefined,errorMessageGetFileStatus:undefined,errorMessageCancelUpload:undefined,errorMessageNoSuchFile:undefined,errorMessageOther:undefined,errorMessageValidatingFileExtension:undefined,errorMessageAJAXRequestFileSize:undefined,errorMessageMaxUploadedFiles:undefined,errorMessageMaxSimultaneousFiles:undefined,errorMessageTryToRemoveNonExistingFile:undefined,errorMessageTryToStartNonExistingFile:undefined,errorMessageDropMultipleFilesWhenSingleModel:undefined,titleUploadFileButtonInit:undefined,titleAddFileButton:undefined,titleCancelUploadButton:undefined,titleSummaryProgressButtonContinue:undefined,titleClearUploaded:undefined,titleShowDetailsButton:undefined,titleHideDetailsButton:undefined,titleSummaryProgressButtonCancel:undefined,titleSummaryProgressButtonDone:undefined,titleSingleUploadButtonContinue:undefined,titleClearAllButton:undefined},uploadUrl:"ig_fua34sf345sdf13sdf3454erdsf2345asd3425df5235d54df345.aspx",progressUrl:"IGUploadStatusHandler.ashx",allowedExtensions:[],showFileExtensionIcon:true,css:null,fileExtensionIcons:[{ext:[],css:"",def:false}],mode:"single",multipleFiles:false,maxUploadedFiles:-1,maxSimultaneousFilesUploads:1,fileSizeMetric:"auto",controlId:"",fileSizeDecimalDisplay:2,maxFileSize:null,useSingleRequest:false},events:{fileSelecting:"fileSelecting",fileSelected:"fileSelected",fileUploading:"fileUploading",fileUploaded:"fileUploaded",fileUploadAborted:"fileUploadAborted",cancelAllClicked:"cancelAllClicked",onError:"onError",fileExtensionsValidating:"fileExtensionsValidating",onXHRLoad:"onXHRLoad",onFormDataSubmit:"onFormDataSubmit"},summaryButtonModes:{cancel:1,startupload:2,done:3},container:function(){if(this._isDivElement){return this.element}return $("#"+this.element[0].id+"_wrprinit")},widget:function(){return this.element},_id:function(suffix,formNumber){var id=this.element[0].id;if(formNumber!==undefined){return id+"_"+formNumber+"_"+suffix}return id+suffix},_create:function(){var data={formNumber:0,iframe:{ids:[]},pendingQueueIDs:[],uploadingIDs:[],batch:[],lastId:-1,filesInfo:[],countUploadingFiles:0,countTotalFiles:0,fileSizeUploaded:0,fileSizeTotal:0};this.css=$.extend({},this.css,this.options.css);this.allCancelled=false;this.fileInfoData=data;this._renderStartupBrowseButton();this.container().bind("drop",$.proxy(this._dropFiles,this)).width(this.options.width).height(this.options.height);this._attachFakeIframe();this._analyzeFileExtensionIcons();$(document).bind("dragenter."+this.element[0].id,$.proxy(this._docEnter,this));$(document).bind("dragover."+this.element[0].id,$.proxy(this._docOver,this));$(document).bind("dragleave."+this.element[0].id,$.proxy(this._docLeave,this))},_dropFiles:function(e){var isInit=$("#"+this._id("_ibb")).is(":visible"),data={files:e.originalEvent.dataTransfer.files,multiple:true};e.preventDefault();if(isInit){this._initBrowserFileSelect(e,data)}else{this._onBrowseButtonFileSelected(e,false,data)}return false},_docEnter:function(e){e.preventDefault();return false},_docOver:function(e){e.preventDefault();return false},_docLeave:function(e){e.preventDefault();return false},_analyzeFileExtensionIcons:function(){var i,j,arrIconExtensions=this.options.fileExtensionIcons,lengthIconExtensions,defIconExtensions=$.extend(true,[],this.defaultFileExtensionIcons),lengthDefaultIconExtensions=defIconExtensions.length,resArr=[],isDefaultDefined=false;if(arrIconExtensions===undefined||arrIconExtensions===null){this.options.fileExtensionIcons=defIconExtensions;return}lengthIconExtensions=arrIconExtensions.length;if(lengthIconExtensions===1&&arrIconExtensions[0].css===""){this.options.fileExtensionIcons=defIconExtensions;return}for(j=0;j<lengthIconExtensions;j++){for(i=0;i<lengthDefaultIconExtensions;i++){defIconExtensions[i].ext=this._removeCommonElementsInArrays(defIconExtensions[i].ext,arrIconExtensions[j].ext)}if(arrIconExtensions[j].def===true){isDefaultDefined=true}resArr.push(arrIconExtensions[j])}for(i=0;i<lengthDefaultIconExtensions;i++){if(defIconExtensions[i].ext.length>0||isDefaultDefined===false&&defIconExtensions[i].def===true){resArr.push(defIconExtensions[i])}}this.options.fileExtensionIcons=resArr},_removeCommonElementsInArrays:function(arr1,arr2){return $.grep(arr1,function(n){return $.inArray(n,arr2)===-1})},_attachFakeIframe:function(){var idTempIframe=this._id("_tempIframe");if($.ig.util.isIE7||$.ig.util.isIE8||$.ig.util.isIEQuircks){$("#"+idTempIframe).remove();setTimeout($('<iframe src="javascript:false;" '+'id="'+idTempIframe+'" '+'style="display: none;"></iframe>').appendTo($("#"+this._id("_fu"))),300)}},_renderStartupBrowseButton:function(){var self=this,attr,i,css=self.css,e=self.element,o=self.options,bbId=this._id("_ibb"),isMultipleFiles=o.mode==="multiple"&&o.multipleFiles,wrapperElementId=this._id("_wrprinit"),containerDiv,button;if(this.element.is("div")){this._isDivElement=true;this.originalElement=e;containerDiv=e;this._initialAttributes=[];attr=this.element[0].attributes;for(i=0;i<attr.length;i++){if(attr[i].name!=="id"){this._initialAttributes.push({name:attr[i].name,value:attr[i].value})}}this._initialHTML=this.element.html();this.element.empty()}else{this.originalElement=e;containerDiv='<div id="'+wrapperElementId+'" class="ig-upload-container"></div>';e.wrap(containerDiv);e.hide();e=$("#"+wrapperElementId)}bbId=this._id("_ibb");if($.ig.util.isIE7){e.addClass(css.baseClassIE7)}else if($.ig.util.isOpera){e.addClass(css.baseClassOpera)}else if($.ig.util.isOpera){e.addClass(css.baseClassMoz)}else if($.ig.util.isOpera){e.addClass(css.baseClassWebkit)}button=$("<button></button>").appendTo(e).attr("id",bbId).addClass(css.startupBrowseButtonClasses);button.igBrowseButton({multipleFiles:isMultipleFiles,labelText:this._getLocaleValue("labelUploadButton"),container:this.container(),title:this._getLocaleValue("titleUploadFileButtonInit"),fileselect:function(event,data){self._initBrowserFileSelect(event,data)},disabled:o.disabled,click:function(event){var isCancelEvent=false;if(self._trigger(self.events.fileSelecting,event,{owner:self})===false){isCancelEvent=true}return!isCancelEvent}})},_initBrowserFileSelect:function(event,data){var countFiles=1,filePicker,o=this.options;if(!data||!data.files||data.files.length===0){filePicker=$("#"+this._id("_ibb_fp"));if(this._validateFileExtension(filePicker[0].value,true,null)===false){return}}else if(o.mode==="single"&&data.files.length>1){this._setError(this._getLocaleValue("errorMessageDropMultipleFilesWhenSingleModel"),null,this._const.clientSideErrorCode.dropMultipleFilesWhenSingleMode,"clientside");return}if(this._checkMaxUploadingFilesCount(countFiles,true)===true){$("#"+this._id("_ibb")).css({display:"none"});this._HTMLUpload();this._onBrowseButtonFileSelected(event,true,data)}},_HTMLUpload:function(){var uploaderId=this._id("_fu"),baseMainContainerId=this._id("_bmncntr"),o=this.options,e=this.container(),self=this,css=self.css,fileContainerId=this._id("_fc"),browseButtonId=this._id("_bb"),clearAllButtonId=this._id("_clrabtn"),uploaderContainerId=this._id("_fi_main_cntnr"),clearAllButton,html="";if(o.mode==="single"){html+='<div  class="'+css.singleDialogClass+'" id="$baseMainContainerId">';html+='   <div id="$uploaderId$" class="$baseMainContainerClass">';html+='\t\t<div id="$fileContainerId$"></div>';html+='\t\t<button id="$browseButtonId$" class="$browseButtonClass$"></button>';html+="\t</div>";html+="</div>"}else if(o.mode==="multiple"){html='<div class="'+css.multipleDialogClasses+'" id="$baseMainContainerId">';html+='   <div  id="$uploaderId$" class="$baseMainContainerClass">';html+='\t\t<div id="$uploaderFilesContainer" class="$fuMainContainerClass">';html+='\t\t\t<button id="$browseButtonId$" class="$browseButtonClass$"></button>';html+='\t\t\t<button id="$clearAllButtonId$"></button>';html+='\t\t\t<div id="$fileContainerId$"></div>';html+="\t\t</div>";html+="   </div>";html+="</div>"}html=html.replace("$uploaderId$",uploaderId).replace("$browseButtonId$",browseButtonId).replace("$baseMainContainerId",baseMainContainerId).replace("$browseButtonClass$",css.browseButtonClass).replace("$fileContainerId$",fileContainerId).replace("$clearAllButtonId$",clearAllButtonId).replace("$uploaderFilesContainer",uploaderContainerId).replace("$fuMainContainerClass",css.fileInfoMainContainer).replace("$baseMainContainerClass",css.baseMainContainerClass);$(html).appendTo(e).css({width:o.width,height:o.height}).addClass(css.baseClass);clearAllButton=$("#"+clearAllButtonId);if(clearAllButton.length>0){clearAllButton.igButton({title:this._getLocaleValue("titleClearAllButton"),labelText:this._getLocaleValue("labelClearAllButton"),disabled:true,click:function(event){event.preventDefault();self.clearAll()},css:{buttonClasses:"ui-igbutton ui-igupload-button-clear-all",buttonHoverClasses:"",buttonActiveClasses:"",buttonFocusClasses:"",buttonLabelClass:""}})}$("#"+browseButtonId).igBrowseButton({multipleFiles:o.mode==="multiple"&&o.multipleFiles,labelText:this._getLocaleValue("labelAddButton"),container:this.container(),title:this._getLocaleValue("titleAddFileButton"),fileselect:function(event,data){self._onBrowseButtonFileSelected(event,false,data)},click:function(event){var isCancelEvent=false;if(self._trigger(self.events.fileSelecting,event,{owner:self})===false){isCancelEvent=true}return!isCancelEvent}});$("#"+fileContainerId).addClass(css.containerClass);if(o.mode==="multiple"){self._spbRenderInit()}},_disableBrowseButton:function(isToDisable){$("#"+this._id("_bb")).igBrowseButton("option","disabled",isToDisable);$("#"+this._id("_ibb")).igBrowseButton("option","disabled",isToDisable)},_checkMaxUploadingFilesCount:function(count,callEvent){if(count===null||count===undefined){count=1}var o=this.options,allowUpload=true,totalFiles=this.fileInfoData.countTotalFiles+count;if(o.maxUploadedFiles!==this._const.maxUploadFilesDefault&&o.maxUploadedFiles!==null&&totalFiles>o.maxUploadedFiles){allowUpload=false;if(callEvent===true){this._setError(this._getLocaleValue("errorMessageMaxUploadedFiles"),null,this._const.clientSideErrorCode.maxAllowedUploadingFiles,"clientside")}}return allowUpload},_onBrowseButtonFileSelected:function(event,isInitBrowseButton,data){var self=this,allFilesData=this.fileInfoData,o=self.options,fileData,countFiles=1;if(data&&data.files&&data.files.length>=1){countFiles=data.files.length;if(o.mode==="single"){if(countFiles>1){self._setError(this._getLocaleValue("errorMessageDropMultipleFilesWhenSingleModel"),null,self._const.clientSideErrorCode.dropMultipleFilesWhenSingleMode,"clientside");return}}}if(self._checkMaxUploadingFilesCount(countFiles,true)===false){if(data.multiple===true){return}self._disableBrowseButton(true);return}if(o.maxUploadedFiles!==null&&o.maxUploadedFiles!==this._const.maxUploadFilesDefault&&o.maxUploadedFiles===allFilesData.countTotalFiles+countFiles){self._disableBrowseButton(true)}if(o.mode==="single"){if(allFilesData.iframe.ids.length===0){self._removeSingleUpload(allFilesData.lastId);fileData=allFilesData.files||data;if(self._attachIframe(event,isInitBrowseButton,fileData)===true){self._disableBrowseButton(true)}}}else if(o.mode==="multiple"){if(self._attachIframe(event,isInitBrowseButton,data)===false){self._disableBrowseButton(false)}}},clearAll:function(){var e=this.container(),arr=e.data("finishedIDs"),id,l;if(arr===undefined){return}l=arr.length;for(id=0;id<l;id++){this._removeSingleUpload(arr[id])}arr=[];e.data("finishedIDs",arr);this._disableClearAllButton()},_enableClearAllButton:function(){$("#"+this._id("_clrabtn")).igButton({disabled:false})},_disableClearAllButton:function(){$("#"+this._id("_clrabtn")).igButton("option","disabled",true)},_attachIframe:function(event,isInitBrowseButton,data){var res,files,filePicker,browse=$("#"+this._id("_bb"));if(data&&data.files){files=data.files}if(isInitBrowseButton===true){filePicker=$("#"+this._id("_ibb")).igBrowseButton("getFilePicker")}else{filePicker=browse.igBrowseButton("getFilePicker")}if(filePicker[0].files&&(files===null||files===undefined)){files=filePicker[0].files}if(files&&files.length>=1){res=this._uploadMultiple(files);filePicker.remove()}else{res=this._createForm(filePicker)}return res},_uploadMultiple:function(files){var res,i,filesLength=files.length,data=this.fileInfoData,fileId=data.formNumber,o=this.options;for(i=0;i<filesLength;i++){res=this._html5createForm(files[i],i,fileId)}if(o.autostartupload&&o.useSingleRequest){var retVal=this._html5upload();if(retVal){data.batch=[];this._spbCheckModeButton()}else{var idsToRemove=data.batch;for(i=0;i<idsToRemove.length;i++){var id=idsToRemove[i];this._removeIframe(id);this._removeFileUpload(id)}}}return res},_html5upload:function(fileId){var xhr=new XMLHttpRequest,formData=new FormData,o=this.options,self=this,cid=o.controlId,upload=xhr.upload;var fileInfo,file,key,uploadUrl;if(fileId!==undefined){fileInfo=this.fileInfoData.filesInfo[fileId];file=fileInfo.file;key=fileInfo.key;uploadUrl=o.uploadUrl+"?key="+key+"&cid="+cid+"&multiple=true";xhr.open("POST",uploadUrl);xhr.withCredentials="true";self._trigger(self.events.onFormDataSubmit,null,{formData:formData,fileId:fileId,fileInfo:fileInfo,xhr:xhr,owner:self});formData.append(this._id("_frm",fileId)+"_if",file);this.fileInfoData.filesInfo[fileId].xhr=xhr}else{var idsToSend=this.fileInfoData.batch,fileSize=0;fileInfo=[];file=[];key="";fileId=[];for(var i=0;i<idsToSend.length;i++){var currentFileId=idsToSend[i],currentFileInfo=this.fileInfoData.filesInfo[currentFileId],currentFile=currentFileInfo.file,currentKey=currentFileInfo.key,currentFileSize=0;if(currentFile){currentFileSize=currentFile.size}if($.type(currentFileSize)==="number"){fileSize+=currentFileSize}formData.append(this._id("_frm",currentFileId)+"_if",currentFile);this.fileInfoData.filesInfo[currentFileId].xhr=xhr;fileInfo.push(currentFileInfo);file.push(currentFile);if(key===""){key+=currentKey}else{key+=";"+currentKey}fileId.push(currentFileId);var eventArgs={formData:formData,fileId:currentFileId,fileInfo:currentFileInfo,xhr:xhr,owner:self};self._trigger(self.events.onFormDataSubmit,null,eventArgs)}if($.type(o.maxFileSize)==="number"&&$.type(fileSize)==="number"&&o.maxFileSize>-1&&fileSize>o.maxFileSize){self._setError(fileId,this._getLocaleValue("errorMessageMaxFileSizeExceeded"),self._const.clientSideErrorCode.maxFileSizeExcceeded,"clientside");return false}uploadUrl=o.uploadUrl+"?key="+key+"&cid="+cid+"&multiple=true";xhr.open("POST",uploadUrl);xhr.withCredentials="true"}upload.addEventListener("progress",function(e){self._html5progress(e,fileId)},false);upload.addEventListener("error",function(){self._getFileStatus(fileId,true)},false);xhr.onload=function(e){var responseText,response,error,msg;self._trigger(self.events.onXHRLoad,e,{fileId:fileId,xhr:xhr,fileInfo:fileInfo,owner:self});if(xhr.status>=200&&xhr.status<=299){responseText=xhr.responseText;if(responseText){response=self._stringToXmlObject(responseText);if(response){error=parseInt(response.find("error").text(),10);msg=response.find("serverMessage").text()}else{response=self._stringToJSONObject(responseText);if(response){error=parseInt(response.error,10);msg=response.serverMessage}}fileInfo.serverMessage=msg;if(!isNaN(error)){if(msg){self._setFileStatus(fileId,true,{error:error,serverMessage:msg})}else{self._getFileStatus(fileId,true)}return}self._html5progress(e,fileId,true)}else{self._html5progress(e,fileId,true)}}else{self._getFileStatus(fileId,true)}};xhr.send(formData);return true},_html5progress:function(e,formInfo,isFinish){if(typeof formInfo==="number"){this._html5progressSingle(e,formInfo,isFinish)}else{for(var i=0;i<formInfo.length;i++){this._html5progressSingle(e,formInfo[i],isFinish)}}},_html5progressSingle:function(e,formNumber,isFinish){var self=this,singleFileData,data={};if(e.lengthComputable||isFinish){singleFileData=this.getFileInfo(formNumber);if(singleFileData&&singleFileData.innerStatus===self._const.status.Canceled){return}data.size=e.total||0;data.bytesUploaded=e.loaded>singleFileData.sizeBytes?singleFileData.sizeBytes:e.loaded||0;if(isFinish){data.total=data.bytesUploaded=singleFileData.sizeBytes;data.status=self._const.status.Finished}else{data.status=self._const.status.Started}self._setFileStatus(formNumber,true,data)}else{self.cancelUpload(formNumber)}},addDataField:function(formData,field){if(!field||$.type(field)!=="object"){return}this.addDataFields(formData,[field])},addDataFields:function(formData,fields){if(!formData||$.type(fields)!=="array"||!fields.length){return}var i,len=fields.length,f,isHTMLForm;isHTMLForm=formData.length&&formData.is("form");if(!isHTMLForm){if(!(formData instanceof FormData)){return}}for(i=0;i<len;i++){f=fields[i];if(!f.name||$.type(f.value)!=="string"){continue}if(isHTMLForm){$("<input />").attr({type:"hidden",name:f.name,value:f.value}).appendTo(formData)}else{formData.append(f.name,f.value)}}},_html5createForm:function(fileInfo,ind,formNumber){var self=this,o=self.options,fileName=fileInfo.name,fileSize=fileInfo.size,data=this.fileInfoData,fileId=data.formNumber++,key=self._randomString(30),status=self._const.status.Started;if(self._validateFileExtension(fileInfo.name,true,formNumber)===false){if(o.mode==="multiple"){self._spbRenderProgress()}if(o.maxUploadedFiles!==null&&o.maxUploadedFiles>=data.countTotalFiles+1){self._disableBrowseButton(false)}return false}if(isNaN(fileSize)){fileSize=0}data.filesInfo[fileId]={path:fileName,key:key,sizeBytes:fileSize,uploadedBytes:0,status:self._const.status.NotStarted,checksNoSuchFile:0,innerStatus:self._const.status.NotStarted,multipleFiles:true,file:fileInfo,formNumber:formNumber};data.countTotalFiles++;self._spbRenderProgress();self._HTMLSingleUpload(fileId);this._saveFileSize(fileSize,fileId);if(o.autostartupload===true&&o.useSingleRequest===false){if(self._checkCanUpload()===true){self.startUpload(fileId)}else{self._addPendingId(fileId);status=self._const.status.NotStarted}}else{if(o.mode==="single"){self._showSingleUploadStartUpload(true,fileId)}else{self._addIDBatch(fileId);status=self._const.status.NotStarted}}data.iframe.ids[data.iframe.ids.fileId]={id:fileId,status:status};if(o.mode==="multiple"){self._spbCheckModeButton()}self._trigger(self.events.fileSelected,null,{owner:self,fileId:fileId,filePath:self._getOnlyFileName(fileName)});return true},_createForm:function(filePicker){var self=this,o=self.options,data=this.fileInfoData,fileId=data.formNumber++,iframeId=this._id("_ifrm",fileId),formId=this._id("_frm",fileId),form,key=self._randomString(30),status=self._const.status.Started,cid=o.controlId,uploadUrl=o.uploadUrl+"?key="+key+"&cid="+cid;if(self._validateFileExtension(filePicker[0].value,true,fileId)===false){filePicker.remove();if(o.mode==="multiple"){self._spbRenderProgress()}if(o.maxUploadedFiles!==null&&o.maxUploadedFiles>=data.countTotalFiles+1){self._disableBrowseButton(false)}return false}data.filesInfo[fileId]={path:filePicker.val(),key:key,sizeBytes:0,uploadedBytes:0,status:self._const.status.NotStarted,checksNoSuchFile:0,innerStatus:self._const.status.NotStarted};data.countTotalFiles++;self._spbRenderProgress();$('<iframe src="javascript:false;" id="'+iframeId+'" name="'+iframeId+'"></iframe>').appendTo($(document.body)).css({display:"none"});form=$('<form method="post" enctype="multipart/form-data"></form>').attr("id",formId).attr("target",iframeId).attr("action",uploadUrl).appendTo($(document.body));filePicker.attr("name",formId+"_if").attr("id",formId+"_if").appendTo(form);self._trigger(self.events.onFormDataSubmit,null,{formData:form,fileId:fileId,fileInfo:data.filesInfo[fileId],owner:self});self._HTMLSingleUpload(fileId);if(o.autostartupload===true){if(self._checkCanUpload()===true){self.startUpload(fileId)}else{self._addPendingId(fileId);status=self._const.status.NotStarted;self._getFileSize(fileId,key)}}else{if(o.mode==="single"){self._showSingleUploadStartUpload(true,fileId);self._getFileSize(fileId,key)}else{self._addIDBatch(fileId);status=self._const.status.NotStarted;self._getFileSize(fileId,key)}}data.iframe.ids[data.iframe.ids.fileId]={id:fileId,status:status};if(o.mode==="multiple"){self._spbCheckModeButton()}self._trigger(self.events.fileSelected,event,{owner:self,fileId:fileId,filePath:self._getOnlyFileName(filePicker.val())});return true},_showSingleUploadStartUpload:function(){var self=this,startUploadButtonId="_strtuplbtn",startUploadButton=$("#"+this._id(startUploadButtonId)),browseButton=$("#"+this._id("_bb"));if(startUploadButton.length===0){$('<button id="'+self._id(startUploadButtonId)+'"></button>').appendTo($("#"+self._id("_fu"))).igButton({labelText:this._getLocaleValue("labelSummaryProgressButtonContinue"),title:this._getLocaleValue("titleSingleUploadButtonContinue"),click:function(e){e.preventDefault();self.startUpload(self.fileInfoData.formNumber-1,e);browseButton.igBrowseButton("attachFilePicker",e,true)}});startUploadButton=$("#"+this._id(startUploadButtonId))}browseButton.hide();startUploadButton.show()},_removeIframe:function(iframeNumber){var self=this,data=this.fileInfoData,iframeId=this._id("_ifrm",iframeNumber),formId=this._id("_frm",iframeNumber),browseButton=$("#"+self._id("_bb"));$("#"+iframeId).remove();$("#"+formId).remove();data.iframe.ids=self._removeElementArrayById(data.iframe.ids,iframeNumber);
if(self.options.mode==="single"){browseButton.igBrowseButton("option","disabled",false);data.lastId=iframeNumber}this._attachFakeIframe()},_HTMLSingleUpload:function(formNumber){var self=this,o=this.options,css=self.css,fileContainerId=self._id("_fc"),fileUploadStatusId=self._id("_fus",formNumber),singleProgressBarId=self._id("_snglpbar",formNumber),iconId=self._id("_icn",formNumber),cancelButtonId=self._id("_cbtn",formNumber),fileContainer=$("#"+fileContainerId),fileName=this.fileInfoData.filesInfo[formNumber].path,html,progressBarFileNameId=self._id("_pbrflnm",formNumber),progressBarFileSizeId=self._id("_pbrflsz",formNumber),progressBarFileName,singleProgressBar,iconClass=self._getFileExtensionIconPath(self._getFileExtension(fileName));html='<div id="'+fileUploadStatusId+'">';html+='\t<div class="'+css.containerFUS+'">';html+='\t\t<div class="'+css.containerButtonCancelClass+'">';html+='\t\t\t<button id="'+cancelButtonId+'"></button>';html+="\t\t</div>";html+='\t\t<div class="'+css.progressContainer+'">';html+='\t\t\t<div class="'+css.progressBarInnerHTMLContainerClass+'" ';html+='\t\t\ttitle="'+fileName+'">';html+='\t\t\t\t<span id="'+iconId+'" class="'+iconClass+'"></span>';html+='\t\t\t\t<span class="'+css.progressBarFileNameClass+'" ';html+='\t\t\t\t\tid="'+progressBarFileNameId+'">';html+="\t\t\t\t</span>";html+='\t\t\t\t<span class="'+css.progressBarFileSizeClass+'" ';html+='\t\t\t\t\tid="'+progressBarFileSizeId+'">';html+="\t\t\t\t</span>";html+="\t\t\t</div>";html+='\t\t\t<div id="'+singleProgressBarId+'"';html+='\t\t\t\tclass="'+css.progressBarUploadClass+'">';html+="\t\t\t</div>";html+="\t\t</div>";html+="\t</div>";html+="</div>";$(html).appendTo(fileContainer);$("#"+fileUploadStatusId).addClass(css.uploadProgressClass+" "+css.clearClass);singleProgressBar=$("#"+singleProgressBarId);$("#"+cancelButtonId).igButton({onlyIcons:true,icons:{primary:"ui-icon-closethick"},title:this._getLocaleValue("titleCancelUploadButton"),click:function(event){event.preventDefault();self.cancelUpload(formNumber);$("#"+cancelButtonId).igButton("option",{disabled:true,icons:{primary:"ui-icon-check",secondary:null}})},css:{buttonClasses:"ui-button ui-widget "+"ui-state-default "+"ui-corner-all "+"ui-button-icon-only "+"ui-igbutton "+"ui-igupload-cancel-button",buttonHoverClasses:"ui-state-hover",buttonActiveClasses:"ui-state-active",buttonFocusClasses:"ui-state-focus",buttonLabelClass:"ui-button-text",buttonDisabledClass:"ui-state-disabled",buttonPrimaryIconClass:"ui-button-icon-primary ui-icon",buttonMainElementPrimaryIconClass:" ui-button-text-icon-primary",buttonMainElementSecondaryIconClass:" ui-button-text-icon-secondary",buttonSecondaryIconClass:"ui-button-icon-secondary ui-icon",buttonIconsOnly:"ui-button-icons-only",buttonIconOnly:"ui-button-icon-only",buttonIcons:"ui-button-text-icons",buttonTextOnlyClass:"ui-button-text-only"}});singleProgressBar.igProgressBar({animate:self._const.isProgressBarAnimationEnabled,animateTimeout:self._const.animateProgressBarInterval,range:self._const.isProgressBarRange,value:0,queue:false});if(!o.showFileExtensionIcon){$("#"+iconId).css("display","none")}progressBarFileName=$("#"+progressBarFileNameId);fileName=self._getOnlyFileName(fileName);singleProgressBar.data("originalFileName",fileName);if(fileName.length>self._const.fileNameLimit){fileName=fileName.substr(0,self._const.fileNameLimit)}progressBarFileName.text(self._formatFilePath(fileName));self._renderFileName(formNumber,0,fileName)},_renderFileName:function(formNumber,fileSize,fn){var self=this,fileName=fn,previousFileName="",originalFileSize,progressBarFileName=$("#"+self._id("_pbrflnm",formNumber)),progressBarFileSize=$("#"+self._id("_pbrflsz",formNumber)),singleProgressBarWidth=$("#"+self._id("_snglpbar",formNumber)).width(),singleProgressBar=$("#"+self._id("_snglpbar",formNumber)),progressBarFileSizeWidth=progressBarFileSize.width(),offsetLeft;if(progressBarFileName.length===0){return}if(fileName===undefined||fileName===null){fileName=singleProgressBar.data("fileName")}if(singleProgressBarWidth<=0){fileName=this._getLocaleValue("labelProgressBarFileNameContinue");progressBarFileName.text(fileName)}else{if(fileSize!==0&&fileSize!==undefined&&fileSize!==null){originalFileSize=progressBarFileSize.text();progressBarFileSizeWidth=progressBarFileSize.text(self._formatFileSize(fileSize)+"/"+self._formatFileSize(fileSize)).width();progressBarFileSize.text(originalFileSize)}offsetLeft=progressBarFileName.igPosition().left-this.container().igPosition().left;while(offsetLeft+progressBarFileName.width()+progressBarFileSizeWidth>=singleProgressBarWidth&&previousFileName!==fileName){previousFileName=fileName;fileName=fileName.substr(0,fileName.length/2);if(previousFileName===fileName&&fileName.length-1>1){fileName=fileName.substr(0,(fileName.length-1)/2)}progressBarFileName.text(fileName+this._getLocaleValue("labelProgressBarFileNameContinue"))}if(offsetLeft+progressBarFileName.width()+progressBarFileSize.width()>=singleProgressBarWidth){fileName=this._getLocaleValue("labelProgressBarFileNameContinue")}}singleProgressBar.data("fileName",fileName)},_removeSingleUpload:function(formNumber){var self=this,fileUploadStatusId=self._id("_fus",formNumber),fileUploadStatusTmpId=fileUploadStatusId+"_"+self._randomString(20);if(self.options.mode==="multiple"){$("#"+fileUploadStatusId).attr("id",fileUploadStatusTmpId);self._renderAnimatedRemovingUpload(fileUploadStatusTmpId)}else if(self.options.mode==="single"){$("#"+fileUploadStatusId).hide().remove()}},_renderAnimatedRemovingUpload:function(id){$("#"+id).slideUp(this._const.removeSingleUploadAnimationTimeout,function(){$(this).remove()})},startUpload:function(formNumber){var self=this,o=this.options,formId=self._id("_frm",formNumber),allFilesData=this.fileInfoData,fileInfo=allFilesData.filesInfo[formNumber],file,fileSize,isHTML5=false;if(arguments.length===0&&o.useSingleRequest){var retVal=this._html5upload();if(retVal){this.fileInfoData.batch=[]}return}if(formNumber===null||fileInfo===null||fileInfo===undefined){self._setError(this._getLocaleValue("errorMessageTryToStartNonExistingFile").replace("{0}",formNumber),formNumber,self._const.clientSideErrorCode.startUpload,"clientside");return}file=fileInfo.file;if(file){fileSize=file.size}if($.type(o.maxFileSize)==="number"&&$.type(fileSize)==="number"&&o.maxFileSize>-1&&fileSize>o.maxFileSize){self._removeUploadSetError(formNumber,this._getLocaleValue("errorMessageMaxFileSizeExceeded"),self._const.clientSideErrorCode.maxFileSizeExcceeded,"clientside");return false}if(fileInfo.status!==self._const.status.NotStarted){return}isHTML5=fileInfo.multipleFiles;if(isHTML5!==true){$("#"+formId).submit()}else{this._html5upload(formNumber)}self._addUploadingID(formNumber);self._removeIDBatch(formNumber);self._spbCheckModeButton();fileInfo.status=self._const.status.Started;fileInfo.innerStatus=self._const.status.Started;self._spbRenderProgress();if(o.mode==="single"){$("#"+self._id("_strtuplbtn")).hide();$("#"+self._id("_bb")).igBrowseButton("option","disabled",true).show()}if(isHTML5===true){return}setTimeout(function(){self._getFileStatus(formNumber,true)},self._const.progressUpdateInterval)},_setFileStatus:function(formNumber,isNewFile,data){if(!data){return}var self=this,o=self.options,eArgs,isFinishUpload=false,status="",bytesUploaded=0,fileSize=0,singleFileData=this.getFileInfo(formNumber),allFilesData=this.fileInfoData,key=self._getKey(formNumber),fileName,error,isError,serverMessage="";if(key===null||key===undefined||!singleFileData){return false}fileName=singleFileData.path;bytesUploaded=parseInt(data.bytesUploaded,10);status=parseInt(data.status,10);if(singleFileData.file){data.size=singleFileData.file.size}fileSize=parseInt(data.size,10);serverMessage=data.serverMessage;isFinishUpload=status===self._const.status.Finished;error=parseInt(data.error,10);isError=!isNaN(error)&&error!==self._const.fileStatusNoError;if(serverMessage){singleFileData.serverMessage=serverMessage}if(singleFileData.innerStatus===self._const.status.Canceled&&isError){self._setError(this._getLocaleValue("errorMessageOther").replace("{0}",error),formNumber,error,"serverside",serverMessage);return false}if(isError===true&&status!==self._const.status.NoSuchFile){self._removeUploadSetError(formNumber,this._getLocaleValue("errorMessageOther").replace("{0}",error),error,"serverside",serverMessage);return false}if(singleFileData!==null&&singleFileData.status!==self._const.status.Canceled){allFilesData.fileSizeUploaded-=singleFileData.uploadedBytes;if(singleFileData.sizeBytes===0||singleFileData.sizeBytes===null){singleFileData.sizeBytes=fileSize;allFilesData.fileSizeTotal+=fileSize}else if(singleFileData.sizeBytes!==fileSize){fileSize=singleFileData.sizeBytes}if(isFinishUpload){allFilesData.countUploadingFiles++}if(bytesUploaded===0&&singleFileData.uploadedBytes>0){bytesUploaded=singleFileData.uploadedBytes}singleFileData.uploadedBytes=bytesUploaded;singleFileData.status=status;allFilesData.fileSizeUploaded+=singleFileData.uploadedBytes;self._spbRenderProgress();eArgs={fileId:formNumber,filePath:self._getOnlyFileName(fileName),totalSize:fileSize,uploadedBytes:bytesUploaded,fileStatus:status,fileInfo:singleFileData,owner:self};if(self._trigger(self.events.fileUploading,null,eArgs)===false){self.cancelUpload(formNumber)}}if(isFinishUpload||status===self._const.status.Started){if(isFinishUpload){self._removeUploadingID(formNumber);if(o.mode==="multiple"){self._spbCheckModeButton();self._submitNextPendingId()}}self._renderStatus(formNumber,bytesUploaded,fileSize,isFinishUpload,singleFileData);if(!isFinishUpload){return true}}else if(status===self._const.status.NoSuchFile){if(singleFileData!==null&&singleFileData!==undefined&&singleFileData.checksNoSuchFile===0){singleFileData.checksNoSuchFile++;return true}self._removeUploadSetError(formNumber,this._getLocaleValue("errorMessageNoSuchFile"),"nosuchfilekeyid","serverside",serverMessage)}return false},_getFileStatus:function(formNumber,isNewFile){var self=this,o=self.options,key=self._getKey(formNumber);if(key===null||key===undefined){return}key=key.replace("-$#","").replace("#$-","");$.ajaxQueue("uploadrequestsqueue",{url:self._formatURL(o.progressUrl,$.param({key:key,command:"status"})),dataType:"json",cache:false,success:function(data){if(self._setFileStatus(formNumber,isNewFile,data)===true){setTimeout(function(){self._getFileStatus(formNumber,false)},self._const.progressUpdateInterval)}},error:function(){self._setError(self._getLocaleValue("errorMessageGetFileStatus"),formNumber,self._const.clientSideErrorCode.ajaxErrorGetFileStatus,"clientside")}})},_removeUploadSetError:function(formNumber,errorMessage,errorCode,errorType,serverMessage){var self=this,o=this.options;self._removeIframe(formNumber);self._removeFileUpload(formNumber);self._setError(errorMessage,formNumber,errorCode,errorType,serverMessage);if(o.mode==="multiple"){self._spbCheckModeButton();self._submitNextPendingId()}else{$("#"+this._id("_strtuplbtn")).hide();$("#"+this._id("_bb")).igBrowseButton("option","disabled",false).show()}},cancelUpload:function(formNumber){var self=this,eArgs,o=self.options,singleProgressBarId=self._id("_snglpbar",formNumber),singleProgressBar=$("#"+singleProgressBarId),filePicker=$("#"+self._id("_frm",formNumber)+"_if"),fileName=filePicker.val(),totalSize=0,bytesUploaded=0,key=this._getKey(formNumber),singleFileInfo=this.getFileInfo(formNumber);totalSize=singleProgressBar.data("totalSize");bytesUploaded=singleProgressBar.data("bytesUploaded");if(totalSize===undefined){totalSize=0}if(bytesUploaded===undefined){bytesUploaded=0}if(singleFileInfo!==null){if(singleFileInfo.status===self._const.status.Started){singleFileInfo.innerStatus=self._const.status.Canceled;if(singleFileInfo.multipleFiles===true){if(singleFileInfo.xhr){singleFileInfo.xhr.abort()}self._onCancelUpload(formNumber)}else{$.ajaxQueue("uploadrequestsqueue",{url:self._formatURL(o.progressUrl,$.param({key:key,command:"cancel"})),dataType:"json",cache:false,success:function(){self._onCancelUpload(formNumber)},error:function(){self._setError(self._getLocaleValue("errorMessageCancelUpload"),formNumber,self._const.clientSideErrorCode.ajaxErrorCancelUpload,"clientside");self._removeFileUpload(formNumber)}})}}else if(singleFileInfo.status===self._const.status.NotStarted){if(o.mode==="single"){$("#"+this._id("_strtuplbtn")).hide();$("#"+this._id("_bb")).igBrowseButton("option","disabled","false").show()}eArgs={fileId:formNumber,filePath:self._getOnlyFileName(fileName),uploadedBytes:0,totalSize:totalSize,status:self._const.status.NotStarted,owner:self};self._trigger(self.events.fileUploadAborted,null,eArgs);self._removeFileUpload(formNumber)}}},_onCancelUpload:function(formNumber){var eArgs,self=this,o=self.options,continueButton=null,totalSize=0,bytesUploaded=0,allIds=null,singleFileInfo=this.getFileInfo(formNumber),fileName=singleFileInfo.path;if(o.autostartupload===false&&o.mode==="multiple"){continueButton=$("#"+self._id("_spbtncncl"));allIds=continueButton.data("ids");allIds=self._removeElementFromArray(allIds,formNumber);continueButton.data("ids",allIds)}eArgs={fileId:formNumber,filePath:self._getOnlyFileName(fileName),uploadedBytes:bytesUploaded,totalSize:totalSize,status:self._const.status.Canceled,owner:self};self._trigger(self.events.fileUploadAborted,null,eArgs);self._removeFileUpload(formNumber)},_removeFileUpload:function(formNumber){var self=this,o=self.options,cancelButtonId=self._id("_cbtn",formNumber),singleProgressBarId=self._id("_snglpbar",formNumber),singleProgressBar=$("#"+singleProgressBarId),totalSize=0,bytesUploaded=0,allFilesData=this.fileInfoData,singleFileInfo=this.getFileInfo(formNumber);if(singleFileInfo===null){self._setError(this._getLocaleValue("errorMessageTryToRemoveNonExistingFile").replace("{0}",formNumber),formNumber,self._const.clientSideErrorCode.removeFileUpload,"clientside");return}totalSize=singleProgressBar.data("totalSize");bytesUploaded=singleProgressBar.data("bytesUploaded");if(totalSize===undefined){totalSize=0}if(bytesUploaded===undefined){bytesUploaded=0}allFilesData.countTotalFiles--;singleFileInfo.status=self._const.status.Canceled;allFilesData.fileSizeUploaded-=singleFileInfo.uploadedBytes;allFilesData.fileSizeTotal-=singleFileInfo.sizeBytes;self._spbRenderProgress();self._removeUploadingID(formNumber);if(o.mode==="multiple"){self._removePendingId(formNumber);self._removeIDBatch(formNumber);if(this.allCancelled===false){self._submitNextPendingId()}self._spbCheckModeButton()}$("#"+cancelButtonId).remove();self._removeIframe(formNumber);self._removeSingleUpload(formNumber);self._disableBrowseButton(!self._checkMaxUploadingFilesCount())},_getKey:function(formNumber){var a=this.fileInfoData.filesInfo[formNumber];if(a!==null&&a!==undefined){return a.key}return null},_singleFileUploadFinished:function(formNumber){var e=this.container(),self=this,arr;$("#"+self._id("_cbtn",formNumber)).igButton("option",{disabled:true,icons:{primary:"ui-icon-check",secondary:null}});self._removeIframe(formNumber);if(self.options.mode==="multiple"){self._enableClearAllButton();arr=e.data("finishedIDs");if(arr===undefined){arr=[]}arr.push(formNumber);e.data("finishedIDs",arr)}},_renderStatus:function(formNumber,bytesUploaded,fileSize,isFinished,fileInfo){var self=this,eArgs,originalFileName,statusLabel=$("#"+self._id("_pbrflsz",formNumber)),singleProgressBarId=self._id("_snglpbar",formNumber),singleProgressBar=$("#"+singleProgressBarId),percentUploaded=0,fileNameRendered;if(isFinished){bytesUploaded=fileSize;self._singleFileUploadFinished(formNumber)}if(fileSize!==0&&isNaN(bytesUploaded)===false&&isNaN(fileSize)===false){percentUploaded=bytesUploaded/fileSize*100}else if(isFinished){percentUploaded=100}singleProgressBar.data("totalSize",fileSize);singleProgressBar.data("bytesUploaded",bytesUploaded);fileNameRendered=singleProgressBar.data("isFileNameRendered");originalFileName=singleProgressBar.data("originalFileName");singleProgressBar.igProgressBar("option","value",percentUploaded);statusLabel.text(self._formatFileSize(bytesUploaded)+"/"+self._formatFileSize(fileSize));if(fileNameRendered!==true){singleProgressBar.data("isFileNameRendered",true);self._renderFileName(formNumber,fileSize)}if(isFinished){eArgs={fileId:formNumber,filePath:originalFileName,totalSize:bytesUploaded,fileInfo:fileInfo,owner:self};self._trigger(self.events.fileUploaded,null,eArgs);if(self._checkMaxUploadingFilesCount()===false){self._disableBrowseButton(true);return}}},_formatURL:function(url,args){if(url.indexOf("?")===-1){url+="?"}url+=args;return url},_showHideIcons:function(properties){var files=this.fileInfoData.filesInfo,i;for(i in files){if(files[i]!==undefined){$("#"+this._id("_icn",i)).css(properties)}}},_setWidthHeightAllUploads:function(value,isHeight){var files=this.fileInfoData.filesInfo,option=isHeight?"height":"width",i;for(i in files){if(files[i]!==undefined){$("#"+this._id("_snglpbar",i)).igProgressBar("option",option,value)}}},changeLocale:function(){var $button=$("#"+this._id("_ibb")),$sumarryProgressTmp=$("#upload_summplbl"),self=this;this._super();if($sumarryProgressTmp.length){$sumarryProgressTmp.text(this._getLocaleValue("labelSummaryTemplate").replace("{0}",this.fileInfoData.countUploadingFiles).replace("{1}",this.fileInfoData.countTotalFiles))}if($button.length){$button.igBrowseButton("option",{labelText:this._getLocaleValue("labelUploadButton"),title:this._getLocaleValue("titleUploadFileButtonInit")})}$button=$("#"+this._id("_bb"));if($button.length){$button.igBrowseButton("option",{labelText:this._getLocaleValue("labelAddButton"),title:this._getLocaleValue("titleAddFileButton")})}$button=$("#"+this._id("_clrabtn"));if($button.length){$button.igButton("option",{title:this._getLocaleValue("titleClearAllButton"),labelText:this._getLocaleValue("labelClearAllButton")})}$button=$("#"+this._id("_spbtncncl"));if($button.length){$button.igButton("option",{title:this._getLocaleValue("titleShowDetailsButton"),labelText:this._getLocaleValue("labelSummaryProgressButtonCancel")})}$button=$("button[id$='cbtn']");if($button.length){$button.each(function(){$(this).igButton("option",{title:self._getLocaleValue("labelSummaryProgressButtonCancel")})})}},_setOption:function(key,value){var originalMode=this.options.mode,originalAutoStartUpload=this.options.autostartupload;this._superApply(arguments);switch(key){case"width":this.container().width(value);$("#"+this._id("_bmncntr")).width(value);this._reRenderFileSizeMetrics();this._reRenderFileNames();break;case"height":this.container().height(value);$("#"+this._id("_bmncntr")).height(value);break;case"labelSummaryProgressButtonDone":if(this.spbButtonMode===this.summaryButtonModes.done){$("#"+this._id("_spbtncncl")).igButton("option","labelText",value)}break;case"showFileExtensionIcon":this._showHideIcons({display:!value?"none":"block"});break;case"fileSizeMetric":this._reRenderFileSizeMetrics();break;case"fileSizeDecimalDisplay":this._reRenderFileSizeMetrics();break;case"maxUploadedFiles":this._disableBrowseButton(!this._checkMaxUploadingFilesCount());break;case"mode":if(originalMode!==value){this._destroyMarkup();this._create()}break;case"disabled":this._disableBrowseButton(value);break;case"autostartupload":if(value===true&&value!==originalAutoStartUpload){this._spbSubmitAllButton()}break}},_reRenderFileSizeMetrics:function(){var data=this.fileInfoData.filesInfo,l=data.length,i,bytesUploaded=0,self=this,fileSize,statusLabel,singleProgressBar;for(i=0;i<l;i++){statusLabel=$("#"+self._id("_pbrflsz",i));if(statusLabel.length===0){continue}fileSize=data[i].sizeBytes;bytesUploaded=data[i].uploadedBytes;singleProgressBar=$("#"+self._id("_snglpbar",i));statusLabel.text(self._formatFileSize(bytesUploaded)+"/"+self._formatFileSize(fileSize));singleProgressBar.data("isFileNameRendered",true);self._renderFileName(i,fileSize);$("#"+self._id("_summpbrlbl_1")).width($("#"+this._id("_summpbar")).width())}this._spbRenderProgress()},_destroyMarkup:function(){var i,attr,startupButton=$("#"+this._id("_ibb")),browseButton=$("#"+this._id("_bb")),baseMainContainer=$("#"+this._id("_bmncntr"));if(!this._isDivElement){this.originalElement.show().unwrap()}startupButton.igBrowseButton("destroy");browseButton.igBrowseButton("destroy");startupButton.remove();baseMainContainer.remove();if(!this._isDivElement){this.container().remove()}else{this.element.empty();attr=this.element[0].attributes;for(i=0;i<attr.length;i++){if(attr[i].name!=="id"){this.element.removeAttr(attr[i].name)}}for(i=0;i<this._initialAttributes.length;i++){if(this._initialAttributes[i].name!=="id"){this.element.attr(this._initialAttributes[i].name,this._initialAttributes[i].value)}}this.element.html(this._initialHTML)}},destroy:function(){this._destroyMarkup();this._superApply(arguments)},_getFileSize:function(formNumber,key){var self=this,o=this.options,formId=this._id("_fszfrm",formNumber),filePicker=$("#"+self._id("_frm",formNumber)+"_if"),iframeId=this._id("_fszifrm",formNumber),form,url=self._formatURL(o.uploadUrl,$.param({key:key,command:"fileSize"}));$('<iframe src="javascript:false;" id="'+iframeId+'" name="'+iframeId+'"></iframe>').appendTo($(document.body)).css({display:"none"});$('<form method="post" id="'+formId+'" target="'+iframeId+'" enctype="multipart/form-data"></form>').appendTo($(document.body)).css({display:"none"}).attr("action",url);form=$("#"+formId);filePicker.appendTo(form);form.submit();form.remove();$("#"+iframeId).ready(function(){setTimeout(function(){self._sendRequestFileSize(formNumber,key)},self._const.timeoutGetFileSize)});filePicker.appendTo($("#"+self._id("_frm",formNumber)))},_removeGetFileSizeHTML:function(formNumber){var iframeGetFileSize=$("#"+this._id("_fszifrm",formNumber)),formGetFileSize=$("#"+this._id("_fszfrm",formNumber));iframeGetFileSize.remove();formGetFileSize.remove()},_sendRequestFileSize:function(formNumber,key){var self=this,o=this.options,singleFileData=this.getFileInfo(formNumber);if(singleFileData.sizeBytes!==0){return}$.ajaxQueue("uploadrequestsqueue",{url:self._formatURL(o.progressUrl,$.param({key:key,command:"fileSize"})),dataType:"json",cache:false,success:function(data){var fileSize=parseInt(data.fileSize,10);self._saveFileSize(fileSize,formNumber);self._removeGetFileSizeHTML(formNumber)},error:function(){self._setError(self._getLocaleValue("errorMessageAJAXRequestFileSize"),formNumber,self._const.clientSideErrorCode.ajaxErrorRequestFileSize,"clientside");self._removeGetFileSizeHTML(formNumber)}})},_saveFileSize:function(fileSize,formNumber){var self=this,singleProgressBarId=self._id("_snglpbar",formNumber),singleProgressBar=$("#"+singleProgressBarId),allFilesData=this.fileInfoData,singleFileData=this.getFileInfo(formNumber);if(isNaN(fileSize)===true){return}singleProgressBar.data("totalSize",fileSize);if(singleFileData!==null){singleFileData.sizeBytes=fileSize;allFilesData.fileSizeTotal+=fileSize;self._spbRenderProgress()}self._renderStatus(formNumber,0,fileSize,false,singleFileData)},_onShowHideDetailsClick:function(){var self=this,fileContainer=$("#"+self._id("_fc")),marginTop=fileContainer.css("margin-top"),marginBottom=fileContainer.css("margin-bottom");if($.ig.util.isIE7||$.ig.util.isIEQuircks){self._setShowHideDetailsButtonText(fileContainer.is(":hidden"));if(fileContainer.is(":hidden")){fileContainer.show();self._reRenderFileNames()}else{fileContainer.hide()}self._setShowHideDetailsButtonText(fileContainer.is(":hidden"))}else{fileContainer.css({"margin-top":0,"margin-bottom":0});fileContainer.slideToggle(self._const.showHideDetailsAnimationTimeout,function(){fileContainer.css({"margin-top":marginTop,"margin-bottom":marginBottom});self._setShowHideDetailsButtonText(fileContainer.is(":hidden"));if(fileContainer.is(":hidden")===false){self._reRenderFileNames()}})}},_reRenderFileNames:function(){var data=this.fileInfoData.filesInfo,l=data.length,i,originalFileName;for(i=0;i<l;i++){originalFileName=$("#"+this._id("_snglpbar",i)).data("originalFileName");$("#"+this._id("_pbrflnm",i)).text(originalFileName);this._renderFileName(i,0,originalFileName)}},_setShowHideDetailsButtonText:function(isHidden){var showHideDetailsButton=$("#"+this._id("_shdbtn"));if(isHidden){showHideDetailsButton.text(this._getLocaleValue("labelShowDetails"));showHideDetailsButton.attr({"data-localeid":"titleShowDetailsButton"})}else{showHideDetailsButton.text(this._getLocaleValue("labelHideDetails"));showHideDetailsButton.attr({"data-localeid":"titleHideDetailsButton"})}},getFileInfoData:function(){return this.fileInfoData},cancelAll:function(){var i,data=this.fileInfoData,uploadingIDs=data.uploadingIDs,luploadingIDs=uploadingIDs.length,pendingIDs=data.pendingQueueIDs,lpendingIDs=pendingIDs.length,batch=data.batch,lbatch=batch.length;this.allCancelled=true;for(i=0;i<luploadingIDs;i++){if(uploadingIDs[i]!==undefined){this.cancelUpload(uploadingIDs[i])}}for(i=0;i<lpendingIDs;i++){if(pendingIDs[i]!==undefined){this.cancelUpload(pendingIDs[i])}}for(i=0;i<lbatch;i++){if(batch[i]!==undefined){this.cancelUpload(batch[i])}}uploadingIDs=[];pendingIDs=[];batch=[];$("#"+this._id("_spbtncncl")).data("ids",[]);this.allCancelled=false},_submitAllFormsUpload:function(){var self=this,i,id,idsToSubmit=this.fileInfoData.batch,l=idsToSubmit.length,pendingIDs=[];if(this.options.useSingleRequest===false){for(i=0;i<l;i++){id=idsToSubmit[i];if(self._checkCanUpload()){self.startUpload(id)}else{self._addPendingId(id);pendingIDs.push(id)}}this.fileInfoData.batch=[]}else{var result=this._html5upload();if(result===true){this.fileInfoData.batch=[]}}},_spbRenderInit:function(){var self=this,o=this.options,css=self.css,uploaderId=this._id("_fu"),labelSummaryButton=this._getLocaleValue("labelSummaryProgressButtonContinue"),summaryProgressContainerId=this._id("_spbcntr"),summaryProgressBarLabelId=this._id("_summpbrlbl"),summaryProgressBarId=this._id("_summpbar"),summaryProgressLabelId=this._id("_summplbl"),showHideDetailsId=this._id("_shdbtn"),summaryProgressButtonCancelId=this._id("_spbtncncl"),summaryProgressDetailsButtonId=this._id("_spdtlbtn"),summaryProgressBar,html="",data,progressData="progressData",titleSummaryButton=this._getLocaleValue("titleSummaryProgressButtonContinue");html+='<div id="$summaryProgressContainerId$">';html+='\t<div  class="'+css.summaryInformationContainerClass+'">';html+='\t\t<span id="$summaryProgressLabelId$"  data-localeid="labelSummaryTemplate" ';html+='\t\t\tclass="'+css.summaryUploadedFilesLabelClass+'"></span>';html+='\t\t<a href="javascript:void(0);"'+' id="$showHideDetailsId$" data-localeid="titleHideDetailsButton" ';html+='\t\t\tclass="'+css.summaryShowHideDetailsButtonClass+'">$labelShowHideDetails$</a>';html+="\t</div>";html+='\t<div class="'+css.clearClass+'">';html+='\t\t<button id="$summaryProgressButtonCancelId$"></button>';html+='\t\t<div id="$summaryProgressBarId$"></div>';html+="\t</div>";html+="</div>";html=html.replace("$summaryProgressContainerId$",summaryProgressContainerId).replace("$summaryProgressLabelId$",summaryProgressLabelId).replace("$summaryProgressDetailsButtonId$",summaryProgressDetailsButtonId).replace("$summaryProgressBarId$",summaryProgressBarId).replace("$showHideDetailsId$",showHideDetailsId).replace("$labelShowHideDetails$",this._getLocaleValue("labelHideDetails")).replace("$labelSummaryProgressButtonCancel$",this._getLocaleValue("labelSummaryProgressButtonCancel")).replace("$summaryProgressButtonCancelId$",summaryProgressButtonCancelId);$(html).appendTo($("#"+uploaderId));data={IDs:{},CurrentUploadedFiles:0,CurrentUploadedSize:0,TotalFileSize:0,TotalFiles:0,UploadingFiles:0};$("#"+summaryProgressContainerId).data(progressData,data).addClass(css.summaryProgressContainerClass+" "+css.clearClass);summaryProgressBar=$("#"+summaryProgressBarId);$('<span id="'+summaryProgressBarLabelId+'"></span>').addClass(css.summaryProgressbarLabelClass).appendTo(summaryProgressBar.igProgressBar({animate:self._const.isProgressBarAnimationEnabled,animateTimeout:self._const.animateProgressBarInterval,range:self._const.isProgressBarRange,value:0,queue:false}).addClass(css.summaryProgressBarClass));$('<div id="'+summaryProgressBarLabelId+'_1"></div>').width(summaryProgressBar.width()).addClass(css.summaryProgressBarSecondaryLabel).appendTo($("#"+this._id("_summpbar_progress")).addClass(css.summaryProgressBarInnerProgress));$("#"+showHideDetailsId).bind({click:function(event){event.preventDefault();self._onShowHideDetailsClick()}});if(o.autostartupload){labelSummaryButton=this._getLocaleValue("labelSummaryProgressButtonCancel");titleSummaryButton=this._getLocaleValue("titleSummaryProgressButtonCancel");this.spbButtonMode=this.summaryButtonModes.cancel}$("#"+summaryProgressButtonCancelId).igButton({labelText:labelSummaryButton,title:titleSummaryButton,disabled:false,click:function(event){event.preventDefault();self._spbOnClickButton(event)}}).addClass(css.summaryButtonClass)},_spbRenderProgress:function(){var summaryProgressBar=$("#"+this._id("_summpbar")),summaryProgressLabel=$("#"+this._id("_summplbl")),summaryProgressBarLabel=$("#"+this._id("_summpbrlbl")),summaryProgressBarLabel1=$("#"+this._id("_summpbrlbl_1")),textSummaryProgressBarLabel="",value=0,data=this.fileInfoData,fileSizeTotal=data.fileSizeTotal,fileSizeUploaded=data.fileSizeUploaded;if(fileSizeTotal!==0&&isNaN(fileSizeTotal)===false){value=fileSizeUploaded/fileSizeTotal*100}else if(fileSizeTotal===0){value=0}if(data.countUploadingFiles===data.countTotalFiles){if(data.countTotalFiles===0){value=0}else{value=100}data.fileSizeUploaded=fileSizeTotal;fileSizeUploaded=fileSizeTotal}summaryProgressBar.igProgressBar("option","value",value);textSummaryProgressBarLabel=this._getLocaleValue("labelSummaryProgressBarTemplate").replace("{0}",this._formatFileSize(fileSizeUploaded)).replace("{1}",this._formatFileSize(fileSizeTotal)).replace("{2}",value);summaryProgressLabel.html(this._getLocaleValue("labelSummaryTemplate").replace("{0}",data.countUploadingFiles).replace("{1}",data.countTotalFiles));summaryProgressBarLabel.text(textSummaryProgressBarLabel);summaryProgressBarLabel1.text(textSummaryProgressBarLabel)},_spbOnClickButton:function(event){var modes=this.summaryButtonModes,m=this.spbButtonMode;event.preventDefault();if(m===modes.cancel){this._trigger(this.events.cancelAllClicked,event,{owner:this});this.cancelAll()}else if(m===modes.startupload){this._spbSubmitAllButton()}},_spbSubmitAllButton:function(){this._submitAllFormsUpload();this._spbCheckModeButton()},_spbCheckModeButton:function(){var allFilesData=this.fileInfoData;if(this.options.autostartupload){if(allFilesData.pendingQueueIDs.length>0||allFilesData.uploadingIDs.length>0){this._spbSetCancelButton()}else{this._spbSetButtonDone()}}else{if(allFilesData.pendingQueueIDs.length===0&&allFilesData.uploadingIDs.length===0){if(allFilesData.batch.length>0){this._spbSetContinueButton()}else{this._spbSetButtonDone()}}else{this._spbSetCancelButton()}}},_spbSetButtonDone:function(){var button=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.done;button.igButton("option",{labelText:this._getLocaleValue("labelSummaryProgressButtonDone"),title:this._getLocaleValue("titleSummaryProgressButtonDone"),disabled:true})},_spbSetContinueButton:function(){var button=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.startupload;button.igButton({title:this._getLocaleValue("titleSummaryProgressButtonContinue"),labelText:this._getLocaleValue("labelSummaryProgressButtonContinue"),disabled:false})},_spbSetCancelButton:function(){var cancelButton=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.cancel;cancelButton.igButton("option",{labelText:this._getLocaleValue("labelSummaryProgressButtonCancel"),title:this._getLocaleValue("titleSummaryProgressButtonCancel"),disabled:false})},getFileInfo:function(fileIndex){var fid=this.fileInfoData.filesInfo[fileIndex];if(fid===undefined||fid===null){return null}return fid},_formatFilePath:function(file){var ind=file.lastIndexOf("/");
file=file.replace(/(\/|\\)$/,"");if(ind===-1){ind=file.lastIndexOf("\\")}return file.substring(ind+1)},_checkCanUpload:function(){var o=this.options,data=this.fileInfoData,canUpload=true,maxSimultaneousFilesUploads=o.maxSimultaneousFilesUploads;if(o.mode==="multiple"&&maxSimultaneousFilesUploads!==null&&data.uploadingIDs.length>=maxSimultaneousFilesUploads&&o.useSingleRequest===false){canUpload=false;if(maxSimultaneousFilesUploads<=0){this._setError(this._getLocaleValue("errorMessageMaxSimultaneousFiles"),null,this._const.clientSideErrorCode.checkCanUpload,"clientside")}}return canUpload},_addPendingId:function(id){this.fileInfoData.pendingQueueIDs.push(id)},_removePendingId:function(formNumber){var pendingIDs=this.fileInfoData.pendingQueueIDs,id;if(formNumber!==undefined&&formNumber!==null){id=formNumber;this.fileInfoData.pendingQueueIDs=this._removeElementFromArray(pendingIDs,id)}else{id=pendingIDs.shift();if(id===undefined){id=null}}return id},_addUploadingID:function(id){this.fileInfoData.uploadingIDs.push(id)},_removeUploadingID:function(id){this.fileInfoData.uploadingIDs=this._removeElementFromArray(this.fileInfoData.uploadingIDs,id)},_addIDBatch:function(id){this.fileInfoData.batch.push(id)},_removeIDBatch:function(id){this.fileInfoData.batch=this._removeElementFromArray(this.fileInfoData.batch,id)},_submitNextPendingId:function(){var self=this,nextFormToSubmitId;if(self._checkCanUpload()===true){nextFormToSubmitId=self._removePendingId();if(nextFormToSubmitId!==null){self.startUpload(nextFormToSubmitId)}}},_randomString:function(stringLength){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",randomstring="",i,rnum;for(i=0;i<stringLength;i++){rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1)}return randomstring},_cutFilePath:function(fileName,length){var fileNameSize=fileName.length;if(fileNameSize<=length){return fileName}},_getOnlyFileName:function(fileName){var delimeter="";if(fileName===null||fileName===undefined){return""}if(fileName.indexOf("/")!==-1){delimeter="/"}else if(fileName.indexOf("\\")!==-1){delimeter="\\"}if(delimeter!==""){fileName=fileName.substr(fileName.lastIndexOf(delimeter)+1)}return fileName},_getFileExtension:function(fileName){return fileName.substring(fileName.lastIndexOf(".")+1)},_validateFileExtension:function(fileName,callEvent,formNumber){var ext="",arrE=this.options.allowedExtensions,res,noCancel;if(arrE.length===0){return true}ext=fileName.substring(fileName.lastIndexOf(".")+1);noCancel=this._trigger(this.events.fileExtensionsValidating,this,{fileName:fileName,fileExtension:ext,owner:this});ext=ext.toLowerCase();res=$.inArray(ext,arrE)>=0;if(callEvent===true&&res===false||!noCancel){res=false;this._setError(this._getLocaleValue("errorMessageValidatingFileExtension"),formNumber,this._const.clientSideErrorCode.extensionValidation,"clientside")}return res},_getFileExtensionIconPath:function(ext){var arrIE=this.options.fileExtensionIcons,i,icon="",l=arrIE.length;ext=String(ext).toLowerCase();for(i=0;i<l;i++){if(arrIE[i].ext!==undefined&&(arrIE[i].ext===ext||$.inArray(ext,arrIE[i].ext)!==-1)){icon=arrIE[i].css;break}if(icon===""&&(arrIE[i].def===true||$.isArray(arrIE[i].ext)&&arrIE[i].ext.length===0)){icon=arrIE[i].css}}return icon},_setError:function(message,fileId,errorCode,errorType,serverMessage){var eArgs,errC=this._const.errorCode;if(serverMessage===undefined){serverMessage=""}if(errorType==="serverside"){switch(errorCode){case errC.MimeTypeValidation:message=this._getLocaleValue("errorMessageValidatingFileExtension");break;case errC.FileSizeExceeded:message=this._getLocaleValue("errorMessageMaxFileSizeExceeded");break}}this._spbCheckModeButton();eArgs={fileId:fileId,errorCode:errorCode,errorMessage:message,errorType:errorType,serverMessage:serverMessage,owner:this};this._trigger(this.events.onError,null,eArgs)},_formatFileSize:function(val){var fsm=this.options.fileSizeMetric,res=val;switch(fsm){case"bytes":res=val+"B";break;case"kbytes":res=this._convertToKBytes(val);break;case"mbytes":res=this._convertToMBytes(val);break;case"gbytes":res=this._convertToGBytes(val);break;case"auto":if(val<1024){res=val+"B"}else if(val<1024*1024){res=this._convertToKBytes(val)}else if(val<1024*1024*1024){res=this._convertToMBytes(val)}else{res=this._convertToGBytes(val)}break;default:break}return res},_convertToKBytes:function(val){var res=val/1024;return res.toFixed(this.options.fileSizeDecimalDisplay)+"KB"},_convertToMBytes:function(val){var res=val/(1024*1024);return res.toFixed(this.options.fileSizeDecimalDisplay)+"MB"},_convertToGBytes:function(val){var res=val/(1024*1024*1024);return res.toFixed(this.options.fileSizeDecimalDisplay)+"GB"},_removeElementArrayById:function(array,keyValue){if(array===undefined||array===null){return[]}return $.grep(array,function(n){return n.id!==keyValue})},_removeElementFromArray:function(array,keyValue){if(array===undefined||array===null){return[]}return $.grep(array,function(n){return n!==keyValue})},_stringToJSONObject:function(s){var data={};try{data=JSON.parse(s)}catch(e){return false}return data},_stringToXmlObject:function(s){var $xml;try{$xml=$(s)}catch(e){return false}if(!$xml.length){return false}return $xml}});$.extend($.ui.igUpload,{version:"0.0.1"});return $});