blob: bfcaa100c3251524c51bc64a5c58fb9fc9b68770 [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@covalent/core/media",["exports","@angular/common","rxjs","@angular/core"],t):t((e.covalent=e.covalent||{},e.covalent.core=e.covalent.core||{},e.covalent.core.media={}),e.ng.common,e.rxjs,e.ng.core)}(this,function(e,t,r,i){"use strict";var s=(n.prototype.deregisterQuery=function(e){this._queryMap.get(e.toLowerCase())&&(e=this._queryMap.get(e.toLowerCase())),this._querySources[e].unsubscribe(),delete this._querySources[e],delete this._queryObservables[e]},n.prototype.query=function(e){return this._queryMap.get(e.toLowerCase())&&(e=this._queryMap.get(e.toLowerCase())),this._ngZone.run(function(){return matchMedia(e).matches})},n.prototype.registerQuery=function(e){return this._queryMap.get(e.toLowerCase())&&(e=this._queryMap.get(e.toLowerCase())),this._querySources[e]||(this._querySources[e]=new r.BehaviorSubject(matchMedia(e).matches),this._queryObservables[e]=this._querySources[e].asObservable()),this._queryObservables[e]},n.prototype.broadcast=function(){this._onResize()},n.prototype._onResize=function(){function e(e){r._ngZone.run(function(){t._matchMediaTrigger(e)})}var t=this,r=this;for(var i in this._querySources)e(i)},n.prototype._matchMediaTrigger=function(e){this._querySources[e].next(matchMedia(e).matches)},n.decorators=[{type:i.Injectable}],n.ctorParameters=function(){return[{type:i.NgZone}]},n);function n(e){var t=this;this._ngZone=e,this._resizing=!1,this._queryMap=new Map,this._querySources={},this._queryObservables={},this._queryMap.set("xs","(max-width: 599px)"),this._queryMap.set("gt-xs","(min-width: 600px)"),this._queryMap.set("sm","(min-width: 600px) and (max-width: 959px)"),this._queryMap.set("gt-sm","(min-width: 960px)"),this._queryMap.set("md","(min-width: 960px) and (max-width: 1279px)"),this._queryMap.set("gt-md","(min-width: 1280px)"),this._queryMap.set("lg","(min-width: 1280px) and (max-width: 1919px)"),this._queryMap.set("gt-lg","(min-width: 1920px)"),this._queryMap.set("xl","(min-width: 1920px)"),this._queryMap.set("landscape","(orientation: landscape)"),this._queryMap.set("portrait","(orientation: portrait)"),this._queryMap.set("print","print"),this._resizing=!1,this._globalSubscription=this._ngZone.runOutsideAngular(function(){return r.fromEvent(window,"resize").subscribe(function(){t._resizing||(t._resizing=!0,setTimeout(function(){t._onResize(),t._resizing=!1},100))})})}function o(e,t){return e||new s(t)}var a={provide:s,deps:[[new i.Optional,new i.SkipSelf,s],i.NgZone],useFactory:o},u=(Object.defineProperty(c.prototype,"query",{set:function(e){if(!e)throw new Error("Query needed for [tdMediaToggle] directive.");this._query=e},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"attributes",{set:function(e){this._attributes=e},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"classes",{set:function(e){this._classes=e},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"styles",{set:function(e){this._styles=e},enumerable:!0,configurable:!0}),c.prototype.ngOnInit=function(){var t=this;this._mediaChange(this._mediaService.query(this._query)),this._subscription=this._mediaService.registerQuery(this._query).subscribe(function(e){t._mediaChange(e)})},c.prototype.ngOnDestroy=function(){this._subscription&&this._subscription.unsubscribe()},c.prototype._mediaChange=function(e){this._matches=e,this._changeAttributes(),this._changeClasses(),this._changeStyles()},c.prototype._changeAttributes=function(){for(var e in this._attributes)this._matches?this._renderer.setAttribute(this._elementRef.nativeElement,e,this._attributes[e]):this._renderer.removeAttribute(this._elementRef.nativeElement,e)},c.prototype._changeClasses=function(){var t=this;this._classes.forEach(function(e){t._matches?t._renderer.addClass(t._elementRef.nativeElement,e):t._renderer.removeClass(t._elementRef.nativeElement,e)})},c.prototype._changeStyles=function(){for(var e in this._styles)this._matches?this._renderer.setStyle(this._elementRef.nativeElement,e,this._styles[e]):this._renderer.removeStyle(this._elementRef.nativeElement,e)},c.decorators=[{type:i.Directive,args:[{selector:"[tdMediaToggle]"}]}],c.ctorParameters=function(){return[{type:i.Renderer2},{type:i.ElementRef},{type:s}]},c.propDecorators={query:[{type:i.Input,args:["tdMediaToggle"]}],attributes:[{type:i.Input,args:["mediaAttributes"]}],classes:[{type:i.Input,args:["mediaClasses"]}],styles:[{type:i.Input,args:["mediaStyles"]}]},c);function c(e,t,r){this._renderer=e,this._elementRef=t,this._mediaService=r,this._matches=!1,this._attributes={},this._styles={},this._classes=[]}var h=[u],p=(_.decorators=[{type:i.NgModule,args:[{imports:[t.CommonModule],declarations:[h],exports:[h],providers:[a]}]}],_);function _(){}e.CovalentMediaModule=p,e.TdMediaToggleDirective=u,e.MEDIA_PROVIDER_FACTORY=o,e.TdMediaService=s,e.MEDIA_PROVIDER=a,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=covalent-core-media.umd.min.js.map