003ddef05c84ee60fd54c566626d53bb98e4e6e4
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_crpages / Resources / Public / JavaScript / WizardCreatePages.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * JavaScript functions for creating multiple pages
16 */
17 define('TYPO3/CMS/WizardCrpages/WizardCreatePages', ['jquery'], function($) {
18
19 var WizardCreatePages = {
20 lineCounter: 9,
21 containerSelector: '#formFieldContainerBody',
22 addMoreFieldsButtonSelector: '#createNewFormFields'
23 };
24
25 WizardCreatePages.createNewFormFields = function() {
26 for (i = 0; i < 5; i++) {
27 var label = this.lineCounter + i + 1;
28 var line = String.format(tpl, (this.lineCounter + i), label);
29 $(line).appendTo(this.containerSelector);
30 }
31 this.lineCounter += 5;
32 };
33
34 WizardCreatePages.actOnTypeSelectChange = function($selectElement) {
35 var $optionElement = $selectElement.find(':selected');
36 $selectElement.css('background-image', $optionElement.css('background-image'));
37 };
38
39 /**
40 * Register listeners
41 */
42 WizardCreatePages.initializeEvents = function() {
43 $(this.addMoreFieldsButtonSelector).on('click', function() {
44 WizardCreatePages.createNewFormFields();
45 });
46
47 $(document).on('change', '.icon-select', function() {
48 WizardCreatePages.actOnTypeSelectChange($(this));
49 });
50 };
51
52 return function() {
53 $(document).ready(function() {
54 WizardCreatePages.initializeEvents();
55 });
56
57 TYPO3.WizardCreatePages = WizardCreatePages;
58 return WizardCreatePages;
59 }();
60 });