theme_nin/js/theme_option.js

204 lines
7.0 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-07-31 10:58:25 +02:00
var windowHeight = $(window).height();
2015-08-03 16:20:22 +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/,
'postContext.addClass(\'post-retransmited-by-container\').prependTo(postContext.parent()).append(_templatePostRtBy'));
2015-07-29 06:05:10 +02:00
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-09-14 13:34:33 +02:00
// Collapse all .post.open
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-09-14 13:34:33 +02:00
});
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
if( ( $('.toptrends').html() == '' ) && ($('.who-to-follow').html() == '') && ( $('.twistday-reminder').html() == '' ) ){
$('.dashboard.right').css('display: none');
$('.wrapper .postboard').addClass('large');
}
else {
$('.dashboard.right').css('display: block');
$('.wrapper .postboard').removeClass('large');
}
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-09-12 15:21:54 +02: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-08-03 16:20:22 +02: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-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
$('.module.toptrends').detach().appendTo($('.dashboard.right'));
$('.module.who-to-follow').detach().appendTo($('.dashboard.right'));
$('.module.twistday-reminder').detach().appendTo($('.dashboard.right'));
}
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() {
$("label[for=tab_language]").text(polyglot.t("Language"));
$("label[for=t-2]").text(polyglot.t("Theme"));
$("label[for=t-3]").text(polyglot.t("Notifications"));
$("label[for=t-4]").text(polyglot.t("Keys"));
$("label[for=t-5]").text(polyglot.t("Appearance"));
$("label[for=t-6]").text(polyglot.t("Users"));
}
function openModal(modal) {
2015-07-31 10:58:25 +02:00
var windowHeight = $(window).height();
2015-07-26 21:39:11 +02:00
if (!modal.classBase)
modal.classBase = '.modal-wrapper';
$(modal.classBase + ':not(#templates *)').remove();
modal.self = $('#templates ' + modal.classBase).clone(true)
.addClass(modal.classAdd);
if (modal.title)
modal.self.find('.modal-header h3').html(modal.title);
if (modal.content)
modal.content = modal.self.find('.modal-content')
.append(modal.content);
else
modal.content = modal.self.find('.modal-content');
2015-07-28 10:40:52 +02:00
modal.postboard = modal.self.find('.postboard-posts');
2015-08-01 22:52:31 +02:00
modal.self.prependTo('body').slideDown();
2015-07-28 10:40:52 +02:00
2015-07-26 21:39:11 +02:00
if (modal.classBase === '.modal-wrapper') {
modal.content.outerHeight(modal.self.height() - modal.self.find('.modal-header').outerHeight());
if (modal.self.outerHeight() > windowHeight) {
modal.content.outerHeight(modal.content.outerHeight() - modal.self.outerHeight() + windowHeight);
modal.self.outerHeight(windowHeight);
modal.self.css('margin-top', - windowHeight / 2);
}
}
return modal;
2015-10-24 23:48:21 +02:00
}