1 $(document).ready(function() {
2 $('#submit_update').hide();
4 $("#sms_add_form").hide();
5 $("#new_provider").on("click",function(){
8 $(".edit").on("click",function(e){
10 var providerid = $(this).data("providerid");
11 edit_provider( providerid );
13 $(".delete").on("click",function(e){
15 var providerid = $(this).data("providerid");
16 var patrons_using = $(this).data("patrons_using");
17 if( patrons_using !== "" ){
18 delete_provider( providerid, patrons_using );
20 delete_provider( providerid );
23 $(".cancel_edit").on("click",function(e){
29 function clear_form(){
30 $("#id,#name,#domain").val("");
33 function add_provider(){
36 $("legend").text( LABEL_SMS_ADD_PROVIDER );
37 $("#toolbar,#submit_update,#providerst").hide();
38 $("#sms_add_form,#submit_save").show();
42 function edit_provider( id ) {
44 $("legend").text( LABEL_SMS_EDIT_PROVIDER.format( $("#name_" + id).text() ) );
45 $("#sms_add_form,#submit_update").show();
48 $("#name").val( $("#name_" + id).text() );
49 $("#domain").val( $("#domain_" + id).text() );
51 $("#toolbar,#submit_save,#providerst").hide();
57 function cancel_edit() {
60 $("#sms_add_form,#submit_update").hide();
61 $("#toolbar,#submit_save,#providerst").show();
64 function delete_provider( id, users ) {
67 c = confirm( MSG_SMS_PATRONS_USING.format( $("#name_" + id).html(), users ) );
69 c = confirm( MSG_SMS_DELETE_CONFIRM.format( $("#name_" + id).html() ) );
73 $("#op").val('delete');
75 $("#sms_form").submit();