Advertisement
pjmakey2

javascript_feo

Aug 13th, 2013
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 12.82 KB | None | 0 0
  1. var hacer_tables = {
  2.     bt_tables: function(id_tabla){
  3.         $.extend($.tablesorter.themes.bootstrap, {
  4.                         // these classes are added to the table. To see other table classes available,
  5.                         // look here: http://twitter.github.com/bootstrap/base-css.html#tables
  6.                         table      : 'table table-bordered',
  7.                         header     : 'bootstrap-header', // give the header a gradient background
  8.                         footerRow  : '',
  9.                         footerCells: '',
  10.                         icons      : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
  11.                         sortNone   : 'bootstrap-icon-unsorted',
  12.                         sortAsc    : 'icon-chevron-up',
  13.                         sortDesc   : 'icon-chevron-down',
  14.                         active     : '', // applied when column is sorted
  15.                         hover      : '', // use custom css here - bootstrap class may not override it
  16.                         filterRow  : '', // filter row class
  17.                         even       : '', // odd row zebra striping
  18.                         odd        : ''  // even row zebra striping
  19.         });
  20.  
  21.         $(id_tabla).tablesorter(
  22.                 {
  23.                     // this will apply the bootstrap theme if "uitheme" widget is included
  24.                     // the widgetOptions.uitheme is no longer required to be set
  25.                     theme : "bootstrap",
  26.                     widthFixed: true,
  27.                     headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
  28.                     // widget code contained in the jquery.tablesorter.widgets.js file
  29.                     // use the zebra stripe widget if you plan on hiding any rows (filter widget)
  30.                     widgets : [ "uitheme", "filter", "zebra" ],
  31.                     widgetOptions : {
  32.                       // using the default zebra striping class name, so it actually isn't included in the theme variable above
  33.                       // this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden
  34.                       zebra : ["even", "odd"],
  35.                       // reset filters button
  36.                       filter_reset : ".reset"
  37.                       // set the uitheme widget to use the bootstrap theme class names
  38.                       // this is no longer required, if theme is set
  39.                       // ,uitheme : "bootstrap"
  40.                     }
  41.                 }
  42.         ).tablesorterPager({
  43.         // target the pager markup - see the HTML block below
  44.         container: $(".pager"),
  45.         // target the pager page select dropdown - choose a page
  46.         cssGoto  : ".pagenum",
  47.         // remove rows from the table to speed up the sort of large tables.
  48.         // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
  49.         removeRows: false,
  50.         // output string - default is '{page}/{totalPages}';
  51.         // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
  52.         output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'
  53.                 });
  54.     },
  55.     big_tables: function(id_tabla){
  56.         $.extend($.tablesorter.themes.bootstrap, {
  57.                         // these classes are added to the table. To see other table classes available,
  58.                         // look here: http://twitter.github.com/bootstrap/base-css.html#tables
  59.                         table      : 'table table-bordered',
  60.                         header     : 'bootstrap-header', // give the header a gradient background
  61.                         footerRow  : '',
  62.                         footerCells: '',
  63.                         icons      : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
  64.                         sortNone   : 'bootstrap-icon-unsorted',
  65.                         sortAsc    : 'icon-chevron-up',
  66.                         sortDesc   : 'icon-chevron-down',
  67.                         active     : '', // applied when column is sorted
  68.                         hover      : '', // use custom css here - bootstrap class may not override it
  69.                         filterRow  : '', // filter row class
  70.                         even       : '', // odd row zebra striping
  71.                         odd        : ''  // even row zebra striping
  72.         });
  73.  
  74.         $(id_tabla).tablesorter(
  75.                 {
  76.                     // this will apply the bootstrap theme if "uitheme" widget is included
  77.                     // the widgetOptions.uitheme is no longer required to be set
  78.                     theme : "bootstrap",
  79.                     widthFixed: true,
  80.                     headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
  81.                     // widget code contained in the jquery.tablesorter.widgets.js file
  82.                     // use the zebra stripe widget if you plan on hiding any rows (filter widget)
  83.                     widgets : [ "uitheme", "filter", "zebra" ],
  84.                     widgetOptions : {
  85.                       // using the default zebra striping class name, so it actually isn't included in the theme variable above
  86.                       // this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden
  87.                       zebra : ["even", "odd"],
  88.                       // reset filters button
  89.                       filter_reset : ".reset"
  90.                       // set the uitheme widget to use the bootstrap theme class names
  91.                       // this is no longer required, if theme is set
  92.                       // ,uitheme : "bootstrap"
  93.                     }
  94.                 }
  95.         ).tablesorterPager({
  96.         // target the pager markup - see the HTML block below
  97.         container: $(".pager"),
  98.         // target the pager page select dropdown - choose a page
  99.         cssGoto  : ".pagenum",
  100.         // remove rows from the table to speed up the sort of large tables.
  101.         // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
  102.         removeRows: true,
  103.         // output string - default is '{page}/{totalPages}';
  104.         // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
  105.         output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'
  106.                 });
  107.     }
  108. }
  109.  
  110.  
  111. var control_submit = {
  112.     no_enter: function(classname) {
  113.         $(classname).keypress(function(e){
  114.             if ( e.which == 13 ) return false;
  115.             if ( e.which == 13 ) e.preventDefault();
  116.         });
  117.     }
  118. }
  119.  
  120.  
  121. var esconder_comunes = {
  122.     identificadores: function(ids){
  123.         $(ids).hide();
  124.     }
  125. }
  126.  
  127.  
  128. var pedidos = {
  129.     //el codigo es asqueroso,
  130.     //pero no puedo meter python aqui
  131.     //y no pienso perder tiempo con pyjs
  132.     pro_repopular: function(){
  133.         $('.thumbnails').html('');
  134.         for (var index in pgh){
  135.             $('.thumbnails').append(
  136.                 this.pro_html(pgh[index])
  137.             );
  138.         }
  139.         this.pre_cantidades('.cant_fijas');
  140.         control_submit.no_enter('.noenter');
  141.     },
  142.  
  143.     pro_html: function(producto){
  144.         //esto es bastante aterrador, pero
  145.         //no encuentro otra manera, de no recargar la pagina o_O
  146.         outhtml = '<li class="span3">'+
  147.               '<div class="thumbnail">'+
  148.               ' <img src="'+producto.imagen+'" alt="product 1" class="img-rounded imgpp" >'+
  149.               '   <div class="caption">'+
  150.               '      <h4 style="text-align: center; color: #ffffff">'+producto.descripcion+'</h4>'+
  151.               '   <div class="btn-group-wrap">'+
  152.               '       <div class="btn-toolbar">'+
  153.               '         <div class="btn-group">'+
  154.               '             <button class="btn btn-primary btn-med cant_fijas" data-producto="'+producto.pk+'">1</button>'+
  155.               '         </div>'+
  156.               '           <div class="btn-group">'+
  157.               '                 <button class="btn btn-info btn-med cant_fijas" data-producto="'+producto.pk+'">2</button>'+
  158.               '           </div>'+
  159.               '           <div class="btn-group">'+
  160.               '               <button class="btn btn-success btn-med cant_fijas" data-producto="'+producto.pk+'">3</button>'+
  161.               '           </div>'+
  162.               '       </div>'+
  163.               '   </div>'+
  164.               '   <div class="btn-group-wrap">'+
  165.               '       <input  id="'+producto.pk+'_can" type="number" class="input-small cant_deli noenter" min="1" max="20" style="padding-bottom: 1px; margin-bottom: 1px; font-size: 20px; height: 40px;" />'+
  166.               '   </div>'+
  167.               '   <div class="btn-group-wrap">'+
  168.               '       <div class="btn-toolbar">'+
  169.               '           <div class="btn-group">'+
  170.               '               <button class="btn btn-warning btn-medc" data-producto="'+producto.pk+'">PEDIDO</button>'+
  171.               '           </div>'+
  172.               '           <div class="btn-group">'+
  173.               '               <button class="btn btn-danger btn-medc" data-producto="'+producto.pk+'">CONFIRMAR</button>'+
  174.               '           </div>'+
  175.               '       </div>'+
  176.               '   </div>'+
  177.               '       </div>'+
  178.               '</div>'+
  179.              '</li>'
  180.  
  181.         return outhtml
  182.     },
  183.  
  184.     pre_cantidades: function(clase){
  185.         $(clase).on('click', function(evt){
  186.             cantidad = evt.target.innerHTML;
  187.             pkpro = evt.target.getAttribute("data-producto");
  188.             console.log(pkpro);
  189.             inputo = $("#"+pkpro+"_can");
  190.             pedidos.cantidades_fijas({  pkpro: pkpro,
  191.                         inputo: inputo,
  192.                         cantidad: cantidad}
  193.             );
  194.         });
  195.     },
  196.  
  197.     realizarlo: function(pobj){
  198.         $.get(pobj.url, pobj.data, function(response){
  199.             $(pobj.target).html(response);
  200.         });
  201.     },
  202.     cantidades_fijas: function(obj) {
  203.         $("#ac_"+obj.pkpro).show();
  204.         obj.inputo.val(obj.cantidad);
  205.     },
  206.     buscar: function(pkpr){
  207.         var enc = false;
  208.         mensajes.ini_aba();
  209.         for (var index in pgl){
  210.             if (pgl[index].hasOwnProperty(pkpr)) {
  211.                 var producto = pgl[index][pkpr];
  212.                 enc = true;
  213.                 break;
  214.             }
  215.         }
  216.         if (enc === true) {
  217.             $('.thumbnails').html(
  218.                 this.pro_html(producto)
  219.             );
  220.             this.pre_cantidades('.cant_fijas');
  221.             control_submit.no_enter('.noenter');
  222.         }
  223.         else {
  224.             mensajes.error('VERIFIQUE EL CODIGO DEL PRODUCTO');
  225.             this.pro_repopular();
  226.         }
  227.     }
  228. };
  229.  
  230. var esperar = {
  231.     animated: function(bar){
  232.         var progress = setInterval(function() {
  233.             if (bar.width()==400) {
  234.                 clearInterval(progress);
  235.                 $('.progress').removeClass('active');
  236.             } else {
  237.                 bar.width(bar.width()+40);
  238.             }
  239.             bar.text(bar.width()/4 + "%");
  240.         }, 800);
  241.         return progress;
  242.     },
  243.     definir: function(){
  244.         bar ='<br><br><br><br><br><br><div class="container" style="text-align: center"; margin-top: 200px;>'
  245.             +'<div class="progress progress-striped active">'
  246.             +'<div class="bar" style="width: 0%;"></div>'
  247.             +'</div>'
  248.             +'</div>'
  249.         return bar;
  250.     },
  251.     procesando: function(){
  252.         bar = $('<div class="modal hide pro_dia" data-backdrop="static" data-keyboard="false">'
  253.         +'<div class="modal-header">'
  254.         +'    <h1>PROCESANDO...</h1>'
  255.         +'</div>'
  256.         +'<div class="modal-body">'
  257.         +    '<div class="progress progress-striped active">'
  258.         +        '<div class="bar" style="width: 100%;"></div>'
  259.         +    '</div>'
  260.         +'</div>'
  261.         +'</div>');
  262.  
  263.         return bar;
  264.     },
  265.     mostrar_dialogo: function(){
  266.         bar = this.procesando();
  267.         bar.modal();
  268.     },
  269.     cerrar_dialogo: function(){
  270.         $('.pro_dia').modal('hide');
  271.     }
  272. }
  273.  
  274. var mensajes = {
  275.     ini_aba: function() {
  276.         Messenger.options = {
  277.         extraClasses: 'messenger-fixed messenger-on-bottom',
  278.         theme: 'future'
  279.         }
  280.     },
  281.     ini_arri: function() {
  282.         Messenger.options = {
  283.         extraClasses: 'messenger-fixed messenger-on-top',
  284.         theme: 'future'
  285.         }
  286.     },
  287.  
  288.     error: function(mensaje){
  289.         Messenger().post({
  290.             message: mensaje,
  291.             type: 'error',
  292.             showCloseButton: true
  293.         });
  294.     },
  295.     exitos: function(mensaje) {
  296.         Messenger().post(mensaje);
  297.     }
  298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement