Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.ControlObjectsVisibility=function(){
throw Error.invalidOperation();
};
Telerik.Web.UI.ControlObjectsVisibility.prototype={None:0,CheckBoxes:1,RemoveButtons:2,ClearButtons:4,AddButton:8,DeleteSelectedButton:16,Default:(1|2|4|16),All:(1|2|4|8|16)};
Telerik.Web.UI.ControlObjectsVisibility.registerEnum("Telerik.Web.UI.ControlObjectsVisibility",false);
Type.registerNamespace("Telerik.Web.UI.RadUploadUtils");
Telerik.Web.UI.RadUploadUtils.Localization={"Remove":"Remove","Add":"Add","Clear":"Clear","Select":"Select","Delete":"Delete"};
function getRadUpload(_1){
return $find(_1);
}
Telerik.Web.UI.RadUpload=function(_2){
Telerik.Web.UI.RadUpload.initializeBase(this,[_2]);
this._formId="";
this._enabled=true;
this._maxFileCount=0;
this._initialFileInputsCount=1;
this._inputSize=23;
this._controlObjectsVisibility=Telerik.Web.UI.ControlObjectsVisibility.Default;
this._showCheckboxes=true;
this._showRemoveButtons=true;
this._showClearButtons=true;
this._showAddButton=true;
this._showDeleteButton=true;
this._focusOnLoad=false;
this._enableFileInputSkinning=true;
this._readOnlyFileInputs=false;
this._allowedFileExtensions=[];
this._currentIndex=0;
};
Telerik.Web.UI.RadUpload.prototype={initialize:function(){
Telerik.Web.UI.RadUpload.callBaseMethod(this,"initialize");
this._updateFormProperties($get(this._formId));
this._listContainer=this._findElement("ListContainer");
this._addButton=this._initButton(this._findElement("AddButton"),"Add",this.addFileInput);
this._deleteButton=this._initButton(this._findElement("DeleteButton"),"Delete",this.deleteSelectedFileInputs);
var _3=this._maxFileCount==0?this._initialFileInputsCount:Math.min(this._initialFileInputsCount,this._maxFileCount);
for(var i=0;i<_3;i++){
this.addFileInput();
}
this._setAddDeleteButtonStates();
this._initialized=true;
},dispose:function(){
if(this._addButton){
$clearHandlers(this._addButton);
}
if(this._deleteButton){
$clearHandlers(this._deleteButton);
}
var _5=this._getRowCount();
for(var i=0;i<_5;i++){
var _7=this._getRow(i);
if(_7){
$clearHandlers(_7);
var _8=this.getFileInputFrom(_7);
if(_8){
$clearHandlers(_8);
}
}
}
Telerik.Web.UI.RadUpload.callBaseMethod(this,"dispose");
},_updateFormProperties:function(_9){
if(!_9){
_9=document.forms[0];
}
_9.enctype=_9.encoding="multipart/form-data";
},_getLocalization:function(){
return Telerik.Web.UI.RadUploadUtils.Localization;
},_getChildInputElement:function(_a,_b){
var _c=_a.getElementsByTagName("input");
for(var i=0;i<_c.length;i++){
if(_c[i].type==_b){
return _c[i];
}
}
return null;
},_getChildInputElements:function(_e,_f){
var _10=[];
var _11=_e.getElementsByTagName("input");
var num=0;
for(var i=0;i<_11.length;i++){
if(_11[i].type==_f){
_10[num]=_11[i];
num++;
}
}
return _10;
},_getChildUploadCheckbox:function(row){
var _15=new RegExp(this.get_id()+"checkbox\\d+$");
var _16=this._getChildInputElements(row,"checkbox");
for(var i=0;i<_16.length;i++){
if(_16[i].id.match(_15)){
return _16[i];
}
}
return null;
},_getRowCount:function(){
var _18=this._listContainer.getElementsByTagName("li").length;
if(this._showAddButton||this._showDeleteButton){
return _18-1;
}else{
return _18;
}
},_getParentRow:function(_19){
if(!_19){
return null;
}
var _1a=_19.parentNode;
while(_1a.tagName!="LI"){
_1a=_1a.parentNode;
if(null==_1a){
break;
}
}
return _1a;
},_getRowIndex:function(row){
var _1c=this._listContainer;
var _1d=_1c.getElementsByTagName("li");
for(var i=0;i<_1d.length;i++){
if(_1d[i]==row){
return i;
}
}
return null;
},_getRow:function(_1f){
var _20=this._listContainer;
var _21=_20.getElementsByTagName("li");
var _22=(_1f<_21.length)?_21[_1f]:null;
return _22;
},_addRow:function(_23){
if(_23<0){
_23=0;
}
var row=document.createElement("LI");
var _25=this._getRow(_23);
var _26=this._listContainer;
if(_25){
_26.insertBefore(row,_25);
}else{
_26.appendChild(row);
}
return row;
},getID:function(_27){
return this.get_id()+_27+this._currentIndex;
},_findElement:function(_28){
var _29=this.get_id()+_28;
return $get(_29);
},_initButton:function(_2a,_2b,_2c){
if(_2a){
var loc=this._getLocalization();
_2a.value=loc[_2b];
if(this._enabled){
if(_2c){
$addHandlers(_2a,{"click":_2c},this);
}
}else{
_2a.disabled=true;
}
}
return _2a;
},addFileInput:function(_2e){
var _2f=this.addFileInputAt(this._getRowCount());
if(this._initialized){
try{
_2f.focus();
}
catch(ex){
}
}
},addFileInputAt:function(_30){
if(typeof (_30)=="undefined"||_30>this._getRowCount()){
_30=this._getRowCount();
}
if(this._maxFileCount>0&&_30>=this._maxFileCount){
return;
}
if(this._initialized){
var _31=new Sys.CancelEventArgs();
this.raiseEvent("adding",_31);
if(_31.get_cancel()){
return;
}
}
this.addFileInputAtInternal(_30);
},addFileInputAtInternal:function(_32){
var row=this._addRow(_32);
$addHandlers(row,{"click":this._rowClicked},this);
if(this._showCheckboxes){
this.appendCheckBox(row);
}
this.appendStyledFileInput(row);
if(this._showClearButtons){
this.appendClearButton(row);
}
if(this._showRemoveButtons){
this.appendRemoveButton(row);
}
this._setAddDeleteButtonStates();
var _34=new Sys.EventArgs();
_34._row=row;
_34.get_row=function(){
return this._row;
};
this.raiseEvent("added",_34);
this._currentIndex++;
return row;
},appendCheckBox:function(_35){
var _36=document.createElement("input");
_36.type="checkbox";
_36.id=_36.name=this.getID("checkbox");
_35.appendChild(_36);
_36.className="ruCheck";
_36.disabled=!this._enabled;
return _36;
},appendClearButton:function(_37){
var _38=document.createElement("input");
_38.type="button";
_38.id=this.getID("clear");
_37.appendChild(_38);
this._initButton(_38,"Clear");
_38.className="ruButton ruClear";
_38.name="ClearInput";
_38.disabled=!this._enabled;
return _38;
},appendRemoveButton:function(_39){
var _3a=document.createElement("input");
_3a.type="button";
_3a.id=this.getID("remove");
_39.appendChild(_3a);
var loc=this._getLocalization();
_3a.value=loc["Remove"];
_3a.className="ruButton ruRemove";
_3a.name="RemoveRow";
_3a.disabled=!this._enabled;
return _3a;
},appendStyledFileInput:function(_3c){
var _3d=this.createFileInput();
this._fileInput=_3d;
$addHandlers(_3d,{"change":this.uploadFileSelected},this);
var _3e=document.createElement("span");
_3e.className="ruFileWrap";
_3c.appendChild(_3e);
_3e.appendChild(_3d);
if(this._enableFileInputSkinning){
Sys.UI.DomElement.addCssClass(_3e,"ruStyled");
_3d.className="ruFileInput";
this._appendFakeInput(_3e);
if(!this._readOnlyFileInputs){
$addHandlers(_3d,{"keyup":this._syncFileInputContent},this);
}else{
$addHandlers(_3d,{"keydown":this._cancelEvent},this);
}
return _3e;
}else{
_3d.className="";
if(this._readOnlyFileInputs){
$addHandlers(_3d,{"keydown":this._cancelEvent},this);
}
return _3d;
}
},_appendFakeInput:function(_3f){
var _40=document.createElement("input");
_40.type="text";
_40.className="ruFakeInput";
_40.size=this._inputSize-1;
_3f.appendChild(_40);
var _41=document.createElement("input");
_41.type="button";
_3f.appendChild(_41);
this._initButton(_41,"Select");
_41.disabled=!this._enabled;
_41.className="ruButton ruBrowse";
if($telerik.isSafari){
var _42=$telerik.getBounds(_41).width;
var _43=$telerik.getBounds(_40).width;
var _44=this._fileInput;
if(_44){
_44.style.width=(_42+_43)+"px";
}
}
},createFileInput:function(){
var _45=document.createElement("input");
_45.type="file";
_45.name=this.getID("file");
_45.id=this.getID("file");
_45.disabled=!this._enabled;
_45.size=this._inputSize;
return _45;
},_setAddDeleteButtonStates:function(){
var _46=this._getRowCount();
this._setButtonState(this._deleteButton,_46>0);
this._setButtonState(this._addButton,(this._maxFileCount<=0)||(_46<this._maxFileCount));
},_setButtonState:function(_47,_48){
if(_47){
if(_48){
Sys.UI.DomElement.removeCssClass(_47,"ruButtonDisabled");
}else{
Sys.UI.DomElement.addCssClass(_47,"ruButtonDisabled");
}
}
},_cancelEvent:function(_49){
return $telerik.cancelRawEvent(_49);
},clearFileInputAt:function(_4a){
var row=this._getRow(_4a);
if(row){
var _4c=new Sys.CancelEventArgs();
_4c._fileInputField=this.getFileInputFrom(row);
_4c.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("clearing",_4c);
if(_4c.get_cancel()){
return false;
}
this.deleteFileInputAt(_4a,true);
this.addFileInputAtInternal(_4a,true);
}
},deleteSelectedFileInputs:function(_4d){
var _4e=[];
var _4f=[];
var _50=this._getRowCount()-1;
for(var i=_50;i>=0;i--){
var _52=this._getRow(i);
var _53=this._getChildUploadCheckbox(_52);
if(_53&&_53.checked){
_4f[_4f.length]=i;
_4e[_4e.length]=this.getFileInputFrom(_52);
}
}
var _54=new Sys.CancelEventArgs();
_54._fileInputFields=_4e;
_54.get_fileInputFields=function(){
return this._fileInputFields;
};
this.raiseEvent("deletingSelected",_54);
if(_54.get_cancel()){
return;
}
for(var i=0;i<_4f.length;i++){
this.deleteFileInputAt(_4f[i],true);
}
},deleteFileInputAt:function(_55,_56){
var row=this._getRow(_55);
if(row){
if(!_56){
var _58=new Sys.CancelEventArgs();
_58._fileInputField=this.getFileInputFrom(row);
_58.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("deleting",_58);
if(_58.get_cancel()){
return false;
}
}
$clearHandlers(row);
row.parentNode.removeChild(row);
this._setAddDeleteButtonStates();
}
},getFileInputFrom:function(row){
return this._getChildInputElement(row,"file");
},getFileInputs:function(){
var _5a=[];
var _5b=this._getRowCount();
for(var i=0;i<_5b;i++){
_5a[_5a.length]=this.getFileInputFrom(this._getRow(i));
}
return _5a;
},uploadFileSelected:function(e){
if(this._enableFileInputSkinning){
this._syncFileInputContent(e);
}
var _5e=e.target;
_5e.alt=_5e.title=_5e.value;
var _5f=new Sys.EventArgs();
_5f._fileInputField=_5e;
_5f.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("fileSelected",_5f);
},_syncFileInputContent:function(e){
var _61=e.target;
var _62=_61.parentNode.getElementsByTagName("input");
var _63=null;
for(var i=0;i<_62.length;i++){
var _65=_62[i];
if(_65.type=="text"){
_63=_65;
break;
}
}
if(_61!==_63){
_63.value=_61.value;
_63.title=_61.value;
_63.disabled=true;
}
},isExtensionValid:function(_66){
if(_66==""){
return true;
}
var _67=this._allowedFileExtensions.length;
for(var i=0;i<_67;i++){
var _69=this._allowedFileExtensions[i];
var _6a=_69.substring(1);
var _6b=new RegExp("."+_6a+"$","ig");
if(_66.match(_6b)){
return true;
}
}
return false;
},validateExtensions:function(){
var _6c=this._getRowCount();
for(var i=0;i<_6c;i++){
var row=this._getRow(i);
var _6f=this.getFileInputFrom(row).value;
if(!this.isExtensionValid(_6f)){
return false;
}
}
return true;
},_rowClicked:function(e){
var _71=e.target;
var _72=this._getParentRow(_71);
var _73=this._getRowIndex(_72);
if(_71.name=="RemoveRow"){
this.deleteFileInputAt(_73);
}else{
if(_71.name=="ClearInput"){
this.clearFileInputAt(_73);
}
}
},get_inputSize:function(){
return this._inputSize;
},set_inputSize:function(_74){
this._inputSize=_74;
},get_controlObjectsVisibility:function(){
return this._controlObjectsVisibility;
},set_controlObjectsVisibility:function(_75){
this._controlObjectsVisibility=_75;
var _76=Telerik.Web.UI.ControlObjectsVisibility;
this._showCheckboxes=(_75&_76.CheckBoxes);
this._showRemoveButtons=(_75&_76.RemoveButtons);
this._showClearButtons=(_75&_76.ClearButtons);
this._showAddButton=(_75&_76.AddButton);
this._showDeleteButton=(_75&_76.DeleteSelectedButton);
},get_allowedFileExtensions:function(){
return this._allowedFileExtensions;
},set_allowedFileExtensions:function(_77){
if(!_77){
this._allowedFileExtensions=[];
}else{
this._allowedFileExtensions=eval(_77);
}
},get_enabled:function(){
return this._enabled;
},set_enabled:function(_78){
this._enabled=_78;
},get_maxFileCount:function(){
return this._maxFileCount;
},set_maxFileCount:function(_79){
this._maxFileCount=_79;
},get_initialFileInputsCount:function(){
return this._initialFileInputsCount;
},set_initialFileInputsCount:function(_7a){
this._initialFileInputsCount=_7a;
},get_enableFileInputSkinning:function(){
return this._enableFileInputSkinning;
},set_enableFileInputSkinning:function(_7b){
this._enableFileInputSkinning=_7b;
},get_focusOnLoad:function(){
return this._focusOnLoad;
},set_focusOnLoad:function(_7c){
this._focusOnLoad=_7c;
},get_formId:function(){
return this._formId;
},set_formId:function(_7d){
this._formId=_7d;
},get_readOnlyFileInputs:function(){
return this._readOnlyFileInputs;
},set_readOnlyFileInputs:function(_7e){
this._readOnlyFileInputs=_7e;
},add_adding:function(_7f){
this.get_events().addHandler("adding",_7f);
},remove_adding:function(_80){
this.get_events().removeHandler("adding",_80);
},add_added:function(_81){
this.get_events().addHandler("added",_81);
},remove_added:function(_82){
this.get_events().removeHandler("added",_82);
},add_fileSelected:function(_83){
this.get_events().addHandler("fileSelected",_83);
},remove_fileSelected:function(_84){
this.get_events().removeHandler("fileSelected",_84);
},add_deleting:function(_85){
this.get_events().addHandler("deleting",_85);
},remove_deleting:function(_86){
this.get_events().removeHandler("deleting",_86);
},add_clearing:function(_87){
this.get_events().addHandler("clearing",_87);
},remove_clearing:function(_88){
this.get_events().removeHandler("clearing",_88);
},add_deletingSelected:function(_89){
this.get_events().addHandler("deletingSelected",_89);
},remove_deletingSelected:function(_8a){
this.get_events().removeHandler("deletingSelected",_8a);
}};
Telerik.Web.UI.RadUpload.registerClass("Telerik.Web.UI.RadUpload",Telerik.Web.UI.RadWebControl);

