This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 823
URL previewing support #260
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e6842ea
WIP url previewing
ara4n 4d959fc
improve layout and make thumbnails work
ara4n 62d04c3
fix typo and add linkify descriptions
ara4n 4388334
fix up scroll behaviour when loading widgets
ara4n a6b6be7
add ImageUtils
ara4n bffb482
add FIXME
ara4n 2d289b3
Merge branch 'develop' into matthew/preview_urls
ara4n f195d2e
Merge branch 'develop' into matthew/preview_urls
ara4n f9c914c
specify timestamps for historical previews
ara4n e61c99f
support cancelling previews
ara4n 0eb7b62
ugly impl to track whether to hide the widget or not
ara4n 96b0f42
support lightboxes for image previews
ara4n 1de4e0d
label previews with the target URL if all else fails
ara4n 7884c13
Merge branch 'develop' into matthew/preview_urls
ara4n 1125c62
add comments for thumbHeight
ara4n 1d8b080
incorporate PR feedback
ara4n 4abc5d0
add comment
ara4n 23d6edb
forceupdate the whole scrollPanel rather than the geminiPanel at vdh'…
ara4n 6c372d3
add the concept of eventTileOps for managing widget visibility based …
ara4n 8e48bed
apparently we don't need this. i'm lost now
ara4n 9845e5e
move all the localstorage crap to TextualBody
ara4n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2015, 2016 OpenMarket Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
|
||
/** | ||
* Returns the actual height that an image of dimensions (fullWidth, fullHeight) | ||
* will occupy if resized to fit inside a thumbnail bounding box of size | ||
* (thumbWidth, thumbHeight). | ||
* | ||
* If the aspect ratio of the source image is taller than the aspect ratio of | ||
* the thumbnail bounding box, then we return the thumbHeight parameter unchanged. | ||
* Otherwise we return the thumbHeight parameter scaled down appropriately to | ||
* reflect the actual height the scaled thumbnail occupies. | ||
* | ||
* This is very useful for calculating how much height a thumbnail will actually | ||
* consume in the timeline, when performing scroll offset calcuations | ||
* (e.g. scroll locking) | ||
*/ | ||
thumbHeight: function(fullWidth, fullHeight, thumbWidth, thumbHeight) { | ||
if (!fullWidth || !fullHeight) { | ||
// Cannot calculate thumbnail height for image: missing w/h in metadata. We can't even | ||
// log this because it's spammy | ||
return undefined; | ||
} | ||
if (fullWidth < thumbWidth && fullHeight < thumbHeight) { | ||
// no scaling needs to be applied | ||
return fullHeight; | ||
} | ||
var widthMulti = thumbWidth / fullWidth; | ||
var heightMulti = thumbHeight / fullHeight; | ||
if (widthMulti < heightMulti) { | ||
// width is the dominant dimension so scaling will be fixed on that | ||
return Math.floor(widthMulti * fullHeight); | ||
} | ||
else { | ||
// height is the dominant dimension so scaling will be fixed on that | ||
return Math.floor(heightMulti * fullHeight); | ||
} | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,6 @@ limitations under the License. | |
|
||
module.exports.components = {}; | ||
module.exports.components['structures.CreateRoom'] = require('./components/structures/CreateRoom'); | ||
module.exports.components['structures.login.ForgotPassword'] = require('./components/structures/login/ForgotPassword'); | ||
module.exports.components['structures.login.Login'] = require('./components/structures/login/Login'); | ||
module.exports.components['structures.login.PostRegistration'] = require('./components/structures/login/PostRegistration'); | ||
module.exports.components['structures.login.Registration'] = require('./components/structures/login/Registration'); | ||
module.exports.components['structures.MatrixChat'] = require('./components/structures/MatrixChat'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aside: it would be nice to fix |
||
module.exports.components['structures.MessagePanel'] = require('./components/structures/MessagePanel'); | ||
module.exports.components['structures.RoomStatusBar'] = require('./components/structures/RoomStatusBar'); | ||
|
@@ -38,6 +34,10 @@ module.exports.components['structures.ScrollPanel'] = require('./components/stru | |
module.exports.components['structures.TimelinePanel'] = require('./components/structures/TimelinePanel'); | ||
module.exports.components['structures.UploadBar'] = require('./components/structures/UploadBar'); | ||
module.exports.components['structures.UserSettings'] = require('./components/structures/UserSettings'); | ||
module.exports.components['structures.login.ForgotPassword'] = require('./components/structures/login/ForgotPassword'); | ||
module.exports.components['structures.login.Login'] = require('./components/structures/login/Login'); | ||
module.exports.components['structures.login.PostRegistration'] = require('./components/structures/login/PostRegistration'); | ||
module.exports.components['structures.login.Registration'] = require('./components/structures/login/Registration'); | ||
module.exports.components['views.avatars.BaseAvatar'] = require('./components/views/avatars/BaseAvatar'); | ||
module.exports.components['views.avatars.MemberAvatar'] = require('./components/views/avatars/MemberAvatar'); | ||
module.exports.components['views.avatars.RoomAvatar'] = require('./components/views/avatars/RoomAvatar'); | ||
|
@@ -64,10 +64,10 @@ module.exports.components['views.login.LoginHeader'] = require('./components/vie | |
module.exports.components['views.login.PasswordLogin'] = require('./components/views/login/PasswordLogin'); | ||
module.exports.components['views.login.RegistrationForm'] = require('./components/views/login/RegistrationForm'); | ||
module.exports.components['views.login.ServerConfig'] = require('./components/views/login/ServerConfig'); | ||
module.exports.components['views.messages.MessageEvent'] = require('./components/views/messages/MessageEvent'); | ||
module.exports.components['views.messages.MFileBody'] = require('./components/views/messages/MFileBody'); | ||
module.exports.components['views.messages.MImageBody'] = require('./components/views/messages/MImageBody'); | ||
module.exports.components['views.messages.MVideoBody'] = require('./components/views/messages/MVideoBody'); | ||
module.exports.components['views.messages.MessageEvent'] = require('./components/views/messages/MessageEvent'); | ||
module.exports.components['views.messages.TextualBody'] = require('./components/views/messages/TextualBody'); | ||
module.exports.components['views.messages.TextualEvent'] = require('./components/views/messages/TextualEvent'); | ||
module.exports.components['views.messages.UnknownBody'] = require('./components/views/messages/UnknownBody'); | ||
|
@@ -77,6 +77,7 @@ module.exports.components['views.rooms.AuxPanel'] = require('./components/views/ | |
module.exports.components['views.rooms.EntityTile'] = require('./components/views/rooms/EntityTile'); | ||
module.exports.components['views.rooms.EventTile'] = require('./components/views/rooms/EventTile'); | ||
module.exports.components['views.rooms.InviteMemberList'] = require('./components/views/rooms/InviteMemberList'); | ||
module.exports.components['views.rooms.LinkPreviewWidget'] = require('./components/views/rooms/LinkPreviewWidget'); | ||
module.exports.components['views.rooms.MemberInfo'] = require('./components/views/rooms/MemberInfo'); | ||
module.exports.components['views.rooms.MemberList'] = require('./components/views/rooms/MemberList'); | ||
module.exports.components['views.rooms.MemberTile'] = require('./components/views/rooms/MemberTile'); | ||
|
@@ -90,8 +91,8 @@ module.exports.components['views.rooms.RoomPreviewBar'] = require('./components/ | |
module.exports.components['views.rooms.RoomSettings'] = require('./components/views/rooms/RoomSettings'); | ||
module.exports.components['views.rooms.RoomTile'] = require('./components/views/rooms/RoomTile'); | ||
module.exports.components['views.rooms.RoomTopicEditor'] = require('./components/views/rooms/RoomTopicEditor'); | ||
module.exports.components['views.rooms.SearchableEntityList'] = require('./components/views/rooms/SearchableEntityList'); | ||
module.exports.components['views.rooms.SearchResultTile'] = require('./components/views/rooms/SearchResultTile'); | ||
module.exports.components['views.rooms.SearchableEntityList'] = require('./components/views/rooms/SearchableEntityList'); | ||
module.exports.components['views.rooms.SimpleRoomHeader'] = require('./components/views/rooms/SimpleRoomHeader'); | ||
module.exports.components['views.rooms.TabCompleteBar'] = require('./components/views/rooms/TabCompleteBar'); | ||
module.exports.components['views.rooms.TopUnreadMessagesBar'] = require('./components/views/rooms/TopUnreadMessagesBar'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is a public function, it would be nice to give this a comment saying what it does and what the parameters mean. How does its result relate to the
thumbHeight
param? Which of the params are allowed to be undefined? I could figure it out, but I shouldn't have to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done