aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/assets/javascript/core.js
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/assets/javascript/core.js')
-rw-r--r--phpBB/assets/javascript/core.js45
1 files changed, 27 insertions, 18 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index b079043396..5218a8c1be 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -20,6 +20,13 @@ var phpbbAlertTimer = null;
phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');
+// Add ajax pre-filter to prevent cross-domain script execution
+$.ajaxPrefilter(function(s) {
+ if (s.crossDomain) {
+ s.contents.script = false;
+ }
+});
+
/**
* Display a loading screen
*
@@ -27,7 +34,10 @@ phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');
*/
phpbb.loadingIndicator = function() {
if (!$loadingIndicator) {
- $loadingIndicator = $('<div />', { id: 'loading_indicator' });
+ $loadingIndicator = $('<div />', {
+ 'id': 'loading_indicator',
+ 'class': 'loading_indicator'
+ });
$loadingIndicator.appendTo('#page-footer');
}
@@ -176,7 +186,7 @@ phpbb.alert.close = function($alert, fadedark) {
phpbb.confirm = function(msg, callback, fadedark) {
var $confirmDiv = $('#phpbb_confirm');
$confirmDiv.find('.alert_text').html(msg);
- fadedark = fadedark || true;
+ fadedark = typeof fadedark !== 'undefined' ? fadedark : true;
$(document).on('keydown.phpbb.alert', function(e) {
if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) {
@@ -191,9 +201,7 @@ phpbb.confirm = function(msg, callback, fadedark) {
$confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) {
var confirmed = this.name === 'confirm';
- if (confirmed) {
- callback(true);
- }
+ callback(confirmed);
$confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox');
phpbb.alert.close($confirmDiv, fadedark || !confirmed);
@@ -934,9 +942,9 @@ phpbb.addAjaxCallback('alt_text', function() {
$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);
+ $this.attr('data-alt-text', $.trim($this.text()));
+ $this.attr('title', altText);
+ $this.children('span').text(altText);
});
});
@@ -965,12 +973,6 @@ phpbb.addAjaxCallback('toggle_link', function() {
$anchor.each(function() {
var $this = $(this);
- // Toggle link text
- 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 = $this.attr('data-toggle-url');
$this.attr('data-toggle-url', $this.attr('href'));
@@ -978,8 +980,14 @@ phpbb.addAjaxCallback('toggle_link', function() {
// Toggle class of link parent
toggleClass = $this.attr('data-toggle-class');
- $this.attr('data-toggle-class', $this.parent().attr('class'));
- $this.parent().attr('class', toggleClass);
+ $this.attr('data-toggle-class', $this.children().attr('class'));
+ $this.children('.icon').attr('class', toggleClass);
+
+ // Toggle link text
+ toggleText = $this.attr('data-toggle-text');
+ $this.attr('data-toggle-text', $this.children('span').text());
+ $this.attr('title', $.trim(toggleText));
+ $this.children('span').text(toggleText);
});
});
@@ -1330,6 +1338,7 @@ phpbb.toggleDropdown = function() {
$this.css({
marginLeft: 0,
left: 0,
+ marginRight: 0,
maxWidth: (windowWidth - 4) + 'px'
});
@@ -1641,7 +1650,7 @@ phpbb.lazyLoadAvatars = function loadAvatars() {
});
};
-$(window).load(phpbb.lazyLoadAvatars);
+$(window).on('load', phpbb.lazyLoadAvatars);
/**
* Apply code editor to all textarea elements with data-bbcode attribute
@@ -1653,7 +1662,7 @@ $(function() {
phpbb.registerPageDropdowns();
- $('#color_palette_placeholder').each(function() {
+ $('[data-orientation]').each(function() {
phpbb.registerPalette($(this));
});