Skip to content

Commit

Permalink
Merge pull request #550 from RocketChat/image-manual-download
Browse files Browse the repository at this point in the history
Prevent download of images in phone and allow click to download
  • Loading branch information
engelgabriel committed Aug 22, 2015
2 parents e10beca + 89478b9 commit dd3bc79
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
17 changes: 17 additions & 0 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1988,6 +1988,23 @@ a.github-fork {
}
}

.image-to-download {
background-color: #fafafa;
border-radius: 6px;
border: 1px dashed #ddd;
padding: 20px 15px;
margin-bottom: 5px;
display: inline-block;
text-transform: uppercase;
color: #aaa;
text-align: center;
cursor: pointer;

i {
font-size: 24px;
}
}

.upload-progress {
position: absolute;
top: 60px;
Expand Down
3 changes: 3 additions & 0 deletions client/views/app/room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ Template.room.events
Session.set('flexOpened', true)
Session.set('showUserInfo', $(e.currentTarget).data('username'))

'click .image-to-download': (event) ->
ChatMessage.update {_id: this._arguments[1]._id, 'urls.url': $(event.currentTarget).data('url')}, {$set: {'urls.$.downloadImages': true}}

'click .delete-message': (event) ->
message = @_arguments[1]
msg = event.currentTarget.parentNode.parentNode
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-oembed/client/oembedImageWidget.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Template.oembedImageWidget.helpers
showImage: ->
return @downloadImages is true or not Meteor.Device.isPhone()
17 changes: 12 additions & 5 deletions packages/rocketchat-oembed/client/oembedImageWidget.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<template name="oembedImageWidget">
<a href="{{url}}" target="_blank">
{{#if parsedUrl}}
<blockquote>
{{#if showImage}}
<a href="{{url}}" target="_blank">
{{#if parsedUrl}}
<div style="background-image: url({{url}}); background-size: contain; background-repeat: no-repeat; background-position: center left; height: 200px;"></div>
</blockquote>
{{/if}}
</a>
{{else}}
{{#if parsedUrl}}
<div class="image-to-download" data-url="{{url}}">
<i class="icon-picture"></i>
<div>click to download</div>
</div>
{{/if}}
</a>
{{/if}}
</template>
1 change: 1 addition & 0 deletions packages/rocketchat-oembed/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Package.onUse(function(api) {
api.addFiles('client/baseWidget.coffee', 'client');

api.addFiles('client/oembedImageWidget.html', 'client');
api.addFiles('client/oembedImageWidget.coffee', 'client');

api.addFiles('client/oembedAudioWidget.html', 'client');

Expand Down

0 comments on commit dd3bc79

Please sign in to comment.