main.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. $(document).ready(function () {
  2. $("#emailTitle").focus();
  3. });
  4. $(function() {
  5. $('.resizable').resizable();
  6. $('.resizable-vertical').resizable({
  7. handles: "n, s"
  8. });
  9. });
  10. var Announcement = {};
  11. Announcement.sort = function(c_id, ids, f){
  12. var url = www + '/main/inc/ajax/announcement.ajax.php';
  13. var data = {c_id: c_id, ids: ids, action: 'sort'};
  14. $.post(url, data, f);
  15. };
  16. Announcement.hide = function(c_id, id, token, f)
  17. {
  18. var url = www + '/main/inc/ajax/announcement.ajax.php';
  19. var data = {c_id: c_id, id: id, action: 'hide', sec_token: token};
  20. $.post(url, data, f, 'json');
  21. };
  22. Announcement.show = function(c_id, id, token, f)
  23. {
  24. var url = www + '/main/inc/ajax/announcement.ajax.php';
  25. var data = {c_id: c_id, id: id, action: 'show', sec_token: token};
  26. $.post(url, data, f, 'json');
  27. };
  28. Announcement.del = function(c_id, id, token, f)
  29. {
  30. var url = www + '/main/inc/ajax/announcement.ajax.php';
  31. var data = {c_id: c_id, id: id, action: 'delete', sec_token: token};
  32. $.post(url, data, f, 'json');
  33. };
  34. Announcement.delete_by_course = function(c_id, token, f)
  35. {
  36. var url = www + '/main/inc/ajax/announcement.ajax.php';
  37. var data = {c_id: c_id, action: 'delete_by_course', sec_token: token};
  38. $.post(url, data, f, 'json');
  39. };
  40. Announcement.delete_all = function(c_id, ids, token, f)
  41. {
  42. var url = www + '/main/inc/ajax/announcement.ajax.php';
  43. var data = {c_id: c_id, ids: ids, action: 'delete_all', sec_token: token};
  44. $.post(url, data, f, 'json');
  45. };
  46. function move_selected_option(from, to){
  47. var selected = $("option:selected", from)
  48. selected.each(function(index, option)
  49. {
  50. option = $(option);
  51. option.detach();
  52. $(to).append(option);
  53. });
  54. }
  55. function update_hidden_field(name){
  56. var select = $('#' + name + '_selected');
  57. var options = $("option", select)
  58. //update hidden field
  59. var keys = [];
  60. options.each(function(index, option)
  61. {
  62. option = $(option);
  63. keys.push(option.val());
  64. });
  65. keys = keys.join(',');
  66. var hidden = $('#' + name);
  67. hidden.val(keys);
  68. }
  69. function toggle_list_selector(name)
  70. {
  71. var list = $('#' + name + '_list');
  72. var overview = $('#' + name + '_overview');
  73. if(list.css('display') == 'none'){
  74. list.show();
  75. overview.hide();
  76. }
  77. else
  78. {
  79. list.hide();
  80. overview.show();
  81. }
  82. var select = $('#' + name + '_selected');
  83. //update overview
  84. var content = [];
  85. var options = $("option", select)
  86. options.each(function(index, option)
  87. {
  88. option = $(option);
  89. content.push(option.text());
  90. });
  91. content = content.join(', ');
  92. content = (content == '') ? lang.Everybody : content;
  93. overview.text(content);
  94. }
  95. function toggle_sendto()
  96. {
  97. var list = $('#recipient_list');
  98. var overview = $('#recipient_overview');
  99. if(list.css('display') == 'none'){
  100. list.show();
  101. overview.hide();
  102. }
  103. else
  104. {
  105. list.hide();
  106. overview.show();
  107. }
  108. var selected = $('#selectedform');
  109. var content = list_box_content(selected[0])
  110. content = (content == '') ? lang.Everybody : content;
  111. overview.text(content);
  112. }
  113. function list_box_content(box)
  114. {
  115. if(box.options.length == 0)
  116. {
  117. return '';
  118. }
  119. var values = [];
  120. var i;
  121. for (i = 0; i < box.options.length; i++) {
  122. values[i] = box.options[i].text;
  123. }
  124. return values.join(', ');
  125. }
  126. // Begin javascript menu swapper
  127. function move(fbox, tbox) {
  128. "use strict";
  129. var arrFbox = [];
  130. var arrTbox = [];
  131. var arrLookup = [];
  132. var arrFboxIsDisabled = []; // if this from checkbox after move is disabled or not
  133. var arrTboxIsDisabled = []; // if this to checkbox after move is disabled or not
  134. var key_value = ""; // key for arrays arrFboxIsDisabled and arrTboxIsDisabled, use associative array key_value is the value of the array element (eg : GROUP:1 or USER:24)
  135. var i;
  136. for (i = 0; i < tbox.options.length; i++) {
  137. arrLookup[tbox.options[i].text] = tbox.options[i].value;
  138. arrTbox[i] = tbox.options[i].text;
  139. key_value = tbox.options[i].value;
  140. arrTboxIsDisabled[key_value] = tbox.options[i].disabled;
  141. }
  142. var fLength = 0;
  143. var tLength = arrTbox.length;
  144. for (i = 0; i < fbox.options.length; i++)
  145. {
  146. arrLookup[fbox.options[i].text] = fbox.options[i].value;
  147. if (fbox.options[i].selected && fbox.options[i].value != "")
  148. {
  149. arrTbox[tLength] = fbox.options[i].text;
  150. tLength++;
  151. }
  152. else
  153. {
  154. arrFbox[fLength] = fbox.options[i].text;
  155. key_value = fbox.options[i].value;
  156. arrFboxIsDisabled[key_value] = fbox.options[i].disabled;
  157. fLength++;
  158. }
  159. }
  160. arrFbox.sort();
  161. arrTbox.sort();
  162. var arrFboxGroup = [];
  163. var arrFboxUser = [];
  164. var prefix_x;
  165. var x;
  166. for (x = 0; x < arrFbox.length; x++) {
  167. prefix_x = arrFbox[x].substring(0, 2);
  168. if (prefix_x == 'G:') {
  169. arrFboxGroup.push(arrFbox[x]);
  170. } else {
  171. arrFboxUser.push(arrFbox[x]);
  172. }
  173. }
  174. arrFboxGroup.sort();
  175. arrFboxUser.sort();
  176. arrFbox = arrFboxGroup.concat(arrFboxUser);
  177. var arrTboxGroup = [];
  178. var arrTboxUser = [];
  179. var prefix_y;
  180. var y;
  181. for (y = 0; y < arrTbox.length; y++) {
  182. prefix_y = arrTbox[y].substring(0, 2);
  183. if (prefix_y == 'G:') {
  184. arrTboxGroup.push(arrTbox[y]);
  185. } else {
  186. arrTboxUser.push(arrTbox[y]);
  187. }
  188. }
  189. arrTboxGroup.sort();
  190. arrTboxUser.sort();
  191. arrTbox = arrTboxGroup.concat(arrTboxUser);
  192. fbox.length = 0;
  193. tbox.length = 0;
  194. var c;
  195. for (c = 0; c < arrFbox.length; c++)
  196. {
  197. var no = new Option();
  198. no.value = arrLookup[arrFbox[c]];
  199. no.text = arrFbox[c];
  200. key_value = no.value;
  201. if (arrFboxIsDisabled[key_value]) {
  202. no.disabled = "disabled";
  203. }
  204. fbox[c] = no;
  205. }
  206. for (c = 0; c < arrTbox.length; c++)
  207. {
  208. var no = new Option();
  209. no.value = arrLookup[arrTbox[c]];
  210. no.text = arrTbox[c];
  211. key_value = no.value;
  212. if (arrTboxIsDisabled[key_value]) {
  213. no.disabled = "disabled";
  214. }
  215. tbox[c] = no;
  216. }
  217. }
  218. function validate()
  219. {
  220. "use strict";
  221. var f = document.new_calendar_item;
  222. f.submit();
  223. return true;
  224. }
  225. function selectAll(cbList, bSelect, showwarning) {
  226. "use strict";
  227. if (document.getElementById('emailTitle').value == '') {
  228. document.getElementById('msg_error').innerHTML = lang.FieldRequired;
  229. document.getElementById('msg_error').style.display = 'block';
  230. document.getElementById('emailTitle').focus();
  231. } else {
  232. //if (cbList.length < 1) {
  233. //if (!confirm(lang.Send2All)) {
  234. // return false;
  235. //}
  236. //}
  237. var i;
  238. for (i = 0; i < cbList.length; i++)
  239. {
  240. cbList[i].selected = cbList[i].checked = bSelect;
  241. }
  242. document.f1.submit();
  243. }
  244. }
  245. function reverseAll(cbList)
  246. {
  247. "use strict";
  248. var i;
  249. for (i = 0; i < cbList.length; i++)
  250. {
  251. cbList[i].checked = !(cbList[i].checked);
  252. cbList[i].selected = !(cbList[i].selected);
  253. }
  254. }
  255. // End