/** * Created by tgoupil on 19/02/16. */ (function(jq){ //var jq = jQuery.noConflict(true); jq('#all-parties-dropdown').hide(); jq.fn.initIssueTracker(function(){ // Capture the Issues tab click jq("#nav-issues").click(function(){ jq('#all-issues-dropdown').show().val("*"); jq('#all-parties-dropdown').hide(); jq('.issue-tracker-inner-container').showAllIssues(); if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Button Group', 'label': "Issues", 'action': 'LEFT button clicked'},{'event': 'data-layer-event'}); } }); // Capture the Parties tab click jq("#nav-parties").click(function(){ jq('#all-parties-dropdown').show().val("*"); jq('#all-issues-dropdown').hide(); jq('.issue-tracker-inner-container').showAllParties(); if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Button Group', 'label': "Parties", 'action': 'RIGHT button clicked'},{'event': 'data-layer-event'}); } }); // Show the All Issues screen by default jq('.issue-tracker-inner-container').showAllIssues(); // Capture issues selections from the dropdown jq("#all-issues-dropdown").change(function(){ if(jq(this).val() === "*") { jq('.issue-tracker-inner-container').showAllIssues(); } else { jq('.issue-tracker-inner-container').showIssue({ title: jq("#all-issues-dropdown option:selected").text(), code: jq(this).val() }); } if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Dropdown', 'label': jq("#all-issues-dropdown option:selected").text(), 'action': 'Under Issues'},{'event': 'data-layer-event'}); } }); // Capture parties selections from the dropdown jq("#all-parties-dropdown").change(function(){ console.log(jq("#all-parties-dropdown option:selected").text()); if(jq(this).val() === "*") { jq('.issue-tracker-inner-container').showAllParties(); } else { jq('.issue-tracker-inner-container').showParty({ title: jq("#all-parties-dropdown option:selected").text(), code: jq(this).val() }); } if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Dropdown', 'label': jq("#all-parties-dropdown option:selected").text(), 'action': 'Under Parties'},{'event': 'data-layer-event'}); } }); }); jq(document).on('click', '.ge-issue-tracker__single-party', function(){ var code = jq(this).attr("data-issue-tracker-party-code"); jq('.issue-tracker-inner-container').showParty({ title: jq(this).attr("data-issue-tracker-party-title"), code: code }); jq('#nav-parties-input').prop('checked', true); jq('#nav-issues-input').prop('checked', false); jq('#all-issues-dropdown').hide(); jq('#all-parties-dropdown').show().val(code.toLowerCase()); if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Single party all issues text link', 'label': "View more policies from this party", 'action': jq(this).attr("data-issue-tracker-party-title")},{'event': 'data-layer-event'}); } }); jq(document).on('click', '.ge-issue-tracker__single-issue', function(){ var code = jq(this).attr("data-issue-tracker-issue-code"); jq('.issue-tracker-inner-container').showIssue({ title: jq(this).attr("data-issue-tracker-issue-title"), code: code }); jq('#nav-issues-input').prop('checked', true); jq('#nav-parties-input').prop('checked', false); jq('#all-parties-dropdown').hide(); jq('#all-issues-dropdown').show().val(code.toLowerCase()); if ( dataLayer && Array.isArray(dataLayer) ) { dataLayer.push({'category': 'Single issue all parties text link', 'label': "View each party's stance on this issue", 'action': jq(this).attr("data-issue-tracker-issue-title")},{'event': 'data-layer-event'}); } }); })(jQuery);