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();
$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";
},createFileInput:function(){
var _42=document.createElement("input");
_42.type="file";
_42.name=this.getID("file");
_42.id=this.getID("file");
_42.disabled=!this._enabled;
_42.size=this._inputSize;
return _42;
},_setAddDeleteButtonStates:function(){
var _43=this._getRowCount();
this._setButtonState(this._deleteButton,_43>0);
this._setButtonState(this._addButton,(this._maxFileCount<=0)||(_43<this._maxFileCount));
},_setButtonState:function(_44,_45){
if(_44){
if(_45){
Sys.UI.DomElement.removeCssClass(_44,"ruButtonDisabled");
}else{
Sys.UI.DomElement.addCssClass(_44,"ruButtonDisabled");
}
}
},_cancelEvent:function(_46){
return $telerik.cancelRawEvent(_46);
},clearFileInputAt:function(_47){
var row=this._getRow(_47);
if(row){
var _49=new Sys.CancelEventArgs();
_49._fileInputField=this.getFileInputFrom(row);
_49.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("clearing",_49);
if(_49.get_cancel()){
return false;
}
this.deleteFileInputAt(_47,true);
this.addFileInputAtInternal(_47,true);
}
},deleteSelectedFileInputs:function(_4a){
var _4b=[];
var _4c=[];
var _4d=this._getRowCount()-1;
for(var i=_4d;i>=0;i--){
var _4f=this._getRow(i);
var _50=this._getChildUploadCheckbox(_4f);
if(_50&&_50.checked){
_4c[_4c.length]=i;
_4b[_4b.length]=this.getFileInputFrom(_4f);
}
}
var _51=new Sys.CancelEventArgs();
_51._fileInputFields=_4b;
_51.get_fileInputFields=function(){
return this._fileInputFields;
};
this.raiseEvent("deletingSelected",_51);
if(_51.get_cancel()){
return;
}
for(var i=0;i<_4c.length;i++){
this.deleteFileInputAt(_4c[i],true);
}
},deleteFileInputAt:function(_52,_53){
var row=this._getRow(_52);
if(row){
if(!_53){
var _55=new Sys.CancelEventArgs();
_55._fileInputField=this.getFileInputFrom(row);
_55.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("deleting",_55);
if(_55.get_cancel()){
return false;
}
}
$clearHandlers(row);
row.parentNode.removeChild(row);
this._setAddDeleteButtonStates();
}
},getFileInputFrom:function(row){
return this._getChildInputElement(row,"file");
},getFileInputs:function(){
var _57=[];
var _58=this._getRowCount();
for(var i=0;i<_58;i++){
_57[_57.length]=this.getFileInputFrom(this._getRow(i));
}
return _57;
},uploadFileSelected:function(e){
if(this._enableFileInputSkinning){
this._syncFileInputContent(e);
}
var _5b=e.target;
_5b.alt=_5b.title=_5b.value;
var _5c=new Sys.EventArgs();
_5c._fileInputField=_5b;
_5c.get_fileInputField=function(){
return this._fileInputField;
};
this.raiseEvent("fileSelected",_5c);
},_syncFileInputContent:function(e){
var _5e=e.target;
var _5f=_5e.parentNode.getElementsByTagName("input");
var _60=null;
for(var i=0;i<_5f.length;i++){
var _62=_5f[i];
if(_62.type=="text"){
_60=_62;
break;
}
}
if(_5e!==_60){
_60.value=_5e.value;
_60.title=_5e.value;
_60.disabled=true;
}
},isExtensionValid:function(_63){
if(_63==""){
return true;
}
var _64=this._allowedFileExtensions.length;
for(var i=0;i<_64;i++){
var _66=this._allowedFileExtensions[i];
var _67=_66.substring(1);
var _68=new RegExp("."+_67+"$","ig");
if(_63.match(_68)){
return true;
}
}
return false;
},validateExtensions:function(){
var _69=this._getRowCount();
for(var i=0;i<_69;i++){
var row=this._getRow(i);
var _6c=this.getFileInputFrom(row).value;
if(!this.isExtensionValid(_6c)){
return false;
}
}
return true;
},_rowClicked:function(e){
var _6e=e.target;
var _6f=this._getParentRow(_6e);
var _70=this._getRowIndex(_6f);
if(_6e.name=="RemoveRow"){
this.deleteFileInputAt(_70);
}else{
if(_6e.name=="ClearInput"){
this.clearFileInputAt(_70);
}
}
},get_inputSize:function(){
return this._inputSize;
},set_inputSize:function(_71){
this._inputSize=_71;
},get_controlObjectsVisibility:function(){
return this._controlObjectsVisibility;
},set_controlObjectsVisibility:function(_72){
this._controlObjectsVisibility=_72;
var _73=Telerik.Web.UI.ControlObjectsVisibility;
this._showCheckboxes=(_72&_73.CheckBoxes);
this._showRemoveButtons=(_72&_73.RemoveButtons);
this._showClearButtons=(_72&_73.ClearButtons);
this._showAddButton=(_72&_73.AddButton);
this._showDeleteButton=(_72&_73.DeleteSelectedButton);
},get_allowedFileExtensions:function(){
return this._allowedFileExtensions;
},set_allowedFileExtensions:function(_74){
if(!_74){
this._allowedFileExtensions=[];
}else{
this._allowedFileExtensions=eval(_74);
}
},get_enabled:function(){
return this._enabled;
},set_enabled:function(_75){
this._enabled=_75;
},get_maxFileCount:function(){
return this._maxFileCount;
},set_maxFileCount:function(_76){
this._maxFileCount=_76;
},get_initialFileInputsCount:function(){
return this._initialFileInputsCount;
},set_initialFileInputsCount:function(_77){
this._initialFileInputsCount=_77;
},get_enableFileInputSkinning:function(){
return this._enableFileInputSkinning;
},set_enableFileInputSkinning:function(_78){
this._enableFileInputSkinning=_78;
},get_focusOnLoad:function(){
return this._focusOnLoad;
},set_focusOnLoad:function(_79){
this._focusOnLoad=_79;
},get_formId:function(){
return this._formId;
},set_formId:function(_7a){
this._formId=_7a;
},get_readOnlyFileInputs:function(){
return this._readOnlyFileInputs;
},set_readOnlyFileInputs:function(_7b){
this._readOnlyFileInputs=_7b;
},add_adding:function(_7c){
this.get_events().addHandler("adding",_7c);
},remove_adding:function(_7d){
this.get_events().removeHandler("adding",_7d);
},add_added:function(_7e){
this.get_events().addHandler("added",_7e);
},remove_added:function(_7f){
this.get_events().removeHandler("added",_7f);
},add_fileSelected:function(_80){
this.get_events().addHandler("fileSelected",_80);
},remove_fileSelected:function(_81){
this.get_events().removeHandler("fileSelected",_81);
},add_deleting:function(_82){
this.get_events().addHandler("deleting",_82);
},remove_deleting:function(_83){
this.get_events().removeHandler("deleting",_83);
},add_clearing:function(_84){
this.get_events().addHandler("clearing",_84);
},remove_clearing:function(_85){
this.get_events().removeHandler("clearing",_85);
},add_deletingSelected:function(_86){
this.get_events().addHandler("deletingSelected",_86);
},remove_deletingSelected:function(_87){
this.get_events().removeHandler("deletingSelected",_87);
}};
Telerik.Web.UI.RadUpload.registerClass("Telerik.Web.UI.RadUpload",Telerik.Web.UI.RadWebControl);

