theme_nin/js/theme_option.js

170 lines
5.7 KiB
JavaScript
Raw Normal View History

2015-07-28 10:40:52 +02:00
$(window).resize(function()
2015-07-26 21:39:11 +02:00
{
2015-08-10 05:59:24 +02:00
testRightSide();
2015-07-31 10:58:25 +02:00
reAppendModules();
2015-07-26 21:39:11 +02:00
});
2015-08-10 06:12:31 +02:00
$(window).load(function()
{
testRightSide();
});
2015-08-10 05:56:39 +02:00
2015-07-28 10:40:52 +02:00
$(document).ready(function()
2015-07-26 21:39:11 +02:00
{
2015-08-10 05:56:39 +02:00
testRightSide();
2015-08-10 06:12:31 +02:00
reOrganizeTemplates();
$.globalEval(postToElem.toString().replace(/postContext.append\(_templatePostRtBy/,
2015-11-06 21:50:57 +05:00
'postContext.prependTo(postContext.parent()).append(_templatePostRtBy'));
2015-07-29 06:05:10 +02:00
2016-11-27 21:41:25 +05:00
$.globalEval(openModal.toString().replace(/window_scrollY = window\.pageYOffset;/, '')
.replace(/\$\('body'\)\.css\('overflow', 'hidden'\);/, ''));
2015-07-26 21:39:11 +02:00
$( '.userMenu-home.current a' ).on( 'click', function() {
$('html, body').animate({scrollTop:0},300);
return false
});
// modify the way promoted posts are shown
2015-07-31 10:58:25 +02:00
$( ".promoted-posts-only").click(function() {
2015-07-26 21:39:11 +02:00
//active promoted posts tab
$(this).children('.promoted-posts').addClass(promotedPostsOnly ? "active" : "disabled");
$(this).children('.normal-posts').addClass(promotedPostsOnly ? "disabled" : "active");
2015-07-29 06:05:10 +02:00
$('#postboard-top').removeClass(promotedPostsOnly ? "show" : "hide");
2015-07-26 21:39:11 +02:00
//active normal posts
$(this).children('.promoted-posts').removeClass(promotedPostsOnly ? "disabled" : "active");
$(this).children('.normal-posts').removeClass(promotedPostsOnly ? "active" : "disabled");
2015-07-29 06:05:10 +02:00
$('#postboard-top').addClass(promotedPostsOnly ? "hide" : "show");
2015-07-26 21:39:11 +02:00
});
if (/\/options.html$/i.test(document.location))
$(document).ready(localizeLabels);
2015-07-31 10:58:25 +02:00
$(window).scroll(function(){
window_scrollY = window.pageYOffset; // declare variable here for screen not to scroll when closing modals
2015-09-01 07:50:00 +02:00
2015-07-31 10:58:25 +02:00
});
2015-11-06 21:50:57 +05:00
// Collapse all .post.open
2015-09-14 13:34:33 +02:00
var allPostButton = $('<li></li>').addClass('userMenu-collapsePosts').append('<a href="#">Collapse All</a>');
$('.mini-profile-indicators').append(allPostButton);
$(allPostButton).children('a').on('click', function(e) {
var allPost = $('#posts .post.open');
allPost.each(function(){
if (e.button === 0 && window.getSelection() == 0)
postExpandFunction(e, $(this));
});
return false
});
});
2015-08-01 22:52:31 +02:00
2015-08-10 05:56:39 +02:00
function testRightSide() { // if rightside is empty, don't show it and engarge postboard
var container = $('.dashboard.right');
if (container.children('.module:not(:empty)').length) {
container.show();
2015-08-10 05:56:39 +02:00
$('.wrapper .postboard').removeClass('large');
} else {
container.hide();
$('.wrapper .postboard').addClass('large');
2015-08-10 05:56:39 +02:00
}
2015-07-31 10:58:25 +02:00
}
2015-08-01 22:52:31 +02:00
2015-07-31 10:58:25 +02:00
function reOrganizeTemplates() { // for nin's templating
2015-07-26 21:39:11 +02:00
2015-07-31 10:58:25 +02:00
reAppendModules();
//removes unused html
$('.modal-close').html('');
$('.modal-back').html('');
$('.twister-user-remove').html('');
$('.profile-card-main').attr('style', '');
$('.mini-profile-actions span').html('');
2015-11-06 21:50:57 +05:00
//group chat
2015-09-12 15:34:25 +02:00
$('.mini-profile-indicators li.userMenu-groupmessages a span:last-child ').html('Group Msg');
2015-09-14 13:34:33 +02:00
2015-09-12 15:21:54 +02:00
$('button.invite').html('invite');
$('button.leave').html('leave');
$('.secret-key').attr('title', 'copy secret key');
2015-07-31 10:58:25 +02:00
//re-organizes
$('.promoted-posts-only').detach().appendTo($('.left .mini-profile'));
$('.mini-profile .open-following-page').parent('li').detach().appendTo($('.mini-profile-indicators'));
$('.mini-profile-indicators').detach().insertAfter($('.dashboard.left .profile-data'));
2015-11-06 21:50:57 +05:00
///// page profile
2015-08-10 06:17:22 +02:00
$('.forEdition .profile-card-main h2').detach().insertBefore($('.profile-card-main'));
2015-08-01 22:52:31 +02:00
2015-07-31 10:58:25 +02:00
//loader
newLoader()
2015-09-01 07:50:00 +02:00
// new post button
$('<li></li>')
.addClass('userMenu-newPost')
.prependTo('.mini-profile-indicators');
$('<a href="#">New post</a>')
.addClass('ion')
.addClass('ion-plus')
.appendTo('.userMenu-newPost')
.bind( 'click', function() {
if(!$('.mini-profile .post-area').hasClass('display')) {$('.mini-profile .post-area').addClass('display');}
else {$('.mini-profile .post-area').removeClass('display');}
return false;
});
2015-09-01 10:54:04 +02:00
2015-09-14 13:34:33 +02:00
// new post prompt
2015-09-01 10:54:04 +02:00
$('<div><h3>New post</h3><span class="modal-close prompt-close"></span></div>')
.addClass('modal-header')
.prependTo('.mini-profile .post-area');
2015-09-01 07:50:00 +02:00
$('.mini-profile .post-area .post-submit').bind( 'click', function() {
$('.mini-profile .post-area').removeClass('display');
2015-09-01 07:50:00 +02:00
});
2015-09-01 10:54:04 +02:00
$('.mini-profile .post-area .modal-close').bind( 'click', function() {
$('.mini-profile .post-area').removeClass('display');
});
2015-09-13 22:20:04 +02:00
// button "follow" in search
2015-09-14 13:34:33 +02:00
// not very nice but works
2015-09-13 22:20:04 +02:00
$('li:not(.twister-user) button.follow').html('+').attr('title',polyglot.t('Follow'));
$('li:not(.twister-user) button.follow')
.on("eventToggleFollow", function() {
$(this).text('+').attr('title', polyglot.t('Follow'));
})
.on("eventToggleUnfollow", function() {
$(this).text('-').attr('title', polyglot.t('Unfollow'));
2015-11-06 21:50:57 +05:00
});
2015-07-31 10:58:25 +02:00
}
2015-07-26 21:39:11 +02:00
2015-09-14 13:34:33 +02:00
// Close new post prompt with esc key
$(document).keyup(function(e) {
2015-10-24 23:48:21 +02:00
if (e.keyCode == 27) {
$('.mini-profile .post-area').removeClass('display');
closeModal();
}
});
2015-07-31 10:58:25 +02:00
function reAppendModules() { // avoid w1200 things
$('.dashboard.right')
.append($('.module.toptrends'))
.append($('.module.who-to-follow'))
.append($('.module.twistday-reminder'))
.append($('.module.new-users'))
;
2015-07-31 10:58:25 +02:00
}
2015-07-26 21:39:11 +02:00
2015-07-31 10:58:25 +02:00
function newLoader() { // create divs for new loader
$('<div></div>').appendTo('.postboard-loading');
$('<div></div>').appendTo('.postboard-loading');
$('<div></div>').appendTo('.postboard-loading');
}
2015-07-26 21:39:11 +02:00
function localizeLabels() {
2018-01-23 01:21:25 +05:00
$('label.tabs').each(function (i, elem) {
var elem = $(elem);
elem.text(polyglot.t(elem.text()));
});
2015-07-26 21:39:11 +02:00
}