<commit_before>/*!
 *
 * jquery-debouncedwidth - v1.1.0
 * https://github.com/janrembold/jquery-debouncedwidth
 * Copyright (c) 2015 Jan Rembold <janrembold@gmail.com>; License: MIT
 *
 * */

(function($) {
    'use strict';

    var timeout;
    var $window = $(window);
    var lastWidth = $window.width();
    var elements = [];

    // use timeouts to debounce resize event
    var debouncer = function(){
        clearTimeout(timeout);
        timeout = setTimeout( function(){

            // check if width really changed
            var currentWidth = $window.width();
            if(currentWidth !== lastWidth) {
                // set current width to last seen width
                lastWidth = currentWidth;

                // trigger debouncedwidth event
                var index = elements.length;
                while(index--) {
                    $(elements[index]).trigger('debouncedwidth');
                }
            }

        }, $.event.special.debouncedwidth.threshold);
    };

    var inArray = function(element){
        var index = elements.length;
        while(index--) {
            if(elements[index] === element) {
                return index;
            }
        }

        return -1;
    };

    $.event.special.debouncedwidth = {
        setup: function(){
            if(inArray(this) === -1) {
                elements.push(this);
            }

            var $this = $(this);
            $this.on('resize.debouncedwidth', debouncer);
        },

        teardown: function(){
            var index = inArray(this);
            if(index !== -1) {
                elements = elements.splice(index, 1);
            }

            $(this).off('resize.debouncedwidth');
        },

        threshold: 150
    };

})(window.jQuery);<commit_msg>fixed multiple resize event initialization changed internal inArray function to jQuerys inArray function<commit_after>/*!
 *
 * jquery-debouncedwidth - v1.1.1
 * https://github.com/janrembold/jquery-debouncedwidth
 * Copyright (c) 2015 Jan Rembold <janrembold@gmail.com>; License: MIT
 *
 * */

(function($) {
    'use strict';

    var timeout;
    var $window = $(window);
    var lastWidth = 0;
    var elements = [];

    // use timeouts to debounce resize event
    var debouncer = function(){
        clearTimeout(timeout);
        timeout = setTimeout( function(){

            // check if width really changed
            var currentWidth = $window.width();
            if(currentWidth !== lastWidth) {
                // set current width to last seen width
                lastWidth = currentWidth;

                // trigger debouncedwidth event for all elements
                var index = elements.length;
                while(index--) {
                    $(elements[index]).trigger('debouncedwidth');
                }
            }

        }, $.event.special.debouncedwidth.threshold);

    };

    $.event.special.debouncedwidth = {
        setup: function(){
            // start resize event only once
            if(elements.length === 0) {
                lastWidth = $window.width();
                $(this).on('resize.debouncedwidth', debouncer);
            }

            // push new elements to internal array
            if($.inArray(this, elements) === -1) {
                elements.push(this);
            }
        },

        teardown: function(){
            // remove element from internal array
            var index = $.inArray(this, elements);
            if(index > -1) {
                elements.splice(index, 1);
            }

            // clean up, if nothing is left to listen to
            if(elements.length === 0) {
                $(this).off('resize.debouncedwidth');
            }
        },

        threshold: 150
    };

})(window.jQuery);
<|endoftext|>


<commit_before>/*
 * Copyright 2015. Author: Jeffrey Hing. All Rights Reserved.
 *
 * MIT License
 *
 * drawerClass directive
 */
'use strict';

//--------------------------------------
// Module exports
//--------------------------------------

module.exports = drawerClassDirective;

//--------------------------------------
// Directive
//--------------------------------------

/*
 * The drawerClassDirective dynamically updates the element's classes
 * whenever the state of the drawer changes.
 *
 * @example
 *

 *
 * @param {string} directiveNames.cabinet
 * @param {string} directiveNames.drawerClass
 * @return {object} directive
 */
function drawerClassDirective(directiveNames, parse) {

    return {
        link: {
            pre: prelink
        },
        require: '^' + directiveNames.cabinet
    };

    function prelink(scope, element, attrs, cabinetCtrl) {
        var classes = parse(attrs[directiveNames.drawerClass])(scope);

        var drawerCtrl = cabinetCtrl.getDrawerController(classes.id);

        // Listen for open changes.
        drawerCtrl.addOpenListener(function(isOpened) {

            // Replace the element's class.
            if (isOpened) {
                element.addClass(classes.open);
                element.removeClass(classes.closed);
            } else {
                element.removeClass(classes.open);
                element.addClass(classes.closed);
            }
        });
    }
}
<commit_msg>Fix documentation issue.<commit_after>/*
 * Copyright 2015. Author: Jeffrey Hing. All Rights Reserved.
 *
 * MIT License
 *
 * drawerClass directive
 */
'use strict';

//--------------------------------------
// Module exports
//--------------------------------------

module.exports = drawerClassDirective;

//--------------------------------------
// Directive
//--------------------------------------

/*
 * The drawerClassDirective dynamically updates the element's classes
 * whenever the state of the drawer changes.
 *
 * @example
 *

 *
 * @param {string} directiveNames.cabinet
 * @param {string} directiveNames.drawerClass
 * @param {object} parse The angular parse service.
 * @return {object} directive
 */
function drawerClassDirective(directiveNames, parse) {

    return {
        link: {
            pre: prelink
        },
        require: '^' + directiveNames.cabinet
    };

    function prelink(scope, element, attrs, cabinetCtrl) {
        var classes = parse(attrs[directiveNames.drawerClass])(scope);

        var drawerCtrl = cabinetCtrl.getDrawerController(classes.id);

        // Listen for open changes.
        drawerCtrl.addOpenListener(function(isOpened) {

            // Replace the element's class.
            if (isOpened) {
                element.addClass(classes.open);
                element.removeClass(classes.closed);
            } else {
                element.removeClass(classes.open);
                element.addClass(classes.closed);
            }
        });
    }
}
<|endoftext|>


