// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) // // MIT License (MIT) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // search_fields = {}; // Search Selector 2.0 // ------------------- function setlinkvalue(name) { //selector.input.set(name);// in local - this will be set onchange selector.input.set_input_value(name); // on screen selector.hide(); } // Link Selector // ------------- function makeselector() { var d = new Dialog(540,440, 'Search'); d.make_body([ ['HTML', 'Help'], ['Data', 'Beginning With', 'Tip: You can use wildcard "%"'], ['Select', 'Search By'], ['Button', 'Search'], ['HTML', 'Result'] ]); // search with var inp = d.widgets['Beginning With']; var field_sel = d.widgets['Search By']; var btn = d.widgets['Search']; // result d.sel_type = ''; d.values_len = 0; d.set = function(input, type, label) { d.sel_type = type; d.input = input; if(d.style!='Link') { d.rows['Result'].innerHTML =''; d.values_len = 0; } d.style = 'Link'; d.set_query_description() if(!d.sel_type)d.sel_type = 'Value'; d.set_title("Select"); d.set_query_description('Select a "'+ d.sel_type +'" for field "'+label+'"'); } d.set_search = function(dt) { if(d.style!='Search') { d.rows['Result'].innerHTML =''; d.values_len = 0; } d.style = 'Search'; if(d.input) { d.input = null; sel_type = null; } d.sel_type = dt; d.set_title('Quick Search for ' + dt); } $(inp).keydown(function(e) { if(e.which==13) { if(!btn.disabled)btn.onclick(); } }) d.set_query_description = function(txt) { txt = d.input && d.input.query_description || txt; if(txt) { d.rows['Help'].innerHTML ='
' + txt + '
'; } else { d.rows['Help'].innerHTML ='' } } d.onshow = function() { if(d.set_doctype!=d.sel_type) { d.rows['Result'].innerHTML =''; d.values_len = 0; } inp.value = ''; if(d.input && d.input.txt.value) { inp.value = d.input.txt.value; } try{inp.focus();} catch(e){} if(d.input) d.input.set_get_query(); // temp function to strip labels from search fields var get_sf_list = function(dt) { var l = []; var lf = search_fields[dt]; for(var i=0; i