Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Revisions to the NPR API editor meta box #47

Merged
merged 35 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b1c8228
Add text domain to plugin readme.txt
benlk Mar 19, 2018
654bae0
Clean up meta-boxes.php
benlk Mar 19, 2018
f855752
Add useless check boxes to the NPR Story API metabox, enqueue a style…
benlk Mar 19, 2018
4bd9606
Create the checkboxes in the NPR Story API box and make sure they sav…
benlk Mar 20, 2018
2eaf1c6
default the 'send to npr api' box to checked
benlk Mar 20, 2018
099130b
Checkbox validation javascript
benlk Mar 22, 2018
d9a7740
Better recursion, cleaner form validation javascript
benlk Mar 22, 2018
2896c9b
Metabox validation is less DRY than form javascript.
benlk Mar 22, 2018
445b8e2
console.log
benlk Mar 22, 2018
dc50455
Date picker boilerplate elements
benlk Mar 22, 2018
06f7623
Improvements to the presentation of the datepicker form, but no progr…
benlk Mar 23, 2018
c8d5212
enqueue jquery-ui-datepicker
benlk Mar 23, 2018
776d6f1
Add the jquery-ui datepicker
benlk Mar 24, 2018
3e900c2
Nah, use the datepicker only if there's not a native solution to the …
benlk Mar 24, 2018
d1d4329
Add the fallback assets for the jquery ui datepicker
benlk Mar 26, 2018
727fce9
Fix recursion upon initilization in the metabox javascript validation
benlk Mar 26, 2018
a7a546a
Add file contents to some PHP files that were missing them
benlk Mar 26, 2018
5ce08d9
Save the NPR One expiry datetime as post meta, and output the saved v…
benlk Mar 27, 2018
5ad0a49
Notes on what the next steps are for the datepicker box
benlk Mar 27, 2018
7ab8c3a
Minor cleanup in nprstory_api_push
benlk Mar 27, 2018
93a6126
import @tylermachado's datepicker functionality
benlk Mar 27, 2018
e730ef6
fix off-by-one error on day number, and left pad the minutes if it's …
benlk Mar 27, 2018
f85dc68
sanitize this one weird error field
benlk Mar 27, 2018
39c9603
Formatting and internal commenting in nprstory_post_to_nprml_story
benlk Mar 27, 2018
a6b989c
Based on the post meta values of _send_to_org, _send_to_one, and _npr…
benlk Mar 27, 2018
b77cd0c
another spacing fix
benlk Mar 28, 2018
b8a7b81
Historical note
benlk Mar 28, 2018
4277fe5
Add the audioRunByDat field to the pushed NPRML
benlk Mar 28, 2018
7155975
Remove a test for a function that no longer exists; create tests file…
benlk Mar 28, 2018
8ce7dc4
actually remove that missing test
benlk Mar 28, 2018
1210131
Merge branch 'master' into 9-expiration-date-picker
benlk Apr 16, 2018
5f47778
remove $helper_text, as it is no longer used
benlk Apr 16, 2018
4234bd6
set nprapi to string 1, not int 1
benlk Apr 17, 2018
493ef78
remove send_to_org checkbox, save function, API push function
benlk Apr 17, 2018
22af682
Merge branch 'master' into 9-expiration-date-picker
benlk Apr 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
855 changes: 855 additions & 0 deletions assets/css/jquery-ui.css

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions assets/css/meta-box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Styles for the NPR Story API meta box
*/
#ds_npr_document_meta ul ul {
margin-top: 6px;
}
#ds_npr_document_meta ul ul ul {
padding-left: 24px;
}
#nprone-expiry {
border-top: 1px solid #eee;
padding-top: 6px;
}
#nprone-expiry-form,
#nprone-expiry-form select,
#nprone-expiry-form input {
font-size: 12px;
padding-left: 0;
padding-right: 0;
}
#nprone-expiry-form .row {
clear: both;
margin-top: 6px;
line-height: 28px;
}
button.link-effect {
border: none;
color: #0073aa;
text-decoration: underline;
}
#nprone-expiry-month {
vertical-align: baseline;
margin: 0;
}

