/** * * Copyright (c) 2013 OCR Services Inc * Author(s) Jinesh Gopinathan, George Anil John */ var smartHintsLabels; var CURRENT_MODULE; $(document).ready(function(){ $(document).keypress(function(event){ var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ var textareabox = $("textarea"); var selectbox = $("select"); var hyperlink = $("a"); if ($('.modal-backdrop').length == 0){ $(this).find(".form-content").find(".primary-btn:first:enabled").each(function(index){ if (textareabox.is(':focus') || selectbox.is(':focus') || hyperlink.is(':focus')){ return false; }else{ $(this).trigger('click').change(); return false; } }); }else if($('.modal-backdrop').length > 0){ $(document).find(".modal-dialog").find(".recordFromPopup:first, .popupSearchButton,.popupSearchButtonUserProf").each(function(index){ if (textareabox.is(':focus') || selectbox.is(':focus') || hyperlink.is(':focus')){ return false; }else if ($(this).hasClass('recordFromPopup') && $('#resultDIV').css('display') == 'block'){ $(this).trigger('click').change(); return false; }else if ($(this).hasClass('popupSearchButton') && $('#searchDIV').css('display') == 'block'){ $(this).trigger('click').change(); return false; }else if ($(this).hasClass('popupSearchButtonUserProf') && $('#searchDIV').css('display') == 'block'){ $(this).trigger('click').change(); return false; } }); } } }); }); if (!jQuery) {throw new TypeError("jQuery is required.");}; ;(function ($, window, document, undefined) { 'use strict'; var smartHintsLabelsHrd = { "countryName": "Country Name", "isoCode": "ISO Code", "customCode": "Custom Code", "specialProgramName": "Special Program Name", "specialProgramIndicator": "Special Program Indicator", "officeTitle": "office Title", "code": "Code", "description": "Description", "name": "name", "warehouseCode": "warehouseCode" }; if(typeof smartHintsLbls !== "undefined" && smartHintsLbls){ smartHintsLabels = smartHintsLbls; }else{ smartHintsLabels = smartHintsLabelsHrd; } var DEFUALT_COUNTRY_CODE = ''; var countrySmartFieldData = null; var countryJson = null; var uomSmartFieldData = null; var maxExportExcelSize = null; var maxExportExcelErrMsg = null; var filteredCountriesSmartData = null; var US_DATE_FORMAT = 'mm/dd/yy'; var US_DATE_FORMAT_PLACEHOLDER = 'MM/DD/YYYY'; var GRID_US_DATE_FORMAT = 'm/d/Y'; // put module name on which US-DF is needed. var modules = ['LES','CRS','ELAIN','FTZ','CIT','TDEA','DRS','TRNG','PCS','GTC','NRC','OFAC']; var moduleName = $('#moduleName'); var enableUDF = true; if(moduleName && moduleName.length > 0){ moduleName = $(moduleName).val(); } /* PRJ-645: FLEX FIELDS FILE SELECTORS */ var SmartFieldDataRTF = null; var filteredSmartDataRTF = null; /* Subtask#4392 Date format globalization: Defining global variables to globalize dates of GRID, Date Picker etc. */ var userDateFormat = US_DATE_FORMAT; var placeHolderDateFormat = US_DATE_FORMAT_PLACEHOLDER; var gridDateFormat = GRID_US_DATE_FORMAT; var dateFormats = $('#userDateFormat').val(); var countryGroupSmartFieldData = null; var commonLoadText = null; if(dateFormats){ var formats = JSON.parse(dateFormats); placeHolderDateFormat = formats.defaultDateFormat.toUpperCase(); userDateFormat = formats.defaultJSDateFormat; gridDateFormat = formats.defaultGridDateFormat; } /* Process request */ var ProcessRequest = { name : 'OCR-JS', version : '1.0.0', defaults: { role: '', url: '', dismiss: '', source: '', target: '', before: null, complete: null, //Call back functions error: null, data: null, processData: true, avoidModalOnFormProcess: true, avoidPopupOverPopup: false, contentType: 'application/x-www-form-urlencoded; charset=UTF-8', asyncProcessing:true, }, init: function(options, element) { this.$element = $(element); this.options = jQuery.extend({}, this.defaults, options); this._build(); return this; }, _build: function(){ this.fromData(); this.process(); }, fromData: function(){ //PRJ-3084(SUBTASK-4487) Number format by Mukesh Singh /*if($.numberFormat){ $.numberFormat.setUnformattedNumber(); }*/ var self = this.$element; if(this.options.role == ''){ this.options.role = self.data('ocr-role'); if(!this.options.role){ this.options.role = 'ajax-link'; } } if(this.options.role == 'native-form'){ this.options.role = 'ajax-form'; } if(this.options.role == 'native-link'){ this.options.role = 'ajax-link'; } if(this.options.url == ''){ this.options.url = self.data('ocr-url'); if(!this.options.url){ var link = self.attr('href'); if(link && link != '#'){ this.options.url = link; } else { link = self.attr('action'); if(link && link != '#'){ this.options.url = link; } } } } /* Added by Anil Jaglan to set 'data-ocr-refresh' attribute in options array */ this.options.refresh = self.data('ocr-refresh'); /* manipulating urls if required : Rakesh Arora*/ this.options.url = $.manipulateUrlForCountrycodes({url: this.options.url}); if(this.options.source == ''){ this.options.source = self.data('ocr-source'); } if(this.options.target == ''){ this.options.target = self.data('ocr-target'); } if(this.options.dismiss == ''){ this.options.dismiss = self.data('ocr-dismiss'); } if(!this.options.url || this.options.url == ''){ throw new Error('The link is invalid. '+ this.options.url); } /*if (self.data('ocr-avoidpopupoverpopup') != '') { this.options.avoidPopupOverPopup = self.data('ocr-avoidpopupoverpopup'); }*/ if (self.data('avoidpopupoverpopup') == '') { this.options.avoidPopupOverPopup = self.data('ocr-avoidpopupoverpopup'); } }, process: function() { if(this.options.role == 'frame-link'){ this.iframe(); } else if(this.options.role == 'tab-link'){ this.showLoader(); this.loadTabContent(); } else { this.showLoader(); this.xhrRequest(this.serializeData()); } }, iframe: function(){ if($.hasValue(this.options.url)){ $('#content-cont').html('').addClass('hidden'); $('.footer-bar').addClass('hidden'); $('#frame-cont').removeClass('hidden'); $('#frame-cont iframe').css('display','block').trigger('resize').attr("src", this.options.url); } }, showLoader: function(){ var self = this.$element; this.$backdrop && this.$backdrop.remove(); this.$backdrop = $('
').insertAfter(document.body); /* make ajax call to get the loading text data */ if(!commonLoadText){ $.ajax({ url : "/vrsportal/getLoadingText.ocr", dataType : "json", cache: false, async: false, success : function(data) { commonLoadText = data.loadingText; } }); } $(".loader-cont .loader-info").html(' '); $(".loader-cont").removeClass('hidden'); if (this.options.role == 'modal-form') { $(self).closest('.modal-loader').removeClass('hidden'); } return this; }, serializeData: function(){ var self = this.$element; var tagType = null; var data = this.options.data; if(this.options.source != null && $.hasValue(this.options.source)){ self = $(this.options.source); } tagType = self.prop("tagName"); /* If data is provided, then don't fetch the data from the form */ if(tagType == 'FORM' && !data){ $.each(self, function(i, value) { var $tempObj = $(value); /*PRJ-75:TextArea having ignoreTrim cssclass to be ignored from trim */ $tempObj.find('input:text, textarea:not(.ignoreTrim)').each(function(){ $(this).val($.trim($(this).val())); }); }); data = self.serialize(); if(data != null){ //replace CRLF with LF data=data.replace(/%0D%0A/g,'%0A'); } } return data; }, /*PRJ-3084(SUBTASK-4487) Number format by Mukesh Singh * Further Enhanced the number format framework. */ manipulateNumberFields: function(data){ var decimalFields = $('.decimal-formatter'); var nonDecimalFields = $('.nondecimal-formatter'); if(data && $.numberFormat && typeof data != 'object'){ if(decimalFields.length > 0 || nonDecimalFields.length > 0){ var dataArrs = []; var dataArr = data.split('&'); $.each(dataArr, function(index, val){ var valArr = val.split('='); var dataValuesArr = [valArr[0], valArr[1]]; dataArrs.push(dataValuesArr); }); if(decimalFields.length > 0){ $.each(decimalFields, function(index, $obj){ if($($obj).val()){ var unformatted_val = $.numberFormat.getUnformattedNumber({number: $($obj).val()}); $.each(dataArrs, function(indx, val){ if(val && $($obj).attr('name') == val[0]){ dataArrs[indx] = [val[0], unformatted_val]; } }); } }); } if(nonDecimalFields.length > 0){ $.each(nonDecimalFields, function(index, $obj){ if($($obj).val()){ var unformatted_val = $.numberFormat.getUnformattedNumber({number: $($obj).val(), isDecimal: false}); $.each(dataArrs, function(indx, val){ if(val && $($obj).attr('name') == val[0]){ dataArrs[indx] = [val[0], unformatted_val]; } }); } }); } data = ''; var i = 0; $.each(dataArrs, function(index, val){ if(i == dataArrs.length-1){ data += val[0]+'='+val[1]; }else{ data += val[0]+'='+val[1]+'&'; } i++; }); } } return data; }, setEnableUDF:function(response){ var enableUDF = true; try{ var enableUDFVal = $(response).find('[name="enableUDF"]').val(); if(moduleName){ if(modules.join(',').indexOf(moduleName)> -1){//Used for minimal user date format required in any module enableUDF = false; if(enableUDFVal == 'Y'){//Put Y in hidden field value if UDF needed enableUDF = true; } }else {//Used for minimal US date format required in any module if(enableUDFVal == 'N'){//Put N in hidden field value if US-DF needed enableUDF = false; } } } }catch(e){} this.enableUDF = enableUDF; }, xhrRequest: function(data) { var that = this; data = this.manipulateNumberFields(data); $.ajax({ context: document.body, data: data, dataType: 'html', type: 'POST', processData: that.options.processData, contentType: that.options.contentType, url: this.options.url, timeout: 300000, async:that.options.asyncProcessing, success: function(response) { that.setEnableUDF(response); if($.isFunction(that.options.complete)){ that.options.complete.call(that, response); } else { try{ that.loadResponse(response); } catch(e){ that.showErrors(e,"success"); } } that.removeLoader(); that.initMultiCountry(); that.initMultiCountryCode(); that.initializeSmartHints(); that.initializeScreen(); /* disable the online help for now - Rakesh */ that.fieldHelpContent(); /* initialize online help, if there is a requirement */ try{ var initOnlineHelp = window["initOnlineHelp"]; if(typeof initOnlineHelp === 'function'){ var $targetContainer = null; if(that.options.role.indexOf('modal') < 0){ /* not a modal */ $targetContainer = $('#content-cont'); }else{ /* its modal */ $targetContainer = that.$element.closest('.ocr-modal-cont').find('.modal'); } var returnObj; initOnlineHelp.call(returnObj, that.options.url, $targetContainer); } }catch(e){ console.log(e.message); } /* calling for initializing external smarthints */ var externalSmartHint = window["initializeHintsOnReady"]; if(typeof externalSmartHint === 'function'){ externalSmartHint.call(); } }, error: function(jqXHR, textStatus, errorThrown) { if(textStatus ==="timeout") { that.timeOut(); that.showErrors(errorThrown,"timeout"); } else { that.removeLoader(); that.showErrors(errorThrown,"error",jqXHR.status); } } }); }, showErrors : function(errorThrown,type,status){ var errors =[]; var message = ""; if(type=="error"){ if(status=="0"){ message="Server encountered an error. Please try again."; }else{ message=" HTTP Status "+status+" - The server encountered an internal error and was unable to complete your request. Please provide the log under Tools -> Server Logs -> tomcat-ocr.log."; } }else if(type=="timeout"){ message="Request has timed out. If applicable, please narrow the search criteria and try again. Otherwise, please contact your system administrator."; } else { message="Unable to process the request due to error in script"; } errors.push({msg:message}); if(this.options.role.indexOf('modal') != -1){ var self = this.$element; var tagType = self.prop("tagName"); var modalCont = null; if(tagType == 'FORM' && this.options.avoidModalOnFormProcess){ modalCont = self.closest('.ocr-modal-cont'); } else { modalCont = self.closest('.ocr-modal-base').find('.ocr-modal-cont:first'); if(modalCont.length < 1){ modalCont = self.closest('#content-cont').find('.ocr-modal-cont:first'); if(modalCont.length < 1){ modalCont = self.closest('body').find('.ocr-modal-cont:last'); } } } if(modalCont.find('.modal').hasClass('in')){ if(modalCont.find('.ocr-error').length > 0){ $(modalCont.find('form')).processMsg({errors:errors}); }else{ alert(message); } }else{ $(this).processMsg({errors:errors}); } }else{ $(this).processMsg({errors:errors}); } console.error(errorThrown); }, loadResponse: function(response){ var self = this.$element; var that = this; var contCont = $('#content-cont'); var frameCont = $('#frame-cont'); if(this.options.role.indexOf('modal') < 0){ if(!frameCont.hasClass('hidden')){ $('#frame-cont iframe').css('display','hidden').attr("src", "about:blank"); frameCont.addClass('hidden'); } if(contCont.hasClass('hidden')){ contCont.removeClass('hidden'); $('.footer-bar').removeClass('hidden'); } contCont.empty().html(response).processMsg().trigger('resize'); $('#lastUsedLink_').val(this.options.url); this.afterResponseLoad(); }else { var tagType = self.prop("tagName"); var modalCont = null; var modalObj = null; var isHidden = true; if(tagType == 'FORM' && this.options.avoidModalOnFormProcess){ modalCont = self.closest('.ocr-modal-cont'); } else { modalCont = self.closest('.ocr-modal-base').find('.ocr-modal-cont:first'); if(modalCont.length < 1){ modalCont = self.closest('#content-cont').find('.ocr-modal-cont:first'); if(modalCont.length < 1){ modalCont = self.closest('body').find('.ocr-modal-cont:last'); } } } if(this.options.dismiss == 'close'){ this.options.clickedCancel = true; modalCont.find('.modal').modal('hide'); }else { /* TODO: need to review this code block: popup on popup POC work */ modalCont.find("#gridPopup").jqGrid("GridUnload"); if(!modalCont.find('.modal').is(":hidden") && !this.options.avoidPopupOverPopup){ try{ if($(".archivedPopups").length == 0 || $(".archivedPopups:last").html().length > 0) $("#content-cont").append(""); /* backup the form state into json */ var formbackup = modalCont.find('.modal').closest(".ocr-modal-cont form").jsonify(); $(".archivedPopups:last").html(modalCont.find('.modal').closest(".ocr-modal-cont").html()); /* restore the form state from its json data */ $(".archivedPopups:last form").loadJSON(formbackup); modalCont.find('.modal .modal-content').addClass("backedUp"); }catch(ex){} } /* End: popup on popup POC changes */ modalObj = modalCont.find('.modal:first'); if(modalObj.length > 0 && modalObj.css('display') == 'block'){ isHidden = false; } if(isHidden){ modalCont.empty().html(response).processMsg().find('.modal:first').modal({backdrop: 'static'}) .initializeDatePickers({jqueryDateFormat:{datePickerFormat: userDateFormat, placeHolderFormat: placeHolderDateFormat}, enableUDF:that.enableUDF}) .ocrSmartHints(); } else { modalCont.find('.modal').modal('hide'); if($('html').hasClass('lt-ie9')||$('html').hasClass('lt-ie10')){//IE8,IE9 fix modalCont.empty().html(response).processMsg().find('.modal:first').modal({backdrop: 'static'}) .initializeDatePickers({jqueryDateFormat:{datePickerFormat: userDateFormat, placeHolderFormat: placeHolderDateFormat}, enableUDF:that.enableUDF}).ocrSmartHints(); } else { modalCont.find('.modal').on('hidden.bs.modal', function (){ modalCont.empty().html(response).processMsg().find('.modal:first').modal({backdrop: 'static'}) .initializeDatePickers({jqueryDateFormat:{datePickerFormat: userDateFormat, placeHolderFormat: placeHolderDateFormat}, enableUDF:that.enableUDF}).ocrSmartHints();; }); } } } } }, afterResponseLoad: function(){ if(this.options.role.indexOf('modal') < 0){ /* Used to remove double spaces from the page heading */ var heading = $('.page-heading h3').length == 0 ? $('.page-heading').contents() : $('.page-heading h3').contents(); if(heading != undefined && heading[0] != undefined && heading[0].nodeValue != undefined){ heading[0].nodeValue = $.trim(heading[0].nodeValue.replace(/\s(\s+)/g, ' ')); } if($('#scrollTarget_').length != 0 && $('#scrollTarget_').val() != ""){ var target = $($('#scrollTarget_').val()); $('html, body').animate({ scrollTop: target.offset().top }, 'slow'); } else { $("#go-top").trigger("click"); } } }, removeLoader: function(){ $(".loader-cont").addClass('hidden'); this.$backdrop && this.$backdrop.remove(); this.$backdrop = null; }, fieldHelpContent:function(){ var globalUserRole=$("input:hidden[name=globalUserType]").val(); var self = this; var screenUrl=''; var iconTag = ""; var $targetContainer = null; var fullScreenUrl=self.options.url; if(self.options.role.indexOf('modal') < 0){ /* not a modal */ $targetContainer = $('#content-cont'); }else{ /* its modal */ $targetContainer = self.$element.closest('.ocr-modal-cont').find('.modal'); } var $targetContainerVar=$targetContainer; screenUrl=fullScreenUrl.substring(0,fullScreenUrl.indexOf('.')); $targetContainer.find(".form-control").each(function(){ var $formElement = $(this); var $helpIcon = $(iconTag); $targetContainer.find(".form-control").closest('div').css('position','relative'); $formElement.after($helpIcon); //Temporary fix for date picker Help Icon alignment. if($formElement.hasClass("ocr-date")){ $helpIcon.children().css('right','0px !important'); } $helpIcon.on('click', function(){ var fName=$helpIcon.parent().find(':input').attr('name'); var newUrl = '/user/openFieldConfigurationPopup.ocr?screenUrl='+screenUrl+'&fieldName='+fName; $(this).processRequest({ url: newUrl, role: 'modal-link', });; }); }); self.setupfieldHelpContent(screenUrl,$targetContainerVar,globalUserRole); $targetContainer.find(".form-control").each(function(){ var $formElement = $(this); if(globalUserRole!='CORP'){ if($formElement.parent().find('a').hasClass('helpIcon')){ $formElement.parent().find('a').remove(); }else{ $formElement.parent().find('a').off('click'); } }else{ if($formElement.parent().find('a').hasClass('helpIcon')){ $formElement.parent().find('a').removeAttr('data-tooltip'); } } }); }, setupfieldHelpContent: function(screenUrl,$targetContainerVar,globalUserRole){ var newUrl = '/user/setupfieldHelpContent.ocr?screenUrl='+screenUrl; $.ajax({ }); }, timeOut: function(){ this.removeLoader(); }, initializeSmartHints: function(){ $(document).ocrSmartHints({targetURL:this.options.url}); }, initMultiCountry: function(){ this.$element.initMultiCountry(); }, initMultiCountryCode: function(){ this.$element.initMultiCountryCode(); }, getJqueryDateFormat: function(dateFormat){ var dateFormat = {datePickerFormat: userDateFormat, placeHolderFormat: placeHolderDateFormat}; /*if(dateFormat == 'mm/dd/yyyy'){ dateFormat.datePickerFormat = 'mm/dd/yy'; dateFormat.placeHolderFormat = 'MM/DD/YYYY'; }else{ dateFormat.datePickerFormat = 'mm/dd/yy'; dateFormat.placeHolderFormat = 'MM/DD/YYYY'; }*/ return dateFormat; }, initializeScreen: function(){ var self = this; $(document).initializeDatePickers({jqueryDateFormat: self.getJqueryDateFormat('dd/M/yy'), enableUDF:self.enableUDF}); self.loadFlagFields(); }, loadFlagFields: function(){ var self = this; /* todo: need to init the flag fields plugin here */ $("[data-ocr-type='flagField']:not(.flag-field)").ocrFlagFields({}); }, loadTabContent: function() { var tab = this.options.target + ' .col-xs-12:first'; var targetContainer = $(tab); var that = this; $(".tab-menu .popover-content li a").removeClass('active'); $(this.$element).addClass('active'); /* added support for refresh the tab on demand, * also added support for confirmed refreshing a tab */ if (!this.options.refresh && $.trim(targetContainer.html()).length > 0 ) { $('.tab-content').removeClass('active'); targetContainer.parent().addClass('active').trigger('resize'); //targetContainer.addClass('active').trigger('resize'); if($.isFunction(that.options.complete)){ that.options.complete.call(that, null); } /* Monu: This will resize the grids present in the tab */ var grid; if (grid = $('.ui-jqgrid-btable:visible')) { grid.each(function(index) { var gridId = $(this).attr('id'); var gridParentWidth = $('#gbox_' + gridId).parent().width(); $('#' + gridId).setGridWidth(gridParentWidth); }); } this.removeLoader(); } else { $('.tab-content').removeClass('active'); $.ajax({ context: document.body, dataType: 'html', type: 'POST', url: this.options.url, timeout: 9000, async: that.options.asyncProcessing, success: function(response) { that.setEnableUDF(response); if($.isFunction(that.options.complete)){ that.options.complete.call(that, response); } //$('.tab-content').removeClass('active'); targetContainer.empty().html(response).processMsg(); /* Adding active URL as a marker for which url, this div is loaded, so that if the url changes, we need to reload the rab */ targetContainer.parent().addClass('active').trigger('resize'); that.removeLoader(); that.initMultiCountry(); that.initMultiCountryCode(); that.initializeSmartHints(); that.initializeScreen(); }, error: function(jqXHR, textStatus, errorThrown) { if(textStatus ==="timeout") { that.timeOut(); } else { throw new Error(errorThrown); } } }); } } }; /* Dhermi: Fix for Date picker modal popup on chrome and mozilla browsers, requested by Rocky * It was broken on these browsers because browsers compatibilities for the date pickers * */ $.fn.modal.Constructor.prototype.enforceFocus = function() {}; /* Process Error and Java Script Messages. */ var ProcessMsg = { name : 'OCR-JS', version : '1.0.0', defaults: { errors : [], warnings : [], info: [] }, init: function(options, element) { this.$element = $(element); this.options = jQuery.extend({}, this.defaults, options); this._build(); return this; }, _build: function(){ this.checkTagsPresent(); this.showMsg(); }, checkTagsPresent: function(){ var self = this.$element; var options = this.options; var baseCont = null; var hasAlert = false; if(self.closest('.ocr-modal-cont') .length < 1){ baseCont = $('#content-cont'); } else { baseCont = self.closest('.ocr-modal-cont'); } if(baseCont == null){ baseCont = self; } this.$parentContainer = baseCont; baseCont.find('.form-control').removeClass("form-error"); baseCont.find('.form-control').removeClass("form-warning"); if($.hasValue(options.errors) && options.errors.length > 0){ var $errorTag = baseCont.find('.ocr-error:first'); if($errorTag.find('.alert-danger').length < 1){ $errorTag.find('.col-xs-12').append('' + (item.value[column.valueField]?item.value[column.valueField]:"") + ' | ';
});
t += '
' + (item.value[column.valueField]?item.value[column.valueField]:"") + ' | ';
});
t += '
'+data+' | '); }); if(idx == 0){ $tr.appendTo($thead); }else{ $tr.appendTo($tbody); } }); $tableElement.appendTo(self.$element); }, }; var OcrFileDownload = { name: 'OCR-Inc', version: '1.0.0', defaults: { url: null, data: null }, init: function(options, element) { this.$element = $(element); this.options = jQuery.extend({}, this.defaults, options); this.elementId = this.$element.attr('id'); this._setup(); return this; }, /* This will initialise the listeners on the elements and other setup related tasks */ _setup: function(){ /* manipulate the url as required :Rakesh Arora */ this.options.url = $.manipulateUrlForCountrycodes({url: this.options.url}); var self = this; $.fileDownload(self.options.url, { data: self.options.data }); }, }; /* Add created plugins */ $.plugin('processMsg', ProcessMsg); $.plugin('processRequest', ProcessRequest); $.plugin('ocrGrid', OcrGrid); $.plugin('getUserList', GetUserList); $.plugin('changeActiveSbu', ChangeActiveSbu); /* Add plugins for Modular Popup */ // PRJ-49_OCR_FTZ-001 added new popup $.plugin('modularPopup',ModularPopup); $.plugin('ocrSmartHints', ocrSmartHints); $.plugin('getMaxExportExcelSize', getMaxExportExcelSize); $.plugin('initMultiCountry', initMultiCountry); $.plugin('initMultiCountryCode', initMultiCountryCode); $.plugin('initializeDatePickers', initializeDatePickers); $.plugin('ocrTabs',OcrTabs); $.plugin('ocrFlagFields',OcrFlagFields); /* PRJ-645: Adding created plugins for flex field(s) components*/ $.plugin('ocrSmartHintsFileTypeRecords', ocrSmartHintsFileTypeRecords); $.plugin('ocrCreateSearchFlexFields', ocrCreateSearchFlexFields); $.plugin('ocrCreateEditPageFlexFields', ocrCreateEditPageFlexFields); /* added the graphs support */ $.plugin('ocrPieGraphs', OcrPieGraphs); $.plugin('ocrGraphs', OcrGraphs); $.plugin('ocrSimpleTableGraph', OcrSimpleTableGraph); $.plugin('ocrFileDownload', OcrFileDownload); /* Register events for request processing */ $(document).on('click.processRequest.api', '[data-ocr-role="menu-link"], [data-ocr-role="ajax-link"], [data-ocr-role="modal-link"], [data-ocr-role="frame-link"], [data-ocr-role="tab-link"]', function(e){ $(this).blur(); $(this).processRequest(); e.preventDefault(); return false; }); $(document).on('submit.processRequest.api', '[data-ocr-role="ajax-form"], [data-ocr-role="modal-form"]', function(e){ $(this).processRequest(); e.preventDefault(); return false; }); $(document).on('submit.processRequest.api', '[data-ocr-role="native-form"]', function(e){ e.preventDefault(); return false; }); $(document).on('click.changeActiveSbu.api', '[data-ocr-role="sbu-select"]', function(e){ $(this).changeActiveSbu(); e.preventDefault(); return false; }); $(document).ready(function(){ $(document).getMaxExportExcelSize(); var ie = (function(){ var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '', all[0] ); return v > 4 ? v : undef; }()); if(ie == '8') $("html").addClass("lt-ie9"); if(ie == '9') $("html").addClass("lt-ie10"); var userAgent = navigator.userAgent; if(userAgent != null && userAgent.indexOf("MSIE 10.0") > -1){ $("html").addClass("ie10"); } /** collaps plus and minus icon*****************/ $('.slidingDiv').find('.show_hide').addClass("shChild"); $(".slidingDiv").hide(); $('.show_hide').click(function( e ){ var that = this; var children = $(this).closest('li').closest('li:not(.open)').find('.shChild').length; if(children){ if(children > 0){ if($(this).hasClass('shChild')){ toggleMenu(that); }else{ closeMenu(that); toggleMenu(that); } } }else{ closeMenu(that); toggleMenu(that); } }); var closeMenu = function (that){ if($(that).closest('li').find('.fa-minus-square').length == 0){ $('.fa-minus-square').closest('li').find('.slidingDiv').hide(300); $('.menu-width').find(".fa-minus-square").removeClass("fa-minus-square").addClass("fa-plus-square"); } }; var toggleMenu = function (that){ $(that).next(".slidingDiv").slideToggle(); if($(that).find(".fa-plus-square").length > 0) $(that).find(".fa-plus-square").removeClass("fa-plus-square").addClass("fa-minus-square"); else if($(that).find(".fa-minus-square").length > 0) $(that).find(".fa-minus-square").removeClass("fa-minus-square").addClass("fa-plus-square"); }; /* fix for rendering the icons correctly */ setTimeout(function(){ $.makeIe8FontCompatibile(); },20); }); /***************************** Menu Filter Start*****************/ $('.box').keyup(function(){ var valThis = $(this).val().toLowerCase(); var noresult = 0; if(valThis == ""){ //$('.navList > li').show(); $(this).closest('ul.navList').find('li').show(); $(this).parent().find(".fa-minus-square").trigger('click'); noresult = 1; $('.no-results-found').remove(); } else { var $tobeOpened = null; $(this).closest('ul.navList').find('li').each(function(){ var text = $(this).text().toLowerCase(); var match = text.indexOf(valThis); if (match >= 0) { $(this).show(); if($(this).closest('ul').closest('div').closest('li').find(".fa-plus-square:first").length > 0 && $tobeOpened == null) $tobeOpened = $(this).closest('ul').closest('div').closest('li').find(".fa-plus-square:first"); } else { $(this).hide(); } }); if($tobeOpened){ //alert("here its found"); $tobeOpened.trigger('click'); }else{ //alert("here not found"); } }; //if (noresult == 0) { // $(".navList").append('