awips2/elements/common_elements.vulcanized.js

4 lines
97 KiB
JavaScript
Raw Normal View History

2016-04-03 22:04:09 -05:00
(function(scope){scope.CoreResizable={resizableAttachedHandler:function(cb){cb=cb||this._notifyResizeSelf;this.async(function(){var detail={callback:cb,hasParentResizer:false};this.fire("core-request-resize",detail);if(!detail.hasParentResizer){this._boundWindowResizeHandler=cb.bind(this);window.addEventListener("resize",this._boundWindowResizeHandler)}}.bind(this))},resizableDetachedHandler:function(){this.fire("core-request-resize-cancel",null,this,false);if(this._boundWindowResizeHandler){window.removeEventListener("resize",this._boundWindowResizeHandler)}},_notifyResizeSelf:function(){return this.fire("core-resize",null,this,false).defaultPrevented}};scope.CoreResizer=Polymer.mixin({resizerAttachedHandler:function(){this.resizableAttachedHandler(this.notifyResize);this._boundResizeRequested=this._boundResizeRequested||this._handleResizeRequested.bind(this);var listener;if(this.resizerIsPeer){listener=this.parentElement||this.parentNode&&this.parentNode.host;listener._resizerPeers=listener._resizerPeers||[];listener._resizerPeers.push(this)}else{listener=this}listener.addEventListener("core-request-resize",this._boundResizeRequested);this._resizerListener=listener},resizerDetachedHandler:function(){this.resizableDetachedHandler();this._resizerListener.removeEventListener("core-request-resize",this._boundResizeRequested)},notifyResize:function(){if(!this._notifyResizeSelf()){var r=this.resizeRequestors;if(r){for(var i=0;i<r.length;i++){var ri=r[i];if(!this.resizerShouldNotify||this.resizerShouldNotify(ri.target)){ri.callback.apply(ri.target)}}}}},_handleResizeRequested:function(e){var target=e.path[0];if(target==this||target==this._resizerListener||this._resizerPeers&&this._resizerPeers.indexOf(target)<0){return}if(!this.resizeRequestors){this.resizeRequestors=[]}this.resizeRequestors.push({target:target,callback:e.detail.callback});target.addEventListener("core-request-resize-cancel",this._cancelResizeRequested.bind(this));e.detail.hasParentResizer=true;e.stopPropagation()},_cancelResizeRequested:function(e){if(this.resizeRequestors){for(var i=0;i<this.resizeRequestors.length;i++){if(this.resizeRequestors[i].target==e.target){this.resizeRequestors.splice(i,1);break}}}}},Polymer.CoreResizable)})(Polymer);Polymer.mixin2=function(prototype,mixin){if(mixin.mixinPublish){prototype.publish=prototype.publish||{};Polymer.mixin(prototype.publish,mixin.mixinPublish)}if(mixin.mixinDelegates){prototype.eventDelegates=prototype.eventDelegates||{};for(var e in mixin.mixinDelegates){if(!prototype.eventDelegates[e]){prototype.eventDelegates[e]=mixin.mixinDelegates[e]}}}if(mixin.mixinObserve){prototype.observe=prototype.observe||{};for(var o in mixin.mixinObserve){if(!prototype.observe[o]&&!prototype[o+"Changed"]){prototype.observe[o]=mixin.mixinObserve[o]}}}Polymer.mixin(prototype,mixin);delete prototype.mixinPublish;delete prototype.mixinDelegates;delete prototype.mixinObserve;return prototype};Polymer.CoreFocusable={mixinPublish:{active:{value:false,reflect:true},focused:{value:false,reflect:true},pressed:{value:false,reflect:true},disabled:{value:false,reflect:true},toggle:false},mixinDelegates:{contextMenu:"_contextMenuAction",down:"_downAction",up:"_upAction",focus:"_focusAction",blur:"_blurAction"},mixinObserve:{disabled:"_disabledChanged"},_disabledChanged:function(){if(this.disabled){this.style.pointerEvents="none";this.removeAttribute("tabindex");this.setAttribute("aria-disabled","")}else{this.style.pointerEvents="";this.setAttribute("tabindex",0);this.removeAttribute("aria-disabled")}},_downAction:function(){this.pressed=true;if(this.toggle){this.active=!this.active}else{this.active=true}},_contextMenuAction:function(e){this._upAction(e);this._focusAction()},_upAction:function(){this.pressed=false;if(!this.toggle){this.active=false}},_focusAction:function(){if(!this.pressed){this.focused=true}},_blurAction:function(){this.focused=false}};!function(a,b){b["true"]=a;var c={},d={},e={},f=null;!function(a){function b(b,c){var d={delay:0,endDelay:0,fill:c?"both":"none",iterationStart:0,iterations:1,duration:c?"auto":0,playbackR
this._player.currentTime=a,this._register(),this._forEachChild(function(b,c){b.currentTime=a-c})},get startTime(){return this._player.startTime},set startTime(a){this._player.startTime=a,this._register(),this._forEachChild(function(b,c){b.startTime=a+c})},get playbackRate(){return this._player.playbackRate},set playbackRate(a){this._player.playbackRate=a,this._forEachChild(function(b){b.playbackRate=a})},get finished(){return this._player.finished},play:function(){this._player.play(),this._register(),b.awaitStartTime(this),this._forEachChild(function(a){var b=a.currentTime;a.play(),a.currentTime=b})},pause:function(){this._player.pause(),this._register(),this._forEachChild(function(a){a.pause()})},finish:function(){this._player.finish(),this._register()},cancel:function(){this._player.cancel(),this._register(),this._removePlayers()},reverse:function(){this._player.reverse(),b.awaitStartTime(this),this._register(),this._forEachChild(function(a,b){a.reverse(),a.startTime=this.startTime+b*this.playbackRate,a.currentTime=this.currentTime+b*this.playbackRate})},addEventListener:function(a,b){var c=b;"function"==typeof b&&(c=function(a){a.target=this,b.call(this,a)}.bind(this),b._wrapper=c),this._player.addEventListener(a,c)},removeEventListener:function(a,b){this._player.removeEventListener(a,b&&b._wrapper||b)},_removePlayers:function(){for(;this._childPlayers.length;)this._childPlayers.pop().cancel()},_forEachChild:function(a){var b=0;this._childPlayers.forEach(function(c){a.call(this,c,b),this.source instanceof window.AnimationSequence&&(b+=c.source.activeDuration)}.bind(this))}}}(c,e,f),function(a,b){function c(a){return a._timing.delay+a.activeDuration+a._timing.endDelay}function d(b){this._frames=a.normalizeKeyframes(b)}function e(){for(var a=!1;h.length;)h.shift()._updateChildren(),a=!0;return a}d.prototype={getFrames:function(){return this._frames}},b.Animation=function(b,c,e){return this.target=b,this._timingInput=e,this._timing=a.normalizeTimingInput(e),this.timing=a.makeTiming(e),this.effect="function"==typeof c?c:new d(c),this._effect=c,this.activeDuration=a.calculateActiveDuration(this._timing),this};var f=Element.prototype.animate;Element.prototype.animate=function(a,c){return b.timeline.play(new b.Animation(this,a,c))};var g=document.createElementNS("http://www.w3.org/1999/xhtml","div");b.newUnderlyingPlayerForAnimation=function(a){var b=a.target||g,c=a._effect;return"function"==typeof c&&(c=[]),f.apply(b,[c,a._timingInput])},b.bindPlayerForAnimation=function(a){a.source&&"function"==typeof a.source.effect&&b.bindPlayerForCustomEffect(a)};var h=[];b.awaitStartTime=function(a){null===a.startTime&&a._isGroup&&(0==h.length&&requestAnimationFrame(e),h.push(a))};var i=window.getComputedStyle;Object.defineProperty(window,"getComputedStyle",{configurable:!0,enumerable:!0,value:function(){var a=i.apply(this,arguments);return e()&&(a=i.apply(this,arguments)),a}}),b.Player.prototype._updateChildren=function(){if(this.source&&this._isGroup&&"idle"!=this.playState)for(var a=this.source._timing.delay,b=0;b<this.source.children.length;b++){var d,e=this.source.children[b];b>=this._childPlayers.length?(d=window.document.timeline.play(e),this._childPlayers.push(d),d.playbackRate=this.playbackRate,this.paused&&d.pause()):d=this._childPlayers[b],e.player=this.source.player,d.startTime!=this.startTime+a&&(null===this.startTime?(d.currentTime=this.source.player.currentTime-a,d._startTime=null):d.startTime=this.startTime+a,d._updateChildren()),-1==this.playbackRate&&this.currentTime<a&&-1!==d.currentTime&&(d.currentTime=-1),this.source instanceof window.AnimationSequence&&(a+=c(e))}},window.Animation=b.Animation,window.Element.prototype.getAnimationPlayers=function(){return document.timeline.getAnimationPlayers().filter(function(a){return null!==a.source&&a.source.target==this}.bind(this))},b.groupChildDuration=c}(c,e,f),function(a,b){function c(a){a._registered||(a._registered=!0,f.push(a),g||(g=!0,requestAnimationFrame(d)))}function d(){var a=f;f=[],a.sort(function(a,b){return a._sequenceNumber-b._sequenceNumber}),a=a.filter(funct
ajaxify:true,isReady:false,coreElements:{},paperElements:{},created:function(){this.coreElementsList=[];this.paperElementsList=[]},domReady:function(){this.isReady=true;this.highlightItemWithCurrentURL()},coreElementsChanged:function(){for(var name in this.coreElements){this.coreElementsList.push({name:name,url:this.coreElements[name]})}},paperElementsChanged:function(){for(var name in this.paperElements){this.paperElementsList.push({name:name,url:this.paperElements[name]})}},highlightItemWithCurrentURL:function(opt_href){var href=opt_href||location.pathname+location.hash;if(href.match(/core-elements.html$/)){this.$.mainmenu.selected=this.$.mainmenu.items.indexOf(this.$.coreelements);return}else if(href.match(/paper-elements.html$/)){this.$.mainmenu.selected=this.$.mainmenu.items.indexOf(this.$.paperelements);return}var item=this.shadowRoot.querySelector('[href$="'+href+'"]');if(!item){item=this.shadowRoot.querySelector('[data-href$="'+href+'"]')}if(item){var submenu=item.parentElement;if(submenu==this.$.mainmenu){return}if(submenu.parentElement&&submenu.parentElement.localName=="core-submenu"){do{submenu.parentElement.selected=submenu.parentElement.items.indexOf(submenu);submenu=submenu.parentElement}while(submenu&&submenu.localName=="core-submenu")}else{this.$.mainmenu.selected=this.$.mainmenu.items.indexOf(submenu)}}}});Polymer("core-media-query",{queryMatches:false,query:"",ready:function(){this._mqHandler=this.queryHandler.bind(this);this._mq=null},queryChanged:function(){if(this._mq){this._mq.removeListener(this._mqHandler)}var query=this.query;if(query[0]!=="("){query="("+this.query+")"}this._mq=window.matchMedia(query);this._mq.addListener(this._mqHandler);this.queryHandler(this._mq)},queryHandler:function(mq){this.queryMatches=mq.matches;this.asyncFire("core-media-change",mq)}});(function(){function onScroll_(){this.previousScrollY=this.latestKnownScrollY;this.latestKnownScrollY=window.scrollY||window.pageYOffset;requestTick_.bind(this)()}function requestTick_(){if(!this.ticking){window.requestAnimationFrame(update_.bind(this))}this.ticking=true}function update_(){this.ticking=false;var currentScrollY=this.latestKnownScrollY;this.smallBannerSizeReached=this.siteBannerHeight-currentScrollY<this.appBarHeight}Polymer("scroll-area",{latestKnownScrollY:0,previousScrollY:0,smallBannerSizeReached:false,ticking:false,fancyheader:true,publish:{sidebar:{value:false,reflect:true}},attached:function(){this.init()},init:function(){var siteBanner=this.querySelector("site-banner");this.appBar=siteBanner.querySelector("app-bar");this.header=siteBanner.querySelector("header");this.async(function(){this.siteBannerHeight=siteBanner.offsetHeight;this.appBarHeight=this.appBar.offsetHeight});this.onscroll=onScroll_.bind(this);this.fancyheaderChanged();if((window.scrollY||window.pageYOffset)&&this.fancyheader){this.onscroll()}},fancyheaderChanged:function(){if(this.fancyheader){window.addEventListener("scroll",this.onscroll,false)}else{window.removeEventListener("scroll",this.onscroll,false);this.classList.remove("scrolling");this.header&&this.header.classList.remove("shrink")}}})})();(function(){Polymer("site-banner",{shortname:"",isPhone:false,isPhoneChanged:function(){this.parentElement.classList.toggle("mobile",this.isPhone)}})})();(function(){var waveMaxRadius=150;function waveRadiusFn(touchDownMs,touchUpMs,anim){var touchDown=touchDownMs/1e3;var touchUp=touchUpMs/1e3;var totalElapsed=touchDown+touchUp;var ww=anim.width,hh=anim.height;var waveRadius=Math.min(Math.sqrt(ww*ww+hh*hh),waveMaxRadius)*1.1+5;var duration=1.1-.2*(waveRadius/waveMaxRadius);var tt=totalElapsed/duration;var size=waveRadius*(1-Math.pow(80,-tt));return Math.abs(size)}function waveOpacityFn(td,tu,anim){var touchDown=td/1e3;var touchUp=tu/1e3;var totalElapsed=touchDown+touchUp;if(tu<=0){return anim.initialOpacity}return Math.max(0,anim.initialOpacity-touchUp*anim.opacityDecayVelocity)}function waveOuterOpacityFn(td,tu,anim){var touchDown=td/1e3;var touchUp=tu/1e3;var outerOpacity=touchDown*.3;var waveOpacity=waveOpacityFn(td,tu,anim);return Math.max(0,Math.min
duration:itemDuration,fill:"both"}))}.bind(this));anims.push(new Animation(node.$.scroller,[{opacity:1},{opacity:1}],{delay:duration*itemDelay,duration:itemDuration*items.length,fill:"both"}))}else{anims.push(new Animation(node.$.scroller,[{opacity:0},{opacity:1}],{delay:duration*(offset+(1-offset)/2),duration:duration*.5,fill:"both"}))}var group=new AnimationGroup(anims,{easing:"cubic-bezier(0.4, 0, 0.2, 1)"});this.player=document.timeline.play(group);this.player.onfinish=function(){this.fire("core-transitionend",this,node)}.bind(this)}else{this.fire("core-transitionend",this,node)}}});Polymer("paper-dropdown",{publish:{transition:"paper-dropdown-transition"},ready:function(){this.super();this.sizingTarget=this.$.scroller}});Polymer("paper-item",{publish:{raised:false,recenteringTouch:false,fill:true}});var $rows;Polymer("app-bar",{theme:"dark",home:false,showingSearch:false,badge:"",toggleSearch:function(e,detail,sender){$rows=$("table tr");if(e){e.stopPropagation()}if(e.target===this.$.input){return}this.showingSearch=true;this.classList.add("search-on");this.async(function(){this.$.input.focus()})},disableSearch:function(e,detail,sender){if(sender.value==""){this.classList.remove("search-on");this.showingSearch=false}},onKeyPress:function(e,detail,sender){$rows=$("table tr");var val="^(?=.*\\b"+$.trim(sender.value).split(/\s+/).join("\\b)(?=.*\\b")+").*$",reg=RegExp(val,"i"),text;$rows.show().filter(function(){text=$(this).text().replace(/\s+/g," ");return!reg.test(text)}).hide();if(e.keyCode==13){if(sender.value){recordSearch(sender.value);var q="site:unidata.github.io/awips2+"+sender.value;window.open("https://www.google.com/search?q="+q)}}},onMenuClick:function(){this.fire("hamburger-time")}});Polymer("app-drawer",{publish:{mobile:{value:false,reflect:true}},active:false,controller:null,toggle:function(){this.controller.toggle()},close:function(){this.controller.close()},attached:function(){var content=this.$.content;var mask=this.$.mask;this.controller=new DrawerController({target:this,left:0,right:315,position:0,curve:"ease-in-out",willOpen:function(){mask.style.display="block";content.style.display="block";this.active=true;document.body.classList.add("noscroll")},didClose:function(){mask.style.display="none";content.style.display="none";this.active=false;document.body.classList.remove("noscroll")},onAnimate:function(position){mask.style.opacity=(position+1)/315*.2;content.style.WebkitTransform="translate3d("+(position-315)+"px,0,0)"}})},mobileChanged:function(){if(this.controller&&!this.mobile){this.$.mask.removeAttribute("style");this.$.content.removeAttribute("style");this.controller.state=this.controller.kClosed;this.controller.position=0;this.controller.left=0;this.controller.right=315;this.active=false;document.body.classList.remove("noscroll")}}});Polymer("paper-button",{publish:{raised:false,recenteringTouch:false,fill:true},_activate:function(){this.click();this.fire("tap");if(!this.pressed){var bcr=this.getBoundingClientRect();var x=bcr.left+bcr.width/2;var y=bcr.top+bcr.height/2;this.downAction({x:x,y:y});var fn=function fn(){this.upAction();this.removeEventListener("keyup",fn)}.bind(this);this.addEventListener("keyup",fn)}}});var p={overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction"},activateAction:function(){this.opened=false}};Polymer.mixin2(p,Polymer.CoreFocusable);Polymer("core-menu-button",p);