Merge branch 'develop-ascraeus' into develop

This commit is contained in:
Marc Alexander 2014-09-12 19:54:34 +02:00
commit 08d16cf7c9
5 changed files with 651 additions and 628 deletions

View file

@ -1,6 +1,8 @@
/* global phpbb */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
"use strict"; 'use strict';
/** /**
* The following callbacks are for reording items. row_down * The following callbacks are for reording items. row_down
@ -13,11 +15,10 @@ phpbb.addAjaxCallback('row_down', function(res) {
return; return;
} }
var el = $(this), var $firstTr = $(this).parents('tr'),
tr = el.parents('tr'), $secondTr = $firstTr.next();
trSwap = tr.next();
tr.insertAfter(trSwap); $firstTr.insertAfter($secondTr);
}); });
phpbb.addAjaxCallback('row_up', function(res) { phpbb.addAjaxCallback('row_up', function(res) {
@ -25,11 +26,10 @@ phpbb.addAjaxCallback('row_up', function(res) {
return; return;
} }
var el = $(this), var $secondTr = $(this).parents('tr'),
tr = el.parents('tr'), $firstTr = $secondTr.prev();
trSwap = tr.prev();
tr.insertBefore(trSwap); $secondTr.insertBefore($firstTr);
}); });
/** /**
@ -38,10 +38,10 @@ phpbb.addAjaxCallback('row_up', function(res) {
* in the href with "deactivate", and vice versa. * in the href with "deactivate", and vice versa.
*/ */
phpbb.addAjaxCallback('activate_deactivate', function(res) { phpbb.addAjaxCallback('activate_deactivate', function(res) {
var el = $(this), var $this = $(this),
newHref = el.attr('href'); newHref = $this.attr('href');
el.text(res.text); $this.text(res.text);
if (newHref.indexOf('deactivate') !== -1) { if (newHref.indexOf('deactivate') !== -1) {
newHref = newHref.replace('deactivate', 'activate'); newHref = newHref.replace('deactivate', 'activate');
@ -49,7 +49,7 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) {
newHref = newHref.replace('activate', 'deactivate'); newHref = newHref.replace('activate', 'deactivate');
} }
el.attr('href', newHref); $this.attr('href', newHref);
}); });
/** /**
@ -66,11 +66,10 @@ phpbb.addAjaxCallback('row_delete', function(res) {
$('[data-ajax]').each(function() { $('[data-ajax]').each(function() {
var $this = $(this), var $this = $(this),
ajax = $this.attr('data-ajax'), ajax = $this.attr('data-ajax');
fn;
if (ajax !== 'false') { if (ajax !== 'false') {
fn = (ajax !== 'true') ? ajax : null; var fn = (ajax !== 'true') ? ajax : null;
phpbb.ajaxify({ phpbb.ajaxify({
selector: this, selector: this,
refresh: $this.attr('data-refresh') !== undefined, refresh: $this.attr('data-refresh') !== undefined,
@ -82,7 +81,7 @@ $('[data-ajax]').each(function() {
/** /**
* Automatically resize textarea * Automatically resize textarea
*/ */
$(document).ready(function() { $(function() {
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
}); });

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,8 @@
/* global phpbb */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
"use strict"; 'use strict';
// This callback will mark all forum icons read // This callback will mark all forum icons read
phpbb.addAjaxCallback('mark_forums_read', function(res) { phpbb.addAjaxCallback('mark_forums_read', function(res) {
@ -40,10 +42,10 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) {
/** /**
* This callback will mark all topic icons read * This callback will mark all topic icons read
* *
* @param update_topic_links bool Wether "Mark topics read" links should be * @param update_topic_links bool Whether "Mark topics read" links should be
* updated. Defaults to true. * updated. Defaults to true.
*/ */
phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) { phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
var readTitle = res.NO_UNREAD_POSTS; var readTitle = res.NO_UNREAD_POSTS;
var unreadTitle = res.UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS;
var iconsArray = { var iconsArray = {
@ -53,12 +55,12 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) {
'topic_unread': 'topic_read' 'topic_unread': 'topic_read'
}; };
var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
var unreadClassSelectors = ''; var unreadClassSelectors;
var classMap = {}; var classMap = {};
var classNames = []; var classNames = [];
if (typeof update_topic_links === 'undefined') { if (typeof updateTopicLinks === 'undefined') {
update_topic_links = true; updateTopicLinks = true;
} }
$.each(iconsArray, function(unreadClass, readClass) { $.each(iconsArray, function(unreadClass, readClass) {
@ -88,7 +90,7 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) {
$('a').has('span.icon_topic_newest').remove(); $('a').has('span.icon_topic_newest').remove();
// Update mark topics read links // Update mark topics read links
if (update_topic_links) { if (updateTopicLinks) {
$('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS); $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS);
} }
@ -114,22 +116,22 @@ phpbb.addAjaxCallback('notification.mark_read', function(res) {
/** /**
* Mark notification popup rows as read. * Mark notification popup rows as read.
* *
* @param {jQuery} el jQuery object(s) to mark read. * @param {jQuery} $popup jQuery object(s) to mark read.
* @param {int} unreadCount The new unread notifications count. * @param {int} unreadCount The new unread notifications count.
*/ */
phpbb.markNotifications = function(el, unreadCount) { phpbb.markNotifications = function($popup, unreadCount) {
// Remove the unread status. // Remove the unread status.
el.removeClass('bg2'); $popup.removeClass('bg2');
el.find('a.mark_read').remove(); $popup.find('a.mark_read').remove();
// Update the notification link to the real URL. // Update the notification link to the real URL.
el.each(function() { $popup.each(function() {
var link = $(this).find('a'); var link = $(this).find('a');
link.attr('href', link.attr('data-real-url')); link.attr('href', link.attr('data-real-url'));
}); });
// Update the unread count. // Update the unread count.
$('#notification_list_button strong').html(unreadCount); $('strong', '#notification_list_button').html(unreadCount);
// Remove the Mark all read link if there are no unread notifications. // Remove the Mark all read link if there are no unread notifications.
if (!unreadCount) { if (!unreadCount) {
$('#mark_all_notifications').remove(); $('#mark_all_notifications').remove();
@ -143,12 +145,12 @@ phpbb.markNotifications = function(el, unreadCount) {
// This callback finds the post from the delete link, and removes it. // This callback finds the post from the delete link, and removes it.
phpbb.addAjaxCallback('post_delete', function() { phpbb.addAjaxCallback('post_delete', function() {
var el = $(this), var $this = $(this),
postId; postId;
if (el.attr('data-refresh') === undefined) { if ($this.attr('data-refresh') === undefined) {
postId = el[0].href.split('&p=')[1]; postId = $this[0].href.split('&p=')[1];
var post = el.parents('#p' + postId).css('pointer-events', 'none'); var post = $this.parents('#p' + postId).css('pointer-events', 'none');
if (post.hasClass('bg1') || post.hasClass('bg2')) { if (post.hasClass('bg1') || post.hasClass('bg2')) {
var posts1 = post.nextAll('.bg1'); var posts1 = post.nextAll('.bg1');
post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
@ -167,8 +169,7 @@ phpbb.addAjaxCallback('post_visibility', function(res) {
$(this).remove(); $(this).remove();
}); });
if (res.visible) if (res.visible) {
{
// Remove the "Deleted by" message from the post on restoring. // Remove the "Deleted by" message from the post on restoring.
remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() { remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() {
$(this).remove(); $(this).remove();
@ -199,18 +200,18 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
if (typeof res.success !== 'undefined') { if (typeof res.success !== 'undefined') {
var poll = $('.topic_poll'); var poll = $('.topic_poll');
var panel = poll.find('.panel'); var panel = poll.find('.panel');
var results_visible = poll.find('dl:first-child .resultbar').is(':visible'); var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
var most_votes = 0; var mostVotes = 0;
// Set min-height to prevent the page from jumping when the content changes // Set min-height to prevent the page from jumping when the content changes
var update_panel_height = function (height) { var updatePanelHeight = function (height) {
var height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; var height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
panel.css('min-height', height); panel.css('min-height', height);
}; };
update_panel_height(); updatePanelHeight();
// Remove the View results link // Remove the View results link
if (!results_visible) { if (!resultsVisible) {
poll.find('.poll_view_results').hide(500); poll.find('.poll_view_results').hide(500);
} }
@ -226,8 +227,8 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
// Get the votes count of the highest poll option // Get the votes count of the highest poll option
poll.find('[data-poll-option-id]').each(function() { poll.find('[data-poll-option-id]').each(function() {
var option = $(this); var option = $(this);
var option_id = option.attr('data-poll-option-id'); var optionId = option.attr('data-poll-option-id');
most_votes = (res.vote_counts[option_id] >= most_votes) ? res.vote_counts[option_id] : most_votes; mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
}); });
// Update the total votes count // Update the total votes count
@ -235,28 +236,30 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
// Update each option // Update each option
poll.find('[data-poll-option-id]').each(function() { poll.find('[data-poll-option-id]').each(function() {
var option = $(this); var $this = $(this);
var option_id = option.attr('data-poll-option-id'); var optionId = $this.attr('data-poll-option-id');
var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; var voted = (typeof res.user_votes[optionId] !== 'undefined');
var most_voted = (res.vote_counts[option_id] == most_votes) ? true : false; var mostVoted = (res.vote_counts[optionId] === mostVotes);
var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100);
var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
option.toggleClass('voted', voted); $this.toggleClass('voted', voted);
option.toggleClass('most-votes', most_voted); $this.toggleClass('most-votes', mostVoted);
// Update the bars // Update the bars
var bar = option.find('.resultbar div'); var bar = $this.find('.resultbar div');
var bar_time_lapse = (res.can_vote) ? 500 : 1500; var barTimeLapse = (res.can_vote) ? 500 : 1500;
var new_bar_class = (percent == 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(function () { setTimeout(function () {
bar.animate({width: percent_rel + '%'}, 500).removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5').addClass(new_bar_class); bar.animate({width: percentRel + '%'}, 500)
bar.html(res.vote_counts[option_id]); .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
.addClass(newBarClass)
.html(res.vote_counts[optionId]);
var percent_txt = (!percent) ? res.NO_VOTES : percent + '%'; var percentText = percent ? percent + '%' : res.NO_VOTES;
option.find('.poll_option_percent').html(percent_txt); $this.find('.poll_option_percent').html(percentText);
}, bar_time_lapse); }, barTimeLapse);
}); });
if (!res.can_vote) { if (!res.can_vote) {
@ -264,29 +267,30 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
} }
// Display "Your vote has been cast." message. Disappears after 5 seconds. // Display "Your vote has been cast." message. Disappears after 5 seconds.
var confirmation_delay = (res.can_vote) ? 300 : 900; var confirmationDelay = (res.can_vote) ? 300 : 900;
poll.find('.vote-submitted').delay(confirmation_delay).slideDown(200, function() { poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
if (results_visible) { if (resultsVisible) {
update_panel_height(); updatePanelHeight();
} }
$(this).delay(5000).fadeOut(500, function() { $(this).delay(5000).fadeOut(500, function() {
resize_panel(300); resizePanel(300);
}); });
}); });
// Remove the gap resulting from removing options // Remove the gap resulting from removing options
setTimeout(function() { setTimeout(function() {
resize_panel(500); resizePanel(500);
}, 1500); }, 1500);
var resize_panel = function (time) { var resizePanel = function (time) {
var panel_height = panel.height(); var panelHeight = panel.height();
var inner_height = panel.find('.inner').outerHeight(); var innerHeight = panel.find('.inner').outerHeight();
if (panel_height != inner_height) { if (panelHeight != innerHeight) {
panel.css({'min-height': '', 'height': panel_height}).animate({height: inner_height}, time, function () { panel.css({'min-height': '', 'height': panelHeight})
panel.css({'min-height': inner_height, 'height': ''}); .animate({height: innerHeight}, time, function () {
panel.css({'min-height': innerHeight, 'height': ''});
}); });
} }
}; };
@ -300,20 +304,19 @@ $('.poll_view_results a').click(function(e) {
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
var poll = $(this).parents('.topic_poll'); var $poll = $(this).parents('.topic_poll');
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
poll.find('.poll_view_results').hide(500); $poll.find('.poll_view_results').hide(500);
}); });
$('[data-ajax]').each(function() { $('[data-ajax]').each(function() {
var $this = $(this), var $this = $(this);
ajax = $this.attr('data-ajax'), var ajax = $this.attr('data-ajax');
filter = $this.attr('data-filter'), var filter = $this.attr('data-filter');
fn;
if (ajax !== 'false') { if (ajax !== 'false') {
fn = (ajax !== 'true') ? ajax : null; var fn = (ajax !== 'true') ? ajax : null;
filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null; filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;
phpbb.ajaxify({ phpbb.ajaxify({
@ -344,10 +347,10 @@ $('.display_post').click(function(e) {
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
var post_id = $(this).attr('data-post-id'); var postId = $(this).attr('data-post-id');
$('#post_content' + post_id).show(); $('#post_content' + postId).show();
$('#profile' + post_id).show(); $('#profile' + postId).show();
$('#post_hidden' + post_id).hide(); $('#post_hidden' + postId).hide();
}); });
$('#delete_permanent').click(function () { $('#delete_permanent').click(function () {
@ -366,10 +369,13 @@ $('#delete_permanent').click(function () {
* appropriately changed based on the status of the search panel. * appropriately changed based on the status of the search panel.
*/ */
$('#member_search').click(function () { $('#member_search').click(function () {
$('#memberlist_search').slideToggle('fast'); var $memberlistSearch = $('#memberlist_search');
$memberlistSearch.slideToggle('fast');
phpbb.ajaxCallbacks.alt_text.call(this); phpbb.ajaxCallbacks.alt_text.call(this);
// Focus on the username textbox if it's available and displayed // Focus on the username textbox if it's available and displayed
if ($('#memberlist_search').is(':visible')) { if ($memberlistSearch.is(':visible')) {
$('#username').focus(); $('#username').focus();
} }
return false; return false;
@ -378,7 +384,7 @@ $('#member_search').click(function () {
/** /**
* Automatically resize textarea * Automatically resize textarea
*/ */
$(document).ready(function() { $(function() {
phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250}); phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250});
phpbb.resizeTextArea($('#message-box textarea')); phpbb.resizeTextArea($('#message-box textarea'));
}); });

View file

@ -1,3 +1,5 @@
/* global phpbb */
/** /**
* phpBB3 forum functions * phpBB3 forum functions
*/ */
@ -6,6 +8,8 @@
* Find a member * Find a member
*/ */
function find_username(url) { function find_username(url) {
'use strict';
popup(url, 760, 570, '_usersearch'); popup(url, 760, 570, '_usersearch');
return false; return false;
} }
@ -14,6 +18,8 @@ function find_username(url) {
* Window popup * Window popup
*/ */
function popup(url, width, height, name) { function popup(url, width, height, name) {
'use strict';
if (!name) { if (!name) {
name = '_popup'; name = '_popup';
} }
@ -26,17 +32,18 @@ function popup(url, width, height, name) {
* Jump to page * Jump to page
*/ */
function pageJump(item) { function pageJump(item) {
'use strict';
var page = item.val(), var page = item.val(),
per_page = item.attr('data-per-page'), perPage = item.attr('data-per-page'),
base_url = item.attr('data-base-url'), baseUrl = item.attr('data-base-url'),
start_name = item.attr('data-start-name'); startName = item.attr('data-start-name');
if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) {
if (base_url.indexOf('?') === -1) { if (baseUrl.indexOf('?') === -1) {
document.location.href = base_url + '?' + start_name + '=' + ((page - 1) * per_page); document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage);
} else { } else {
document.location.href = base_url.replace(/&/g, '&') + '&' + start_name + '=' + ((page - 1) * per_page); document.location.href = baseUrl.replace(/&/g, '&') + '&' + startName + '=' + ((page - 1) * perPage);
} }
} }
} }
@ -46,9 +53,11 @@ function pageJump(item) {
* id = ID of parent container, name = name prefix, state = state [true/false] * id = ID of parent container, name = name prefix, state = state [true/false]
*/ */
function marklist(id, name, state) { function marklist(id, name, state) {
'use strict';
jQuery('#' + id + ' input[type=checkbox][name]').each(function() { jQuery('#' + id + ' input[type=checkbox][name]').each(function() {
var $this = jQuery(this); var $this = jQuery(this);
if ($this.attr('name').substr(0, name.length) == name) { if ($this.attr('name').substr(0, name.length) === name) {
$this.prop('checked', state); $this.prop('checked', state);
} }
}); });
@ -59,6 +68,8 @@ function marklist(id, name, state) {
* e = element * e = element
*/ */
function viewableArea(e, itself) { function viewableArea(e, itself) {
'use strict';
if (!e) { if (!e) {
return; return;
} }
@ -86,18 +97,20 @@ function viewableArea(e, itself) {
/** /**
* Alternate display of subPanels * Alternate display of subPanels
*/ */
jQuery(document).ready(function() { jQuery(function($) {
jQuery('.sub-panels').each(function() { 'use strict';
var panels = [], $('.sub-panels').each(function() {
childNodes = jQuery('a[data-subpanel]', this).each(function() {
panels.push(this.getAttribute('data-subpanel')); var $childNodes = $('a[data-subpanel]', this),
panels = $childNodes.map(function () {
return this.getAttribute('data-subpanel');
}), }),
show_panel = this.getAttribute('data-show-panel'); showPanel = this.getAttribute('data-show-panel');
if (panels.length) { if (panels.length) {
activateSubPanel(show_panel, panels); activateSubPanel(showPanel, panels);
childNodes.click(function () { $childNodes.click(function () {
activateSubPanel(this.getAttribute('data-subpanel'), panels); activateSubPanel(this.getAttribute('data-subpanel'), panels);
return false; return false;
}); });
@ -109,60 +122,30 @@ jQuery(document).ready(function() {
* Activate specific subPanel * Activate specific subPanel
*/ */
function activateSubPanel(p, panels) { function activateSubPanel(p, panels) {
var i; 'use strict';
var i, showPanel;
if (typeof(p) === 'string') { if (typeof(p) === 'string') {
show_panel = p; showPanel = p;
} }
$('input[name="show_panel"]').val(show_panel); $('input[name="show_panel"]').val(showPanel);
if (typeof(panels) === 'undefined') { if (typeof panels === 'undefined') {
panels = []; panels = jQuery('.sub-panels a[data-subpanel]').map(function() {
jQuery('.sub-panels a[data-subpanel]').each(function() { return this.getAttribute('data-subpanel');
panels.push(this.getAttribute('data-subpanel'));
}); });
} }
for (i = 0; i < panels.length; i++) { for (i = 0; i < panels.length; i++) {
jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none'); jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none');
jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === show_panel); jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel);
}
}
/**
* Call print preview
*/
function printPage() {
if (is_ie) {
printPreview();
} else {
window.print();
}
}
/**
* Show/hide groups of blocks
* c = CSS style name
* e = checkbox element
* t = toggle dispay state (used to show 'grip-show' image in the profile block when hiding the profiles)
*/
function displayBlocks(c, e, t) {
var s = (e.checked === true) ? 1 : -1;
if (t) {
s *= -1;
}
var divs = document.getElementsByTagName("DIV");
for (var d = 0; d < divs.length; d++) {
if (divs[d].className.indexOf(c) === 0) {
divs[d].style.display = (s === 1) ? 'none' : 'block';
}
} }
} }
function selectCode(a) { function selectCode(a) {
'use strict';
// Get ID of code block // Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
var s, r; var s, r;
@ -209,6 +192,8 @@ function selectCode(a) {
* from the displayed rectangle area * from the displayed rectangle area
*/ */
function play_qt_file(obj) { function play_qt_file(obj) {
'use strict';
var rectangle = obj.GetRectangle(); var rectangle = obj.GetRectangle();
var width, height; var width, height;
@ -233,30 +218,32 @@ function play_qt_file(obj) {
obj.Play(); obj.Play();
} }
var in_autocomplete = false; var inAutocomplete = false;
var last_key_entered = ''; var lastKeyEntered = '';
/** /**
* Check event key * Check event key
*/ */
function phpbb_check_key(event) { function phpbbCheckKey(event) {
'use strict';
// Keycode is array down or up? // Keycode is array down or up?
if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) {
in_autocomplete = true; inAutocomplete = true;
} }
// Make sure we are not within an "autocompletion" field // Make sure we are not within an "autocompletion" field
if (in_autocomplete) { if (inAutocomplete) {
// If return pressed and key changed we reset the autocompletion // If return pressed and key changed we reset the autocompletion
if (!last_key_entered || last_key_entered === event.which) { if (!lastKeyEntered || lastKeyEntered === event.which) {
in_autocompletion = false; inAutocomplete = false;
return true; return true;
} }
} }
// Keycode is not return, then return. ;) // Keycode is not return, then return. ;)
if (event.which !== 13) { if (event.which !== 13) {
last_key_entered = event.which; lastKeyEntered = event.which;
return true; return true;
} }
@ -266,113 +253,104 @@ function phpbb_check_key(event) {
/** /**
* Apply onkeypress event for forcing default submit button on ENTER key press * Apply onkeypress event for forcing default submit button on ENTER key press
*/ */
function apply_onkeypress_event() { jQuery(function($) {
jQuery('form input[type=text], form input[type=password]').on('keypress', function (e) { 'use strict';
var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action');
if (!default_button || default_button.length <= 0) { $('form input[type=text], form input[type=password]').on('keypress', function (e) {
var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
if (!defaultButton || defaultButton.length <= 0) {
return true; return true;
} }
if (phpbb_check_key(e)) { if (phpbbCheckKey(e)) {
return true; return true;
} }
if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) {
default_button.click(); defaultButton.click();
return false; return false;
} }
return true; return true;
}); });
} });
jQuery(document).ready(apply_onkeypress_event);
/** /**
* Functions for user search popup * Functions for user search popup
*/ */
function insert_user(formId, value) function insertUser(formId, value)
{ {
var form = jQuery(formId), 'use strict';
formName = form.attr('data-form-name'),
fieldName = form.attr('data-field-name'), var $form = jQuery(formId),
formName = $form.attr('data-form-name'),
fieldName = $form.attr('data-field-name'),
item = opener.document.forms[formName][fieldName]; item = opener.document.forms[formName][fieldName];
if (item.value.length && item.type == 'textarea') { if (item.value.length && item.type == 'textarea') {
value = item.value + "\n" + value; value = item.value + '\n' + value;
} }
item.value = value; item.value = value;
} }
function insert_marked_users(formId, users) function insert_marked_users(formId, users) {
{ 'use strict';
if (typeof(users.length) == "undefined")
{ for (var i = 0; i < users.length; i++) {
if (users.checked) if (users[i].checked) {
{ insertUser(formId, users[i].value);
insert_user(formId, users.value);
}
}
else if (users.length > 0)
{
for (i = 0; i < users.length; i++)
{
if (users[i].checked)
{
insert_user(formId, users[i].value);
}
} }
} }
self.close(); window.close();
} }
function insert_single_user(formId, user) function insert_single_user(formId, user) {
{ 'use strict';
insert_user(formId, user);
self.close(); insertUser(formId, user);
window.close();
} }
/** /**
* Parse document block * Parse document block
*/ */
function parse_document(container) function parseDocument($container) {
{ 'use strict';
var test = document.createElement('div'), var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined'); oldBrowser = (typeof test.style.borderRadius == 'undefined');
delete test;
/** /**
* Reset avatar dimensions when changing URL or EMAIL * Reset avatar dimensions when changing URL or EMAIL
*/ */
container.find('input[data-reset-on-edit]').bind('keyup', function() { $container.find('input[data-reset-on-edit]').on('keyup', function() {
$(this.getAttribute('data-reset-on-edit')).val(''); $(this.getAttribute('data-reset-on-edit')).val('');
}); });
/** /**
* Pagination * Pagination
*/ */
container.find('.pagination .page-jump-form :button').click(function() { $container.find('.pagination .page-jump-form :button').click(function() {
$input = $(this).siblings('input.inputbox'); var $input = $(this).siblings('input.inputbox');
pageJump($input); pageJump($input);
}); });
container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { $container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) {
if (event.which == 13 || event.keyCode == 13) { if (event.which === 13 || event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
pageJump($(this)); pageJump($(this));
} }
}); });
container.find('.pagination .dropdown-trigger').click(function() { $container.find('.pagination .dropdown-trigger').click(function() {
$dropdown_container = $(this).parent(); var $dropdownContainer = $(this).parent();
// Wait a little bit to make sure the dropdown has activated // Wait a little bit to make sure the dropdown has activated
setTimeout(function() { setTimeout(function() {
if ($dropdown_container.hasClass('dropdown-visible')) { if ($dropdownContainer.hasClass('dropdown-visible')) {
$dropdown_container.find('input.inputbox').focus(); $dropdownContainer.find('input.inputbox').focus();
} }
}, 100); }, 100);
}); });
@ -382,27 +360,29 @@ function parse_document(container)
*/ */
if (oldBrowser) { if (oldBrowser) {
// Fix .linklist.bulletin lists // Fix .linklist.bulletin lists
container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin'); $container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin');
} }
/** /**
* Resize navigation block to keep all links on same line * Resize navigation block to keep all links on same line
*/ */
container.find('.navlinks').each(function() { $container.find('.navlinks').each(function() {
var $this = $(this), var $this = $(this),
left = $this.children().not('.rightside'), $left = $this.children().not('.rightside'),
right = $this.children('.rightside'); $right = $this.children('.rightside');
if (left.length !== 1 || !right.length) return; if ($left.length !== 1 || !$right.length) {
return;
}
function resize() { function resize() {
var width = 0, var width = 0,
diff = left.outerWidth(true) - left.width(); diff = $left.outerWidth(true) - $left.width();
right.each(function() { $right.each(function() {
width += $(this).outerWidth(true); width += $(this).outerWidth(true);
}); });
left.css('max-width', Math.floor($this.width() - width - diff) + 'px'); $left.css('max-width', Math.floor($this.width() - width - diff) + 'px');
} }
resize(); resize();
@ -412,11 +392,11 @@ function parse_document(container)
/** /**
* Makes breadcrumbs responsive * Makes breadcrumbs responsive
*/ */
container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {
var $this = $(this), var $this = $(this),
$body = $('body'), $body = $('body'),
links = $this.find('.crumb'), $links = $this.find('.crumb'),
length = links.length, length = $links.length,
classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'], classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'],
classesLength = classes.length, classesLength = classes.length,
maxHeight = 0, maxHeight = 0,
@ -429,14 +409,13 @@ function parse_document(container)
$link.attr('title', $link.text()); $link.attr('title', $link.text());
}); });
// Funciton that checks breadcrumbs // Function that checks breadcrumbs
function check() { function check() {
var height = $this.height(), var height = $this.height(),
width = $body.width(), width = $body.width();
link, i, j;
maxHeight = parseInt($this.css('line-height')) | 0; maxHeight = parseInt($this.css('line-height'));
links.each(function() { $links.each(function() {
if ($(this).height() > 0) { if ($(this).height() > 0) {
maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
} }
@ -444,7 +423,6 @@ function parse_document(container)
if (height <= maxHeight) { if (height <= maxHeight) {
if (!wrapped || lastWidth === false || lastWidth >= width) { if (!wrapped || lastWidth === false || lastWidth >= width) {
lastWidth = width;
return; return;
} }
} }
@ -452,7 +430,6 @@ function parse_document(container)
if (wrapped) { if (wrapped) {
$this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); $this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' '));
wrapped = false;
if ($this.height() <= maxHeight) { if ($this.height() <= maxHeight) {
return; return;
} }
@ -464,9 +441,9 @@ function parse_document(container)
return; return;
} }
for (i = 0; i < classesLength; i ++) { for (var i = 0; i < classesLength; i ++) {
for (j = length - 1; j >= 0; j --) { for (var j = length - 1; j >= 0; j --) {
links.eq(j).addClass('wrapped ' + classes[i]); $links.eq(j).addClass('wrapped ' + classes[i]);
if ($this.height() <= maxHeight) { if ($this.height() <= maxHeight) {
return; return;
} }
@ -482,32 +459,29 @@ function parse_document(container)
/** /**
* Responsive link lists * Responsive link lists
*/ */
container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() { $container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() {
var $this = $(this), var $this = $(this),
$body = $('body'), $body = $('body'),
filterSkip = '.breadcrumbs, [data-skip-responsive]', filterSkip = '.breadcrumbs, [data-skip-responsive]',
filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', filterLast = '.edit-icon, .quote-icon, [data-last-responsive]',
persist = $this.attr('id') == 'nav-main', persist = $this.attr('id') == 'nav-main',
allLinks = $this.children(), $allLinks = $this.children(),
links = allLinks.not(filterSkip), $links = $allLinks.not(filterSkip),
html = '<li class="responsive-menu" style="display:none;"><a href="javascript:void(0);" class="responsive-menu-link">&nbsp;</a><div class="dropdown" style="display:none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>', html = '<li class="responsive-menu" style="display:none;"><a href="javascript:void(0);" class="responsive-menu-link">&nbsp;</a><div class="dropdown" style="display:none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>',
filterLastList = links.filter(filterLast), $filterLastList = $links.filter(filterLast),
slack = 1; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured. slack = 1; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured.
if (!persist) { if (!persist) {
if (links.is('.rightside')) if ($links.is('.rightside')) {
{ $links.filter('.rightside:first').before(html);
links.filter('.rightside:first').before(html);
$this.children('.responsive-menu').addClass('rightside'); $this.children('.responsive-menu').addClass('rightside');
} } else {
else
{
$this.append(html); $this.append(html);
} }
} }
var item = $this.children('.responsive-menu'), var $item = $this.children('.responsive-menu'),
menu = item.find('.dropdown-contents'), $menu = $item.find('.dropdown-contents'),
lastWidth = false, lastWidth = false,
compact = false, compact = false,
responsive = false, responsive = false,
@ -521,29 +495,31 @@ function parse_document(container)
// Unhide the quick-links menu if it has content // Unhide the quick-links menu if it has content
if (persist) { if (persist) {
item.addClass('hidden'); $item.addClass('hidden');
if (menu.find('li:not(.separator, .clone)').length || (responsive && menu.find('li.clone').length)) { if ($menu.find('li:not(.separator, .clone)').length || (responsive && $menu.find('li.clone').length)) {
item.removeClass('hidden'); $item.removeClass('hidden');
} }
} }
// Reset responsive and compact layout // Reset responsive and compact layout
if (responsive) { if (responsive) {
responsive = false;
$this.removeClass('responsive'); $this.removeClass('responsive');
links.css('display', ''); $links.css('display', '');
if (!persist) item.css('display', 'none'); if (!persist) {
$item.css('display', 'none');
}
} }
if (compact) { if (compact) {
compact = false;
$this.removeClass('compact'); $this.removeClass('compact');
} }
// Find tallest element // Find tallest element
var maxHeight = 0; var maxHeight = 0;
allLinks.each(function() { $allLinks.each(function() {
if (!$(this).height()) return; if (!$(this).height()) {
return;
}
maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
}); });
@ -557,12 +533,13 @@ function parse_document(container)
} }
// Enable compact layout, find tallest element, compare to height of whole block // Enable compact layout, find tallest element, compare to height of whole block
compact = true;
$this.addClass('compact'); $this.addClass('compact');
var compactMaxHeight = 0; var compactMaxHeight = 0;
allLinks.each(function() { $allLinks.each(function() {
if (!$(this).height()) return; if (!$(this).height()) {
return;
}
compactMaxHeight = Math.max(compactMaxHeight, $(this).outerHeight(true)); compactMaxHeight = Math.max(compactMaxHeight, $(this).outerHeight(true));
}); });
@ -571,51 +548,51 @@ function parse_document(container)
} }
// Compact layout did not resize block enough, switch to responsive layout // Compact layout did not resize block enough, switch to responsive layout
compact = false;
$this.removeClass('compact'); $this.removeClass('compact');
responsive = true; responsive = true;
if (!copied) { if (!copied) {
var clone = links.clone(true); var clone = $links.clone(true);
clone.filter('.rightside').each(function() { clone.filter('.rightside').each(function() {
if (persist) $(this).addClass('clone'); if (persist) {
menu.prepend(this); $(this).addClass('clone');
}
$menu.prepend(this);
}); });
if (persist) { if (persist) {
menu.prepend(clone.not('.rightside').addClass('clone')); $menu.prepend(clone.not('.rightside').addClass('clone'));
} else { } else {
menu.prepend(clone.not('.rightside')); $menu.prepend(clone.not('.rightside'));
} }
menu.find('li.leftside, li.rightside').removeClass('leftside rightside'); $menu.find('li.leftside, li.rightside').removeClass('leftside rightside');
menu.find('.inputbox').parents('li:first').css('white-space', 'normal'); $menu.find('.inputbox').parents('li:first').css('white-space', 'normal');
if ($this.hasClass('post-buttons')) { if ($this.hasClass('post-buttons')) {
$('.button', menu).removeClass('button icon-button'); $('.button', $menu).removeClass('button icon-button');
$('.responsive-menu-link', item).addClass('button icon-button').prepend('<span></span>'); $('.responsive-menu-link', $item).addClass('button icon-button').prepend('<span></span>');
} }
copied = true; copied = true;
} } else {
else { $menu.children().css('display', '');
menu.children().css('display', '');
} }
item.css('display', ''); $item.css('display', '');
$this.addClass('responsive'); $this.addClass('responsive');
// Try to not hide filtered items // Try to not hide filtered items
if (filterLastList.length) { if ($filterLastList.length) {
links.not(filterLast).css('display', 'none'); $links.not(filterLast).css('display', 'none');
maxHeight = 0; maxHeight = 0;
filterLastList.each(function() { $filterLastList.each(function() {
if (!$(this).height()) return; if (!$(this).height()) return;
maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
}); });
if ($this.height() <= (maxHeight + slack)) { if ($this.height() <= (maxHeight + slack)) {
menu.children().filter(filterLast).css('display', 'none'); $menu.children().filter(filterLast).css('display', 'none');
return; return;
} }
} }
@ -624,10 +601,12 @@ function parse_document(container)
compact = true; compact = true;
$this.addClass('compact'); $this.addClass('compact');
links.css('display', 'none'); $links.css('display', 'none');
} }
if (!persist) phpbb.registerDropdown(item.find('a.responsive-menu-link'), item.find('.dropdown')); if (!persist) {
phpbb.registerDropdown($item.find('a.responsive-menu-link'), $item.find('.dropdown'));
}
check(); check();
$(window).resize(check); $(window).resize(check);
@ -643,7 +622,7 @@ function parse_document(container)
/** /**
* Adjust topiclist lists with check boxes * Adjust topiclist lists with check boxes
*/ */
container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); $container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark');
/** /**
* Appends contents of all extra columns to first column in * Appends contents of all extra columns to first column in
@ -652,31 +631,30 @@ function parse_document(container)
* To add that functionality to .topiclist list simply add * To add that functionality to .topiclist list simply add
* responsive-show-all to list of classes * responsive-show-all to list of classes
*/ */
container.find('.topiclist.responsive-show-all > li > dl').each(function() { $container.find('.topiclist.responsive-show-all > li > dl').each(function() {
var $this = $(this), var $this = $(this),
block = $this.find('dt .responsive-show:last-child'), $block = $this.find('dt .responsive-show:last-child'),
first = true; first = true;
// Create block that is visible only on mobile devices // Create block that is visible only on mobile devices
if (!block.length) { if (!$block.length) {
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
block = $this.find('dt .responsive-show:last-child'); $block = $this.find('dt .responsive-show:last-child');
} } else {
else { first = ($.trim($block.text()).length === 0);
first = ($.trim(block.text()).length == 0);
} }
// Copy contents of each column // Copy contents of each column
$this.find('dd').not('.mark').each(function() { $this.find('dd').not('.mark').each(function() {
var column = $(this), var column = $(this),
children = column.children(), $children = column.children(),
html = column.html(); html = column.html();
if (children.length == 1 && children.text() == column.text()) { if ($children.length == 1 && $children.text() == column.text()) {
html = children.html(); html = $children.html();
} }
block.append((first ? '' : '<br />') + html); $block.append((first ? '' : '<br />') + html);
first = false; first = false;
}); });
@ -689,13 +667,13 @@ function parse_document(container)
* To add that functionality to .topiclist list simply add * To add that functionality to .topiclist list simply add
* responsive-show-columns to list of classes * responsive-show-columns to list of classes
*/ */
container.find('.topiclist.responsive-show-columns').each(function() { $container.find('.topiclist.responsive-show-columns').each(function() {
var list = $(this), var $list = $(this),
headers = [], headers = [],
headersLength = 0; headersLength = 0;
// Find all headers, get contents // Find all headers, get contents
list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { $list.prev('.topiclist').find('li.header dd').not('.mark').each(function() {
headers.push($(this).text()); headers.push($(this).text());
headersLength++; headersLength++;
}); });
@ -705,18 +683,18 @@ function parse_document(container)
} }
// Parse each row // Parse each row
list.find('dl').each(function() { $list.find('dl').each(function() {
var $this = $(this), var $this = $(this),
block = $this.find('dt .responsive-show:last-child'), $block = $this.find('dt .responsive-show:last-child'),
first = true; first = true;
// Create block that is visible only on mobile devices // Create block that is visible only on mobile devices
if (!block.length) { if (!$block.length) {
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
block = $this.find('dt .responsive-show:last-child'); $block = $this.find('dt .responsive-show:last-child');
} }
else { else {
first = ($.trim(block.text()).length == 0); first = ($.trim($block.text()).length === 0);
} }
// Copy contents of each column // Copy contents of each column
@ -734,7 +712,7 @@ function parse_document(container)
html = headers[i] + ': <strong>' + html + '</strong>'; html = headers[i] + ': <strong>' + html + '</strong>';
} }
block.append((first ? '' : '<br />') + html); $block.append((first ? '' : '<br />') + html);
first = false; first = false;
}); });
@ -744,16 +722,15 @@ function parse_document(container)
/** /**
* Responsive tables * Responsive tables
*/ */
container.find('table.table1').not('.not-responsive').each(function() { $container.find('table.table1').not('.not-responsive').each(function() {
var $this = $(this), var $this = $(this),
th = $this.find('thead > tr > th'), $th = $this.find('thead > tr > th'),
columns = th.length,
headers = [], headers = [],
totalHeaders = 0, totalHeaders = 0,
i, headersLength; i, headersLength;
// Find each header // Find each header
th.each(function(column) { $th.each(function(column) {
var cell = $(this), var cell = $(this),
colspan = parseInt(cell.attr('colspan')), colspan = parseInt(cell.attr('colspan')),
dfn = cell.attr('data-dfn'), dfn = cell.attr('data-dfn'),
@ -802,8 +779,7 @@ function parse_document(container)
if ((text.length && text !== '-') || cell.children().length) { if ((text.length && text !== '-') || cell.children().length) {
cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>'); cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>');
} } else {
else {
cell.addClass('empty'); cell.addClass('empty');
} }
@ -816,10 +792,9 @@ function parse_document(container)
/** /**
* Hide empty responsive tables * Hide empty responsive tables
*/ */
container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { $container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() {
var items = $(this).children('tr'); var $items = $(this).children('tr');
if (items.length == 0) if (!$items.length) {
{
$(this).parent('table:first').addClass('responsive-hide'); $(this).parent('table:first').addClass('responsive-hide');
} }
}); });
@ -827,65 +802,64 @@ function parse_document(container)
/** /**
* Responsive tabs * Responsive tabs
*/ */
container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { $container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() {
var $this = $(this), var $this = $(this),
$body = $('body'), $body = $('body'),
ul = $this.children(), $ul = $this.children(),
tabs = ul.children().not('[data-skip-responsive]'), $tabs = $ul.children().not('[data-skip-responsive]'),
links = tabs.children('a'), $links = $tabs.children('a'),
item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'), $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'),
menu = item.find('.dropdown-contents'), $menu = $item.find('.dropdown-contents'),
maxHeight = 0, maxHeight = 0,
lastWidth = false, lastWidth = false,
responsive = false; responsive = false;
links.each(function() { $links.each(function() {
var link = $(this); var $this = $(this);
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true)));
}) });
function check() { function check() {
var width = $body.width(), var width = $body.width(),
height = $this.height(); height = $this.height();
if (arguments.length == 0 && (!responsive || width <= lastWidth) && height <= maxHeight) { if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
return; return;
} }
tabs.show(); $tabs.show();
item.hide(); $item.hide();
lastWidth = width; lastWidth = width;
height = $this.height(); height = $this.height();
if (height <= maxHeight) { if (height <= maxHeight) {
responsive = false; if ($item.hasClass('dropdown-visible')) {
if (item.hasClass('dropdown-visible')) { phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0));
phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0));
} }
return; return;
} }
responsive = true; responsive = true;
item.show(); $item.show();
menu.html(''); $menu.html('');
var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'), var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'),
total = availableTabs.length, total = $availableTabs.length,
i, tab; i, $tab;
for (i = total - 1; i >= 0; i --) { for (i = total - 1; i >= 0; i --) {
tab = availableTabs.eq(i); $tab = $availableTabs.eq(i);
menu.prepend(tab.clone(true).removeClass('tab')); $menu.prepend($tab.clone(true).removeClass('tab'));
tab.hide(); $tab.hide();
if ($this.height() <= maxHeight) { if ($this.height() <= maxHeight) {
menu.find('a').click(function() { check(true); }); $menu.find('a').click(function() { check(true); });
return; return;
} }
} }
menu.find('a').click(function() { check(true); }); $menu.find('a').click(function() { check(true); });
} }
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab'}); phpbb.registerDropdown($item.find('a.responsive-tab-link'), $item.find('.dropdown'), {visibleClass: 'activetab'});
check(true); check(true);
$(window).resize(check); $(window).resize(check);
@ -894,10 +868,9 @@ function parse_document(container)
/** /**
* Hide UCP/MCP navigation if there is only 1 item * Hide UCP/MCP navigation if there is only 1 item
*/ */
container.find('#navigation').each(function() { $container.find('#navigation').each(function() {
var items = $(this).children('ol, ul').children('li'); var $items = $(this).children('ol, ul').children('li');
if (items.length == 1) if ($items.length === 1) {
{
$(this).addClass('responsive-hide'); $(this).addClass('responsive-hide');
} }
}); });
@ -905,7 +878,7 @@ function parse_document(container)
/** /**
* Replace responsive text * Replace responsive text
*/ */
container.find('[data-responsive-text]').each(function() { $container.find('[data-responsive-text]').each(function() {
var $this = $(this), var $this = $(this),
fullText = $this.text(), fullText = $this.text(),
responsiveText = $this.attr('data-responsive-text'), responsiveText = $this.attr('data-responsive-text'),
@ -913,12 +886,16 @@ function parse_document(container)
function check() { function check() {
if ($(window).width() > 700) { if ($(window).width() > 700) {
if (!responsive) return; if (!responsive) {
return;
}
$this.text(fullText); $this.text(fullText);
responsive = false; responsive = false;
return; return;
} }
if (responsive) return; if (responsive) {
return;
}
$this.text(responsiveText); $this.text(responsiveText);
responsive = true; responsive = true;
} }
@ -931,8 +908,9 @@ function parse_document(container)
/** /**
* Run onload functions * Run onload functions
*/ */
(function($) { jQuery(function($) {
$(document).ready(function() { 'use strict';
// Swap .nojs and .hasjs // Swap .nojs and .hasjs
$('#phpbb.nojs').toggleClass('nojs hasjs'); $('#phpbb.nojs').toggleClass('nojs hasjs');
$('#phpbb').toggleClass('hastouch', phpbb.isTouch); $('#phpbb').toggleClass('hastouch', phpbb.isTouch);
@ -943,6 +921,5 @@ function parse_document(container)
$('#' + this.getAttribute('data-focus')).focus(); $('#' + this.getAttribute('data-focus')).focus();
}); });
parse_document($('body')); parseDocument($('body'));
}); });
})(jQuery);

View file

@ -1,6 +1,8 @@
/* global phpbb */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
"use strict"; 'use strict';
$('#tz_date').change(function() { $('#tz_date').change(function() {
phpbb.timezoneSwitchDate(false); phpbb.timezoneSwitchDate(false);
@ -10,12 +12,9 @@ $('#tz_select_date_suggest').click(function(){
phpbb.timezonePreselectSelect(true); phpbb.timezonePreselectSelect(true);
}); });
$(document).ready( $(function () {
phpbb.timezoneEnableDateSelection phpbb.timezoneEnableDateSelection();
); phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true');
});
$(document).ready(
phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true')
);
})(jQuery); // Avoid conflicts with other libraries })(jQuery); // Avoid conflicts with other libraries