(function($) { var uniqueId = 0; function getUniqueId($obj) { if ($obj && $obj.attr('id')) { return $obj.attr('id'); } else { var result = "uni_text_" + uniqueId++; if ($obj) $obj.attr('id', result); return result; } } var oldAttr = $.fn.attr; $.fn.attr = function(name, value) { var result = oldAttr.apply(this, arguments); if (name === "disabled" && value) { $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.addClass('disabled'); } }); } else if (name === "readonly" && value) { $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.addClass('readonly'); } }); } return result; } var oldRemoveAttr = $.fn.removeAttr; $.fn.removeAttr = function(name) { if (name === "disabled") { $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.removeClass('disabled'); } }); } else if (name === "readonly") { $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.removeClass('readonly'); } }); } return oldRemoveAttr.apply(this, arguments); } var oldShow = $.fn.show; $.fn.show = function() { var result = oldShow.apply(this); $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.show(); } }); return result; } var oldHide = $.fn.hide; $.fn.hide = function() { var result = oldHide.apply(this); $(this).each(function() { if (this.params && this.params.uni_text) { var $obj = $(this); var wrapperId = $obj.data('wrapper-id'); var $wrapper = $('#' + wrapperId); $wrapper.hide(); } }); return result; } $.fn.uni_text = function(options) { return this.each(function(){ var $obj = $(this); var defaults = { uni_text: true } if ($obj.hasClass('inp-std')) return; if (this.params && this.params.uni_text) return; this.params = $.extend(defaults, options, this.params); var wrapperClass; var objHeight = false; if ($obj.is('textarea')) { wrapperClass = 'textarea'; if ($obj.attr('rows') || $obj.attr('height')) { objHeight = getTextareaHeight($obj); } else { objHeight = 100; } } else if ($obj.is('input[type="search"]')) { wrapperClass = 'input-search'; } else { wrapperClass = 'input-text'; } var $div = $obj.parent().parent(); if (!$div.is('div.inp-nalog')) { var resetId = getUniqueId(); $div = $('