/*
* Minimal Datepicker styles
*/
#ui-datepicker-div {
background: #fff;
border: 1px solid #e5e5e5;
padding: 6px;
box-shadow: 0 3px 5px rgba(0,0,0,.2);
}
.ui-datepicker .ui-datepicker-header {
border: none;
}
.ui-datepicker-calendar .ui-state-default {
text-decoration: none;
background-color: transparent;
}
.ui-datepicker .ui-datepicker-current-day a {
border-color: #0073aa #006799 #006799;
background: #0085ba;
color: #fff;
font-weight: bold;
}
.ui-datepicker .ui-datepicker-today a {
background: #fff;
border: 1px solid #c5c5c5;
font-weight: bold;
color: #000;
}
Binary file added assets/images/ui-icons_444444_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ui-icons_555555_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ui-icons_777620_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ui-icons_777777_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ui-icons_cc0000_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ui-icons_ffffff_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions assets/js/meta-box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* NPR Story API meta box functions and features
*/
document.addEventListener('DOMContentLoaded', () => {
'use strict';
var $ = jQuery;

// contains the inputs
var $container = $( '#ds-npr-publish-actions' );

// initialize the form
$container.find( 'input' ).on( 'change', li_checking );

// Upon update, do the thing
li_checking.call( $container.find( '#send_to_api' ) );

/*
* If a checkbox in an li gets unchecked, uncheck and disable its child li
* If a checkbox in an li gets checked, enable its child li
*/
function li_checking( event ) {
var checked = $( this ).prop('checked');
var $results = $( this ).closest( 'li' ).children( 'ul' ).children( 'li' ); // Only get the first level of list.
$results.each( function( element ) {
// Triggering the change event on the child does not work.
if ( checked ) {
var recurse = $( this ).children( 'label' ).children( 'input' ).prop( 'disabled', false );
li_checking.call( recurse );
} else {
recurse = $( this ).children( 'label' ).children( 'input' ).prop( 'disabled', true ).prop( 'checked', false );
li_checking.call( recurse );
}
});
}

// edit the time selector
$( '#nprone-expiry-edit' ).on( 'click', function( event ) {
event.preventDefault();
$( '#nprone-expiry-form' ).toggleClass( 'hidden' );
$( this ).toggleClass( 'hidden' );
});
// close the time selector
$( '#nprone-expiry-cancel' ).on( 'click', function( event ) {
event.preventDefault();
$( '#nprone-expiry-form' ).toggleClass( 'hidden' );
$( '#nprone-expiry-edit' ).toggleClass( 'hidden' );
});
// save the time selector
$( '#nprone-expiry-ok' ).on( 'click', function( event ) {
event.preventDefault();
$( '#nprone-expiry-form' ).toggleClass( 'hidden' );
$( '#nprone-expiry-edit' ).toggleClass( 'hidden' );

// but then it needs to update the displayed data in #nprone-expiry-display. How is it to do that?
// This needs to take:
// - the YYYY-MM-DD value of #nprone-expiry-datepicker
// - the HH:MM value of #nprone-expiry-hour
// and output a string in the format Apr 1, 2020 @ 09:01 / Nov 1, 2018 @ 23:59
var d = new Date();
var dateinput = $( '#nprone-expiry-datepicker' ).val().split('-');
var timeinput = $( '#nprone-expiry-hour' ).val().split(':');

d.setFullYear(dateinput[0]);
d.setMonth(dateinput[1] - 1); // because this is zero-indexed?
d.setDate(dateinput[2]);
d.setHours(timeinput[0]);
d.setMinutes(timeinput[1]);

var string = d.toLocaleString("en-us", { month: "short" })
+ " "
+ d.getDate()
+ ", "
+ d.getFullYear()
+ " @ "
+ d.getHours()
+ ":"
+ (d.getMinutes() < 10? '0' : '') + d.getMinutes();

$( '#nprone-expiry-display time' ).text( string );
});


// Activate the date picker, if and only if the browser doesn't have a native datepicker
// @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#JavaScript
var test = document.createElement( 'input' );
test.type = 'date';
if ( test.type !== 'date' ) {
$( '#nprone-expiry-datepicker' ).attr('type', 'text').css('width', '8em').datepicker({
dateFormat: 'yy-mm-dd'
});
}
});
Loading