From 528e0094d1cee503e0b2f48ce499c766290b3d74 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 9 Mar 2015 13:55:13 +0900 Subject: [PATCH] Add image display to show view for news --- public/css/main.less | 5 +++++ public/js/main.js | 2 +- views/stories/show.jade | 6 ++++++ views/stories/submit-story.jade | 13 ++++++++++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/public/css/main.less b/public/css/main.less index 37fc8a39ce..406fa54594 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -821,6 +821,11 @@ iframe.iphone { height: 50px; } +.url-preview { + max-width: 250px; + max-height: 250px; +} + //.media ~ .media .media-body-wrapper:nth-child(odd) { // background-color: #e5e5e5; //} diff --git a/public/js/main.js b/public/js/main.js index 64a90ce2d2..893d4d5fac 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -173,7 +173,7 @@ $(document).ready(function() { username: user.profile.username }, comments: [], - image: '' + image: storyImage } }) .fail(function (xhr, textStatus, errorThrown) { diff --git a/views/stories/show.jade b/views/stories/show.jade index 985b9d4f2a..1c83a27354 100644 --- a/views/stories/show.jade +++ b/views/stories/show.jade @@ -5,6 +5,7 @@ var comments = !{JSON.stringify(comments)}; var upVotes = !{JSON.stringify(upVotes)}; var user = !{JSON.stringify(user)}; + var image = !{JSON.stringify(image)}; .spacer h3.row.col-xs-12 @@ -33,6 +34,8 @@ a(href="/" + author.username)@#{author.username} |  ยท  a#reply-to-main-post Reply + .col-xs-12.positive-15.hidden-element#image-display + img.url-preview(src="#{image}") .col-xs-12#reply-area .hidden-element#initial-comment-submit form.form-horizontal.control-label-story-submission @@ -44,6 +47,9 @@ span.spacer.pull-left#textarea_feedback script. + if (image) { + $('#image-display').removeClass('hidden-element') + } $('#reply-to-main-post').on('click', function() { $('#initial-comment-submit').removeClass('hidden-element'); $(this).unbind('click'); diff --git a/views/stories/submit-story.jade b/views/stories/submit-story.jade index 6b44c2c68e..deac4e1f97 100644 --- a/views/stories/submit-story.jade +++ b/views/stories/submit-story.jade @@ -21,17 +21,24 @@ label.control-label.control-label-story-submission(for='name') Description .col-xs-12.col-md-11 input#description-box.form-control(name="comment-box", placeholder="Start off the discussion with a description of your post" maxlength='140') + .form-group + .col-xs-12.col-md-offset-1 span.pull-left#textarea_feedback - .row - img.img-center.img-responsive(src="#{storyImage}", style="max-width: 250px; max-height: 250px") + .form-group + .col-xs-12.col-md-offset-1 + .hidden-element#image-display + img.url-preview(src="#{storyImage}") .spacer .row .form-group + button.btn.btn-big.btn-block.btn-primary#story-submit Submit script. $('#story-url').val(storyURL).attr('disabled', 'disabled'); $('#story-title').val(storyTitle); - console.log(storyImage); + if (storyImage) { + $('#image-display').removeClass('hidden-element'); + } var text_max = 140; $('#textarea_feedback').html(text_max + ' characters remaining'); $('#description-box').keyup(function () {