Fix camper news submit
This commit is contained in:
@ -190,6 +190,10 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
||||||
|
|
||||||
|
if (!$('#story-submission-form')[0].checkValidity()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var link = $('#story-url').val();
|
var link = $('#story-url').val();
|
||||||
var headline = $('#story-title').val();
|
var headline = $('#story-title').val();
|
||||||
var description = $('#description-box').val();
|
var description = $('#description-box').val();
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
.col-xs-12
|
.col-xs-12
|
||||||
div
|
div
|
||||||
form.input-group(name='URLSubmit')
|
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='required', autofocus)
|
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
|
span.input-group-btn
|
||||||
button#preliminary-story-submit.btn.btn-big.btn-primary.btn-responsive(type='button') Submit
|
button#preliminary-story-submit.btn.btn-big.btn-primary.btn-responsive(type='submit') Submit
|
||||||
div
|
|
||||||
alert(type='danger')
|
|
||||||
span.ion-close-circled
|
|
||||||
| Please enter a valid URL format (http://www.example.com/).
|
|
||||||
.spacer
|
.spacer
|
||||||
|
|
||||||
script.
|
script.
|
||||||
$('#story-url').on('keypress', function(e) {
|
$('#story-url').on('keypress', function(e) {
|
||||||
if (e.which === 13 || e === 13) {
|
if (e.keyCode === 13) {
|
||||||
$('#preliminary-story-submit').click();
|
$('#preliminary-story-submit').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var preliminaryStorySubmit = function preliminaryStorySubmit() {
|
function preliminaryStorySubmit(e) {
|
||||||
|
if (!$('#URLSubmit')[0].checkValidity()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
var storyURL = $('#story-url').val();
|
var storyURL = $('#story-url').val();
|
||||||
$('#preliminary-story-submit').attr('disabled', 'disabled');
|
$('#preliminary-story-submit').attr('disabled', 'disabled');
|
||||||
|
|
||||||
$.post('/stories/preliminary',
|
$.post('/stories/preliminary',
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
url: storyURL
|
url: storyURL
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function (xhr, textStatus, errorThrown) {
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
$('#preliminary-story-submit').attr('disabled', false);
|
$('#preliminary-story-submit').attr('disabled', false);
|
||||||
})
|
})
|
||||||
.done(function (data, textStatus, xhr) {
|
.done(function (data, textStatus, xhr) {
|
||||||
if (data.alreadyPosted) {
|
if (data.alreadyPosted) {
|
||||||
window.location = data.storyURL;
|
window.location = data.storyURL;
|
||||||
} else {
|
} else {
|
||||||
window.location = '/stories/submit/new-story?url=' +
|
window.location = '/stories/submit/new-story?url=' +
|
||||||
encodeURIComponent(data.storyURL) +
|
encodeURIComponent(data.storyURL) +
|
||||||
'&title=' + encodeURIComponent(data.storyTitle) +
|
'&title=' + encodeURIComponent(data.storyTitle) +
|
||||||
'&image=' + encodeURIComponent(data.storyImage) +
|
'&image=' + encodeURIComponent(data.storyImage) +
|
||||||
'&description=' + encodeURIComponent(data.storyMetaDescription);
|
'&description=' + encodeURIComponent(data.storyMetaDescription);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
|
|
||||||
|
|
||||||
|
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
|
||||||
|
|
||||||
arr = $( "h3 input:checked" )
|
arr = $( "h3 input:checked" )
|
||||||
.map(function() {
|
.map(function() {
|
||||||
return this.id;
|
return this.id;
|
||||||
})
|
})
|
||||||
.get()
|
.get()
|
||||||
.join('&');
|
.join('&');
|
||||||
|
@ -13,17 +13,12 @@
|
|||||||
.col-xs-12.col-md-1
|
.col-xs-12.col-md-1
|
||||||
label.control-label.control-label-story-submission(for='name') Link
|
label.control-label.control-label-story-submission(for='name') Link
|
||||||
.col-xs-12.col-md-11
|
.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
|
.form-group
|
||||||
.col-xs-12.col-md-1
|
.col-xs-12.col-md-1
|
||||||
label.control-label.control-label-story-submission(for='name') Title
|
label.control-label.control-label-story-submission(for='name') Title
|
||||||
.col-xs-12.col-md-11
|
.col-xs-12.col-md-11
|
||||||
|
input#story-title.form-control(value='#{storyTitle}', name='Title', maxlength='90', autocomplete="off", autofocus, required)
|
||||||
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.
|
|
||||||
.form-group
|
.form-group
|
||||||
.col-xs-12.col-md-offset-1
|
.col-xs-12.col-md-offset-1
|
||||||
span.pull-left#textarea_feedback
|
span.pull-left#textarea_feedback
|
||||||
@ -42,8 +37,6 @@
|
|||||||
|
|
||||||
button.btn.btn-big.btn-block.btn-primary#story-submit(type='submit') Submit
|
button.btn.btn-big.btn-block.btn-primary#story-submit(type='submit') Submit
|
||||||
script.
|
script.
|
||||||
$('#story-url').val(storyURL).attr('disabled', 'disabled');
|
if (main.storyImage) {
|
||||||
$('#story-title').val(storyTitle);
|
$('#image-display').removeClass('hidden-element');
|
||||||
if (storyImage) {
|
}
|
||||||
$('#image-display').removeClass('hidden-element');
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user