Skip to content

Commit

Permalink
added options of desktop notifications, fixed somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Grim committed Feb 14, 2015
1 parent 1438d19 commit 7aa999f
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 207 deletions.
39 changes: 25 additions & 14 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,7 @@ button.disabled:hover
border: solid 1px rgba( 69, 71, 77, .1 );
background: #fff;
}
.options .module
{
margin: 5px;
padding: 5px;
}

.messages-qtd
{
position: absolute;
Expand Down Expand Up @@ -1761,19 +1757,34 @@ ol.toptrends-list {
}
}

/* Options */
#playerVol {
float: right;
margin-right: 20px;
/*************************************
****************** OPTIONS ***********
**************************************/

.options .module
{
margin: 5px;
padding: 15px;
}
.volValue {
float: right;
margin-right: -163px;

.options .container
{
margin: 5px 0px 5px 10px;
}

.options .label-h {
font-weight: 700;
}

.options .module label {
font: 12px "Open Sans", sans-serif;
}
#notifyForm p, #choseLanguage p, #keysOpt p {
margin-top: 15px;

.volValue {
vertical-align: top;
font: 12px "Open Sans", sans-serif;
}

.suboptions {
margin: 5px 30px;
border: double 2px rgba( 69, 71, 77, .1 );
Expand Down
40 changes: 6 additions & 34 deletions js/interface_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ function updateHashtagModal(postboard,hashtag,timeoutArgs) {
requestHashtag(postboard,hashtag,resource,timeoutArgs);

if( _hashtagPendingPostsUpdated ) {
showDesktopNotification(false, polyglot.t('You got')+' '+polyglot.t("new_posts", _hashtagPendingPostsUpdated)+' '+polyglot.t('in search result')+'.', false,'twister_notification_new_posts_modal', function() {
$(".postboard-news").hide();
displayHashtagPending($(".hashtag-modal .postboard-posts"));
}, false)
if ($.Options.getShowDesktopNotifPostsModalOpt() === 'enable') {
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t("new_posts", _hashtagPendingPostsUpdated)+' '+polyglot.t('in search result')+'.', false,'twister_notification_new_posts_modal', $.Options.getShowDesktopNotifPostsModalTimerOpt(), function() {
$(".postboard-news").hide();
displayHashtagPending($(".hashtag-modal .postboard-posts"));
}, false)
}

_hashtagPendingPostsUpdated = 0;
}
Expand Down Expand Up @@ -819,36 +821,6 @@ function replyTextKeypress(e) {
}
}

function showDesktopNotification(notifyTitle, notifyBody, notifyIcon, notifyTag, actionOnClick, actionOnPermDenied) {
function doNotification(notifyTitle, notifyBody, notifyIcon, notifyTag, actionOnClick) {
if (!notifyTitle) {
notifyTitle = polyglot.t('notify_desktop_title');
}
if (!notifyIcon) {
notifyIcon = '../img/twister_mini.png';
}
if (!notifyTag) {
notifyTag = 'twister_notification';
}

var desktopNotification = new Notify(notifyTitle, {
body: notifyBody,
icon: notifyIcon,
tag: notifyTag,
timeout: _desktopNotificationTimeout,
notifyClick: actionOnClick,
notifyError: function() { alert(polyglot.t('notify_desktop_error')) }
});
desktopNotification.show();
}

if (Notify.needsPermission) {
Notify.requestPermission(false, actionOnPermDenied);
} else {
doNotification(notifyTitle, notifyBody, notifyIcon, notifyTag, actionOnClick);
}
}

/*
* unicode convertion list
* k: original string to be replaced
Expand Down
58 changes: 42 additions & 16 deletions js/interface_localization.js

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions js/mobile_abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ var MAL = function()
newTweetsBarMenu.text(String(newPosts));
newTweetsBarMenu.addClass("show");

showDesktopNotification(false, polyglot.t('You got')+' '+polyglot.t("new_posts", newPosts)+' '+polyglot.t('in postboard')+'.', false,'twister_notification_new_posts', function() {
requestTimelineUpdate("latest",postsPerRefresh,followingUsers,promotedPostsOnly);
}, false)
if ($.Options.getShowDesktopNotifPostsOpt() === 'enable') {
this.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t("new_posts", newPosts)+' '+polyglot.t('in postboard')+'.', false,'twister_notification_new_posts', $.Options.getShowDesktopNotifPostsTimerOpt(), function() {
requestTimelineUpdate("latest",postsPerRefresh,followingUsers,promotedPostsOnly);
}, false)
}
} else {
newTweetsBar.hide();
newTweetsBar.text("");
Expand Down Expand Up @@ -375,6 +377,39 @@ var MAL = function()
}
}

this.showDesktopNotif = function(notifyTitle, notifyBody, notifyIcon, notifyTag, notifyTimer, actionOnClick, actionOnPermDenied) {
function doNotification(notifyTitle, notifyBody, notifyIcon, notifyTag, notifyTimer, actionOnClick) {
if (!notifyTitle) {
notifyTitle = polyglot.t('notify_desktop_title');
}
if (!notifyIcon) {
notifyIcon = '../img/twister_mini.png';
}
if (!notifyTag) {
notifyTag = 'twister_notification';
}
if (!notifyTimer) {
notifyTimer = 3600 * 24 * 30; // one month
}

var desktopNotification = new Notify(notifyTitle, {
body: notifyBody,
icon: notifyIcon,
tag: notifyTag,
timeout: notifyTimer,
notifyClick: actionOnClick,
notifyError: function() { alert(polyglot.t('notify_desktop_error')) }
});
desktopNotification.show();
}

if (Notify.needsPermission) {
Notify.requestPermission(false, actionOnPermDenied);
} else {
doNotification(notifyTitle, notifyBody, notifyIcon, notifyTag, notifyTimer, actionOnClick);
}
}

this.reqRepAfterCB = function(postLi, postsFromJson) {
if ($.hasOwnProperty("mobile")) {
for( var i = 0; i < postsFromJson.length; i++) {
Expand Down

0 comments on commit 7aa999f

Please sign in to comment.