Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Commit

Permalink
Merge branch 'develop' of github.com:18F/openFEC-web-app into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LindsayYoung committed Sep 2, 2015
2 parents 80fe487 + 56d54ae commit cf8d472
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 70 deletions.
15 changes: 14 additions & 1 deletion static/js/modules/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function mapFilters(filters) {
var parsedFilters;

function buildCycle(datum) {
if (parsedFilters.cycle) {
if (parsedFilters && parsedFilters.cycle) {
var cycles = _.intersection(
_.map(parsedFilters.cycle, function(cycle) {return parseInt(cycle);}),
datum.cycles
Expand Down Expand Up @@ -130,6 +130,18 @@ function barColumn(formatter) {
};
}

function urlColumn(attr, opts) {
return _.extend({
render: function(data, type, row, meta) {
var anchor = document.createElement('a');
anchor.textContent = data;
anchor.setAttribute('href', row[attr]);
anchor.setAttribute('target', '_blank');
return anchor.outerHTML;
}
}, opts);
}

var dateColumn = formattedColumn(helpers.datetime);
var currencyColumn = formattedColumn(helpers.currency);
var barCurrencyColumn = barColumn(helpers.currency);
Expand Down Expand Up @@ -441,6 +453,7 @@ module.exports = {
candidateColumn: candidateColumn,
committeeColumn: committeeColumn,
currencyColumn: currencyColumn,
urlColumn: urlColumn,
barCurrencyColumn: barCurrencyColumn,
dateColumn: dateColumn,
modalAfterRender: modalAfterRender,
Expand Down
13 changes: 1 addition & 12 deletions static/js/pages/candidate-single.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ var tables = require('../modules/tables');
var decoders = require('../modules/decoders');

var columns = [
{
data: 'document_description',
className: 'all',
orderable: false,
render: function(data, type, row, meta) {
var anchor = document.createElement('a');
anchor.textContent = data;
anchor.setAttribute('href', row.pdf_url);
anchor.setAttribute('target', '_blank');
return anchor.outerHTML;
}
},
tables.urlColumn('pdf_url', {data: 'document_description', className: 'all', orderable: false}),
{
data: 'amendment_indicator',
className: 'min-desktop',
Expand Down
20 changes: 2 additions & 18 deletions static/js/pages/committee-single.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,7 @@ var occupationColumns = [
];

var filingsColumns = [
{
data: 'document_description',
className: 'all',
orderable: false,
render: function(data, type, row, meta) {
var anchor = document.createElement('a');
anchor.textContent = data;
anchor.setAttribute('href', row.pdf_url);
anchor.setAttribute('target', '_blank');
return anchor.outerHTML;
}
},
tables.urlColumn('pdf_url', {data: 'document_description', className: 'all', orderable: false}),
{
data: 'amendment_indicator',
className: 'min-desktop',
Expand Down Expand Up @@ -227,12 +216,7 @@ $(document).ready(function() {
switch ($table.attr('data-type')) {
case 'committee-contributor':
path = ['committee', committeeId, 'schedules', 'schedule_a', 'by_contributor'].join('/');
query = {};
if (year) {
query.year = year;
} else {
query.cycle = cycle;
}
query = {cycle: cycle};
tables.initTableDeferred($table, null, path, query, committeeColumns, aggregateCallbacks, {
dom: tables.simpleDOM,
order: [[1, 'desc']],
Expand Down
13 changes: 1 addition & 12 deletions static/js/pages/elections.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,7 @@ var columns = [
tables.barCurrencyColumn({data: 'total_receipts'}),
tables.barCurrencyColumn({data: 'total_disbursements'}),
tables.barCurrencyColumn({data: 'cash_on_hand_end_period'}),
{
data: 'pdf_url',
className: 'all',
orderable: false,
render: function(data, type, row, meta) {
var anchor = document.createElement('a');
anchor.textContent = row.document_description;
anchor.setAttribute('href', data);
anchor.setAttribute('target', '_blank');
return anchor.outerHTML;
}
},
tables.urlColumn('pdf_url', {data: 'document_description', className: 'all', orderable: false})
];

var sizeColumns = [
Expand Down
13 changes: 1 addition & 12 deletions static/js/pages/filings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@ var tables = require('../modules/tables');
var decoders = require('../modules/decoders');

var columns = [
{
data: 'document_description',
className: 'all',
orderable: false,
render: function(data, type, row, meta) {
var anchor = document.createElement('a');
anchor.textContent = data;
anchor.setAttribute('href', row.pdf_url);
anchor.setAttribute('target', '_blank');
return anchor.outerHTML;
}
},
tables.urlColumn('pdf_url', {data: 'document_description', className: 'all', orderable: false}),
{
data: 'committee_name',
className: 'min-desktop',
Expand Down
38 changes: 38 additions & 0 deletions static/js/pages/landing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

/* global require, document */

var $ = require('jquery');

var tables = require('../modules/tables');

var columns = [
tables.urlColumn('pdf_url', {data: 'document_description', className: 'all', orderable: false}),
{
data: 'committee_name',
className: 'min-desktop',
orderable: false,
render: function(data, type, row, meta) {
return tables.buildEntityLink(data, '/committee/' + row.committee_id + tables.buildCycle(row), 'committee');
},
},
{
data: 'candidate_name',
className: 'min-desktop',
orderable: false,
render: function(data, type, row, meta) {
return tables.buildEntityLink(data, '/candidate/' + row.candidate_id + tables.buildCycle(row), 'candidate');
},
},
tables.dateColumn({data: 'receipt_date', className: 'min-tablet', orderable: false}),
];

$(document).ready(function() {
var $table = $('#results');
tables.initTable($table, null, 'filings', {per_page: 10}, columns, tables.offsetCallbacks, {
// Order by receipt date descending
order: [[3, 'desc']],
useFilters: false,
dom: 't'
});
});
2 changes: 1 addition & 1 deletion templates/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<span class="disclaimer__right">This site is in beta. <a title="Learn about this site's development" tabindex="0" href="https://18f.gsa.gov/dashboard/stages/#beta">Learn more.</a></span>
</div>
<div class="masthead">
<a href="{{ cms_url }}" class="site-title"><img class="site-brand" src="/static/img/brand.svg" alt="Federal Election Commission | United States of America"></a>
<a title="Home" href="{{ cms_url }}" class="site-title"><span class="u-visually-hidden">Federal Election Commission | United States of America</span></a>
<ul class="utility-nav list--flat">
<li class="utility-nav__item">About</li>
<li class="utility-nav__item">Contact</li>
Expand Down
20 changes: 16 additions & 4 deletions templates/partials/navigation.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<nav class="site-nav">
<button class="site-nav__button site-nav__button--left">Navigation</button>
<nav class="site-nav">
<input class="nav-toggle__input" id="nav-toggle" type="checkbox">
<label for="nav-toggle" class="site-nav__button site-nav__button--left">Menu</label>
<ul id="site-menu" class="site-nav__list">
<li class="site-nav__item">
<li class="site-nav__item site-nav__item--with-dropdown">
<a href="/" class="site-nav__link is-current">Campaign Finance Data</a>
<input class="nav-toggle__input" id="dropdown-toggle-1" type="checkbox">
<label for="dropdown-toggle-1" class="site-nav__link nav-toggle__label">Campaign Finance Data</label>
<ul class="site-nav__dropdown">
<li class="site-nav__item">
<a class="site-nav__link" href="/">Search for candidates &raquo;</a>
Expand All @@ -27,8 +30,10 @@
</li>
</ul>
</li>
<li class="site-nav__item">
<li class="site-nav__item site-nav__item--with-dropdown">
<a href="{{ cms_url }}/registration-and-reporting" class="site-nav__link">Registration &amp; Reporting</a>
<input class="nav-toggle__input" id="dropdown-toggle-2" type="checkbox">
<label for="dropdown-toggle-2" class="site-nav__link nav-toggle__label">Registration &amp; Reporting</label>
<ul class="site-nav__dropdown">
<li class="site-nav__item">
<a class="site-nav__link" href="{{ cms_url }}/registration-and-reporting">Registration &amp; Reporting Home</a>
Expand All @@ -47,6 +52,13 @@
<li class="site-nav__item">
<a href="#" class="site-nav__link is-disabled">TBD</a>
</li>
<li class="site-nav__item utility-nav__item">
<a href="#" class="site-nav__link is-disabled">About</a>
</li>
<li class="site-nav__item utility-nav__item">
<a href="#" class="site-nav__link is-disabled">Contact</a>
</li>
</ul>
<a title="Home" href="{{ cms_url }}" class="site-title"><span class="u-visually-hidden">Federal Election Commission | United States of America</span></a>
<button id="glossary-toggle" title="View site glossary" class="button--neutral site-nav__button site-nav__button--right">Glossary</button>
</nav>
74 changes: 64 additions & 10 deletions templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,87 @@

{% block body %}
{% include "partials/hero.html" %}
<section class="main" aria-labelledby="browse-heading">
<section class="main">
<div class="container">
<h2 class="h1 t-no-rules">How to view the data</h2>
<div class="row tiled-cards--2-wide">
<div class="card card--wide">
<img class="card__image icon--complex" src="/static/img/i-committee.svg" alt="Icon representing candidates">
<div class="card__image__container">
<img class="card__image icon--complex" src="/static/img/i-candidates--neutral.svg" alt="Icon representing candidates">
</div>
<div class="card__content">
<h3><a href="{{ url_for('candidates', cycle=default_cycles) }}">Candidates &raquo;</a></h3>
<h2 class="card__title">Candidate data</h2>
<ul class="card__links list--bulleted">
<li><a href="{{ url_for('candidates', cycle=2016, office='P') }}">All 2016 presidential candidates &raquo;</a></li>
<li><a href="{{ url_for('candidates', cycle=2016, office='S') }}">All 2016 senate candidates &raquo;</a></li>
<li><a href="{{ url_for('candidates', cycle=2016, office='H') }}">All 2016 house candidates &raquo;</a></li>
</ul>
<a class="button--neutral button--browse" href="{{ url_for('candidates', cycle=default_cycles) }}">All candidate data</a>
</div>
</div>
<div class="card card--wide">
<img class="card__image icon--complex" src="/static/img/i-committee.svg" alt="Icon representing committees">
<div class="card__image__container">
<img class="card__image icon--complex" src="/static/img/i-committees--neutral.svg" alt="Icon representing committees">
</div>
<div class="card__content">
<h3><a href="{{ url_for('committees', cycle=default_cycles) }}">Committees &raquo;</a></h3>
<h2 class="card__title">Committee data</h2>
<ul class="card__links list--bulleted">
<li><a href="{{ url_for('committees', cycle=2016) }}">Most recent committees &raquo;</a></li>
<li><a>All PACs active 2015-2016 &raquo;</a></li>
<li><a>All Independent Expenditure Committees active 2015-2016 &raquo;</a></li>
</ul>
<a class="button--neutral button--browse" href="{{ url_for('committees', cycle=default_cycles) }}">All committee data</a>
</div>
</div>
<div class="card card--wide">
<img class="card__image icon--complex" src="/static/img/i-committee.svg" alt="Icon representing candidates">
<div class="card__image__container">
<img class="card__image icon--complex" src="/static/img/i-receipts--neutral.svg" alt="Icon representing receipts">
</div>
<div class="card__content">
<h3><a href="{{ url_for('receipts')}}">Receipts &raquo;</a></h3>
<h2 class="card__title">Receipt data</h2>
<ul class="card__links list--bulleted">
<li><a href="{{ url_for('receipts', is_individual='true', min_date='1/01/2015', max_date='12/31/2015') }}">Top contributions from individuals this year &raquo;</a></li>
</ul>
<a class="button--neutral button--browse" href="{{ url_for('receipts')}}">All receipt data</a>
</div>
</div>
<div class="card card--wide">
<img class="card__image icon--complex" src="/static/img/i-committee.svg" alt="Icon representing candidates">
<div class="card__image__container">
<img class="card__image icon--complex" src="/static/img/i-disbursements--neutral.svg" alt="Icon representing disbursements">
</div>
<div class="card__content">
<h3><a href="{{ url_for('disbursements')}}">Disbursements &raquo;</a></h3>
<h2 class="card__title">Disbursement Data</h2>
<ul class="card__links list--bulleted">
<li><a href="{{ url_for('disbursements', is_individual='true', min_date='1/01/2015', max_date='12/31/2015') }}">Disbursements from committees this year &raquo;</a></li>
</ul>
<a class="button--neutral button--browse" href="{{ url_for('disbursements')}}">All disbursement data</a>
</div>
</div>
</div>
</div>

<div class="content__section--extra">
<div class="row">
<div class="icon-heading">
<img class="icon-heading__image" src="/static/img/i-filings--primary.svg" alt="Icon representing filings">
<h2 class="icon-heading__title">Most recent filings submitted</h2>
</div>
<a class="u-float-right button--neutral button--browse" href="{{ url_for('filings') }}">All filing data</a>
</div>
<table id="results" class="data-table" data-type="filing-table">
<thead>
<tr>
<th scope="col">Document</th>
<th scope="col">Filer Name</th>
<th scope="col">Candidate Name</th>
<th scope="col">Receipt Date</th>
</tr>
</thead>
</table>
</div>
</div>
</section>
{% endblock %}

{% block scripts %}
<script src="/{{ assets['dist/js/pages/landing.js'] }}"></script>
{% endblock %}

0 comments on commit cf8d472

Please sign in to comment.