Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- screenshotPreview(); // to display employee snapshot
- $('textarea').autogrow(); // textarea autogrow
- // Sliding Right
- $('li.navAccount a').click(function () {
- $('li.navAccount ul').slideToggle(600);
- });
- // Sliding Right Ends
- $('div.peContent').hover(
- function () {
- $(this).addClass("selected")
- },
- function () {
- $('div.peContent').removeClass("selected")
- });
- // grade selection area
- $('div.selection li').click(function () {
- var currentLi = this;
- var parentUl = this.parentNode.className;
- $('.' + parentUl + ' li').removeClass('selected');
- $(currentLi).addClass("selected").children('input[type=radio]').attr("checked", "checked");
- });
- // grade selection area ENDS
- // **************************
- //Default Action
- $(".tab_content").hide(); //Hide all content
- $("ul.tabs li:first").addClass("active").show(); //Activate first tab
- $(".tab_content:first").show(); //Show first tab content
- //On Click Event
- $("ul.tabs li").click(function () {
- $("ul.tabs li").removeClass("active"); //Remove any "active" class
- $(this).addClass("active"); //Add "active" class to selected tab
- $(".tab_content fieldset").hide(); //Hide all tab content
- var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
- // alert(activeTab)
- $(activeTab).fadeIn(); //Fade in the active content
- return false;
- });
- // *****************************
- // For submit buttons
- $("div#button input[type='submit']").click(function () {
- $("input#action").val($(this).val());
- });
- $('.uiSideNav li a').click(function () {
- $("input#tab").val($(this).attr('rel'));
- $("div#tab-save input[value='Save']").click();
- $('.uiSideNav li').removeClass("selected");
- $(this.parentNode).addClass("selected");
- });
- // $('.required').change(function (){
- // if(jQuery.trim($(this).val()) == ''){
- // $(this).css("border", "1px solid red");
- // $(this).after("<div style='color:red;'> Required Field</div>");
- // $('div#button :input').attr("disable", "disable");
- // }
- // });
- // Required Field validation ends
- /*****************total display section : to toggle detail view*****************/
- $(".total-container").hide();
- $(".total-tab").click(function () {
- $(this).toggleClass("total-active").next().slideToggle("fast");
- });
- $("#total-toggle a").click(function () {
- if ($(this).text() == 'Show all') {
- $(this).text('Hide all');
- $(".total-container").hide();
- $(".total-tab").removeClass("total-active");
- }
- else {
- $(this).text('Show all');
- $(".total-container").show();
- $(".total-tab").addClass("total-active");
- }
- $(".total-container").toggle();
- $(".total-tab").toggleClass("total-active");
- });
- // $("#total-accordion").accordion();
- /*******************************************************************************/
- });
- // Required Field validation
- function validatePE(clientside) {
- var peFormTypeId = $('#peFormTypeId').val();
- var peEmpId = $('#peEmpId').val();
- var errorflag = false;
- var con = true;
- if (clientside) {
- con = confirm("Do you really want to Submit?");
- }
- if (con) {
- var clearkids = $("div").children(".required").each(function () {
- if (($(this).hasClass('highlight_red'))) {
- $(this).removeClass("highlight_red");
- }
- var tabId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
- if (($('.' + tabId).hasClass('highlight_tab'))) {
- $('.' + tabId).removeClass("highlight_tab");
- }
- });
- /* Nazz removed this line :
- * var markkids = $("div").children(".required").each(function() {
- * and added the next line
- * on 5th Jan, 2012 for validating all the fields
- */
- /*
- * As per the update from HR team, the required fields are Quality,Quantity,Customer delight,Atendance and puctuality and ISO . Issue #98737
- * Modified on 4th APril, 2016 for validating the required fields.
- */
- // Validation for staff/admin monthly PE forms
- if (peFormTypeId == '4' || peFormTypeId == '5') {
- // Go through each tab
- $('#navItem_nf a').each(function () {
- // Check the required tab
- if ($(this).hasClass('required-tab')) {
- var hrefVal = $(this).attr("href");
- var tabIdDiv = hrefVal;
- var splitVal = hrefVal.split(/\s*\-\s*/g);
- var tabIdString = splitVal[2];
- var tabIdStringSplit = tabIdString.split('tabs');
- var tabId = tabIdStringSplit[1];
- var currentTabId = 'tab_' + tabId;
- var currentTab = $(this).parent();
- var markString = '_mark_NA';
- var inputId = '';
- // Managing the required tab
- if (($(this).parent().hasClass('highlight_tab'))) {
- $(this).parent().removeClass("highlight_tab");
- }
- $(tabIdDiv + ' :input').each(function () {
- inputId = $(this).attr('id');
- // Skip the input fileds for showing the PE mark and hidden fields
- if (($(this).attr('type') == 'hidden') || (inputId.indexOf(markString) != -1)) {
- // No need to check the value of fileds like 62_mark_NA,61_mark_NA and other hidden fields
- } else {
- // Validate all other input fields
- if (($(this).hasClass('highlight_red'))) {
- $(this).removeClass("highlight_red");
- }
- // Need to validate the required fields. Exception for the some fields in ISO,NC and average ticket and file upload options
- if ((jQuery.trim($(this).val()) == '' || jQuery.trim($(this).val().toLowerCase()) == 'na') && (inputId != '88_data' && inputId != '89_data' &&
- inputId != '40_data' && inputId != '40_expectation' && inputId != '41_data' && inputId != '41_expectation' &&
- inputId != '42_data' && inputId != '42_expectation' && inputId != '43_data' && inputId != '43_expectation' &&
- inputId != '66_data' && inputId != '12_data' && inputId != '13_data')) {
- // Managing the required fields
- if (!($(this).hasClass('highlight_red'))) {
- $(this).addClass("highlight_red");
- }
- var tabNewId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
- // If selected tab is same as current tab
- if (tabNewId === currentTabId) {
- currentTab.addClass("highlight_tab");
- }
- errorflag = true;
- } else {
- // Count the words length of input fields
- var words = jQuery.trim($(this).val()).split(' ');
- /* Add string length checking for the quantity and quality fields.*/
- if (jQuery.trim($(this).val()) != '' && jQuery.trim($(this).val().toLowerCase()) != 'na' && words.length <= '150' && (inputId == '62_data' || inputId == '61_data')) {
- // Managing the required fields
- if (!($(this).hasClass('highlight_red'))) {
- $(this).addClass("highlight_red");
- }
- var tabNewId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
- // If selected tab is same as current tab
- if (tabNewId === currentTabId) {
- currentTab.addClass("highlight_tab");
- }
- errorflag = true;
- }
- }
- }
- });
- }
- });
- } else {
- // Validation for annual PE forms
- var markkids = $("div").children(":input:enabled").each(function () {
- var inputId = $(this).attr('id');
- // validate all required fields except file upload
- if ((jQuery.trim($(this).val()) == '') && (inputId != '88_data' && inputId != '89_data')) {
- if (!($(this).hasClass('highlight_red'))) {
- $(this).addClass("highlight_red");
- }
- var tabId = $(this).parent('div').parent('div').parent('div').parent('div').parent().attr('id');
- $('.' + tabId).addClass("highlight_tab");
- /* Nazz ADDED the next TWO lines
- * on 5th Jan, 2012
- * for validating all the fields
- */
- monthlyTabId = $(this).parent('div').parent('div').parent('div').parent('fieldset').attr('id');
- $('.' + monthlyTabId).addClass('highlight_tab');
- errorflag = true;
- }
- });
- }
- } else {
- return false;
- }
- if (errorflag && clientside) {
- // Validation alert for staff/admin monthly PE forms
- if (peFormTypeId == '4' || peFormTypeId == '5') {
- alert(peEmpId);
- alert('Please fill all mandatory(*) and expectation fields.(Minimum 150 words for Quantity and Quality fields)');
- } else {
- // Validation alert for annual PE forms
- alert('Please fill all mandatory(*) and expectation fields');
- }
- return false;
- }
- }
- // Required Field validation ends
- function screenshotPreview() {
- /* CONFIG */
- xOffset = 17;
- yOffset = 30;
- // these 2 variable determine popup's distance from the cursor
- // you might want to adjust to get the right result
- /* END CONFIG */
- $("a.screenshot").hover(function (e) {
- this.t = this.title;
- this.title = "";
- var c = (this.t != "") ? "<br/>" + this.t : "";
- $("body").append("<p id='screenshot'><img src='" + this.rel + "' alt='url preview' />" + c + "</p>");
- $("#screenshot")
- .css("top", (e.pageY - xOffset) + "px")
- .css("left", (e.pageX + yOffset) + "px")
- .fadeIn("slow");
- },
- function () {
- this.title = this.t;
- $("#screenshot").remove();
- });
- $("a.screenshot").mousemove(function (e) {
- $("#screenshot")
- .css("top", (e.pageY - xOffset) + "px")
- .css("left", (e.pageX + yOffset) + "px");
- });
- }
- ;
- function setMaxCountAndMark(element, maxcount, maxmark, field) {
- var str = element.value;
- str = str.replace(/[^\d.]/g, "");
- str = parseInt(str);
- if (str > maxcount) {
- str = maxcount;
- }
- if (isNaN(str)) {
- str = '';
- $('#' + field).val('');
- } else {
- var mark = Math.round(str * parseInt(maxmark) / parseInt(maxcount));
- $('#' + field).val(mark);
- }
- // alert($('#'+field).val()+" = " + str+" * "+parseInt(maxmark) +"/"+ parseInt(maxcount));
- element.value = str;
- return true;
- }
Add Comment
Please, Sign In to add comment