From baf1060030fc64f5a84550fc8a808739ab541a0b Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sun, 1 Mar 2015 13:31:56 +0500 Subject: [PATCH] switch to home page when clicking on notify, watch hash on loading, return scrolling after modal, primary-btn-only expand --- js/interface_common.js | 12 +++++++++--- js/twister_newmsgs.js | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 72ec8da..395adba 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -5,8 +5,11 @@ // Profile, mentions and hashtag modal // Post actions: submit, count characters +var window_scrollY = 0; + //dispara o modal genérico //o modalClass me permite fazer tratamentos específicos de CSS para cada modal + function openModal( modalClass ) { var $oldModal = $("body").children(".modal-blackout"); @@ -26,6 +29,8 @@ function openModal( modalClass ) $body.css({ "overflow": "hidden" }); + + window_scrollY = window.pageYOffset; } //fecha o modal removendo o conteúdo por detach @@ -33,6 +38,7 @@ function closeModal($this) { closeModalHandler($this); window.location.hash = '#'; + window.scroll(window.pageXOffset, window_scrollY); } function closeModalHandler($this) @@ -479,8 +485,7 @@ function initHashWatching() // Register hash spy and launch it once window.addEventListener('hashchange', watchHashChange, false); - //watchHashChange(null); - window.location.hash="#"; + setTimeout(function(){ watchHashChange() }, 1000); } @@ -1454,7 +1459,8 @@ function initInterfaceCommon() { $( ".userMenu-config-dropdown" ).bind( "click", dropDownMenu ); $( ".config-menu" ).clickoutside( closeThis ); $( ".module.post" ).bind( "click", function(e) { - if(window.getSelection() == 0)postExpandFunction(e,$(this)); }); + if(e.button === 0 && window.getSelection() == 0) postExpandFunction(e,$(this)); + }); $( ".post-area-new" ).bind( "click", function(e) { composeNewPost(e,$(this));} ); $( ".post-area-new" ).clickoutside( unfocusThis ); diff --git a/js/twister_newmsgs.js b/js/twister_newmsgs.js index a078e31..fe753e8 100644 --- a/js/twister_newmsgs.js +++ b/js/twister_newmsgs.js @@ -101,7 +101,13 @@ function requestMentionsCount() { $.MAL.soundNotifyMentions(); if ($.Options.getShowDesktopNotifMentionsOpt() === 'enable') { - $.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_mentions', _newMentions)+'.', false,'twister_notification_new_mentions', $.Options.getShowDesktopNotifMentionsTimerOpt(), openMentionsModal, false) + $.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_mentions', _newMentions)+'.', false,'twister_notification_new_mentions', $.Options.getShowDesktopNotifMentionsTimerOpt(), function() { + if (window.location.pathname === '/home.html' || window.location.pathname === '/following.html' ) { + openMentionsModal(); + } else { + window.location.href = '/home.html#mentions?user='+defaultScreenName; + } + }, false) } } @@ -116,8 +122,12 @@ function requestMentionsCount() { if ($.Options.getShowDesktopNotifDMsOpt() === 'enable') { $.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_direct_messages', newDMs)+'.', false, 'twister_notification_new_DMs', $.Options.getShowDesktopNotifDMsTimerOpt(), function() { + if (window.location.pathname === '/home.html' || window.location.pathname === '/following.html' ) { window.location.hash = '#directmessages'; - }, false) + } else { + window.location.href = '/home.html#directmessages'; + } + }, false) } } }