common.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. function switchDateTodo(switcher)
  2. {
  3. if(switcher.checked)
  4. {
  5. $('#date').attr('disabled','disabled');
  6. }
  7. else
  8. {
  9. $('#date').removeAttr('disabled');
  10. }
  11. }
  12. /**
  13. * Load data.
  14. * @param type $type Type of selected todo.
  15. * @param id $id ID of selected todo.
  16. * @param defaultType $defaultType Default type of selected todo.
  17. * @param objectID $objectID ID of the closed todo type.
  18. * @access public
  19. * @return void
  20. */
  21. function loadList(type, id, defaultType, objectID)
  22. {
  23. if(id)
  24. {
  25. divClass = '.nameBox' + id;
  26. divID = '#nameBox' + id;
  27. }
  28. else
  29. {
  30. divClass = '.nameBox';
  31. divID = '#nameBox';
  32. }
  33. id = id ? id : '';
  34. var param = 'userID=' + userID + '&id=' + id;
  35. if(type == "task") param += '&status=wait,doing';
  36. if(type == 'risk') param += '&status=active,hangup';
  37. if(type == defaultType && objectID != 0) param += '&objectID=' + objectID;
  38. if(moduleList.indexOf(type) !== -1)
  39. {
  40. link = createLink(type, objectsMethod[type], param);
  41. $.get(link, function(data, status)
  42. {
  43. if(data.length != 0)
  44. {
  45. $(divClass).html(data).find('select').chosen();
  46. if(config.currentMethod == 'edit' || type == 'feedback') $(divClass).find('select').val(objectID).trigger('chosen:updated');
  47. if($(divClass + " select").val() == null) $(divClass + " select").attr("data-placeholder", noOptions.replace("%s", chosenType[type])).trigger('chosen:updated');
  48. }
  49. else
  50. {
  51. $(divClass).html("<select id="+ type +" class='form-control'></select>").find('select').chosen();
  52. }
  53. });
  54. }
  55. else
  56. {
  57. $(divClass).html($(divID).html());
  58. }
  59. if(typeof(nameBoxLabel) != "undefined")
  60. {
  61. if(type == 'custom' || (typeof(vision) != "undefined" && vision == 'rnd'))
  62. {
  63. $('#nameBoxLabel').text(nameBoxLabel.custom);
  64. }
  65. else
  66. {
  67. $('#nameBoxLabel').text(nameBoxLabel.objectID);
  68. }
  69. }
  70. }
  71. function selectNext()
  72. {
  73. $("#end ")[0].selectedIndex = $("#begin ")[0].selectedIndex + 3;
  74. $('#end').trigger('chosen:updated');
  75. }
  76. function setBeginsAndEnds(i, beginOrEnd)
  77. {
  78. if(typeof i == 'undefined')
  79. {
  80. for(j = 0; j < batchCreateNum; j++)
  81. {
  82. if(j != 0) $("#begins" + j)[0].selectedIndex = $("#ends" + (j - 1))[0].selectedIndex;
  83. $("#ends" + j)[0].selectedIndex = $("#begins" + j)[0].selectedIndex + 3;
  84. $("#begins" + j).trigger('chosen:updated');
  85. $("#ends" + j).trigger('chosen:updated');
  86. }
  87. }
  88. else
  89. {
  90. if(beginOrEnd == 'begin')
  91. {
  92. $("#ends" + i)[0].selectedIndex = $("#begins" + i)[0].selectedIndex + 3;
  93. $("#ends" + i).trigger('chosen:updated');
  94. }
  95. if(typeof batchCreateNum != 'undefined')
  96. {
  97. for(j = i+1; j < batchCreateNum; j++)
  98. {
  99. $("#begins" + j)[0].selectedIndex = $("#ends" + (j - 1))[0].selectedIndex;
  100. $("#ends" + j)[0].selectedIndex = $("#begins" + j)[0].selectedIndex + 3;
  101. $("#begins" + j).trigger('chosen:updated');
  102. $("#ends" + j).trigger('chosen:updated');
  103. }
  104. }
  105. }
  106. }
  107. function switchTimeList(number)
  108. {
  109. if($('#switchTime' + number).prop('checked'))
  110. {
  111. $('#begins' + number).attr('disabled', 'disabled').trigger('chosen:updated');
  112. $('#ends' + number).attr('disabled', 'disabled').trigger('chosen:updated');
  113. }
  114. else
  115. {
  116. $('#begins' + number).removeAttr('disabled').trigger('chosen:updated');
  117. $('#ends' + number).removeAttr('disabled').trigger('chosen:updated');
  118. }
  119. }
  120. function switchDateFeature(switcher)
  121. {
  122. if(switcher.checked)
  123. {
  124. $('#begin').attr('disabled','disabled').trigger('chosen:updated');
  125. $('#end').attr('disabled','disabled').trigger('chosen:updated');
  126. }
  127. else
  128. {
  129. $('#begin').removeAttr('disabled').trigger('chosen:updated');
  130. $('#end').removeAttr('disabled').trigger('chosen:updated');
  131. }
  132. }
  133. /**
  134. * Show specified date.
  135. *
  136. * @param switcher $switcher
  137. * @access public
  138. * @return void
  139. */
  140. function showSpecifiedDate(switcher)
  141. {
  142. if(switcher.checked)
  143. {
  144. $('#everyInput').attr('disabled','disabled');
  145. $('.specify').removeClass('hidden');
  146. $('.every').addClass('hidden')
  147. $('#configEvery').removeAttr('checked');
  148. }
  149. }
  150. /**
  151. * Show every.
  152. *
  153. * @param switcher $switcher
  154. * @access public
  155. * @return void
  156. */
  157. function showEvery(switcher)
  158. {
  159. if(switcher.checked)
  160. {
  161. $('#everyInput').removeAttr('disabled');
  162. $('.specify').addClass('hidden');
  163. $('.every').removeClass('hidden');
  164. $('#configSpecify').removeAttr('checked');
  165. $('#cycleYear').removeAttr('checked');
  166. $('#configEvery').removeAttr('checked');
  167. }
  168. }
  169. /**
  170. * Set days by specified month.
  171. *
  172. * @param int $specifiedMonth
  173. * @access public
  174. * @return void
  175. */
  176. function setDays(specifiedMonth)
  177. {
  178. /* Get last day in specified month. */
  179. var date = new Date();
  180. date.setMonth(specifiedMonth);
  181. var month = date.getMonth() + 1;
  182. date.setMonth(month);
  183. date.setDate(0);
  184. var specifiedMonthLastDay = date.getDate();
  185. $('#specifiedDay').empty('');
  186. for(var i = 1; i <= specifiedMonthLastDay; i++)
  187. {
  188. html = "<option value='" + i + "' title='" + i + "' data-keys='" + i + "'>" + i + "</option>";
  189. $('#specifiedDay').append(html);
  190. }
  191. }