diff options
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/adm/style/ajax.js | 33 | ||||
| -rw-r--r-- | phpBB/assets/javascript/core.js | 588 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/profilefields/manager.php | 10 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/ajax.js | 148 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/forum_fn.js | 499 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/pagination.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/timezone.js | 15 | 
8 files changed, 658 insertions, 639 deletions
| diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 959580d6c2..4ad6b6afa5 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,6 +1,8 @@ +/* global phpbb */ +  (function($) {  // Avoid conflicts with other libraries -"use strict"; +'use strict';  /**   * The following callbacks are for reording items. row_down @@ -13,11 +15,10 @@ phpbb.addAjaxCallback('row_down', function(res) {  		return;  	} -	var el = $(this), -		tr = el.parents('tr'), -		trSwap = tr.next(); +	var $firstTr = $(this).parents('tr'), +		$secondTr = $firstTr.next(); -	tr.insertAfter(trSwap); +	$firstTr.insertAfter($secondTr);  });  phpbb.addAjaxCallback('row_up', function(res) { @@ -25,11 +26,10 @@ phpbb.addAjaxCallback('row_up', function(res) {  		return;  	} -	var el = $(this), -		tr = el.parents('tr'), -		trSwap = tr.prev(); +	var $secondTr = $(this).parents('tr'), +		$firstTr = $secondTr.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.   */  phpbb.addAjaxCallback('activate_deactivate', function(res) { -	var el = $(this), -		newHref = el.attr('href'); +	var $this = $(this), +		newHref = $this.attr('href'); -	el.text(res.text); +	$this.text(res.text);  	if (newHref.indexOf('deactivate') !== -1) {  		newHref = newHref.replace('deactivate', 'activate'); @@ -49,7 +49,7 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) {  		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() {  	var $this = $(this), -		ajax = $this.attr('data-ajax'), -		fn; +		ajax = $this.attr('data-ajax');  	if (ajax !== 'false') { -		fn = (ajax !== 'true') ? ajax : null; +		var fn = (ajax !== 'true') ? ajax : null;  		phpbb.ajaxify({  			selector: this,  			refresh: $this.attr('data-refresh') !== undefined, @@ -82,7 +81,7 @@ $('[data-ajax]').each(function() {  /**  * Automatically resize textarea  */ -$(document).ready(function() { +$(function() {  	phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});  }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 388f31698f..802b4dd7c8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -3,7 +3,7 @@ phpbb.alertTime = 100;  (function($) {  // Avoid conflicts with other libraries -"use strict"; +'use strict';  // define a couple constants for keydown functions.  var keymap = { @@ -12,8 +12,8 @@ var keymap = {  	ESC: 27  }; -var dark = $('#darkenwrapper'); -var loadingIndicator = $('#loading_indicator'); +var $dark = $('#darkenwrapper'); +var $loadingIndicator = $('#loading_indicator');  var phpbbAlertTimer = null;  phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); @@ -24,18 +24,20 @@ phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');   * @returns object Returns loadingIndicator.   */  phpbb.loadingIndicator = function() { -	if (!loadingIndicator.is(':visible')) { -		loadingIndicator.fadeIn(phpbb.alertTime); +	if (!$loadingIndicator.is(':visible')) { +		$loadingIndicator.fadeIn(phpbb.alertTime);  		// Wait fifteen seconds and display an error if nothing has been returned by then.  		phpbb.clearLoadingTimeout();  		phpbbAlertTimer = setTimeout(function() { -			if (loadingIndicator.is(':visible')) { -				phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); +			var $alert = $('#phpbb_alert'); + +			if ($loadingIndicator.is(':visible')) { +				phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req'));  			}  		}, 15000);  	} -	return loadingIndicator; +	return $loadingIndicator;  };  /** @@ -73,24 +75,24 @@ phpbb.closeDarkenWrapper = function(delay) {   * @returns object Returns the div created.   */  phpbb.alert = function(title, msg, fadedark) { -	var div = $('#phpbb_alert'); -	div.find('.alert_title').html(title); -	div.find('.alert_text').html(msg); +	var $alert = $('#phpbb_alert'); +	$alert.find('.alert_title').html(title); +	$alert.find('.alert_text').html(msg); -	if (!dark.is(':visible')) { -		dark.fadeIn(phpbb.alertTime); +	if (!$dark.is(':visible')) { +		$dark.fadeIn(phpbb.alertTime);  	} -	div.bind('click', function(e) { +	$alert.on('click', function(e) {  		e.stopPropagation();  	}); -	dark.one('click', function(e) { +	$dark.one('click', function(e) {  		var fade; -		div.find('.alert_close').unbind('click'); -		fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; +		$alert.find('.alert_close').off('click'); +		fade = (typeof fadedark !== 'undefined' && !fadedark) ? $alert : $dark;  		fade.fadeOut(phpbb.alertTime, function() { -			div.hide(); +			$alert.hide();  		});  		e.preventDefault(); @@ -98,35 +100,35 @@ phpbb.alert = function(title, msg, fadedark) {  	});  	$(document).keydown(function(e) { -		if ((e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) && dark.is(':visible')) { -			dark.trigger('click'); +		if ((e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) && $dark.is(':visible')) { +			$dark.trigger('click');  			e.preventDefault();  			e.stopPropagation();  		}  	}); -	div.find('.alert_close').one('click', function(e) { -		dark.trigger('click'); +	$alert.find('.alert_close').one('click', function(e) { +		$dark.trigger('click');  		e.preventDefault();  	}); -	if (loadingIndicator.is(':visible')) { -		loadingIndicator.fadeOut(phpbb.alertTime, function() { -			dark.append(div); -			div.fadeIn(phpbb.alertTime); +	if ($loadingIndicator.is(':visible')) { +		$loadingIndicator.fadeOut(phpbb.alertTime, function() { +			$dark.append($alert); +			$alert.fadeIn(phpbb.alertTime);  		}); -	} else if (dark.is(':visible')) { -		dark.append(div); -		div.fadeIn(phpbb.alertTime); +	} else if ($dark.is(':visible')) { +		$dark.append($alert); +		$alert.fadeIn(phpbb.alertTime);  	} else { -		dark.append(div); -		div.show(); -		dark.fadeIn(phpbb.alertTime); +		$dark.append($alert); +		$alert.show(); +		$dark.fadeIn(phpbb.alertTime);  	} -	return div; +	return $alert;  };  /** @@ -143,24 +145,24 @@ phpbb.alert = function(title, msg, fadedark) {   * @returns object Returns the div created.   */  phpbb.confirm = function(msg, callback, fadedark) { -	var div = $('#phpbb_confirm'); -	div.find('.alert_text').html(msg); +	var $confirmDiv = $('#phpbb_confirm'); +	$confirmDiv.find('.alert_text').html(msg); -	if (!dark.is(':visible')) { -		dark.fadeIn(phpbb.alertTime); +	if (!$dark.is(':visible')) { +		$dark.fadeIn(phpbb.alertTime);  	} -	div.bind('click', function(e) { +	$confirmDiv.on('click', function(e) {  		e.stopPropagation();  	});  	var clickHandler = function(e) {  		var res = this.name === 'confirm'; -		var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; -		fade.fadeOut(phpbb.alertTime, function() { -			div.hide(); +		var $fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? $confirmDiv : $dark; +		$fade.fadeOut(phpbb.alertTime, function() { +			$confirmDiv.hide();  		}); -		div.find('input[type="button"]').unbind('click', clickHandler); +		$confirmDiv.find('input[type="button"]').off('click', clickHandler);  		callback(res);  		if (e) { @@ -168,12 +170,12 @@ phpbb.confirm = function(msg, callback, fadedark) {  			e.stopPropagation();  		}  	}; -	div.find('input[type="button"]').one('click', clickHandler); +	$confirmDiv.find('input[type="button"]').one('click', clickHandler); -	dark.one('click', function(e) { -		div.find('.alert_close').unbind('click'); -		dark.fadeOut(phpbb.alertTime, function() { -			div.hide(); +	$dark.one('click', function(e) { +		$confirmDiv.find('.alert_close').off('click'); +		$dark.fadeOut(phpbb.alertTime, function() { +			$confirmDiv.hide();  		});  		callback(false); @@ -181,7 +183,7 @@ phpbb.confirm = function(msg, callback, fadedark) {  		e.stopPropagation();  	}); -	$(document).bind('keydown', function(e) { +	$(document).on('keydown', function(e) {  		if (e.keyCode === keymap.ENTER) {  			$('input[name="confirm"]').trigger('click');  			e.preventDefault(); @@ -193,31 +195,31 @@ phpbb.confirm = function(msg, callback, fadedark) {  		}  	}); -	div.find('.alert_close').one('click', function(e) { -		var fade = (typeof fadedark !== 'undefined' && fadedark) ? div : dark; -		fade.fadeOut(phpbb.alertTime, function() { -			div.hide(); +	$confirmDiv.find('.alert_close').one('click', function(e) { +		var $fade = (typeof fadedark !== 'undefined' && fadedark) ? $confirmDiv : $dark; +		$fade.fadeOut(phpbb.alertTime, function() { +			$confirmDiv.hide();  		});  		callback(false);  		e.preventDefault();  	}); -	if (loadingIndicator.is(':visible')) { -		loadingIndicator.fadeOut(phpbb.alertTime, function() { -			dark.append(div); -			div.fadeIn(phpbb.alertTime); +	if ($loadingIndicator.is(':visible')) { +		$loadingIndicator.fadeOut(phpbb.alertTime, function() { +			$dark.append($confirmDiv); +			$confirmDiv.fadeIn(phpbb.alertTime);  		}); -	} else if (dark.is(':visible')) { -		dark.append(div); -		div.fadeIn(phpbb.alertTime); +	} else if ($dark.is(':visible')) { +		$dark.append($confirmDiv); +		$confirmDiv.fadeIn(phpbb.alertTime);  	} else { -		dark.append(div); -		div.show(); -		dark.fadeIn(phpbb.alertTime); +		$dark.append($confirmDiv); +		$confirmDiv.show(); +		$dark.fadeIn(phpbb.alertTime);  	} -	return div; +	return $confirmDiv;  };  /** @@ -257,12 +259,12 @@ phpbb.parseQuerystring = function(string) {   *     that was returned and (if it is a form) the form action.   */  phpbb.ajaxify = function(options) { -	var elements = $(options.selector), +	var $elements = $(options.selector),  		refresh = options.refresh,  		callback = options.callback,  		overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, -		isForm = elements.is('form'), -		isText = elements.is('input[type="text"], textarea'), +		isForm = $elements.is('form'), +		isText = $elements.is('input[type="text"], textarea'),  		eventName;  	if (isForm) { @@ -273,7 +275,7 @@ phpbb.ajaxify = function(options) {  		eventName = 'click';  	} -	elements.bind(eventName, function(event) { +	$elements.on(eventName, function(event) {  		var action, method, data, submit, that = this, $this = $(this);  		if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { @@ -293,11 +295,12 @@ phpbb.ajaxify = function(options) {  				errorText = errorThrown;  			}  			else { -				errorText = dark.attr('data-ajax-error-text-' + textStatus); -				if (typeof errorText !== 'string' || !errorText.length)  -					errorText = dark.attr('data-ajax-error-text'); +				errorText = $dark.attr('data-ajax-error-text-' + textStatus); +				if (typeof errorText !== 'string' || !errorText.length) { +					errorText = $dark.attr('data-ajax-error-text'); +				}  			} -			phpbb.alert(dark.attr('data-ajax-error-title'), errorText); +			phpbb.alert($dark.attr('data-ajax-error-title'), errorText);  		}  		/** @@ -322,7 +325,7 @@ phpbb.ajaxify = function(options) {  				if (typeof res.MESSAGE_TITLE !== 'undefined') {  					alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);  				} else { -					dark.fadeOut(phpbb.alertTime); +					$dark.fadeOut(phpbb.alertTime);  				}  				if (typeof phpbb.ajaxCallbacks[callback] === 'function') { @@ -345,7 +348,7 @@ phpbb.ajaxify = function(options) {  						// Hide the alert even if we refresh the page, in case the user  						// presses the back button. -						dark.fadeOut(phpbb.alertTime, function() { +						$dark.fadeOut(phpbb.alertTime, function() {  							if (typeof alert !== 'undefined') {  								alert.hide();  							} @@ -355,17 +358,19 @@ phpbb.ajaxify = function(options) {  			} else {  				// If confirmation is required, display a dialog to the user.  				phpbb.confirm(res.MESSAGE_BODY, function(del) { -					if (del) { -						phpbb.loadingIndicator(); -						data =  $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize(); -						$.ajax({ -							url: res.S_CONFIRM_ACTION, -							type: 'POST', -							data: data + '&confirm=' + res.YES_VALUE + '&' + $('#phpbb_confirm form').serialize(), -							success: returnHandler, -							error: errorHandler -						}); +					if (!del) { +						return;  					} + +					phpbb.loadingIndicator(); +					data =  $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize(); +					$.ajax({ +						url: res.S_CONFIRM_ACTION, +						type: 'POST', +						data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(), +						success: returnHandler, +						error: errorHandler +					});  				}, false);  			}  		} @@ -373,7 +378,7 @@ phpbb.ajaxify = function(options) {  		// If the element is a form, POST must be used and some extra data must  		// be taken from the form.  		var runFilter = (typeof options.filter === 'function'); -		var data = {}; +		data = {};  		if (isForm) {  			action = $this.attr('action').replace('&', '&'); @@ -388,7 +393,7 @@ phpbb.ajaxify = function(options) {  				});  			}  		} else if (isText) { -			var name = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : this['name']; +			var name = $this.attr('data-name') || this.name;  			action = $this.attr('data-url').replace('&', '&');  			data[name] = this.value;  			method = 'POST'; @@ -399,7 +404,8 @@ phpbb.ajaxify = function(options) {  		}  		var sendRequest = function() { -			if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { +			var dataOverlay = $this.attr('data-overlay'); +			if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) {  				phpbb.loadingIndicator();  			} @@ -411,7 +417,7 @@ phpbb.ajaxify = function(options) {  				error: errorHandler  			});  			request.always(function() { -				loadingIndicator.fadeOut(phpbb.alertTime); +				$loadingIndicator.fadeOut(phpbb.alertTime);  			});  		}; @@ -426,7 +432,7 @@ phpbb.ajaxify = function(options) {  	});  	if (isForm) { -		elements.find('input:submit').click(function () { +		$elements.find('input:submit').click(function () {  			var $this = $(this);  			$this.siblings('[data-clicked]').removeAttr('data-clicked'); @@ -437,7 +443,13 @@ phpbb.ajaxify = function(options) {  	return this;  }; -phpbb.search = {cache: {data: []}, tpl: [], container: []}; +phpbb.search = { +	cache: { +		data: [] +	}, +	tpl: [], +	container: [] +};  /**   * Get cached search data.  @@ -478,7 +490,7 @@ phpbb.search.cache.set = function(id, key, value) {   * @return undefined   */  phpbb.search.cache.setResults = function(id, keyword, value) { -	this.data[id]['results'][keyword] = value; +	this.data[id].results[keyword] = value;  };  /** @@ -495,16 +507,16 @@ phpbb.search.cleanKeyword = function(keyword) {   * Get clean version of search keyword. If textarea supports several keywords   * (one per line), it fetches the current keyword based on the caret position.   * - * @param jQuery el			Search input|textarea. + * @param jQuery $input		Search input|textarea.   * @param string keyword	Input|textarea value.   * @param bool multiline	Whether textarea supports multiple search keywords.   *   * @return string Clean string.   */ -phpbb.search.getKeyword = function(el, keyword, multiline) { +phpbb.search.getKeyword = function($input, keyword, multiline) {  	if (multiline) { -		var line = phpbb.search.getKeywordLine(el); -		keyword = keyword.split("\n").splice(line, 1); +		var line = phpbb.search.getKeywordLine($input); +		keyword = keyword.split('\n').splice(line, 1);  	}  	return phpbb.search.cleanKeyword(keyword);  }; @@ -513,46 +525,48 @@ phpbb.search.getKeyword = function(el, keyword, multiline) {   * Get the textarea line number on which the keyword resides - for textareas   * that support multiple keywords (one per line).    * - * @param jQuery el	Search textarea. + * @param jQuery $textarea	Search textarea.   * @return int   */ -phpbb.search.getKeywordLine = function (el) { -	return el.val().substr(0, el.get(0).selectionStart).split("\n").length - 1; +phpbb.search.getKeywordLine = function ($textarea) { +	var selectionStart = $textarea.get(0).selectionStart; +	return $textarea.val().substr(0, selectionStart).split('\n').length - 1;  };  /**   * Set the value on the input|textarea. If textarea supports multiple   * keywords, only the active keyword is replaced.   * - * @param jQuery el			Search input|textarea. + * @param jQuery $input		Search input|textarea.   * @param string value		Value to set.   * @param bool multiline	Whether textarea supports multiple search keywords.	   *   * @return undefined   */ -phpbb.search.setValue = function(el, value, multiline) { +phpbb.search.setValue = function($input, value, multiline) {  	if (multiline) { -		var line = phpbb.search.getKeywordLine(el), -			lines = el.val().split("\n"); +		var line = phpbb.search.getKeywordLine($input), +			lines = $input.val().split('\n');  		lines[line] = value; -		value = lines.join("\n"); +		value = lines.join('\n');  	} -	el.val(value); +	$input.val(value);  };  /**   * Sets the onclick event to set the value on the input|textarea to the selected search result.    * - * @param jQuery el		Search input|textarea. + * @param jQuery $input		Search input|textarea.   * @param object value		Result object. - * @param object container	jQuery object for the search container. + * @param jQuery $row		Result element. + * @param jQuery $container	jQuery object for the search container.   *   * @return undefined   */ -phpbb.search.setValueOnClick = function(el, value, row, container) { -	row.click(function() { -		phpbb.search.setValue(el, value.result, el.attr('data-multiline')); -		container.hide(); +phpbb.search.setValueOnClick = function($input, value, $row, $container) { +	$row.click(function() { +		phpbb.search.setValue($input, value.result, $input.attr('data-multiline')); +		$container.hide();  	});  }; @@ -569,39 +583,39 @@ phpbb.search.setValueOnClick = function(el, value, row, container) {   * @return bool Returns false.   */  phpbb.search.filter = function(data, event, sendRequest) { -	var el = $(this), -		dataName = (el.attr('data-name') !== undefined) ? el.attr('data-name') : el.attr('name'), -		minLength = parseInt(el.attr('data-min-length')), -		searchID = el.attr('data-results'), -		keyword = phpbb.search.getKeyword(el, data[dataName], el.attr('data-multiline')), +	var $this = $(this), +		dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'), +		minLength = parseInt($this.attr('data-min-length')), +		searchID = $this.attr('data-results'), +		keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')),  		cache = phpbb.search.cache.get(searchID),  		proceed = true;  	data[dataName] = keyword; -	if (cache['timeout']) { -		clearTimeout(cache['timeout']); +	if (cache.timeout) { +		clearTimeout(cache.timeout);  	}  	var timeout = setTimeout(function() {  		// Check min length and existence of cache.  		if (minLength > keyword.length) {  			proceed = false; -		} else if (cache['last_search']) { +		} else if (cache.lastSearch) {  			// Has the keyword actually changed? -			if (cache['last_search'] === keyword) { +			if (cache.lastSearch === keyword) {  				proceed = false;  			} else {  				// Do we already have results for this? -				if (cache['results'][keyword]) { -					var response = {keyword: keyword, results: cache['results'][keyword]}; -					phpbb.search.handleResponse(response, el, true); +				if (cache.results[keyword]) { +					var response = {keyword: keyword, results: cache.results[keyword]}; +					phpbb.search.handleResponse(response, $this, true);  					proceed = false;  				}  				// If the previous search didn't yield results and the string only had characters added to it,  				// then we won't bother sending a request. -				if (keyword.indexOf(cache['last_search']) === 0 && cache['results'][cache['last_search']].length === 0) { -					phpbb.search.cache.set(searchID, 'last_search', keyword); +				if (keyword.indexOf(cache.lastSearch) === 0 && cache.results[cache.lastSearch].length === 0) { +					phpbb.search.cache.set(searchID, 'lastSearch', keyword);  					phpbb.search.cache.setResults(searchID, keyword, []);  					proceed = false;  				}		 @@ -621,22 +635,22 @@ phpbb.search.filter = function(data, event, sendRequest) {   * Handle search result response.    *   * @param object res		Data received from server. - * @param jQuery el			Search input|textarea. + * @param jQuery $input		Search input|textarea.   * @param bool fromCache	Whether the results are from the cache.   * @param function callback	Optional callback to run when assigning each search result.   *   * @return undefined   */ -phpbb.search.handleResponse = function(res, el, fromCache, callback) { +phpbb.search.handleResponse = function(res, $input, fromCache, callback) {  	if (typeof res !== 'object') {  		return;  	} -	var searchID = el.attr('data-results'), -		container = $(searchID); +	var searchID = $input.attr('data-results'), +		$container = $(searchID); -	if (this.cache.get(searchID)['callback']) { -		callback = this.cache.get(searchID)['callback']; +	if (this.cache.get(searchID).callback) { +		callback = this.cache.get(searchID).callback;  	} else if (typeof callback === 'function') {  		this.cache.set(searchID, 'callback', callback);  	} @@ -645,35 +659,35 @@ phpbb.search.handleResponse = function(res, el, fromCache, callback) {  		this.cache.setResults(searchID, res.keyword, res.results);  	} -	this.cache.set(searchID, 'last_search', res.keyword); -	this.showResults(res.results, el, container, callback); +	this.cache.set(searchID, 'lastSearch', res.keyword); +	this.showResults(res.results, $input, $container, callback);  };  /**   * Show search results.   *   * @param array results		Search results. - * @param jQuery el			Search input|textarea. - * @param jQuery container	Search results container element. + * @param jQuery $input		Search input|textarea. + * @param jQuery $container	Search results container element.   * @param function callback	Optional callback to run when assigning each search result.   *   * @return undefined   */ -phpbb.search.showResults = function(results, el, container, callback) { -	var resultContainer = $('.search-results', container); -	this.clearResults(resultContainer); +phpbb.search.showResults = function(results, $input, $container, callback) { +	var $resultContainer = $('.search-results', $container); +	this.clearResults($resultContainer);  	if (!results.length) { -		container.hide(); +		$container.hide();  		return;  	} -	var searchID = container.attr('id'), +	var searchID = $container.attr('id'),  		tpl,  		row;  	if (!this.tpl[searchID]) { -		tpl = $('.search-result-tpl', container); +		tpl = $('.search-result-tpl', $container);  		this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl');  		tpl.remove();  	} @@ -684,27 +698,27 @@ phpbb.search.showResults = function(results, el, container, callback) {  		row.find('.search-result').html(item.display);  		if (typeof callback === 'function') { -			callback.call(this, el, item, row, container); +			callback.call(this, $input, item, row, $container);  		} -		row.appendTo(resultContainer).show(); +		row.appendTo($resultContainer).show();  	}); -	container.show(); +	$container.show();  };  /**   * Clear search results.   * - * @param jQuery container	Search results container. + * @param jQuery $container	Search results container.   * @return undefined   */ -phpbb.search.clearResults = function(container) { -	container.children(':not(.search-result-tpl)').remove(); +phpbb.search.clearResults = function($container) { +	$container.children(':not(.search-result-tpl)').remove();  }; -$('#phpbb').click(function(e) { -	var target = $(e.target); +$('#phpbb').click(function() { +	var $this = $(this); -	if (!target.is('.live-search') && !target.parents().is('.live-search')) { +	if (!$this.is('.live-search') && !$this.parents().is('.live-search')) {  		$('.live-search').hide();  	}  }); @@ -718,10 +732,7 @@ phpbb.history = {};  * @return bool Returns true if the method is supported.  */  phpbb.history.isSupported = function(fn) { -	if (typeof history === 'undefined' || typeof history[fn] === 'undefined') { -		return false; -	} -	return true; +	return !(typeof history === 'undefined' || typeof history[fn] === 'undefined');  };  /** @@ -783,36 +794,52 @@ phpbb.history.pushUrl = function(url, title, obj) {  * @param	bool	keepSelection		Shall we keep the value selected, or shall the user be forced to repick one.  */  phpbb.timezoneSwitchDate = function(keepSelection) { -	if ($('#timezone_copy').length === 0) { +	var $timezoneCopy = $('#timezone_copy'); +	var $timezone = $('#timezone'); +	var $tzDate = $('#tz_date'); +	var $tzSelectDateSuggest = $('#tz_select_date_suggest'); + +	if ($timezoneCopy.length === 0) {  		// We make a backup of the original dropdown, so we can remove optgroups  		// instead of setting display to none, because IE and chrome will not  		// hide options inside of optgroups and selects via css -		$('#timezone').clone().attr('id', 'timezone_copy').css('display', 'none').attr('name', 'tz_copy').insertAfter('#timezone'); +		$timezone.clone() +			.attr('id', 'timezone_copy') +			.css('display', 'none') +			.attr('name', 'tz_copy') +			.insertAfter('#timezone');  	} else {  		// Copy the content of our backup, so we can remove all unneeded options -		$('#timezone').replaceWith($('#timezone_copy').clone().attr('id', 'timezone').css('display', 'block').attr('name', 'tz')); +		var $replacement = $timezoneCopy.clone(); +		$replacement.attr('id', 'timezone') +			.css('display', 'block') +			.attr('name', 'tz'); + +		$timezone.replaceWith($replacement);  	} -	if ($('#tz_date').val() !== '') { -		$('#timezone > optgroup').remove(":not([label='" + $('#tz_date').val() + "'])"); +	if ($tzDate.val() !== '') { +		$timezone.children('optgroup').remove(':not([label="' + $('#tz_date').val() + '"])');  	} -	if ($('#tz_date').val() === $('#tz_select_date_suggest').attr('data-suggested-tz')) { -		$('#tz_select_date_suggest').css('display', 'none'); +	if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) { +		$tzSelectDateSuggest.css('display', 'none');  	} else { -		$('#tz_select_date_suggest').css('display', 'inline'); +		$tzSelectDateSuggest.css('display', 'inline');  	} +	 +	var $tzOptions = $timezone.children('optgroup[label="' + $tzDate.val() + '"]').children('option'); -	if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() === 1) { +	if ($tzOptions.length === 1) {  		// If there is only one timezone for the selected date, we just select that automatically. -		$("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").prop('selected', true); +		$tzOptions.prop('selected', true);  		keepSelection = true;  	}  	if (typeof keepSelection !== 'undefined' && !keepSelection) { -		var timezoneOptions = $('#timezone > optgroup option'); -		if (timezoneOptions.filter(':selected').length <= 0) { -			timezoneOptions.filter(':first').prop('selected', true); +		var $timezoneOptions = $timezone.find('optgroup option'); +		if ($timezoneOptions.filter(':selected').length <= 0) { +			$timezoneOptions.filter(':first').prop('selected', true);  		}  	}  }; @@ -832,7 +859,6 @@ phpbb.timezoneEnableDateSelection = function() {  phpbb.timezonePreselectSelect = function(forceSelector) {  	// The offset returned here is in minutes and negated. -	// http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp  	var offset = (new Date()).getTimezoneOffset();  	var sign = '-'; @@ -858,9 +884,11 @@ phpbb.timezonePreselectSelect = function(forceSelector) {  	var prefix = 'GMT' + sign + hours + ':' + minutes;  	var prefixLength = prefix.length; -	var selectorOptions = $('#tz_date > option'); +	var selectorOptions = $('option', '#tz_date');  	var i; +	var $tzSelectDateSuggest = $('#tz_select_date_suggest'); +  	for (i = 0; i < selectorOptions.length; ++i) {  		var option = selectorOptions[i]; @@ -869,16 +897,18 @@ phpbb.timezonePreselectSelect = function(forceSelector) {  				// We do not select the option for the user, but notify him,  				// that we would suggest a different setting.  				phpbb.timezoneSwitchDate(true); -				$('#tz_select_date_suggest').css('display', 'inline'); +				$tzSelectDateSuggest.css('display', 'inline');  			} else {  				option.selected = true;  				phpbb.timezoneSwitchDate(!forceSelector); -				$('#tz_select_date_suggest').css('display', 'none'); +				$tzSelectDateSuggest.css('display', 'none');  			} -			$('#tz_select_date_suggest').attr('title', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML)); -			$('#tz_select_date_suggest').attr('value', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML.substring(0, 9))); -			$('#tz_select_date_suggest').attr('data-suggested-tz', option.innerHTML); +			var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); + +			$tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); +			$tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); +			$tzSelectDateSuggest.attr('data-suggested-tz', option.innerHTML);  			// Found the suggestion, there cannot be more, so return from here.  			return; @@ -916,22 +946,22 @@ phpbb.addAjaxCallback('member_search', function(res) {   * current text so that the process can be repeated.   */  phpbb.addAjaxCallback('alt_text', function() { -	var el, +	var $anchor,  		updateAll = $(this).data('update-all'),  		altText;  	if (updateAll !== undefined && updateAll.length) { -		el = $(updateAll); +		$anchor = $(updateAll);  	} else { -		el = $(this); +		$anchor = $(this);  	} -	el.each(function() { -		var el = $(this); -		altText = el.attr('data-alt-text'); -		el.attr('data-alt-text', el.text()); -		el.attr('title', $.trim(altText)); -		el.text(altText); +	$anchor.each(function() { +		var $this = $(this); +		altText = $this.attr('data-alt-text'); +		$this.attr('data-alt-text', $this.text()); +		$this.attr('title', $.trim(altText)); +		$this.text(altText);  	});  }); @@ -945,36 +975,36 @@ phpbb.addAjaxCallback('alt_text', function() {   * and changes the link itself.   */  phpbb.addAjaxCallback('toggle_link', function() { -	var el, +	var $anchor,  		updateAll = $(this).data('update-all') ,  		toggleText,  		toggleUrl,  		toggleClass;  	if (updateAll !== undefined && updateAll.length) { -		el = $(updateAll); +		$anchor = $(updateAll);  	} else { -		el = $(this); +		$anchor = $(this);  	} -	el.each(function() { -		var el = $(this); +	$anchor.each(function() { +		var $this = $(this);  		// Toggle link text -		toggleText = el.attr('data-toggle-text'); -		el.attr('data-toggle-text', el.text()); -		el.attr('title', $.trim(toggleText)); -		el.text(toggleText); +		toggleText = $this.attr('data-toggle-text'); +		$this.attr('data-toggle-text', $this.text()); +		$this.attr('title', $.trim(toggleText)); +		$this.text(toggleText);  		// Toggle link url -		toggleUrl = el.attr('data-toggle-url'); -		el.attr('data-toggle-url', el.attr('href')); -		el.attr('href', toggleUrl); +		toggleUrl = $this.attr('data-toggle-url'); +		$this.attr('data-toggle-url', $this.attr('href')); +		$this.attr('href', toggleUrl);  		// Toggle class of link parent -		toggleClass = el.attr('data-toggle-class'); -		el.attr('data-toggle-class', el.parent().attr('class')); -		el.parent().attr('class', toggleClass); +		toggleClass = $this.attr('data-toggle-class'); +		$this.attr('data-toggle-class', $this.parent().attr('class')); +		$this.parent().attr('class', toggleClass);  	});  }); @@ -984,7 +1014,7 @@ phpbb.addAjaxCallback('toggle_link', function() {  * This function automatically resizes textarea elements when user  * types text.  * -* @param {jQuery} items jQuery object(s) to resize +* @param {jQuery} $items jQuery object(s) to resize  * @param {object} options Optional parameter that adjusts default  * 	configuration. See configuration variable  * @@ -1000,25 +1030,26 @@ phpbb.addAjaxCallback('toggle_link', function() {  *			this points to DOM object  *			item is a jQuery object, same as this  */ -phpbb.resizeTextArea = function(items, options) { +phpbb.resizeTextArea = function($items, options) {  	// Configuration  	var configuration = {  		minWindowHeight: 500,  		minHeight: 200,  		maxHeight: 500,  		heightDiff: 200, -		resizeCallback: function(item) { }, -		resetCallback: function(item) { } +		resizeCallback: function() {}, +		resetCallback: function() {}  	}; -	if (phpbb.isTouch) return; +	if (phpbb.isTouch) { +		return; +	}  	if (arguments.length > 1) {  		configuration = $.extend(configuration, options);  	} -	function resetAutoResize(item)  -	{ +	function resetAutoResize(item) {  		var $item = $(item);  		if ($item.hasClass('auto-resized')) {  			$(item).css({height: '', resize: ''}).removeClass('auto-resized'); @@ -1026,10 +1057,8 @@ phpbb.resizeTextArea = function(items, options) {  		}  	} -	function autoResize(item)  -	{ -		function setHeight(height) -		{ +	function autoResize(item) { +		function setHeight(height) {  			height += parseInt($item.css('height')) - $item.height();  			$item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized');  			configuration.resizeCallback.call(item, $item); @@ -1042,7 +1071,10 @@ phpbb.resizeTextArea = function(items, options) {  			return;  		} -		var maxHeight = Math.min(Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), configuration.maxHeight), +		var maxHeight = Math.min( +				Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), +				configuration.maxHeight +			),  			$item = $(item),  			height = parseInt($item.height()),  			scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; @@ -1059,14 +1091,14 @@ phpbb.resizeTextArea = function(items, options) {  		}  	} -	items.bind('focus change keyup', function() { +	$items.on('focus change keyup', function() {  		$(this).each(function() {  			autoResize(this);  		});  	}).change();  	$(window).resize(function() { -		items.each(function() { +		$items.each(function() {  			if ($(this).hasClass('auto-resized')) {  				autoResize(this);  			} @@ -1104,7 +1136,9 @@ phpbb.inBBCodeTag = function(textarea, startTags, endTags) {  			lastStart = Math.max(lastStart, index);  		}  	} -	if (lastStart == -1) return false; +	if (lastStart === -1) { +		return false; +	}  	if (start > 0) {  		for (i = 0; i < endTags.length; i++) { @@ -1114,7 +1148,7 @@ phpbb.inBBCodeTag = function(textarea, startTags, endTags) {  	}  	return (lastEnd < lastStart); -} +};  /** @@ -1158,7 +1192,7 @@ phpbb.applyCodeEditor = function(textarea) {  	function getLastLine(stripCodeStart) {  		var start = textarea.selectionStart,  			value = textarea.value, -			index = value.lastIndexOf("\n", start - 1); +			index = value.lastIndexOf('\n', start - 1);  		value = value.substring(index + 1, start); @@ -1201,28 +1235,27 @@ phpbb.applyCodeEditor = function(textarea) {  		var key = event.keyCode || event.which;  		// intercept tabs -		if (key == keymap.TAB	&& +		if (key === keymap.TAB	&&  			!event.ctrlKey		&&  			!event.shiftKey		&&  			!event.altKey		&&  			!event.metaKey) {  			if (inTag()) { -				appendText("\t"); +				appendText('\t');  				event.preventDefault();  				return;  			}  		}  		// intercept new line characters -		if (key == keymap.ENTER) { +		if (key === keymap.ENTER) {  			if (inTag()) {  				var lastLine = getLastLine(true),  					code = '' + /^\s*/g.exec(lastLine);  				if (code.length > 0) { -					appendText("\n" + code); +					appendText('\n' + code);  					event.preventDefault(); -					return;  				}  			}  		} @@ -1247,43 +1280,41 @@ phpbb.toggleDropdown = function() {  	var $this = $(this),  		options = $this.data('dropdown-options'),  		parent = options.parent, -		visible = parent.hasClass('dropdown-visible'); +		visible = parent.hasClass('dropdown-visible'), +		direction;  	if (!visible) {  		// Hide other dropdown menus  		$(phpbb.dropdownHandles).each(phpbb.toggleDropdown);  		// Figure out direction of dropdown -		var direction = options.direction, -			verticalDirection = options.verticalDirection, +		direction = options.direction; +		var verticalDirection = options.verticalDirection,  			offset = $this.offset(); -		if (direction == 'auto') { +		if (direction === 'auto') {  			if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) {  				direction = 'right'; -			} -			else { +			} else {  				direction = 'left';  			}  		} -		parent.toggleClass(options.leftClass, direction == 'left').toggleClass(options.rightClass, direction == 'right'); +		parent.toggleClass(options.leftClass, direction === 'left') +			.toggleClass(options.rightClass, direction === 'right'); -		if (verticalDirection == 'auto') { +		if (verticalDirection === 'auto') {  			var height = $(window).height(),  				top = offset.top - $(window).scrollTop(); -			if (top < height * 0.7) { -				verticalDirection = 'down'; -			} -			else { -				verticalDirection = 'up'; -			} +			verticalDirection = (top < height * 0.7) ? 'down' : 'up';  		} -		parent.toggleClass(options.upClass, verticalDirection == 'up').toggleClass(options.downClass, verticalDirection == 'down'); +		parent.toggleClass(options.upClass, verticalDirection === 'up') +			.toggleClass(options.downClass, verticalDirection === 'down');  	}  	options.dropdown.toggle(); -	parent.toggleClass(options.visibleClass, !visible).toggleClass('dropdown-visible', !visible); +	parent.toggleClass(options.visibleClass, !visible) +		.toggleClass('dropdown-visible', !visible);  	// Check dimensions when showing dropdown  	// !visible because variable shows state of dropdown before it was toggled @@ -1304,8 +1335,7 @@ phpbb.toggleDropdown = function() {  			if (offset < 2) {  				$this.css('left', (2 - offset) + 'px'); -			} -			else if ((offset + width + 2) > windowWidth) { +			} else if ((offset + width + 2) > windowWidth) {  				$this.css('margin-left', (windowWidth - offset - width - 2) + 'px');  			} @@ -1315,7 +1345,7 @@ phpbb.toggleDropdown = function() {  		});  		var freeSpace = parent.offset().left - 4; -		if (direction == 'left') { +		if (direction === 'left') {  			options.dropdown.css('margin-left', '-' + freeSpace + 'px');  			// Try to position the notification dropdown correctly in RTL-responsive mode @@ -1342,8 +1372,7 @@ phpbb.toggleDropdown = function() {  			var e = arguments[0];  			e.preventDefault();  			e.stopPropagation(); -		} -		catch (error) { } +		} catch (error) { }  	}  	return false;  }; @@ -1354,7 +1383,7 @@ phpbb.toggleDropdown = function() {  phpbb.toggleSubmenu = function(e) {  	$(this).siblings('.dropdown-submenu').toggle();  	e.preventDefault(); -} +};  /**  * Register dropdown menu @@ -1364,8 +1393,7 @@ phpbb.toggleSubmenu = function(e) {  * @param {jQuery} dropdown Dropdown menu.  * @param {Object} options List of options. Optional.  */ -phpbb.registerDropdown = function(toggle, dropdown, options) -{ +phpbb.registerDropdown = function(toggle, dropdown, options) {  	var ops = {  			parent: toggle.parent(), // Parent item to add classes to  			direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right @@ -1411,8 +1439,8 @@ phpbb.colorPalette = function(dir, width, height) {  	numberList[3] = 'BF';  	numberList[4] = 'FF'; -	var table_class = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette'; -	html += '<table class="not-responsive colour-palette ' + table_class + '" style="width: auto;">'; +	var tableClass = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette'; +	html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">';  	for (r = 0; r < 5; r++) {  		if (dir == 'h') { @@ -1442,7 +1470,7 @@ phpbb.colorPalette = function(dir, width, height) {  	}  	html += '</table>';  	return html; -} +};  /**  * Register a color palette. @@ -1492,12 +1520,14 @@ phpbb.toggleDisplay = function(id, action, type) {  		type = 'block';  	} -	var display = $('#' + id).css('display'); +	var $element = $('#' + id); + +	var display = $element.css('display');  	if (!action) {  		action = (display === '' || display === type) ? -1 : 1;  	} -	$('#' + id).css('display', ((action === 1) ? type : 'none')); -} +	$element.css('display', ((action === 1) ? type : 'none')); +};  /**  * Toggle additional settings based on the selected @@ -1508,9 +1538,9 @@ phpbb.toggleDisplay = function(id, action, type) {  */  phpbb.toggleSelectSettings = function(el) {  	el.children().each(function() { -		var option = $(this), -			setting = $(option.data('toggle-setting')); -		setting.toggle(option.is(':selected')); +		var $this = $(this), +			$setting = $($this.data('toggle-setting')); +		$setting.toggle($this.is(':selected'));  	});  }; @@ -1536,49 +1566,61 @@ phpbb.getFunctionByName = function (functionName) {  * Register page dropdowns.  */  phpbb.registerPageDropdowns = function() { -	$('body').find('.dropdown-container').each(function() { +	var $body = $('body'); + +	$body.find('.dropdown-container').each(function() {  		var $this = $(this), -			trigger = $this.find('.dropdown-trigger:first'), -			contents = $this.find('.dropdown'), +			$trigger = $this.find('.dropdown-trigger:first'), +			$contents = $this.find('.dropdown'),  			options = {  				direction: 'auto',  				verticalDirection: 'auto'  			},  			data; -		if (!trigger.length) { +		if (!$trigger.length) {  			data = $this.attr('data-dropdown-trigger'); -			trigger = data ? $this.children(data) : $this.children('a:first'); +			$trigger = data ? $this.children(data) : $this.children('a:first');  		} -		if (!contents.length) { +		if (!$contents.length) {  			data = $this.attr('data-dropdown-contents'); -			contents = data ? $this.children(data) : $this.children('div:first'); +			$contents = data ? $this.children(data) : $this.children('div:first');  		} -		if (!trigger.length || !contents.length) return; +		if (!$trigger.length || !$contents.length) { +			return; +		} -		if ($this.hasClass('dropdown-up')) options.verticalDirection = 'up'; -		if ($this.hasClass('dropdown-down')) options.verticalDirection = 'down'; -		if ($this.hasClass('dropdown-left')) options.direction = 'left'; -		if ($this.hasClass('dropdown-right')) options.direction = 'right'; +		if ($this.hasClass('dropdown-up')) { +			options.verticalDirection = 'up'; +		} +		if ($this.hasClass('dropdown-down')) { +			options.verticalDirection = 'down'; +		} +		if ($this.hasClass('dropdown-left')) { +			options.direction = 'left'; +		} +		if ($this.hasClass('dropdown-right')) { +			options.direction = 'right'; +		} -		phpbb.registerDropdown(trigger, contents, options); +		phpbb.registerDropdown($trigger, $contents, options);  	});  	// Hide active dropdowns when click event happens outside -	$('body').click(function(e) { -		var parents = $(e.target).parents(); -		if (!parents.is(phpbb.dropdownVisibleContainers)) { +	$body.click(function(e) { +		var $parents = $(e.target).parents(); +		if (!$parents.is(phpbb.dropdownVisibleContainers)) {  			$(phpbb.dropdownHandles).each(phpbb.toggleDropdown);  		}  	}); -} +};  /**  * Apply code editor to all textarea elements with data-bbcode attribute  */ -$(document).ready(function() { +$(function() {  	$('textarea[data-bbcode]').each(function() {  		phpbb.applyCodeEditor(this);  	}); @@ -1595,12 +1637,12 @@ $(document).ready(function() {  	// Hide settings that are not selected via select element.  	$('select[data-togglable-settings]').each(function() { -		var select = $(this); +		var $this = $(this); -		select.change(function() { -			phpbb.toggleSelectSettings(select); +		$this.change(function() { +			phpbb.toggleSelectSettings($this);  		}); -		phpbb.toggleSelectSettings(select); +		phpbb.toggleSelectSettings($this);  	});  }); diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 247b9d1651..804d48ea97 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -36,7 +36,7 @@ class mcp_reports  	function main($id, $mode)  	{  		global $auth, $db, $user, $template, $cache; -		global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; +		global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher;  		include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 98802d2209..4ad3214ae4 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -245,12 +245,8 @@ class manager  			$cp_data = $this->build_insert_sql_array($cp_data);  			$cp_data['user_id'] = (int) $user_id; -			$this->db->sql_return_on_error(true); -  			$sql = 'INSERT INTO ' . $this->fields_data_table . ' ' . $this->db->sql_build_array('INSERT', $cp_data);  			$this->db->sql_query($sql); - -			$this->db->sql_return_on_error(false);  		}  	} @@ -328,7 +324,7 @@ class manager  		* Event to modify profile fields data retrieved from the database  		*  		* @event core.grab_profile_fields_data -		* @var	array	user_ids		Single user id or an array of ids  +		* @var	array	user_ids		Single user id or an array of ids  		* @var	array	field_data		Array with profile fields data  		* @since 3.1.0-b3  		*/ @@ -377,7 +373,7 @@ class manager  		* Event to modify data of the generated profile fields, before the template assignment loop  		*  		* @event core.generate_profile_fields_template_data_before -		* @var	array	profile_row		Array with users profile field data  +		* @var	array	profile_row		Array with users profile field data  		* @var	array	tpl_fields		Array with template data fields  		* @var	bool	use_contact_fields	Should we display contact fields as such?  		* @since 3.1.0-b3 @@ -445,7 +441,7 @@ class manager  		* Event to modify template data of the generated profile fields  		*  		* @event core.generate_profile_fields_template_data -		* @var	array	profile_row		Array with users profile field data  +		* @var	array	profile_row		Array with users profile field data  		* @var	array	tpl_fields		Array with template data fields  		* @var	bool	use_contact_fields	Should we display contact fields as such?  		* @since 3.1.0-b3 diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 63efe5f8ae..13e8d02469 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -1,6 +1,8 @@ +/* global phpbb */ +  (function($) {  // Avoid conflicts with other libraries -"use strict"; +'use strict';  // This callback will mark all forum icons read  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  * -* @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.  */ -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 unreadTitle = res.UNREAD_POSTS;  	var iconsArray = { @@ -53,12 +55,12 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) {  		'topic_unread': 'topic_read'  	};  	var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; -	var unreadClassSelectors = ''; +	var unreadClassSelectors;  	var classMap = {};  	var classNames = []; -	if (typeof update_topic_links === 'undefined') { -		update_topic_links = true; +	if (typeof updateTopicLinks === 'undefined') { +		updateTopicLinks = true;  	}  	$.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();  	// Update mark topics read links -	if (update_topic_links) { +	if (updateTopicLinks) {  		$('[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.   * - * @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.   */ -phpbb.markNotifications = function(el, unreadCount) { +phpbb.markNotifications = function($popup, unreadCount) {  	// Remove the unread status. -	el.removeClass('bg2'); -	el.find('a.mark_read').remove(); +	$popup.removeClass('bg2'); +	$popup.find('a.mark_read').remove();  	// Update the notification link to the real URL. -	el.each(function() { +	$popup.each(function() {  		var link = $(this).find('a');  		link.attr('href', link.attr('data-real-url'));  	});  	// 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.  	if (!unreadCount) {  		$('#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.  phpbb.addAjaxCallback('post_delete', function() { -	var el = $(this), +	var $this = $(this),  		postId; -	if (el.attr('data-refresh') === undefined) { -		postId = el[0].href.split('&p=')[1]; -		var post = el.parents('#p' + postId).css('pointer-events', 'none'); +	if ($this.attr('data-refresh') === undefined) { +		postId = $this[0].href.split('&p=')[1]; +		var post = $this.parents('#p' + postId).css('pointer-events', 'none');  		if (post.hasClass('bg1') || post.hasClass('bg2')) {  			var posts1 = post.nextAll('.bg1');  			post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); @@ -167,8 +169,7 @@ phpbb.addAjaxCallback('post_visibility', function(res) {  		$(this).remove();  	}); -	if (res.visible) -	{ +	if (res.visible) {  		// Remove the "Deleted by" message from the post on restoring.  		remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() {  			$(this).remove(); @@ -199,18 +200,18 @@ phpbb.addAjaxCallback('vote_poll', function(res) {  	if (typeof res.success !== 'undefined') {  		var poll = $('.topic_poll');  		var panel = poll.find('.panel'); -		var results_visible = poll.find('dl:first-child .resultbar').is(':visible'); -		var most_votes = 0; +		var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); +		var mostVotes = 0;  		// 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;  			panel.css('min-height', height);  		}; -		update_panel_height(); +		updatePanelHeight();  		// Remove the View results link -		if (!results_visible) { +		if (!resultsVisible) {  			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  		poll.find('[data-poll-option-id]').each(function() {  			var option = $(this); -			var option_id = option.attr('data-poll-option-id'); -			most_votes = (res.vote_counts[option_id] >= most_votes) ? res.vote_counts[option_id] : most_votes; +			var optionId = option.attr('data-poll-option-id'); +			mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;  		});  		// Update the total votes count @@ -235,28 +236,30 @@ phpbb.addAjaxCallback('vote_poll', function(res) {  		// Update each option  		poll.find('[data-poll-option-id]').each(function() { -			var option = $(this); -			var option_id = option.attr('data-poll-option-id'); -			var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; -			var most_voted = (res.vote_counts[option_id] == most_votes) ? true : false; -			var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); -			var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); +			var $this = $(this); +			var optionId = $this.attr('data-poll-option-id'); +			var voted = (typeof res.user_votes[optionId] !== 'undefined'); +			var mostVoted = (res.vote_counts[optionId] === mostVotes); +			var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100); +			var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); -			option.toggleClass('voted', voted); -			option.toggleClass('most-votes', most_voted); +			$this.toggleClass('voted', voted); +			$this.toggleClass('most-votes', mostVoted);  			// Update the bars -			var bar = option.find('.resultbar div'); -			var bar_time_lapse = (res.can_vote) ? 500 : 1500; -			var new_bar_class = (percent == 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); +			var bar = $this.find('.resultbar div'); +			var barTimeLapse = (res.can_vote) ? 500 : 1500; +			var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);  			setTimeout(function () { -				bar.animate({width: percent_rel + '%'}, 500).removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5').addClass(new_bar_class); -				bar.html(res.vote_counts[option_id]); - -				var percent_txt = (!percent) ? res.NO_VOTES : percent + '%'; -				option.find('.poll_option_percent').html(percent_txt); -			}, bar_time_lapse); +				bar.animate({width: percentRel + '%'}, 500) +					.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5') +					.addClass(newBarClass) +					.html(res.vote_counts[optionId]); + +				var percentText = percent ? percent + '%' : res.NO_VOTES; +				$this.find('.poll_option_percent').html(percentText); +			}, barTimeLapse);  		});  		if (!res.can_vote) { @@ -264,30 +267,31 @@ phpbb.addAjaxCallback('vote_poll', function(res) {  		}  		// Display "Your vote has been cast." message. Disappears after 5 seconds. -		var confirmation_delay = (res.can_vote) ? 300 : 900; -		poll.find('.vote-submitted').delay(confirmation_delay).slideDown(200, function() { -			if (results_visible) { -				update_panel_height(); +		var confirmationDelay = (res.can_vote) ? 300 : 900; +		poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() { +			if (resultsVisible) { +				updatePanelHeight();  			}  			$(this).delay(5000).fadeOut(500, function() { -				resize_panel(300); +				resizePanel(300);  			});  		});  		// Remove the gap resulting from removing options  		setTimeout(function() { -			resize_panel(500); +			resizePanel(500);  		}, 1500); -		var resize_panel = function (time) { -			var panel_height = panel.height(); -			var inner_height = panel.find('.inner').outerHeight(); +		var resizePanel = function (time) { +			var panelHeight = panel.height(); +			var innerHeight = panel.find('.inner').outerHeight(); -			if (panel_height != inner_height) { -				panel.css({'min-height': '', 'height': panel_height}).animate({height: inner_height}, time, function () { -					panel.css({'min-height': inner_height, 'height': ''}); -				}); +			if (panelHeight != innerHeight) { +				panel.css({'min-height': '', 'height': panelHeight}) +					.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  	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('.poll_view_results').hide(500); +	$poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); +	$poll.find('.poll_view_results').hide(500);  });  $('[data-ajax]').each(function() { -	var $this = $(this), -		ajax = $this.attr('data-ajax'), -		filter = $this.attr('data-filter'), -		fn; +	var $this = $(this); +	var ajax = $this.attr('data-ajax'); +	var filter = $this.attr('data-filter');  	if (ajax !== 'false') { -		fn = (ajax !== 'true') ? ajax : null; +		var fn = (ajax !== 'true') ? ajax : null;  		filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;  		phpbb.ajaxify({ @@ -344,10 +347,10 @@ $('.display_post').click(function(e) {  	// Do not follow the link  	e.preventDefault(); -	var post_id = $(this).attr('data-post-id'); -	$('#post_content' + post_id).show(); -	$('#profile' + post_id).show(); -	$('#post_hidden' + post_id).hide(); +	var postId = $(this).attr('data-post-id'); +	$('#post_content' + postId).show(); +	$('#profile' + postId).show(); +	$('#post_hidden' + postId).hide();  });  $('#delete_permanent').click(function () { @@ -366,10 +369,13 @@ $('#delete_permanent').click(function () {  * appropriately changed based on the status of the search panel.  */  $('#member_search').click(function () { -	$('#memberlist_search').slideToggle('fast'); +	var $memberlistSearch = $('#memberlist_search'); + +	$memberlistSearch.slideToggle('fast');  	phpbb.ajaxCallbacks.alt_text.call(this); +  	// Focus on the username textbox if it's available and displayed -	if ($('#memberlist_search').is(':visible')) { +	if ($memberlistSearch.is(':visible')) {  		$('#username').focus();  	}  	return false; @@ -378,7 +384,7 @@ $('#member_search').click(function () {  /**  * Automatically resize textarea  */ -$(document).ready(function() { +$(function() {  	phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250});  	phpbb.resizeTextArea($('#message-box textarea'));  }); diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 4929e14ef7..1280ceb8ac 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -1,3 +1,5 @@ +/* global phpbb */ +  /**  * phpBB3 forum functions  */ @@ -6,6 +8,8 @@  * Find a member  */  function find_username(url) { +	'use strict'; +  	popup(url, 760, 570, '_usersearch');  	return false;  } @@ -14,6 +18,8 @@ function find_username(url) {  * Window popup  */  function popup(url, width, height, name) { +	'use strict'; +  	if (!name) {  		name = '_popup';  	} @@ -26,17 +32,18 @@ function popup(url, width, height, name) {  * Jump to page  */  function pageJump(item) { +	'use strict';  	var page = item.val(), -		per_page = item.attr('data-per-page'), -		base_url = item.attr('data-base-url'), -		start_name = item.attr('data-start-name'); +		perPage = item.attr('data-per-page'), +		baseUrl = item.attr('data-base-url'), +		startName = item.attr('data-start-name');  	if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { -		if (base_url.indexOf('?') === -1) { -			document.location.href = base_url + '?' + start_name + '=' + ((page - 1) * per_page); +		if (baseUrl.indexOf('?') === -1) { +			document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage);  		} 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]  */  function marklist(id, name, state) { +	'use strict'; +  	jQuery('#' + id + ' input[type=checkbox][name]').each(function() {  		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);  		}  	}); @@ -59,6 +68,8 @@ function marklist(id, name, state) {  * e = element  */  function viewableArea(e, itself) { +	'use strict'; +  	if (!e) {  		return;  	} @@ -86,18 +97,20 @@ function viewableArea(e, itself) {  /**  * Alternate display of subPanels  */ -jQuery(document).ready(function() { -	jQuery('.sub-panels').each(function() { +jQuery(function($) { +	'use strict'; -		var panels = [], -			childNodes = jQuery('a[data-subpanel]', this).each(function() { -				panels.push(this.getAttribute('data-subpanel')); +	$('.sub-panels').each(function() { + +		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) { -			activateSubPanel(show_panel, panels); -			childNodes.click(function () { +			activateSubPanel(showPanel, panels); +			$childNodes.click(function () {  				activateSubPanel(this.getAttribute('data-subpanel'), panels);  				return false;  			}); @@ -109,60 +122,30 @@ jQuery(document).ready(function() {  * Activate specific subPanel  */  function activateSubPanel(p, panels) { -	var i; +	'use strict'; + +	var i, showPanel;  	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') { -		panels = []; -		jQuery('.sub-panels a[data-subpanel]').each(function() { -			panels.push(this.getAttribute('data-subpanel')); +	if (typeof panels === 'undefined') { +		panels = jQuery('.sub-panels a[data-subpanel]').map(function() { +			return this.getAttribute('data-subpanel');  		});  	}  	for (i = 0; i < panels.length; i++) { -		jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none'); -		jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === show_panel); -	} -} - -/** -* 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'; -		} +		jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none'); +		jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel);  	}  }  function selectCode(a) { +	'use strict'; +  	// Get ID of code block  	var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];  	var s, r; @@ -209,6 +192,8 @@ function selectCode(a) {  * from the displayed rectangle area  */  function play_qt_file(obj) { +	'use strict'; +  	var rectangle = obj.GetRectangle();  	var width, height; @@ -233,30 +218,32 @@ function play_qt_file(obj) {  	obj.Play();  } -var in_autocomplete = false; -var last_key_entered = ''; +var inAutocomplete = false; +var lastKeyEntered = '';  /**  * Check event key  */ -function phpbb_check_key(event) { +function phpbbCheckKey(event) { +	'use strict'; +  	// Keycode is array down or up?  	if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { -		in_autocomplete = true; +		inAutocomplete = true;  	}  	// 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 (!last_key_entered || last_key_entered === event.which) { -			in_autocompletion = false; +		if (!lastKeyEntered || lastKeyEntered === event.which) { +			inAutocomplete = false;  			return true;  		}  	}  	// Keycode is not return, then return. ;)  	if (event.which !== 13) { -		last_key_entered = event.which; +		lastKeyEntered = event.which;  		return true;  	} @@ -266,115 +253,106 @@ function phpbb_check_key(event) {  /**  * Apply onkeypress event for forcing default submit button on ENTER key press  */ -function apply_onkeypress_event() { -	jQuery('form input[type=text], form input[type=password]').on('keypress', function (e) { -		var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action'); +jQuery(function($) { +	'use strict'; + +	$('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 (!default_button || default_button.length <= 0) { +		if (!defaultButton || defaultButton.length <= 0) {  			return true;  		} -		if (phpbb_check_key(e)) { +		if (phpbbCheckKey(e)) {  			return true;  		}  		if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { -			default_button.click(); +			defaultButton.click();  			return false;  		}  		return true;  	}); -} - -jQuery(document).ready(apply_onkeypress_event); +});  /**  * Functions for user search popup  */ -function insert_user(formId, value) +function insertUser(formId, value)  { -	var form = jQuery(formId), -		formName = form.attr('data-form-name'), -		fieldName = form.attr('data-field-name'), +	'use strict'; + +	var $form = jQuery(formId), +		formName = $form.attr('data-form-name'), +		fieldName = $form.attr('data-field-name'),  		item = opener.document.forms[formName][fieldName];  	if (item.value.length && item.type == 'textarea') { -		value = item.value + "\n" + value; +		value = item.value + '\n' + value;  	}  	item.value = value;  } -function insert_marked_users(formId, users) -{ -	if (typeof(users.length) == "undefined") -	{ -		if (users.checked) -		{ -			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); -			} +function insert_marked_users(formId, users) { +	'use strict'; + +	for (var i = 0; i < users.length; i++) { +		if (users[i].checked) { +			insertUser(formId, users[i].value);  		}  	} -	self.close(); +	window.close();  } -function insert_single_user(formId, user) -{ -	insert_user(formId, user); -	self.close(); +function insert_single_user(formId, user) { +	'use strict'; + +	insertUser(formId, user); +	window.close();  }  /**  * Parse document block  */ -function parse_document(container)  -{ +function parseDocument($container) { +	'use strict'; +  	var test = document.createElement('div'),  		oldBrowser = (typeof test.style.borderRadius == 'undefined'); -	delete test; -  	/**  	* 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('');  	});  	/**  	* Pagination  	*/ -	container.find('.pagination .page-jump-form :button').click(function() { -		$input = $(this).siblings('input.inputbox'); +	$container.find('.pagination .page-jump-form :button').click(function() { +		var $input = $(this).siblings('input.inputbox');  		pageJump($input);  	}); -	container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { -		if (event.which == 13 || event.keyCode == 13) { +	$container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { +		if (event.which === 13 || event.keyCode === 13) {  			event.preventDefault();  			pageJump($(this));  		}  	}); -	container.find('.pagination .dropdown-trigger').click(function() { -		$dropdown_container = $(this).parent(); +	$container.find('.pagination .dropdown-trigger').click(function() { +		var $dropdownContainer = $(this).parent();  		// Wait a little bit to make sure the dropdown has activated  		setTimeout(function() {  -			if ($dropdown_container.hasClass('dropdown-visible')) { -				$dropdown_container.find('input.inputbox').focus(); +			if ($dropdownContainer.hasClass('dropdown-visible')) { +				$dropdownContainer.find('input.inputbox').focus();  			} -		},100); +		}, 100);  	});  	/** @@ -382,27 +360,29 @@ function parse_document(container)  	*/  	if (oldBrowser) {  		// 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  	*/ -	container.find('.navlinks').each(function() { +	$container.find('.navlinks').each(function() {  		var $this = $(this), -			left = $this.children().not('.rightside'), -			right = $this.children('.rightside'); +			$left = $this.children().not('.rightside'), +			$right = $this.children('.rightside'); -		if (left.length !== 1 || !right.length) return; +		if ($left.length !== 1 || !$right.length) { +			return; +		}  		function resize() {  			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);  			}); -			left.css('max-width', Math.floor($this.width() - width - diff) + 'px'); +			$left.css('max-width', Math.floor($this.width() - width - diff) + 'px');  		}  		resize(); @@ -412,11 +392,11 @@ function parse_document(container)  	/**  	* Makes breadcrumbs responsive  	*/ -	container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { +	$container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {  		var $this = $(this),  			$body = $('body'), -			links = $this.find('.crumb'), -			length = links.length, +			$links = $this.find('.crumb'), +			length = $links.length,  			classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'],  			classesLength = classes.length,  			maxHeight = 0, @@ -429,14 +409,13 @@ function parse_document(container)  			$link.attr('title', $link.text());  		}); -		// Funciton that checks breadcrumbs +		// Function that checks breadcrumbs  		function check() {  			var height = $this.height(), -				width = $body.width(), -				link, i, j; +				width = $body.width(); -			maxHeight = parseInt($this.css('line-height')) | 0; -			links.each(function() { +			maxHeight = parseInt($this.css('line-height')); +			$links.each(function() {  				if ($(this).height() > 0) {  					maxHeight = Math.max(maxHeight, $(this).outerHeight(true));  				} @@ -444,7 +423,6 @@ function parse_document(container)  			if (height <= maxHeight) {  				if (!wrapped || lastWidth === false || lastWidth >= width) { -					lastWidth = width;  					return;  				}  			} @@ -452,7 +430,6 @@ function parse_document(container)  			if (wrapped) {  				$this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); -				wrapped = false;  				if ($this.height() <= maxHeight) {  					return;  				} @@ -464,9 +441,9 @@ function parse_document(container)  				return;  			} -			for (i = 0; i < classesLength; i ++) { -				for (j = length - 1; j >= 0; j --) { -					links.eq(j).addClass('wrapped ' + classes[i]); +			for (var i = 0; i < classesLength; i ++) { +				for (var j = length - 1; j >= 0; j --) { +					$links.eq(j).addClass('wrapped ' + classes[i]);  					if ($this.height() <= maxHeight) {  						return;  					} @@ -482,32 +459,29 @@ function parse_document(container)  	/**  	* 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),  			$body = $('body'),  			filterSkip = '.breadcrumbs, [data-skip-responsive]',  			filterLast = '.edit-icon, .quote-icon, [data-last-responsive]',  			persist = $this.attr('id') == 'nav-main', -			allLinks = $this.children(), -			links = allLinks.not(filterSkip), +			$allLinks = $this.children(), +			$links = $allLinks.not(filterSkip),  			html = '<li class="responsive-menu" style="display:none;"><a href="javascript:void(0);" class="responsive-menu-link"> </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.   		if (!persist) { -			if (links.is('.rightside')) -			{ -				links.filter('.rightside:first').before(html); +			if ($links.is('.rightside')) { +				$links.filter('.rightside:first').before(html);  				$this.children('.responsive-menu').addClass('rightside'); -			} -			else -			{ +			} else {  				$this.append(html);  			}  		} -		var item = $this.children('.responsive-menu'), -			menu = item.find('.dropdown-contents'), +		var $item = $this.children('.responsive-menu'), +			$menu = $item.find('.dropdown-contents'),  			lastWidth = false,  			compact = false,  			responsive = false, @@ -521,29 +495,31 @@ function parse_document(container)  			// Unhide the quick-links menu if it has content  			if (persist) { -				item.addClass('hidden'); -				if (menu.find('li:not(.separator, .clone)').length || (responsive && menu.find('li.clone').length)) { -					item.removeClass('hidden'); +				$item.addClass('hidden'); +				if ($menu.find('li:not(.separator, .clone)').length || (responsive && $menu.find('li.clone').length)) { +					$item.removeClass('hidden');  				}  			}  			// Reset responsive and compact layout  			if (responsive) { -				responsive = false;  				$this.removeClass('responsive'); -				links.css('display', ''); -				if (!persist) item.css('display', 'none'); +				$links.css('display', ''); +				if (!persist) { +					$item.css('display', 'none'); +				}  			}  			if (compact) { -				compact = false;  				$this.removeClass('compact');  			}  			// Find tallest element  			var maxHeight = 0; -			allLinks.each(function() { -				if (!$(this).height()) return; +			$allLinks.each(function() { +				if (!$(this).height()) { +					return; +				}  				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 -			compact = true;  			$this.addClass('compact');  			var compactMaxHeight = 0; -			allLinks.each(function() { -				if (!$(this).height()) return; +			$allLinks.each(function() { +				if (!$(this).height()) { +					return; +				}  				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 = false;  			$this.removeClass('compact');  			responsive = true;  			if (!copied) { -				var clone = links.clone(true); +				var clone = $links.clone(true);  				clone.filter('.rightside').each(function() { -					if (persist) $(this).addClass('clone'); -					menu.prepend(this); +					if (persist) { +						$(this).addClass('clone'); +					} +					$menu.prepend(this);  				});  				if (persist) { -					menu.prepend(clone.not('.rightside').addClass('clone')); +					$menu.prepend(clone.not('.rightside').addClass('clone'));  				} else { -					menu.prepend(clone.not('.rightside')); +					$menu.prepend(clone.not('.rightside'));  				} -				menu.find('li.leftside, li.rightside').removeClass('leftside rightside'); -				menu.find('.inputbox').parents('li:first').css('white-space', 'normal'); +				$menu.find('li.leftside, li.rightside').removeClass('leftside rightside'); +				$menu.find('.inputbox').parents('li:first').css('white-space', 'normal');  				if ($this.hasClass('post-buttons')) { -					$('.button', menu).removeClass('button icon-button'); -					$('.responsive-menu-link', item).addClass('button icon-button').prepend('<span></span>'); +					$('.button', $menu).removeClass('button icon-button'); +					$('.responsive-menu-link', $item).addClass('button icon-button').prepend('<span></span>');  				}  				copied = true; -			} -			else { -				menu.children().css('display', ''); +			} else { +				$menu.children().css('display', '');  			} -			item.css('display', ''); +			$item.css('display', '');  			$this.addClass('responsive');  			// Try to not hide filtered items -			if (filterLastList.length) { -				links.not(filterLast).css('display', 'none'); +			if ($filterLastList.length) { +				$links.not(filterLast).css('display', 'none');  				maxHeight = 0; -				filterLastList.each(function() { +				$filterLastList.each(function() {  					if (!$(this).height()) return;  					maxHeight = Math.max(maxHeight, $(this).outerHeight(true));  				});  				if ($this.height() <= (maxHeight + slack)) { -					menu.children().filter(filterLast).css('display', 'none'); +					$menu.children().filter(filterLast).css('display', 'none');  					return;  				}  			} @@ -624,10 +601,12 @@ function parse_document(container)  			compact = true;  			$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();  		$(window).resize(check); @@ -643,7 +622,7 @@ function parse_document(container)  	/**  	* 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 @@ -652,31 +631,30 @@ function parse_document(container)  	* To add that functionality to .topiclist list simply add  	* 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), -			block = $this.find('dt .responsive-show:last-child'), +			$block = $this.find('dt .responsive-show:last-child'),  			first = true;  		// 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;" />'); -			block = $this.find('dt .responsive-show:last-child'); -		} -		else { -			first = ($.trim(block.text()).length == 0); +			$block = $this.find('dt .responsive-show:last-child'); +		} else { +			first = ($.trim($block.text()).length === 0);  		}  		// Copy contents of each column  		$this.find('dd').not('.mark').each(function() {  			var column = $(this), -				children = column.children(), +				$children = column.children(),  				html = column.html(); -			if (children.length == 1 && children.text() == column.text()) { -				html = children.html(); +			if ($children.length == 1 && $children.text() == column.text()) { +				html = $children.html();  			} -			block.append((first ? '' : '<br />') + html); +			$block.append((first ? '' : '<br />') + html);  			first = false;  		}); @@ -689,15 +667,15 @@ function parse_document(container)  	* To add that functionality to .topiclist list simply add  	* responsive-show-columns to list of classes  	*/ -	container.find('.topiclist.responsive-show-columns').each(function() { -		var list = $(this), +	$container.find('.topiclist.responsive-show-columns').each(function() { +		var $list = $(this),  			headers = [],  			headersLength = 0;  		// 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()); -			headersLength ++; +			headersLength++;  		});  		if (!headersLength) { @@ -705,18 +683,18 @@ function parse_document(container)  		}  		// Parse each row -		list.find('dl').each(function() { +		$list.find('dl').each(function() {  			var $this = $(this), -				block = $this.find('dt .responsive-show:last-child'), +				$block = $this.find('dt .responsive-show:last-child'),  				first = true;  			// 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;" />'); -				block = $this.find('dt .responsive-show:last-child'); +				$block = $this.find('dt .responsive-show:last-child');  			}  			else { -				first = ($.trim(block.text()).length == 0); +				first = ($.trim($block.text()).length === 0);  			}  			// Copy contents of each column @@ -734,7 +712,7 @@ function parse_document(container)  					html = headers[i] + ': <strong>' + html + '</strong>';  				} -				block.append((first ? '' : '<br />') + html); +				$block.append((first ? '' : '<br />') + html);  				first = false;  			}); @@ -744,16 +722,15 @@ function parse_document(container)  	/**  	* Responsive tables  	*/ -	container.find('table.table1').not('.not-responsive').each(function() { +	$container.find('table.table1').not('.not-responsive').each(function() {  		var $this = $(this), -			th = $this.find('thead > tr > th'), -			columns = th.length, +			$th = $this.find('thead > tr > th'),  			headers = [],  			totalHeaders = 0,  			i, headersLength;  		// Find each header -		th.each(function(column) { +		$th.each(function(column) {  			var cell = $(this),  				colspan = parseInt(cell.attr('colspan')),  				dfn = cell.attr('data-dfn'), @@ -761,10 +738,10 @@ function parse_document(container)  			colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; -			for (i=0; i<colspan; i++) { +			for (i = 0; i < colspan; i++) {  				headers.push(text);  			} -			totalHeaders ++; +			totalHeaders++;  			if (dfn && !column) {  				$this.addClass('show-header'); @@ -802,8 +779,7 @@ function parse_document(container)  				if ((text.length && text !== '-') || cell.children().length) {  					cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>'); -				} -				else { +				} else {  					cell.addClass('empty');  				} @@ -816,10 +792,9 @@ function parse_document(container)  	/**  	* Hide empty responsive tables  	*/ -	container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { -		var items = $(this).children('tr'); -		if (items.length == 0) -		{ +	$container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { +		var $items = $(this).children('tr'); +		if (!$items.length) {  			$(this).parent('table:first').addClass('responsive-hide');  		}  	}); @@ -827,65 +802,64 @@ function parse_document(container)  	/**  	* 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),  			$body = $('body'), -			ul = $this.children(), -			tabs = ul.children().not('[data-skip-responsive]'), -			links = tabs.children('a'), -			item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </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'), +			$ul = $this.children(), +			$tabs = $ul.children().not('[data-skip-responsive]'), +			$links = $tabs.children('a'), +			$item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </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'),  			maxHeight = 0,  			lastWidth = false,  			responsive = false; -		links.each(function() { -			var link = $(this); -			maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); -		}) +		$links.each(function() { +			var $this = $(this); +			maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true))); +		});  		function check() {  			var width = $body.width(),  				height = $this.height(); -			if (arguments.length == 0 && (!responsive || width <= lastWidth) && height <= maxHeight) { +			if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {  				return;  			} -			tabs.show(); -			item.hide(); +			$tabs.show(); +			$item.hide();  			lastWidth = width;  			height = $this.height();  			if (height <= maxHeight) { -				responsive = false; -				if (item.hasClass('dropdown-visible')) { -					phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0)); +				if ($item.hasClass('dropdown-visible')) { +					phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0));  				}  				return;  			}  			responsive = true; -			item.show(); -			menu.html(''); +			$item.show(); +			$menu.html(''); -			var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'), -				total = availableTabs.length, -				i, tab; +			var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'), +				total = $availableTabs.length, +				i, $tab;  			for (i = total - 1; i >= 0; i --) { -				tab = availableTabs.eq(i); -				menu.prepend(tab.clone(true).removeClass('tab')); -				tab.hide(); +				$tab = $availableTabs.eq(i); +				$menu.prepend($tab.clone(true).removeClass('tab')); +				$tab.hide();  				if ($this.height() <= maxHeight) { -					menu.find('a').click(function() { check(true); }); +					$menu.find('a').click(function() { check(true); });  					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);  		$(window).resize(check); @@ -894,10 +868,9 @@ function parse_document(container)  	/**  	 * Hide UCP/MCP navigation if there is only 1 item  	 */ -	container.find('#navigation').each(function() { -		var items = $(this).children('ol, ul').children('li'); -		if (items.length == 1) -		{ +	$container.find('#navigation').each(function() { +		var $items = $(this).children('ol, ul').children('li'); +		if ($items.length === 1) {  			$(this).addClass('responsive-hide');  		}  	}); @@ -905,7 +878,7 @@ function parse_document(container)  	/**  	* Replace responsive text  	*/ -	container.find('[data-responsive-text]').each(function() { +	$container.find('[data-responsive-text]').each(function() {  		var $this = $(this),  			fullText = $this.text(),  			responsiveText = $this.attr('data-responsive-text'), @@ -913,12 +886,16 @@ function parse_document(container)  		function check() {  			if ($(window).width() > 700) { -				if (!responsive) return; +				if (!responsive) { +					return; +				}  				$this.text(fullText);  				responsive = false;  				return;  			} -			if (responsive) return; +			if (responsive) { +				return; +			}  			$this.text(responsiveText);  			responsive = true;  		} @@ -931,18 +908,18 @@ function parse_document(container)  /**  * Run onload functions  */ -(function($) { -	$(document).ready(function() { -		// Swap .nojs and .hasjs -		$('#phpbb.nojs').toggleClass('nojs hasjs'); -		$('#phpbb').toggleClass('hastouch', phpbb.isTouch); -		$('#phpbb.hastouch').removeClass('notouch'); - -		// Focus forms -		$('form[data-focus]:first').each(function() { -			$('#' + this.getAttribute('data-focus')).focus(); -		}); +jQuery(function($) { +	'use strict'; + +	// Swap .nojs and .hasjs +	$('#phpbb.nojs').toggleClass('nojs hasjs'); +	$('#phpbb').toggleClass('hastouch', phpbb.isTouch); +	$('#phpbb.hastouch').removeClass('notouch'); -		parse_document($('body')); +	// Focus forms +	$('form[data-focus]:first').each(function() { +		$('#' + this.getAttribute('data-focus')).focus();  	}); -})(jQuery); + +	parseDocument($('body')); +}); diff --git a/phpBB/styles/prosilver/template/pagination.html b/phpBB/styles/prosilver/template/pagination.html index cb2c09bff7..4680eaa175 100644 --- a/phpBB/styles/prosilver/template/pagination.html +++ b/phpBB/styles/prosilver/template/pagination.html @@ -7,7 +7,7 @@  			<ul class="dropdown-contents">  				<li>{L_JUMP_TO_PAGE}{L_COLON}</li>  				<li class="page-jump-form"> -					<input type="number" name="page-number"  maxlength="6" title="{L_JUMP_PAGE}" class="inputbox tiny" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}" data-start-name="{START_NAME}" /> +					<input type="number" name="page-number" min="1" maxlength="6" title="{L_JUMP_PAGE}" class="inputbox tiny" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}" data-start-name="{START_NAME}" />  					<input class="button2" value="{L_GO}" type="button" />  				</li>  			</ul> diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js index e0d3da9ff7..44ec1b0979 100644 --- a/phpBB/styles/prosilver/template/timezone.js +++ b/phpBB/styles/prosilver/template/timezone.js @@ -1,6 +1,8 @@ +/* global phpbb */ +  (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict';  $('#tz_date').change(function() {  	phpbb.timezoneSwitchDate(false); @@ -10,12 +12,9 @@ $('#tz_select_date_suggest').click(function(){  	phpbb.timezonePreselectSelect(true);  }); -$(document).ready( -	phpbb.timezoneEnableDateSelection -); - -$(document).ready( -	phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true') -); +$(function () { +	phpbb.timezoneEnableDateSelection(); +	phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true'); +});  })(jQuery); // Avoid conflicts with other libraries | 
