All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.butterfaces-dist-js.butterfaces-expandable.jquery.min.js Maven / Gradle / Ivy

There is a newer version: 3.5.0
Show newest version
var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();!function(t){t.fn.butterExpandable=function(){return this.each(function(e,n){var i=t(n);i.find("textarea").length>0?new ButterFaces.TextareaExpandable(i):new ButterFaces.DivExpandable(i)})}}(jQuery);var ButterFaces;!function(t){var e=function(){function t(t){this.rootElement=t}return t.prototype.expandElement=function(t){var e=this;this.isExpansionEventIgnored(t)||(this.initialHeight=this.originalElement.outerHeight(),this.initialWidth=this.originalElement.outerWidth(),this.initialOffset=this.originalElement.offset(),this.ghostElement=this.createGhostElement(),this.transferValueToGhostElement(),this.ghostElement.css("width",this.initialWidth).css("height",this.initialHeight).css("position","absolute").css("top",this.initialOffset.top).css("left",this.initialOffset.left).css("z-index",2e3).css("box-shadow","5px 5px 5px 0 #999").addClass("butter-component-expandable-ghost").appendTo($("body")).animate({height:250,width:this.initialWidth>500?this.initialWidth:500},200,"swing",function(){$(document).on("click.expandable",function(t){e.handleMouseClick(t)}).on("keydown.expandable",function(t){e.handleEscapeKey(t)}),$(window).on("resize.expandable",function(){e.repositionGhostElement()}),e.positionTriggerInterval=window.setInterval(function(){return e.repositionGhostElement},500)}),this.originalElement.css("visibility","hidden").siblings().css("visibility","hidden"),this.onGhostElementCreated())},t.prototype.collapseElement=function(t){var e="boolean"==typeof t&&t;$(document).off("click.expandable").off("keydown.expandable"),this.originalElement.css("visibility","visible").siblings().css("visibility","visible");var n=this;this.ghostElement.animate({height:n.initialHeight,width:n.initialWidth},200,"swing",function(){n.onGhostElementCollapsed(e),n.ghostElement.remove(),n.ghostElement=null,window.clearInterval(n.positionTriggerInterval),$(window).off("resize.expandable")})},t.prototype.handleMouseClick=function(t){$(t.target).is(".butter-component-expandable-ghost")||this.collapseElement(!1)},t.prototype.handleEscapeKey=function(t){27===t.which&&this.collapseElement(!0)},t.prototype.repositionGhostElement=function(){void 0!==this.ghostElement&&null!=this.ghostElement&&(this.initialOffset=this.originalElement.offset(),this.ghostElement.css("top",this.initialOffset.top).css("left",this.initialOffset.left))},t}(),n=function(t){function e(e){var n=t.call(this,e)||this;return n.originalElement=n.rootElement.find(".butter-component-value-readonly"),n.rearrangeOriginalElementStructure(),n}return __extends(e,t),e.prototype.rearrangeOriginalElementStructure=function(){var t=this,e=this.rootElement.find(".butter-component-label");this.originalElement.addClass("butter-component-expandable-original").click(function(e){t.expandElement(e)}).detach();var n=$("
").addClass("butter-component-expandable-readonly-container").insertAfter(e),i=$("").addClass("input-group-text glyphicon glyphicon-resize-full");this.originalElement.appendTo(n),$("
").addClass("butter-component-expandable-readonly-icon").append(i).appendTo(n)},e.prototype.createGhostElement=function(){return $("
")},e.prototype.isExpansionEventIgnored=function(t){return!1},e.prototype.onGhostElementCreated=function(){},e.prototype.onGhostElementCollapsed=function(t){},e.prototype.transferValueToGhostElement=function(){$("
").html(this.originalElement.html()).addClass("butter-component-expandable-ghost-readonlyContent").appendTo(this.ghostElement)},e}(e);t.DivExpandable=n;var i=function(t){function e(e){var n=t.call(this,e)||this;return n.blockFocusEventOnOriginal=!1,n.blockBlurEventOnOriginal=!1,n.originalElement=n.rootElement.find("textarea"),n.originalElement.addClass("butter-component-expandable-original"),n.originalElement.focus(function(t){n.expandElement(t)}),n.originalElement.blur(function(t){n.handleBlurEvent(t)}),n.addInputGroupAddon(),n}return __extends(e,t),e.prototype.addInputGroupAddon=function(){this.originalElement.addClass("form-control").parent().addClass("input-group"),$('').insertAfter(this.originalElement)},e.prototype.handleBlurEvent=function(t){this.blockBlurEventOnOriginal&&t.preventDefault()},e.prototype.createGhostElement=function(){return $("