This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
core-uncompressed.js
483 lines (453 loc) · 12.2 KB
/
core-uncompressed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/**
* @version $Id: core-uncompressed.js 21463 2011-06-06 15:28:10Z dextercowley $
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Only define the Joomla namespace if not defined.
if (typeof(Joomla) === 'undefined') {
var Joomla = {};
}
Joomla.editors = {};
// An object to hold each editor instance on page
Joomla.editors.instances = {};
/**
* Generic submit form
*/
Joomla.submitform = function(task, form) {
if (typeof(form) === 'undefined') {
form = document.getElementById('adminForm');
/**
* Added to ensure Joomla 1.5 compatibility
*/
if(!form){
form = document.adminForm;
}
}
if (typeof(task) !== 'undefined') {
form.task.value = task;
}
// Submit the form.
if (typeof form.onsubmit == 'function') {
form.onsubmit();
}
if (typeof form.fireEvent == "function") {
form.fireEvent('submit');
}
form.submit();
};
/**
* Default function. Usually would be overriden by the component
*/
Joomla.submitbutton = function(pressbutton) {
Joomla.submitform(pressbutton);
}
/**
* Custom behavior for JavaScript I18N in Joomla! 1.6
*
* Allows you to call Joomla.JText._() to get a translated JavaScript string pushed in with JText::script() in Joomla.
*/
Joomla.JText = {
strings: {},
'_': function(key, def) {
return typeof this.strings[key.toUpperCase()] !== 'undefined' ? this.strings[key.toUpperCase()] : def;
},
load: function(object) {
for (var key in object) {
this.strings[key.toUpperCase()] = object[key];
}
return this;
}
};
/**
* Method to replace all request tokens on the page with a new one.
*/
Joomla.replaceTokens = function(n) {
var els = document.getElementsByTagName('input');
for (var i = 0; i < els.length; i++) {
if ((els[i].type == 'hidden') && (els[i].name.length == 32) && els[i].value == '1') {
els[i].name = n;
}
}
};
/**
* USED IN: administrator/components/com_banners/views/client/tmpl/default.php
*
* Verifies if the string is in a valid email format
*
* @param string
* @return boolean
*/
Joomla.isEmail = function(text) {
var regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");
return regex.test(text);
};
/**
* USED IN: all list forms.
*
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
*
* @param mixed The number of box to 'check', for a checkbox element
* @param string An alternative field name
*/
Joomla.checkAll = function(checkbox, stub) {
if (!stub) {
stub = 'cb';
}
if (checkbox.form) {
var c = 0;
for (var i = 0, n = checkbox.form.elements.length; i < n; i++) {
var e = checkbox.form.elements[i];
if (e.type == checkbox.type) {
if ((stub && e.id.indexOf(stub) == 0) || !stub) {
e.checked = checkbox.checked;
c += (e.checked == true ? 1 : 0);
}
}
}
if (checkbox.form.boxchecked) {
checkbox.form.boxchecked.value = c;
}
return true;
}
return false;
}
/**
* Render messages send via JSON
*
* @param object
* @return void
*/
Joomla.renderMessages = function(messages) {
var container = document.id('system-message-container');
var children = $$('#system-message-container > *');
children.destroy();
var dl = new Element('dl', {
id: 'system-message'
});
Object.each(messages, function (item, type) {
var dt = new Element('dt', {
'class': type,
html: type
});
dt.inject(dl);
var dd = new Element('dd', {
'class': type
});
dd.addClass('message');
var list = new Element('ul');
Array.each(item, function (item, index, object) {
var li = new Element('li', {
html: item
});
li.inject(list);
}, this);
list.inject(dd);
dd.inject(dl);
}, this);
dl.inject(container);
};
/**
* USED IN: administrator/components/com_modules/views/module/tmpl/default.php
*
* Writes a dynamically generated list
*
* @param string
* The parameters to insert into the <select> tag
* @param array
* A javascript array of list options in the form [key,value,text]
* @param string
* The key to display for the initial state of the list
* @param string
* The original key that was selected
* @param string
* The original item value that was selected
*/
function writeDynaList(selectParams, source, key, orig_key, orig_val) {
var html = '\n <select ' + selectParams + '>';
var i = 0;
for (x in source) {
if (source[x][0] == key) {
var selected = '';
if ((orig_key == key && orig_val == source[x][1])
|| (i == 0 && orig_key != key)) {
selected = 'selected="selected"';
}
html += '\n <option value="' + source[x][1] + '" ' + selected
+ '>' + source[x][2] + '</option>';
}
i++;
}
html += '\n </select>';
document.writeln(html);
}
/**
* USED IN: administrator/components/com_content/views/article/view.html.php
*
* Changes a dynamically generated list
*
* @param string
* The name of the list to change
* @param array
* A javascript array of list options in the form [key,value,text]
* @param string
* The key to display
* @param string
* The original key that was selected
* @param string
* The original item value that was selected
*/
function changeDynaList(listname, source, key, orig_key, orig_val) {
var list = document.adminForm[listname];
// empty the list
for (i in list.options.length) {
list.options[i] = null;
}
i = 0;
for (x in source) {
if (source[x][0] == key) {
opt = new Option();
opt.value = source[x][1];
opt.text = source[x][2];
if ((orig_key == key && orig_val == opt.value) || i == 0) {
opt.selected = true;
}
list.options[i++] = opt;
}
}
list.length = i;
}
/**
* USED IN: administrator/components/com_menus/views/menus/tmpl/default.php
*
* @param radioObj
* @return
*/
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function radioGetCheckedValue(radioObj) {
if (!radioObj) {
return '';
}
var n = radioObj.length;
if (n == undefined) {
if (radioObj.checked) {
return radioObj.value;
} else {
return '';
}
}
for ( var i = 0; i < n; i++) {
if (radioObj[i].checked) {
return radioObj[i].value;
}
}
return '';
}
/**
* USED IN: administrator/components/com_banners/views/banner/tmpl/default/php
* administrator/components/com_categories/views/category/tmpl/default.php
* administrator/components/com_categories/views/copyselect/tmpl/default.php
* administrator/components/com_content/views/copyselect/tmpl/default.php
* administrator/components/com_massmail/views/massmail/tmpl/default.php
* administrator/components/com_menus/views/list/tmpl/copy.php
* administrator/components/com_menus/views/list/tmpl/move.php
* administrator/components/com_messages/views/message/tmpl/default_form.php
* administrator/components/com_newsfeeds/views/newsfeed/tmpl/default.php
* components/com_content/views/article/tmpl/form.php
* templates/beez/html/com_content/article/form.php
*
* @param frmName
* @param srcListName
* @return
*/
function getSelectedValue(frmName, srcListName) {
var form = document[frmName];
var srcList = form[srcListName];
i = srcList.selectedIndex;
if (i != null && i > -1) {
return srcList.options[i].value;
} else {
return null;
}
}
/**
* USED IN: all list forms.
*
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
*
* @param mixed The number of box to 'check', for a checkbox element
* @param string An alternative field name
*
* @deprecated 11.1 This function will be removed in a future version. Use Joomla.checkAll() instead.
*/
function checkAll(checkbox, stub) {
if (!stub) {
stub = 'cb';
}
if (checkbox.form) {
var c = 0;
for (var i = 0, n = checkbox.form.elements.length; i < n; i++) {
var e = checkbox.form.elements[i];
if (e.type == checkbox.type) {
if ((stub && e.id.indexOf(stub) == 0) || !stub) {
e.checked = checkbox.checked;
c += (e.checked == true ? 1 : 0);
}
}
}
if (checkbox.form.boxchecked) {
checkbox.form.boxchecked.value = c;
}
return true;
} else {
// The old way of doing it
var f = document.adminForm;
var c = f.toggle.checked;
var n = checkbox;
var n2 = 0;
for (var i = 0; i < n; i++) {
var cb = f[stub+''+i];
if (cb) {
cb.checked = c;
n2++;
}
}
if (c) {
document.adminForm.boxchecked.value = n2;
} else {
document.adminForm.boxchecked.value = 0;
}
}
}
/**
* USED IN: all over :)
*
* @param id
* @param task
* @return
*/
function listItemTask(id, task) {
var f = document.adminForm;
var cb = f[id];
if (cb) {
for (var i = 0; true; i++) {
var cbx = f['cb'+i];
if (!cbx)
break;
cbx.checked = false;
} // for
cb.checked = true;
f.boxchecked.value = 1;
submitbutton(task);
}
return false;
}
/**
* USED IN: administrator/components/com_cache/views/cache/tmpl/default.php
* administrator/components/com_installer/views/components/tmpl/default_item.php
* administrator/components/com_installer/views/discover/tmpl/default_item.php
* administrator/components/com_installer/views/languages/tmpl/default_item.php
* administrator/components/com_installer/views/libraries/tmpl/default_item.php
* administrator/components/com_installer/views/modules/tmpl/default_item.php
* administrator/components/com_installer/views/packages/tmpl/default_item.php
* administrator/components/com_installer/views/plugins/tmpl/default_item.php
* administrator/components/com_installer/views/templates/tmpl/default_item.php
* administrator/components/com_installer/views/update/tmpl/default_item.php
* administrator/components/com_languages/views/languages/tmpl/default.php
* administrator/components/com_localise/views/translations/tmpl/files.php
* administrator/components/com_menus/views/list/tmpl/default.php
* administrator/components/com_menus/views/menus/tmpl/default.php
* administrator/components/com_templates/views/csschose/tmpl/default.php
* administrator/components/com_templates/views/templates/tmpl/default.php
* administrator/components/com_trash/admin.trash.html.php
* administrator/components/com_update/views/update/tmpl/default_item.php
* libraries/joomla/html/html/grid.php
*
* @param isitchecked
* @return
*/
function isChecked(isitchecked) {
if (isitchecked == true) {
document.adminForm.boxchecked.value++;
} else {
document.adminForm.boxchecked.value--;
}
}
/**
* Default function. Usually would be overriden by the component
*
* @deprecated 11.1 This function will be removed in a future version. Use Joomla.submitbutton() instead.
*/
function submitbutton(pressbutton) {
submitform(pressbutton);
}
/**
* Submit the admin form
*
* @deprecated 11.1 This function will be removed in a future version. Use Joomla.submitform() instead.
*/
function submitform(pressbutton) {
if (pressbutton) {
document.adminForm.task.value = pressbutton;
}
if (typeof document.adminForm.onsubmit == "function") {
document.adminForm.onsubmit();
}
if (typeof document.adminForm.fireEvent == "function") {
document.adminForm.fireEvent('submit');
}
document.adminForm.submit();
}
/**
* USED IN: libraries/joomla/html/toolbar/button/help.php
*
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl
+ ',scrollbars=' + scroll + ',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) {
win.window.focus();
}
}
// needed for Table Column ordering
/**
* USED IN: libraries/joomla/html/html/grid.php
*/
function tableOrdering(order, dir, task) {
var form = document.adminForm;
form.filter_order.value = order;
form.filter_order_Dir.value = dir;
submitform(task);
}
/**
* USED IN: libraries/joomla/html/html/grid.php
*/
function saveorder(n, task) {
checkAll_button(n, task);
}
function checkAll_button(n, task) {
if (!task) {
task = 'saveorder';
}
for (var j = 0; j <= n; j++) {
var box = document.adminForm['cb'+j];
if (box) {
if (box.checked == false) {
box.checked = true;
}
} else {
alert("You cannot change the order of items, as an item in the list is `Checked Out`");
return;
}
}
submitform(task);
}