| 98 | | |
|---|
| 99 | | <script type="text/javascript"> |
|---|
| 100 | | $(document).ready(function(){ |
|---|
| 101 | | //show/hide add button/dropdown |
|---|
| 102 | | $('#addbut').click(function(){ |
|---|
| 103 | | $('#addusersel').val('none');//reset select box |
|---|
| 104 | | $(this).fadeOut(250, |
|---|
| 105 | | function(){ |
|---|
| 106 | | $('#addrow').fadeIn(250); |
|---|
| 107 | | }); |
|---|
| 108 | | return false; |
|---|
| 109 | | }); |
|---|
| 110 | | |
|---|
| 111 | | //add row button |
|---|
| 112 | | $('#addrow').change(function(){ |
|---|
| 113 | | $(this).fadeOut(250, |
|---|
| 114 | | function(){ |
|---|
| 115 | | $('#addbut').not("span").fadeIn(250).find("span").hide(); |
|---|
| 116 | | }); |
|---|
| 117 | | if($('#addusersel').val() != 'none'){ |
|---|
| 118 | | var rownum=$('[class^=entrie]').length+1; |
|---|
| 119 | | //increment id untill we find one that isnt being used |
|---|
| 120 | | while($('.entrie' + rownum).length == 1){ |
|---|
| 121 | | rownum++; |
|---|
| 122 | | } |
|---|
| 123 | | addrow($('#addusersel').val() + '|' + rownum); |
|---|
| 124 | | } |
|---|
| 125 | | return false; |
|---|
| 126 | | }); |
|---|
| 127 | | |
|---|
| 128 | | //set toggle value for text-box hint text |
|---|
| 129 | | $(".dpt-title").toggleVal({ |
|---|
| 130 | | populateFrom: "title", |
|---|
| 131 | | changedClass: "text-normal", |
|---|
| 132 | | focusClass: "text-normal" |
|---|
| 133 | | }); |
|---|
| 134 | | $("form").submit(function() { |
|---|
| 135 | | $(".dpt-title").each(function() { |
|---|
| 136 | | if($(this).val() == $(this).data("defText")) { |
|---|
| 137 | | $(this).val(""); |
|---|
| 138 | | } |
|---|
| 139 | | }); |
|---|
| 140 | | }); |
|---|
| 141 | | |
|---|
| 142 | | //delete row when trash can is clicked |
|---|
| 143 | | $('.trash-tr').live('click', function(){ |
|---|
| 144 | | $(this).parents('tr').fadeOut(500, |
|---|
| 145 | | function(){ |
|---|
| 146 | | $(this).remove() |
|---|
| 147 | | }) |
|---|
| 148 | | }); |
|---|
| 149 | | |
|---|
| 150 | | |
|---|
| 151 | | }); |
|---|
| 152 | | |
|---|
| 153 | | |
|---|
| 154 | | //add a new entry to the table |
|---|
| 155 | | function addrow(user){ |
|---|
| 156 | | $.ajax({ |
|---|
| 157 | | type: 'POST', |
|---|
| 158 | | url: location.href, |
|---|
| 159 | | data: 'ajaxgettr='+encodeURIComponent(user)+'&quietmode=1&skip_astman=1', |
|---|
| 160 | | success: function(data) { |
|---|
| 161 | | $('#dir_entries_tbl > tbody:last').append(data); |
|---|
| 162 | | /* now re-apply toggleval - redundant but they may have appended multipe values so... */ |
|---|
| 163 | | $(".dpt-title").not('.text-normal').toggleVal({ |
|---|
| 164 | | populateFrom: "title", |
|---|
| 165 | | changedClass: "text-normal", |
|---|
| 166 | | focusClass: "text-normal" |
|---|
| 167 | | }); |
|---|
| 168 | | }, |
|---|
| 169 | | error: function(XMLHttpRequest, textStatus, errorThrown) { |
|---|
| 170 | | var msg = "<?php echo _("An Error occurred trying to contact the server adding a row, no reply.")?>"; |
|---|
| 171 | | alert(msg); |
|---|
| 172 | | } |
|---|
| 173 | | }); |
|---|
| 174 | | } |
|---|
| 175 | | </script> |
|---|
| 176 | | |
|---|