Commit 8c4ac961 authored by Markus Klein's avatar Markus Klein Committed by Andreas Fernandez
Browse files

[BUGFIX] Add missing DOMready checks and streamline code

Also remove useless closures and public exposure of modules, which are not
used via the TYPO3 global.
Moreover use single quotes for 'use strict' consistently.

Resolves: #70601
Releases: master
Change-Id: If7183f91a5b9fab320cea8eb1759e78b47141984
Reviewed-on: http://review.typo3.org/43999

Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
parent 63785b9e
......@@ -242,13 +242,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Notification'],
$iconElement.removeClass('fa-spin fa-circle-o-notch');
};
/**
* initialize and return the object
*/
return function() {
AjaxDataHandler.initialize();
$(AjaxDataHandler.initialize);
// return the object in the global space
return AjaxDataHandler;
}();
return AjaxDataHandler;
});
......@@ -15,6 +15,8 @@
* The debug console shown at the bottom of the backend
*/
define(['jquery'], function ($) {
'use strict';
var DebugConsole = {
$consoleDom: null,
settings: {
......@@ -255,11 +257,11 @@ define(['jquery'], function ($) {
DebugConsole.$consoleDom = null;
};
return function () {
$(document).ready(function() {
DebugConsole.initialize();
});
TYPO3.DebugConsole = DebugConsole;
return DebugConsole;
}();
$(DebugConsole.initialize);
// expose as global object
TYPO3.DebugConsole = DebugConsole;
return DebugConsole;
});
......@@ -15,7 +15,7 @@
* Calculates the height of the docHeader and hides it upon scrolling
*/
define(['jquery'], function($) {
"use strict";
'use strict';
var DocumentHeader = {
$documentHeader: null,
......
......@@ -212,7 +212,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($) {
};
// Initialization Code
$(document).ready(function() {
$(function() {
// run the flexform functions on all containers (which contains one or more sections)
$('.t3-flex-container').t3FormEngineFlexFormElement();
});
......
......@@ -1022,7 +1022,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
};
FormEngineValidation.registerReady = function() {
$(document).ready(function() {
$(function() {
FormEngineValidation.initialize();
// Start first validation after one second, because all fields are initial empty (typo3form.fieldSet)
window.setTimeout(function() {
......@@ -1031,11 +1031,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
});
};
/**
* Initialize function
*/
FormEngine.Validation = FormEngineValidation;
return FormEngine.Validation;
});
......@@ -314,8 +314,5 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($, Modal) {
});
};
return function() {
TYPO3.ImageManipulation = ImageManipulation;
return ImageManipulation;
}();
return ImageManipulation;
});
......@@ -16,6 +16,7 @@
* based on jQuery UI
*/
define(['jquery', 'jquery-ui/sortable'], function ($) {
'use strict';
var DragDrop = {
contentIdentifier: '.t3js-page-ce',
......@@ -113,11 +114,12 @@ define(['jquery', 'jquery-ui/sortable'], function ($) {
*/
DragDrop.onSortUpdate = function($container, ui) {
var $selectedItem = $(ui.item),
contentElementUid = parseInt($selectedItem.data('uid'));
contentElementUid = parseInt($selectedItem.data('uid')),
parameters = {};
// send an AJAX requst via the AjaxDataHandler
if (contentElementUid > 0) {
var parameters = {};
// add the information about a possible column position change
parameters['data'] = {tt_content: {}};
parameters['data']['tt_content'][contentElementUid] = {colPos: parseInt($container.data('colpos'))};
......@@ -145,11 +147,7 @@ define(['jquery', 'jquery-ui/sortable'], function ($) {
});
};
/**
* initialize function
*/
return function() {
DragDrop.initialize();
return DragDrop;
}();
});
\ No newline at end of file
$(DragDrop.initialize);
return DragDrop;
});
......@@ -15,6 +15,8 @@
* JavaScript replacement for Legacy CSS Classes
*/
define(['jquery'], function($) {
'use strict';
var LegacyCssClasses = {
replacements: [
{
......@@ -25,12 +27,12 @@ define(['jquery'], function($) {
]
};
LegacyCssClasses.initialize = function() {
$(function() {
$.each(LegacyCssClasses.replacements, function(key, replacement) {
$items = $(replacement.selector);
var $items = $(replacement.selector);
if ($items.length > 0) {
$items.each(function() {
$item = $(this);
var $item = $(this);
if (replacement.remove.length > 0) {
$.each(replacement.remove, function(oldClassId, oldClassName) {
$item.removeClass(oldClassName);
......@@ -44,14 +46,7 @@ define(['jquery'], function($) {
});
}
});
};
/**
* initialize function
*/
return function() {
LegacyCssClasses.initialize();
return LegacyCssClasses;
}();
});
return LegacyCssClasses;
});
......@@ -195,7 +195,5 @@ define(['jquery'], function($) {
}
};
return function() {
return Tree;
}();
return Tree;
});
......@@ -15,13 +15,14 @@
* Global search to deal with everything in the backend that is search-related
*/
define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'], function ($) {
'use strict';
var containerSelector = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem';
var searchFieldSelector = '.t3js-topbar-navigation-search-field';
var url = TYPO3.settings.ajaxUrls['livesearch'];
var category = '';
var initialize = function() {
$(function() {
$(searchFieldSelector).autocomplete({
// ajax options
serviceUrl: url,
......@@ -93,16 +94,11 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'],
jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid'));
});
$(searchFieldSelector).clearable(
{
$(searchFieldSelector).clearable({
onClear: function() {
$(containerSelector).removeClass('open');
}
}
);
};
$(document).ready(function() {
initialize();
});
});
});
......@@ -15,6 +15,8 @@
* JavaScript module for the backend login form
*/
define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable', 'bootstrap'], function($) {
'use strict';
var BackendLogin = {
options: {
loginForm: '#typo3-login-form',
......@@ -44,8 +46,6 @@ define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable', 'bootstrap'], function($
* @param event
*/
BackendLogin.handleSubmit = function(event) {
"use strict";
BackendLogin.showLoginProcess();
if (BackendLogin.options.submitHandler) {
......@@ -68,11 +68,11 @@ define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable', 'bootstrap'], function($
BackendLogin.checkForInterfaceCookie = function() {
if ($(options.interfaceField).length) {
var posStart = document.cookie.indexOf('typo3-login-interface=');
if (posStart != -1) {
if (posStart !== -1) {
var selectedInterface = document.cookie.substr(posStart + 22);
selectedInterface = selectedInterface.substr(0, selectedInterface.indexOf(';'));
$(options.interfaceField).val(selectedInterface);
}
$(options.interfaceField).val(selectedInterface);
}
};
......@@ -140,15 +140,15 @@ define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable', 'bootstrap'], function($
};
// initialize and return the BackendLogin object
$(document).ready(function() {
$(function() {
BackendLogin.checkCookieSupport();
BackendLogin.checkForInterfaceCookie();
BackendLogin.initializeEvents();
});
// prevent opening the login form in the backend frameset
if (top.location.href != self.location.href) {
top.location.href = self.location.href;
if (top.location.href !== location.href) {
top.location.href = location.href;
}
return BackendLogin;
......
......@@ -426,20 +426,20 @@ define(['jquery', 'bootstrap'], function($) {
};
// initialize and return the LoginRefresh object
return function() {
$(document).ready(function() {
LoginRefresh.initializeTimeoutModal();
LoginRefresh.initializeBackendLockedModal();
LoginRefresh.initializeLoginForm();
$(function() {
LoginRefresh.initializeTimeoutModal();
LoginRefresh.initializeBackendLockedModal();
LoginRefresh.initializeLoginForm();
LoginRefresh.startTask();
LoginRefresh.startTask();
if (typeof Notification !== 'undefined' && Notification.permission !== 'granted') {
Notification.requestPermission();
}
});
if (typeof Notification !== 'undefined' && Notification.permission !== 'granted') {
Notification.requestPermission();
}
});
// expose to global
TYPO3.LoginRefresh = LoginRefresh;
TYPO3.LoginRefresh = LoginRefresh;
return LoginRefresh;
}();
return LoginRefresh;
});
......@@ -16,7 +16,7 @@
* This module depends on TYPO3/CMS/Backend/Notification due to top.TYPO3.Severity.
*/
define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
"use strict";
'use strict';
// fetch from parent
if (parent && parent.window.TYPO3 && parent.window.TYPO3.Modal) {
......
......@@ -16,6 +16,7 @@
*/
define(['jquery'], function ($) {
'use strict';
/**
* Severity object
......@@ -156,7 +157,7 @@ define(['jquery'], function ($) {
if (Notification.messageContainer === null) {
Notification.messageContainer = $('<div id="alert-container"></div>').appendTo('body');
}
$box = $(
var $box = $(
'<div class="alert alert-' + className + ' alert-dismissible fade" role="alert">' +
'<button type="button" class="close" data-dismiss="alert">' +
'<span aria-hidden="true"><i class="fa fa-times-circle"></i></span>' +
......@@ -204,22 +205,18 @@ define(['jquery'], function ($) {
}
};
/**
* return the Notification object
*/
return function () {
if (typeof TYPO3.Severity === 'undefined') {
TYPO3.Severity = Severity;
}
if (typeof top.TYPO3.Severity === 'undefined') {
top.TYPO3.Severity = Severity;
}
if (typeof TYPO3.Notification === 'undefined') {
TYPO3.Notification = Notification;
}
if (typeof top.TYPO3.Notification === 'undefined') {
top.TYPO3.Notification = Notification;
}
return Notification;
}();
if (typeof TYPO3.Severity === 'undefined') {
TYPO3.Severity = Severity;
}
if (typeof top.TYPO3.Severity === 'undefined') {
top.TYPO3.Severity = Severity;
}
if (typeof TYPO3.Notification === 'undefined') {
TYPO3.Notification = Notification;
}
if (typeof top.TYPO3.Notification === 'undefined') {
top.TYPO3.Notification = Notification;
}
return Notification;
});
......@@ -15,7 +15,7 @@
* Javascript for show the online media dialog
*/
define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Lang/Lang'], function($, NProgress, Modal) {
"use strict";
'use strict';
var OnlineMediaPlugin = function(element) {
var me = this;
......
......@@ -41,7 +41,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Storage'], function($, Storage) {
*/
PageActions.initializePageTitleRenaming = function() {
if (!PageActions.documentIsReady) {
$(document).ready(function() {
$(function() {
PageActions.initializePageTitleRenaming();
});
return;
......
......@@ -15,7 +15,7 @@
* Initializes global handling of split buttons.
*/
define(['jquery'], function($) {
"use strict";
'use strict';
var SplitButtons = {
preSubmitCallbacks: []
......
......@@ -15,7 +15,7 @@
* Toggle the search toolbox
*/
define(['jquery', 'TYPO3/CMS/Backend/DocumentHeader', 'TYPO3/CMS/Backend/jquery.clearable'], function($, DocumentHeader) {
"use strict";
'use strict';
$(function() {
var $toolbar = $('#db_list-searchbox-toolbar');
......
......@@ -16,6 +16,7 @@
* reloading the clear cache icon
*/
define(['jquery', 'TYPO3/CMS/Backend/Icons'], function($, Icons) {
'use strict';
var ClearCacheMenu = {
options: {
......@@ -66,15 +67,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons'], function($, Icons) {
});
};
/**
* initialize and return the ClearCacheMenu object
*/
return function() {
$(document).ready(function() {
ClearCacheMenu.initializeEvents();
});
$(ClearCacheMenu.initializeEvents);
TYPO3.ClearCacheMenu = ClearCacheMenu;
return ClearCacheMenu;
}();
return ClearCacheMenu;
});
......@@ -16,6 +16,7 @@
* and edit a shortcut
*/
define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], function($, Modal, Icons) {
'use strict';
var ShortcutMenu = {
options: {
......@@ -171,15 +172,10 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], functio
});
};
/**
* initialize and return the ShortcutMenu object
*/
return function() {
$(document).ready(function() {
ShortcutMenu.initializeEvents();
});
$(ShortcutMenu.initializeEvents);
// expose as global object
TYPO3.ShortcutMenu = ShortcutMenu;
TYPO3.ShortcutMenu = ShortcutMenu;
return ShortcutMenu;
}();
return ShortcutMenu;
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment