Added mozilla notifications support, added search clear, fixed minor bugs
This commit is contained in:
parent
da88e48185
commit
8bd9ae34eb
@ -400,6 +400,14 @@ fieldset[disabled] .btn-tg.active {
|
|||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.im_dialogs_search_clear {
|
||||||
|
position: absolute;
|
||||||
|
margin-left: 260px;
|
||||||
|
margin-top: -25px;
|
||||||
|
color: #999;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.im_dialogs_wrap {
|
.im_dialogs_wrap {
|
||||||
@ -890,7 +898,6 @@ div.im_message_video_thumb {
|
|||||||
}
|
}
|
||||||
div.im_message_author,
|
div.im_message_author,
|
||||||
div.im_message_body {
|
div.im_message_body {
|
||||||
border-radius: 2px;
|
|
||||||
display: block;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<link rel="stylesheet" href="vendor/angular/angular-csp.css"/>
|
<link rel="stylesheet" href="vendor/angular/angular-csp.css"/>
|
||||||
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
|
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
|
||||||
<link rel="stylesheet" href="vendor/jquery.nanoscroller/nanoscroller.css"/>
|
<link rel="stylesheet" href="vendor/jquery.nanoscroller/nanoscroller.css"/>
|
||||||
<link rel="stylesheet" href="css/app.css?10"/>
|
<link rel="stylesheet" href="css/app.css?11"/>
|
||||||
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||||
|
|
||||||
<meta property="og:title" content="Webogram">
|
<meta property="og:title" content="Webogram">
|
||||||
@ -52,10 +52,10 @@
|
|||||||
|
|
||||||
<script type="text/javascript" src="js/util.js"></script>
|
<script type="text/javascript" src="js/util.js"></script>
|
||||||
<script type="text/javascript" src="js/app.js?8"></script>
|
<script type="text/javascript" src="js/app.js?8"></script>
|
||||||
<script type="text/javascript" src="js/services.js?10"></script>
|
<script type="text/javascript" src="js/services.js?11"></script>
|
||||||
<script type="text/javascript" src="js/controllers.js?16"></script>
|
<script type="text/javascript" src="js/controllers.js?16"></script>
|
||||||
<script type="text/javascript" src="js/filters.js?3"></script>
|
<script type="text/javascript" src="js/filters.js?3"></script>
|
||||||
<script type="text/javascript" src="js/directives.js?9"></script>
|
<script type="text/javascript" src="js/directives.js?10"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -55,7 +55,7 @@ config(['$locationProvider', '$routeProvider', '$compileProvider', function($loc
|
|||||||
// $locationProvider.html5Mode(true);
|
// $locationProvider.html5Mode(true);
|
||||||
$routeProvider.when('/', {templateUrl: 'partials/welcome.html?2', controller: 'AppWelcomeController'});
|
$routeProvider.when('/', {templateUrl: 'partials/welcome.html?2', controller: 'AppWelcomeController'});
|
||||||
$routeProvider.when('/login', {templateUrl: 'partials/login.html?2', controller: 'AppLoginController'});
|
$routeProvider.when('/login', {templateUrl: 'partials/login.html?2', controller: 'AppLoginController'});
|
||||||
$routeProvider.when('/im', {templateUrl: 'partials/im.html?5', controller: 'AppIMController', reloadOnSearch: false});
|
$routeProvider.when('/im', {templateUrl: 'partials/im.html?6', controller: 'AppIMController', reloadOnSearch: false});
|
||||||
$routeProvider.otherwise({redirectTo: '/'});
|
$routeProvider.otherwise({redirectTo: '/'});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@ -25,7 +25,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
restrict: 'AE',
|
restrict: 'AE',
|
||||||
scope: true,
|
scope: true,
|
||||||
translude: false,
|
translude: false,
|
||||||
templateUrl: 'partials/message.html?5'
|
templateUrl: 'partials/message.html?6'
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1013,6 +1013,7 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
notification.message = notificationMessage;
|
notification.message = notificationMessage;
|
||||||
notification.image = notificationPhoto.placeholder;
|
notification.image = notificationPhoto.placeholder;
|
||||||
|
notification.key = 'msg' + message.id;
|
||||||
|
|
||||||
if (notificationPhoto.location) {
|
if (notificationPhoto.location) {
|
||||||
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (url) {
|
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (url) {
|
||||||
@ -1117,6 +1118,8 @@ angular.module('myApp.services', [])
|
|||||||
if (foundDialog) {
|
if (foundDialog) {
|
||||||
dialogsUpdated[peerID] = --foundDialog[0].unread_count;
|
dialogsUpdated[peerID] = --foundDialog[0].unread_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NotificationsManager.cancel('msg' + messageID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1917,8 +1920,10 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, MtpApiManager, AppPeersManager, IdleManager) {
|
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, MtpApiManager, AppPeersManager, IdleManager) {
|
||||||
|
|
||||||
var notificationsUiSupport = window.webkitNotifications !== undefined;
|
var notificationsUiSupport = 'Notification' in window;
|
||||||
var notificationsShown = [];
|
var notificationsShown = {};
|
||||||
|
// var lastClosed = [];
|
||||||
|
var notificationIndex = 0;
|
||||||
var notificationsCount = 0;
|
var notificationsCount = 0;
|
||||||
var peerSettings = {};
|
var peerSettings = {};
|
||||||
var faviconEl = $('link[rel="icon"]');
|
var faviconEl = $('link[rel="icon"]');
|
||||||
@ -1956,6 +1961,7 @@ angular.module('myApp.services', [])
|
|||||||
return {
|
return {
|
||||||
start: start,
|
start: start,
|
||||||
notify: notify,
|
notify: notify,
|
||||||
|
cancel: notificationCancel,
|
||||||
getPeerSettings: getPeerSettings
|
getPeerSettings: getPeerSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1981,25 +1987,23 @@ angular.module('myApp.services', [])
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var havePermission = window.webkitNotifications.checkPermission();
|
if (Notification.permission !== 'granted' && Notification.permission !== 'denied') {
|
||||||
// console.log('perm', havePermission);
|
|
||||||
|
|
||||||
if (havePermission != 0) { // 0 is PERMISSION_ALLOWED
|
|
||||||
$($window).on('click', requestPermission);
|
$($window).on('click', requestPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$($window).on('beforeunload', notificationsClear);
|
$($window).on('beforeunload', notificationsClear);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestPermission() {
|
function requestPermission() {
|
||||||
window.webkitNotifications.requestPermission();
|
Notification.requestPermission();
|
||||||
$($window).off('click', requestPermission);
|
$($window).off('click', requestPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify (data) {
|
function notify (data) {
|
||||||
// console.log('notify', $rootScope.idle.isIDLE);
|
// console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
|
||||||
if (!$rootScope.idle.isIDLE) {
|
if (!$rootScope.idle.isIDLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2007,15 +2011,17 @@ angular.module('myApp.services', [])
|
|||||||
notificationsCount++;
|
notificationsCount++;
|
||||||
|
|
||||||
if (!notificationsUiSupport ||
|
if (!notificationsUiSupport ||
|
||||||
window.webkitNotifications.checkPermission() != 0) {
|
Notification.permission !== 'granted') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notification = window.webkitNotifications.createNotification(
|
var idx = ++notificationIndex,
|
||||||
data.image || '',
|
key = data.key || 'k' + idx;
|
||||||
data.title || '',
|
|
||||||
data.message || ''
|
var notification = new Notification(data.title, {
|
||||||
);
|
icon: data.image || '',
|
||||||
|
body: data.message || ''
|
||||||
|
});
|
||||||
|
|
||||||
notification.onclick = function () {
|
notification.onclick = function () {
|
||||||
notification.close();
|
notification.close();
|
||||||
@ -2026,24 +2032,39 @@ angular.module('myApp.services', [])
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
notification.onclose = function () {
|
||||||
|
delete notificationsShown[key];
|
||||||
|
// lastClosed.push(+new Date());
|
||||||
|
notificationsClear();
|
||||||
|
};
|
||||||
|
|
||||||
// console.log('notify', notification);
|
// console.log('notify', notification);
|
||||||
|
|
||||||
notification.show();
|
notification.show();
|
||||||
|
|
||||||
notificationsShown.push(notification);
|
notificationsShown[key] = notification;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function notificationCancel (key) {
|
||||||
|
var notification = notificationsShown[key];
|
||||||
|
if (notification) {
|
||||||
|
try {
|
||||||
|
if (notification.close) {
|
||||||
|
notification.close();
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function notificationsClear() {
|
function notificationsClear() {
|
||||||
angular.forEach(notificationsShown, function (notification) {
|
angular.forEach(notificationsShown, function (notification) {
|
||||||
try {
|
try {
|
||||||
if (notification.close) {
|
if (notification.close) {
|
||||||
notification.close()
|
notification.close()
|
||||||
} else if (notification.cancel) {
|
|
||||||
notification.cancel();
|
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
notificationsShown = [];
|
notificationsShown = {};
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
<div class="im_dialogs_col_wrap" ng-controller="AppImDialogsController">
|
<div class="im_dialogs_col_wrap" ng-controller="AppImDialogsController">
|
||||||
<div class="im_dialogs_search">
|
<div class="im_dialogs_search">
|
||||||
<input class="form-control im_dialogs_search_field" type="search" placeholder="Search" ng-model="searchQuery"/>
|
<input class="form-control im_dialogs_search_field" type="search" placeholder="Search" ng-model="searchQuery"/>
|
||||||
|
<a class="im_dialogs_search_clear" ng-click="searchQuery = ''" ng-show="searchQuery.length">
|
||||||
|
<span class=" glyphicon glyphicon-remove"></span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div my-dialogs-list class="im_dialogs_col">
|
<div my-dialogs-list class="im_dialogs_col">
|
||||||
<div class="im_dialogs_wrap nano">
|
<div class="im_dialogs_wrap nano">
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
<div class="im_message_media" ng-if="historyMessage.media && historyMessage.media._ != 'messageMediaEmpty'" ng-switch="historyMessage.media._">
|
<div class="im_message_media" ng-if="historyMessage.media && historyMessage.media._ != 'messageMediaEmpty'" ng-switch="historyMessage.media._">
|
||||||
|
|
||||||
<a ng-switch-when="messageMediaPhoto" class="im_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.media.photo.id)" >
|
<a ng-switch-when="messageMediaPhoto" class="im_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.media.photo.id)" style="width: {{historyMessage.media.photo.thumb.width}}px;">
|
||||||
<img
|
<img
|
||||||
class="im_message_photo_thumb"
|
class="im_message_photo_thumb"
|
||||||
my-load-thumb
|
my-load-thumb
|
||||||
@ -90,7 +90,7 @@
|
|||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a ng-switch-when="messageMediaVideo" class="im_message_video_thumb" href="" ng-click="openVideo(historyMessage.media.video.id)">
|
<a ng-switch-when="messageMediaVideo" class="im_message_video_thumb" href="" ng-click="openVideo(historyMessage.media.video.id)" style="width: {{historyMessage.media.video.thumb.width}}px;">
|
||||||
<img
|
<img
|
||||||
class="im_message_video_thumb"
|
class="im_message_video_thumb"
|
||||||
my-load-thumb
|
my-load-thumb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user