1/** 2 * Have default functions to operate with data numeric 3 * @pakage filter.data.numeric 4 * @author Eduardo Aparicio Cardenes 5 * @version 1.0 6 **/ 7 8/** 9 * Sort operator method on this data type 10 **/ 11Filter.method('data_type.numeric.op_sort', function() { 12 return this['data_type.common.op_sort'](); 13}); 14/** 15 * Search operator method on this data type 16 **/ 17Filter.method('data_type.numeric.op_search', function(obj, target, value, ctxt) { 18 return this['data_type.common.op_search'](obj, target, value, ctxt); 19}); 20 21/** 22 * Filter operator method on this data type 23 **/ 24Filter.method('data_type.numeric.op_filter', function(obj, target, value, ctxt) { 25 return this['data_type.common.op_search'](obj, target, value, ctxt); 26}); 27 28Filter.method('data_type.numeric.view_render', function(container) { 29 //add sliders 30 container.find(".slider-numeric").each(function() { 31 var slider = $(this); 32 var wrapper = $(this).parent(); 33 var max_ = parseFloat(wrapper.find("#val_max").val()); 34 var min_ = parseFloat(wrapper.find("#val_min").val()); 35 var step_ = parseFloat(wrapper.find("#val_step").val()); 36 slider.slider({ 37 range: true, 38 min: min_, 39 step: step_, 40 max: max_, 41 values: [min_, max_], 42 slide: function(event, ui) { 43 wrapper.find("#divSlider-numeric").html(ui.values[0] + " - " + ui.values[1]); 44 wrapper.find("#actual_min").val(ui.values[0]); 45 wrapper.find("#actual_max").val(ui.values[1]); 46 } 47 }); 48 }); 49}); 50/** 51 * create data box on this data type 52 **/ 53Filter.method('data_type.numeric.create_data_box', function(id, box) { 54 var box_to_insert = this['data_type.common.create_data_box'](id, box); 55 box_to_insert.max = Number.MAX_VALUE; //data[0][filter.field]; 56 box_to_insert.min = 0; //data[0][filter.field]; 57 box_to_insert.step = 1; //data[0][filter.field]; 58 return box_to_insert; 59}); 60 61/** 62 * create data box on this data type 63 **/ 64Filter.method('data_type.numeric.create_data_box', function(id, filter, data) { 65 var _self = this; 66 var max = Number.MIN_VALUE; //data[0][filter.field]; 67 var min = Number.MAX_VALUE; //data[0][filter.field]; 68 var step = 1; //data[0][filter.field]; 69 var box_to_insert = { 70 title: filter.title, 71 name: filter.name, //(filter.title.length > 20)?filter.title.substring(0,17)+'...':filter.title, 72 type: filter.type, 73 subtype: filter.subtype, 74 el_id: id, 75 field: filter.field 76 }; 77 78 79 if (isNaN(filter.max) || isNaN(filter.min)) { 80 $.each(data, function(ky, dat) { 81 var value = Number(_self.depth_inside(filter.field, dat)); 82 if (value != null) { 83 if (value >= max) 84 max = value; 85 if (value <= min) 86 min = value; 87 } 88 }); 89 //Actualize max and min to ajust data set 90 filter.max = max; 91 filter.min = min; 92 } else { //If the user predefined value assing to filterBox 93 max = filter.max; 94 min = filter.min; 95 } 96 97 if (typeof filter.step != "undefined" && !isNaN(filter.step)) { 98 step = filter.step; 99 } 100 //Initialize data box 101 box_to_insert.max = max; 102 box_to_insert.min = min; 103 box_to_insert.step = step; 104 return box_to_insert; 105}); 106/** 107 * Reset filter box view, when don't have panorama info 108 */ 109Filter.method('data_type.numeric.reset_box', function(container, filter) { 110 var _self = this; 111 container.find(".slider-numeric:first").slider({ 112 range: true, 113 min: parseFloat(container.find("#val_min").val()), 114 max: parseFloat(container.find("#val_max").val()), 115 step: parseFloat(container.find("#val_step").val()), 116 values: [filter.min, filter.max], 117 slide: function(event, ui) { 118 container.find("#divSlider-numeric").html(ui.values[0] + " - " + ui.values[1]); 119 container.find("#actual_min").val(ui.values[0]); 120 container.find("#actual_max").val(ui.values[1]); 121 } 122 }); 123 container.find("#actual_max").val(filter.max); 124 container.find("#actual_min").val(filter.min); 125 container.find("#divSlider-numeric").html(filter.min + " - " + filter.max); 126}); 127/** 128 * When we have panorama info fill filter box view 129 */ 130Filter.method('data_type.numeric.change_filter_box', function(container, filter) { 131 var _self = this; 132 container.find(".slider-numeric:first").slider({ 133 range: true, 134 min: parseFloat(container.find("#val_min").val()), 135 max: parseFloat(container.find("#val_max").val()), 136 step: parseFloat(container.find("#val_step").val()), 137 values: [filter.value.min, filter.value.max], 138 slide: function(event, ui) { 139 container.find("#divSlider-numeric").html(ui.values[0] + " - " + ui.values[1]); 140 container.find("#actual_min").val(ui.values[0]); 141 container.find("#actual_max").val(ui.values[1]); 142 } 143 }); 144 container.find("#actual_max").val(filter.value.max); 145 container.find("#actual_min").val(filter.value.min); 146 container.find("#divSlider-numeric").html(filter.value.min + " - " + filter.value.max); 147}); 148 149/** 150 * Create manager numeric events on data types 151 */ 152Filter.method('data_type.numeric.events', function(container, filter) { 153 var _self = this; 154 155 container.find("#active_filter_" + filter.el_id + " .slider-numeric:first").on("slidestop", function() { 156 var parent = $(this).parent().parent(); 157 var isValid = true; 158 var min_ = parseFloat(parent.find("#actual_min").val()); 159 var max_ = parseFloat(parent.find("#actual_max").val()); 160 if (min_ == filter.min && max_ == filter.max) { 161 isValid = false;
162 } 163 if (isValid) { 164 _self.addOperation("range", filter.field, { 165 min: min_, 166 max: max_ 167 }, "in", { id: filter.field, id_title: filter.el_id }); 168 } 169 var options; 170 //add filters actives 171 if (_self.filters.length > 0) { 172 $.each(_self.filters[_self.filters.length - 1], function(ky, op) { 173 if (typeof op.options != "undefined") { 174 options = op.options; 175 } else { 176 options = { id: op.id, id_title: op.id_title }; 177 } 178 if (op.options.id != filter.field) { 179 _self.addOperation(op.type, op.target, op.value, op.ctxt, options); 180 } 181 }); 182 } 183 if (_self.filter_callback && typeof(_self.filter_callback) == "function" && _self.getOnReadyFlag()) { 184 var result_applyFilter = _self.applyFilter(true); 185 //If have caller need to send info this object 186 if (_self.caller_obj) { 187 _self.filter_callback(result_applyFilter, _self.filtersBox, _self.caller_obj); 188 } else { 189 _self.filter_callback(result_applyFilter, _self.filtersBox); 190 } 191 192 } 193 _self.actualizeActiveFilters(container.find("#list_active_filters")); 194 195 if (_self.pv_filters_saved && _self.pv_filters_saved.parents("td:first")) { 196 _self.pv_filters_saved.parents("td:first").find(".details-filter:first .name-filter:first").html(internationalize("custom_filter", { 197 capitalize: true 198 })); 199 _self.pv_filters_saved.parents("td:first").find(".details-filter:first .description-filter:first").html(""); 200 } 201 }); 202 203 //Execute common data events 204 _self['data_type.common.events'](container, filter); 205});
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.