d3484790073de16ab670fcc0e173cce4b7563cad
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / res / tx_scheduler_be.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2009-2010 Francois Suter <francois@typo3.org>
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 *
16 * This script is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * This copyright notice MUST APPEAR in all copies of the script!
22 ***************************************************************/
23 /**
24 * This javascript file is used in the Scheduler's backend module
25 * It relies on ExtJS core being loaded
26 *
27 * @author Francois Suter <francois@typo3.org>
28 */
29
30 /**
31 * Global variable to keep track of checked/unchecked status of all
32 * checkboxes for execution selection
33 *
34 * @var boolean
35 */
36 var allCheckedStatus = false;
37
38 /**
39 * This method reacts on changes to the task class
40 * It switches on or off the relevant extra fields
41 *
42 * @param theSelector: select form item where the selection was made
43 * @return void
44 */
45 function actOnChangedTaskClass(theSelector) {
46 var taskClass = theSelector.options[theSelector.selectedIndex].value;
47 // Hide all extra fields
48 // Show only relevant extra fields
49 Ext.select('.extraFields').setDisplayed(false);
50 Ext.select('.extra_fields_' + taskClass).setDisplayed(true);
51 }
52
53 /**
54 * This method reacts on changes to the type of a task, i.e. single or recurring,
55 * by showing or hiding the relevant form fields
56 *
57 * @param theSelector: select form item where the selection was made
58 * @return void
59 */
60 function actOnChangedTaskType(theSelector) {
61 // Get task type from selected value, or set default value
62 var taskType;
63 if (theSelector.selectedIndex) {
64 taskType = theSelector.options[theSelector.selectedIndex].value;
65 } else {
66 taskType = 1;
67 }
68 // Single task
69 // Hide all fields related to recurring tasks
70 if (taskType == 1) {
71 Ext.fly('task_end_row').setDisplayed(false);
72 Ext.fly('task_frequency_row').setDisplayed(false);
73 Ext.fly('task_multiple_row').setDisplayed(false);
74
75 // Recurring task
76 // Show all fields related to recurring tasks
77 } else {
78 Ext.fly('task_end_row').setDisplayed(true);
79 Ext.fly('task_frequency_row').setDisplayed(true);
80 Ext.fly('task_multiple_row').setDisplayed(true);
81 }
82 }
83
84 /**
85 * This method reacts on the checking of a toggle,
86 * activating or not the check of all other checkboxes
87 *
88 * @return void
89 */
90 function toggleCheckboxes() {
91 // Toggle status of global variable
92 allCheckedStatus = !allCheckedStatus;
93 // Get all checkboxes with proper class
94 var checkboxes = Ext.select('.checkboxes');
95 var count = checkboxes.getCount();
96 // Set them all to same status as main checkbox
97 for (var i = 0; i < count; i++) {
98 checkboxes.item(i).dom.checked = allCheckedStatus;
99 }
100 }
101
102 /**
103 * Ext.onReader functions
104 *
105 * onClick event for scheduler task execution from backend module
106 */
107 Ext.onReady(function(){
108 Ext.addBehaviors({
109 // Add a listener for click on scheduler execute button
110 '#scheduler_executeselected@click' : function(e, t){
111 // Get all active checkboxes with proper class
112 var checkboxes = Ext.select('.checkboxes:checked');
113 var count = checkboxes.getCount();
114 var idParts;
115
116 // Set the status icon all to same status: running
117 for (var i = 0; i < count; i++) {
118 idParts = checkboxes.item(i).id.split('_');
119 Ext.select('#executionstatus_' + idParts[1]).item(0).set({src: TYPO3.settings.scheduler.runningIcon});
120 }
121 }
122 });
123 });