From 790a2d987bbf241e298edfe54b7134cdd4b6f321 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Sun, 8 Mar 2015 11:53:03 +0900 Subject: [PATCH] Fighting CSS --- controllers/story.js | 8 +++++-- public/css/main.less | 12 ++++++++++ public/js/main.js | 6 +++++ views/stories/preliminary-submit.jade | 34 +++++++++++---------------- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index e44c4d7dad1..11c6fa9b19d 100644 --- a/controllers/story.js +++ b/controllers/story.js @@ -179,6 +179,9 @@ exports.comments = function(req, res, next) { exports.newStory = function(req, res, next) { var url = req.body.data.url; + if (url.search(/^https?:\/\//g) === -1) { + url = 'http://' + url; + } debug('In pre submit with a url', url); Story.find({'link': url}, function(err, story) { @@ -193,13 +196,14 @@ exports.newStory = function(req, res, next) { msg: "Someone's already posted that link. Here's the discussion." }); debug('Redirecting the user with', story[0].storyLink); - res.json({ + return res.json({ alreadyPosted: true, storyURL: story.pop().storyLink }); } + resources.getURLTitle(url, processResponse); }); - resources.getURLTitle(url, processResponse); + function processResponse(err, storyTitle) { if (err) { res.json({ diff --git a/public/css/main.less b/public/css/main.less index 0fba6d88197..3a95c021aa2 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -395,9 +395,21 @@ ul { font-size: 30px; } +.btn-small { + font-size: 30px; + @media (max-width: 768px) { + font-size: 15px; + height: 26.5px; + padding-top: 1px; + } +} .big-text-field { font-size: 30px; height: 57px; + @media (max-width: 768px) { + font-size: 15px; + height: 26.5px; + } } .table { diff --git a/public/js/main.js b/public/js/main.js index 93cbb46cb03..22c2f0751c0 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -253,6 +253,12 @@ profileValidation.controller('emailSignInController', ['$scope', } ]); +profileValidation.controller('URLSubmitController', ['$scope', + function($scope) { + + } +]); + profileValidation.controller('nonprofitFormController', ['$scope', function($scope) { diff --git a/views/stories/preliminary-submit.jade b/views/stories/preliminary-submit.jade index f8485ff26c1..70ca4bf6016 100644 --- a/views/stories/preliminary-submit.jade +++ b/views/stories/preliminary-submit.jade @@ -1,24 +1,17 @@ .col-xs-12 .spacer - .input-group - input#story-url.big-text-field.form-control(placeholder='Paste your link here', name='Link', autofocus) - span.input-group-btn - button#preliminary-story-submit.btn.btn-big.btn-primary(type='button') Submit + div(ng-controller="URLSubmitController") + + form.input-group(name='URLSubmit') + input#story-url.big-text-field.form-control(placeholder='Paste your link here', name='link', type='url', ng-model='possibleURL' autofocus) + span.input-group-btn + button#preliminary-story-submit.btn.btn-big.btn-primary(type='button', ng-disabled='URLSubmit.link.$invalid') Submit + 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 - - // - .col-xs-12 - form.form-horizontal.control-label-story-submission#story-submission-form - .col-xs-2.img-story-post - img.img-responsive(src='#{user.profile.picture}') - .col-xs-10 - .form-group - .col-xs-11 - input#story-url.form-control(placeholder='Paste your link here', name='Link') - .spacer - .form-group - button.btn.btn-big.btn-block.btn-primary Submit script. $('#story-url').on('keypress', function(e) { if (e.which === 13 || e === 13) { @@ -44,10 +37,11 @@ .done(function (data, textStatus, xhr) { if (data.alreadyPosted) { window.location = '/stories/' + data.storyURL; + } else { + window.location = '/stories/submit/url=' + + encodeURIComponent(data.storyURL) + + '&title=' + encodeURIComponent(data.storyTitle); } - window.location = '/stories/submit/url=' + - encodeURIComponent(data.storyURL) + - '&title=' + encodeURIComponent(data.storyTitle); }); } $('#preliminary-story-submit').on('click', preliminaryStorySubmit); \ No newline at end of file