main.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 i;
  135. for (i = 0; i < tbox.options.length; i++) {
  136. arrLookup[tbox.options[i].text] = tbox.options[i].value;
  137. arrTbox[i] = tbox.options[i].text;
  138. arrTboxIsDisabled[i] = tbox.options[i].disabled;
  139. }
  140. var fLength = 0;
  141. var tLength = arrTbox.length;
  142. for (i = 0; i < fbox.options.length; i++)
  143. {
  144. arrLookup[fbox.options[i].text] = fbox.options[i].value;
  145. if (fbox.options[i].selected && fbox.options[i].value != "")
  146. {
  147. arrTbox[tLength] = fbox.options[i].text;
  148. tLength++;
  149. }
  150. else
  151. {
  152. arrFbox[fLength] = fbox.options[i].text;
  153. arrFboxIsDisabled[fLength] = fbox.options[i].disabled;
  154. fLength++;
  155. }
  156. }
  157. arrFbox.sort();
  158. arrTbox.sort();
  159. var arrFboxGroup = [];
  160. var arrFboxUser = [];
  161. var prefix_x;
  162. var x;
  163. for (x = 0; x < arrFbox.length; x++) {
  164. prefix_x = arrFbox[x].substring(0, 2);
  165. if (prefix_x == 'G:') {
  166. arrFboxGroup.push(arrFbox[x]);
  167. } else {
  168. arrFboxUser.push(arrFbox[x]);
  169. }
  170. }
  171. arrFboxGroup.sort();
  172. arrFboxUser.sort();
  173. arrFbox = arrFboxGroup.concat(arrFboxUser);
  174. var arrTboxGroup = [];
  175. var arrTboxUser = [];
  176. var prefix_y;
  177. var y;
  178. for (y = 0; y < arrTbox.length; y++) {
  179. prefix_y = arrTbox[y].substring(0, 2);
  180. if (prefix_y == 'G:') {
  181. arrTboxGroup.push(arrTbox[y]);
  182. } else {
  183. arrTboxUser.push(arrTbox[y]);
  184. }
  185. }
  186. arrTboxGroup.sort();
  187. arrTboxUser.sort();
  188. arrTbox = arrTboxGroup.concat(arrTboxUser);
  189. fbox.length = 0;
  190. tbox.length = 0;
  191. var c;
  192. for (c = 0; c < arrFbox.length; c++)
  193. {
  194. var no = new Option();
  195. no.value = arrLookup[arrFbox[c]];
  196. no.text = arrFbox[c];
  197. if (arrFboxIsDisabled[c]) {
  198. no.disabled = "disabled";
  199. }
  200. fbox[c] = no;
  201. }
  202. for (c = 0; c < arrTbox.length; c++)
  203. {
  204. var no = new Option();
  205. no.value = arrLookup[arrTbox[c]];
  206. no.text = arrTbox[c];
  207. if (arrTboxIsDisabled[c]) {
  208. no.disabled = "disabled";
  209. }
  210. tbox[c] = no;
  211. }
  212. }
  213. function validate()
  214. {
  215. "use strict";
  216. var f = document.new_calendar_item;
  217. f.submit();
  218. return true;
  219. }
  220. function selectAll(cbList, bSelect, showwarning) {
  221. "use strict";
  222. if (document.getElementById('emailTitle').value == '') {
  223. document.getElementById('msg_error').innerHTML = lang.FieldRequired;
  224. document.getElementById('msg_error').style.display = 'block';
  225. document.getElementById('emailTitle').focus();
  226. } else {
  227. //if (cbList.length < 1) {
  228. //if (!confirm(lang.Send2All)) {
  229. // return false;
  230. //}
  231. //}
  232. var i;
  233. for (i = 0; i < cbList.length; i++)
  234. {
  235. cbList[i].selected = cbList[i].checked = bSelect;
  236. }
  237. document.f1.submit();
  238. }
  239. }
  240. function reverseAll(cbList)
  241. {
  242. "use strict";
  243. var i;
  244. for (i = 0; i < cbList.length; i++)
  245. {
  246. cbList[i].checked = !(cbList[i].checked);
  247. cbList[i].selected = !(cbList[i].selected);
  248. }
  249. }
  250. function plus_attachment() {
  251. "use strict";
  252. if (document.getElementById('options').style.display == 'none') {
  253. document.getElementById('options').style.display = 'block';
  254. document.getElementById('plus').innerHTML = '&nbsp;<img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" />&nbsp;' + lang.AddAnAttachment;
  255. } else {
  256. document.getElementById('options').style.display = 'none';
  257. document.getElementById('plus').innerHTML = '&nbsp;<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;' + lang.AddAnAttachment;
  258. }
  259. }
  260. // End