/** * Validator javascript include */ validator = { /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// _hasErrors: [], hasErrors: function(errors) { return this._hasErrors[errors] == true; }, /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// collectErrorIds: function(errors) { result = ''; for (var id in errors) { if (result != '') result += ','; result += id; } return result; }, /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// clear: function(errors) { // unattached for (var id in errors) { try { if (errors[id].element == null) continue; jQuery(errors[id].element).html( this.composeUnattachedMessage(false, null) ); } catch (ex) { } } // attached - affected inputs var _validator = this; jQuery(".validator-affected").removeClass("validator-affected").each( function(ind) { _validator.detachTooltip(jQuery(this)); } ); // attached jQuery(".validator-group").css("display", "none").empty(); }, composeUnattachedMessage: function(isError, msg) { if (!isError) { return " "; } var html = "" + "" + "" + "" + "" + "
" + msg + "
"; return html; }, composeUnattached : function(errors, data) { for (var id in data) { try { if (errors[id].element == null) continue; jQuery(errors[id].element).html( this.composeUnattachedMessage(data[id].error, data[id].message) ); } catch (ex) { } } }, composeAttachedMessage: function(msg) { var html = "
" + msg + "
"; return html; }, composeAttached: function(errors, data) { for (var id in data) { try { if (errors[id].group == null || !data[id].error) continue; // ричёвые айдишники не работают через «#» (в них есть «:») var g = jQuery("*[id='" + errors[id].group + "']"); if (g.length == 0) continue; g.eq(0).append( this.composeAttachedMessage(data[id].message) ); } catch (ex) { } } }, applyAffected: function(errors, data) { // //jQuery(".validator-affected").removeClass("validator-affected").unbind(".validator"); // for (var id in data) { try { if (errors[id].group == null) continue; if (errors[id].affected == null) continue; for (var i = 0; i ' + data.validationData[id].error + ': ' + data.validationData[id].message + "\n"; } alert(xxx); */ this.composeUnattached(errors, data.validationData); this.composeAttached(errors, data.validationData); this.showAttached(); this.applyAffected(errors, data.validationData); try { scrollAfterValidation(); } catch(e) { } }, attachTooltip: function (obj, tooltip) { obj.data("titleBackup", obj.attr("title")); obj.attr("title", tooltip); }, detachTooltip: function (obj) { obj.attr("title", obj.data("titleBackup")); obj.removeData("titleBackup"); } }; /* //var has_errors_internal = new Object(); //var fields_for_errors = new Object(); function collectErrorIds(errors) { result = ''; for (var id in errors) { if (result != '') result += ','; result += id; } return result; } function processErrors(errors, data) { //has_errors_internal[errors] = data.hasErrors; validator.processErrors(errors, data); } function hasValidationErrors(errors) { //return has_errors_internal[errors] == true; return validator.hasErrors(errors); } */