Skip to content

Commit

Permalink
Merge 60de50a into e371233
Browse files Browse the repository at this point in the history
  • Loading branch information
anselmbradford committed Dec 18, 2017
2 parents e371233 + 60de50a commit 34a49a3
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 201 deletions.
5 changes: 0 additions & 5 deletions cfgov/cfgov/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@
MEDIA_URL = '/f/'


#Enabling compression for use in base.html
COMPRESS_ENABLED = True

COMPRESS_JS_FILTERS = []

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
Expand Down
122 changes: 61 additions & 61 deletions cfgov/jinja2/v1/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,31 @@
{# Customized Modernizr build that includes html5shiv.
Built via gulp-modernizer in `scripts.js` task. #}
<script src="{{ static('js/modernizr.min.js') }}"></script>

{#
Turn off JavaScript for browsers that don't support ECMAScript 5 features
(e.g. Internet Explorer 8)
by reversing no-js/js CSS class change made by modernizr.
The following ECMAScript 5 feature checks come from
https://github.com/Modernizr/Modernizr/tree/master/feature-detects/es5
#}
<script>
//<![CDATA[
if ( window.Modernizr && window.Modernizr.es5 === false ) {
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = '{{ static('js/es5-shim.js') }}';
document.getElementsByTagName( 'head' )[0].appendChild( script );
var modernizr = window.Modernizr;
if ( !( typeof modernizr !== 'undefined' &&
modernizr.es5array &&
modernizr.es5date &&
modernizr.es5function &&
modernizr.es5object &&
modernizr.json &&
modernizr.es5string &&
modernizr.es5syntax &&
modernizr.es5undefined ) ) {
var docElement = document.documentElement;
docElement.className = docElement.className.replace( /(^|\s)js(\s|$)/, '$1no-js$2' );
}
//]]>
</script>
<!--[if lt IE 9]>
{# If in IE8 reverse no-js/js class change made by modernizr. #}
<script>
var docElement = document.documentElement;
docElement.className = docElement.className.replace( /(^|\s)js(\s|$)/, '$1no-js$2' );
</script>
<![endif]-->

<!--[if IE 9]><script src="{{ static('js/ie/common.ie.js') }}"></script><![endif]-->
<!--[if IE 9]><script src="{{ static('js/ie/common.ie9.js') }}"></script><![endif]-->
</head>

<body>
Expand Down Expand Up @@ -241,57 +247,51 @@
#}

{% block javascript scoped %}
<!--[if gt IE 8]><!-->
{# Include site-wide JavaScript. #}
<script src="{{ static('js/routes/common.js') }}"></script>

{# Check and include template-level JavaScript. #}
{% macro template_js() %}
{% include 'js/routes/' + request.path.split('/')[1] + '/single.js' ignore missing %}
{% endmacro %}
{% set js_source = template_js() | trim %}
{% if js_source | length > 0 %}
<script src="{{ static('js/routes/' + request.path.split('/')[1] + '/single.js') }}"></script>
{% endif %}

{# Check and include component-level JavaScript. #}
{% macro component_ondemand_js(js) %}
{% include 'js/routes/on-demand/' + js ignore missing %}
{% endmacro %}

{% if page and page.media %}
{% compress js %}
<script>
{% for js in page.media %}
{% set component_js_source = component_ondemand_js(js) | trim %}
{% if component_js_source | length > 0 %}
{{ component_js_source }}
{% endif %}
{% endfor %}
</script>
{% endcompress %}
{% endif %}

{# TODO: Remove the below block when all pages
using this template are moved to Wagtail. #}
{# Check and include page-level JavaScript. #}
{% macro page_js() %}
{% include 'js/routes/' + request.path[1:] + 'index.js' ignore missing %}
{% endmacro %}
{% set js_source = page_js() | trim %}
{% if js_source | length > 0 %}
<script src="{{ static('js/routes/' + request.path[1:] + 'index.js') }}"></script>
{% endif %}
<!--<![endif]-->
{#
Modernizr adds a no-js class the HTML element if ECMAScript 5 features aren't
available. Check for that CSS class here and act accordingly.
#}
<script>
function loadScript(t,e){var n=document.createElement('script');n.type='text/javascript',n.onload=function(){return e?e():null},n.src=t,document.getElementsByTagName('head')[0].appendChild(n)}

if (document.body.parentElement.className.indexOf('no-js')===-1){
{# Include site-wide JavaScript. #}
loadScript('{{ static('js/routes/common.js') }}');
{# Check and include template-level JavaScript. #}
{% macro template_js() %}
{% include 'js/routes/' + request.path.split('/')[1] + '/single.js' ignore missing %}
{% endmacro %}
{% set js_source = template_js() | trim %}
{% if js_source | length > 0 %}
loadScript('{{ static('js/routes/' + request.path.split('/')[1] + '/single.js') }}');
{% endif %}
{# Check and include component-level JavaScript. #}
{% if page and page.media %}
{% for js in page.media %}
loadScript('{{ static('js/routes/on-demand/' + js) }}');
{% endfor %}
{% endif %}
{# TODO: Remove the below block when all pages
using this template are moved to Wagtail. #}
{# Check and include page-level JavaScript. #}
{% macro page_js() %}
{% include 'js/routes/' + request.path[1:] + 'index.js' ignore missing %}
{% endmacro %}
{% set js_source = page_js() | trim %}
{% if js_source | length > 0 %}
loadScript('{{ static('js/routes/' + request.path[1:] + 'index.js') }}');
{% endif %}
}
</script>

<script>
//<![CDATA[
var usasearch_config = { siteHandle: 'cfpb' };

var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = 'https://search.usa.gov/javascripts/remote.loader.js';
document.getElementsByTagName( 'head' )[0].appendChild( script );
loadScript('https://search.usa.gov/javascripts/remote.loader.js');
//]]>
</script>

Expand Down
2 changes: 1 addition & 1 deletion cfgov/jinja2/v1/_layouts/spanish-ask-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<!--[if gt IE 8]><!--> <link rel="stylesheet" href="{{ static('knowledgebase/es-ask-styles.min.css') }}"> <!--<![endif]-->

<!--[if lt IE 9]> <script src="{{ static('nemo/_/js/html5shim.js') }}"></script> <![endif]-->
<!--[if IE 9]><script src="{{ static('js/ie/common.ie.js') }}"></script><![endif]-->
<!--[if IE 9]><script src="{{ static('js/ie/common.ie9.js') }}"></script><![endif]-->
</head>
<body>
<!-- Google Tag Manager -->
Expand Down
2 changes: 1 addition & 1 deletion cfgov/jinja2/v1/es/es-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!--[if gt IE 8]><!--> <link rel="stylesheet" href="{{ static('nemo/_/c/es-styles.min.css') }}"> <!--<![endif]-->

<!--[if lt IE 9]> <script src="{{ static('nemo/_/js/html5shim.js') }}"></script> <![endif]-->
<!--[if IE 9]><script src="{{ static('js/ie/common.ie.js') }}"></script><![endif]-->
<!--[if IE 9]><script src="{{ static('js/ie/common.ie9.js') }}"></script><![endif]-->
</head>
<body class="page {% block body_class %} page-parent {% endblock %}
page-template
Expand Down
2 changes: 1 addition & 1 deletion cfgov/legacy/templates/front/base_nonresponsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</script>
<![endif]-->

<!--[if IE 9]><script src="{% static 'js/ie/common.ie.js' %}"></script><![endif]-->
<!--[if IE 9]><script src="{% static 'js/ie/common.ie9.js' %}"></script><![endif]-->
{% global_include "on-demand/header.html" %}
<div id="page">
{% block app_notification %}
Expand Down
2 changes: 1 addition & 1 deletion cfgov/legacy/templates/front/base_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
</script>
<![endif]-->

<!--[if IE 9]><script src="{% static 'js/ie/common.ie.js' %}"></script><![endif]-->
<!--[if IE 9]><script src="{% static 'js/ie/common.ie9.js' %}"></script><![endif]-->

<script src="{% static 'nemo/_/js/jquery-1.9.1.min.js' %}"></script>

Expand Down
7 changes: 0 additions & 7 deletions cfgov/unprocessed/js/ie/common.ie.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* ==========================================================================
Common application-wide scripts for Internet Explorer 9
========================================================================== */

/* classList.js: Cross-browser full element.classList implementation.
2014-07-23
By Eli Grey, http://eligrey.com
Expand Down Expand Up @@ -223,7 +227,5 @@ if ( 'document' in self ) {

testElement = null;
} )();

}

}
16 changes: 6 additions & 10 deletions cfgov/unprocessed/js/modules/behavior/FlyoutMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const BaseTransition = require( '../../modules/transition/BaseTransition' );
const behavior = require( '../../modules/util/behavior' );
const breakpointState = require( '../../modules/util/breakpoint-state' );
const EventObserver = require( '../../modules/util/EventObserver' );
const fnBind = require( '../../modules/util/fn-bind' ).fnBind;
const standardType = require( '../../modules/util/standard-type' );

/**
Expand Down Expand Up @@ -56,10 +55,10 @@ function FlyoutMenu( element ) { // eslint-disable-line max-statements, no-inlin
let _collapseTransitionMethodArgs = [];

// Binded events.
const _collapseBinded = fnBind( collapse, this );
const _collapseBinded = collapse.bind( this );
// Needed to add and remove events to transitions.
const _collapseEndBinded = fnBind( _collapseEnd, this );
const _expandEndBinded = fnBind( _expandEnd, this );
const _collapseEndBinded = _collapseEnd.bind( this );
const _expandEndBinded = _expandEnd.bind( this );

/* If this menu appears in a data source,
this can be used to store the source.
Expand Down Expand Up @@ -92,12 +91,9 @@ function FlyoutMenu( element ) { // eslint-disable-line max-statements, no-inlin
_triggerDom.setAttribute( 'data-gtm_ignore', 'true' );
}

const handleTriggerClickedBinded =
fnBind( _handleTriggerClicked, this );
const handleTriggerOverBinded =
fnBind( _handleTriggerOver, this );
const handleTriggerOutBinded =
fnBind( _handleTriggerOut, this );
const handleTriggerClickedBinded = _handleTriggerClicked.bind( this );
const handleTriggerOverBinded = _handleTriggerOver.bind( this );
const handleTriggerOutBinded = _handleTriggerOut.bind( this );

// Set initial aria attributes to false.
_setAriaAttr( 'expanded', _triggerDom, 'false' );
Expand Down
3 changes: 1 addition & 2 deletions cfgov/unprocessed/js/modules/transition/AlphaTransition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Required modules.
const EventObserver = require( '../../modules/util/EventObserver' );
const BaseTransition = require( './BaseTransition' );
const fnBind = require( '../../modules/util/fn-bind' ).fnBind;

// Exported constants.
const CLASSES = {
Expand Down Expand Up @@ -29,7 +28,7 @@ function AlphaTransition( element ) {
*/
function init() {
_baseTransition.init();
const _transitionCompleteBinded = fnBind( _transitionComplete, this );
const _transitionCompleteBinded = _transitionComplete.bind( this );
_baseTransition.addEventListener( BaseTransition.END_EVENT,
_transitionCompleteBinded );
return this;
Expand Down
5 changes: 2 additions & 3 deletions cfgov/unprocessed/js/modules/transition/BaseTransition.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Required modules.
const EventObserver = require( '../../modules/util/EventObserver' );
const fnBind = require( '../../modules/util/fn-bind' ).fnBind;

/**
* BaseTransition
Expand Down Expand Up @@ -32,8 +31,8 @@ function BaseTransition( element, classes ) {
* @returns {BaseTransition} An instance.
*/
function init() {
_transitionCompleteBinded = fnBind( _transitionComplete, this );
_addEventListenerBinded = fnBind( _addEventListener, this );
_transitionCompleteBinded = _transitionComplete.bind( this );
_addEventListenerBinded = _addEventListener.bind( this );
setElement( element );

return this;
Expand Down
3 changes: 1 addition & 2 deletions cfgov/unprocessed/js/modules/transition/MoveTransition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Required modules.
const EventObserver = require( '../../modules/util/EventObserver' );
const BaseTransition = require( './BaseTransition' );
const fnBind = require( '../../modules/util/fn-bind' ).fnBind;

// Exported constants.
const CLASSES = {
Expand Down Expand Up @@ -34,7 +33,7 @@ function MoveTransition( element ) {
*/
function init() {
_baseTransition.init();
const _transitionCompleteBinded = fnBind( _transitionComplete, this );
const _transitionCompleteBinded = _transitionComplete.bind( this );
_baseTransition.addEventListener(
BaseTransition.END_EVENT,
_transitionCompleteBinded
Expand Down
5 changes: 1 addition & 4 deletions cfgov/unprocessed/js/modules/util/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
Copyright (c) 2014 Alexey Maslennikov
========================================================================== */


const fnBind = require( './fn-bind' ).fnBind;

/**
* @param {object} object - JavaScript object.
* @returns {boolean} True if object is plain Javascript object.
Expand All @@ -29,7 +26,7 @@ function assign( destination ) {
let hasOwnProp;
for ( let i = 1; i < arguments.length; i++ ) {
const source = arguments[i] || {};
hasOwnProp = fnBind( Object.hasOwnProperty, source );
hasOwnProp = Object.hasOwnProperty.bind( source );
for ( const key in source ) {
if ( hasOwnProp( key ) ) {
const value = source[key];
Expand Down
30 changes: 0 additions & 30 deletions cfgov/unprocessed/js/modules/util/fn-bind.js

This file was deleted.

3 changes: 1 addition & 2 deletions cfgov/unprocessed/js/molecules/GlobalSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const breakpointState = require( '../modules/util/breakpoint-state' );
const ClearableInput = require( '../modules/ClearableInput' );
const EventObserver = require( '../modules/util/EventObserver' );
const FlyoutMenu = require( '../modules/behavior/FlyoutMenu' );
const fnBind = require( '../modules/util/fn-bind' ).fnBind;
const MoveTransition = require( '../modules/transition/MoveTransition' );
const standardType = require( '../modules/util/standard-type' );

Expand Down Expand Up @@ -68,7 +67,7 @@ function GlobalSearch( element ) { // eslint-disable-line max-statements, no-inl
// Initialize new clearable input behavior on the input-contains-label.
const clearableInput = new ClearableInput( inputContainsLabel );
clearableInput.init();
const handleExpandBeginBinded = fnBind( _handleExpandBegin, this );
const handleExpandBeginBinded = _handleExpandBegin.bind( this );
_flyoutMenu.addEventListener( 'expandBegin', handleExpandBeginBinded );
_flyoutMenu.addEventListener( 'collapseBegin', _handleCollapseBegin );
_flyoutMenu.addEventListener( 'collapseEnd', _handleCollapseEnd );
Expand Down
5 changes: 2 additions & 3 deletions cfgov/unprocessed/js/organisms/Expandable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const atomicHelpers = require( '../modules/util/atomic-helpers' );
const breakpointState = require( '../modules/util/breakpoint-state' );
const EventObserver = require( '../modules/util/EventObserver' );
const fnBind = require( '../modules/util/fn-bind' ).fnBind;
const standardType = require( '../modules/util/standard-type' );

/**
Expand Down Expand Up @@ -41,8 +40,8 @@ function Expandable( element ) { // eslint-disable-line max-statements, inline-c

// TODO: Replace function of _that with Function.prototype.bind.
const _that = this;
const _collapseBinded = fnBind( collapse, this );
const _expandBinded = fnBind( expand, this );
const _collapseBinded = collapse.bind( this );
const _expandBinded = expand.bind( this );

/* Reference to MutationObserver for watching DOM changes within the content.
No-op Function for MutationObserver.disconnect() is set in case destroy()
Expand Down
Loading

0 comments on commit 34a49a3

Please sign in to comment.