Browse Source

Added broadcast in UI

master
Igor Zhukov 9 years ago
parent
commit
82e5f0c068
  1. 5
      app/js/controllers.js
  2. 9
      app/js/directives.js
  3. 1
      app/js/locales/en-us.json
  4. 5
      app/js/message_composer.js
  5. 6
      app/partials/desktop/im.html
  6. 2
      app/partials/mobile/im.html

5
app/js/controllers.js

@ -1156,8 +1156,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1156,8 +1156,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
data: peerData
});
MtpApiManager.getUserID().then(function (id) {
$scope.ownID = id;
MtpApiManager.getUserID().then(function (myID) {
$scope.ownID = myID;
});
if (preload) {
@ -2147,6 +2147,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2147,6 +2147,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
Storage.get('draft' + $scope.curDialog.peerID).then(function (draftText) {
// console.log('Restore draft', 'draft' + $scope.curDialog.peerID, draftText);
$scope.draftMessage.text = draftText || '';
$scope.draftMessage.isBroadcast = AppPeersManager.isChannel($scope.curDialog.peerID);
// console.log('send broadcast', $scope.draftMessage);
$scope.$broadcast('ui_peer_draft');
});

9
app/js/directives.js

@ -1395,7 +1395,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1395,7 +1395,7 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('mySendForm', function ($timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService) {
.directive('mySendForm', function (_, $timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService) {
return {
link: link,
@ -1495,9 +1495,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1495,9 +1495,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var richTextarea = composer.richTextareaEl[0];
if (richTextarea) {
$(richTextarea)
.attr('placeholder', $interpolate($(messageField).attr('placeholder'))($scope))
.on('keydown keyup', updateHeight);
$(richTextarea).on('keydown keyup', updateHeight);
}
fileSelects.on('change', function () {
@ -1571,6 +1569,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1571,6 +1569,9 @@ angular.module('myApp.directives', ['myApp.filters'])
$scope.$on('ui_peer_change', composer.resetTyping.bind(composer));
$scope.$on('ui_peer_draft', function () {
var isBroadcast = $scope.draftMessage.isBroadcast;
composer.setPlaceholder(_(isBroadcast ? 'im_broadcast_field_placeholder_raw' : 'im_message_field_placeholder_raw'));
if (richTextarea) {
composer.setValue($scope.draftMessage.text || '');
updateHeight();

1
app/js/locales/en-us.json

@ -442,6 +442,7 @@ @@ -442,6 +442,7 @@
"im_reply_loading": "Loading{dots}",
"im_photos_drop_text": "Drop photos here to send",
"im_message_field_placeholder": "Write a message...",
"im_broadcast_field_placeholder": "Broadcast a message...",
"im_media_attach_title": "Send media",
"im_attach_file_title": "Send file",
"im_emoji_btn_title": "Insert emoticon",

5
app/js/message_composer.js

@ -1174,6 +1174,11 @@ MessageComposer.prototype.resetTyping = function () { @@ -1174,6 +1174,11 @@ MessageComposer.prototype.resetTyping = function () {
this.lastLength = 0;
}
MessageComposer.prototype.setPlaceholder = function (newPlaceholder) {
(this.richTextareaEl || this.textareaEl).attr('placeholder', newPlaceholder);
}
function Scroller(content, options) {

6
app/partials/desktop/im.html

@ -170,10 +170,10 @@ @@ -170,10 +170,10 @@
<div class="im_send_form_wrap clearfix" ng-controller="AppImSendController" ng-class="{im_send_reply_form_wrap: draftMessage.replyToMessage != null}">
<a class="pull-right im_panel_peer_photo" my-peer-photolink="historyPeer.id" img-class="im_panel_peer_photo" watch="true">
<a class="pull-right im_panel_peer_photo" my-peer-photolink="historyPeer.id" img-class="im_panel_peer_photo" watch="true" ng-show="!draftMessage.isBroadcast">
<i class="icon im_panel_peer_online" ng-show="historyPeer.id > 0 &amp;&amp; historyPeer.data.status._ == 'userStatusOnline'"></i>
</a>
<a class="pull-left im_panel_own_photo" my-peer-photolink="ownID" img-class="im_panel_own_photo" watch="true" ng-click="openSettings()" no-open="true"></a>
<a class="pull-left im_panel_own_photo" my-peer-photolink="draftMessage.isBroadcast ? historyPeer.id : ownID" img-class="im_panel_own_photo" watch="true" ng-click="openSettings()" no-open="true"></a>
<form my-send-form draft-message="draftMessage" mentions="mentions" commands="commands" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}">
@ -188,7 +188,7 @@ @@ -188,7 +188,7 @@
<a class="composer_keyboard_btn" ng-show="historyState.replyKeyboard._ == 'replyKeyboardMarkup'" ng-mousedown="replyKeyboardToggle($event)" ng-class="!historyState.replyKeyboard.pFlags.hidden ? 'active' : ''"><i class="icon icon-keyboard"></i></a>
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>
<textarea ng-model="draftMessage.text" placeholder="{{'im_message_field_placeholder' | i18n}}" class="form-control im_message_field no_outline" dir="auto"></textarea>
<textarea ng-model="draftMessage.text" class="form-control im_message_field no_outline" dir="auto"></textarea>
</div>
<div class="im_send_buttons_wrap clearfix">

2
app/partials/mobile/im.html

@ -151,7 +151,7 @@ @@ -151,7 +151,7 @@
<a class="composer_keyboard_btn" ng-show="historyState.replyKeyboard._ == 'replyKeyboardMarkup'" ng-mousedown="replyKeyboardToggle($event)" ng-class="!historyState.replyKeyboard.pFlags.hidden ? 'active' : ''"><i class="icon icon-keyboard"></i></a>
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>
<textarea ng-model="draftMessage.text" placeholder="{{'im_message_field_placeholder' | i18n}}" class="form-control im_message_field no_outline" dir="auto"></textarea>
<textarea ng-model="draftMessage.text" class="form-control im_message_field no_outline" dir="auto"></textarea>
</div>
<div class="im_attach pull-right">

Loading…
Cancel
Save