Browse Source

Fixed buttons

master
Igor Zhukov 9 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'])
updateMessageText($scope, element, message); updateMessageText($scope, element, message);
unlink(); unlink();
} }
}) });
} }
$scope.$on('message_edit', function (e, data) { $scope.$on('message_edit', function (e, data) {
@ -272,7 +272,10 @@ angular.module('myApp.directives', ['myApp.filters'])
return; return;
} }
console.log('after edit', message); console.log('after edit', message);
updateMessageText($scope, element, message);
updateMessageMedia($scope, element, message);
updateMessageKeyboard($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', [])
return { return {
wrapRichText: wrapRichText, wrapRichText: wrapRichText,
wrapPlainText: wrapPlainText, wrapPlainText: wrapPlainText,
wrapUrl: wrapUrl,
parseEntities: parseEntities, parseEntities: parseEntities,
parseMarkdown: parseMarkdown, parseMarkdown: parseMarkdown,
parseEmojis: parseEmojis, parseEmojis: parseEmojis,
@ -1584,32 +1585,7 @@ angular.module('izhukov.utils', [])
break; break;
} }
var url = entity.url || entityText; var url = entity.url || entityText;
if (!url.match(/^https?:\/\//i)) { url = wrapUrl(url, entity._ == 'messageEntityTextUrl');
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] : '');
}
}
}
html.push( html.push(
'<a href="', '<a href="',
encodeEntities(url), encodeEntities(url),
@ -1765,6 +1741,37 @@ angular.module('izhukov.utils', [])
return text.join(''); 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'])
sendInlineResult: sendInlineResult, sendInlineResult: sendInlineResult,
regroupWrappedResults: regroupWrappedResults, regroupWrappedResults: regroupWrappedResults,
switchToPM: switchToPM, switchToPM: switchToPM,
checkSwitchReturn: checkSwitchReturn,
getInlineResults: getInlineResults, getInlineResults: getInlineResults,
getPopularBots: getPopularBots getPopularBots: getPopularBots
}; };
@ -2489,7 +2490,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
result.rTitle = RichTextProcessor.wrapRichText(result.title, {noLinebreaks: true, noLinks: true}); result.rTitle = RichTextProcessor.wrapRichText(result.title, {noLinebreaks: true, noLinks: true});
result.rDescription = RichTextProcessor.wrapRichText(result.description, {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) { if (result.document) {
AppDocsManager.saveDoc(result.document); AppDocsManager.saveDoc(result.document);
@ -2500,6 +2501,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
inlineResults[qID] = result; inlineResults[qID] = result;
}); });
console.log('res', botResults);
return botResults; return botResults;
}); });
} }
@ -2513,6 +2515,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
AppMessagesManager.startBot(botID, 0, startParam); 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) { function regroupWrappedResults (results, rowW, rowH) {
if (!results || if (!results ||
!results[0] || !results[0] ||

3
app/less/app.less

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

5
app/partials/desktop/reply_markup.html

@ -1,8 +1,9 @@
<div class="reply_markup_wrap"> <div class="reply_markup_wrap">
<div class="reply_markup" ng-class="replyMarkup.splitCount ? 'reply_markup_h' + replyMarkup.splitCount : ''"> <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_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"> <div class="reply_markup_button_wrap" ng-class="'reply_markup_button_w' + row.buttons.length" ng-repeat="button in row.buttons" ng-switch="button._">
<button class="btn reply_markup_button" ng-bind-html="::button.rText" ng-click="buttonSend(button)"></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> </div>
</div> </div>

Loading…
Cancel
Save