1(function ($) { 2 Drupal.behaviors.sekoeko_barcode = { 3 4 attach: function (context, settings) { 5 6 // Warehouse functionality 7 Drupal.behaviors.sekoeko_barcode.warehouse(); 8 9 // Sell product page 10 Drupal.behaviors.sekoeko_barcode.sellProductPage(); 11 12 }, 13 14 // Warehouse functionality 15 warehouse: function(context){ 16 17 var $warehouseFiltersForm = $('#views-exposed-form-warehouse-view-page-1', context); 18 var $barcodeInput = $('#edit-field-barcode-value', $warehouseFiltersForm); 19 var $warehouseResultsForm = $('#views-form-warehouse-view-page-1'); 20 21 // Does form and barcode field exist 22 if(!$warehouseFiltersForm.length && !$barcodeInput.length){ 23 return; 24 } 25 26 // Focus & Select barcode field 27 $barcodeInput.focus().select(); 28 29 // Add increase/decrease buttons for in-stock field 30 $('.field-name-field-count-in-store', $warehouseResultsForm).each(function(i){ 31 // Check if this is already processed 32 if($(this).hasClass('js-processed')){ 33 return; 34 } 35 $(this).addClass('js-processed'); 36 37 var $countInStoreInput = $('input', $(this)); 38 var $countInStoreField = $('.form-item', $(this)); 39 40 $countInStoreField.prepend('<span class="s--plusminus s--decrease">-</span>'); 41 $countInStoreField.append('<span class="s--plusminus s--increase">+</span>'); 42 43 var $sDecreaseBtn = $('.s--decrease', $(this)); 44 var $sIncreaseBtn = $('.s--increase', $(this)); 45 46 // Add listener for decrease button 47 $sDecreaseBtn.click(function(e){ 48 var fieldVal = parseFloat($countInStoreInput.val()); 49 if(fieldVal > 0){ 50 $countInStoreInput.val(fieldVal - 1); 51 $countInStoreInput.change(); 52 } 53 }); 54 55 // Add listener for increase button 56 $sIncreaseBtn.click(function(e){ 57 var fieldVal = parseFloat($countInStoreInput.val()); 58 $countInStoreInput.val(fieldVal + 1); 59 $countInStoreInput.change(); 60 }); 61 62 }); 63 64 65 }, 66 67 // Sell product page 68 sellProductPage: function(context){ 69 70 var $sellProductPageFiltersForm = $('#views-exposed-form-sell-product-page-1', context); 71 var $barcodeInput = $('#edit-field-barcode-value', $sellProductPageFiltersForm); 72 var $sellProductPageResultsForm = $('#views-form-sell-product-page-1'); 73 74 // Does form and barcode field exist 75 if(!$sellProductPageFiltersForm.length && !$barcodeInput.length){ 76 return; 77 } 78 79 // Focus & Select barcode field 80 $barcodeInput.focus().select(); 81 82 // Hide error div @todo do 83 $('#console').hide(); 84 85 if($sellProductPageResultsForm.length){ 86 // Check if this is already processed 87 if($('body').hasClass('sell-product-processed')){ 88 return; 89 } 90 $('body').addClass('sell-product-processed'); 91 92 // Hide "submit" button after results 93 $('.form-actions', $sellProductPageResultsForm).hide(); 94 95 // Decrease value for in-stock field 96 $('.field-name-field-count-in-store', $sellProductPageResultsForm).each(function(i){ 97 98 var $countInStoreInput = $('input', $(this)); 99 100 // Decrease count in store 101 var fieldVal = parseFloat($countInStoreInput.val()); 102 103 if(fieldVal > 0){ 104 $countInStoreInput.val(fieldVal - 1); 105 setTimeout(function(){ 106 $countInStoreInput.change(); 107 $countInStoreInput.attr('disabled','disabled'); 108 }, 500); 109 } 110 111 }); 112 113 } 114 115 116 } 117 118 } 119 120})(jQuery); 121;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.