1(function() { 2 var validationIDSuffix = { 3 ButtonImageIdPostfix: "Img" 4 }; 5 ASPx.HtmlEditorClasses.Managers.ValidationManager = ASPx.CreateClass(null, { 6 constructor: function(htmlEditor) { 7 this.htmlEditor = htmlEditor; 8 this.templateHoverErrorFrameCloseButton = null; 9 this.isValid = true; 10 this.clientValidationEnabled = false; 11 this.validationPatterns = []; 12 this.initialErrorText = ""; 13 this.errorText = ""; 14 this.notifyValidationSummariesToAcceptNewError = false; 15 }, 16 initialize: function() { 17 if(this.htmlEditor.enabled) 18 this.initializeErrorFrames(); 19 this.updateClientValidationState(); 20 this.updateValidationSummaries(null , true ); 21 }, 22 initializeErrorFrames: function() { 23 this.initialErrorText = this.errorText; 24 this.createErrorFrames(); 25 }, 26 createErrorFrames: function() { 27 if(!this.htmlEditor.getTemplateErrorFrame()) 28 return; 29 this.createAndInsertErrorFrame(this.htmlEditor.getDesignViewCell(), ASPx.HtmlEditorClasses.View.Design); 30 this.createAndInsertErrorFrame(this.htmlEditor.getHtmlViewEditCell(), ASPx.HtmlEditorClasses.View.Html); 31 this.createAndInsertErrorFrame(this.htmlEditor.getPreviewCell(), ASPx.HtmlEditorClasses.View.Preview); 32 }, 33 createAndInsertErrorFrame: function(cell, view) { 34 if(!cell) 35 return; 36 var errorFrame = this.createErrorFrame( 37 this.htmlEditor.getErrorFrameID(view), 38 this.htmlEditor.getErrorTextCellID(view), 39 this.htmlEditor.getErrorFrameCloseButtonCellID(view)); 40 if(view == ASPx.HtmlEditorClasses.View.Design && this.htmlEditor.enableTagInspector) 41 ASPx.InsertElementAfter(errorFrame, cell.firstChild); 42 else 43 cell.insertBefore(errorFrame, cell.firstChild); 44 }, 45 createErrorFrame: function(errorFrameId, errorTextCellId, errorFrameCloseButtonCellId) { 46 var errorFrame = this.htmlEditor.getTemplateErrorFrame().cloneNode(true); 47 errorFrame.id = errorFrameId; 48 errorTable = ASPx.GetNodeByTagName(errorFrame, "TABLE", 0); 49 var errorTextCell = ASPx.GetNodeByTagName(errorTable, "TD", 0); 50 errorTextCell.id = errorTextCellId; 51 var errorFrameCloseButtonCell = ASPx.GetNodeByTagName(errorTable, "TD", 2); 52 errorFrameCloseButtonCell.id = errorFrameCloseButtonCellId; 53 var errorFrameCloseButtonImage = ASPx.GetNodeByTagName(errorFrameCloseButtonCell, "IMG", 0); 54 errorFrameCloseButtonImage.id = errorFrameCloseButtonCellId + validationIDSuffix.ButtonImageIdPostfix; 55 this.createErrorFrameCloseButtonHoverState(errorFrameCloseButtonCell.id); 56 return errorFrame; 57 }, 58 createErrorFrameCloseButtonHoverState: function(buttonID) { 59 if(this.templateHoverErrorFrameCloseButton) { 60 ASPx.GetStateController().AddHoverItem(buttonID, 61 this.templateHoverErrorFrameCloseButton.className, this.templateHoverErrorFrameCloseButton.cssText, 62 this.templateHoverErrorFrameCloseButton.postfixes, this.templateHoverErrorFrameCloseButton.imageUrls, 63 this.templateHoverErrorFrameCloseButton.imagePostfixes); 64 } 65 }, 66 getIsValid: function(){ 67 return this.isValid; 68 }, 69 getErrorText: function(){ 70 return this.errorText; 71 }, 72 setIsValid: function(isValid, validating){ 73 if(this.clientValidationEnabled) { 74 this.isValid = isValid; 75 this.updateErrorFrame(); 76 this.updateClientValidationState(); 77 if(!validating) 78 this.updateValidationSummaries(ASPx.ValidationType.PersonalViaScript); 79 } 80 }, 81 setErrorText: function(errorText, validating){ 82 if(this.clientValidationEnabled) { 83 this.errorText = errorText; 84 this.updateErrorFrame(); 85 this.updateClientValidationState(); 86 if(!validating) 87 this.htmlEditor.updateValidationSummaries(ASPx.ValidationType.PersonalViaScript); 88 } 89 }, 90 validate: function() { 91 this.onValidation(ASPx.ValidationType.PersonalViaScript); 92 }, 93 beginErrorFrameUpdate: function() { 94 if(!this.errorFrameUpdateLocked) 95 this.errorFrameUpdateLocked = true; 96 }, 97 endErrorFrameUpdate: function() { 98 this.errorFrameUpdateLocked = false; 99 this.updateErrorFrame(); 100 },
101 onValidation: function(validationType) { 102 if(this.clientValidationEnabled && this.htmlEditor.isInitialized) { 103 this.beginErrorFrameUpdate(); 104 this.setIsValid(true, true); 105 this.setErrorText(this.initialErrorText, true); 106 this.isValid = this.validateWithPatterns(); 107 if(this.isValid) { 108 var currentHtml = this.htmlEditor.GetHtml(); 109 var args = this.htmlEditor.RaiseValidation(currentHtml, this.isValid, this.errorText); 110 if(currentHtml != args.html) 111 this.htmlEditor.SetHtml(args.html); 112 this.setIsValid(args.isValid, true); 113 this.setErrorText(args.errorText, true); 114 } 115 this.endErrorFrameUpdate(); 116 this.updateClientValidationState(); 117 this.updateValidationSummaries(validationType); 118 return this.isValid; 119 } 120 else 121 return true; 122 }, 123 validateWithPatterns: function() { 124 if(this.validationPatterns.length > 0) { 125 var html = this.htmlEditor.GetHtml(); 126 for(var i = 0; i < this.validationPatterns.length; i++) { 127 var validator = this.validationPatterns[i]; 128 if(!validator.EvaluateIsValid(html)) { 129 this.setIsValid(false, true); 130 this.setErrorText(validator.errorText, true); 131 return false; 132 } 133 } 134 } 135 return true; 136 }, 137 updateErrorFrame: function() { 138 if(this.errorFrameUpdateLocked) 139 return; 140 if(!this.htmlEditor.IsIFrameReady()) { 141 this.needUpdateErrorFrame = true; 142 return; 143 } 144 this.needUpdateErrorFrame = false; 145 this.htmlEditor.layoutManager.saveCurrentSize(false, true); 146 var errorTextCell = this.htmlEditor.getErrorTextCell(); 147 if(errorTextCell != null) 148 errorTextCell.innerHTML = this.htmlEditor.HtmlEncode(this.errorText); 149 if(!this.isValid) 150 this.showErrorFrame(); 151 else 152 this.hideErrorFrame(); 153 this.htmlEditor.layoutManager.restoreHeight(); 154 }, 155 showErrorFrame: function() { 156 this.setErrorFrameVisibility(true); 157 }, 158 hideErrorFrame: function() { 159 this.setErrorFrameVisibility(false); 160 }, 161 setErrorFrameVisibility: function(visible) { 162 var errorFrame = this.htmlEditor.getErrorFrame(); 163 if(errorFrame != null) 164 ASPx.SetElementDisplay(errorFrame, visible); 165 }, 166 updateClientValidationState: function() { 167 if(this.clientValidationEnabled && this.htmlEditor.isInitialized) { 168 var validationState = !this.isValid ? this.errorText : ""; 169 this.htmlEditor.UpdateStateObjectWithObject({ validationState: validationState }); 170 } 171 }, 172 updateValidationSummaries: function(validationType, initializing) { 173 if(ASPx.Ident.scripts.ASPxClientValidationSummary) { 174 var summaryCollection = ASPx.GetClientValidationSummaryCollection(); 175 if(summaryCollection != null) 176 summaryCollection.OnEditorIsValidStateChanged(this.htmlEditor, validationType, initializing && this.htmlEditor.notifyValidationSummariesToAcceptNewError); 177 } 178 }, 179 isStandardValidationEnabled: function() { 180 return !!window.ValidatorHookupControl; 181 }, 182 redirectStandardValidators: function() { 183 var contentToValidate = this.htmlEditor.getStandardValidationHiddenField(); 184 if(contentToValidate.Validators) { 185 for(var i = 0; i < contentToValidate.Validators.length; i++) 186 contentToValidate.Validators[i].controltovalidate = contentToValidate.id; 187 } 188 } 189 }); 190})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.