Browse Source

Fixed buttons

master
Igor Zhukov 8 years ago
parent
commit
031a47ef25
  1. 5
      app/js/directives.js
  2. 59
      app/js/lib/ng_utils.js
  3. 21
      app/js/services.js
  4. 3
      app/less/app.less
  5. 5
      app/partials/desktop/reply_markup.html

5
app/js/directives.js

@ -264,7 +264,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -264,7 +264,7 @@ angular.module('myApp.directives', ['myApp.filters'])
updateMessageText($scope, element, message);
unlink();
}
})
});
}
$scope.$on('message_edit', function (e, data) {
@ -272,7 +272,10 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -272,7 +272,10 @@ angular.module('myApp.directives', ['myApp.filters'])
return;
}
console.log('after edit', message);
updateMessageText($scope, element, message);
updateMessageMedia($scope, element, message);
updateMessageKeyboard($scope, element, message);
$scope.$emit('ui_height');
});
}
})

59
app/js/lib/ng_utils.js

@ -1217,6 +1217,7 @@ angular.module('izhukov.utils', []) @@ -1217,6 +1217,7 @@ angular.module('izhukov.utils', [])
return {
wrapRichText: wrapRichText,
wrapPlainText: wrapPlainText,
wrapUrl: wrapUrl,
parseEntities: parseEntities,
parseMarkdown: parseMarkdown,
parseEmojis: parseEmojis,
@ -1584,32 +1585,7 @@ angular.module('izhukov.utils', []) @@ -1584,32 +1585,7 @@ angular.module('izhukov.utils', [])
break;
}
var url = entity.url || entityText;
if (!url.match(/^https?:\/\//i)) {
url = 'http://' + url;
}
var tgMeMatch;
if (entity._ == 'messageEntityTextUrl') {
url = 'tg://unsafe_url?url=' + encodeURIComponent(url);
}
else if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) {
var path = tgMeMatch[1].split('/');
switch (path[0]) {
case 'joinchat':
url = 'tg://join?invite=' + path[1];
break;
case 'addstickers':
url = 'tg://addstickers?set=' + path[1];
break;
default:
if (path[1] && path[1].match(/^\d+$/)) {
url = 'tg://resolve?domain=' + path[0] + '&post=' + path[1];
}
else if (!path[1]) {
var domainQuery = path[0].split('?');
url = 'tg://resolve?domain=' + domainQuery[0] + (domainQuery[1] ? '&' + domainQuery[1] : '');
}
}
}
url = wrapUrl(url, entity._ == 'messageEntityTextUrl');
html.push(
'<a href="',
encodeEntities(url),
@ -1765,6 +1741,37 @@ angular.module('izhukov.utils', []) @@ -1765,6 +1741,37 @@ angular.module('izhukov.utils', [])
return text.join('');
}
function wrapUrl(url, unsafe) {
var url = entity.url || entityText;
if (!url.match(/^https?:\/\//i)) {
url = 'http://' + url;
}
var tgMeMatch;
if (unsafe) {
url = 'tg://unsafe_url?url=' + encodeURIComponent(url);
}
else if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) {
var path = tgMeMatch[1].split('/');
switch (path[0]) {
case 'joinchat':
url = 'tg://join?invite=' + path[1];
break;
case 'addstickers':
url = 'tg://addstickers?set=' + path[1];
break;
default:
if (path[1] && path[1].match(/^\d+$/)) {
url = 'tg://resolve?domain=' + path[0] + '&post=' + path[1];
}
else if (!path[1]) {
var domainQuery = path[0].split('?');
url = 'tg://resolve?domain=' + domainQuery[0] + (domainQuery[1] ? '&' + domainQuery[1] : '');
}
}
}
return url;
}
})

21
app/js/services.js

@ -2410,6 +2410,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2410,6 +2410,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
sendInlineResult: sendInlineResult,
regroupWrappedResults: regroupWrappedResults,
switchToPM: switchToPM,
checkSwitchReturn: checkSwitchReturn,
getInlineResults: getInlineResults,
getPopularBots: getPopularBots
};
@ -2489,7 +2490,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2489,7 +2490,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
result.rTitle = RichTextProcessor.wrapRichText(result.title, {noLinebreaks: true, noLinks: true});
result.rDescription = RichTextProcessor.wrapRichText(result.description, {noLinebreaks: true, noLinks: true});
result.initials = (result.url || result.title || result.type || '').substr(0, 1)
result.initials = (result.url || result.title || result.type || '').substr(0, 1);
if (result.document) {
AppDocsManager.saveDoc(result.document);
@ -2500,6 +2501,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2500,6 +2501,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
inlineResults[qID] = result;
});
console.log('res', botResults);
return botResults;
});
}
@ -2513,6 +2515,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2513,6 +2515,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
AppMessagesManager.startBot(botID, 0, startParam);
}
function checkSwitchReturn(botID) {
var bot = AppUsersManager.getUser(botID);
if (!bot || !bot.pFlags.bot || !bot.bot_inline_placeholder) {
return qSync.when(false);
}
var key = 'inline_switch_pm' + botID;
return Storage.get(key).then(function (peerData) {
if (peerData) {
Storage.remove(key);
if (tsNow() - peerData.time < 3600000) {
return peerData.peerString;
}
}
return false;
});
}
function regroupWrappedResults (results, rowW, rowH) {
if (!results ||
!results[0] ||

3
app/less/app.less

@ -3320,6 +3320,9 @@ _:-ms-lang(x), .composer_rich_textarea:empty:focus:before { @@ -3320,6 +3320,9 @@ _:-ms-lang(x), .composer_rich_textarea:empty:focus:before {
color: #698192;
}
}
.inline_article_url {
padding-top: 4px;
}
.composer_dropdown > li.inline_result_gif > a,
.composer_dropdown > li.inline_result_photo > a,

5
app/partials/desktop/reply_markup.html

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
<div class="reply_markup_wrap">
<div class="reply_markup" ng-class="replyMarkup.splitCount ? 'reply_markup_h' + replyMarkup.splitCount : ''">
<div class="reply_markup_row" ng-repeat="row in replyMarkup.rows">
<div class="reply_markup_button_wrap" ng-class="'reply_markup_button_w' + row.buttons.length" ng-repeat="button in row.buttons">
<button class="btn reply_markup_button" ng-bind-html="::button.rText" ng-click="buttonSend(button)"></button>
<div class="reply_markup_button_wrap" ng-class="'reply_markup_button_w' + row.buttons.length" ng-repeat="button in row.buttons" ng-switch="button._">
<a ng-switch-when="keyboardButtonUrl" class="btn reply_markup_button" ng-bind-html="::button.rText" ng-click="buttonSend(button)"></a>
<button ng-switch-default class="btn reply_markup_button" ng-bind-html="::button.rText" ng-click="buttonSend(button)"></button>
</div>
</div>
</div>

Loading…
Cancel
Save