Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MPEG0 , MP ISP
- function view_modal(html){
- $("#common-modal .modal-dialog").removeClass("modal-sm");
- $("#common-modal .modal-dialog").removeClass("modal-lg");
- $("#common-modal .modal-dialog .modal-content").html(html);
- $("#common-modal").modal({backdrop: 'static'});
- }
- function view_modal_small(html){
- $("#common-modal .modal-dialog").removeClass("modal-lg");
- $("#common-modal .modal-dialog").addClass("modal-sm");
- $("#common-modal .modal-dialog .modal-content").html(html);
- $("#common-modal").modal({backdrop: 'static'});
- }
- function view_modal_large(html){
- $("#common-modal .modal-dialog").removeClass("modal-sm");
- $("#common-modal .modal-dialog").addClass("modal-lg");
- $("#common-modal .modal-dialog .modal-content").html(html);
- $("#common-modal").modal({backdrop: 'static'});
- }
- function unEntity(str){
- return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
- }
- function hide_modal(){
- $("#common-modal").modal("hide");
- }
- function setDangerMessage(val, id){
- id += "_danger";
- setGenericMessage(val, id);
- }
- function setSuccessMessage(val, id){
- id += "_success";
- setGenericMessage(val, id);
- }
- function setGenericMessage(val, id){
- id = "#"+id;
- $(".modal-message").addClass("hidden");
- $(id).html(val);
- $(id).removeClass("hidden");
- setTimeout(function(){$(id).addClass("hidden");}, 2000);
- }
- function setResponse(text, type){
- var id = "#common_response_"+type;
- $(".common-response").addClass("hidden");
- $(id).html(text);
- $(id).removeClass("hidden");
- $("#common-modal-response").modal();
- }
- function viewDanger(id){
- clearValidationStatus(id);
- $("#"+id).parents("div.form-group").addClass("has-error");
- $("#"+id).parents("div.form-group").addClass("has-feedback");
- $("#"+id).next("span.form-control-feedback").addClass("glyphicon-remove");
- }
- function viewSuccess(id){
- clearValidationStatus(id);
- $("#"+id).parents("div.form-group").addClass("has-success");
- $("#"+id).parents("div.form-group").addClass("has-feedback");
- $("#"+id).next("span.form-control-feedback").addClass("glyphicon-ok");
- }
- function viewWarning(id){
- clearValidationStatus(id);
- $("#"+id).parents("div.form-group").addClass("has-warning");
- $("#"+id).parents("div.form-group").addClass("has-feedback");
- $("#"+id).next("span.form-control-feedback").addClass("glyphicon-warning-sign");
- }
- function clearValidation(){
- $("div.form-group").each(function(){
- $(this).removeClass("has-warning");
- $(this).removeClass("has-success");
- $(this).removeClass("has-error");
- $(this).removeClass("has-feedback");
- });
- $("span.form-control-feedback").each(function(){
- $(this).removeClass("glyphicon-ok");
- $(this).removeClass("glyphicon-warning-sign");
- $(this).removeClass("glyphicon-remove");
- });
- }
- function clearValidationStatus(id){
- $("#"+id).parents("div.form-group").removeClass("has-warnings");
- $("#"+id).parents("div.form-group").removeClass("has-success");
- $("#"+id).parents("div.form-group").removeClass("has-error");
- $("#"+id).parents("div.form-group").removeClass("has-feedback");
- $("#"+id).next("span.form-control-feedback").removeClass("glyphicon-warning-sign");
- $("#"+id).next("span.form-control-feedback").removeClass("glyphicon-ok");
- $("#"+id).next("span.form-control-feedback").removeClass("glyphicon-remove");
- }
- function setDanger(text){
- setResponse(text, "danger");
- }
- function setInfo(text){
- setResponse(text, "info");
- }
- function setWarning(text){
- setResponse(text, "warning");
- }
- function setSuccess(text){
- setResponse(text, "success");
- }
- function refreshCart(n){
- $("#cart_items").html(n);
- }
- function isInt(n){
- return Number(n)==n && n%1===0;
- }
- function isFloat(n){
- return n==Number(n) && n%1!==0
- }
- //Arguments :
- //verb : 'GET'|'POST'
- //target : an optional opening target (a name, or "_blank"), defaults to "_self"
- function openUrl(verb, url, data, target) {
- var form = document.createElement("form");
- form.action = url;
- form.method = verb;
- form.target = target || "_self";
- if (data) {
- for (var key in data) {
- var input = document.createElement("textarea");
- input.name = key;
- input.value = typeof data[key] === "object" ? JSON.stringify(data[key]) : data[key];
- form.appendChild(input);
- }
- }
- form.style.display = 'none';
- document.body.appendChild(form);
- form.submit();
- };
- function formatNumberAsItCurrencyStr(nStr)
- {
- nStr = nStr.toFixed(2);
- x = nStr.split('.');
- x1 = x[0];
- x2 = x.length > 1 ? ',' + x[1] : ',00';
- var rgx = /(\d+)(\d{3})/;
- while (rgx.test(x1)) {
- x1 = x1.replace(rgx, '$1' + '\.' + '$2');
- }
- return x1 + x2;
- }
- function parseItCurrencyStrAsNumber(nStr)
- {
- var valueAsNumberStr = nStr.replace(/\./g,"").replace(",",".")
- if (valueAsNumberStr.length > 0) {
- return parseFloat(valueAsNumberStr);
- } else {
- return 0;
- }
- }
- function queryStringToJSON (qs) {
- var pairs = qs.split('&');
- var result = {};
- pairs.forEach(function(pair) {
- pair = pair.split('=');
- result[pair[0]] = decodeURIComponent(pair[1] || '');
- });
- return JSON.parse(JSON.stringify(result));
- }
- function dateToStr (date){
- var dd = date.getDate();
- var mm = date.getMonth()+1;
- var yyyy = date.getFullYear();
- return ""+dd+"/"+((""+mm).length>1?mm:"0"+mm)+"/"+yyyy;
- }
- function validCF(cf){
- var regex = /[A-Z]{6}[\d]{2}[A-Z][\d]{2}[A-Z][\d]{3}[A-Z]/;
- return cf.match(regex);
- }
- function getRadioValue(radioCssClass) {
- var radioValue = "";
- $(radioCssClass).each( function() {
- if (this.checked)
- {
- radioValue = $(this).val();
- }
- });
- return radioValue;
- }
- function controllo_data(stringa){
- var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
- if (!espressione.test(stringa))
- {
- return false;
- }else{
- anno = parseInt(stringa.substr(6),10);
- mese = parseInt(stringa.substr(3, 2),10);
- giorno = parseInt(stringa.substr(0, 2),10);
- var data=new Date(anno, mese-1, giorno);
- if(data.getFullYear()==anno && data.getMonth()+1==mese && data.getDate()==giorno){
- return true;
- }else{
- return false;
- }
- }
- }
- function pulisciFiltri() {
- $(".campo-filtro").each(function() {
- $(this).val("");
- });
- $(".tendina-filtro option:selected").each(function() {
- $(this).removeAttr("selected"); });
- $("#filtro_cod_stato option:first").attr("selected","selected");
- }
- $(function() {
- $(".dropdow-toggle").click(function(){
- e.stopPropagation();
- $(".dropdown-toggle").dropdown('toggle');
- // $(".dropdown-toggle").dropdown();
- });
- $(document).ajaxStart(function() {
- $("#loading_spinner").show();
- });
- $(document).ajaxStop(function() {
- $("#loading_spinner").hide();
- });
- if (typeof(gestioneDocumentiAnagrafe)!=='undefined')
- {
- gestioneDocumentiAnagrafe.init();
- }
- $("input[readonly='readonly']").off("focus");
- $("input[readonly='readonly']").on("focus",function(event){
- $(this).blur();
- $(this).next("input, select, button").focus();
- });
- (function () {
- var old = {};
- $("body").off("change",".calendar").off("focus",".calendar");
- $("body").on("focus", function(){
- old[this.id] = this.value;
- }).on("change",".calendar",function(event){
- var dt = this.value;
- if (dt != "")
- {
- var risposta = controllo_data(dt);
- if (!risposta)
- {
- alert("Formato Data Errato");
- this.value = old[this.id];
- $(this).focus();
- }
- }
- old[this.id] = this.value;
- });
- })();
- $("body").off("click",".btn-pulisci-filtri");
- $("body").on("click",".btn-pulisci-filtri",function(event){
- pulisciFiltri();
- });
- $("body").off("click",".cf-help");
- $("body").on("click",".cf-help",function(event){
- var cf = $(this).text(); //cf
- var menu = $(".btn-warning").text(); //leggo la tendina dove sono
- $.post("helpCFUtil.action?cf="+cf+"&menu="+menu,function(html){
- view_modal(html);
- });
- });
- $("body").off("click",".fer-help");
- $("body").on("click",".fer-help",function(event){
- var p = $(this).text(); //pratica
- var menu = $(".btn-warning").text(); //leggo la tendina dove sono
- $.post("helpFermoPraticaUtil.action?pratica="+p+"&menu="+menu,function(html){
- view_modal(html);
- });
- });
- $("body").off("click",".pol-help");
- $("body").on("click",".pol-help",function(event){
- var p = $(this).text(); //polizza
- var menu = $(".btn-warning").text(); //leggo la tendina dove sono
- $.post("helpPolizzaUtil.action?p="+p+"&menu="+menu,function(html){
- view_modal(html);
- });
- });
- $('#loading_spinner').hide(); //Hide our preloader
- $('[data-toggle="tooltip"]').tooltip();
- $("#common-modal-response").on('shown.bs.modal', function () {
- setTimeout(function(){
- $("#common-modal-response").modal('hide');
- }, 2000);
- });
- if (jQuery.validator) {
- jQuery.validator.setDefaults({
- debug: true,
- errorClass: 'has-error',
- validClass: 'has-success',
- ignore: ":hidden",
- highlight: function (element, errorClass, validClass) {
- $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
- },
- unhighlight: function (element, errorClass, validClass) {
- $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
- $(element).closest('.form-group').find('.help-block').text('');
- },
- errorPlacement: function (error, element) {
- $(element).closest('.form-group').find('.help-block').text(error.text());
- },
- submitHandler: function (form) {
- if ($(form).valid()) {
- form.submit();
- }
- }
- });
- }
- });
- function checkUndefinedOrNull(o){
- if(o == undefined || o == null)
- return o = "";
- else
- return o;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement