Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $(document).ready(function() {
  2.         // $('#myModal').modal('show');
  3.         $('[data-toggle="tooltip"]').tooltip();
  4.         $('.accordion-body.in').collapse('toggle');
  5.     });
  6.  
  7.     $(function() {
  8.         $('[data-toggle="popover"]').popover()
  9.     })
  10.     $('#tabListado').click(function(e) {
  11.         e.preventDefault()
  12.         $(this).tab('show');
  13.     });
  14.  
  15.    
  16.     var adjustment;
  17.  
  18.     $(function() {
  19.              var group = $("ul.ordenable").sortable({
  20.                  group: "ordenable",
  21.                  pullPlaceholder: true,
  22.                  handle: 'div.btn-default',
  23.                  vertical: true,
  24.                  onDragStart: function($item, container, _super) {
  25.                      var offset = $item.offset(),
  26.                         pointer = container.rootGroup.pointer;
  27.                
  28.                     adjustment = {
  29.                       left: pointer.left - offset.left,
  30.                       top: pointer.top - offset.top
  31.                     };
  32.                      _super($item, container);
  33.                  },
  34.                  onDrop: function($item, container, _super) {
  35.                      // Duplicate items of the no drop area
  36.                      var data = group.sortable("serialize").get();
  37.                      var jsonString = JSON.stringify(data, null, ' ');
  38.                     // alert((jsonString));
  39.                      
  40.                      var repartidor_id = $('#repartidor_id').val();
  41.                      $.ajax({
  42.                          data: {ids: jsonString},
  43.                          type: 'POST',
  44.                          dataType: "json",
  45.                          url: 'ajax/guardar_orden.php?repartidor_id=' + repartidor_id
  46.                      });
  47.                      
  48.                      _super($item, container);
  49.  
  50.                  }
  51.              });
  52.  
  53.  
  54.     });
  55.  
  56.  
  57.  
  58.     (function($) {
  59.         var topics = {};
  60.         $.publish = function(topic, args) {
  61.             if (topics[topic]) {
  62.                 var currentTopic = topics[topic],
  63.                     args = args || {};
  64.  
  65.                 for (var i = 0, j = currentTopic.length; i < j; i++) {
  66.                     currentTopic[i].call($, args);
  67.                 }
  68.             }
  69.         };
  70.         $.subscribe = function(topic, callback) {
  71.             if (!topics[topic]) {
  72.                 topics[topic] = [];
  73.             }
  74.             topics[topic].push(callback);
  75.             return {
  76.                 "topic": topic,
  77.                 "callback": callback
  78.             };
  79.         };
  80.         $.unsubscribe = function(handle) {
  81.             var topic = handle.topic;
  82.             if (topics[topic]) {
  83.                 var currentTopic = topics[topic];
  84.  
  85.                 for (var i = 0, j = currentTopic.length; i < j; i++) {
  86.                     if (currentTopic[i] === handle.callback) {
  87.                         currentTopic.splice(i, 1);
  88.                     }
  89.                 }
  90.             }
  91.         };
  92.     })(jQuery);
  93.  
  94.  
  95.  
  96.  
  97.     $(document).ready(function() {
  98.  
  99.  
  100.         // Ejecutar mostrar firma al abrir la modal
  101.         $('.carga').on('shown.bs.modal', function(e) {
  102.  
  103.             // Primero vaciamos el div por si ha sido cargado previamente
  104.             $("#signature").html('');
  105.             // Tambien la variable
  106.             var $sigdiv = '';
  107.             $tools = '';
  108.  
  109.  
  110.             // This is the part where jSignature is initialized.
  111.             var $sigdiv = $("#signature").jSignature({
  112.                 'UndoButton': true
  113.             })
  114.  
  115.             // All the code below is just code driving the demo.
  116.             , $tools = $('#tools'), $extraarea = $('#displayarea'), pubsubprefix = 'jSignature.demo.'
  117.  
  118.             var export_plugins = $sigdiv.jSignature('listPlugins', 'export'),
  119.                 chops = ['<span><b>Extract signature data as: </b></span><select>', '<option value="">(select export format)</option>'],
  120.                 name
  121.             for (var i in export_plugins) {
  122.                 if (export_plugins.hasOwnProperty(i)) {
  123.                     name = export_plugins[i]
  124.                     chops.push('<option value="' + name + '">' + name + '</option>')
  125.                 }
  126.             }
  127.             chops.push('</select><span><b> or: </b></span>')
  128.  
  129.             $(chops.join('')).bind('change', function(e) {
  130.                 if (e.target.value !== '') {
  131.                     var data = $sigdiv.jSignature('getData', e.target.value)
  132.                     $.publish(pubsubprefix + 'formatchanged')
  133.                     if (typeof data === 'string') {
  134.                         $('textarea', $tools).val(data)
  135.                     } else if ($.isArray(data) && data.length === 2) {
  136.                         $('textarea', $tools).val(data.join(','))
  137.                         $.publish(pubsubprefix + data[0], data);
  138.                     } else {
  139.                         try {
  140.                             $('textarea', $tools).val(JSON.stringify(data))
  141.                         } catch (ex) {
  142.                             $('textarea', $tools).val('Not sure how to stringify this, likely binary, format.')
  143.                         }
  144.                     }
  145.                 }
  146.             }).appendTo($tools)
  147.  
  148.  
  149.             $('<input type="button" value="Reset">').bind('click', function(e) {
  150.                 $sigdiv.jSignature('reset')
  151.             }).appendTo($tools)
  152.  
  153.             $('<div><textarea style="width:100%;height:7em;"></textarea></div>').appendTo($tools)
  154.  
  155.             $.subscribe(pubsubprefix + 'formatchanged', function() {
  156.                 $extraarea.html('')
  157.             })
  158.  
  159.             $.subscribe(pubsubprefix + 'image/svg+xml', function(data) {
  160.  
  161.                 try {
  162.                     var i = new Image()
  163.                     i.src = 'data:' + data[0] + ';base64,' + btoa(data[1])
  164.                     $(i).appendTo($extraarea)
  165.                 } catch (ex) {
  166.  
  167.                 }
  168.  
  169.                 var message = [
  170.                     "If you don't see an image immediately above, it means your browser is unable to display in-line (data-url-formatted) SVG.", "This is NOT an issue with jSignature, as we can export proper SVG document regardless of browser's ability to display it.", "Try this page in a modern browser to see the SVG on the page, or export data as plain SVG, save to disk as text file and view in any SVG-capabale viewer."
  171.                 ]
  172.                 $("<div>" + message.join("<br/>") + "</div>").appendTo($extraarea)
  173.             });
  174.  
  175.             $.subscribe(pubsubprefix + 'image/svg+xml;base64', function(data) {
  176.                 var i = new Image()
  177.                 i.src = 'data:' + data[0] + ',' + data[1]
  178.                 $(i).appendTo($extraarea)
  179.  
  180.                 var message = [
  181.                     "If you don't see an image immediately above, it means your browser is unable to display in-line (data-url-formatted) SVG.", "This is NOT an issue with jSignature, as we can export proper SVG document regardless of browser's ability to display it.", "Try this page in a modern browser to see the SVG on the page, or export data as plain SVG, save to disk as text file and view in any SVG-capabale viewer."
  182.                 ]
  183.                 $("<div>" + message.join("<br/>") + "</div>").appendTo($extraarea)
  184.             });
  185.  
  186.             $.subscribe(pubsubprefix + 'image/png;base64', function(data) {
  187.                 var i = new Image()
  188.                 i.src = 'data:' + data[0] + ',' + data[1]
  189.                 $('<span><b>As you can see, one of the problems of "image" extraction (besides not working on some old Androids, elsewhere) is that it extracts A LOT OF DATA and includes all the decoration that is not part of the signature.</b></span>').appendTo($extraarea)
  190.                 $(i).appendTo($extraarea)
  191.             });
  192.  
  193.             $.subscribe(pubsubprefix + 'image/jsignature;base30', function(data) {
  194.                 $('<span><b>This is a vector format not natively render-able by browsers. Format is a compressed "movement coordinates arrays" structure tuned for use server-side. The bonus of this format is its tiny storage footprint and ease of deriving rendering instructions in programmatic, iterative manner.</b></span>').appendTo($extraarea)
  195.             });
  196.  
  197.             if (Modernizr.touch) {
  198.                 $('#scrollgrabber').height($('#content').height())
  199.             }
  200.  
  201.         });
  202.  
  203.     })
  204.  
  205.  
  206.  
  207.     $(document).ready(function() {
  208.         // INICIO RELOJ /////
  209.         var currentdate = new Date();
  210.         var l = 0;
  211.  
  212.         function callme() {
  213.             currentdate = new Date();
  214.             $('.hour').html(currentdate.getHours());
  215.             $('.min').html(currentdate.getMinutes());
  216.             $('.second').html(currentdate.getSeconds());
  217.             $('.data').css({
  218.                 'padding-left': l + 'px'
  219.             });
  220.             l = l + 5;
  221.         }
  222.         window.setInterval(callme, 1000);
  223.         // FIN RELOJ /////
  224.  
  225.  
  226.  
  227.         // INICIO GEOLOCALIZACION /////
  228.  
  229.         function actualizarUbicacion() {
  230.             if (navigator.onLine) {
  231.                 navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
  232.             }
  233.         }
  234.  
  235.         window.setInterval(actualizarUbicacion, 60000);
  236.  
  237.         function foundLocation(position) {
  238.             var lat = position.coords.latitude;
  239.             var long = position.coords.longitude;
  240.             var repartidor_id = $('#repartidor_id').val();
  241.             //alert(repartidor_id);
  242.             $.get("ajax/guardar_localizacion.php", {
  243.                 repartidor_id: repartidor_id,
  244.                 lat: lat,
  245.                 long: long
  246.             });
  247.         }
  248.  
  249.         function noLocation() {
  250.  
  251.             var lat = 0;
  252.             var long = 0;
  253.             var repartidor_id = $('#repartidor_id').val();
  254.             $.get("ajax/guardar_localizacion.php", {
  255.                 repartidor_id: repartidor_id,
  256.                 lat: lat,
  257.                 long: long
  258.             });
  259.  
  260.         }
  261.  
  262.         // FIN GEOLOCALIZACION /////       
  263.  
  264.  
  265.  
  266.        
  267.        
  268.        
  269.        
  270.        
  271.         // DETECTAR FIRMA //
  272.         $(".BtnFirma").click(function(event) {
  273.            
  274.            
  275.             var id = $(this).data("id");
  276.             var data = $("#signature_" + id).jSignature('getData', 'image/svg+xml;base64');
  277.             var data_vacio = 'image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iMCIgaGVpZ2h0PSIwIj48L3N2Zz4=';
  278.             $extraarea = $('#resultadoFirma');
  279.             if(data != data_vacio){
  280.                 var i = new Image()
  281.                 i.src = 'data:' + data[0] + ',' + data[1]
  282.                 $(i).appendTo($extraarea);
  283.             }
  284.          
  285.          });
  286.          // DETECTAR FIRMA //
  287.    
  288.    
  289.    
  290.             // DETECTAR QUE LOS KILOS Y UNIDADES MODIFICADOS ESTAN DENTRO DE LOS RANGOS PERMITIDOS //
  291.         $(".cambiarUnidades").change(function(event) {
  292.            
  293.             var id = $(this).data("id");
  294.             var valor_original = parseInt($(this).data("original"));
  295.             var valor_actual = parseInt($(this).val());
  296.             if(valor_actual > valor_original){
  297.                  $( "#warning"+id ).html('<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> No puedes incrementar las unidades, solo reducirlas.');
  298.                  $( "#warning"+id ).show( "slow", function() {
  299.                     // Animation complete.
  300.                   });
  301.                 $(this).val(valor_original);
  302.                 $(this).focus();
  303.                 $('#guardarCambiosUnidadesKilos'+id).attr( "disabled", "disabled");
  304.                 return false;
  305.             }
  306.             if(valor_actual <= 0){
  307.                  $( "#warning"+id ).html('<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> Debes eliminar la línea en vez de poner las unidades a cero.');
  308.                  $( "#warning"+id ).show( "slow", function() {
  309.                     // Animation complete.
  310.                   });
  311.                 $(this).val(valor_original);
  312.                 $(this).focus();
  313.                 $('#guardarCambiosUnidadesKilos'+id).attr( "disabled", "disabled");
  314.                 return false;
  315.             }
  316.          
  317.          $( "#warning"+id ).hide( "slow", function() {
  318.                     // Animation complete.
  319.         });
  320.          $('#guardarCambiosUnidadesKilos'+id).removeAttr("disabled");
  321.          return true;
  322.          
  323.          });
  324.          
  325.         $(".cambiarPeso").change(function(event) {
  326.            
  327.             var id = $(this).data("id");
  328.             var valor_original = parseFloat($(this).data("original"));
  329.             var valor_actual = parseFloat($(this).val());
  330.             if(valor_actual > valor_original){
  331.                  $( "#warning"+id ).html('<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> No puedes incrementar los kilogramos, solo reducirlos.');
  332.                  $( "#warning"+id ).show( "slow", function() {
  333.                     // Animation complete.
  334.                   });
  335.                 $(this).val(valor_original);
  336.                 $(this).focus();
  337.                 $('#guardarCambiosUnidadesKilos'+id).attr( "disabled", "disabled");
  338.                 return false;
  339.             }
  340.             if(valor_actual <= 0){
  341.                  $( "#warning"+id ).html('<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> Debes eliminar la línea en vez de poner los kilogramos a cero.');
  342.                  $( "#warning"+id ).show( "slow", function() {
  343.                     // Animation complete.
  344.                   });
  345.                 $(this).val(valor_original);
  346.                 $(this).focus();
  347.                 $('#guardarCambiosUnidadesKilos'+id).attr( "disabled", "disabled");
  348.                 return false;
  349.             }
  350.          
  351.           $( "#warning"+id ).hide( "slow", function() {
  352.                     // Animation complete.
  353.         });
  354.          $('#guardarCambiosUnidadesKilos'+id).removeAttr("disabled");
  355.          return true;
  356.          
  357.          });
  358.          // DETECTAR QUE LOS KILOS Y UNIDADES MODIFICADOS ESTAN DENTRO DE LOS RANGOS PERMITIDOS //
  359.    
  360.    
  361.    
  362.             // PULSADO EL BOTON DE ELIMINAR LINEA //
  363.         $(".cseliminarlinea").click(function(event) {
  364.             event.preventDefault();
  365.             alert('aa');
  366.             var id = $(this).data("id");
  367.             // COMPROBAR QUE NO ESTE DESACTIVADO EL BOTON
  368.             var isDisabled = $(this).hasAttr('disabled');
  369.             if (isDisabled){
  370.                 alert('desactivado');
  371.                 return false;
  372.             }else{
  373.                
  374.             }
  375.          
  376.          });
  377.          // PULSADO EL BOTON DE ELIMINAR LINEA //
  378.  
  379.    
  380.  
  381.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement