Sha256: a9480f70d5e610b74b5ada304787aa874a6f843514a8444c8c9b62f78a3c548d
Contents?: true
Size: 1.79 KB
Versions: 8
Compression:
Stored size: 1.79 KB
Contents
$(function() { // clear search fields and results function clearLdapPersonSearchForm() { $('#first_name').val(''); $('#last_name').val(''); $("#lps-results").empty(); $('#matches').empty(); } function setHiddenField(link, dataAttribute) { var selector = '#' + dataAttribute; var value = link.data(dataAttribute); $(selector).val(value); } // add hidden fields to from coming from data attribute of link function setHiddenFields(link) { setHiddenField(link, 'search-field-name'); setHiddenField(link, 'result-link-http-method'); setHiddenField(link, 'result-link-text'); setHiddenField(link, 'result-link-class'); setHiddenField(link, 'result-link-url'); } function setSearchUrl(link) { var url = link.data('search-url'); var formAction = url == undefined ? '/ucb_rails/ldap_person_search' : url; $('form#lps-form').attr('action', formAction); } // open search dialog $('.ldap-person-search').click(function() { $('#lps-modal').modal('show'); var link = $(this); setHiddenFields(link); setSearchUrl(link) }); // Clear button $('#lps-clear').click(function() { clearLdapPersonSearchForm(); }); // modal shown $("#lps-modal").on('shown', function() { $("#first_name").focus(); }); // modal hidden $("#lps-modal").on('hide', function() { clearLdapPersonSearchForm(); }); // Default handler for search. Implementers should specify a result-link-class // data attribute on the element that starts the search. $(document).on('click', 'a.result-link-default', function (e) { var link = $(this); alert('Default click handler: ' + link.data('uid')); e.preventDefault(); hideLpsModal(); }); }); function hideLpsModal() { $("#lps-modal").modal('hide'); }
Version data entries
8 entries across 8 versions & 1 rubygems