<commit_before>/* Modernizr 2.6.1 (Custom Build) | MIT & BSD
 * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-flexbox_legacy-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
 */
;window.Modernizr=function(a,b,c){function C(a){j.cssText=a}function D(a,b){return C(n.join(a+";")+(b||""))}function E(a,b){return typeof a===b}function F(a,b){return!!~(""+a).indexOf(b)}function G(a,b){for(var d in a){var e=a[d];if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function H(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}return!1}function I(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.1",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["",'<style id="s',h,'">',a,"</style>"].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return I("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!E(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!I("indexedDB",a)},s.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},s.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},s.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return I("backgroundSize")},s.borderimage=function(){return I("borderImage")},s.borderradius=function(){return I("borderRadius")},s.boxshadow=function(){return I("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return I("animationName")},s.csscolumns=function(){return I("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},s.cssreflections=function(){return I("boxReflect")},s.csstransforms=function(){return!!I("transform")},s.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return I("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(['#modernizr:after{content:"',l,'";visibility:hidden}'].join(""),function(b){a=b.offsetHeight>=1}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=y,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};<commit_msg>Remove midernizr since it is a foundation dependency. Contributes to #37<commit_after><|endoftext|>


<commit_before>import {FefDebounceHelper} from '../classes/fef-debounce-helper';

export function init() {
    $('.js-masthead').each((i, elem) => {
        new FeFStickyHeader(elem);
    });
}

const MASTHEAD_PADDING_BOTTOM = 24;
const DEBOUNCE_TIME = 20;

export class FeFStickyHeader {

    constructor(element, options) {
        this.$masthead = $(element);
        this.$mastheadNav = $('.masthead__nav');
        this.$stickyContainer = this.$masthead.closest('.sticky-container');
        this.$affixPlacehoder = $('.affix-placeholder');
        this.affixMarginTop = this.$masthead.outerHeight() - this.$mastheadNav.outerHeight();
        this.affixPlacehoderHeight = this.$masthead.outerHeight() + MASTHEAD_PADDING_BOTTOM;
        this.lastScrollTop = 0;
        this.hasResized = false;
        this.isFullHeaderAffixMode = this.$stickyContainer.attr('data-full-header-affix') !== undefined;

        this.initializeAffix();
        if (this.isFullHeaderAffixMode) {
            this.registerListeners();
        }
    }

    registerListeners() {
        $(window).on('scroll', FefDebounceHelper.debounce(() => this.afterScrolling(), DEBOUNCE_TIME) );
        $(window).on('resize', FefDebounceHelper.debounce(() => this.afterResize(), DEBOUNCE_TIME) );
    }

    afterScrolling() {
        let scrollTop = $(window).scrollTop();
        let that = this;
        let scrollDifference = Math.abs(this.lastScrollTop - scrollTop);

        /*
         * Sticky Header must stay as it is after resizing
         * Sticky Header may not change state after a minimal scrolling (5 pixel)
         * Sticky Header may not change state if scrollTop has a negative value (safari)
         */
        if (!this.hasResized && scrollDifference > 5 || scrollTop < 0) {
            // scroll up > show full header
            if (scrollTop <= this.lastScrollTop) {
                this.$stickyContainer.css('margin-top', '0');
                this.$stickyContainer.addClass('sticky-container--full');
                this.$masthead[0].className = this.$masthead[0].className.replace(/\-\-off\-theme\-/g, '--theme-');
            }
            // scroll down > show small header
            else {
                $('.affix').css('margin-top', '-' + this.affixMarginTop + 'px');
                this.$stickyContainer.removeClass('sticky-container--full');
                if(scrollTop >= this.affixMarginTop) {
                    this.$masthead.addClass('masthead--in-transition');
                    setTimeout(
                        function() {
                            that.$masthead.removeClass('masthead--in-transition');
                            that.$masthead[0].className = that.$masthead[0].className.replace(/\-\-theme\-/g, '--off-theme-');
                        },
                        225
                    );
                }
            }
        }

        this.hasResized = false;
        this.lastScrollTop = scrollTop;

    }

    afterResize() {
        this.hasResized = true;
        this.affixMarginTop = this.$masthead.outerHeight() - this.$mastheadNav.outerHeight();
        this.affixPlacehoderHeight = this.$masthead.outerHeight() + MASTHEAD_PADDING_BOTTOM;
        this.initializeAffix();

        if (this.$stickyContainer.hasClass('sticky-container--full')) {
            $('.affix').css('margin-top', '0');
        } else {
            $('.affix').css('margin-top', '-' + this.affixMarginTop + 'px');
        }

    }

    initializeAffix() {
        $('[data-smart-affix]').affix({offset:{top: this.affixMarginTop}});
        this.$affixPlacehoder.css('height', this.affixPlacehoderHeight + 'px');
    }

}
<commit_msg>new calculation of affix-margin-top<commit_after>import {FefDebounceHelper} from '../classes/fef-debounce-helper';

export function init() {
    $('.js-masthead').each((i, elem) => {
        new FeFStickyHeader(elem);
    });
}

const MASTHEAD_PADDING_BOTTOM = 24;
const DEBOUNCE_TIME = 20;

export class FeFStickyHeader {

    constructor(element, options) {
        this.$masthead = $(element);
        this.$mastheadNav = $('.masthead__nav');
        this.$subNavMask = this.$mastheadNav.find('.subnav__mask');
        this.$stickyContainer = this.$masthead.closest('.sticky-container');
        this.$affixPlacehoder = $('.affix-placeholder');
        this.affixMarginTop = this.$mastheadNav.outerHeight() !== undefined ? this.$masthead.outerHeight() - this.$mastheadNav.outerHeight() : this.$masthead.outerHeight();
        this.affixPlacehoderHeight = this.$masthead.outerHeight() + MASTHEAD_PADDING_BOTTOM;
        this.lastScrollTop = 0;
        this.hasResized = false;
        this.isFullHeaderAffixMode = this.$stickyContainer.attr('data-full-header-affix') !== undefined;
        this.scrollDirection = '';

        this.initializeAffix();
        if (this.isFullHeaderAffixMode) {
            this.registerListeners();
        }
    }

    registerListeners() {
        $(window).on('scroll', FefDebounceHelper.debounce(() => this.afterScrolling(), DEBOUNCE_TIME) );
        $(window).on('resize', FefDebounceHelper.debounce(() => this.afterResize(), DEBOUNCE_TIME) );
    }

    afterScrolling() {
        let scrollTop = $(window).scrollTop();
        let that = this;
        let scrollDifference = Math.abs(this.lastScrollTop - scrollTop);

        console.log('afterScrolling');

        /*
         * Sticky Header must stay as it is after resizing
         * Sticky Header may not change state after a minimal scrolling (5 pixel)
         * Sticky Header may not change state if scrollTop has a negative value (safari)
         */
        if (!this.hasResized && scrollDifference > 5 || scrollTop < 0) {
            // scroll up > show full header
            if (scrollTop <= this.lastScrollTop) {

                console.log('scroll up');

                this.$stickyContainer.css('margin-top', '0');
                this.$stickyContainer.addClass('sticky-container--full');
                this.$masthead[0].className = this.$masthead[0].className.replace(/\-\-off\-theme\-/g, '--theme-');

                if(this.scrollDirection === 'down') {
                   this.$subNavMask.hide();
                   setTimeout(
                       function() {
                           that.$subNavMask.show();
                       },
                       300
                   );
                }

                this.scrollDirection = 'up';
            }
            // scroll down > show small header
            else {
                $('.affix').css('margin-top', '-' + this.affixMarginTop + 'px');
                this.$stickyContainer.removeClass('sticky-container--full');

                if(scrollTop >= this.affixMarginTop && this.scrollDirection === 'up') {

                    console.log('scroll down');

                    this.$masthead.addClass('masthead--in-transition');
                    setTimeout(
                        function() {
                            that.$masthead.removeClass('masthead--in-transition');
                            that.$masthead[0].className = that.$masthead[0].className.replace(/\-\-theme\-/g, '--off-theme-');
                        },
                        225
                    );
                    this.$subNavMask.hide();
                    setTimeout(
                        function() {
                            that.$subNavMask.show();
                        },
                        300
                    );
                }

                this.scrollDirection = 'down';

            }
        }

        this.hasResized = false;
        this.lastScrollTop = scrollTop;

    }

    afterResize() {
        this.hasResized = true;
        this.affixMarginTop = this.$masthead.outerHeight() - this.$mastheadNav.outerHeight();
        this.affixPlacehoderHeight = this.$masthead.outerHeight() + MASTHEAD_PADDING_BOTTOM;
        this.initializeAffix();

        if (this.$stickyContainer.hasClass('sticky-container--full')) {
            $('.affix').css('margin-top', '0');
        } else {
            $('.affix').css('margin-top', '-' + this.affixMarginTop + 'px');
        }

    }

    initializeAffix() {
        $('[data-smart-affix]').affix({offset:{top: this.affixMarginTop}});
        this.$affixPlacehoder.css('height', this.affixPlacehoderHeight + 'px');
    }

}
<|endoftext|>


<commit_before>function strip_tags(str, allowed_tags) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strip_tags('
Kevin

van Zonneveld', ',');
    // *     returns 1: 'Kevin van Zonneveld'

    var key = '', tag = '';
    var matches = allowed_array = [];
    var allowed_keys = {};

    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_tags  = allowed_tags.replace(/[\<\> ]+/g, '');;
        allowed_array = allowed_tags.split(',');

        for (key in allowed_array) {
            tag = allowed_array[key];
            allowed_keys['<' + tag + '>']   = true;
            allowed_keys['<' + tag + ' />'] = true;
            allowed_keys['</' + tag + '>']  = true;
        }
    }

    // Match tags
    matches = str.match(/(<\/?[^>]+>)/gi);

    // Is tag not in allowed list? Remove from str!
    for (key in matches) {
        tag = matches[key];
        document.write('<xmp>'+tag+'</xmp>');

        if (!allowed_keys[tag]) {
            document.write('not allowed');
            str = str.replace(tag, "");
        } else {
            document.write('allowed');
        }
    }

    return str;
}<commit_msg>Minor improvements to functions<commit_after>function strip_tags(str, allowed_tags) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strip_tags('
Kevin

van Zonneveld', ',');
    // *     returns 1: 'Kevin van Zonneveld'

    var key = '', tag = '';
    var matches = allowed_array = [];
    var allowed_keys = {};

    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_tags  = allowed_tags.replace(/[\<\> ]+/g, '');;
        allowed_array = allowed_tags.split(',');

        for (key in allowed_array) {
            tag = allowed_array[key];
            allowed_keys['<' + tag + '>']   = true;
            allowed_keys['<' + tag + ' />'] = true;
            allowed_keys['</' + tag + '>']  = true;
        }
    }

    // Match tags
    matches = str.match(/(<\/?[^>]+>)/gi);

    // Is tag not in allowed list? Remove from str!
    for (key in matches) {
        tag = matches[key];
        if (!allowed_keys[tag]) {
            str = str.replace(tag, "");
        }
    }

    return str;
}<|endoftext|>


