Browse Source

Fixed subset of StandardJS errors (#1356)

Fixed the errors that would definitly not change the functionality of the program
These include
* Unexpected && and || combinations
* variables with different values defined in same line of code
* Global variable never defined
* spacing/placing errors

These errors were not touched
* variables who are never used
* == and != errors
master
Bart 7 years ago committed by Igor Zhukov
parent
commit
5871645ca6
  1. 1
      app/js/app.js
  2. 137
      app/js/controllers.js
  3. 306
      app/js/directives.js
  4. 3
      app/service_worker.js
  5. 47
      gulpfile.js

1
app/js/app.js

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
*/
'use strict'
/* global Config, templateUrl */
var extraModules = []
if (Config.Modes.animations) {

137
app/js/controllers.js

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
*/
'use strict'
/* global Config, location, templateUrl, onContentLoaded, tsNow, cancelEvent, safeReplaceObject, dT, SearchIndexManager, setZeroTimeout, versionCompare, calcImageInBox, getSelectedText, SVGElement */
/* Controllers */
@ -127,8 +128,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -127,8 +128,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var phoneNumber = (
($scope.credentials.phone_country || '') +
($scope.credentials.phone_number || '')
).replace(/\D+/g, ''),
i, j, code
).replace(/\D+/g, '')
var i, j, code
var maxLength = 0
var maxName = false
@ -172,11 +173,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -172,11 +173,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$timeout.cancel(nextTimeout)
var fullPhone = ($scope.credentials.phone_country || '') + ($scope.credentials.phone_number || '')
var badPhone = !fullPhone.match(/^[\d\-+\s]+$/);
var badPhone = !fullPhone.match(/^[\d\-+\s]+$/)
if (!badPhone) {
fullPhone = fullPhone.replace(/\D/g, '');
fullPhone = fullPhone.replace(/\D/g, '')
if (fullPhone.length < 7) {
badPhone = true;
badPhone = true
}
}
if (badPhone) {
@ -313,7 +314,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -313,7 +314,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
}
$scope.progress.forceSignUp = forceSignUp;
$scope.progress.forceSignUp = forceSignUp
$scope.progress.enabled = true
MtpApiManager.invokeApi(method, params, options).then(saveAuth, function (error) {
$scope.progress.enabled = false
@ -426,8 +427,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -426,8 +427,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
error.type.substr(0, 17) == '2FA_CONFIRM_WAIT_') {
error.waitTime = error.type.substr(17)
error.type = '2FA_CONFIRM_WAIT_TIME'
}
}
delete $scope.progress.enabled
})
})
@ -591,8 +592,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -591,8 +592,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var params = {peerString: peerString}
if (messageID) {
params.messageID = messageID
}
else if ($scope.search.query) {
} else if ($scope.search.query) {
$scope.searchClear()
}
var peerID = AppPeersManager.getPeerID(peerString)
@ -782,7 +782,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -782,7 +782,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
}
function sortDialogs() {
function sortDialogs () {
$scope.dialogs.sort(function (d1, d2) {
return d2.index - d1.index
})
@ -822,7 +822,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -822,7 +822,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (draftUpdate.index) {
curDialog.index = draftUpdate.index
}
sortDialogs();
sortDialogs()
break
}
}
@ -877,7 +877,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -877,7 +877,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$watchCollection('search', function () {
$scope.dialogs = []
$scope.foundMessages = []
searchMessages = $scope.searchPeer ? true : false
searchMessages = !!$scope.searchPeer
contactsJump++
loadDialogs()
})
@ -1037,7 +1037,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1037,7 +1037,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
function showMoreDialogs () {
if (contactsShown && (!hasMore || !offsetIndex && !maxID)) {
if (contactsShown && (!hasMore || (!offsetIndex && !maxID))) {
return
}
@ -1088,7 +1088,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1088,7 +1088,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('ui_dialogs_append')
hasMore = true
}else {
} else {
hasMore = false
}
})
@ -1220,9 +1220,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1220,9 +1220,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var moreJump = 0
var moreActive = false
var morePending = false
var lessJump = 0,
lessActive = false,
lessPending = false
var lessJump = 0
var lessActive = false
var lessPending = false
function applyDialogSelect (newDialog, oldDialog) {
peerID = $rootScope.selectedPeerID = newDialog.peerID
@ -1237,21 +1237,18 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1237,21 +1237,18 @@ angular.module('myApp.controllers', ['myApp.i18n'])
oldDialog.peer == newDialog.peer &&
newDialog.messageID) {
messageFocusHistory()
}
else if (peerID) {
} else if (peerID) {
updateHistoryPeer(true)
loadHistory()
}else {
} else {
showEmptyHistory()
}
}
function historiesQueuePush (peerID) {
var pos = -1
var maxLen = 10,
i,
history,
diff
var maxLen = 10
var i, history, diff
for (i = 0; i < $scope.peerHistories.length; i++) {
if ($scope.peerHistories[i].peerID == peerID) {
@ -1332,8 +1329,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1332,8 +1329,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.historyFilter.mediaType ||
$scope.curDialog.messageID) {
$scope.historyState.botActions = false
}
else if (
} else if (
$scope.state.empty || (
peerHistory &&
peerHistory.messages.length == 1 &&
@ -1342,10 +1338,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1342,10 +1338,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
)
) {
$scope.historyState.botActions = 'start'
}
else if ($scope.curDialog.startParam) {
} else if ($scope.curDialog.startParam) {
$scope.historyState.botActions = 'param'
}else {
} else {
$scope.historyState.botActions = false
}
if (wasBotActions != $scope.historyState.botActions) {
@ -1376,7 +1371,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1376,7 +1371,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
$scope.historyState.canReply = canSend
$scope.historyState.canDelete = canSend || channel.pFlags.moderator
}else {
} else {
$scope.historyState.channelActions = false
$scope.historyState.canReply = true
$scope.historyState.canDelete = true
@ -1477,7 +1472,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1477,7 +1472,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
hasMore = historyResult.count === null ||
historyResult.history.length && peerHistory.messages.length < historyResult.count
(historyResult.history.length && peerHistory.messages.length < historyResult.count)
if (historyResult.history.length) {
delete $scope.state.empty
@ -1510,8 +1505,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1510,8 +1505,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
maxID = parseInt($scope.curDialog.messageID)
limit = 20
backLimit = 20
}
else if (forceRecent) {
} else if (forceRecent) {
limit = 10
}
@ -1542,14 +1536,14 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1542,14 +1536,14 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var fetchedLength = historyResult.history.length
minID = (historyResult.unreadSkip || maxID && historyResult.history.indexOf(maxID) >= backLimit - 1)
minID = (historyResult.unreadSkip || (maxID && historyResult.history.indexOf(maxID) >= backLimit - 1))
? historyResult.history[0]
: 0
maxID = historyResult.history[historyResult.history.length - 1]
$scope.historyState.skipped = hasLess = minID > 0
hasMore = historyResult.count === null ||
fetchedLength && fetchedLength < historyResult.count
(fetchedLength && fetchedLength < historyResult.count)
updateHistoryPeer()
safeReplaceObject($scope.state, {loaded: true, empty: !fetchedLength})
@ -1576,8 +1570,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1576,8 +1570,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (historyResult.unreadOffset) {
$scope.historyUnreadAfter = historyResult.history[historyResult.unreadOffset - 1]
}
else if ($scope.historyUnreadAfter) {
} else if ($scope.historyUnreadAfter) {
delete $scope.historyUnreadAfter
}
$scope.$broadcast('messages_unread_after')
@ -1681,7 +1674,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1681,7 +1674,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (Config.Mobile) {
$scope.historyState.canEdit = AppMessagesManager.canEditMessage(messageID)
$modal.open({
templateUrl: templateUrl('message_actions_modal'),
windowClass: 'message_actions_modal_window',
@ -1732,8 +1725,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1732,8 +1725,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (!shiftClick) {
lastSelectID = messageID
} else if (lastSelectID != messageID) {
var dir = lastSelectID > messageID,
i, startPos, curMessageID
var dir = lastSelectID > messageID
var i, startPos, curMessageID
for (i = 0; i < peerHistory.messages.length; i++) {
if (peerHistory.messages[i].mid == lastSelectID) {
@ -1798,8 +1791,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1798,8 +1791,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var selectedMessageIDs = []
if (selectedMessageID) {
selectedMessageIDs.push(selectedMessageID)
}
else if ($scope.selectedCount > 0) {
} else if ($scope.selectedCount > 0) {
angular.forEach($scope.selectedMsgs, function (t, messageID) {
selectedMessageIDs.push(messageID)
})
@ -1842,8 +1834,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1842,8 +1834,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var selectedMessageIDs = []
if (selectedMessageID) {
selectedMessageIDs.push(selectedMessageID)
}
else if ($scope.selectedCount > 0) {
} else if ($scope.selectedCount > 0) {
angular.forEach($scope.selectedMsgs, function (t, messageID) {
selectedMessageIDs.push(messageID)
})
@ -2114,7 +2105,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2114,7 +2105,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return
}
var messageID, historyMessage, i
var messageID, i
var hasOut = false
var unreadAfterNew = false
var historyMessage = history.messages[history.messages.length - 1]
@ -2185,8 +2176,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2185,8 +2176,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (!history) {
return
}
var newMessages = [],
i
var newMessages = []
var i
for (i = 0; i < history.messages.length; i++) {
if (!historyUpdate.msgs[history.messages[i].mid]) {
@ -2282,7 +2273,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2282,7 +2273,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$on('edit_selected', function (e, messageID) {
setEditDraft(messageID, true)
})
$scope.$on('ui_typing', onTyping)
$scope.draftMessage = {
@ -2357,7 +2348,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2357,7 +2348,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return cancelEvent(e)
}
function sendMessage() {
function sendMessage () {
var text = $scope.draftMessage.text
if (angular.isString(text) && text.length > 0) {
@ -2384,7 +2375,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2384,7 +2375,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('ui_message_send')
}
function editMessage() {
function editMessage () {
var text = $scope.draftMessage.text
text = RichTextProcessor.parseEmojis(text)
@ -2591,15 +2582,13 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2591,15 +2582,13 @@ angular.module('myApp.controllers', ['myApp.i18n'])
]
})
}, 1000)
}
else if (attachment._ == 'fwd_messages') {
} else if (attachment._ == 'fwd_messages') {
forceDraft = $scope.curDialog.peer
$timeout(function () {
$scope.draftMessage.fwdMessages = attachment.id
$scope.$broadcast('ui_peer_reply')
}, 100)
}
else if (attachment._ == 'inline_query') {
} else if (attachment._ == 'inline_query') {
var mention = attachment.mention
var query = attachment.query
forceDraft = $scope.curDialog.peer
@ -2634,12 +2623,12 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2634,12 +2623,12 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
}
function setEditDraft(messageID) {
function setEditDraft (messageID) {
editMessageID = messageID
getDraft()
}
function setEditLastMessage() {
function setEditLastMessage () {
if (editMessageID ||
!$scope.curDialog.peerID) {
return false
@ -2731,8 +2720,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2731,8 +2720,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (addReplyMessage) {
replySelect(replyKeyboard.mid)
replyToMarkup = true
}
else if (replyToMarkup) {
} else if (replyToMarkup) {
replyClear()
}
var enabled = replyKeyboard &&
@ -2768,7 +2756,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2768,7 +2756,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (replyToMsgID &&
$scope.historyState.replyKeyboard &&
$scope.historyState.replyKeyboard.mid == replyToMsgID) {
replyToMsgID = 0;
replyToMsgID = 0
}
DraftsManager.changeDraft($scope.curDialog.peerID, {
text: newVal,
@ -3134,7 +3122,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -3134,7 +3122,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var messageID = list[index]
var message = AppMessagesManager.getMessage(messageID)
var photoID = message && message.media && (message.media.photo && message.media.photo.id || message.media.webpage && message.media.webpage.photo && message.media.webpage.photo.id)
var photoID = message && message.media &&
((message.media.photo && message.media.photo.id) ||
(message.media.webpage && message.media.webpage.photo && message.media.webpage.photo.id))
if (!photoID) {
console.error('Invalid photo message', index, list, messageID, message)
return
@ -3359,7 +3349,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -3359,7 +3349,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
onDeleted()
})
}else {
} else {
MtpApiManager.invokeApi('photos.deletePhotos', {
id: [{_: 'inputPhoto', id: photoID, access_hash: 0}]
}).then(onDeleted)
@ -3527,7 +3517,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -3527,7 +3517,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
.controller('GameModalController', function ($q, $scope, $rootScope, $modalInstance, AppPhotosManager, AppMessagesManager, AppPeersManager, AppGamesManager, PeersSelectService, ErrorService) {
$scope.game = AppGamesManager.wrapForFull($scope.gameID, $scope.messageID, $scope.embedUrl)
var messageID = $scope.messageID
@ -4485,7 +4474,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4485,7 +4474,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var confirmPromise
if ($scope.action == 'disable') {
confirmPromise = $q.when()
}else {
} else {
if (!$scope.passwordSettings.new_password) {
$scope.passwordSettings.error_field = 'new_password'
$scope.$broadcast('new_password_focus')
@ -4562,17 +4551,15 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4562,17 +4551,15 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('new_password_focus')
})
break
}
$scope.$watch('passwordSettings.new_password', function (newValue) {
var len = newValue && newValue.length || 0
var len = (newValue && newValue.length) || 0
if (!len) {
$scope.passwordSettings.hint = ''
}
else if (len <= 3) {
} else if (len <= 3) {
$scope.passwordSettings.hint = '***'
}else {
} else {
$scope.passwordSettings.hint = newValue.charAt(0) + (new Array(len - 1)).join('*') + newValue.charAt(len - 1)
}
$scope.$broadcast('value_updated')
@ -4616,18 +4603,19 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4616,18 +4603,19 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.slice = {limit: 20, limitDelta: 20}
var jump = 0
var i
resetSelected()
$scope.disabledContacts = {}
if ($scope.disabled) {
for (var i = 0; i < $scope.disabled.length; i++) {
for (i = 0; i < $scope.disabled.length; i++) {
$scope.disabledContacts[$scope.disabled[i]] = true
}
}
if ($scope.selected) {
for (var i = 0; i < $scope.selected.length; i++) {
for (i = 0; i < $scope.selected.length; i++) {
if (!$scope.selectedContacts[$scope.selected[i]]) {
$scope.selectedContacts[$scope.selected[i]] = true
$scope.selectedCount++
@ -4687,7 +4675,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4687,7 +4675,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$watch('search.query', updateContacts)
$scope.$on('contacts_update', function () {
updateContacts($scope.search && $scope.search.query || '')
updateContacts(($scope.search && $scope.search.query) || '')
})
$scope.toggleEdit = function (enabled) {
@ -4760,10 +4748,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4760,10 +4748,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
$scope.dialogSelect = function (peerString) {
var peerID
if (!$scope.multiSelect) {
var promise
if ($scope.confirm_type) {
var peerID = AppPeersManager.getPeerID(peerString)
peerID = AppPeersManager.getPeerID(peerString)
var peerData = AppPeersManager.getPeer(peerID)
promise = ErrorService.confirm({
type: $scope.confirm_type,
@ -4779,7 +4768,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4779,7 +4768,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return
}
var peerID = AppPeersManager.getPeerID(peerString)
peerID = AppPeersManager.getPeerID(peerString)
if ($scope.selectedPeers[peerID]) {
delete $scope.selectedPeers[peerID]
$scope.selectedCount--

306
app/js/directives.js

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
*/
'use strict'
/* global Config, templateUrl, onContentLoaded, cancelEvent, dT, setZeroTimeout calcImageInBox, getSelectedText,Scroller, setFieldSelection, scrollToNode, EmojiTooltip, EmojiPanel, MessageComposer, checkDragEvent, checkClick, Image, Clipboard, EmojiHelper, encodeEntities, FB, twttr, gapi, isInDOM */
/* Directives */
@ -43,13 +44,13 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -43,13 +44,13 @@ angular.module('myApp.directives', ['myApp.filters'])
.directive('myMessage', function ($filter, _) {
var dateFilter = $filter('myDate')
var dateSplitHtml = '<div class="im_message_date_split im_service_message_wrap"><div class="im_service_message"><span class="copyonly"><br/>---&nbsp;</span><span class="im_message_date_split_text"></span><span class="copyonly">&nbsp;---</span></div></div>',
unreadSplitHtml = '<div class="im_message_unread_split">' + _('unread_messages_split') + '</div>',
selectedClass = 'im_message_selected',
focusClass = 'im_message_focus',
unreadClass = 'im_message_unread',
errorClass = 'im_message_error',
pendingClass = 'im_message_pending'
var dateSplitHtml = '<div class="im_message_date_split im_service_message_wrap"><div class="im_service_message"><span class="copyonly"><br/>---&nbsp;</span><span class="im_message_date_split_text"></span><span class="copyonly">&nbsp;---</span></div></div>'
var unreadSplitHtml = '<div class="im_message_unread_split">' + _('unread_messages_split') + '</div>'
var selectedClass = 'im_message_selected'
var focusClass = 'im_message_focus'
var unreadClass = 'im_message_unread'
var errorClass = 'im_message_error'
var pendingClass = 'im_message_pending'
return {
templateUrl: templateUrl('message'),
@ -65,42 +66,41 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -65,42 +66,41 @@ angular.module('myApp.directives', ['myApp.filters'])
var needDate = false
var unreadAfter = false
var applySelected = function () {
if (selected != ($scope.selectedMsgs[$scope.historyMessage.mid] || false)) {
selected = !selected
element.toggleClass(selectedClass, selected)
if (selected != ($scope.selectedMsgs[$scope.historyMessage.mid] || false)) {
selected = !selected
element.toggleClass(selectedClass, selected)
}
}
var needDateSplit, unreadAfterSplit
var applyGrouped = function () {
if (grouped != $scope.historyMessage.grouped) {
if (grouped) {
element.removeClass(grouped)
}
},
needDateSplit,
applyGrouped = function () {
if (grouped != $scope.historyMessage.grouped) {
if (grouped) {
element.removeClass(grouped)
}
grouped = $scope.historyMessage.grouped
if (grouped) {
element.addClass(grouped)
}
grouped = $scope.historyMessage.grouped
if (grouped) {
element.addClass(grouped)
}
if (needDate != ($scope.historyMessage.needDate || false)) {
needDate = !needDate
if (needDate) {
if (needDateSplit) {
needDateSplit.show()
}
if (needDate != ($scope.historyMessage.needDate || false)) {
needDate = !needDate
if (needDate) {
if (needDateSplit) {
needDateSplit.show()
} else {
needDateSplit = $(dateSplitHtml)
$('.im_message_date_split_text', needDateSplit).text(dateFilter($scope.historyMessage.date))
if (unreadAfterSplit) {
needDateSplit.insertBefore(unreadAfterSplit)
} else {
needDateSplit = $(dateSplitHtml)
$('.im_message_date_split_text', needDateSplit).text(dateFilter($scope.historyMessage.date))
if (unreadAfterSplit) {
needDateSplit.insertBefore(unreadAfterSplit)
} else {
needDateSplit.prependTo(element)
}
needDateSplit.prependTo(element)
}
} else {
needDateSplit.hide()
}
} else {
needDateSplit.hide()
}
},
unreadAfterSplit
}
}
applySelected()
applyGrouped()
@ -155,19 +155,19 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -155,19 +155,19 @@ angular.module('myApp.directives', ['myApp.filters'])
}
if ($scope.historyMessage.error || $scope.historyMessage.pending) {
var applyPending = function () {
if (pending != ($scope.historyMessage.pending || false)) {
pending = !pending
element.toggleClass(pendingClass, pending)
}
if (error != ($scope.historyMessage.error || false)) {
error = !error
element.toggleClass(errorClass, error)
}
if (!error && !pending) {
deregisterPending()
}
},
deregisterPending = $scope.$on('messages_pending', applyPending)
if (pending != ($scope.historyMessage.pending || false)) {
pending = !pending
element.toggleClass(pendingClass, pending)
}
if (error != ($scope.historyMessage.error || false)) {
error = !error
element.toggleClass(errorClass, error)
}
if (!error && !pending) {
deregisterPending()
}
}
var deregisterPending = $scope.$on('messages_pending', applyPending)
applyPending()
}
@ -187,7 +187,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -187,7 +187,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
function updateMessageText ($scope, element, message) {
if (message.media && message.media.handleMessage ||
if ((message.media && message.media.handleMessage) ||
typeof message.message !== 'string' ||
!message.message.length) {
$('.im_message_text', element).hide()
@ -455,7 +455,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -455,7 +455,7 @@ angular.module('myApp.directives', ['myApp.filters'])
AppInlineBotsManager.gameButtonClick($scope.messageId)
}
function updateMessageText(argument) {
function updateMessageText (argument) {
var message = AppMessagesManager.getMessage($scope.messageId)
if (message.message) {
var html = AppMessagesManager.wrapMessageText($scope.messageId)
@ -671,7 +671,6 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -671,7 +671,6 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('myMessageEdited', function (_, $timeout, AppMessagesManager) {
var editedLabel = _('message_edited')
return {
@ -679,7 +678,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -679,7 +678,7 @@ angular.module('myApp.directives', ['myApp.filters'])
link: link
}
function link($scope, element, attrs) {
function link ($scope, element, attrs) {
var messageID = $scope.$parent.$eval(attrs.myMessageEdited)
if (checkEdited($scope, element, messageID)) {
$scope.$on('message_edit', function (e, data) {
@ -691,7 +690,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -691,7 +690,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
function checkEdited($scope, element, messageID) {
function checkEdited ($scope, element, messageID) {
var message = AppMessagesManager.getMessage(messageID)
if (!message.canBeEdited) {
$timeout(function () {
@ -769,8 +768,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -769,8 +768,9 @@ angular.module('myApp.directives', ['myApp.filters'])
return true
}
var currentSelected, nextDialogWrap, dialogWraps
if (e.keyCode == 36 && !e.shiftKey && !e.ctrlKey && e.altKey) { // Alt + Home
var currentSelected = $(scrollableWrap).find('.im_dialog_wrap a')
currentSelected = $(scrollableWrap).find('.im_dialog_wrap a')
if (currentSelected.length) {
$(currentSelected[0]).trigger('mousedown')
scrollableWrap.scrollTop = 0
@ -779,16 +779,15 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -779,16 +779,15 @@ angular.module('myApp.directives', ['myApp.filters'])
return cancelEvent(e)
}
if (e.keyCode == 27 || e.keyCode == 9 && e.shiftKey && !e.ctrlKey && !e.metaKey) { // ESC or Shift + Tab
if (e.keyCode == 27 || (e.keyCode == 9 && e.shiftKey && !e.ctrlKey && !e.metaKey)) { // ESC or Shift + Tab
if (!searchFocused) {
setFieldSelection(searchField)
if (searchField.value) {
searchField.select()
}
}
else if (searchField.value) {
} else if (searchField.value) {
$(searchClear).trigger('click')
}else {
} else {
$scope.$emit('esc_no_more')
// Strange Chrome bug, when field doesn't get blur, but becomes inactive after location change
setTimeout(function () {
@ -802,7 +801,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -802,7 +801,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
if (searchFocused && e.keyCode == 13 && !Config.Navigator.mobile) { // Enter
var currentSelected = $(scrollableWrap).find('.im_dialog_selected')[0] || $(scrollableWrap).find('.im_dialog_wrap a')[0]
currentSelected = $(scrollableWrap).find('.im_dialog_selected')[0] || $(scrollableWrap).find('.im_dialog_wrap a')[0]
if (currentSelected &&
!$(currentSelected).hasClass('disabled')) {
$(currentSelected).trigger('mousedown')
@ -813,15 +812,13 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -813,15 +812,13 @@ angular.module('myApp.directives', ['myApp.filters'])
if (
(!Config.Navigator.osX && // No Mac users
e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey &&
e.keyCode >= 49 && e.keyCode <= 57 ) // Alt + Shift + # , switch to conversation # where # is in [1..9]
||
e.keyCode >= 49 && e.keyCode <= 57) || // Alt + Shift + # , switch to conversation # where # is in [1..9]
(Config.Navigator.osX && // Mac users only
e.ctrlKey && e.shiftKey && !e.metaKey && !e.altKey &&
e.keyCode >= 49 && e.keyCode <= 57 ) ) { // Ctrl + Shift + # , switch to conversation # where # is in [1..9]
e.keyCode >= 49 && e.keyCode <= 57)) { // Ctrl + Shift + # , switch to conversation # where # is in [1..9]
var dialogNumber = e.keyCode - 49
var dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
var nextDialogWrap = dialogWraps[dialogNumber]
dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
nextDialogWrap = dialogWraps[dialogNumber]
if (nextDialogWrap) {
$(nextDialogWrap).find('a').trigger('mousedown')
@ -838,8 +835,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -838,8 +835,7 @@ angular.module('myApp.directives', ['myApp.filters'])
next = e.keyCode == 40
prev = !next
skip = !e.shiftKey && e.altKey
}
else if (ctrlTabSupported && e.keyCode == 9 && e.ctrlKey && !e.metaKey) { // Ctrl + Tab, Shift + Ctrl + Tab
} else if (ctrlTabSupported && e.keyCode == 9 && e.ctrlKey && !e.metaKey) { // Ctrl + Tab, Shift + Ctrl + Tab
next = !e.shiftKey
prev = !next
skip = true
@ -850,22 +846,21 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -850,22 +846,21 @@ angular.module('myApp.directives', ['myApp.filters'])
return true
}
var currentSelected = !skip && $(scrollableWrap).find('.im_dialog_selected')[0] || $(scrollableWrap).find('.active a.im_dialog')[0]
var currentSelectedWrap = currentSelected && currentSelected.parentNode,
nextDialogWrap
currentSelected = (!skip && $(scrollableWrap).find('.im_dialog_selected')[0]) || $(scrollableWrap).find('.active a.im_dialog')[0]
var currentSelectedWrap = currentSelected && currentSelected.parentNode
if (currentSelectedWrap) {
var nextDialogWrap = currentSelected[next ? 'nextSibling' : 'previousSibling']
nextDialogWrap = currentSelected[next ? 'nextSibling' : 'previousSibling']
if (!nextDialogWrap || !nextDialogWrap.className || nextDialogWrap.className.indexOf('im_dialog_wrap') == -1) {
var dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
var pos = dialogWraps.index(currentSelected.parentNode)
var nextPos = pos + (next ? 1 : -1)
nextDialogWrap = dialogWraps[nextPos]
}
} else {
var dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
dialogWraps = $(scrollableWrap).find('.im_dialog_wrap')
if (next) {
nextDialogWrap = dialogWraps[0]
} else {
@ -1024,8 +1019,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1024,8 +1019,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes () {
$(element).css({
height: $($window).height() -
(panelWrap && panelWrap.offsetHeight || 0) -
(searchWrap && searchWrap.offsetHeight || 0) -
((panelWrap && panelWrap.offsetHeight) || 0) -
((searchWrap && searchWrap.offsetHeight) || 0) -
(Config.Mobile ? 64 : 200)
})
$(contactsWrap).nanoScroller()
@ -1055,10 +1050,10 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1055,10 +1050,10 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes () {
$(element).css({
height: $($window).height()
- (panelWrap && panelWrap.offsetHeight || 0)
- (searchWrap && searchWrap.offsetHeight || 0)
- (Config.Mobile ? 46 + 18 : 200)
height: $($window).height() -
((panelWrap && panelWrap.offsetHeight) || 0) -
((searchWrap && searchWrap.offsetHeight) || 0) -
(Config.Mobile ? 46 + 18 : 200)
})
$(countriesWrap).nanoScroller()
}
@ -1085,8 +1080,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1085,8 +1080,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes () {
$(element).css({
height: Math.min(760, $($window).height()
- (Config.Mobile ? 46 + 18 : 200))
height: Math.min(760, $($window).height() -
(Config.Mobile ? 46 + 18 : 200))
})
$(sessionsWrap).nanoScroller()
}
@ -1110,8 +1105,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1110,8 +1105,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes () {
$(element).css({
height: Math.min(600, $($window).height()
- (Config.Mobile ? 46 + 18 : 200))
height: Math.min(600, $($window).height() -
(Config.Mobile ? 46 + 18 : 200))
})
$(stickersWrap).nanoScroller()
}
@ -1155,8 +1150,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1155,8 +1150,8 @@ angular.module('myApp.directives', ['myApp.filters'])
}
var transform = false
var trs = ['transform', 'webkitTransform', 'MozTransform', 'msTransform', 'OTransform'],
i
var trs = ['transform', 'webkitTransform', 'MozTransform', 'msTransform', 'OTransform']
var i
for (i = 0; i < trs.length; i++) {
if (trs[i] in historyMessagesEl.style) {
transform = trs[i]
@ -1164,7 +1159,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1164,7 +1159,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
var animated = transform && false ? true : false
var animated = transform && false ? true : false // ?
var curAnimation = false
$scope.$on('ui_history_append_new', function (e, options) {
@ -1183,8 +1178,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1183,8 +1178,8 @@ angular.module('myApp.directives', ['myApp.filters'])
}
var curAnimated = animated &&
!$rootScope.idle.isIDLE &&
historyMessagesEl.clientHeight > 0,
wasH
historyMessagesEl.clientHeight > 0
var wasH
if (curAnimated) {
wasH = scrollableWrap.scrollHeight
@ -1344,29 +1339,29 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1344,29 +1339,29 @@ angular.module('myApp.directives', ['myApp.filters'])
$(scrollable).css({bottom: -(sh - st - ch), paddingRight: pr})
var upd = function () {
$(scrollableWrap).removeClass('im_history_to_bottom')
$(scrollable).css({bottom: '', paddingRight: ''})
if (scrollTopInitial >= 0) {
changeScroll()
} else {
// console.log('change scroll prepend')
scrollableWrap.scrollTop = st + scrollableWrap.scrollHeight - sh
}
$(scrollableWrap).removeClass('im_history_to_bottom')
$(scrollable).css({bottom: '', paddingRight: ''})
if (scrollTopInitial >= 0) {
changeScroll()
} else {
// console.log('change scroll prepend')
scrollableWrap.scrollTop = st + scrollableWrap.scrollHeight - sh
}
updateBottomizer()
moreNotified = false
updateBottomizer()
moreNotified = false
$timeout(function () {
if (scrollableWrap.scrollHeight != sh) {
$(scrollableWrap).trigger('scroll')
}
})
$timeout(function () {
if (scrollableWrap.scrollHeight != sh) {
$(scrollableWrap).trigger('scroll')
}
})
clearTimeout(timer)
unreg()
},
timer = setTimeout(upd, 0),
unreg = $scope.$on('$viewContentLoaded', upd)
clearTimeout(timer)
unreg()
}
var timer = setTimeout(upd, 0)
var unreg = $scope.$on('$viewContentLoaded', upd)
})
$scope.$on('ui_history_append', function () {
@ -1439,8 +1434,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1439,8 +1434,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if (!moreNotified && st <= 300) {
moreNotified = true
$scope.$emit('history_need_more')
}
else if (!lessNotified && st >= scrollableWrap.scrollHeight - scrollableWrap.clientHeight - 300) {
} else if (!lessNotified && st >= scrollableWrap.scrollHeight - scrollableWrap.clientHeight - 300) {
lessNotified = true
$scope.$emit('history_need_less')
}
@ -1486,10 +1480,10 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1486,10 +1480,10 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateBottomizer () {
$(historyMessagesEl).css({marginTop: 0})
var marginTop = scrollableWrap.offsetHeight
- historyMessagesEl.offsetHeight
- emptyWrapEl.offsetHeight
- (Config.Mobile ? 0 : 39)
var marginTop = scrollableWrap.offsetHeight -
historyMessagesEl.offsetHeight -
emptyWrapEl.offsetHeight -
(Config.Mobile ? 0 : 39)
if (historyMessagesEl.offsetHeight > 0 && marginTop > 0) {
$(historyMessagesEl).css({marginTop: marginTop})
@ -1671,7 +1665,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1671,7 +1665,7 @@ angular.module('myApp.directives', ['myApp.filters'])
})
}
function onDirectionKey(e) {
function onDirectionKey (e) {
if (e.keyCode == 38) {
$scope.$emit('last_message_edit')
return cancelEvent(e)
@ -1727,7 +1721,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1727,7 +1721,7 @@ angular.module('myApp.directives', ['myApp.filters'])
composer.setValue($scope.draftMessage.text || '')
updateHeight()
}
if (shouldFocusOnInteraction || options && options.focus) {
if (shouldFocusOnInteraction || (options && options.focus)) {
composer.focus()
}
}
@ -1786,10 +1780,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1786,10 +1780,9 @@ angular.module('myApp.directives', ['myApp.filters'])
function onPasteEvent (e) {
var cData = (e.originalEvent || e).clipboardData
var items = cData && cData.items || []
var files = [],
file
var i
var items = (cData && cData.items) || []
var files = []
var i, file
for (i = 0; i < items.length; i++) {
if (items[i].kind == 'file') {
@ -1902,7 +1895,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1902,7 +1895,7 @@ angular.module('myApp.directives', ['myApp.filters'])
// console.log('new loc', newLocation, arguments)
var counterSaved = ++counter
if (!newLocation || newLocation.empty) {
element.attr('src', $scope.thumb && $scope.thumb.placeholder || 'img/blank.gif')
element.attr('src', ($scope.thumb && $scope.thumb.placeholder) || 'img/blank.gif')
cleanup()
return
}
@ -2007,9 +2000,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2007,9 +2000,9 @@ angular.module('myApp.directives', ['myApp.filters'])
if (e && e.type == 'FS_BROWSER_UNSUPPORTED') {
$scope.error = {html: _('error_browser_no_local_file_system_image_md', {
'moz-link': '<a href="{0}" target="_blank">{1}</a>',
'chrome-link': '<a href="{0}" target="_blank">{1}</a>',
'telegram-link': '<a href="{0}" target="_blank">{1}</a>'
'moz-link': '<a href="{0}" target="_blank">{1}</a>',
'chrome-link': '<a href="{0}" target="_blank">{1}</a>',
'telegram-link': '<a href="{0}" target="_blank">{1}</a>'
})}
} else {
$scope.error = {text: _('error_image_download_failed'), error: e}
@ -2072,9 +2065,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2072,9 +2065,9 @@ angular.module('myApp.directives', ['myApp.filters'])
if (e && e.type == 'FS_BROWSER_UNSUPPORTED') {
$scope.error = {html: _('error_browser_no_local_file_system_video_md', {
'moz-link': '<a href="{0}" target="_blank">{1}</a>',
'chrome-link': '<a href="{0}" target="_blank">{1}</a>',
'telegram-link': '<a href="{0}" target="_blank">{1}</a>'
'moz-link': '<a href="{0}" target="_blank">{1}</a>',
'chrome-link': '<a href="{0}" target="_blank">{1}</a>',
'telegram-link': '<a href="{0}" target="_blank">{1}</a>'
})}
} else {
$scope.error = {text: _('error_video_download_failed'), error: e}
@ -2179,7 +2172,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2179,7 +2172,7 @@ angular.module('myApp.directives', ['myApp.filters'])
imgElement.attr('alt', '[' + ($scope.document.stickerEmojiRaw || '') + ' ' + _('conversation_media_sticker') + ']')
var dim = attrs.dim && $scope.$parent.$eval(attrs.dim) || $scope.document.thumb
var dim = (attrs.dim && $scope.$parent.$eval(attrs.dim)) || $scope.document.thumb
if (attrs.open && $scope.document.stickerSetInput) {
element
@ -2404,7 +2397,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2404,7 +2397,8 @@ angular.module('myApp.directives', ['myApp.filters'])
if (animationSupported === undefined) {
animationSupported = el.style.animationName !== undefined
if (animationSupported === false) {
var domPrefixes = 'Webkit Moz O ms Khtml'.split(' '), i
var domPrefixes = 'Webkit Moz O ms Khtml'.split(' ')
var i
for (i = 0; i < domPrefixes.length; i++) {
if (el.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
animationSupported = true
@ -2570,7 +2564,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2570,7 +2564,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var height = element[0].parentNode.offsetHeight
var modal = element[0].parentNode.parentNode.parentNode
var bottomPanel = $('.media_modal_bottom_panel_wrap', modal)[0]
var contHeight = modal.offsetHeight - (bottomPanel && bottomPanel.offsetHeight || 0)
var contHeight = modal.offsetHeight - ((bottomPanel && bottomPanel.offsetHeight) || 0)
if (height < contHeight) {
$(element[0].parentNode).css('marginTop', (contHeight - height) / 2)
@ -2611,7 +2605,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2611,7 +2605,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var updateMargin = function () {
var height = element[0].offsetHeight
var fullHeight = height - (height && usePadding ? 2 * prevMargin : 0)
var ratio = attrs.myVerticalPosition && parseFloat(attrs.myVerticalPosition) || 0.5
var ratio = (attrs.myVerticalPosition && parseFloat(attrs.myVerticalPosition)) || 0.5
var contHeight = attrs.contHeight ? $scope.$eval(attrs.contHeight) : $($window).height()
var margin = fullHeight < contHeight ? parseInt((contHeight - fullHeight) * ratio) : ''
var styles = usePadding
@ -2668,7 +2662,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2668,7 +2662,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var user = AppUsersManager.getUser(userID)
element
.html(statusFilter(user, attrs.botChatPrivacy))
.toggleClass('status_online', user.status && user.status._ == 'userStatusOnline' || false)
.toggleClass('status_online', (user.status && user.status._ == 'userStatusOnline') || false)
// console.log(dT(), 'update status', element[0], user.status && user.status, tsNow(true), element.html())
}
@ -3045,10 +3039,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3045,10 +3039,8 @@ angular.module('myApp.directives', ['myApp.filters'])
if ($scope.audio.url) {
checkPlayer($scope.mediaPlayer.player)
$scope.mediaPlayer.player.playPause()
}
else if ($scope.audio.progress && $scope.audio.progress.enabled) {
return
}else {
} else if ($scope.audio.progress && $scope.audio.progress.enabled) {
} else {
AppDocsManager.downloadDoc($scope.audio.id).then(function () {
onContentLoaded(function () {
var errorListenerEl = $('audio', element)[0] || element[0]
@ -3145,7 +3137,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3145,7 +3137,7 @@ angular.module('myApp.directives', ['myApp.filters'])
e = e.originalEvent || e
var offsetX = (e.touches && e.touches[0] ? e.touches[0].pageX : e.pageX) - lastMinPageX
offsetX = Math.min(width, Math.max(0 , offsetX))
offsetX = Math.min(width, Math.max(0, offsetX))
// console.log(e.type, lastMinPageX, e.pageX, offsetX)
lastUpdValue = minValue + offsetX / width * (maxValue - minValue)
if (sliderCallback) {
@ -3169,7 +3161,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3169,7 +3161,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var percent = Math.max(0, (newVal - minValue) / (maxValue - minValue))
if (width) {
var offsetX = Math.ceil(width * percent)
offsetX = Math.min(width, Math.max(0 , offsetX))
offsetX = Math.min(width, Math.max(0, offsetX))
thumb.css('left', Math.max(0, offsetX - thumbWidth))
fill.css('width', offsetX)
} else {
@ -3198,15 +3190,13 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3198,15 +3190,13 @@ angular.module('myApp.directives', ['myApp.filters'])
if (e.touches && e.touches[0]) {
lastMinPageX = element.position().left
offsetX = e.touches[0].pageX - lastMinPageX
}
else if (e.offsetX !== undefined) {
} else if (e.offsetX !== undefined) {
offsetX = e.offsetX
lastMinPageX = e.pageX - offsetX
}
else if (e.layerX !== undefined) {
} else if (e.layerX !== undefined) {
offsetX = e.layerX
lastMinPageX = e.pageX - offsetX
}else {
} else {
return cancelEvent(e)
}
@ -3468,8 +3458,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3468,8 +3458,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var spritesheet, pos
var categoryIndex
var count = Math.min(5, codes.length)
var i, x
var y
var i, x, y
for (i = 0; i < count; i++) {
emoticonCode = codes[i]
@ -3517,8 +3506,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3517,8 +3506,9 @@ angular.module('myApp.directives', ['myApp.filters'])
if ((result.type == 'gif' || result.type == 'sticker') && result.document) {
AppDocsManager.downloadDoc(result.document.id)
}
var photoSize
if (result.type == 'photo' && result.photo) {
var photoSize = AppPhotosManager.choosePhotoSize(result.photo, result.thumbW, result.thumbH)
photoSize = AppPhotosManager.choosePhotoSize(result.photo, result.thumbW, result.thumbH)
var dim = calcImageInBox(photoSize.w, photoSize.h, result.thumbW, result.thumbH)
result.thumb = {
width: dim.w,
@ -3528,7 +3518,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3528,7 +3518,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
if (result.type == 'game' && result.photo) {
var photoSize = AppPhotosManager.choosePhotoSize(result.photo, 100, 100)
photoSize = AppPhotosManager.choosePhotoSize(result.photo, 100, 100)
// var dim = calcImageInBox(photoSize.w, photoSize.h, result.thumbW, result.thumbH)
result.thumb = {
// width: dim.w,
@ -3562,7 +3552,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3562,7 +3552,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if (!dataParsed || !dataParsed.eventType) {
return
}
$scope.$emit('game_frame_event', dataParsed);
$scope.$emit('game_frame_event', dataParsed)
}
$($window).on('message', handler)
@ -3579,7 +3569,6 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3579,7 +3569,6 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('myEmojiImage', function (RichTextProcessor) {
function link ($scope, element, attrs) {
var emoji = attrs.myEmojiImage
var html = RichTextProcessor.wrapRichText(emoji, {noLinks: true, noLinebreaks: true})
@ -3607,16 +3596,17 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3607,16 +3596,17 @@ angular.module('myApp.directives', ['myApp.filters'])
var html = ''
var callback = false
var needTwitter = false
var videoID
switch (embedData[0]) {
case 'youtube':
var videoID = embedData[1]
videoID = embedData[1]
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://www.youtube.com/embed/' + videoID +
'?autoplay=0&amp;controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
break
case 'vimeo':
var videoID = embedData[1]
videoID = embedData[1]
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://player.vimeo.com/video/' + videoID +
'?title=0&amp;byline=0&amp;portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
@ -3666,8 +3656,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3666,8 +3656,7 @@ angular.module('myApp.directives', ['myApp.filters'])
})
})
.attr('src', 'https://platform.twitter.com/widgets.js')
}
else if (window.twttr) {
} else if (window.twttr) {
twttr.widgets.load(element[0])
}
twitterPendingWidgets.push($scope)
@ -3691,9 +3680,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3691,9 +3680,7 @@ angular.module('myApp.directives', ['myApp.filters'])
})
})
.attr('src', 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&appId=254098051407226&version=v2.0')
}
else if (window.FB) {
} else if (window.FB) {
FB.XFBML.parse(element[0])
}
facebookPendingWidgets.push($scope)
@ -3714,8 +3701,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3714,8 +3701,7 @@ angular.module('myApp.directives', ['myApp.filters'])
gapi.post.go()
})
.attr('src', 'https://apis.google.com/js/plusone.js')
}
else if (window.gapi) {
} else if (window.gapi) {
gapi.post.go(element[0])
}
element.one('load', function () {

3
app/service_worker.js

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
/* global importScripts */
importScripts('js/lib/push_worker.js')
// Version 53
// Version 53

47
gulpfile.js

@ -10,7 +10,6 @@ var runSequence = require('run-sequence') @@ -10,7 +10,6 @@ var runSequence = require('run-sequence')
var swPrecache = require('sw-precache')
var Server = require('karma').Server
// The generated file is being created at src
// so it can be fetched by usemin.
gulp.task('templates', function () {
@ -37,14 +36,14 @@ gulp.task('usemin-index', function () { @@ -37,14 +36,14 @@ gulp.task('usemin-index', function () {
.pipe(gulp.dest('dist'))
})
gulp.task('usemin-badbrowser', function() {
gulp.task('usemin-badbrowser', function () {
return gulp.src('app/badbrowser.html')
.pipe($.usemin({
html: [$.minifyHtml({empty: true})],
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})],
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})]
}))
.pipe(gulp.dest('dist'));
});
.pipe(gulp.dest('dist'))
})
// ulimit -n 10240 on OS X
gulp.task('imagemin', function () {
@ -279,32 +278,32 @@ gulp.task('bump', ['bump-version-manifests', 'bump-version-config'], function () @@ -279,32 +278,32 @@ gulp.task('bump', ['bump-version-manifests', 'bump-version-config'], function ()
// Single run of karma
gulp.task('karma-single', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
new Server({
configFile: path.join(__dirname, '/karma.conf.js'),
singleRun: true
}, done).start()
})
// Continuous testing with karma by watching for changes
gulp.task('karma-tdd', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
}, done).start();
});
new Server({
configFile: path.join(__dirname, '/karma.conf.js')
}, done).start()
})
gulp.task('test', function (callback) {
runSequence(
['templates', 'karma-single'],
callback
)
});
runSequence(
['templates', 'karma-single'],
callback
)
})
gulp.task('tdd', function (callback) {
runSequence(
['templates', 'karma-tdd'],
callback
)
});
runSequence(
['templates', 'karma-tdd'],
callback
)
})
gulp.task('build', ['clean'], function (callback) {
runSequence(

Loading…
Cancel
Save