<commit_before>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Assorted tests to qualify browsers by detecting features
//>>label: Support Tests
//>>group: Core
define( [  "jquery", "./jquery.mobile.core", "./jquery.mobile.media", "./jquery.mobile.support.touch", "./jquery.mobile.support.orientation" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

// thx Modernizr
function propExists( prop ) {
	var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
		props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " ),
		v;

	for ( v in props ) {
		if ( fbCSS[ props[ v ] ] !== undefined ) {
			return true;
		}
	}
}

var fakeBody = $( "" ).prependTo( "html" ),
	fbCSS = fakeBody[ 0 ].style,
	vendors = [ "Webkit", "Moz", "O" ],
	webos = "palmGetResource" in window, //only used to rule out scrollTop
	opera = window.opera,
	operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
	bb = window.blackberry && !propExists( "-webkit-transform" ), //only used to rule out box shadow, as it's filled opaque on BB 5 and lower
	nokiaLTE7_3;

function validStyle( prop, value, check_vend ) {
	var div = document.createElement( "div" ),
		uc = function( txt ) {
			return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
		},
		vend_pref = function( vend ) {
			if( vend === "" ) {
				return "";
			} else {
				return  "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
			}
		},
		check_style = function( vend ) {
			var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
				uc_vend = uc( vend ),
				propStyle = uc_vend + ( uc_vend === "" ? prop : uc( prop ) );

			div.setAttribute( "style", vend_prop );

			if ( !!div.style[ propStyle ] ) {
				ret = true;
			}
		},
		check_vends = check_vend ? check_vend : vendors,
		i, ret;

	for( i = 0; i < check_vends.length; i++ ) {
		check_style( check_vends[i] );
	}
	return !!ret;
}

// inline SVG support test
function inlineSVG() {
	// Thanks Modernizr & Erik Dahlstrom
	var w = window,
		svg = !!w.document.createElementNS && !!w.document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect && !!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1"),
		support = function( data ) {
			if ( !( data && svg ) ) {
				$( "html" ).addClass( "ui-nosvg" );
			}
		},
		img = new w.Image();

	img.onerror = function() {
		support( false );
	};
	img.onload = function() {
		support( img.width === 1 && img.height === 1 );
	};
	img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
}

function transform3dTest() {
	var mqProp = "transform-3d",
		// Because the `translate3d` test below throws false positives in Android:
		ret = $.mobile.media( "(-" + vendors.join( "-" + mqProp + "),(-" ) + "-" + mqProp + "),(" + mqProp + ")" ),
		el, transforms, t;

	if( ret ) {
		return !!ret;
	}

	el = document.createElement( "div" );
	transforms = {
		// We’re omitting Opera for the time being; MS uses unprefixed.
		"MozTransform": "-moz-transform",
		"transform": "transform"
	};

	fakeBody.append( el );

	for ( t in transforms ) {
		if( el.style[ t ] !== undefined ){
			el.style[ t ] = "translate3d( 100px, 1px, 1px )";
			ret = window.getComputedStyle( el ).getPropertyValue( transforms[ t ] );
		}
	}
	return ( !!ret && ret !== "none" );
}

// Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
function baseTagTest() {
	var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
		base = $( "head base" ),
		fauxEle = null,
		href = "",
		link, rebase;

	if ( !base.length ) {
		base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
	} else {
		href = base.attr( "href" );
	}

	link = $( "" ).prependTo( fakeBody );
	rebase = link[ 0 ].href;
	base[ 0 ].href = href || location.pathname;

	if ( fauxEle ) {
		fauxEle.remove();
	}
	return rebase.indexOf( fauxBase ) === 0;
}

// Thanks Modernizr
function cssPointerEventsTest() {
	var element = document.createElement( "x" ),
		documentElement = document.documentElement,
		getComputedStyle = window.getComputedStyle,
		supports;

	if ( !( "pointerEvents" in element.style ) ) {
		return false;
	}

	element.style.pointerEvents = "auto";
	element.style.pointerEvents = "x";
	documentElement.appendChild( element );
	supports = getComputedStyle &&
	getComputedStyle( element, "" ).pointerEvents === "auto";
	documentElement.removeChild( element );
	return !!supports;
}

function boundingRect() {
	var div = document.createElement( "div" );
	return typeof div.getBoundingClientRect !== "undefined";
}

// non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
// allows for inclusion of IE 6+, including Windows Mobile 7
$.extend( $.mobile, { browser: {} } );
$.mobile.browser.oldIE = (function() {
	var v = 3,
		div = document.createElement( "div" ),
		a = div.all || [];

	do {
		div.innerHTML = "";
	} while( a[0] );

	return v > 4 ? v : !v;
})();

function fixedPosition() {
	var w = window,
		ua = navigator.userAgent,
		platform = navigator.platform,
		// Rendering engine is Webkit, and capture major version
		wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
		wkversion = !!wkmatch && wkmatch[ 1 ],
		ffmatch = ua.match( /Fennec\/([0-9]+)/ ),
		ffversion = !!ffmatch && ffmatch[ 1 ],
		operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ),
		omversion = !!operammobilematch && operammobilematch[ 1 ];

	if(
		// iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5)
		( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1  || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) ||
		// Opera Mini
		( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) ||
		( operammobilematch && omversion < 7458 )	||
		//Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2)
		( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 533 ) ||
		// Firefox Mobile before 6.0 -
		( ffversion && ffversion < 6 ) ||
		// WebOS less than 3
		( "palmGetResource" in window && wkversion && wkversion < 534 )	||
		// MeeGo
		( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) {
		return false;
	}

	return true;
}

$.extend( $.support, {
	cssTransitions: "WebKitTransitionEvent" in window ||
		validStyle( "transition", "height 100ms linear", [ "Webkit", "Moz", "" ] ) &&
		!$.mobile.browser.oldIE && !opera,

	// Note, Chrome for iOS has an extremely quirky implementation of popstate.
	// We've chosen to take the shortest path to a bug fix here for issue #5426
	// See the following link for information about the regex chosen
	// https://developers.google.com/chrome/mobile/docs/user-agent#chrome_for_ios_user-agent
	pushState: "pushState" in history &&
		"replaceState" in history &&
		// When running inside a FF iframe, calling replaceState causes an error
		!( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
		( window.navigator.userAgent.search(/CriOS/) === -1 ),

	mediaquery: $.mobile.media( "only all" ),
	cssPseudoElement: !!propExists( "content" ),
	touchOverflow: !!propExists( "overflowScrolling" ),
	cssTransform3d: transform3dTest(),
	boxShadow: !!propExists( "boxShadow" ) && !bb,
	fixedPosition: fixedPosition(),
	scrollTop: ("pageXOffset" in window ||
		"scrollTop" in document.documentElement ||
		"scrollTop" in fakeBody[ 0 ]) && !webos && !operamini,

	dynamicBaseTag: baseTagTest(),
	cssPointerEvents: cssPointerEventsTest(),
	boundingRect: boundingRect(),
	inlineSVG: inlineSVG
});

fakeBody.remove();

// $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
// or that generally work better browsing in regular http for full page refreshes (Opera Mini)
// Note: This detection below is used as a last resort.
// We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
nokiaLTE7_3 = (function() {

	var ua = window.navigator.userAgent;

	//The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
	return ua.indexOf( "Nokia" ) > -1 &&
			( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
			ua.indexOf( "AppleWebKit" ) > -1 &&
			ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
})();

// Support conditions that must be met in order to proceed
// default enhanced qualifications are media query support OR IE 7+

$.mobile.gradeA = function() {
	return ( ( $.support.mediaquery && $.support.cssPseudoElement ) || $.mobile.browser.oldIE && $.mobile.browser.oldIE >= 8 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null );
};

$.mobile.ajaxBlacklist =
			// BlackBerry browsers, pre-webkit
			window.blackberry && !window.WebKitPoint ||
			// Opera Mini
			operamini ||
			// Symbian webkits pre 7.3
			nokiaLTE7_3;

// Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
// to render the stylesheets when they're referenced before this script, as we'd recommend doing.
// This simply reappends the CSS in place, which for some reason makes it apply
if ( nokiaLTE7_3 ) {
	$(function() {
		$( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
	});
}

// For ruling out shadows via css
if ( !$.support.boxShadow ) {
	$( "html" ).addClass( "ui-noboxshadow" );
}

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");
<commit_msg>Support: No SVG for Opera except Opera Next. Removed hasFeature() check because we don't suppport Firefox 3.6.<commit_after>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Assorted tests to qualify browsers by detecting features
//>>label: Support Tests
//>>group: Core
define( [  "jquery", "./jquery.mobile.core", "./jquery.mobile.media", "./jquery.mobile.support.touch", "./jquery.mobile.support.orientation" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

// thx Modernizr
function propExists( prop ) {
	var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
		props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " ),
		v;

	for ( v in props ) {
		if ( fbCSS[ props[ v ] ] !== undefined ) {
			return true;
		}
	}
}

var fakeBody = $( "" ).prependTo( "html" ),
	fbCSS = fakeBody[ 0 ].style,
	vendors = [ "Webkit", "Moz", "O" ],
	webos = "palmGetResource" in window, //only used to rule out scrollTop
	opera = window.opera,
	operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
	bb = window.blackberry && !propExists( "-webkit-transform" ), //only used to rule out box shadow, as it's filled opaque on BB 5 and lower
	nokiaLTE7_3;

function validStyle( prop, value, check_vend ) {
	var div = document.createElement( "div" ),
		uc = function( txt ) {
			return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
		},
		vend_pref = function( vend ) {
			if( vend === "" ) {
				return "";
			} else {
				return  "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
			}
		},
		check_style = function( vend ) {
			var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
				uc_vend = uc( vend ),
				propStyle = uc_vend + ( uc_vend === "" ? prop : uc( prop ) );

			div.setAttribute( "style", vend_prop );

			if ( !!div.style[ propStyle ] ) {
				ret = true;
			}
		},
		check_vends = check_vend ? check_vend : vendors,
		i, ret;

	for( i = 0; i < check_vends.length; i++ ) {
		check_style( check_vends[i] );
	}
	return !!ret;
}

// inline SVG support test
function inlineSVG() {
	// Thanks Modernizr & Erik Dahlstrom
	var w = window,
		svg = !!w.document.createElementNS && !!w.document.createElementNS( "http://www.w3.org/2000/svg", "svg" ).createSVGRect && !( w.opera && navigator.userAgent.indexOf( "Chrome" ) === -1 ),
		support = function( data ) {
			if ( !( data && svg ) ) {
				$( "html" ).addClass( "ui-nosvg" );
			}
		},
		img = new w.Image();

	img.onerror = function() {
		support( false );
	};
	img.onload = function() {
		support( img.width === 1 && img.height === 1 );
	};
	img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
}

function transform3dTest() {
	var mqProp = "transform-3d",
		// Because the `translate3d` test below throws false positives in Android:
		ret = $.mobile.media( "(-" + vendors.join( "-" + mqProp + "),(-" ) + "-" + mqProp + "),(" + mqProp + ")" ),
		el, transforms, t;

	if( ret ) {
		return !!ret;
	}

	el = document.createElement( "div" );
	transforms = {
		// We’re omitting Opera for the time being; MS uses unprefixed.
		"MozTransform": "-moz-transform",
		"transform": "transform"
	};

	fakeBody.append( el );

	for ( t in transforms ) {
		if( el.style[ t ] !== undefined ){
			el.style[ t ] = "translate3d( 100px, 1px, 1px )";
			ret = window.getComputedStyle( el ).getPropertyValue( transforms[ t ] );
		}
	}
	return ( !!ret && ret !== "none" );
}

// Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
function baseTagTest() {
	var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
		base = $( "head base" ),
		fauxEle = null,
		href = "",
		link, rebase;

	if ( !base.length ) {
		base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
	} else {
		href = base.attr( "href" );
	}

	link = $( "" ).prependTo( fakeBody );
	rebase = link[ 0 ].href;
	base[ 0 ].href = href || location.pathname;

	if ( fauxEle ) {
		fauxEle.remove();
	}
	return rebase.indexOf( fauxBase ) === 0;
}

// Thanks Modernizr
function cssPointerEventsTest() {
	var element = document.createElement( "x" ),
		documentElement = document.documentElement,
		getComputedStyle = window.getComputedStyle,
		supports;

	if ( !( "pointerEvents" in element.style ) ) {
		return false;
	}

	element.style.pointerEvents = "auto";
	element.style.pointerEvents = "x";
	documentElement.appendChild( element );
	supports = getComputedStyle &&
	getComputedStyle( element, "" ).pointerEvents === "auto";
	documentElement.removeChild( element );
	return !!supports;
}

function boundingRect() {
	var div = document.createElement( "div" );
	return typeof div.getBoundingClientRect !== "undefined";
}

// non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
// allows for inclusion of IE 6+, including Windows Mobile 7
$.extend( $.mobile, { browser: {} } );
$.mobile.browser.oldIE = (function() {
	var v = 3,
		div = document.createElement( "div" ),
		a = div.all || [];

	do {
		div.innerHTML = "";
	} while( a[0] );

	return v > 4 ? v : !v;
})();

function fixedPosition() {
	var w = window,
		ua = navigator.userAgent,
		platform = navigator.platform,
		// Rendering engine is Webkit, and capture major version
		wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
		wkversion = !!wkmatch && wkmatch[ 1 ],
		ffmatch = ua.match( /Fennec\/([0-9]+)/ ),
		ffversion = !!ffmatch && ffmatch[ 1 ],
		operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ),
		omversion = !!operammobilematch && operammobilematch[ 1 ];

	if(
		// iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5)
		( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1  || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) ||
		// Opera Mini
		( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) ||
		( operammobilematch && omversion < 7458 )	||
		//Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2)
		( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 533 ) ||
		// Firefox Mobile before 6.0 -
		( ffversion && ffversion < 6 ) ||
		// WebOS less than 3
		( "palmGetResource" in window && wkversion && wkversion < 534 )	||
		// MeeGo
		( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) {
		return false;
	}

	return true;
}

$.extend( $.support, {
	cssTransitions: "WebKitTransitionEvent" in window ||
		validStyle( "transition", "height 100ms linear", [ "Webkit", "Moz", "" ] ) &&
		!$.mobile.browser.oldIE && !opera,

	// Note, Chrome for iOS has an extremely quirky implementation of popstate.
	// We've chosen to take the shortest path to a bug fix here for issue #5426
	// See the following link for information about the regex chosen
	// https://developers.google.com/chrome/mobile/docs/user-agent#chrome_for_ios_user-agent
	pushState: "pushState" in history &&
		"replaceState" in history &&
		// When running inside a FF iframe, calling replaceState causes an error
		!( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
		( window.navigator.userAgent.search(/CriOS/) === -1 ),

	mediaquery: $.mobile.media( "only all" ),
	cssPseudoElement: !!propExists( "content" ),
	touchOverflow: !!propExists( "overflowScrolling" ),
	cssTransform3d: transform3dTest(),
	boxShadow: !!propExists( "boxShadow" ) && !bb,
	fixedPosition: fixedPosition(),
	scrollTop: ("pageXOffset" in window ||
		"scrollTop" in document.documentElement ||
		"scrollTop" in fakeBody[ 0 ]) && !webos && !operamini,

	dynamicBaseTag: baseTagTest(),
	cssPointerEvents: cssPointerEventsTest(),
	boundingRect: boundingRect(),
	inlineSVG: inlineSVG
});

fakeBody.remove();

// $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
// or that generally work better browsing in regular http for full page refreshes (Opera Mini)
// Note: This detection below is used as a last resort.
// We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
nokiaLTE7_3 = (function() {

	var ua = window.navigator.userAgent;

	//The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
	return ua.indexOf( "Nokia" ) > -1 &&
			( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
			ua.indexOf( "AppleWebKit" ) > -1 &&
			ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
})();

// Support conditions that must be met in order to proceed
// default enhanced qualifications are media query support OR IE 7+

$.mobile.gradeA = function() {
	return ( ( $.support.mediaquery && $.support.cssPseudoElement ) || $.mobile.browser.oldIE && $.mobile.browser.oldIE >= 8 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null );
};

$.mobile.ajaxBlacklist =
			// BlackBerry browsers, pre-webkit
			window.blackberry && !window.WebKitPoint ||
			// Opera Mini
			operamini ||
			// Symbian webkits pre 7.3
			nokiaLTE7_3;

// Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
// to render the stylesheets when they're referenced before this script, as we'd recommend doing.
// This simply reappends the CSS in place, which for some reason makes it apply
if ( nokiaLTE7_3 ) {
	$(function() {
		$( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
	});
}

// For ruling out shadows via css
if ( !$.support.boxShadow ) {
	$( "html" ).addClass( "ui-noboxshadow" );
}

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");
<|endoftext|>


<commit_before>'use strict';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import moment from 'moment';
import { queryKeyValue, external_url_map } from '../globals';
import { getAffiliationName } from '../../libs/get_affiliation_name';
import { sortListByDate } from '../../libs/helpers/sort';

var _ = require('underscore');

import PopOverComponent from '../../libs/bootstrap/popover';

// Display in-progress or provisional interpretations associated with variant
var CurationRecordCurator = module.exports.CurationRecordCurator = createReactClass({
    propTypes: {
        calculatedPathogenicity: PropTypes.string,
        data: PropTypes.object, // ClinVar data payload
        interpretationUuid: PropTypes.string,
        interpretation: PropTypes.object,
        session: PropTypes.object,
        affiliation: PropTypes.object
    },

    getInitialState() {
        return {
            variant: this.props.data,
            calculatedPathogenicity: this.props.calculatedPathogenicity,
            interpretationUuid: this.props.interpretationUuid,
            interpretation: this.props.interpretation ? this.props.interpretation : null // parent interpretation object
        };
    },

    componentWillReceiveProps(nextProps) {
        // this block is for handling props and states when props (external data) is updated after the initial load/rendering
        // when props are updated, update the parent interpreatation object, if applicable
        if (typeof nextProps.interpretation !== undefined && !_.isEqual(nextProps.interpretation, this.props.interpretation)) {
            this.setState({interpretation: nextProps.interpretation, interpretationUuid: nextProps.interpretationUuid});
        }
        if (typeof nextProps.calculatedPathogenicity !== undefined && nextProps.calculatedPathogenicity !== this.props.calculatedPathogenicity) {
            this.setState({calculatedPathogenicity: nextProps.calculatedPathogenicity});
        }
    },

    // Sort interpretation array, and move current user's as the first element
    getInterpretations(data, session, affiliation) {
        let myInterpretation = null, affiliatedInterpretation = null;
        let otherInterpretations = [];
        if (data && data.associatedInterpretations && data.associatedInterpretations.length) {
            for (let interpretation of data.associatedInterpretations) {
                if (interpretation.affiliation && affiliation && interpretation.affiliation === affiliation.affiliation_id) {
                    affiliatedInterpretation = interpretation;
                } else if (!interpretation.affiliation && !affiliation && interpretation.submitted_by.uuid === session.user_properties.uuid) {
                    myInterpretation = interpretation;
                } else {
                    otherInterpretations.push(interpretation);
                }
            }
        }
        return {
            affiliatedInterpretation: affiliatedInterpretation,
            myInterpretation: myInterpretation,
            otherInterpretations: otherInterpretations
        };
    },

    goToInterpretationPage(e) {
        e.preventDefault(); e.stopPropagation();

        let interpretationData = this.getInterpretations(this.props.data, this.props.session, this.props.affiliation);
        let uuid = interpretationData.affiliatedInterpretation ? interpretationData.affiliatedInterpretation.uuid : interpretationData.myInterpretation.uuid;
        let selectedTab = queryKeyValue('tab', window.location.href);
        let selectedSubtab = queryKeyValue('subtab', window.location.href);
        let url = '/variant-central/?edit=true&variant=' + this.props.data.uuid + '&interpretation=' + uuid + (selectedTab ? '&tab=' + selectedTab : '') + (selectedSubtab ? '&subtab=' + selectedSubtab : '');
        window.location.href = url;
    },

    /**
     * Method to display classification tag/label in the interpretation header
     * @param {string} status - The status of a given classification in an interpretation
     */
    renderClassificationStatusTag(classification) {
        let status = classification.classificationStatus;
        let snapshots = classification.associatedInterpretationSnapshots && classification.associatedInterpretationSnapshots.length ? classification.associatedInterpretationSnapshots : [];
        let filteredSnapshots = [];
        // Determine whether the classification had been previously approved
        if (snapshots && snapshots.length) {
            filteredSnapshots = snapshots.filter(snapshot => {
                return snapshot.approvalStatus === 'Approved' && snapshot.resourceType === 'interpretation';
            });
            // The "In progress" label shouldn't be shown after any given number of Provisional/Approval had been saved
            if (status === 'In progress') {
                let sortedSnapshots = sortListByDate(snapshots, 'date_created');
                if (sortedSnapshots[0].approvalStatus === 'Provisioned') {
                    if (filteredSnapshots.length) {
                        return (
                            APPROVEDNEW PROVISIONAL
                        );
                    } else {
                        return PROVISIONAL;
                    }
                } else if (sortedSnapshots[0].approvalStatus === 'Approved') {
                    return APPROVED;
                }
            } else {
                if (status === 'Provisional') {
                    if (filteredSnapshots.length) {
                        return (
                            APPROVEDNEW PROVISIONAL
                        );
                    } else {
                        return PROVISIONAL;
                    }
                } else if (status === 'Approved') {
                    return APPROVED;
                }
            }
        } else {
            if (status === 'In progress') {
                return IN PROGRESS;
            }
        }
    },

    /**
     * Method to render the header of a given classification in the interpretation header
     * @param {object} classification - A given classification in an interpretation
     */
    renderClassificationHeader(classification) {
        return (

                Provisional/Approved Status:

                    {classification && classification[0].classificationStatus ?
                        this.renderClassificationStatusTag(classification[0])
                        :
                        None
                    }

        );
    },

    renderSummaryStatus(classification) {
        if (classification && classification[0].classificationStatus && classification[0].classificationStatus === 'In progress') {
            return NEW SAVED SUMMARY;
        }
    },

    render() {
        let variant = this.props.data;
        let session = this.props.session;
        let interpretationUuid = this.state.interpretationUuid;
        let affiliation = this.props.affiliation;

        let sortedInterpretations = variant && variant.associatedInterpretations && variant.associatedInterpretations.length ? this.getInterpretations(variant, session, affiliation) : null;
        let myInterpretation = this.state.interpretation ? this.state.interpretation
            : (sortedInterpretations && sortedInterpretations.affiliatedInterpretation ? sortedInterpretations.affiliatedInterpretation
                : (sortedInterpretations && sortedInterpretations.myInterpretation ? sortedInterpretations.myInterpretation : null));
        let otherInterpretations = sortedInterpretations && sortedInterpretations.otherInterpretations.length ? sortedInterpretations.otherInterpretations : null;
        let calculatedPathogenicity = this.state.calculatedPathogenicity ? this.state.calculatedPathogenicity
            : (myInterpretation && myInterpretation.provisional_variant && myInterpretation.provisional_variant.length ? myInterpretation.provisional_variant[0].autoClassification : 'None');
        let modifiedPathogenicity = myInterpretation && myInterpretation.provisional_variant && myInterpretation.provisional_variant.length && myInterpretation.provisional_variant[0].alteredClassification ?
            myInterpretation.provisional_variant[0].alteredClassification : 'None';
        let self = this;

        return (

                    {interpretationUuid ?

My Interpretation

                            {myInterpretation ?

Disease:
                                        {myInterpretation && myInterpretation.disease ?

                                                {myInterpretation.disease.term}

                                                {!myInterpretation.disease.freetext ?

                                                        (
                                                        {myInterpretation.disease.diseaseId.replace('_', ':')}
                                                        {myInterpretation.disease.description && myInterpretation.disease.description.length ?
                                                            ,
                                                                <PopOverComponent popOverWrapperClass="interpretation-disease-description"
                                                                    actuatorTitle="View definition" popOverRef={ref => (this.popoverDesc = ref)}>
                                                                    {myInterpretation.disease.description}
                                                                </PopOverComponent>

                                                            : null}
                                                        )

                                                    :

                                                        (
                                                        {myInterpretation.disease.phenotypes && myInterpretation.disease.phenotypes.length ?
                                                            <PopOverComponent popOverWrapperClass="gdm-disease-phenotypes"
                                                                actuatorTitle="View HPO term(s)" popOverRef={ref => (this.popoverPhenotypes = ref)}>
                                                                {myInterpretation.disease.phenotypes.join(', ')}
                                                            </PopOverComponent>
                                                            : null}
                                                        {myInterpretation.disease.description && myInterpretation.disease.description.length ?
                                                            {myInterpretation.disease.phenotypes && myInterpretation.disease.phenotypes.length ? ,  : null}
                                                                <PopOverComponent popOverWrapperClass="interpretation-disease-description"
                                                                    actuatorTitle="View definition" popOverRef={ref => (this.popoverDesc = ref)}>
                                                                    {myInterpretation.disease.description}
                                                                </PopOverComponent>

                                                            : null}
                                                        )

                                                }

                                            :
                                            Not associated
                                        }

Calculated Pathogenicity: {calculatedPathogenicity}

Modified Pathogenicity: {modifiedPathogenicity}

                                    {myInterpretation.provisional_variant ? this.renderClassificationHeader(myInterpretation.provisional_variant) : null}

                                        {myInterpretation.provisional_variant ?
                                            Interpretation Last Saved: {moment(myInterpretation.provisional_variant.last_modified).format("YYYY MMM DD, h:mm a")}
                                            : null}
                                        {myInterpretation.provisional_variant ? this.renderSummaryStatus(myInterpretation.provisional_variant) : null}

                                : null}

                        :

All Existing Interpretations

                            {myInterpretation ?

                                                {myInterpretation.disease ? {myInterpretation.disease.term} : No disease}
                                                {myInterpretation.modeInheritance ?
                                                    -
                                                        {myInterpretation.modeInheritance.indexOf('(HP:') === -1 ?
                                                            {myInterpretation.modeInheritance}
                                                            :
                                                            {myInterpretation.modeInheritance.substr(0, myInterpretation.modeInheritance.indexOf('(HP:')-1)}
                                                        }
                                                        ,

                                                    :
                                                    ,
                                                }

                                                    {myInterpretation.affiliation ?
                                                        {getAffiliationName(myInterpretation.affiliation)},
                                                        :
                                                        {myInterpretation.submitted_by.title},
                                                    }

                                                    {myInterpretation.provisional_variant && myInterpretation.provisional_variant[0].alteredClassification ?
                                                        {myInterpretation.provisional_variant[0].alteredClassification},   : null}

                                                {myInterpretation.provisional_variant ?
                                                    last saved: {moment(myInterpretation.provisional_variant.last_modified).format("YYYY MMM DD, h:mm a")}
                                                    : null}
                                                {myInterpretation.provisional_variant ? this.renderClassificationHeader(myInterpretation.provisional_variant) : null}

                                : null}
                            {otherInterpretations && otherInterpretations.length ?

                                    {otherInterpretations.map(function(interpretation, i) {
                                        return (

                                                    {interpretation.disease ? {interpretation.disease.term} : No disease}
                                                    {interpretation.modeInheritance ?
                                                        -
                                                            {interpretation.modeInheritance.indexOf('(HP:') === -1 ?
                                                                {interpretation.modeInheritance}
                                                                :
                                                                {interpretation.modeInheritance.substr(0, interpretation.modeInheritance.indexOf('(HP:')-1)}
                                                            }
                                                            ,

                                                        :
                                                        ,
                                                    }

                                                        {interpretation.affiliation ?
                                                            {getAffiliationName(interpretation.affiliation)},
                                                            :
                                                            {interpretation.submitted_by.title },
                                                        }

                                                        {interpretation.provisional_variant && interpretation.provisional_variant[0].alteredClassification ?
                                                            {interpretation.provisional_variant[0].alteredClassification},  : null}

                                                    {interpretation.provisional_variant ?
                                                        last saved: {moment(interpretation.provisional_variant.last_modified).format("YYYY MMM DD, h:mm a")}
                                                        : null}
                                                    {interpretation.provisional_variant ? self.renderClassificationHeader(interpretation.provisional_variant) : null}

                                        );
                                    })}

                                : null}

                    }

        );
    }
});
<commit_msg>Removed the rendering of other interpretations from the header since all existing interpretations are now shown on the Basic Info tab<commit_after>'use strict';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import moment from 'moment';
import { queryKeyValue, external_url_map } from '../globals';
import { getAffiliationName } from '../../libs/get_affiliation_name';
import { sortListByDate } from '../../libs/helpers/sort';

var _ = require('underscore');

import PopOverComponent from '../../libs/bootstrap/popover';

// Display in-progress or provisional interpretations associated with variant
var CurationRecordCurator = module.exports.CurationRecordCurator = createReactClass({
    propTypes: {
        calculatedPathogenicity: PropTypes.string,
        data: PropTypes.object, // ClinVar data payload
        interpretationUuid: PropTypes.string,
        interpretation: PropTypes.object,
        session: PropTypes.object,
        affiliation: PropTypes.object
    },

    getInitialState() {
        return {
            variant: this.props.data,
            calculatedPathogenicity: this.props.calculatedPathogenicity,
            interpretationUuid: this.props.interpretationUuid,
            interpretation: this.props.interpretation ? this.props.interpretation : null // parent interpretation object
        };
    },

    componentWillReceiveProps(nextProps) {
        // this block is for handling props and states when props (external data) is updated after the initial load/rendering
        // when props are updated, update the parent interpreatation object, if applicable
        if (typeof nextProps.interpretation !== undefined && !_.isEqual(nextProps.interpretation, this.props.interpretation)) {
            this.setState({interpretation: nextProps.interpretation, interpretationUuid: nextProps.interpretationUuid});
        }
        if (typeof nextProps.calculatedPathogenicity !== undefined && nextProps.calculatedPathogenicity !== this.props.calculatedPathogenicity) {
            this.setState({calculatedPathogenicity: nextProps.calculatedPathogenicity});
        }
    },

    // Sort interpretation array, and move current user's as the first element
    getInterpretations(data, session, affiliation) {
        let myInterpretation = null, affiliatedInterpretation = null;
        let otherInterpretations = [];
        if (data && data.associatedInterpretations && data.associatedInterpretations.length) {
            for (let interpretation of data.associatedInterpretations) {
                if (interpretation.affiliation && affiliation && interpretation.affiliation === affiliation.affiliation_id) {
                    affiliatedInterpretation = interpretation;
                } else if (!interpretation.affiliation && !affiliation && interpretation.submitted_by.uuid === session.user_properties.uuid) {
                    myInterpretation = interpretation;
                } else {
                    otherInterpretations.push(interpretation);
                }
            }
        }
        return {
            affiliatedInterpretation: affiliatedInterpretation,
            myInterpretation: myInterpretation,
            otherInterpretations: otherInterpretations
        };
    },

    goToInterpretationPage(e) {
        e.preventDefault(); e.stopPropagation();

        let interpretationData = this.getInterpretations(this.props.data, this.props.session, this.props.affiliation);
        let uuid = interpretationData.affiliatedInterpretation ? interpretationData.affiliatedInterpretation.uuid : interpretationData.myInterpretation.uuid;
        let selectedTab = queryKeyValue('tab', window.location.href);
        let selectedSubtab = queryKeyValue('subtab', window.location.href);
        let url = '/variant-central/?edit=true&variant=' + this.props.data.uuid + '&interpretation=' + uuid + (selectedTab ? '&tab=' + selectedTab : '') + (selectedSubtab ? '&subtab=' + selectedSubtab : '');
        window.location.href = url;
    },

    /**
     * Method to display classification tag/label in the interpretation header
     * @param {string} status - The status of a given classification in an interpretation
     */
    renderClassificationStatusTag(classification) {
        let status = classification.classificationStatus;
        let snapshots = classification.associatedInterpretationSnapshots && classification.associatedInterpretationSnapshots.length ? classification.associatedInterpretationSnapshots : [];
        let filteredSnapshots = [];
        // Determine whether the classification had been previously approved
        if (snapshots && snapshots.length) {
            filteredSnapshots = snapshots.filter(snapshot => {
                return snapshot.approvalStatus === 'Approved' && snapshot.resourceType === 'interpretation';
            });
            // The "In progress" label shouldn't be shown after any given number of Provisional/Approval had been saved
            if (status === 'In progress') {
                let sortedSnapshots = sortListByDate(snapshots, 'date_created');
                if (sortedSnapshots[0].approvalStatus === 'Provisioned') {
                    if (filteredSnapshots.length) {
                        return (
                            APPROVEDNEW PROVISIONAL
                        );
                    } else {
                        return PROVISIONAL;
                    }
                } else if (sortedSnapshots[0].approvalStatus === 'Approved') {
                    return APPROVED;
                }
            } else {
                if (status === 'Provisional') {
                    if (filteredSnapshots.length) {
                        return (
                            APPROVEDNEW PROVISIONAL
                        );
                    } else {
                        return PROVISIONAL;
                    }
                } else if (status === 'Approved') {
                    return APPROVED;
                }
            }
        } else {
            if (status === 'In progress') {
                return IN PROGRESS;
            }
        }
    },

    /**
     * Method to render the header of a given classification in the interpretation header
     * @param {object} classification - A given classification in an interpretation
     */
    renderClassificationHeader(classification) {
        return (

                Provisional/Approved Status:

                    {classification && classification[0].classificationStatus ?
                        this.renderClassificationStatusTag(classification[0])
                        :
                        None
                    }

        );
    },

    renderSummaryStatus(classification) {
        if (classification && classification[0].classificationStatus && classification[0].classificationStatus === 'In progress') {
            return NEW SAVED SUMMARY;
        }
    },

    render() {
        let variant = this.props.data;
        let session = this.props.session;
        let interpretationUuid = this.state.interpretationUuid;
        let affiliation = this.props.affiliation;

        let sortedInterpretations = variant && variant.associatedInterpretations && variant.associatedInterpretations.length ? this.getInterpretations(variant, session, affiliation) : null;
        let myInterpretation = this.state.interpretation ? this.state.interpretation
            : (sortedInterpretations && sortedInterpretations.affiliatedInterpretation ? sortedInterpretations.affiliatedInterpretation
                : (sortedInterpretations && sortedInterpretations.myInterpretation ? sortedInterpretations.myInterpretation : null));
        let calculatedPathogenicity = this.state.calculatedPathogenicity ? this.state.calculatedPathogenicity
            : (myInterpretation && myInterpretation.provisional_variant && myInterpretation.provisional_variant.length ? myInterpretation.provisional_variant[0].autoClassification : 'None');
        let modifiedPathogenicity = myInterpretation && myInterpretation.provisional_variant && myInterpretation.provisional_variant.length && myInterpretation.provisional_variant[0].alteredClassification ?
            myInterpretation.provisional_variant[0].alteredClassification : 'Not provided';
        let self = this;

        return (

My Interpretation

                        {myInterpretation ?

Disease:
                                                {myInterpretation && myInterpretation.disease ?

                                                        {myInterpretation.disease.term}

                                                        {!myInterpretation.disease.freetext ?

                                                                (
                                                                {myInterpretation.disease.diseaseId.replace('_', ':')}
                                                                {myInterpretation.disease.description && myInterpretation.disease.description.length ?
                                                                    ,
                                                                        <PopOverComponent popOverWrapperClass="interpretation-disease-description"
                                                                            actuatorTitle="View definition" popOverRef={ref => (this.popoverDesc = ref)}>
                                                                            {myInterpretation.disease.description}
                                                                        </PopOverComponent>

                                                                    : null}
                                                                )

                                                            :

                                                                (
                                                                {myInterpretation.disease.phenotypes && myInterpretation.disease.phenotypes.length ?
                                                                    <PopOverComponent popOverWrapperClass="gdm-disease-phenotypes"
                                                                        actuatorTitle="View HPO term(s)" popOverRef={ref => (this.popoverPhenotypes = ref)}>
                                                                        {myInterpretation.disease.phenotypes.join(', ')}
                                                                    </PopOverComponent>
                                                                    : null}
                                                                {myInterpretation.disease.description && myInterpretation.disease.description.length ?
                                                                    {myInterpretation.disease.phenotypes && myInterpretation.disease.phenotypes.length ? ,  : null}
                                                                        <PopOverComponent popOverWrapperClass="interpretation-disease-description"
                                                                            actuatorTitle="View definition" popOverRef={ref => (this.popoverDesc = ref)}>
                                                                            {myInterpretation.disease.description}
                                                                        </PopOverComponent>

                                                                    : null}
                                                                )

                                                        }

                                                    :
                                                    Not provided
                                                }

Calculated Pathogenicity: {calculatedPathogenicity}

Modified Pathogenicity: {modifiedPathogenicity}

                                            {myInterpretation.provisional_variant ? this.renderClassificationHeader(myInterpretation.provisional_variant) : null}

                                                {myInterpretation.provisional_variant ?
                                                    Interpretation Last Saved: {moment(myInterpretation.provisional_variant[0].last_modified).format("YYYY MMM DD, h:mm a")}
                                                    : null}
                                                {myInterpretation.provisional_variant ? this.renderSummaryStatus(myInterpretation.provisional_variant) : null}

                                        {!interpretationUuid ?

                                            : null}

                            : null}

{/*

My Existing Interpretation

                            {myInterpretation ?

                                                {myInterpretation.disease ? {myInterpretation.disease.term} : No disease}
                                                {myInterpretation.modeInheritance ?
                                                    -
                                                        {myInterpretation.modeInheritance.indexOf('(HP:') === -1 ?
                                                            {myInterpretation.modeInheritance}
                                                            :
                                                            {myInterpretation.modeInheritance.substr(0, myInterpretation.modeInheritance.indexOf('(HP:')-1)}
                                                        }
                                                        ,

                                                    :
                                                    ,
                                                }

                                                    {myInterpretation.affiliation ?
                                                        {getAffiliationName(myInterpretation.affiliation)},
                                                        :
                                                        {myInterpretation.submitted_by.title},
                                                    }

                                                    {myInterpretation.provisional_variant && myInterpretation.provisional_variant[0].alteredClassification ?
                                                        {myInterpretation.provisional_variant[0].alteredClassification},   : null}

                                                {myInterpretation.provisional_variant ?
                                                    last saved: {moment(myInterpretation.provisional_variant.last_modified).format("YYYY MMM DD, h:mm a")}
                                                    : null}
                                                {myInterpretation.provisional_variant ? this.renderClassificationHeader(myInterpretation.provisional_variant) : null}

                                : null}

*/}

        );
    }
});
<|endoftext|>


<commit_before>
//positioning settings
var width = 740;
var height = 2800;
var pad = { left: 10, right: 0, top: 60, bottom: 10 };
var vertSpace = 45;
var xName = 20;

var xPrct = 520;
var xChange = 640;
var xNumF = 260;
var xTotal = 380;

var rectW = 80;
var rectH = 35;
var yHeader = 20;
var ySubHead = 40;

//define scales
var sizeNumF = d3.scale.linear().domain([10, 100]).range([11, 30]);
var sizeTotal = d3.scale.linear().domain([50, 500]).range([11, 30]);
var changeH = d3.scale.linear().domain([0, 13]).range([0, 18]);
var prctBar = d3.scale.linear().domain([0, 32]).range([0, 25]);

//create container elements
var svg = d3.select(".top25").append("svg")
            .attr("width", width + pad.left + pad.right)
            .attr("height", height + pad.top + pad.bottom);

//create header (background) tiles
var headerTiles = svg.append("g").attr("class", "headerTile").attr("transform", "translate(" + pad.left + ",0)");
var activeTile = headerTiles.append("rect").attr({x: xNumF-45, y: 7, width: 90, height: 43, fill: "white", class: "numF"}).on("click", rankNumF);
headerTiles.append("rect").attr({x: xTotal-45, y: 7, width: 90, height: 43, fill: "white", class: "total"}).on("click", rankTotal);
headerTiles.append("rect").attr({x: xPrct-60,  y: 7, height: 43, width: 120, fill: "white", class: "prct"}).on("click", rankPrct);
headerTiles.append("rect").attr({x: xChange-60, y: 7, width: 120, height: 43, fill: "white", class: "change"}).on("click", rankChange);
headerTiles.selectAll("rect").style("cursor", "pointer");
activeTile.style("fill", "#eee");
rankNumF();

//create header text
var header = svg.append("g").attr("class", "header").attr("transform", "translate(" + pad.left + "," + yHeader + ")");
header.append("text").text("Sci. Majors").attr("x", xPrct).on("click", rankPrct);
header.append("text").text("Researchers").attr("x", xChange).on("click", rankChange);
header.append("text").text("Explicit").attr("x", xNumF).on("click", rankNumF);
header.append("text").text("Implicit").attr("x", xTotal).on("click", rankTotal);
var subHead = svg.append("g").attr("class", "subHead").attr("transform", "translate(" + pad.left + "," + ySubHead + ")");
subHead.append("text").text("% Women").attr("x", xPrct).on("click", rankPrct);
subHead.append("text").text("% Women").attr("x", xChange).on("click", rankChange);
subHead.append("text").text("Stereotypes").attr("x", xNumF).on("click", rankNumF);
subHead.append("text").text("Stereotypes").attr("x", xTotal).on("click", rankTotal);
header.selectAll("text").style("cursor", "pointer");
subHead.selectAll("text").style("cursor", "pointer");

//event handlers for resorting the rows
function rankPrct() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .prct");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankPrct - 0.5) + ")"; });
}
function rankChange() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .change");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankChange - 0.5) + ")"; });
}
function rankNumF() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .numF");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankNumF - 0.5) + ")"; });
}
function rankTotal() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .total");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankTotal - 0.5) + ")"; });
}

//create header line and content SVG group
svg.append("line").attr({ x1: 0, x2: width, y1: 2, y2: 2}).style({"stroke-width": 2, stroke: "#222"});
svg.append("line").attr({ x1: 0, x2: width, y1: pad.top-5, y2: pad.top-5}).style({"stroke-width": 2, stroke: "#222"});
var g = svg.append("g").attr("transform", "translate(" + pad.left + ", " + pad.top + ")");

//load data...
d3.csv("data/top25.csv", function(data) {

  ///////////////////////////////
  //  FIXED POSITION ELEMENTS  //
  ///////////////////////////////

  //add lines in between
  g.selectAll("line.sep").data(data).enter().append("line")
    .attr({ x1: -pad.left, x2: width-pad.left, class: "sep"})
    .attr("y1", function(d) { return vertSpace*d.rank; })
    .attr("y2", function(d) { return vertSpace*d.rank; })
    .style({"stroke-width": 0.5, stroke: "#888"});

  //ranking text
  g.selectAll("text.rank").data(data).enter().append("text")
    .attr("class", "rank")
    .text(function(d) { return d.rank + "."; })
    .attr("y", function(d) { return vertSpace*(d.rank - 0.5); })
    .attr("x", 5);

  /////////////////////////////////
  //  DYNAMIC POSITION ELEMENTS  //
  /////////////////////////////////

  //add grouping elements
  var rows = g.selectAll(".rows")
              .data(data).enter()
              .append("g")
              .attr("class", "row")
              .attr("transform", function(d) {
                return "translate(0," + vertSpace*(+d.rank - 0.5) + ")";
              });

  //for each school...
  rows.each(function(d) {

    //get a D3 selection of the g SVG element
    var s = d3.select(this);

    //school name
    s.append("text")
      .attr("class", "name")
      .text(function(d) { return d.abbrev; })
      .attr("x", xName);

    //percent women text
    s.append("text")
      .attr("class", "prct")
      .text(function(d) { return d.prctStr; })
      .attr("x", xPrct)
      .style("fill", "#333")
      .style("font-size", 25);

    //change percent text
    s.append("text")
      .attr("class", "change")
      .text(function(d) { return d.changeStr; })
      .attr("x", xChange)
      .style("font-size", 25);

    //number women text
    s.append("text")
      .attr("class", "numF")
      .text(function(d) { return d.numF; })
      .attr("x", xNumF)
      .style("font-size", 25);
      //.style("font-size", function(d) { return sizeNumF(d.numF); });

    //total number text
    s.append("text")
      .attr("class", "total")
      .text(function(d) { return d.total; })
      .attr("x", xTotal)
      .style("font-size", 25);
      //.style("font-size", function(d) { return sizeTotal(d.total); });

  });

});
<commit_msg>Update top25.js<commit_after>
//positioning settings
var width = 740;
var height = 2900;
var pad = { left: 10, right: 0, top: 60, bottom: 10 };
var vertSpace = 45;
var xName = 20;

var xPrct = 520;
var xChange = 640;
var xNumF = 260;
var xTotal = 380;

var rectW = 80;
var rectH = 35;
var yHeader = 20;
var ySubHead = 40;

//define scales
var sizeNumF = d3.scale.linear().domain([10, 100]).range([11, 30]);
var sizeTotal = d3.scale.linear().domain([50, 500]).range([11, 30]);
var changeH = d3.scale.linear().domain([0, 13]).range([0, 18]);
var prctBar = d3.scale.linear().domain([0, 32]).range([0, 25]);

//create container elements
var svg = d3.select(".top25").append("svg")
            .attr("width", width + pad.left + pad.right)
            .attr("height", height + pad.top + pad.bottom);

//create header (background) tiles
var headerTiles = svg.append("g").attr("class", "headerTile").attr("transform", "translate(" + pad.left + ",0)");
var activeTile = headerTiles.append("rect").attr({x: xNumF-45, y: 7, width: 90, height: 43, fill: "white", class: "numF"}).on("click", rankNumF);
headerTiles.append("rect").attr({x: xTotal-45, y: 7, width: 90, height: 43, fill: "white", class: "total"}).on("click", rankTotal);
headerTiles.append("rect").attr({x: xPrct-60,  y: 7, height: 43, width: 120, fill: "white", class: "prct"}).on("click", rankPrct);
headerTiles.append("rect").attr({x: xChange-60, y: 7, width: 120, height: 43, fill: "white", class: "change"}).on("click", rankChange);
headerTiles.selectAll("rect").style("cursor", "pointer");
activeTile.style("fill", "#eee");
rankNumF();

//create header text
var header = svg.append("g").attr("class", "header").attr("transform", "translate(" + pad.left + "," + yHeader + ")");
header.append("text").text("Sci. Majors").attr("x", xPrct).on("click", rankPrct);
header.append("text").text("Researchers").attr("x", xChange).on("click", rankChange);
header.append("text").text("Explicit").attr("x", xNumF).on("click", rankNumF);
header.append("text").text("Implicit").attr("x", xTotal).on("click", rankTotal);
var subHead = svg.append("g").attr("class", "subHead").attr("transform", "translate(" + pad.left + "," + ySubHead + ")");
subHead.append("text").text("% Women").attr("x", xPrct).on("click", rankPrct);
subHead.append("text").text("% Women").attr("x", xChange).on("click", rankChange);
subHead.append("text").text("Stereotypes").attr("x", xNumF).on("click", rankNumF);
subHead.append("text").text("Stereotypes").attr("x", xTotal).on("click", rankTotal);
header.selectAll("text").style("cursor", "pointer");
subHead.selectAll("text").style("cursor", "pointer");

//event handlers for resorting the rows
function rankPrct() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .prct");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankPrct - 0.5) + ")"; });
}
function rankChange() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .change");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankChange - 0.5) + ")"; });
}
function rankNumF() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .numF");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankNumF - 0.5) + ")"; });
}
function rankTotal() {
  activeTile.style("fill", "white");
  activeTile = d3.select(".headerTile .total");
  activeTile.style("fill", "#eee");
  d3.selectAll("g.row")
    .transition().duration(800)
    .attr("transform", function(d) { return "translate(0," + vertSpace*(+d.rankTotal - 0.5) + ")"; });
}