<commit_before>
if (require.register) {
  var qs = require('querystring');
} else {
  var qs = require('../')
    , expect = require('expect.js');
}

describe('qs.parse()', function(){
  it('should support the basics', function(){
    expect(qs.parse('0=foo')).to.eql({ '0': 'foo' });

    expect(qs.parse('foo=c++'))
      .to.eql({ foo: 'c  ' });

    expect(qs.parse('a[>=]=23'))
      .to.eql({ a: { '>=': '23' }});

    expect(qs.parse('a[<=>]==23'))
      .to.eql({ a: { '<=>': '=23' }});

    expect(qs.parse('a[==]=23'))
      .to.eql({ a: { '==': '23' }});

    expect(qs.parse('foo'))
      .to.eql({ foo: '' });

    expect(qs.parse('foo=bar'))
      .to.eql({ foo: 'bar' });

    expect(qs.parse(' foo = bar = baz '))
      .to.eql({ ' foo ': ' bar = baz ' });

    expect(qs.parse('foo=bar=baz'))
      .to.eql({ foo: 'bar=baz' });

    expect(qs.parse('foo=bar&bar=baz'))
      .to.eql({ foo: 'bar', bar: 'baz' });

    expect(qs.parse('foo=bar&baz'))
      .to.eql({ foo: 'bar', baz: '' });

    expect(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'))
      .to.eql({
          cht: 'p3'
        , chd: 't:60,40'
        , chs: '250x100'
        , chl: 'Hello|World'
      });
  })

  it('should support encoded = signs', function(){
    expect(qs.parse('he%3Dllo=th%3Dere'))
      .to.eql({ 'he=llo': 'th=ere' });
  })

  it('should support nesting', function(){
    expect(qs.parse('ops[>=]=25'))
      .to.eql({ ops: { '>=': '25' }});

    expect(qs.parse('user[name]=tj'))
      .to.eql({ user: { name: 'tj' }});

    expect(qs.parse('user[name][first]=tj&user[name][last]=holowaychuk'))
      .to.eql({ user: { name: { first: 'tj', last: 'holowaychuk' }}});
  })

  it('should support array notation', function(){
    expect(qs.parse('images[]'))
      .to.eql({ images: [] });

    expect(qs.parse('user[]=tj'))
      .to.eql({ user: ['tj'] });

    expect(qs.parse('user[]=tj&user[]=tobi&user[]=jane'))
      .to.eql({ user: ['tj', 'tobi', 'jane'] });

    expect(qs.parse('user[names][]=tj&user[names][]=tyler'))
      .to.eql({ user: { names: ['tj', 'tyler'] }});

    expect(qs.parse('user[names][]=tj&user[names][]=tyler&user[email]=tj@vision-media.ca'))
      .to.eql({ user: { names: ['tj', 'tyler'], email: 'tj@vision-media.ca' }});

    expect(qs.parse('items=a&items=b'))
      .to.eql({ items: ['a', 'b'] });

    expect(qs.parse('user[names]=tj&user[names]=holowaychuk&user[names]=TJ'))
      .to.eql({ user: { names: ['tj', 'holowaychuk', 'TJ'] }});

    expect(qs.parse('user[name][first]=tj&user[name][first]=TJ'))
      .to.eql({ user: { name: { first: ['tj', 'TJ'] }}});

    var o = qs.parse('existing[fcbaebfecc][name][last]=tj')
    expect(o).to.eql({ existing: { 'fcbaebfecc': { name: { last: 'tj' }}}})
    expect(Array.isArray(o.existing)).to.equal(false);
  })

  it('should support arrays with indexes', function(){
    expect(qs.parse('foo[0]=bar&foo[1]=baz')).to.eql({ foo: ['bar', 'baz'] });
    expect(qs.parse('foo[1]=bar&foo[0]=baz')).to.eql({ foo: ['baz', 'bar'] });
    expect(qs.parse('foo[base64]=RAWR')).to.eql({ foo: { base64: 'RAWR' }});
    expect(qs.parse('foo[64base]=RAWR')).to.eql({ foo: { '64base': 'RAWR' }});
  })

  it('should expand to an array when dupliate keys are present', function(){
    expect(qs.parse('items=bar&items=baz&items=raz'))
      .to.eql({ items: ['bar', 'baz', 'raz'] });
  })

  it('should support right-hand side brackets', function(){
    expect(qs.parse('pets=["tobi"]'))
      .to.eql({ pets: '["tobi"]' });

    expect(qs.parse('operators=[">=", "<="]'))
      .to.eql({ operators: '[">=", "<="]' });

    expect(qs.parse('op[>=]=[1,2,3]'))
      .to.eql({ op: { '>=': '[1,2,3]' }});

    expect(qs.parse('op[>=]=[1,2,3]&op[=]=[[[[1]]]]'))
          .to.eql({ op: { '>=': '[1,2,3]', '=': '[[[[1]]]]' }});
  })

  it('should support empty values', function(){
    expect(qs.parse('')).to.eql({});
    expect(qs.parse(undefined)).to.eql({});
    expect(qs.parse(null)).to.eql({});
  })

  it('should transform arrays to objects', function(){
    expect(qs.parse('foo[0]=bar&foo[bad]=baz')).to.eql({ foo: { 0: "bar", bad: "baz" }});
    expect(qs.parse('foo[bad]=baz&foo[0]=bar')).to.eql({ foo: { 0: "bar", bad: "baz" }});
  })

  it('should support malformed uri chars', function(){
    expect(qs.parse('{%:%}')).to.eql({ '{%:%}': '' });
    expect(qs.parse('foo=%:%}')).to.eql({ 'foo': '%:%}' });
  })

  it('should support semi-parsed strings', function(){
    expect(qs.parse({ 'user[name]': 'tobi' }))
      .to.eql({ user: { name: 'tobi' }});

    expect(qs.parse({ 'user[name]': 'tobi', 'user[email][main]': 'tobi@lb.com' }))
      .to.eql({ user: { name: 'tobi', email: { main: 'tobi@lb.com' } }});
  })

  it('should not produce empty keys', function(){
    expect(qs.parse('_r=1&'))
      .to.eql({ _r: '1' })
  })

  it('should not be possible to access Object prototype', function() {
    qs.parse('constructor[prototype][bad]=bad');
    qs.parse('bad[constructor][prototype][bad]=bad');
    expect(Object.prototype.bad).to.be(undefined);
  });
})
<commit_msg>make previous test conditional<commit_after>
if (require.register) {
  var qs = require('querystring');
} else {
  var qs = require('../')
    , expect = require('expect.js');
}

describe('qs.parse()', function(){
  it('should support the basics', function(){
    expect(qs.parse('0=foo')).to.eql({ '0': 'foo' });

    expect(qs.parse('foo=c++'))
      .to.eql({ foo: 'c  ' });

    expect(qs.parse('a[>=]=23'))
      .to.eql({ a: { '>=': '23' }});

    expect(qs.parse('a[<=>]==23'))
      .to.eql({ a: { '<=>': '=23' }});

    expect(qs.parse('a[==]=23'))
      .to.eql({ a: { '==': '23' }});

    expect(qs.parse('foo'))
      .to.eql({ foo: '' });

    expect(qs.parse('foo=bar'))
      .to.eql({ foo: 'bar' });

    expect(qs.parse(' foo = bar = baz '))
      .to.eql({ ' foo ': ' bar = baz ' });

    expect(qs.parse('foo=bar=baz'))
      .to.eql({ foo: 'bar=baz' });

    expect(qs.parse('foo=bar&bar=baz'))
      .to.eql({ foo: 'bar', bar: 'baz' });

    expect(qs.parse('foo=bar&baz'))
      .to.eql({ foo: 'bar', baz: '' });

    expect(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'))
      .to.eql({
          cht: 'p3'
        , chd: 't:60,40'
        , chs: '250x100'
        , chl: 'Hello|World'
      });
  })

  it('should support encoded = signs', function(){
    expect(qs.parse('he%3Dllo=th%3Dere'))
      .to.eql({ 'he=llo': 'th=ere' });
  })

  it('should support nesting', function(){
    expect(qs.parse('ops[>=]=25'))
      .to.eql({ ops: { '>=': '25' }});

    expect(qs.parse('user[name]=tj'))
      .to.eql({ user: { name: 'tj' }});

    expect(qs.parse('user[name][first]=tj&user[name][last]=holowaychuk'))
      .to.eql({ user: { name: { first: 'tj', last: 'holowaychuk' }}});
  })

  it('should support array notation', function(){
    expect(qs.parse('images[]'))
      .to.eql({ images: [] });

    expect(qs.parse('user[]=tj'))
      .to.eql({ user: ['tj'] });

    expect(qs.parse('user[]=tj&user[]=tobi&user[]=jane'))
      .to.eql({ user: ['tj', 'tobi', 'jane'] });

    expect(qs.parse('user[names][]=tj&user[names][]=tyler'))
      .to.eql({ user: { names: ['tj', 'tyler'] }});

    expect(qs.parse('user[names][]=tj&user[names][]=tyler&user[email]=tj@vision-media.ca'))
      .to.eql({ user: { names: ['tj', 'tyler'], email: 'tj@vision-media.ca' }});

    expect(qs.parse('items=a&items=b'))
      .to.eql({ items: ['a', 'b'] });

    expect(qs.parse('user[names]=tj&user[names]=holowaychuk&user[names]=TJ'))
      .to.eql({ user: { names: ['tj', 'holowaychuk', 'TJ'] }});

    expect(qs.parse('user[name][first]=tj&user[name][first]=TJ'))
      .to.eql({ user: { name: { first: ['tj', 'TJ'] }}});

    var o = qs.parse('existing[fcbaebfecc][name][last]=tj')
    expect(o).to.eql({ existing: { 'fcbaebfecc': { name: { last: 'tj' }}}})
    expect(Array.isArray(o.existing)).to.equal(false);
  })

  it('should support arrays with indexes', function(){
    expect(qs.parse('foo[0]=bar&foo[1]=baz')).to.eql({ foo: ['bar', 'baz'] });
    expect(qs.parse('foo[1]=bar&foo[0]=baz')).to.eql({ foo: ['baz', 'bar'] });
    expect(qs.parse('foo[base64]=RAWR')).to.eql({ foo: { base64: 'RAWR' }});
    expect(qs.parse('foo[64base]=RAWR')).to.eql({ foo: { '64base': 'RAWR' }});
  })

  it('should expand to an array when dupliate keys are present', function(){
    expect(qs.parse('items=bar&items=baz&items=raz'))
      .to.eql({ items: ['bar', 'baz', 'raz'] });
  })

  it('should support right-hand side brackets', function(){
    expect(qs.parse('pets=["tobi"]'))
      .to.eql({ pets: '["tobi"]' });

    expect(qs.parse('operators=[">=", "<="]'))
      .to.eql({ operators: '[">=", "<="]' });

    expect(qs.parse('op[>=]=[1,2,3]'))
      .to.eql({ op: { '>=': '[1,2,3]' }});

    expect(qs.parse('op[>=]=[1,2,3]&op[=]=[[[[1]]]]'))
          .to.eql({ op: { '>=': '[1,2,3]', '=': '[[[[1]]]]' }});
  })

  it('should support empty values', function(){
    expect(qs.parse('')).to.eql({});
    expect(qs.parse(undefined)).to.eql({});
    expect(qs.parse(null)).to.eql({});
  })

  it('should transform arrays to objects', function(){
    expect(qs.parse('foo[0]=bar&foo[bad]=baz')).to.eql({ foo: { 0: "bar", bad: "baz" }});
    expect(qs.parse('foo[bad]=baz&foo[0]=bar')).to.eql({ foo: { 0: "bar", bad: "baz" }});
  })

  it('should support malformed uri chars', function(){
    expect(qs.parse('{%:%}')).to.eql({ '{%:%}': '' });
    expect(qs.parse('foo=%:%}')).to.eql({ 'foo': '%:%}' });
  })

  it('should support semi-parsed strings', function(){
    expect(qs.parse({ 'user[name]': 'tobi' }))
      .to.eql({ user: { name: 'tobi' }});

    expect(qs.parse({ 'user[name]': 'tobi', 'user[email][main]': 'tobi@lb.com' }))
      .to.eql({ user: { name: 'tobi', email: { main: 'tobi@lb.com' } }});
  })

  it('should not produce empty keys', function(){
    expect(qs.parse('_r=1&'))
      .to.eql({ _r: '1' })
  })

  if ('undefined' == typeof window) {
    it('should not be possible to access Object prototype', function() {
      qs.parse('constructor[prototype][bad]=bad');
      qs.parse('bad[constructor][prototype][bad]=bad');
      expect(Object.prototype.bad).to.be(undefined);
    });
  }
})
<|endoftext|>


<commit_before>import React from 'react'
import { Global } from '@emotion/core'
import { GlobalStyles } from '../styles/globalStyles.js'
import { motion, AnimatePresence } from 'framer-motion'

import Helmet from './Helmet'
import Menu from '../components/Menu'
import Footer from '../components/Footer'

if (typeof window !== 'undefined') {
  // eslint-disable-next-line global-require
  require('smooth-scroll')('a[href*="#"]')
}

const duration = 0.5

const variants = {
  initial: {
    opacity: 0,
  },
  enter: {
    opacity: 1,
    transition: {
      duration: duration,
      delay: duration,
      when: 'beforeChildren',
    },
  },
  exit: {
    opacity: 0,
    transition: { duration: duration },
  },
}

const Layout = ({ children, location }) => {
  return (
    <>
      <Helmet />
      <Global styles={GlobalStyles} />

        <Menu />
        <AnimatePresence>
          <motion.main
            key={location.pathname}
            variants={variants}
            initial="initial"
            animate="enter"
            exit="exit"
          >
            {children}
          </motion.main>
        </AnimatePresence>

    </>
  )
}

export default Layout
<commit_msg>update footer placement<commit_after>import React from 'react'
import { Global } from '@emotion/core'
import { GlobalStyles } from '../styles/globalStyles.js'
import { motion, AnimatePresence } from 'framer-motion'

import Helmet from './Helmet'
import Menu from '../components/Menu'
import Footer from '../components/Footer'

if (typeof window !== 'undefined') {
  // eslint-disable-next-line global-require
  require('smooth-scroll')('a[href*="#"]')
}

const duration = 0.5

const variants = {
  initial: {
    opacity: 0,
  },
  enter: {
    opacity: 1,
    transition: {
      duration: duration,
      delay: duration,
      when: 'beforeChildren',
    },
  },
  exit: {
    opacity: 0,
    transition: { duration: duration },
  },
}

const Layout = ({ children, location }) => {
  return (
    <>
      <Helmet />
      <Global styles={GlobalStyles} />

        <Menu />
        <AnimatePresence>
          <motion.main
            key={location.pathname}
            variants={variants}
            initial="initial"
            animate="enter"
            exit="exit"
          >
            {children}

          </motion.main>
        </AnimatePresence>

    </>
  )
}

export default Layout
<|endoftext|>


<commit_before>import React from 'react';
import InfoBox from '../components/InfoOnOpportunity';
import jobPropTypes from '../propTypes/job';

class DetailView extends React.Component {
  constructor(props) {
    super(props);
    this.id = parseInt(props.match.params.id, 10);
    this.job = props.jobs.find(j => j.id === this.id);
  }

  componentDidMount(){
      window.scrollTo(0, 0);
  }

  render() {
    return this.job ? (
      <InfoBox {...this.job} />
    ) : (

Denne karrieremuligheten eksisterer ikke.

    );
  }
}

DetailView.propTypes = {
  jobs: React.PropTypes.arrayOf(React.PropTypes.shape(jobPropTypes)),
  match: React.PropTypes.shape({
    isExact: React.PropTypes.bool,
    params: React.PropTypes.object.isRequired,
    path: React.PropTypes.string.isRequired,
    url: React.PropTypes.string.isRequired,
  }),
};

export default DetailView;
<commit_msg>fix linting... again<commit_after>import React from 'react';
import InfoBox from '../components/InfoOnOpportunity';
import jobPropTypes from '../propTypes/job';

class DetailView extends React.Component {
  constructor(props) {
    super(props);
    this.id = parseInt(props.match.params.id, 10);
    this.job = props.jobs.find(j => j.id === this.id);
  }

  componentDidMount() {
    window.scrollTo(0, 0);
  }

  render() {
    return this.job ? (
      <InfoBox {...this.job} />
    ) : (

Denne karrieremuligheten eksisterer ikke.

    );
  }
}

DetailView.propTypes = {
  jobs: React.PropTypes.arrayOf(React.PropTypes.shape(jobPropTypes)),
  match: React.PropTypes.shape({
    isExact: React.PropTypes.bool,
    params: React.PropTypes.object.isRequired,
    path: React.PropTypes.string.isRequired,
    url: React.PropTypes.string.isRequired,
  }),
};

export default DetailView;
<|endoftext|>


<commit_before>/**
 * Copyright (c) Nicolas Gallagher.
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import { useEffect, useCallback, useState, useRef } from 'react';
import StyleSheet from '../StyleSheet';
import createElement from '../createElement';

const ANIMATION_DURATION = 300;

function getAnimationStyle(animationType, visible) {
  if (animationType === 'slide') {
    return visible ? animatedSlideInStyles : animatedSlideOutStyles;
  }
  if (animationType === 'fade') {
    return visible ? animatedFadeInStyles : animatedFadeOutStyles;
  }
  return visible ? styles.container : styles.hidden;
}

export type ModalAnimationProps = {|
  animationType?: ?('none' | 'slide' | 'fade'),
  children?: any,
  onDismiss?: ?() => void,
  onShow?: ?() => void,
  visible?: ?boolean
|};

function ModalAnimation(props: ModalAnimationProps) {
  const { animationType, children, onDismiss, onShow, visible } = props;

  const [isRendering, setIsRendering] = useState(false);
  const wasVisible = useRef(false);

  const isAnimated = animationType && animationType !== 'none';

  const animationEndCallback = useCallback(
    (e: any) => {
      if (e && e.currentTarget !== e.target) {
        // If the event was generated for something NOT this element we
        // should ignore it as it's not relevant to us
        return;
      }

      if (visible) {
        if (onShow) {
          onShow();
        }
      } else {
        setIsRendering(false);
        if (onDismiss) {
          onDismiss();
        }
      }
    },
    [onDismiss, onShow, visible]
  );

  useEffect(() => {
    if (visible) {
      setIsRendering(true);
    }
    if (visible !== wasVisible.current && !isAnimated) {
      // Manually call `animationEndCallback` if no animation is used
      animationEndCallback();
    }
    wasVisible.current = visible;
  }, [isAnimated, visible, animationEndCallback]);

  return isRendering || visible
    ? createElement('div', {
        style: isRendering ? getAnimationStyle(animationType, visible) : styles.hidden,
        onAnimationEnd: animationEndCallback,
        children
      })
    : null;
}

const styles = StyleSheet.create({
  container: {
    position: 'fixed',
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    zIndex: 9999
  },
  animatedIn: {
    animationDuration: `${ANIMATION_DURATION}ms`,
    animationTimingFunction: 'ease-in'
  },
  animatedOut: {
    pointerEvents: 'none',
    animationDuration: `${ANIMATION_DURATION}ms`,
    animationTimingFunction: 'ease-out'
  },
  fadeIn: {
    opacity: 1,
    animationKeyframes: {
      '0%': { opacity: 0 },
      '100%': { opacity: 1 }
    }
  },
  fadeOut: {
    opacity: 0,
    animationKeyframes: {
      '0%': { opacity: 1 },
      '100%': { opacity: 0 }
    }
  },
  slideIn: {
    transform: [{ translateY: '0%' }],
    animationKeyframes: {
      '0%': { transform: [{ translateY: '100%' }] },
      '100%': { transform: [{ translateY: '0%' }] }
    }
  },
  slideOut: {
    transform: [{ translateY: '100%' }],
    animationKeyframes: {
      '0%': { transform: [{ translateY: '0%' }] },
      '100%': { transform: [{ translateY: '100%' }] }
    }
  },
  hidden: {
    display: 'none'
  }
});

const animatedSlideInStyles = [styles.container, styles.animatedIn, styles.slideIn];
const animatedSlideOutStyles = [styles.container, styles.animatedOut, styles.slideOut];
const animatedFadeInStyles = [styles.container, styles.animatedIn, styles.fadeIn];
const animatedFadeOutStyles = [styles.container, styles.animatedOut, styles.fadeOut];

export default ModalAnimation;
<commit_msg>[fix] Modal: support programmtic focus on content<commit_after>/**
 * Copyright (c) Nicolas Gallagher.
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import { useEffect, useCallback, useState, useRef } from 'react';
import StyleSheet from '../StyleSheet';
import createElement from '../createElement';

const ANIMATION_DURATION = 300;

function getAnimationStyle(animationType, visible) {
  if (animationType === 'slide') {
    return visible ? animatedSlideInStyles : animatedSlideOutStyles;
  }
  if (animationType === 'fade') {
    return visible ? animatedFadeInStyles : animatedFadeOutStyles;
  }
  return visible ? styles.container : styles.hidden;
}

export type ModalAnimationProps = {|
  animationType?: ?('none' | 'slide' | 'fade'),
  children?: any,
  onDismiss?: ?() => void,
  onShow?: ?() => void,
  visible?: ?boolean
|};

function ModalAnimation(props: ModalAnimationProps) {
  const { animationType, children, onDismiss, onShow, visible } = props;

  const [isRendering, setIsRendering] = useState(false);
  const wasVisible = useRef(false);

  const isAnimated = animationType && animationType !== 'none';

  const animationEndCallback = useCallback(
    (e: any) => {
      if (e && e.currentTarget !== e.target) {
        // If the event was generated for something NOT this element we
        // should ignore it as it's not relevant to us
        return;
      }

      if (visible) {
        if (onShow) {
          onShow();
        }
      } else {
        setIsRendering(false);
        if (onDismiss) {
          onDismiss();
        }
      }
    },
    [onDismiss, onShow, visible]
  );

  useEffect(() => {
    if (visible) {
      setIsRendering(true);
    }
    if (visible !== wasVisible.current && !isAnimated) {
      // Manually call `animationEndCallback` if no animation is used
      animationEndCallback();
    }
    wasVisible.current = visible;
  }, [isAnimated, visible, animationEndCallback]);

  return isRendering || visible
    ? createElement('div', {
        style: isRendering ? getAnimationStyle(animationType, visible) : styles.hidden,
        onAnimationEnd: animationEndCallback,
        children
      })
    : null;
}

const styles = StyleSheet.create({
  container: {
    position: 'fixed',
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    zIndex: 9999
  },
  animatedIn: {
    animationDuration: `${ANIMATION_DURATION}ms`,
    animationTimingFunction: 'ease-in'
  },
  animatedOut: {
    pointerEvents: 'none',
    animationDuration: `${ANIMATION_DURATION}ms`,
    animationTimingFunction: 'ease-out'
  },
  fadeIn: {
    opacity: 1,
    animationKeyframes: {
      '0%': { opacity: 0 },
      '100%': { opacity: 1 }
    }
  },
  fadeOut: {
    opacity: 0,
    animationKeyframes: {
      '0%': { opacity: 1 },
      '100%': { opacity: 0 }
    }
  },
  slideIn: {
    transform: [{ translateY: '0%' }],
    animationKeyframes: {
      '0%': { transform: [{ translateY: '100%' }] },
      '100%': { transform: [{ translateY: '0%' }] }
    }
  },
  slideOut: {
    transform: [{ translateY: '100%' }],
    animationKeyframes: {
      '0%': { transform: [{ translateY: '0%' }] },
      '100%': { transform: [{ translateY: '100%' }] }
    }
  },
  hidden: {
    opacity: 0
  }
});

const animatedSlideInStyles = [styles.container, styles.animatedIn, styles.slideIn];
const animatedSlideOutStyles = [styles.container, styles.animatedOut, styles.slideOut];
const animatedFadeInStyles = [styles.container, styles.animatedIn, styles.fadeIn];
const animatedFadeOutStyles = [styles.container, styles.animatedOut, styles.fadeOut];

export default ModalAnimation;
<|endoftext|>


<commit_before>import React from 'react';
import { StaticQuery, graphql } from 'gatsby';
import Img from 'gatsby-image';

const ImageMe = () => (
  <StaticQuery
    query={graphql`
      query {
        placeholderImage: file(relativePath: { eq: "me.jpg" }) {
          childImageSharp {
            fluid(maxWidth: 600) {
              ...GatsbyImageSharpFluid_withWebp_noBase64
            }
          }
        }
      }
    `}
    render={data => (

    )}
  />
);

export default ImageMe;
<commit_msg>reduce image size<commit_after>import React from 'react';
import { StaticQuery, graphql } from 'gatsby';
import Img from 'gatsby-image';

const ImageMe = () => (
  <StaticQuery
    query={graphql`
      query {
        placeholderImage: file(relativePath: { eq: "me.jpg" }) {
          childImageSharp {
            fluid(maxWidth: 288) {
              ...GatsbyImageSharpFluid_withWebp_noBase64
            }
          }
        }
      }
    `}
    render={data => (

    )}
  />
);

export default ImageMe;
<|endoftext|>


<commit_before>import test from 'ava';
import parse from '../library/parse';
import footerLeadingBlank from './footer-leading-blank';

const messages = {
	simple: 'chore: subject',
	body: 'chore: subject\nbody',
	trailing: 'chore: subject\nbody\n\n',
	without: 'chore: subject\nbody\nBREAKING CHANGE: something important',
	with: 'chore: subject\nbody\n\nBREAKING CHANGE: something important',
	withMulitLine:
		'chore: subject\nmulti\nline\nbody\n\nBREAKING CHANGE: something important'
};

const parsed = {
	simple: parse(messages.simple),
	body: parse(messages.body),
	trailing: parse(messages.trailing),
	without: parse(messages.without),
	with: parse(messages.with),
	withMulitLine: parse(messages.withMulitLine)
};

test('with simple message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple);
	const expected = true;
	t.is(actual, expected);
});

test('with simple message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with simple message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.body);
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.body, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.body, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing);
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('without blank line before footer should fail for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.without);
	const expected = false;
	t.is(actual, expected);
});

test('without blank line before footer should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.without, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('without blank line before footer should fail for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.without, 'always');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.with);
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer should fail for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.with, 'never');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.with, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine);
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should fail for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine, 'never');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine, 'always');
	const expected = true;
	t.is(actual, expected);
});
<commit_msg>test(core): add failing tests for regression related to to-lines<commit_after>import test from 'ava';
import parse from '../library/parse';
import footerLeadingBlank from './footer-leading-blank';

const messages = {
	simple: 'chore: subject',
	body: 'chore: subject\nbody',
	trailing: 'chore: subject\nbody\n\n',
	without: 'chore: subject\nbody\nBREAKING CHANGE: something important',
	withoutBody:
		'feat(new-parser): introduces a new parsing library\n\nBREAKING CHANGE: new library does not support foo-construct',
	with: 'chore: subject\nbody\n\nBREAKING CHANGE: something important',
	withMulitLine:
		'chore: subject\nmulti\nline\nbody\n\nBREAKING CHANGE: something important'
};

const parsed = {
	simple: parse(messages.simple),
	body: parse(messages.body),
	trailing: parse(messages.trailing),
	without: parse(messages.without),
	withoutBody: parse(messages.withoutBody),
	with: parse(messages.with),
	withMulitLine: parse(messages.withMulitLine)
};

test('with simple message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple);
	const expected = true;
	t.is(actual, expected);
});

test('with simple message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with simple message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.simple, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.body);
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.body, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with body message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.body, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing);
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('with trailing message should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.trailing, 'always');
	const expected = true;
	t.is(actual, expected);
});

test.failing('without body should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withoutBody, 'never');
	const expected = true;
	t.is(actual, expected);
});

test.failing('without body should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withoutBody, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('without blank line before footer should fail for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.without);
	const expected = false;
	t.is(actual, expected);
});

test('without blank line before footer should succeed for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.without, 'never');
	const expected = true;
	t.is(actual, expected);
});

test('without blank line before footer should fail for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.without, 'always');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.with);
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer should fail for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.with, 'never');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.with, 'always');
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should succeed for empty keyword', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine);
	const expected = true;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should fail for "never"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine, 'never');
	const expected = false;
	t.is(actual, expected);
});

test('with blank line before footer and multiline body should succeed for "always"', async t => {
	const [actual] = footerLeadingBlank(await parsed.withMulitLine, 'always');
	const expected = true;
	t.is(actual, expected);
});
<|endoftext|>


<commit_before>// on startup run resizing event
Meteor.startup(function() {
  $(window).resize(function() {
    $('#map').css('height', window.innerHeight - 82 - 45);
  });
  $(window).resize(); // trigger resize event
});

// create marker collection
var Markers = new Meteor.Collection('markers');

Meteor.subscribe('markers');

Template.map.rendered = function() {
  L.Icon.Default.imagePath = 'packages/bevanhunt_leaflet/images';

  var map = L.map('map', {
    doubleClickZoom: false
  }).setView([49.25044, -123.137], 13);

  L.tileLayer.provider('Thunderforest.Outdoors').addTo(map);

  map.on('dblclick', function(event) {
    Markers.insert({latlng: event.latlng});
  });

  var query = Markers.find();
  query.observe({
    added: function (document) {
      var marker = L.marker(document.latlng).addTo(map)
        .on('click', function(event) {
          map.removeLayer(marker);
          Markers.remove({_id: document._id});
        });
    },
    removed: function (oldDocument) {
      layers = map._layers;
      var key, val;
      for (key in layers) {
        val = layers[key];
        if (val._latlng) {
          if (val._latlng.lat === oldDocument.latlng.lat && val._latlng.lng === oldDocument.latlng.lng) {
            map.removeLayer(val);
          }
        }
      }
    }
  });
};
<commit_msg>Fix coordinates<commit_after>// on startup run resizing event
Meteor.startup(function() {
  $(window).resize(function() {
    $('#map').css('height', window.innerHeight - 82 - 45);
  });
  $(window).resize(); // trigger resize event
});

// create marker collection
var Markers = new Meteor.Collection('markers');

Meteor.subscribe('markers');

Template.map.rendered = function() {
  L.Icon.Default.imagePath = 'packages/bevanhunt_leaflet/images';

  var map = L.map('map', {
    doubleClickZoom: false
  }).setView([36.850, -76.285], 13);

  L.tileLayer.provider('Thunderforest.Outdoors').addTo(map);

  map.on('dblclick', function(event) {
    Markers.insert({latlng: event.latlng});
  });

  var query = Markers.find();
  query.observe({
    added: function (document) {
      var marker = L.marker(document.latlng).addTo(map)
        .on('click', function(event) {
          map.removeLayer(marker);
          Markers.remove({_id: document._id});
        });
    },
    removed: function (oldDocument) {
      layers = map._layers;
      var key, val;
      for (key in layers) {
        val = layers[key];
        if (val._latlng) {
          if (val._latlng.lat === oldDocument.latlng.lat && val._latlng.lng === oldDocument.latlng.lng) {
            map.removeLayer(val);
          }
        }
      }
    }
  });
};
<|endoftext|>


<commit_before>angular.module("omniControllers")
  .controller("ExchangeSaleController",["$scope", "Transaction", "MIN_MINER_FEE",
    function ExchangeSaleController($scope, Transaction, MIN_MINER_FEE) {
      $scope.minersFee = MIN_MINER_FEE;

      $scope.confirm = function(){
        //TODO: VALIDATIONS
        var fee = new Big($scope.minerFees);
        var exchangeSale = new Transaction(20,$scope.selectedAddress,fee,{
            amount: $scope.saleAmount,
            price: $scope.salePrice,
            min_buyer_fee: $scope.buyersFee,
            blocks: $scope.saleBlocks,
            currency: $scope.selectedCoin.symbol,
            donate: $scope.account.getSetting("donate")
          });

        $scope.modalManager.openConfirmationModal({
          dataTemplate: '/views/modals/partials/sale.html',
          scope:{
            title:"EXCHANGE.SALE.MODALTITLE",
            saleAmount: $scope.saleAmount,
            buyersFee: $scope.buyersfee,
            selectedCoin: $scope.selectedCoin,
            salePricePerCoin: $scope.salePrice,
            saleBlocks : $scope.saleBlocks,
            fees : $scope.minerFees,
            totalCost : exchangeSale.totalCost,
            confirmText:"EXCHANGE.SALE.CONFIRM",
            explorerUrl:ADDRESS_EXPLORER_URL
          },
          transaction:exchangeSale
        })
      }

      $scope.selectedAddress= $scope.hasCoins ? $scope.selectedAsset.tradableAddresses[0] : undefined;
      $scope.setAddress = function(address){
            $scope.selectedAddress = address;
      }

      // $scope.validateSaleForm = function() {
      //   var dustValue = 5757;
      //   var minerMinimum = 10000;
      //   var nonZeroValue = 1;
      //   var cancelFees = (5757*3);
      //   var divisible = $scope.selectedCoin.divisible;

      //   var convertToSatoshi = [
      //       $scope.minerFees,
      //       $scope.buyersFee,
      //       0, //$scope.salePricePerCoin,
      //       $scope.saleAmount,
      //       $scope.balanceData[0],
      //       $scope.balanceData[1]
      //     ];

      //   if (!divisible) {
      //     delete convertToSatoshi[ convertToSatoshi.indexOf( $scope.saleAmount ) ];
      //     delete convertToSatoshi[ convertToSatoshi.indexOf( $scope.balanceData[0] ) ];
      //   }

      //   var convertedValues = $scope.convertDisplayedValue( convertToSatoshi );

      //   var minerFees = +convertedValues[0];
      //   var buyersFee = +convertedValues[1];
      //   //var salePricePerCoin = +convertedValues[2];
      //   var saleAmount = divisible ? +convertedValues[3] : +$scope.saleAmount;

      //   var balance = divisible ? +convertedValues[4] : +$scope.balanceData[0];
      //   var btcbalance = +convertedValues[5];

      //   var coin = $scope.isCancel != true ? $scope.selectedCoin.symbol : $scope.selectedCoin_extra;
      //   var salePricePerCoin = $scope.salePricePerCoin;
      //   var address = $scope.selectedAddress;
      //   var saleBlocks = +$scope.saleBlocks;

      //   var totalFeeCost = parseFloat($scope.convertDisplayedValue($scope.totalCost));

      //   var required = [coin, address, saleAmount, saleBlocks, salePricePerCoin, minerFees, buyersFee, balance, btcbalance, $scope.saleForm.$valid];

      //   var error = 'Please ';
      //   if ($scope.saleForm.$valid == false) {
      //     error += 'make sure all fields are completely filled, ';
      //   }
      //   if ( $scope.isCancel != true && coin == 'BTC') {
      //     error += 'make sure your sale is for MSC or TMSC, ';
      //   }
      //   if( $scope.isCancel != true && ((coin == 'MSC') || (coin == 'TMSC')) ) {
      //     if (saleAmount < nonZeroValue)
      //       error += 'make sure your send amount is non-zero, ';
      //     if (buyersFee < minerMinimum)
      //       error += 'make sure your buyers fee entry is at least 0.0001 BTC, ';
      //     if (minerFees < minerMinimum)
      //       error += 'make sure your fee entry is at least 0.0001 BTC, ';
      //     if ((saleAmount <= balance) == false)
      //       error += 'make sure you aren\'t putting more coins up for sale than you own, ';
      //     if ((totalFeeCost <= btcbalance) == false)
      //       error += 'make sure you have enough Bitcoin to cover your fees, ';

      //     if (saleBlocks < 1)
      //       error += 'make sure your block timeframe is at least 1, ';
      //   }
      //   if ($scope.isCancel == true && (((cancelFees + minerFees) <= btcbalance) == false) )
      //     error += 'make sure you have enough Bitcoin to cover your transaction fees, ';
      //   if (error.length < 8) {
      //     $scope.$parent.showErrors = false;

      //     // open modal
      //     var modalInstance = $modal.open({
      //       templateUrl: $scope.isCancel == true ? '/partials/wallet_cancel_modal.html' : '/partials/wallet_sale_modal.html',
      //       controller: function($scope, $modalInstance, $rootScope, data, prepareSaleTransaction, getUnsignedSaleTransaction, convertSatoshiToDisplayedValue, getDisplayedAbbreviation) {
      //         $scope.sendSuccess = false, $scope.sendError = false, $scope.waiting = false, $scope.privKeyPass = {};
      //         $scope.convertSatoshiToDisplayedValue=convertSatoshiToDisplayedValue,
      //         $scope.getDisplayedAbbreviation=getDisplayedAbbreviation,
      //         $scope.saleAmount=data.amt,
      //         $scope.buyersFee=data.buyersfee,
      //         $scope.selectedCoin=data.selectedCoin,
      //         $scope.salePricePerCoin= data.price,
      //         $scope.saleBlocks = data.blocks;

      //         $scope.ok = function() {
      //           $scope.clicked = true;
      //           $scope.waiting = true;

      //           prepareSaleTransaction(data.seller, data.amt, data.price,
      //           data.buyersfee, data.fee, data.blocks, data.currency, $scope.privKeyPass, $scope);
      //         };
      //         $scope.cancel = function () {
      //           $modalInstance.dismiss('cancel');
      //         };
      //       },
      //       resolve: {
      //         data: function() {
      //           return {
      //             seller: address,
      //             amt: saleAmount,
      //             price: salePricePerCoin,
      //             buyersfee: buyersFee,
      //             fee: minerFees,
      //             blocks: saleBlocks,
      //             currency: coin,
      //             selectedCoin: $scope.selectedCoin,
      //             saleBlocks: saleBlocks
      //           };
      //         },
      //         prepareSaleTransaction: function() {
      //           return prepareSaleTransaction;
      //         },
      //         getUnsignedSaleTransaction: function() {
      //           return getUnsignedSaleTransaction;
      //         },
      //         pushSignedTransaction: function() {
      //           return walletTransactionService.pushSignedTransaction;
      //         },
      //         convertSatoshiToDisplayedValue: function() {
      //           return $scope.convertSatoshiToDisplayedValue;
      //         },
      //         getDisplayedAbbreviation: function() {
      //           return $scope.getDisplayedAbbreviation;
      //         }
      //       }
      //     });

      //     modalInstance.result.then(function() {
      //       if ($scope.isCancel)
      //         $scope.$parent.$parent.$parent.cancelTrig = null;
      //     }, function() {
      //       if ($scope.isCancel)
      //         $scope.$parent.$parent.$parent.cancelTrig = null;
      //     });

      //   } else {
      //     error += 'and try again.';
      //     $scope.error = error;
      //     $scope.$parent.showErrors = true;
      //   }
      // };
    }])

<commit_msg>fix spelling error<commit_after>angular.module("omniControllers")
  .controller("ExchangeSaleController",["$scope", "Transaction", "MIN_MINER_FEE",
    function ExchangeSaleController($scope, Transaction, MIN_MINER_FEE) {
      $scope.minerFees = MIN_MINER_FEE;

      $scope.confirm = function(){
        //TODO: VALIDATIONS
        var fee = new Big($scope.minerFees);
        var exchangeSale = new Transaction(20,$scope.selectedAddress,fee,{
            amount: $scope.saleAmount,
            price: $scope.salePrice,
            min_buyer_fee: $scope.buyersFee,
            blocks: $scope.saleBlocks,
            currency: $scope.selectedCoin.symbol,
            donate: $scope.account.getSetting("donate")
          });

        $scope.modalManager.openConfirmationModal({
          dataTemplate: '/views/modals/partials/sale.html',
          scope:{
            title:"EXCHANGE.SALE.MODALTITLE",
            saleAmount: $scope.saleAmount,
            buyersFee: $scope.buyersfee,
            selectedCoin: $scope.selectedCoin,
            salePricePerCoin: $scope.salePrice,
            saleBlocks : $scope.saleBlocks,
            fees : $scope.minerFees,
            totalCost : exchangeSale.totalCost,
            confirmText:"EXCHANGE.SALE.CONFIRM",
            explorerUrl:ADDRESS_EXPLORER_URL
          },
          transaction:exchangeSale
        })
      }

      $scope.selectedAddress= $scope.hasCoins ? $scope.selectedAsset.tradableAddresses[0] : undefined;
      $scope.setAddress = function(address){
            $scope.selectedAddress = address;
      }

      // $scope.validateSaleForm = function() {
      //   var dustValue = 5757;
      //   var minerMinimum = 10000;
      //   var nonZeroValue = 1;
      //   var cancelFees = (5757*3);
      //   var divisible = $scope.selectedCoin.divisible;

      //   var convertToSatoshi = [
      //       $scope.minerFees,
      //       $scope.buyersFee,
      //       0, //$scope.salePricePerCoin,
      //       $scope.saleAmount,
      //       $scope.balanceData[0],
      //       $scope.balanceData[1]
      //     ];

      //   if (!divisible) {
      //     delete convertToSatoshi[ convertToSatoshi.indexOf( $scope.saleAmount ) ];
      //     delete convertToSatoshi[ convertToSatoshi.indexOf( $scope.balanceData[0] ) ];
      //   }

      //   var convertedValues = $scope.convertDisplayedValue( convertToSatoshi );

      //   var minerFees = +convertedValues[0];
      //   var buyersFee = +convertedValues[1];
      //   //var salePricePerCoin = +convertedValues[2];
      //   var saleAmount = divisible ? +convertedValues[3] : +$scope.saleAmount;

      //   var balance = divisible ? +convertedValues[4] : +$scope.balanceData[0];
      //   var btcbalance = +convertedValues[5];

      //   var coin = $scope.isCancel != true ? $scope.selectedCoin.symbol : $scope.selectedCoin_extra;
      //   var salePricePerCoin = $scope.salePricePerCoin;
      //   var address = $scope.selectedAddress;
      //   var saleBlocks = +$scope.saleBlocks;

      //   var totalFeeCost = parseFloat($scope.convertDisplayedValue($scope.totalCost));

      //   var required = [coin, address, saleAmount, saleBlocks, salePricePerCoin, minerFees, buyersFee, balance, btcbalance, $scope.saleForm.$valid];

      //   var error = 'Please ';
      //   if ($scope.saleForm.$valid == false) {
      //     error += 'make sure all fields are completely filled, ';
      //   }
      //   if ( $scope.isCancel != true && coin == 'BTC') {
      //     error += 'make sure your sale is for MSC or TMSC, ';
      //   }
      //   if( $scope.isCancel != true && ((coin == 'MSC') || (coin == 'TMSC')) ) {
      //     if (saleAmount < nonZeroValue)
      //       error += 'make sure your send amount is non-zero, ';
      //     if (buyersFee < minerMinimum)
      //       error += 'make sure your buyers fee entry is at least 0.0001 BTC, ';
      //     if (minerFees < minerMinimum)
      //       error += 'make sure your fee entry is at least 0.0001 BTC, ';
      //     if ((saleAmount <= balance) == false)
      //       error += 'make sure you aren\'t putting more coins up for sale than you own, ';
      //     if ((totalFeeCost <= btcbalance) == false)
      //       error += 'make sure you have enough Bitcoin to cover your fees, ';

      //     if (saleBlocks < 1)
      //       error += 'make sure your block timeframe is at least 1, ';
      //   }
      //   if ($scope.isCancel == true && (((cancelFees + minerFees) <= btcbalance) == false) )
      //     error += 'make sure you have enough Bitcoin to cover your transaction fees, ';
      //   if (error.length < 8) {
      //     $scope.$parent.showErrors = false;

      //     // open modal
      //     var modalInstance = $modal.open({
      //       templateUrl: $scope.isCancel == true ? '/partials/wallet_cancel_modal.html' : '/partials/wallet_sale_modal.html',
      //       controller: function($scope, $modalInstance, $rootScope, data, prepareSaleTransaction, getUnsignedSaleTransaction, convertSatoshiToDisplayedValue, getDisplayedAbbreviation) {
      //         $scope.sendSuccess = false, $scope.sendError = false, $scope.waiting = false, $scope.privKeyPass = {};
      //         $scope.convertSatoshiToDisplayedValue=convertSatoshiToDisplayedValue,
      //         $scope.getDisplayedAbbreviation=getDisplayedAbbreviation,
      //         $scope.saleAmount=data.amt,
      //         $scope.buyersFee=data.buyersfee,
      //         $scope.selectedCoin=data.selectedCoin,
      //         $scope.salePricePerCoin= data.price,
      //         $scope.saleBlocks = data.blocks;

      //         $scope.ok = function() {
      //           $scope.clicked = true;
      //           $scope.waiting = true;

      //           prepareSaleTransaction(data.seller, data.amt, data.price,
      //           data.buyersfee, data.fee, data.blocks, data.currency, $scope.privKeyPass, $scope);
      //         };
      //         $scope.cancel = function () {
      //           $modalInstance.dismiss('cancel');
      //         };
      //       },
      //       resolve: {
      //         data: function() {
      //           return {
      //             seller: address,
      //             amt: saleAmount,
      //             price: salePricePerCoin,
      //             buyersfee: buyersFee,
      //             fee: minerFees,
      //             blocks: saleBlocks,
      //             currency: coin,
      //             selectedCoin: $scope.selectedCoin,
      //             saleBlocks: saleBlocks
      //           };
      //         },
      //         prepareSaleTransaction: function() {
      //           return prepareSaleTransaction;
      //         },
      //         getUnsignedSaleTransaction: function() {
      //           return getUnsignedSaleTransaction;
      //         },
      //         pushSignedTransaction: function() {
      //           return walletTransactionService.pushSignedTransaction;
      //         },
      //         convertSatoshiToDisplayedValue: function() {
      //           return $scope.convertSatoshiToDisplayedValue;
      //         },
      //         getDisplayedAbbreviation: function() {
      //           return $scope.getDisplayedAbbreviation;
      //         }
      //       }
      //     });

      //     modalInstance.result.then(function() {
      //       if ($scope.isCancel)
      //         $scope.$parent.$parent.$parent.cancelTrig = null;
      //     }, function() {
      //       if ($scope.isCancel)
      //         $scope.$parent.$parent.$parent.cancelTrig = null;
      //     });

      //   } else {
      //     error += 'and try again.';
      //     $scope.error = error;
      //     $scope.$parent.showErrors = true;
      //   }
      // };
    }])

<|endoftext|>


<commit_before><commit_msg>Open for videosettings in texturecreator<commit_after><|endoftext|>