@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 6.14 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/router"),require("@lxlib/util"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@lxlib/seed/full-content",["exports","@angular/common","@angular/core","@angular/router","@lxlib/util","rxjs","rxjs/operators"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed["full-content"]={}),e.ng.common,e.ng.core,e.ng.router,e.lxlib.util,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,o,r,i,l){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function s(e,t,n,o){var r,i=arguments.length,l=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(l=(i<3?r(l):i>3?r(t,n,l):r(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return l}function a(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(c(arguments[t]));return e}var p=function(){function e(){this._change=new i.BehaviorSubject(null)}return e.prototype.toggle=function(){this._change.next(!0)},Object.defineProperty(e.prototype,"change",{get:function(){return this._change.pipe(l.share())},enumerable:!0,configurable:!0}),e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var d="full-content__body",h="full-content__opened",f="full-content__hidden-title",g=function(){function e(e,t,o,r,i){this.el=e,this.cdr=t,this.srv=o,this.router=r,this.doc=i,this.inited=!1,this.id="_full-content-"+Math.random().toString(36).substring(2),this.scroll$=null,this._height=0,this.hideTitle=!0,this.padding=24,this.fullscreenChange=new n.EventEmitter}return e.prototype.updateCls=function(){var e=this.bodyEl.classList;this.fullscreen?(e.add(h),this.hideTitle&&e.add(f)):(e.remove(h),this.hideTitle&&e.remove(f))},e.prototype.update=function(){this.updateCls(),this.updateHeight(),this.fullscreenChange.emit(this.fullscreen)},e.prototype.updateHeight=function(){this._height=this.bodyEl.getBoundingClientRect().height-this.el.nativeElement.getBoundingClientRect().top-this.padding,this.cdr.detectChanges()},e.prototype.removeInBody=function(){this.bodyEl.classList.remove(d,h,f)},e.prototype.ngOnInit=function(){var e=this;this.inited=!0,this.bodyEl=this.doc.querySelector("body"),this.bodyEl.classList.add(d),this.el.nativeElement.id=this.id,this.updateCls(),this.scroll$=i.fromEvent(window,"resize").pipe(l.debounceTime(200)).subscribe((function(){return e.updateHeight()})),this.srv$=this.srv.change.pipe(l.filter((function(e){return null!==e}))).subscribe((function(){return e.toggle()})),this.route$=this.router.events.pipe(l.filter((function(e){return e instanceof o.ActivationStart||e instanceof o.ActivationEnd})),l.debounceTime(200)).subscribe((function(){e.doc.querySelector("#"+e.id)?(e.bodyEl.classList.add(d),e.updateCls()):e.removeInBody()}))},e.prototype.toggle=function(){this.fullscreen=!this.fullscreen,this.update(),this.updateHeight()},e.prototype.ngAfterViewInit=function(){var e=this;setTimeout((function(){return e.updateHeight()}))},e.prototype.ngOnChanges=function(){this.inited&&this.update()},e.prototype.ngOnDestroy=function(){this.removeInBody(),this.scroll$.unsubscribe(),this.srv$.unsubscribe(),this.route$.unsubscribe()},e.decorators=[{type:n.Component,args:[{selector:"full-content",exportAs:"fullContent",template:" <ng-content></ng-content> ",host:{"[class.full-content]":"true","[style.height.px]":"_height"},preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.ChangeDetectorRef},{type:p},{type:o.Router},{type:void 0,decorators:[{type:n.Inject,args:[t.DOCUMENT]}]}]},e.propDecorators={fullscreen:[{type:n.Input}],hideTitle:[{type:n.Input}],padding:[{type:n.Input}],fullscreenChange:[{type:n.Output}]},s([r.InputBoolean(),u("design:type",Boolean)],e.prototype,"fullscreen",void 0),s([r.InputBoolean(),u("design:type",Object)],e.prototype,"hideTitle",void 0),s([r.InputNumber(),u("design:type",Object)],e.prototype,"padding",void 0),e}();var y=function(){function e(e){this.parent=e}return e.prototype._click=function(){this.parent.toggle()},e.decorators=[{type:n.Directive,args:[{selector:"[full-toggle]",exportAs:"fullToggle",host:{"(click)":"_click()"}}]}],e.ctorParameters=function(){return[{type:g}]},e}();var b=[g,y],v=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{imports:[t.CommonModule,r.LxlibUtilModule],declarations:a(b),exports:a(b)}]}],e}();e.FullContentComponent=g,e.FullContentModule=v,e.FullContentService=p,e.FullContentToggleDirective=y,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=fullContent.umd.min.js.map