@duoduo-oba/ng-devui
Version:
DevUI components based on Angular
16 lines (14 loc) • 6.7 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core"),require("@angular/common"),require("ng-devui/button")):"function"==typeof define&&define.amd?define("ng-devui/fullscreen",["exports","@angular/core","@angular/common","ng-devui/button"],n):n(((e=e||self)["ng-devui"]=e["ng-devui"]||{},e["ng-devui"].fullscreen={}),e.ng.core,e.ng.common,e["ng-devui"].button)}(this,(function(e,n,t,r){"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 l(e,n,t,r){return new(t||(t=Promise))((function(l,u){function c(e){try{o(r.next(e))}catch(e){u(e)}}function s(e){try{o(r.throw(e))}catch(e){u(e)}}function o(e){e.done?l(e.value):new t((function(n){n(e.value)})).then(c,s)}o((r=r.apply(e,n||[])).next())}))}function u(e,n){var t,r,l,u,c={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return u={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(u){return function(s){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;c;)try{if(t=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(l=(l=c.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){c.label=u[1];break}if(6===u[0]&&c.label<l[1]){c.label=l[1],l=u;break}if(l&&c.label<l[2]){c.label=l[2],c.ops.push(u);break}l[2]&&c.ops.pop(),c.trys.pop();continue}u=n.call(e,c)}catch(e){u=[6,e],r=0}finally{t=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}var c=function(){function e(e,t){var r=this;this.elementRef=e,this.doc=t,this.isFullscreen=!1,this.mode="immersive",this.zIndex=10,this.fullscreenLaunch=new n.EventEmitter,this.onFullScreenChange=function(e){if(r.currentTarget){var n=r.currentTarget;r.doc.fullscreenElement?r.launchNormalFullscreen(n):(r.currentTarget=null,r.exitNormalFullscreen(n));var t=!!r.doc.fullscreenElement;r.fullscreenLaunch.emit({isFullscreen:t}),r.isFullscreen=t}},this.handleFullscreen=function(){return l(r,void 0,void 0,(function(){var e,n;return u(this,(function(t){switch(t.label){case 0:return e=this.elementRef.nativeElement.querySelector("[fullscreen-target]"),"normal"!==this.mode?[3,1]:(e.classList.contains("fullscreen")?(this.exitNormalFullscreen(e),n=!1):(this.launchNormalFullscreen(e),n=!0),[3,5]);case 1:return this.currentTarget=e,this.doc.fullscreenElement?[4,this.exitImmersiveFullScreen(this.doc)]:[3,3];case 2:return n=t.sent(),[3,5];case 3:return[4,this.launchImmersiveFullScreen(this.doc.documentElement)];case 4:n=t.sent(),t.label=5;case 5:return this.isFullscreen=n,this.fullscreenLaunch.emit({isFullscreen:n}),[2]}}))}))},this.handleKeyDown=function(e){if(27===e.keyCode&&r.isFullscreen){var n=r.elementRef.nativeElement.querySelector("[fullscreen-target]");"normal"===r.mode?r.exitNormalFullscreen(n):r.doc.fullscreenElement&&r.exitImmersiveFullScreen(r.doc),r.fullscreenLaunch.emit({isFullscreen:!1}),r.isFullscreen=!1}}}return e.prototype.ngOnInit=function(){document.addEventListener("fullscreenchange",this.onFullScreenChange),document.addEventListener("keydown",this.handleKeyDown);var e=this.elementRef.nativeElement.querySelector("[fullscreen-launch]");e&&e.addEventListener("click",this.handleFullscreen)},e.prototype.launchNormalFullscreen=function(e){e.classList.add("fullscreen"),this.zIndex&&e.setAttribute("style","z-index: "+this.zIndex)},e.prototype.exitNormalFullscreen=function(e){e.classList.remove("fullscreen"),e.style.zIndex=null},e.prototype.launchImmersiveFullScreen=function(e){return l(this,void 0,void 0,(function(){var n,t=this;return u(this,(function(r){switch(r.label){case 0:return e.requestFullscreen?n=e.requestFullscreen():e.mozRequestFullScreen?n=e.mozRequestFullScreen():e.webkitRequestFullScreen?n=e.webkitRequestFullScreen():e.msRequestFullscreen&&(n=e.msRequestFullscreen()),[4,n.then((function(){return!!t.doc.fullscreenElement}))];case 1:return[2,r.sent()]}}))}))},e.prototype.exitImmersiveFullScreen=function(e){return l(this,void 0,void 0,(function(){var n,t=this;return u(this,(function(r){switch(r.label){case 0:return e.exitFullscreen?n=e.exitFullscreen():e.mozCancelFullScreen?n=e.mozCancelFullScreen():e.webkitCancelFullScreen?n=e.webkitCancelFullScreen():e.msExitFullscreen&&(n=e.msExitFullscreen()),[4,n.then((function(){return!!t.doc.fullscreenElement}))];case 1:return[2,r.sent()]}}))}))},e.prototype.ngOnDestroy=function(){document.removeEventListener("fullscreenchange",this.onFullScreenChange),document.removeEventListener("keydown",this.handleKeyDown);var e=this.elementRef.nativeElement.querySelector("[fullscreen-launch]");e&&e.removeEventListener("click",this.handleFullscreen)},e.decorators=[{type:n.Component,args:[{selector:"d-fullscreen",template:'<div class="fullscreen-container">\r\n <ng-content select="[fullscreen-launch]"></ng-content>\r\n <ng-content select="[fullscreen-target]"></ng-content>\r\n</div>\r\n',styles:[":host ::ng-deep .fullscreen{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10;overflow:auto;background-color:#fff}"]}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:void 0,decorators:[{type:n.Inject,args:[t.DOCUMENT]}]}]},e.propDecorators={mode:[{type:n.Input}],zIndex:[{type:n.Input}],target:[{type:n.Input}],fullscreenLaunch:[{type:n.Output}]},e}();var s=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{imports:[t.CommonModule,r.ButtonModule],exports:[c],declarations:[c]}]}],e}();e.FullscreenModule=s,e.ɵa=c,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-devui-fullscreen.umd.min.js.map