//create header line and content SVG group
svg.append("line").attr({ x1: 0, x2: width, y1: 2, y2: 2}).style({"stroke-width": 2, stroke: "#222"});
svg.append("line").attr({ x1: 0, x2: width, y1: pad.top-5, y2: pad.top-5}).style({"stroke-width": 2, stroke: "#222"});
var g = svg.append("g").attr("transform", "translate(" + pad.left + ", " + pad.top + ")");

//load data...
d3.csv("data/top25.csv", function(data) {

  ///////////////////////////////
  //  FIXED POSITION ELEMENTS  //
  ///////////////////////////////

  //add lines in between
  g.selectAll("line.sep").data(data).enter().append("line")
    .attr({ x1: -pad.left, x2: width-pad.left, class: "sep"})
    .attr("y1", function(d) { return vertSpace*d.rank; })
    .attr("y2", function(d) { return vertSpace*d.rank; })
    .style({"stroke-width": 0.5, stroke: "#888"});

  //ranking text
  g.selectAll("text.rank").data(data).enter().append("text")
    .attr("class", "rank")
    .text(function(d) { return d.rank + "."; })
    .attr("y", function(d) { return vertSpace*(d.rank - 0.5); })
    .attr("x", 5);

  /////////////////////////////////
  //  DYNAMIC POSITION ELEMENTS  //
  /////////////////////////////////

  //add grouping elements
  var rows = g.selectAll(".rows")
              .data(data).enter()
              .append("g")
              .attr("class", "row")
              .attr("transform", function(d) {
                return "translate(0," + vertSpace*(+d.rank - 0.5) + ")";
              });

  //for each school...
  rows.each(function(d) {

    //get a D3 selection of the g SVG element
    var s = d3.select(this);

    //school name
    s.append("text")
      .attr("class", "name")
      .text(function(d) { return d.abbrev; })
      .attr("x", xName);

    //percent women text
    s.append("text")
      .attr("class", "prct")
      .text(function(d) { return d.prctStr; })
      .attr("x", xPrct)
      .style("fill", "#333")
      .style("font-size", 25);

    //change percent text
    s.append("text")
      .attr("class", "change")
      .text(function(d) { return d.changeStr; })
      .attr("x", xChange)
      .style("font-size", 25);

    //number women text
    s.append("text")
      .attr("class", "numF")
      .text(function(d) { return d.numF; })
      .attr("x", xNumF)
      .style("font-size", 25);
      //.style("font-size", function(d) { return sizeNumF(d.numF); });

    //total number text
    s.append("text")
      .attr("class", "total")
      .text(function(d) { return d.total; })
      .attr("x", xTotal)
      .style("font-size", 25);
      //.style("font-size", function(d) { return sizeTotal(d.total); });

  });

});
<|endoftext|>


