/*!@license
* Infragistics.Web.ClientUI Upload localization resources 13.1.20131.2523
*
* Copyright (c) 2011-2014 Infragistics Inc.
*
* http://www.infragistics.com/
*
*/
(function($){$.ig=$.ig||{};if(!$.ig.Upload){$.ig.Upload={};$.extend($.ig.Upload,{locale:{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}.",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"}})}})(jQuery);/*!@license
 * Infragistics.Web.ClientUI jQuery File Upload 13.1.20131.2523
 *
 * Copyright (c) 2011-2014 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 *  jquery-1.4.2.js
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *  infragistics.util.js
 *  infragistics.ui.shared.js
 */
if(typeof jQuery!=="function"){throw new Error("jQuery is undefined")}(function($){$.widget("ui.igBrowseButton",$.ui.igButton,{_const:{filePickerWidth:"220px",filePickerHeight:"30px"},css:{filePickerClass:"ui-igbrowsebutton-filepicker"},options:{autoselect:true,multipleFiles:false},_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="";if(this.options.multipleFiles===true){multiple=' multiple=""'}this.filePicker=$('<input type="file" id="'+filepickerId+'"'+multiple+"/>").appendTo($(document.body));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,fileUploadButton=self.element,filePicker=this.filePicker,offset=fileUploadButton.offset(),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){filePickerDOM.style.top=e.pageY+"px";filePickerDOM.style.left=e.pageX+"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,fileUploadButton=self.element,filePicker=this.filePicker,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){filePickerDOM.style.top=e.pageY+"px";filePickerDOM.style.left=e.pageX+"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);$.Widget.prototype.destroy.apply(this,arguments);$.ui.igButton.prototype.destroy.apply(this);$("#"+this._id("_fp")).remove()},_fileFromPath:function(file){return file.replace(/(\/|\\)$/,"")}});$.extend($.ui.igBrowseButton,{version:"13.1.20131.2523"});$.widget("ui.igUpload",{_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},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:$.ig.Upload.locale.labelUploadButton,labelAddButton:$.ig.Upload.locale.labelAddButton,labelClearAllButton:$.ig.Upload.locale.labelClearAllButton,labelSummaryTemplate:$.ig.Upload.locale.labelSummaryTemplate,labelSummaryProgressBarTemplate:$.ig.Upload.locale.labelSummaryProgressBarTemplate,labelShowDetails:$.ig.Upload.locale.labelShowDetails,labelHideDetails:$.ig.Upload.locale.labelHideDetails,labelSummaryProgressButtonCancel:$.ig.Upload.locale.labelSummaryProgressButtonCancel,labelSummaryProgressButtonContinue:$.ig.Upload.locale.labelSummaryProgressButtonContinue,labelSummaryProgressButtonDone:$.ig.Upload.locale.labelSummaryProgressButtonDone,labelProgressBarFileNameContinue:$.ig.Upload.locale.labelProgressBarFileNameContinue,errorMessageMaxFileSizeExceeded:$.ig.Upload.locale.errorMessageFileSizeExceeded,errorMessageGetFileStatus:$.ig.Upload.locale.errorMessageGetFileStatus,errorMessageCancelUpload:$.ig.Upload.locale.errorMessageCancelUpload,errorMessageNoSuchFile:$.ig.Upload.locale.errorMessageNoSuchFile,errorMessageOther:$.ig.Upload.locale.errorMessageOther,errorMessageValidatingFileExtension:$.ig.Upload.locale.errorMessageValidatingFileExtension,errorMessageAJAXRequestFileSize:$.ig.Upload.locale.errorMessageAJAXRequestFileSize,errorMessageTryToRemoveNonExistingFile:$.ig.Upload.locale.errorMessageTryToRemoveNonExistingFile,errorMessageTryToStartNonExistingFile:$.ig.Upload.locale.errorMessageTryToStartNonExistingFile,errorMessageMaxUploadedFiles:$.ig.Upload.locale.errorMessageMaxUploadedFiles,errorMessageMaxSimultaneousFiles:$.ig.Upload.locale.errorMessageMaxSimultaneousFiles,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},events:{fileSelecting:"fileSelecting",fileSelected:"fileSelected",fileUploading:"fileUploading",fileUploaded:"fileUploaded",fileUploadAborted:"fileUploadAborted",cancelAllClicked:"cancelAllClicked",onError:"onError",fileExtensionsValidating:"fileExtensionsValidating"},summaryButtonModes:{cancel:1,startupload:2,done:3},container:function(){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.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,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;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:o.labelUploadButton,title:$.ig.Upload.locale.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)===false){isCancelEvent=true}return!isCancelEvent}})},_initBrowserFileSelect:function(event,data){var countFiles=1,filePicker;if(!data||!data.files||data.files.length===0){filePicker=$("#"+this._id("_ibb_fp"));if(this._validateFileExtension(filePicker[0].value,true)===false){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+='       <div id="$fileContainerId$"></div>';html+='       <button id="$browseButtonId$" class="$browseButtonClass$"></button>';html+="   </div>";html+="</div>"}else if(o.mode==="multiple"){html='<div class="'+css.multipleDialogClasses+'" id="$baseMainContainerId">';html+='   <div  id="$uploaderId$" class="$baseMainContainerClass">';html+='       <div id="$uploaderFilesContainer" class="$fuMainContainerClass">';html+='           <button id="$browseButtonId$" class="$browseButtonClass$"></button>';html+='           <button id="$clearAllButtonId$"></button>';html+='           <div id="$fileContainerId$"></div>';html+="       </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:$.ig.Upload.locale.titleClearAllButton,labelText:o.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.options.labelAddButton,title:$.ig.Upload.locale.titleAddFileButton,fileselect:function(event,data){self._onBrowseButtonFileSelected(event,false,data)},click:function(event){var isCancelEvent=false;if(self._trigger(self.events.fileSelecting,event)===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(o.errorMessageMaxUploadedFiles,this._const.clientSideErrorCode.maxAllowedUploadingFiles,"clientside")}}return allowUpload},_onBrowseButtonFileSelected:function(event,isInitBrowseButton,data){var self=this,fileData=this.fileInfoData,filePicker,o=self.options,countFiles=1;if(data&&data.files&&data.files.length>=1){countFiles=data.files.length}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===fileData.countTotalFiles+countFiles){self._disableBrowseButton(true)}if(o.mode==="single"){if(fileData.iframe.ids.length===0){self._removeSingleUpload(fileData.lastId);if(self._attachIframe(event,isInitBrowseButton,fileData.files)===true){self._disableBrowseButton(true)}}}else if(o.mode==="multiple"){if(isInitBrowseButton===true){filePicker=$("#"+self._id("_ibb"))}else{filePicker=$("#"+self._id("_bb"))}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;for(i=0;i<filesLength;i++){res=this._html5createForm(files[i],i,fileId)}return res},_html5upload:function(fileId){var xhr=new XMLHttpRequest,formData=new FormData,o=this.options,self=this,file=this.fileInfoData.filesInfo[fileId].file,key=this.fileInfoData.filesInfo[fileId].key,cid=o.controlId,upload=xhr.upload,uploadUrl=o.uploadUrl+"?key="+key+"&cid="+cid+"&multiple=true";xhr.open("POST",uploadUrl);xhr.withCredentials="true";formData.append(this._id("_frm",fileId)+"_if",file);upload.addEventListener("progress",function(e){self._html5progress(e,fileId)},false);upload.addEventListener("error",function(e){self._getFileStatus(fileId,true)},false);this.fileInfoData.filesInfo[fileId].xhr=xhr;xhr.onload=function(e){var response,error;if(xhr.status>=200&&xhr.status<=299){response=xhr.responseText;if(response){error=response.substring(response.indexOf("<error>"),response.indexOf("</error>")).replace("<error>","");if(error!==""){error=parseInt(error,10);if(!isNaN(error)){self._getFileStatus(fileId,true);return}}self._html5progress(e,fileId,true)}}else{self._getFileStatus(fileId,true)}};xhr.send(formData)},_html5progress:function(e,formNumber,isFinish){var self=this,singleFileData,data={};if(e.lengthComputable||isFinish){data.bytesUploaded=e.loaded;if(isNaN(data.bytesUploaded)){data.bytesUploaded=0}if(isNaN(e.total)){e.total=0}singleFileData=this._getFileInfo(formNumber);if(singleFileData&&singleFileData.innerStatus===self._const.status.Canceled){return}if(isFinish){data.total=data.bytesUploaded=singleFileData.sizeBytes;data.status=self._const.status.Finished}else{data.status=self._const.status.Started}data.size=e.total;self._setFileStatus(formNumber,true,data)}else{self.cancelUpload(formNumber)}},_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)===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){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,{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),iframe,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)===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=$('<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._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,{fileId:fileId,filePath:self._getOnlyFileName(filePicker.val())});return true},_showSingleUploadStartUpload:function(){var self=this,o=self.options,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:o.labelSummaryProgressButtonContinue,title:$.ig.Upload.locale.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),fileUploadStatus,fileName=this.fileInfoData.filesInfo[formNumber].path,html,progressBarFileNameId=self._id("_pbrflnm",formNumber),progressBarFileSizeId=self._id("_pbrflsz",formNumber),progressBarFileName,progressBarFileSize,singleProgressBar,iconClass=self._getFileExtensionIconPath(self._getFileExtension(fileName));html='<div id="'+fileUploadStatusId+'">';html+='   <div class="'+css.containerFUS+'">';html+='       <div class="'+css.containerButtonCancelClass+'">';html+='           <button id="'+cancelButtonId+'"></button>';html+="       </div>";html+='       <div class="'+css.progressContainer+'">';html+='           <div class="'+css.progressBarInnerHTMLContainerClass+'" title="'+fileName+'">';html+='               <span id="'+iconId+'" class="'+iconClass+'"></span>';html+='               <span class="'+css.progressBarFileNameClass+'" id="'+progressBarFileNameId+'"></span>';html+='               <span class="'+css.progressBarFileSizeClass+'" id="'+progressBarFileSizeId+'"></span>';html+="           </div>";html+='           <div id="'+singleProgressBarId+'" class="'+css.progressBarUploadClass+'"></div>';html+="       </div>";html+="   </div>";html+="</div>";$(html).appendTo(fileContainer);fileUploadStatus=$("#"+fileUploadStatusId).addClass(css.uploadProgressClass+" "+css.clearClass);singleProgressBar=$("#"+singleProgressBarId);$("#"+cancelButtonId).igButton({onlyIcons:true,icons:{primary:"ui-icon-closethick"},title:$.ig.Upload.locale.titleCancelUploadButton,click:function(event){event.preventDefault();self.cancelUpload(formNumber);$("#"+cancelButtonId).igButton("option","disabled",true).igButton("option","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);progressBarFileSize=$("#"+progressBarFileSizeId);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,o=self.options,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();if(progressBarFileName.length===0){return}if(fileName===undefined||fileName===null){fileName=singleProgressBar.data("fileName")}if(singleProgressBarWidth<=0){fileName=o.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)}while(progressBarFileName.position().left+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+o.labelProgressBarFileNameContinue)}if(progressBarFileName.position().left+progressBarFileName.width()+progressBarFileSize.width()>=singleProgressBarWidth){fileName=o.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,formId=self._id("_frm",formNumber),fileData=this.fileInfoData,isHTML5=false;if(formNumber===null||fileData.filesInfo[formNumber]===null||fileData.filesInfo[formNumber]===undefined){self._setError(self.options.errorMessageTryToStartNonExistingFile.replace("{0}",formNumber),self._const.clientSideErrorCode.startUpload,"clientside");return}if(fileData.filesInfo[formNumber].status!==self._const.status.NotStarted){return}isHTML5=fileData.filesInfo[formNumber].multipleFiles;if(isHTML5!==true){$("#"+formId).submit()}else{this._html5upload(formNumber)}self._addUploadingID(formNumber);self._removeIDBatch(formNumber);self._spbCheckModeButton();fileData.filesInfo[formNumber].status=self._const.status.Started;fileData.filesInfo[formNumber].innerStatus=self._const.status.Started;self._spbRenderProgress();if(this.options.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){var self=this,o=self.options,isFinishUpload=false,status="",bytesUploaded=0,fileSize=0,singleFileData=this._getFileInfo(formNumber),fileData=this.fileInfoData,key=self._getKey(formNumber),fileDetails=fileData.filesInfo[formNumber],fileName=fileDetails.path,error,isError,serverMessage="";if(key===null||key===undefined){return false}bytesUploaded=parseInt(data.bytesUploaded,10);status=parseInt(data.status,10);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(fileDetails.innerStatus===self._const.status.Canceled&&isError){self._setError(o.errorMessageOther.replace("{0}",error),error,"serverside",serverMessage);return false}if(isError===true&&status!==self._const.status.NoSuchFile){self._removeUploadSetError(formNumber,o.errorMessageOther.replace("{0}",error),error,"serverside",serverMessage);return false}if(singleFileData!==null&&singleFileData.status!==self._const.status.Canceled){fileData.fileSizeUploaded-=singleFileData.uploadedBytes;if(singleFileData.sizeBytes===0||singleFileData.sizeBytes===null){singleFileData.sizeBytes=fileSize;fileData.fileSizeTotal+=fileSize}else if(singleFileData.sizeBytes!==fileSize){fileSize=singleFileData.sizeBytes}if(isFinishUpload){fileData.countUploadingFiles++}if(bytesUploaded===0&&singleFileData.uploadedBytes>0){bytesUploaded=singleFileData.uploadedBytes}singleFileData.uploadedBytes=bytesUploaded;singleFileData.status=status;fileData.fileSizeUploaded+=singleFileData.uploadedBytes;self._spbRenderProgress();if(self._trigger(self.events.fileUploading,null,{fileId:formNumber,filePath:self._getOnlyFileName(fileName),totalSize:fileSize,uploadedBytes:bytesUploaded,fileStatus:status})===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,isNewFile);if(!isFinishUpload){return true}}else if(status===self._const.status.NoSuchFile){if(fileDetails!==null&&fileDetails!==undefined&&fileDetails.checksNoSuchFile===0){fileDetails.checksNoSuchFile++;return true}self._removeUploadSetError(formNumber,o.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(o.errorMessageGetFileStatus,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,errorCode,errorType,serverMessage);if(o.mode==="multiple"){self._spbCheckModeButton();self._submitNextPendingId()}},cancelUpload:function(formNumber){var self=this,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){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(o.errorMessageCancelUpload,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()}self._trigger(self.events.fileUploadAborted,null,{fileId:formNumber,filePath:self._getOnlyFileName(fileName),uploadedBytes:0,totalSize:totalSize,status:self._const.status.NotStarted});self._removeFileUpload(formNumber)}}},_onCancelUpload:function(formNumber){var 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)}self._trigger(self.events.fileUploadAborted,null,{fileId:formNumber,filePath:self._getOnlyFileName(fileName),uploadedBytes:bytesUploaded,totalSize:totalSize,status:self._const.status.Canceled});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,fileData=this.fileInfoData,singleFileInfo=this._getFileInfo(formNumber);if(singleFileInfo===null){self._setError(o.errorMessageTryToRemoveNonExistingFile.replace("{0}",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}fileData.countTotalFiles--;singleFileInfo.status=self._const.status.Canceled;fileData.fileSizeUploaded-=singleFileInfo.uploadedBytes;fileData.fileSizeTotal-=singleFileInfo.sizeBytes;self._spbRenderProgress();if(o.mode==="multiple"){self._removeUploadingID(formNumber);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).igButton("option","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){var self=this,fileName,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}singleProgressBar.data("totalSize",fileSize);singleProgressBar.data("bytesUploaded",bytesUploaded);fileNameRendered=singleProgressBar.data("isFileNameRendered");fileName=singleProgressBar.data("fileName");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){self._trigger(self.events.fileUploaded,null,{fileId:formNumber,filePath:originalFileName,totalSize:bytesUploaded});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)}}},_setOption:function(key,value){var originalMode=this.options.mode,originalAutoStartUpload=this.options.autostartupload;$.Widget.prototype._setOption.apply(this,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"labelUploadButton":$("#"+this._id("_ibb")).igBrowseButton("option","labelText",value);break;case"labelAddButton":$("#"+this._id("_bb")).igBrowseButton("option","labelText",value);break;case"labelClearAllButton":$("#"+this._id("_clrabtn")).igButton("option","labelText",value);break;case"labelSummaryTemplate":case"labelSummaryProgressBarTemplate":this._spbRenderProgress();break;case"labelShowDetails":case"labelHideDetails":this._setShowHideDetailsButtonText($("#"+this._id("_shdbtn")).is("hidden"));$("#"+this._id("_shdbtn")).text(value);break;case"labelSummaryProgressButtonCancel":if(this.spbButtonMode===this.summaryButtonModes.cancel){$("#"+this._id("_spbtncncl")).igButton("option","labelText",value)}break;case"labelSummaryProgressButtonContinue":if(this.spbButtonMode===this.summaryButtonModes.startupload){$("#"+this._id("_spbtncncl")).igButton("option","labelText",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,fileName,originalFileName,statusLabel,singleProgressBar,percentUploaded=0;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));if(fileSize!==0&&isNaN(bytesUploaded)===false&&isNaN(fileSize)===false){percentUploaded=bytesUploaded/fileSize*100}fileName=singleProgressBar.data("fileName");originalFileName=singleProgressBar.data("originalFileName");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 startupButton=$("#"+this._id("_ibb")),browseButton=$("#"+this._id("_bb")),baseMainContainer=$("#"+this._id("_bmncntr"));this.originalElement.show().unwrap();startupButton.igBrowseButton("destroy");browseButton.igBrowseButton("destroy");startupButton.remove();baseMainContainer.remove();this.container().remove()},destroy:function(){this._destroyMarkup();$.Widget.prototype.destroy.apply(this,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(o.errorMessageAJAXRequestFileSize,self._const.clientSideErrorCode.ajaxErrorRequestFileSize,"clientside");self._removeGetFileSizeHTML(formNumber)}})},_saveFileSize:function(fileSize,formNumber){var self=this,singleProgressBarId=self._id("_snglpbar",formNumber),singleProgressBar=$("#"+singleProgressBarId),fileData=this.fileInfoData,singleFileData=this._getFileInfo(formNumber);if(isNaN(fileSize)===true){return}singleProgressBar.data("totalSize",fileSize);if(singleFileData!==null){singleFileData.sizeBytes=fileSize;fileData.fileSizeTotal+=fileSize;self._spbRenderProgress()}self._renderStatus(formNumber,0,fileSize,false,false)},_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 o=this.options,showHideDetailsButton=$("#"+this._id("_shdbtn"));if(isHidden){showHideDetailsButton.text(o.labelShowDetails);showHideDetailsButton.attr("title",$.ig.Upload.locale.titleShowDetailsButton)}else{showHideDetailsButton.text(o.labelHideDetails);showHideDetailsButton.attr("title",$.ig.Upload.locale.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=[];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=[]},_spbRenderInit:function(){var self=this,o=this.options,css=self.css,uploaderId=this._id("_fu"),labelSummaryButton=o.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=$.ig.Upload.locale.titleSummaryProgressButtonContinue;html+='<div id="$summaryProgressContainerId$">';html+='   <div  class="'+css.summaryInformationContainerClass+'">';html+='       <span id="$summaryProgressLabelId$" class="'+css.summaryUploadedFilesLabelClass+'"></span><a href="javascript:void(0);" id="$showHideDetailsId$" class="'+css.summaryShowHideDetailsButtonClass+'">$labelShowHideDetails$</a>';html+="   </div>";html+='   <div class="'+css.clearClass+'">';html+='       <button id="$summaryProgressButtonCancelId$"></button>';html+='       <div id="$summaryProgressBarId$"></div>';html+="   </div>";html+="</div>";html=html.replace("$summaryProgressContainerId$",summaryProgressContainerId).replace("$summaryProgressLabelId$",summaryProgressLabelId).replace("$summaryProgressDetailsButtonId$",summaryProgressDetailsButtonId).replace("$summaryProgressBarId$",summaryProgressBarId).replace("$showHideDetailsId$",showHideDetailsId).replace("$labelShowHideDetails$",o.labelHideDetails).replace("$labelSummaryProgressButtonCancel$",o.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($.ig.Upload.locale.titleHideDetailsButton!==false){$("#"+showHideDetailsId).attr("title",$.ig.Upload.locale.titleHideDetailsButton)}if(o.autostartupload){labelSummaryButton=o.labelSummaryProgressButtonCancel;titleSummaryButton=$.ig.Upload.locale.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 o=this.options,summaryProgressBar=$("#"+this._id("_summpbar")),summaryProgressLabel=$("#"+this._id("_summplbl")),summaryProgressBarLabel=$("#"+this._id("_summpbrlbl")),summaryProgressBarLabel_1=$("#"+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=o.labelSummaryProgressBarTemplate.replace("{0}",this._formatFileSize(fileSizeUploaded)).replace("{1}",this._formatFileSize(fileSizeTotal)).replace("{2}",value);summaryProgressLabel.html(o.labelSummaryTemplate.replace("{0}",data.countUploadingFiles).replace("{1}",data.countTotalFiles));summaryProgressBarLabel.text(textSummaryProgressBarLabel);summaryProgressBarLabel_1.text(textSummaryProgressBarLabel)},_spbOnClickButton:function(event){var modes=this.summaryButtonModes,m=this.spbButtonMode;event.preventDefault();if(m===modes.cancel){this._trigger(this.events.cancelAllClicked,event);this.cancelAll()}else if(m===modes.startupload){this._spbSubmitAllButton()}},_spbSubmitAllButton:function(){this._submitAllFormsUpload();this._spbCheckModeButton()},_spbCheckModeButton:function(){var fileData=this.fileInfoData;if(this.options.autostartupload){if(fileData.pendingQueueIDs.length>0||fileData.uploadingIDs.length>0){this._spbSetCancelButton()}else{this._spbSetButtonDone()}}else{if(fileData.pendingQueueIDs.length===0&&fileData.uploadingIDs.length===0){if(fileData.batch.length>0){this._spbSetContinueButton()}else{this._spbSetButtonDone()}}else{this._spbSetCancelButton()}}},_spbSetButtonDone:function(){var o=this.options,button=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.done;button.igButton("option","labelText",o.labelSummaryProgressButtonDone).igButton("option","title",$.ig.Upload.locale.titleSummaryProgressButtonDone).igButton("option","disabled",true)},_spbSetContinueButton:function(){var o=this.options,button=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.startupload;button.igButton({title:$.ig.Upload.locale.titleSummaryProgressButtonContinue,labelText:o.labelSummaryProgressButtonContinue,disabled:false})},_spbSetCancelButton:function(){var cancelButton=$("#"+this._id("_spbtncncl"));this.spbButtonMode=this.summaryButtonModes.cancel;cancelButton.igButton("option","labelText",this.options.labelSummaryProgressButtonCancel).igButton("option","title",$.ig.Upload.locale.titleSummaryProgressButtonCancel).igButton("option","disabled",false)},_getFileInfo:function(length){var fid=this.fileInfoData.filesInfo[length];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){canUpload=false;if(maxSimultaneousFilesUploads<=0){this._setError(o.errorMessageMaxSimultaneousFiles,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(string_length){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",randomstring="",i,rnum;for(i=0;i<string_length;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){var ext="",arrE=this.options.allowedExtensions,res,noCancel;if(arrE.length===0){return true}ext=fileName.substring(fileName.lastIndexOf(".")+1);ext=ext.toLowerCase();noCancel=this._trigger(this.events.fileExtensionsValidating,this,{fileName:fileName,fileExtension:ext});res=$.inArray(ext,arrE)>=0;if(callEvent===true&&res===false||!noCancel){res=false;this._setError(this.options.errorMessageValidatingFileExtension,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}else if(icon===""&&(arrIE[i].def===true||$.isArray(arrIE[i].ext)&&arrIE[i].ext.length===0)){icon=arrIE[i].css}}return icon},_setError:function(message,errorCode,errorType,serverMessage){var o=this.options,errC=this._const.errorCode;if(serverMessage===undefined){serverMessage=""}if(errorType==="serverside"){switch(errorCode){case errC.MimeTypeValidation:message=o.errorMessageValidatingFileExtension;break;case errC.FileSizeExceeded:message=o.errorMessageMaxFileSizeExceeded;break}}this._spbCheckModeButton();this._trigger(this.events.onError,null,{errorCode:errorCode,errorMessage:message,errorType:errorType,serverMessage:serverMessage})},_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})}});$.extend($.ui.igUpload,{version:"13.1.20131.2523"})})(jQuery);