unterminated JS statement
[moodle.git] / mod / data / data.js
CommitLineData
9d0cffa5 1/**
2 * Javascript to insert the field tags into the textarea.
3 * Used when editing a data template
4 */
5function insert_field_tags(selectlist) {
6 if (typeof(currEditor) != 'undefined' && currEditor._editMode == 'wysiwyg') {
7 // HTMLArea-specific
8 currEditor.insertHTML(selectlist.options[selectlist.selectedIndex].value);
9 } else {
10 // For inserting when in HTMLArea code view or for normal textareas
11 insertAtCursor(currTextarea, selectlist.options[selectlist.selectedIndex].value);
12 }
13}
14
15/**
16 * javascript for hiding/displaying advanced search form when viewing
17 */
18function showHideAdvSearch(checked) {
19 var divs = document.getElementsByTagName('div');
20 for(i=0;i<divs.length;i++) {
21 if(divs[i].id.match('data_adv_form')) {
22 if(checked) {
23 divs[i].style.display = 'inline';
24 }
25 else {
26 divs[i].style.display = 'none';
27 }
28 }
29 else if (divs[i].id.match('reg_search')) {
30 if (!checked) {
31 divs[i].style.display = 'inline';
32 }
33 else {
34 divs[i].style.display = 'none';
35 }
36 }
37 }
26032c2d
DC
38}
39
40M.data_filepicker = {};
41
e4256380
DC
42
43M.data_filepicker.callback = function(params) {
44 var html = '<a href="'+params['url']+'">'+params['file']+'</a>';
45 document.getElementById('file_info_'+params['client_id']).innerHTML = html;
46};
47
48/**
49 * This fucntion is called for each file picker on page.
50 */
26032c2d
DC
51M.data_filepicker.init = function(Y, options) {
52 options.formcallback = M.data_filepicker.callback;
53 if (!M.core_filepicker.instances[options.client_id]) {
9d8de346 54 M.core_filepicker.init(Y, options);
26032c2d
DC
55 }
56 Y.on('click', function(e, client_id) {
57 e.preventDefault();
58 M.core_filepicker.instances[client_id].show();
59 }, '#filepicker-button-'+options.client_id, null, options.client_id);
60
e4256380
DC
61 var item = document.getElementById('nonjs-filepicker-'+options.client_id);
62 if (item) {
63 item.parentNode.removeChild(item);
64 }
65 item = document.getElementById('filepicker-wrapper-'+options.client_id);
66 if (item) {
67 item.style.display = '';
68 }
26032c2d
DC
69};
70
e4256380
DC
71M.data_urlpicker = {};
72
73M.data_urlpicker.init = function(Y, options) {
e4256380
DC
74 options.formcallback = M.data_urlpicker.callback;
75 if (!M.core_filepicker.instances[options.client_id]) {
9d8de346 76 M.core_filepicker.init(Y, options);
e4256380
DC
77 }
78 Y.on('click', function(e, client_id) {
79 e.preventDefault();
80 M.core_filepicker.instances[client_id].show();
81 }, '#filepicker-button-'+options.client_id, null, options.client_id);
82
83};
84
85M.data_urlpicker.callback = function (params) {
cd4a1897 86 document.getElementById('field_url_'+params.client_id).value = params.url;
9d8de346 87};
e4256380
DC
88
89M.data_imagepicker = {};
90
e4256380
DC
91M.data_imagepicker.callback = function(params) {
92 var html = '<a href="'+params['url']+'"><img src="'+params['url']+'" /> '+params['file']+'</a>';
93 document.getElementById('file_info_'+params['client_id']).innerHTML = html;
94};
95
96/**
97 * This fucntion is called for each file picker on page.
98 */
99M.data_imagepicker.init = function(Y, options) {
100 options.formcallback = M.data_imagepicker.callback;
101 if (!M.core_filepicker.instances[options.client_id]) {
9d8de346 102 M.core_filepicker.init(Y, options);
e4256380
DC
103 }
104 Y.on('click', function(e, client_id) {
105 e.preventDefault();
106 M.core_filepicker.instances[client_id].show();
107 }, '#filepicker-button-'+options.client_id, null, options.client_id);
108
109 var item = document.getElementById('nonjs-filepicker-'+options.client_id);
110 if (item) {
111 item.parentNode.removeChild(item);
112 }
113 item = document.getElementById('filepicker-wrapper-'+options.client_id);
114 if (item) {
115 item.style.display = '';
116 }
117};