| ... | ... |
@@ -99,6 +99,9 @@ this.App = |
| 99 | 99 |
updateMyStatus: (message, state)-> |
| 100 | 100 |
App.Com.trigger(event: 'app.roster.updateMyStatus', data: {message: message, state: state})
|
| 101 | 101 |
|
| 102 |
+ updateMyVcard: (name, avatar) -> |
|
| 103 |
+ App.Com.trigger(event: 'app.roster.updateMyVcard', data: {name: name})
|
|
| 104 |
+ |
|
| 102 | 105 |
removeContactRemote: (contact, client) -> |
| 103 | 106 |
App.Com.trigger(event: 'app.roster.removeContact', data: {jid: contact, client: client})
|
| 104 | 107 |
|
| ... | ... |
@@ -1,8 +1,9 @@ |
| 1 | 1 |
.user |
| 2 | 2 |
.avatar.bigger{ title: "#{@jid}" }
|
| 3 | 3 |
%img{ src: "#{@avatar || 'assets/avatar.png'}", alt: I18n.t('chat.roster.avatar_alt') }
|
| 4 |
- %h1{ title: "#{@jid}"} #{@name }
|
|
| 5 |
- %h2 #{@message || '<input type="text" class="js-click-edit empty" value="'+I18n.t('chat.roster.change_status_msg')+'">'}
|
|
| 4 |
+ %h1 |
|
| 5 |
+ %input{ type: 'text', title: "#{@jid}", class: 'js-edit-name', value: "#{@name}"}
|
|
| 6 |
+ %h2 #{@message || '<input type="text" class="js-edit-status empty" value="'+I18n.t('chat.roster.change_status_msg')+'">' }
|
|
| 6 | 7 |
-#todo: nastylovat placeholder |
| 7 | 8 |
%h3 |
| 8 | 9 |
.rolldown.js-change-state |
| ... | ... |
@@ -5,8 +5,12 @@ class Xmpp.Views.Contacts.MeView extends Backbone.View |
| 5 | 5 |
el: $('#js-me')
|
| 6 | 6 |
|
| 7 | 7 |
events: |
| 8 |
- 'click .js-click-edit': (e) -> @editMyStatus(e) |
|
| 9 |
- 'keypress .js-click-edit': (e) -> @confirmMyStatus(e) |
|
| 8 |
+ 'click .js-edit-status': (e) -> @editTextInput(e) |
|
| 9 |
+ 'keypress .js-edit-status': (e) -> @confirmMyStatus(e) |
|
| 10 |
+ |
|
| 11 |
+ 'click .js-edit-name': (e) -> @editTextInput(e) |
|
| 12 |
+ 'keypress .js-edit-name': (e) -> @confirmMyName(e) |
|
| 13 |
+ |
|
| 10 | 14 |
'click .js-change-state': (e) -> @openChangeState(e) |
| 11 | 15 |
'click .js-state-clickable': (e) -> @confirmChangeState(e) |
| 12 | 16 |
|
| ... | ... |
@@ -24,7 +28,7 @@ class Xmpp.Views.Contacts.MeView extends Backbone.View |
| 24 | 24 |
$(@el).html(@template(contact)) |
| 25 | 25 |
this |
| 26 | 26 |
|
| 27 |
- editMyStatus: (e) -> |
|
| 27 |
+ editTextInput: (e) -> |
|
| 28 | 28 |
$this = $(e.currentTarget) |
| 29 | 29 |
|
| 30 | 30 |
if ($this.hasClass('empty'))
|
| ... | ... |
@@ -50,6 +54,21 @@ class Xmpp.Views.Contacts.MeView extends Backbone.View |
| 50 | 50 |
$this.blur() |
| 51 | 51 |
App.Com.updateMyStatus(@_getStatusMessage(), @_getState()) |
| 52 | 52 |
|
| 53 |
+ confirmMyName: (e) -> |
|
| 54 |
+ if (e.which != 13 && e.which != 10) |
|
| 55 |
+ return |
|
| 56 |
+ |
|
| 57 |
+ $this = $(e.currentTarget) |
|
| 58 |
+ |
|
| 59 |
+ if ($this.val() == '') |
|
| 60 |
+ $this.removeClass('editing')
|
|
| 61 |
+ .val(@model.get('jid'))
|
|
| 62 |
+ else |
|
| 63 |
+ $this.removeClass('editing')
|
|
| 64 |
+ |
|
| 65 |
+ $this.blur() |
|
| 66 |
+ App.Com.updateMyVcard(@_getName()) |
|
| 67 |
+ |
|
| 53 | 68 |
openChangeState: (e) -> |
| 54 | 69 |
$this = $(e.currentTarget) |
| 55 | 70 |
|
| ... | ... |
@@ -73,10 +92,13 @@ class Xmpp.Views.Contacts.MeView extends Backbone.View |
| 73 | 73 |
App.Com.updateMyStatus(@_getStatusMessage(), @_getState()) |
| 74 | 74 |
|
| 75 | 75 |
_getStatusMessage: -> |
| 76 |
- if $('.js-click-edit').hasClass('empty')
|
|
| 76 |
+ if $('.js-edit-status').hasClass('empty')
|
|
| 77 | 77 |
return '' |
| 78 | 78 |
else |
| 79 |
- $('.js-click-edit').val()
|
|
| 79 |
+ $('.js-edit-status').val()
|
|
| 80 | 80 |
|
| 81 | 81 |
_getState: -> |
| 82 | 82 |
$('.js-state-clickable:not(.hidden)').data('state')
|
| 83 |
+ |
|
| 84 |
+ _getName: -> |
|
| 85 |
+ $('.js-edit-name').val()
|
|
| 83 | 86 |
\ No newline at end of file |
| ... | ... |
@@ -34,39 +34,20 @@ |
| 34 | 34 |
margin: 0 0 1px; |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
+ //.name {
|
|
| 38 |
+ // font-size: 12px; |
|
| 39 |
+ // color: $black; |
|
| 40 |
+ // text-shadow: white 1px 1px; |
|
| 41 |
+ // margin: 0; |
|
| 42 |
+ // width: auto; |
|
| 43 |
+ //} |
|
| 44 |
+ |
|
| 37 | 45 |
h1 {
|
| 38 | 46 |
font-size: 12px; |
| 39 | 47 |
color: $black; |
| 40 | 48 |
text-shadow: white 1px 1px; |
| 41 | 49 |
} |
| 42 | 50 |
|
| 43 |
- h2 {
|
|
| 44 |
- input {
|
|
| 45 |
- border: 0; |
|
| 46 |
- background: transparent; |
|
| 47 |
- width: 151px; |
|
| 48 |
- padding: 0; |
|
| 49 |
- outline: none; |
|
| 50 |
- margin: 0; |
|
| 51 |
- font-style: italic; |
|
| 52 |
- font-size: 11px; |
|
| 53 |
- font-weight: normal; |
|
| 54 |
- color: #7e8b90; |
|
| 55 |
- text-shadow: white 1px 1px; |
|
| 56 |
- height: 18px; |
|
| 57 |
- |
|
| 58 |
- &:focus {
|
|
| 59 |
- border: none !important; |
|
| 60 |
- } |
|
| 61 |
- |
|
| 62 |
- &.editing {
|
|
| 63 |
- padding: 3px 0; |
|
| 64 |
- font-style: normal; |
|
| 65 |
- text-shadow: none; |
|
| 66 |
- } |
|
| 67 |
- } |
|
| 68 |
- } |
|
| 69 |
- |
|
| 70 | 51 |
h3 {
|
| 71 | 52 |
font-size: 12px; |
| 72 | 53 |
color: $status-color; |
| ... | ... |
@@ -100,6 +81,40 @@ |
| 100 | 100 |
} |
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 |
+ h1 input, h2 input {
|
|
| 104 |
+ border: 0; |
|
| 105 |
+ background: transparent; |
|
| 106 |
+ width: 151px; |
|
| 107 |
+ padding: 0; |
|
| 108 |
+ outline: none; |
|
| 109 |
+ margin: 0; |
|
| 110 |
+ font-weight: normal; |
|
| 111 |
+ color: #7e8b90; |
|
| 112 |
+ text-shadow: white 1px 1px; |
|
| 113 |
+ height: 18px; |
|
| 114 |
+ |
|
| 115 |
+ &:focus {
|
|
| 116 |
+ border: none !important; |
|
| 117 |
+ } |
|
| 118 |
+ |
|
| 119 |
+ &.editing {
|
|
| 120 |
+ padding: 3px 0; |
|
| 121 |
+ font-style: normal; |
|
| 122 |
+ text-shadow: none; |
|
| 123 |
+ } |
|
| 124 |
+ } |
|
| 125 |
+ |
|
| 126 |
+ h1 input {
|
|
| 127 |
+ color: $black; |
|
| 128 |
+ font-size: 12px; |
|
| 129 |
+ font-weight: bold; |
|
| 130 |
+ } |
|
| 131 |
+ |
|
| 132 |
+ h2 input {
|
|
| 133 |
+ font-style: italic; |
|
| 134 |
+ font-size: 11px; |
|
| 135 |
+ } |
|
| 136 |
+ |
|
| 103 | 137 |
.avatar {
|
| 104 | 138 |
float: left; |
| 105 | 139 |
|
| ... | ... |
@@ -191,7 +191,11 @@ class WsRosterController < WsController |
| 191 | 191 |
end |
| 192 | 192 |
|
| 193 | 193 |
def me_update_vcard |
| 194 |
- |
|
| 194 |
+ connection_store[:clients].each do |client| |
|
| 195 |
+ my_vcard = Jabber::Vcard::Helper.get(client) |
|
| 196 |
+ my_vcard['FN'] = my_vcard['NICKNAME'] = message[:name] |
|
| 197 |
+ Jabber::Vcard::Helper.set(client, my_vcard) |
|
| 198 |
+ end |
|
| 195 | 199 |
end |
| 196 | 200 |
|
| 197 | 201 |
def disconnect |