if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] !== 'undefined' ? args[number] : match; }); }; } if (!Array.prototype.hasValue) { Array.prototype.hasValue = function (key, value) { for (var item in this) { if (this.hasOwnProperty(item)) { if (this[item][key] === value) { return true; } } } return false; }; } if (!Array.prototype.contains) { Array.prototype.contains = function (value) { if ($.inArray(value, this) === -1) { return false; } else { return true; } }; } if (!String.prototype.endsWith) { String.prototype.endsWith = function (suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; } if (!String.prototype.isBase64) { String.prototype.isBase64 = function () { try { var decodedText = atob(this); var encodedText = btoa(decodedText); var isBase64Text = encodedText == this; return isBase64Text; } catch (ex) { return false; } }; } $.fn.onKeyPressEnter = function (func) { return this.each(function () { $(this).keypress(function (event) { var keycode = parseInt(event.keyCode ? event.keyCode : event.which); if (keycode === 13) { func.call(this, event); } }); }); }; $.fn.onKeyPressLeft = function (func) { return this.each(function () { $(this).keypress(function (event) { var keycode = parseInt(event.keyCode ? event.keyCode : event.which); if (keycode === 37) { func.call(this, event); } }); }); }; $.fn.onKeyPressRight = function (func) { return this.each(function () { $(this).keypress(function (event) { var keycode = parseInt(event.keyCode ? event.keyCode : event.which); if (keycode === 39) { func.call(this, event); } }); }); }; jQuery.fn.extend({ insertAtCaret: function (myValue) { return this.each(function (i) { if (document.selection) { //For browsers like Internet Explorer this.focus(); var sel = document.selection.createRange(); sel.text = myValue; this.focus(); } else if (this.selectionStart || this.selectionStart == '0') { //For browsers like Firefox and Webkit based var startPos = this.selectionStart; var endPos = this.selectionEnd; var scrollTop = this.scrollTop; this.value = this.value.substring(0, startPos) + myValue + this.value.substring(endPos, this.value.length); this.focus(); this.selectionStart = startPos + myValue.length; this.selectionEnd = startPos + myValue.length; this.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } }); } }); $.fn.resetForm = function () { var form = $(this); var inputs = form.find( "input:not([disabled]):not(.disabledItem):not([type='hidden'])" ); $.each(inputs, function () { var input = $(this); var type = input.prop('type'); if (type === 'checkbox' || type === 'radio') { input.prop('checked', false); } else { input.val(''); } }); var multiselects = form.find('select[multiple]'); $.each(multiselects, function () { var multiselect = $(this); var kendoMultiSelect = multiselect.data('kendoMultiSelect'); if (typeof kendoMultiSelect !== 'undefined') kendoMultiSelect.value([]); }); }; var CommonUtils = (function () { var commonUtils = function () {}; commonUtils.allowOnlyNumber = function (e) { return allowOnlyNumber(e); }; commonUtils.checkBrowserVersion = function () { return CheckBrowserVersion(); }; commonUtils.checkKendoComboBoxHasItemByValue = function ( comboBoxName, value ) { return checkKendoComboBoxHasItemByValue(comboBoxName, value); }; commonUtils.createGuid = function (withoutHyphen) { return createGuid(withoutHyphen); }; commonUtils.exists = function (variable) { return exists(variable); }; commonUtils.getHtmlInnerTextFromString = function (variable) { return getHtmlInnerTextFromString(variable); }; commonUtils.getNormalizedHtmlFromString = function (variable) { return getNormalizedHtmlFromString(variable); }; commonUtils.isBool = function (variable) { return isBool(variable); }; commonUtils.isFunction = function (variable) { return isFunction(variable); }; commonUtils.isNull = function (variable) { return isNull(variable); }; commonUtils.isNullOrEmpty = function (variable) { return isNullOrEmpty(variable); }; commonUtils.isNullOrUndefined = function (variable) { return isNull(variable) || isUndefined(variable); }; commonUtils.isNullOrWhiteSpace = function (variable, checkUnstrippedText) { return isNullOrWhiteSpace(variable, checkUnstrippedText); }; commonUtils.isNullOrEmptyOrUndefined = function (variable) { return isNullOrEmpty(variable) || isUndefined(variable); }; commonUtils.isUndefined = function (variable) { return isUndefined(variable); }; commonUtils.parseBool = function (variable) { return parseBool(variable); }; commonUtils.parseNull = function (variable) { return parseNull(variable); }; commonUtils.setCaretPosition = function (input, position) { return setCaretPosition(input, position); }; commonUtils.Log = function (text) { if (!isUndefined(console) && !isUndefined(console.error)) { console.error(text); } }; commonUtils.formFileDownload = function (url, fileId) { if ($('#hidden-form').length > 0) { $('#hidden-form').remove(); } $('