2015-03-07 17:42:22 +09:00
.col-xs-12
2015-03-08 11:53:03 +09:00
div(ng-controller="URLSubmitController")
form.input-group(name='URLSubmit')
2015-04-30 14:55:00 -07:00
input#story-url.big-text-field.field-responsive.form-control(placeholder='Paste your link here', name='link', type='url', ng-model='possibleURL', required='required', autofocus)
2015-03-08 11:53:03 +09:00
span.input-group-btn
2015-03-07 19:03:26 -08:00
button#preliminary-story-submit.btn.btn-big.btn-primary.btn-responsive(type='button', ng-disabled='URLSubmit.link.$invalid') Submit
2015-03-08 11:53:03 +09:00
div(ng-show="URLSubmit.link.$error.url && !URLsubmit.link.$pristine")
alert(type='danger')
span.ion-close-circled
| Please enter a valid URL format (http://www.example.com/).
.spacer
2015-03-07 16:48:57 -08:00
2015-03-07 17:42:22 +09:00
script.
2015-03-07 20:51:20 +09:00
$('#story-url').on('keypress', function(e) {
if (e.which === 13 || e === 13) {
$('#preliminary-story-submit').click();
2015-03-07 17:42:22 +09:00
}
});
2015-03-07 20:51:20 +09:00
var preliminaryStorySubmit = function preliminaryStorySubmit() {
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) {
2015-03-07 17:38:47 -08:00
if (data.alreadyPosted) {
2015-03-09 18:39:00 +09:00
window.location = data.storyURL;
2015-03-08 11:53:03 +09:00
} else {
2015-03-09 18:39:00 +09:00
window.location = '/stories/submit/new-story?url=' +
2015-03-08 11:53:03 +09:00
encodeURIComponent(data.storyURL) +
2015-03-09 13:08:39 +09:00
'&title=' + encodeURIComponent(data.storyTitle) +
2015-03-09 18:39:00 +09:00
'&image=' + encodeURIComponent(data.storyImage) +
'&description=' + encodeURIComponent(data.storyMetaDescription);
2015-03-07 17:38:47 -08:00
}
2015-03-07 20:51:20 +09:00
});
}
2015-03-27 12:36:21 -07:00
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
arr = $( "h3 input:checked" )
.map(function() {
return this.id;
})
.get()
2015-04-30 14:55:00 -07:00
.join('&');