Guest User

Untitled

a guest
Jul 8th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.42 KB | None | 0 0
  1.  
  2. $(document).ready(function () {
  3. screenshotPreview(); // to display employee snapshot
  4. $('textarea').autogrow(); // textarea autogrow
  5.  
  6.  
  7.  
  8. // Sliding Right
  9. $('li.navAccount a').click(function () {
  10. $('li.navAccount ul').slideToggle(600);
  11. });
  12. // Sliding Right Ends
  13.  
  14. $('div.peContent').hover(
  15. function () {
  16. $(this).addClass("selected")
  17. },
  18. function () {
  19. $('div.peContent').removeClass("selected")
  20. });
  21.  
  22. // grade selection area
  23. $('div.selection li').click(function () {
  24. var currentLi = this;
  25. var parentUl = this.parentNode.className;
  26. $('.' + parentUl + ' li').removeClass('selected');
  27. $(currentLi).addClass("selected").children('input[type=radio]').attr("checked", "checked");
  28. });
  29. // grade selection area ENDS
  30.  
  31. // **************************
  32. //Default Action
  33. $(".tab_content").hide(); //Hide all content
  34. $("ul.tabs li:first").addClass("active").show(); //Activate first tab
  35. $(".tab_content:first").show(); //Show first tab content
  36.  
  37. //On Click Event
  38. $("ul.tabs li").click(function () {
  39. $("ul.tabs li").removeClass("active"); //Remove any "active" class
  40. $(this).addClass("active"); //Add "active" class to selected tab
  41. $(".tab_content fieldset").hide(); //Hide all tab content
  42. var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
  43. // alert(activeTab)
  44. $(activeTab).fadeIn(); //Fade in the active content
  45. return false;
  46. });
  47.  
  48. // *****************************
  49.  
  50. // For submit buttons
  51. $("div#button input[type='submit']").click(function () {
  52. $("input#action").val($(this).val());
  53. });
  54.  
  55.  
  56. $('.uiSideNav li a').click(function () {
  57. $("input#tab").val($(this).attr('rel'));
  58. $("div#tab-save input[value='Save']").click();
  59. $('.uiSideNav li').removeClass("selected");
  60. $(this.parentNode).addClass("selected");
  61. });
  62.  
  63.  
  64.  
  65. // $('.required').change(function (){
  66. // if(jQuery.trim($(this).val()) == ''){
  67. // $(this).css("border", "1px solid red");
  68. // $(this).after("<div style='color:red;'> Required Field</div>");
  69. // $('div#button :input').attr("disable", "disable");
  70. // }
  71. // });
  72. // Required Field validation ends
  73.  
  74.  
  75. /*****************total display section : to toggle detail view*****************/
  76. $(".total-container").hide();
  77.  
  78. $(".total-tab").click(function () {
  79. $(this).toggleClass("total-active").next().slideToggle("fast");
  80. });
  81.  
  82. $("#total-toggle a").click(function () {
  83. if ($(this).text() == 'Show all') {
  84. $(this).text('Hide all');
  85. $(".total-container").hide();
  86. $(".total-tab").removeClass("total-active");
  87. }
  88. else {
  89. $(this).text('Show all');
  90. $(".total-container").show();
  91. $(".total-tab").addClass("total-active");
  92. }
  93. $(".total-container").toggle();
  94. $(".total-tab").toggleClass("total-active");
  95. });
  96. // $("#total-accordion").accordion();
  97. /*******************************************************************************/
  98.  
  99. });
  100.  
  101.  
  102. // Required Field validation
  103. function validatePE(clientside) {
  104. var peFormTypeId = $('#peFormTypeId').val();
  105. var peEmpId = $('#peEmpId').val();
  106. var errorflag = false;
  107. var con = true;
  108.  
  109. if (clientside) {
  110. con = confirm("Do you really want to Submit?");
  111. }
  112.  
  113. if (con) {
  114.  
  115. var clearkids = $("div").children(".required").each(function () {
  116. if (($(this).hasClass('highlight_red'))) {
  117. $(this).removeClass("highlight_red");
  118. }
  119.  
  120. var tabId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
  121. if (($('.' + tabId).hasClass('highlight_tab'))) {
  122. $('.' + tabId).removeClass("highlight_tab");
  123. }
  124. });
  125.  
  126. /* Nazz removed this line :
  127. * var markkids = $("div").children(".required").each(function() {
  128. * and added the next line
  129. * on 5th Jan, 2012 for validating all the fields
  130. */
  131.  
  132. /*
  133. * As per the update from HR team, the required fields are Quality,Quantity,Customer delight,Atendance and puctuality and ISO . Issue #98737
  134. * Modified on 4th APril, 2016 for validating the required fields.
  135. */
  136. // Validation for staff/admin monthly PE forms
  137. if (peFormTypeId == '4' || peFormTypeId == '5') {
  138.  
  139. // Go through each tab
  140. $('#navItem_nf a').each(function () {
  141.  
  142. // Check the required tab
  143. if ($(this).hasClass('required-tab')) {
  144. var hrefVal = $(this).attr("href");
  145. var tabIdDiv = hrefVal;
  146. var splitVal = hrefVal.split(/\s*\-\s*/g);
  147. var tabIdString = splitVal[2];
  148. var tabIdStringSplit = tabIdString.split('tabs');
  149. var tabId = tabIdStringSplit[1];
  150. var currentTabId = 'tab_' + tabId;
  151. var currentTab = $(this).parent();
  152. var markString = '_mark_NA';
  153. var inputId = '';
  154.  
  155. // Managing the required tab
  156. if (($(this).parent().hasClass('highlight_tab'))) {
  157. $(this).parent().removeClass("highlight_tab");
  158. }
  159.  
  160. $(tabIdDiv + ' :input').each(function () {
  161. inputId = $(this).attr('id');
  162.  
  163. // Skip the input fileds for showing the PE mark and hidden fields
  164. if (($(this).attr('type') == 'hidden') || (inputId.indexOf(markString) != -1)) {
  165.  
  166. // No need to check the value of fileds like 62_mark_NA,61_mark_NA and other hidden fields
  167. } else {
  168.  
  169. // Validate all other input fields
  170. if (($(this).hasClass('highlight_red'))) {
  171. $(this).removeClass("highlight_red");
  172. }
  173.  
  174. // Need to validate the required fields. Exception for the some fields in ISO,NC and average ticket and file upload options
  175. if ((jQuery.trim($(this).val()) == '' || jQuery.trim($(this).val().toLowerCase()) == 'na') && (inputId != '88_data' && inputId != '89_data' &&
  176. inputId != '40_data' && inputId != '40_expectation' && inputId != '41_data' && inputId != '41_expectation' &&
  177. inputId != '42_data' && inputId != '42_expectation' && inputId != '43_data' && inputId != '43_expectation' &&
  178. inputId != '66_data' && inputId != '12_data' && inputId != '13_data')) {
  179.  
  180. // Managing the required fields
  181. if (!($(this).hasClass('highlight_red'))) {
  182. $(this).addClass("highlight_red");
  183. }
  184.  
  185. var tabNewId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
  186.  
  187. // If selected tab is same as current tab
  188. if (tabNewId === currentTabId) {
  189. currentTab.addClass("highlight_tab");
  190. }
  191. errorflag = true;
  192.  
  193. } else {
  194.  
  195. // Count the words length of input fields
  196. var words = jQuery.trim($(this).val()).split(' ');
  197.  
  198.  
  199. /* Add string length checking for the quantity and quality fields.*/
  200. if (jQuery.trim($(this).val()) != '' && jQuery.trim($(this).val().toLowerCase()) != 'na' && words.length <= '150' && (inputId == '62_data' || inputId == '61_data')) {
  201.  
  202. // Managing the required fields
  203. if (!($(this).hasClass('highlight_red'))) {
  204. $(this).addClass("highlight_red");
  205. }
  206.  
  207. var tabNewId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
  208.  
  209. // If selected tab is same as current tab
  210. if (tabNewId === currentTabId) {
  211. currentTab.addClass("highlight_tab");
  212. }
  213. errorflag = true;
  214. }
  215. }
  216. }
  217. });
  218. }
  219.  
  220. });
  221.  
  222. } else {
  223.  
  224. // Validation for annual PE forms
  225. var markkids = $("div").children(":input:enabled").each(function () {
  226. var inputId = $(this).attr('id');
  227.  
  228. // validate all required fields except file upload
  229. if ((jQuery.trim($(this).val()) == '') && (inputId != '88_data' && inputId != '89_data')) {
  230. if (!($(this).hasClass('highlight_red'))) {
  231. $(this).addClass("highlight_red");
  232. }
  233.  
  234. var tabId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
  235. $('.' + tabId).addClass("highlight_tab");
  236.  
  237. /* Nazz ADDED the next TWO lines
  238. * on 5th Jan, 2012
  239. * for validating all the fields
  240. */
  241. monthlyTabId = $(this).parent('div').parent('div').parent('div').parent('fieldset').attr('id');
  242. $('.' + monthlyTabId).addClass('highlight_tab');
  243.  
  244. errorflag = true;
  245. }
  246. });
  247. }
  248. } else {
  249. return false;
  250. }
  251.  
  252. if (errorflag && clientside) {
  253.  
  254. // Validation alert for staff/admin monthly PE forms
  255. if (peFormTypeId == '4' || peFormTypeId == '5') {
  256. alert(peEmpId);
  257. alert('Please fill all mandatory(*) and expectation fields.(Minimum 150 words for Quantity and Quality fields)');
  258. } else {
  259.  
  260. // Validation alert for annual PE forms
  261. alert('Please fill all mandatory(*) and expectation fields');
  262. }
  263. return false;
  264. }
  265.  
  266. }
  267. // Required Field validation ends
  268.  
  269. function screenshotPreview() {
  270. /* CONFIG */
  271.  
  272. xOffset = 17;
  273. yOffset = 30;
  274.  
  275. // these 2 variable determine popup's distance from the cursor
  276. // you might want to adjust to get the right result
  277.  
  278. /* END CONFIG */
  279. $("a.screenshot").hover(function (e) {
  280. this.t = this.title;
  281. this.title = "";
  282. var c = (this.t != "") ? "<br/>" + this.t : "";
  283. $("body").append("<p id='screenshot'><img src='" + this.rel + "' alt='url preview' />" + c + "</p>");
  284. $("#screenshot")
  285. .css("top", (e.pageY - xOffset) + "px")
  286. .css("left", (e.pageX + yOffset) + "px")
  287. .fadeIn("slow");
  288. },
  289. function () {
  290. this.title = this.t;
  291. $("#screenshot").remove();
  292. });
  293. $("a.screenshot").mousemove(function (e) {
  294. $("#screenshot")
  295. .css("top", (e.pageY - xOffset) + "px")
  296. .css("left", (e.pageX + yOffset) + "px");
  297. });
  298. }
  299. ;
  300.  
  301.  
  302. function setMaxCountAndMark(element, maxcount, maxmark, field) {
  303. var str = element.value;
  304. str = str.replace(/[^\d.]/g, "");
  305. str = parseInt(str);
  306. if (str > maxcount) {
  307. str = maxcount;
  308. }
  309. if (isNaN(str)) {
  310. str = '';
  311. $('#' + field).val('');
  312. } else {
  313. var mark = Math.round(str * parseInt(maxmark) / parseInt(maxcount));
  314. $('#' + field).val(mark);
  315. }
  316. // alert($('#'+field).val()+" = " + str+" * "+parseInt(maxmark) +"/"+ parseInt(maxcount));
  317. element.value = str;
  318. return true;
  319.  
  320. }
Add Comment
Please, Sign In to add comment