Fix camper news submit

pull/5022/head
Berkeley Martinez 2015-12-04 19:23:06 -08:00
parent 85510a2fd8
commit 3462ba791e
3 changed files with 53 additions and 56 deletions

View File

@ -190,6 +190,10 @@ $(document).ready(function() {
var storySubmitButtonHandler = function storySubmitButtonHandler() {
if (!$('#story-submission-form')[0].checkValidity()) {
return null;
}
var link = $('#story-url').val();
var headline = $('#story-title').val();
var description = $('#description-box').val();

View File

@ -1,53 +1,53 @@
.col-xs-12
div
form.input-group(name='URLSubmit')
input#story-url.big-text-field.field-responsive.form-control(placeholder='Paste your link here', name='link', type='url', required='required', autofocus)
span.input-group-btn
button#preliminary-story-submit.btn.btn-big.btn-primary.btn-responsive(type='button') Submit
div
alert(type='danger')
span.ion-close-circled
| Please enter a valid URL format (http://www.example.com/).
form.input-group(id='URLSubmit' name='URLSubmit')
input#story-url.big-text-field.field-responsive.form-control(placeholder='Paste your link here', name='link', type='url', required, autofocus)
span.input-group-btn
button#preliminary-story-submit.btn.btn-big.btn-primary.btn-responsive(type='submit') Submit
.spacer
script.
$('#story-url').on('keypress', function(e) {
if (e.which === 13 || e === 13) {
$('#preliminary-story-submit').click();
}
});
var preliminaryStorySubmit = function preliminaryStorySubmit() {
$('#story-url').on('keypress', function(e) {
if (e.keyCode === 13) {
$('#preliminary-story-submit').click();
}
});
function preliminaryStorySubmit(e) {
if (!$('#URLSubmit')[0].checkValidity()) {
return null;
}
e.preventDefault();
var storyURL = $('#story-url').val();
$('#preliminary-story-submit').attr('disabled', 'disabled');
var storyURL = $('#story-url').val();
$('#preliminary-story-submit').attr('disabled', 'disabled');
$.post('/stories/preliminary',
{
data: {
url: storyURL
}
})
.fail(function (xhr, textStatus, errorThrown) {
$('#preliminary-story-submit').attr('disabled', false);
})
.done(function (data, textStatus, xhr) {
if (data.alreadyPosted) {
window.location = data.storyURL;
} else {
window.location = '/stories/submit/new-story?url=' +
encodeURIComponent(data.storyURL) +
'&title=' + encodeURIComponent(data.storyTitle) +
'&image=' + encodeURIComponent(data.storyImage) +
'&description=' + encodeURIComponent(data.storyMetaDescription);
}
});
}
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
$.post('/stories/preliminary',
{
data: {
url: storyURL
}
})
.fail(function (xhr, textStatus, errorThrown) {
$('#preliminary-story-submit').attr('disabled', false);
})
.done(function (data, textStatus, xhr) {
if (data.alreadyPosted) {
window.location = data.storyURL;
} else {
window.location = '/stories/submit/new-story?url=' +
encodeURIComponent(data.storyURL) +
'&title=' + encodeURIComponent(data.storyTitle) +
'&image=' + encodeURIComponent(data.storyImage) +
'&description=' + encodeURIComponent(data.storyMetaDescription);
}
});
}
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
arr = $( "h3 input:checked" )
.map(function() {
return this.id;
})
.get()
.join('&');
arr = $( "h3 input:checked" )
.map(function() {
return this.id;
})
.get()
.join('&');

View File

@ -13,17 +13,12 @@
.col-xs-12.col-md-1
label.control-label.control-label-story-submission(for='name') Link
.col-xs-12.col-md-11
input#story-url.form-control(name='Link', disabled="disabled")
input#story-url.form-control(name='Link', disabled, value='#{storyURL}')
.form-group
.col-xs-12.col-md-1
label.control-label.control-label-story-submission(for='name') Title
.col-xs-12.col-md-11
input#story-title.form-control(placeholder='Type a headline for your link here', name='Title', maxlength='90', required='required', autocomplete="off", autofocus)
.col-xs-12.col-md-11.col-md-offset-1
alert(type='danger')
span.ion-close-circled
| A headline is required to submit.
input#story-title.form-control(value='#{storyTitle}', name='Title', maxlength='90', autocomplete="off", autofocus, required)
.form-group
.col-xs-12.col-md-offset-1
span.pull-left#textarea_feedback
@ -42,8 +37,6 @@
button.btn.btn-big.btn-block.btn-primary#story-submit(type='submit') Submit
script.
$('#story-url').val(storyURL).attr('disabled', 'disabled');
$('#story-title').val(storyTitle);
if (storyImage) {
$('#image-display').removeClass('hidden-element');
}
if (main.storyImage) {
$('#image-display').removeClass('hidden-element');
}