Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/addon/display/panel.min.js |
(function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)})(function(n){n.defineExtension("addPanel",function(t,e){e=e||{},this.state.panels||d(this);var i=this.state.panels,r=i.wrapper,s=this.getWrapperElement(),p=e.replace instanceof a&&!e.replace.cleared;e.after instanceof a&&!e.after.cleared?r.insertBefore(t,e.before.node.nextSibling):e.before instanceof a&&!e.before.cleared?r.insertBefore(t,e.before.node):p?(r.insertBefore(t,e.replace.node),e.replace.clear(!0)):e.position=="bottom"?r.appendChild(t):e.position=="before-bottom"?r.insertBefore(t,s.nextSibling):e.position=="after-top"?r.insertBefore(t,s):r.insertBefore(t,r.firstChild);var f=e&&e.height||t.offsetHeight,o=new a(this,t,e,f);return i.panels.push(o),this.setSize(),e.stable&&c(this,t)&&this.scrollTo(null,this.getScrollInfo().top+f),o});function a(t,e,i,r){this.cm=t,this.node=e,this.options=i,this.height=r,this.cleared=!1}a.prototype.clear=function(t){if(!this.cleared){this.cleared=!0;var e=this.cm.state.panels;e.panels.splice(e.panels.indexOf(this),1),this.cm.setSize(),this.options.stable&&c(this.cm,this.node)&&this.cm.scrollTo(null,this.cm.getScrollInfo().top-this.height),e.wrapper.removeChild(this.node),e.panels.length==0&&!t&&g(this.cm)}},a.prototype.changed=function(){this.height=this.node.getBoundingClientRect().height,this.cm.setSize()};function d(t){var e=t.getWrapperElement(),i=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,r=parseInt(i.height),s=t.state.panels={setHeight:e.style.height,panels:[],wrapper:document.createElement("div")},p=t.hasFocus(),f=t.getScrollInfo();e.parentNode.insertBefore(s.wrapper,e),s.wrapper.appendChild(e),t.scrollTo(f.left,f.top),p&&t.focus(),t._setSize=t.setSize,r!=null&&(t.setSize=function(o,l){if(l||(l=s.wrapper.offsetHeight),s.setHeight=l,typeof l!="number"){var u=/^(\d+\.?\d*)px$/.exec(l);u?l=Number(u[1]):(s.wrapper.style.height=l,l=s.wrapper.offsetHeight)}var v=l-s.panels.map(function(h){return h.node.getBoundingClientRect().height}).reduce(function(h,S){return h+S},0);t._setSize(o,v),r=l})}function g(t){var e=t.state.panels;t.state.panels=null;var i=t.getWrapperElement(),r=t.hasFocus(),s=t.getScrollInfo();e.wrapper.parentNode.replaceChild(i,e.wrapper),t.scrollTo(s.left,s.top),r&&t.focus(),i.style.height=e.setHeight,t.setSize=t._setSize,t.setSize()}function c(t,e){for(var i=e.nextSibling;i;i=i.nextSibling)if(i==t.getWrapperElement())return!0;return!1}});