/* * @class ExpandingInput */ (function() { var ExpandingInput; ExpandingInput = function($container, options) { if (options == null) { options = {}; } this.options = $.extend({}, ExpandingInput.DEFAULTS, options || {}); this.$container = $container; this.$target = this.options.target && this.$container.find(this.options.target).length ? this.$container.find(this.options.target) : null; this.$content = this.options.hidden_content && this.$container.find(this.options.hidden_content).length ? this.$container.find(this.options.hidden_content) : null; this.$container.addClass('expanding-input'); if (this.$target) { this.$target.addClass('expanding-input-target'); if (this.$target.hasClass('input-sm')) { this.$container.addClass('expanding-input-sm'); } if (this.$target.hasClass('input-lg')) { this.$container.addClass('expanding-input-lg'); } } if (this.$content) { this.$content.addClass('expanding-input-content'); } this.$overlay = $('
').appendTo(this.$container); if (this.$target && this.$target.attr('placeholder')) { if (!this.options.placeholder) { this.options.placeholder = this.$target.attr('placeholder'); } this.$target.attr('placeholder', ''); } if (this.options.placeholder) { this.$overlay.append($('').html(this.options.placeholder)); } if (this.$target) { this.$target.on('focus', $.proxy(this.expand, this)); } return this.$overlay.on('click.expanding_input', $.proxy(this.expand, this)); }; ExpandingInput.prototype.expand = function() { if (this.$container.hasClass('expanded')) { return; } if (this.options.onBeforeExpand) { this.options.onBeforeExpand.call(this); } this.$overlay.remove(); this.$container.addClass('expanded'); if (this.$target) { setTimeout((function(_this) { return function() { return _this.$target.focus(); }; })(this), 1); } if (this.$target && this.options.placeholder) { this.$target.attr('placeholder', $('