Browse Source

Merge pull request #199 from milouse/feature/followhashlinks

Better navigation inside modal windows (next, previous)
master
miguelfreitas 10 years ago
parent
commit
63f36c8e39
  1. 54
      js/interface_common.js
  2. 2
      js/interface_home.js

54
js/interface_common.js

@ -103,7 +103,12 @@ function openProfileModal(e) @@ -103,7 +103,12 @@ function openProfileModal(e)
var $this = $( this );
var username = $.MAL.urlToUser( $this.attr("href") );
openProfileModalWithUsername(username);
}
function openProfileModalWithUsername(username)
{
if(!username)
{
alert(polyglot.t("You don't have any profile because you are not logged in."));
@ -128,6 +133,7 @@ function openProfileModal(e) @@ -128,6 +133,7 @@ function openProfileModal(e)
$(".tox-ctc").attr("title", polyglot.t("Copy to clipboard"));
$(".bitmessage-ctc").attr("title", polyglot.t("Copy to clipboard"));
window.location.hash = '#profile?user=' + username;
}
function newHashtagModal(hashtag) {
@ -150,16 +156,7 @@ function openHashtagModal(e) @@ -150,16 +156,7 @@ function openHashtagModal(e)
var $this = $( this );
var hashtag = $this.text().substring(1).toLowerCase();
var hashtagModalClass = "hashtag-modal";
openModal( hashtagModalClass );
$( "."+hashtagModalClass ).attr("data-resource","hashtag");
var hashtagModalContent = newHashtagModal( hashtag );
hashtagModalContent.appendTo("." +hashtagModalClass + " .modal-content");
//título do modal
$( "."+hashtagModalClass + " h3" ).text( "#" + hashtag );
openHashtagModalFromSearch(hashtag);
}
function openHashtagModalFromSearch(hashtag)
@ -173,6 +170,7 @@ function openHashtagModalFromSearch(hashtag) @@ -173,6 +170,7 @@ function openHashtagModalFromSearch(hashtag)
//título do modal
$( "."+hashtagModalClass + " h3" ).text( "#" + hashtag );
window.location.hash = '#hashtag?hashtag=' + hashtag;
}
function updateHashtagModal(postboard,hashtag) {
@ -354,6 +352,42 @@ function openConversationModal(e) @@ -354,6 +352,42 @@ function openConversationModal(e)
$( "." + conversationModalClass + " h3" ).text( polyglot.t('conversation_title', {'username': postLi.find('.post-data').attr('data-screen-name')}) );
}
function watchHashChange(e)
{
var hashstring = window.location.hash
hashstring = decodeURIComponent(hashstring);
var hashdata = hashstring.split(':');
if (hashdata[0] != '#web+twister') {
hashdata = hashstring.match(/(hashtag|profile)\?(?:user|hashtag)=(.+)/);
}
if (hashdata && hashdata[1] != undefined && hashdata[2] != undefined)
{
if(hashdata[1] == 'profile') {
openProfileModalWithUsername(hashdata[2]);
}else if (hashdata[1] == 'hashtag') {
openHashtagModalFromSearch(hashdata[2]);
}
}
}
function initHashWatching()
{
// Register custom protocol handler
if (window.navigator && window.navigator.registerProtocolHandler){
var local_twister_url = window.location.protocol + '//' + window.location.host + '/home.html#%s';
window.navigator.registerProtocolHandler('web+twister', local_twister_url, 'Twister');
}
// Register hash spy and launch it once
window.addEventListener('hashchange', watchHashChange, false);
watchHashChange(null);
}
//
// Post actions, submit, count characters
// --------------------------------------

2
js/interface_home.js

@ -52,6 +52,7 @@ var InterfaceFunctions = function() @@ -52,6 +52,7 @@ var InterfaceFunctions = function()
initInterfaceDirectMsg();
initUser(initHome);
initHashWatching();
};
function initHome(cbFunc, cbArg) {
@ -174,4 +175,3 @@ function fixDiv() @@ -174,4 +175,3 @@ function fixDiv()
$cache.removeClass( "fixed" );
}
$(window).scroll(fixDiv);

Loading…
Cancel
Save