<commit_before>// (c) 2016 osmcz-app, https://github.com/osmcz/osmcz

var osmcz = osmcz || {};
osmcz.openingHoursService = {};
osmcz.openingHoursService.getHtml = function (v) {
    var opening_hours = require('opening_hours');

    if (!v)
        return [];

    var oh = new opening_hours(v);

    // Truncate time values from given date. Set it to 00:00.0000
    function truncTime(v) {
        return new Date(v.getFullYear(), v.getMonth(), v.getDate(), 0, 0, 0, 0)
    }

    // Format given time as time string as HH:MI
    function formatTimeD(d) {
        return ("00" + d.getHours()).slice(-2) + ":" + ("00" + d.getMinutes()).slice(-2);
    }

    // Format given hour and minutes values as time string as HH:MI
    function formatTimeHM(h, m) {
        return ("00" + h).slice(-2) + ":" + ("00" + m).slice(-2);
    }

    // Shift to requested day forward or backward
    function shiftDay(d, i) {
        return (new Date((d).valueOf() + 1000 * 60 * 60 * 24 * i));
    }

    // Format date as YYYYMMDD
    function getFormatedDate(d) {
        return (d.getFullYear() + ("00" + (d.getMonth() + 1)).slice(-2) + ("00" + d.getDate()).slice(-2)).toString();
    }

    // Return day name. Normal (Mo,Tu...) or special day name like Today
    function getDayName(d) {
        var idxToday = "#" + getFormatedDate(new Date());
        var idxTomorrow = "#" + getFormatedDate(shiftDay((new Date()), 1));

        var days = ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"];
        var specialDays = [];
        specialDays[idxToday] = "Dnes";
        specialDays[idxTomorrow] = "Zítra";

        idx = "#" + getFormatedDate(d);
        if (idx in specialDays)
            return specialDays[idx];

        var day = d.getDay();
        return days[day];
    }

    // Go through opening hours array and prepare oh times for each day
    function splitByDays(oh_array) {
        var ret = [];
        var lastDay = "";

        for (i = 0; i < oh_array.length; i++) {
            var from = oh_array[i][0];
            var to = oh_array[i][1];

            var formatedDayFrom = getFormatedDate(from);
            var formatedDayTo = getFormatedDate(to);
            var diffDays = Math.ceil((to - from) / 1000 / 60 / 60 / 24) // difference by days

            var idx = "#" + formatedDayFrom;

            if (!(idx in ret)) {
                ret[idx] = [];
            }

            if (formatedDayFrom == formatedDayTo) { // the same day
                ret[idx].push(formatTimeD(from) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
            } else if (diffDays == 1) // over midnight
                ret[idx].push(formatTimeD(from) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
            else { // over more days - 24/7
                var tFrom = new Date(from);
                var tTo = new Date(to);
                var idx = "#" + getFormatedDate(tFrom);

                ret[idx].push(formatTimeD(tFrom) + '-' + formatTimeHM(24, 0));

                while (formatedDayFrom != formatedDayTo) {
                    tFrom = shiftDay(tFrom, 1);
                    formatedDayFrom = getFormatedDate(tFrom);
                    idx = "#" + formatedDayFrom;
                    ret[idx] = [];
                    if (formatedDayFrom != formatedDayTo)
                        ret[idx].push(formatTimeHM(0, 0) + '-' + formatTimeHM(24, 0));
                    else
                        ret[idx].push(formatTimeHM(0, 0) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
                }
            }
        }
        return ret;
    }

    // Return formated opening hours table
    function formatWeek(aOH, dFrom, nDays, bVisible) {
        var ret = [];

        var idxDay = new Date(dFrom);
        var formatedDayFrom = getFormatedDate(idxDay);
        var formatedDayTo = getFormatedDate(shiftDay(dFrom, nDays + 1));

        var idx = "#" + formatedDayFrom;

        var clVisible = "";
        if (!bVisible)
            clVisible = 'class="oh-extended" style="display:none"';

        while (formatedDayFrom != formatedDayTo) {
            ret.push('
');

            if (idx in aOH) {
                ret.push('' + getDayName(idxDay) + ': 	' + aOH[idx].join(', ') + '
');
            } else
                ret.push("" + getDayName(idxDay) + ': 	' + "zavřeno" + "
");

            idxDay = shiftDay(idxDay, 1);
            formatedDayFrom = getFormatedDate(idxDay);
            idx = "#" + formatedDayFrom;
        }
        return ret;
    }

    // === Start ===
    var now = new Date();
    var today = truncTime(now);
    var tomorrow = shiftDay(today, 1);
    var intervalStart = shiftDay(today, -1); // we will start on yesterday
    var intervalEnd = shiftDay(today, 10); // plus 10 days should be enough to show week correctly

    // get opening hours grouped by days
    var intervals = splitByDays(oh.getOpenIntervals(intervalStart, intervalEnd));

    // check current state: open, close, last hour
    var currentState = oh.getStateString();
    var nextChangeDate = oh.getNextChange();

    if (nextChangeDate)
        var diffChangeMin = Math.ceil((nextChangeDate - now) / 1000 / 60); // difference to next change of state in minutes
    else
        var diffChangeMin = -1;

    var ohStateFormated = "";
    var ohClass = "";

    switch (currentState) {
        case "open":
            if (diffChangeMin > 0 && diffChangeMin <= 60) {
                ohClass = "ohlasthour";
                ohStateFormated = "poslední hodina";
            } else {
                ohClass = "ohopen";
                ohStateFormated = "otevřeno";
            }
            break;
        case "close":
            ohClass = "ohclosed";
            ohStateFormated = "zavřeno";
            break;
        case "unknown":
            ohClass = "";
            ohStateFormated = "neznámo";
            break;
    }

    // Add toggler class handler
    // see: http://stackoverflow.com/questions/19797064/show-hide-table-rows-using-javascript-classes
    // TODO: fix it!
    $(".toggler").click(function (e) {
        e.preventDefault();
        console.log("toggler");
        $('.oh' + $(this).attr('data-oh')).show();
    });

    // prepare opening hours table
    var ret = [];
    ret.push('
Otevírací hodiny
');
    ret.push(' ');
    ret.push('(' + ohStateFormated + ')');
    ret.push(' ▼
');
    ret.push('
');
    ret = ret.concat(formatWeek(intervals, today, 1, true));
    ret = ret.concat(formatWeek(intervals, shiftDay(today, 2), 5, false));
    ret.push('
');
    return ret;
};

<commit_msg>opening-hours-service: Fix regression - current state on new row<commit_after>// (c) 2016 osmcz-app, https://github.com/osmcz/osmcz

var osmcz = osmcz || {};
osmcz.openingHoursService = {};
osmcz.openingHoursService.getHtml = function (v) {
    var opening_hours = require('opening_hours');

    if (!v)
        return [];

    var oh = new opening_hours(v);

    // Truncate time values from given date. Set it to 00:00.0000
    function truncTime(v) {
        return new Date(v.getFullYear(), v.getMonth(), v.getDate(), 0, 0, 0, 0)
    }

    // Format given time as time string as HH:MI
    function formatTimeD(d) {
        return ("00" + d.getHours()).slice(-2) + ":" + ("00" + d.getMinutes()).slice(-2);
    }

    // Format given hour and minutes values as time string as HH:MI
    function formatTimeHM(h, m) {
        return ("00" + h).slice(-2) + ":" + ("00" + m).slice(-2);
    }

    // Shift to requested day forward or backward
    function shiftDay(d, i) {
        return (new Date((d).valueOf() + 1000 * 60 * 60 * 24 * i));
    }

    // Format date as YYYYMMDD
    function getFormatedDate(d) {
        return (d.getFullYear() + ("00" + (d.getMonth() + 1)).slice(-2) + ("00" + d.getDate()).slice(-2)).toString();
    }

    // Return day name. Normal (Mo,Tu...) or special day name like Today
    function getDayName(d) {
        var idxToday = "#" + getFormatedDate(new Date());
        var idxTomorrow = "#" + getFormatedDate(shiftDay((new Date()), 1));

        var days = ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"];
        var specialDays = [];
        specialDays[idxToday] = "Dnes";
        specialDays[idxTomorrow] = "Zítra";

        idx = "#" + getFormatedDate(d);
        if (idx in specialDays)
            return specialDays[idx];

        var day = d.getDay();
        return days[day];
    }

    // Go through opening hours array and prepare oh times for each day
    function splitByDays(oh_array) {
        var ret = [];
        var lastDay = "";

        for (i = 0; i < oh_array.length; i++) {
            var from = oh_array[i][0];
            var to = oh_array[i][1];

            var formatedDayFrom = getFormatedDate(from);
            var formatedDayTo = getFormatedDate(to);
            var diffDays = Math.ceil((to - from) / 1000 / 60 / 60 / 24) // difference by days

            var idx = "#" + formatedDayFrom;

            if (!(idx in ret)) {
                ret[idx] = [];
            }

            if (formatedDayFrom == formatedDayTo) { // the same day
                ret[idx].push(formatTimeD(from) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
            } else if (diffDays == 1) // over midnight
                ret[idx].push(formatTimeD(from) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
            else { // over more days - 24/7
                var tFrom = new Date(from);
                var tTo = new Date(to);
                var idx = "#" + getFormatedDate(tFrom);

                ret[idx].push(formatTimeD(tFrom) + '-' + formatTimeHM(24, 0));

                while (formatedDayFrom != formatedDayTo) {
                    tFrom = shiftDay(tFrom, 1);
                    formatedDayFrom = getFormatedDate(tFrom);
                    idx = "#" + formatedDayFrom;
                    ret[idx] = [];
                    if (formatedDayFrom != formatedDayTo)
                        ret[idx].push(formatTimeHM(0, 0) + '-' + formatTimeHM(24, 0));
                    else
                        ret[idx].push(formatTimeHM(0, 0) + '-' + formatTimeD(to).replace(/00:00/g, '24:00'));
                }
            }
        }
        return ret;
    }

    // Return formated opening hours table
    function formatWeek(aOH, dFrom, nDays, bVisible) {
        var ret = [];

        var idxDay = new Date(dFrom);
        var formatedDayFrom = getFormatedDate(idxDay);
        var formatedDayTo = getFormatedDate(shiftDay(dFrom, nDays + 1));

        var idx = "#" + formatedDayFrom;

        var clVisible = "";
        if (!bVisible)
            clVisible = 'class="oh-extended" style="display:none"';

        while (formatedDayFrom != formatedDayTo) {
            ret.push('
');

            if (idx in aOH) {
                ret.push('' + getDayName(idxDay) + ': 	' + aOH[idx].join(', ') + '
');
            } else
                ret.push("" + getDayName(idxDay) + ': 	' + "zavřeno" + "
");

            idxDay = shiftDay(idxDay, 1);
            formatedDayFrom = getFormatedDate(idxDay);
            idx = "#" + formatedDayFrom;
        }
        return ret;
    }

    // === Start ===
    var now = new Date();
    var today = truncTime(now);
    var tomorrow = shiftDay(today, 1);
    var intervalStart = shiftDay(today, -1); // we will start on yesterday
    var intervalEnd = shiftDay(today, 10); // plus 10 days should be enough to show week correctly

    // get opening hours grouped by days
    var intervals = splitByDays(oh.getOpenIntervals(intervalStart, intervalEnd));

    // check current state: open, close, last hour
    var currentState = oh.getStateString();
    var nextChangeDate = oh.getNextChange();

    if (nextChangeDate)
        var diffChangeMin = Math.ceil((nextChangeDate - now) / 1000 / 60); // difference to next change of state in minutes
    else
        var diffChangeMin = -1;

    var ohStateFormated = "";
    var ohClass = "";

    switch (currentState) {
        case "open":
            if (diffChangeMin > 0 && diffChangeMin <= 60) {
                ohClass = "ohlasthour";
                ohStateFormated = "poslední hodina";
            } else {
                ohClass = "ohopen";
                ohStateFormated = "otevřeno";
            }
            break;
        case "close":
            ohClass = "ohclosed";
            ohStateFormated = "zavřeno";
            break;
        case "unknown":
            ohClass = "";
            ohStateFormated = "neznámo";
            break;
    }

    // Add toggler class handler
    // see: http://stackoverflow.com/questions/19797064/show-hide-table-rows-using-javascript-classes
    // TODO: fix it!
    $(".toggler").click(function (e) {
        e.preventDefault();
        console.log("toggler");
        $('.oh' + $(this).attr('data-oh')).show();
    });

    // prepare opening hours table
    var ret = [];
    ret.push('
Otevírací hodiny');
    ret.push(' ');
    ret.push('(' + ohStateFormated + ')');
    ret.push(' ▼
');
    ret.push('
');
    ret = ret.concat(formatWeek(intervals, today, 1, true));
    ret = ret.concat(formatWeek(intervals, shiftDay(today, 2), 5, false));
    ret.push('
');
    return ret;
};

<|endoftext|>


<commit_before>// Copyright 2016-2018, University of Colorado Boulder

/**
 *  The 'Systems' screen in the Energy Forms and Changes simulation.
 *
 * @author John Blanco
 * @author Martin Veillette (Berea College)
 * @author Andrew Adare
 */
define( function( require ) {
  'use strict';

  // modules
  var EFACConstants = require( 'ENERGY_FORMS_AND_CHANGES/common/EFACConstants' );
  var energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  var Image = require( 'SCENERY/nodes/Image' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Property = require( 'AXON/Property' );
  var Screen = require( 'JOIST/Screen' );
  var SystemsModel = require( 'ENERGY_FORMS_AND_CHANGES/systems/model/SystemsModel' );
  var SystemsScreenView = require( 'ENERGY_FORMS_AND_CHANGES/systems/view/SystemsScreenView' );

  // strings
  var systemsString = require( 'string!ENERGY_FORMS_AND_CHANGES/systems' );

  // images
  var systemsScreenIcon = require( 'image!ENERGY_FORMS_AND_CHANGES/systems_screen_icon.png' );

  /**
   * @param {Tandem} tandem
   * @constructor
   */
  function SystemsScreen( tandem ) {

    var options = {
      name: systemsString,
      backgroundColorProperty: new Property( EFACConstants.SECOND_SCREEN_BACKGROUND_COLOR ),
      homeScreenIcon: new Image( systemsScreenIcon ),
      tandem: tandem
    };

    Screen.call( this,
      function() {
        return new SystemsModel();
      },
      function( model ) {
        return new SystemsScreenView( model );
      },
      options );
  }

  energyFormsAndChanges.register( 'SystemsScreen', SystemsScreen );

  return inherit( Screen, SystemsScreen );
} );

<commit_msg>Convert to ES6, see https://github.com/phetsims/energy-forms-and-changes/issues/211<commit_after>// Copyright 2016-2019, University of Colorado Boulder

/**
 * The 'Systems' screen in the Energy Forms and Changes simulation.
 *
 * @author John Blanco
 * @author Martin Veillette (Berea College)
 * @author Andrew Adare
 * @author Chris Klusendorf (PhET Interactive Simulations)
 */
define( require => {
  'use strict';

  // modules
  const EFACConstants = require( 'ENERGY_FORMS_AND_CHANGES/common/EFACConstants' );
  const energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  const Image = require( 'SCENERY/nodes/Image' );
  const Property = require( 'AXON/Property' );
  const Screen = require( 'JOIST/Screen' );
  const SystemsModel = require( 'ENERGY_FORMS_AND_CHANGES/systems/model/SystemsModel' );
  const SystemsScreenView = require( 'ENERGY_FORMS_AND_CHANGES/systems/view/SystemsScreenView' );

  // strings
  const systemsString = require( 'string!ENERGY_FORMS_AND_CHANGES/systems' );

  // images
  const systemsScreenIcon = require( 'image!ENERGY_FORMS_AND_CHANGES/systems_screen_icon.png' );

  class SystemsScreen extends Screen {

    /**
     * @param {Tandem} tandem
     */
    constructor( tandem ) {

      const options = {
        name: systemsString,
        backgroundColorProperty: new Property( EFACConstants.SECOND_SCREEN_BACKGROUND_COLOR ),
        homeScreenIcon: new Image( systemsScreenIcon ),
        tandem: tandem
      };

      super( () => new SystemsModel(), model => new SystemsScreenView( model ), options );
    }
  }

  return energyFormsAndChanges.register( 'SystemsScreen', SystemsScreen );
} );

<|endoftext|>


<commit_before>define(function(require) {
	var registerSuite = require('intern!object'),
		assert = require('intern/chai!assert'),
		el;

	require('js/tests/support/exports.js');

	registerSuite({
		name: 'Screen',

		setup: function() {
			el = document.createElement('style');
			el.textContent = 'html {font-family: "5"}';

			document.head.appendChild(el);
		},

		teardown: function() {
			document.head.removeChild(el);
		},

		size: function() {
			assert.strictEqual(Wee.screen.size(), 5,
				'Screen size should return 5'
			);
		},

		map: function() {
			// TODO: Complete
			assert.strictEqual(Wee.screen.map({
					size: 1,
					callback: function() {}
				}), undefined,
				'Single event was not mapped successfully'
			);

			assert.strictEqual(Wee.screen.map([{
					size: 1,
					callback: function() {}
				}, {
					size: 2,
					callback: function() {}
				}]), undefined,
				'Multiple events were not mapped successfully'
			);
		}
	});
});<commit_msg>Add test for ‘run’ method<commit_after>define(function(require) {
	var registerSuite = require('intern!object'),
		assert = require('intern/chai!assert'),
		el;

	require('js/tests/support/exports.js');

	registerSuite({
		name: 'Screen',

		setup: function() {
			el = document.createElement('style');
			el.textContent = 'html {font-family: "5"}';

			document.head.appendChild(el);
		},

		teardown: function() {
			document.head.removeChild(el);
		},

		size: function() {
			assert.strictEqual(Wee.screen.size(), 5,
				'Screen size should return 5'
			);
		},

		map: function() {
			// TODO: Complete
			assert.strictEqual(Wee.screen.map({
					size: 1,
					callback: function() {}
				}), undefined,
				'Single event was not mapped successfully'
			);

			assert.strictEqual(Wee.screen.map([{
					size: 1,
					callback: function() {}
				}, {
					size: 2,
					callback: function() {}
				}]), undefined,
				'Multiple events were not mapped successfully'
			);
		},

		run: function() {
			assert.isFunction(Wee.screen.run, true,
				'"run" did not evaluate as a function'
			);
		}
	});
});<|endoftext|>


<commit_before>(function ($) {
	$.fn.tigronDatetimepicker = function (options) {
		if (typeof options.postFormat === 'undefined') {
			options.postFormat = options.format;
		}
		var getInput = function(element) {
			if ($(element).is('input')) {
				input = $(element);
			} else {
				input = $(element).find($(element).data('DateTimePicker').datepickerInput());
				if (input.length === 0) {
					input = $(element).find('input[type=text]');
				} else if (!input.is('input')) {
					throw new Error('CSS class "' + $(element).data('DateTimePicker').datepickerInput() + '" cannot be applied to non input element');
				}
			}
			return input;
		}

		cleaned_options = jQuery.extend(true, {}, options);
		delete cleaned_options.postFormat;

		$.each($(this), function(element, value) {

			$(this).addClass('datetimepicker-input').attr('data-toggle', 'datetimepicker')
			value = $(this).val();
			if (typeof value !== 'undefined') {
				$(this).attr('data-value', value);
				$(this).removeAttr('value');
				cleaned_options['defaultDate'] = value;
			}
			$(this).datetimepicker(cleaned_options)
		});

		$(this).on('change.datetimepicker', function(e) {
			input = getInput( $(this) );
			classname = $(input).attr('data-hidden-class');

			if (e.date === false || e.date == undefined) {
				value = '';
			} else {
				value = e.date.format(options.postFormat);
			}
			$('input.' + classname).val(value);
		});

		var count = $('input[class^="datetimepicker_"]').length + 1;

		$.each($(this), function(element, value) {
			input = getInput($(this));

			if ($(this).data('datetimepicker').date() === null) {
				value = '';
			} else {
				value = $(this).data('datetimepicker').date().format(options.postFormat);
				$(this).data('datetimepicker').viewDate($(this).data('datetimepicker').date());
			}

			if ($(input).next().length > 0 && $(input).next().is('[class*="datetimepicker_"]')) {
				return true;
			}

			$(input).after(
				$('<input>')
				   .attr('type', 'hidden')
				   .attr('autocomplete', 'off')
				   .attr('name', $(input).attr('name')).val( value )
				   .addClass('datetimepicker_' + count)
			);
			$(input).attr('data-hidden-class', 'datetimepicker_' + count);
			$(input).removeAttr('name');
			count++;
		})
	};
})(jQuery);
<commit_msg>revert last commit<commit_after>(function ($) {
	$.fn.tigronDatetimepicker = function (options) {
		if (typeof options.postFormat === 'undefined') {
			options.postFormat = options.format;
		}
		var getInput = function(element) {
			if ($(element).is('input')) {
				input = $(element);
			} else {
				input = $(element).find($(element).data('DateTimePicker').datepickerInput());
				if (input.length === 0) {
					input = $(element).find('input[type=text]');
				} else if (!input.is('input')) {
					throw new Error('CSS class "' + $(element).data('DateTimePicker').datepickerInput() + '" cannot be applied to non input element');
				}
			}
			return input;
		}

		cleaned_options = jQuery.extend(true, {}, options);
		delete cleaned_options.postFormat;

		$(this).datetimepicker(cleaned_options).on('dp.change', function(e) {
			input = getInput( $(this) );
			classname = $(input).attr('data-hidden-class');
			if (e.date === false) {
				value = '';
			} else {
				value = e.date.format(options.postFormat);
			}
			$('input.' + classname).val(value);
		});

		var count = $('input[class^="datetimepicker_"]').length + 1;

		$.each($(this), function(element, value) {
			input = getInput($(this));

			if ($(this).data('DateTimePicker').date() === null) {
				value = '';
			} else {
				value = $(this).data('DateTimePicker').date().format(options.postFormat);
				$(this).data('DateTimePicker').viewDate($(this).data('DateTimePicker').date());
			}

			if ($(input).next().length > 0 && $(input).next().is('[class*="datetimepicker_"]')) {
				return true;
			}

			$(input).after( $('<input>').attr('type', 'hidden').attr('name', $(input).attr('name')).val( value ).addClass('datetimepicker_' + count) );
			$(input).attr('data-hidden-class', 'datetimepicker_' + count);
			$(input).removeAttr('name');
			count++;
		})
	};
})(jQuery);
<|endoftext|>