Skip to content

Commit

Permalink
Initial implementation of search in channel
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Aug 28, 2015
1 parent b1de4c8 commit ca0710d
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 170 deletions.
247 changes: 124 additions & 123 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -2455,149 +2455,150 @@ a.github-fork {
border-radius: 4px;
}
}
.message {
font-size: 14px;
padding-left: 50px;
position: relative;
line-height: 20px;
margin: 12px 20px 5px;
margin-top: 12px;
min-height: 40px;
&:nth-child(1) {
margin-top: 0;
}
&.new-day {
margin-top: 60px;
}
&.new-day {
&:before {
content: attr(data-date);
display: block;
position: absolute;
top: -30px;
left: 0;
font-size: 12px;
font-weight: 600;
text-align: center;
.calc(left,
~"50% - 70px");
color: @secondary-font-color;
z-index: 10;
padding: 0 10px;
background-color: #FFF;
min-width: 140px;
}
&:after {
content: " ";
display: block;
position: absolute;
top: -20px;
left: 0;
width: 100%;
border-top: 1px solid #ddd;
}
}
.edit-message {
display: none;
cursor: pointer;
}
&.own:hover:not(.system) .edit-message {
display: inline-block;
}

.message {
font-size: 14px;
padding-left: 50px;
position: relative;
line-height: 20px;
margin: 12px 20px 5px;
margin-top: 12px;
min-height: 40px;
&:nth-child(1) {
margin-top: 0;
}
&.new-day {
margin-top: 60px;
}
&.new-day {
&:before {
content: attr(data-date);
display: block;
position: absolute;
top: -30px;
left: 0;
font-size: 12px;
font-weight: 600;
text-align: center;
.calc(left,
~"50% - 70px");
color: @secondary-font-color;
z-index: 10;
padding: 0 10px;
background-color: #FFF;
min-width: 140px;
}
.delete-message {
display: none;
cursor: pointer;
&:after {
content: " ";
display: block;
position: absolute;
top: -20px;
left: 0;
width: 100%;
border-top: 1px solid #ddd;
}
&.own:hover:not(.system) .delete-message {
display: inline-block;
}
.edit-message {
display: none;
cursor: pointer;
}
&.own:hover:not(.system) .edit-message {
display: inline-block;
}
.delete-message {
display: none;
cursor: pointer;
}
&.own:hover:not(.system) .delete-message {
display: inline-block;
}
.user {
display: inline-block;
font-weight: 600;
color: #444444;
margin-right: 5px;
&:hover {
color: #333;
}
}
.thumb {
position: absolute;
left: 0;
top: 0;
display: block;
width: 40px;
height: 40px;
}
.info {
font-size: 12px;
color: @info-font-color;
}
&.sequential {
margin-top: 5px;
min-height: 20px;
.user {
display: inline-block;
font-weight: 600;
color: #444444;
margin-right: 5px;
&:hover {
color: #333;
}
display: none;
}
.thumb {
position: absolute;
left: 0;
top: 0;
display: block;
width: 40px;
height: 40px;
display: none;
}
.info {
font-size: 12px;
color: @info-font-color;
}
&.sequential {
margin-top: 5px;
min-height: 20px;
.user {
position: absolute;
text-align: right;
left: -20px;
width: 65px;
.time {
display: none;
}
.thumb {
display: none;
.edited {
display: inline-block;
}
.info {
position: absolute;
text-align: right;
left: -20px;
width: 65px;
.time {
display: none;
}
.edited {
display: inline-block;
}
.edit-message {
float: left;
margin-left: 1px;
}
.delete-message {
float: left;
}
.edit-message {
float: left;
margin-left: 1px;
}
&:hover {
.time {
display: inline-block;
}
.edited {
display: none;
}
.delete-message {
float: left;
}
}
&.system {
.body {
color: @info-font-color;
font-style: italic;
text-transform: lowercase;
em {
font-weight: 600;
}
&:hover {
.time {
display: inline-block;
}
}
.avatar-initials {
line-height: 40px;
}
a {
color: @link-font-color;
font-weight: 400;
&:hover {
color: darken(@link-font-color, 10%);
text-decoration: underline;
.edited {
display: none;
}
}
}
&.system {
.body {
opacity: 1;
.transition(opacity 1s linear);
color: @info-font-color;
font-style: italic;
text-transform: lowercase;
em {
font-weight: 600;
}
}
&.temp .body {
opacity: .5;
}
.avatar-initials {
line-height: 40px;
}
a {
color: @link-font-color;
font-weight: 400;
&:hover {
color: darken(@link-font-color, 10%);
text-decoration: underline;
}
}
.body {
opacity: 1;
.transition(opacity 1s linear);
}
&.temp .body {
opacity: .5;
}
}

// FLEX-TAB and FLEX-TAB views
Expand Down Expand Up @@ -2700,7 +2701,7 @@ a.github-fork {
> div {
position: relative;
}
.icon-plus {
.icon-plus {
position: absolute;
top: 11px;
left: 8px;
Expand Down
4 changes: 2 additions & 2 deletions client/views/app/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Template.message.onViewRendered = (context) ->

if not lastNode.nextElementSibling?
if lastNode.classList.contains('own') is true
view.parentView.parentView.parentView.parentView.parentView.templateInstance().atBottom = true
view.parentView.parentView.parentView.parentView.parentView.templateInstance?().atBottom = true
else
if view.parentView.parentView.parentView.parentView.parentView.templateInstance().atBottom isnt true
if view.parentView.parentView.parentView.parentView.parentView.templateInstance?().atBottom isnt true
newMessage = document.querySelector(".new-message")
newMessage.className = "new-message"
19 changes: 18 additions & 1 deletion client/views/app/room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Template.room.helpers
tQuickSearch: ->
return t('Quick_Search')

searchResult: ->
return Template.instance().searchResult.get()

favorite: ->
sub = ChatSubscription.findOne { rid: this._id }, { fields: { f: 1 } }
return 'icon-star favorite-room' if sub?.f? and sub.f
Expand Down Expand Up @@ -275,6 +278,18 @@ Template.room.helpers


Template.room.events
"keyup #room-search": _.debounce (e, t) ->
t.searchResult.set undefined
value = e.target.value.trim()
if value is ''
return

Tracker.nonreactive ->
Meteor.call 'messageSearch', value, Session.get('openedRoom'), (error, result) ->
if result? and (result.messages?.length > 0 or result.users?.length > 0 or result.channels?.length > 0)
t.searchResult.set result
, 1000

"touchstart .message": (e, t) ->
message = this._arguments[1]
doLongTouch = ->
Expand All @@ -294,10 +309,11 @@ Template.room.events
"click .upload-progress-item > a": ->
Session.set "uploading-cancel-#{this.id}", true

"click .flex-tab .more": (event) ->
"click .flex-tab .more": (event, t) ->
if (Session.get('flexOpened'))
Session.set('rtcLayoutmode', 0)
Session.set('flexOpened',false)
t.searchResult.set undefined
else
Session.set('flexOpened', true)

Expand Down Expand Up @@ -630,6 +646,7 @@ Template.room.onCreated ->
# this.typing = new msgTyping this.data._id
this.showUsersOffline = new ReactiveVar false
this.atBottom = true
this.searchResult = new ReactiveVar

self = @

Expand Down
Loading

0 comments on commit ca0710d

Please sign in to comment.