| [ Index ] |
PHP Cross Reference of zeList |
[Summary view] [Print] [Text view]
1 ( function($) { 2 inlineEditLink = { 3 init : function() { 4 var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); 5 t.type = 'link'; 6 t.what = '#' + t.type + '-'; 7 8 t.rows = $('tr.iedit'); 9 10 // prepare the edit rows 11 qeRow.keyup( function(e) { 12 if (e.which == 27) 13 return inlineEditLink.revert(); 14 }); 15 bulkRow.keyup( function(e) { 16 if (e.which == 27) 17 return inlineEditLink.revert(); 18 }); 19 20 $('a.cancel', qeRow).click( function() { 21 return inlineEditLink.revert(); 22 }); 23 $('a.save', qeRow).click( function() { 24 return inlineEditLink.save(this); 25 }); 26 $('input, select', qeRow).keydown( function(e) { 27 if (e.which == 13) 28 return inlineEditLink.save(this); 29 }); 30 31 $('a.cancel', bulkRow).click( function() { 32 return inlineEditLink.revert(); 33 }); 34 35 // add events 36 t.addEvents(t.rows); 37 38 // categories expandable? 39 $('span.catshow').click( function() { 40 $('.inline-editor ul.cat-checklist').addClass("cat-hover"); 41 $('.inline-editor span.cathide').show(); 42 $(this).hide(); 43 }); 44 45 $('span.cathide').click( function() { 46 $('.inline-editor ul.cat-checklist').removeClass("cat-hover"); 47 $('.inline-editor span.catshow').show(); 48 $(this).hide(); 49 }); 50 51 $('#doaction, #doaction2').click( function(e) { 52 var n = $(this).attr('id').substr(2); 53 if ($('select[name="' + n + '"]').val() == 'edit') { 54 e.preventDefault(); 55 t.setBulk(); 56 } else if ($('form#posts-filter tr.inline-editor').length > 0) { 57 t.revert(); 58 } 59 }); 60 61 $('#link-query-submit').click( function(e) { 62 if ($('form#posts-filter tr.inline-editor').length > 0) 63 t.revert(); 64 }); 65 66 67 }, 68 addEvents : function(r) { 69 r.each( function() { 70 var row = $(this); 71 $('a.editinline', row).click( function() { 72 inlineEditLink.edit(this); 73 return false; 74 }); 75 }); 76 }, 77 edit : function(id) { 78 var t = this; 79 t.revert(); 80 81 if (typeof (id) == 'object') 82 id = t.getId(id); 83 84 var fields = [ 'link_name', 'link_owner', '_status', 'tags_input','link_category' ]; 85 86 // add the new blank row 87 var editRow = $('#inline-edit').clone(true); 88 89 $('td', editRow).attr('colspan', 90 $('.widefat:first thead th:visible').length); 91 92 if ($(t.what + id).hasClass('alternate')) 93 $(editRow).addClass('alternate'); 94 $(t.what + id).hide().after(editRow); 95 96 // populate the data 97 var rowData = $('#inline_' + id); 98 99 for ( var f = 0; f < fields.length; f++) { 100 $(':input[name="' + fields[f] + '"]', editRow).val($('.' + fields[f], rowData).text()); 101 } 102 103 $('.link_description', editRow).html($('.link_description', rowData).text()); 104 105 $('.link_url', editRow).attr('href',$('._url', rowData).text()); 106 $('.link_url', editRow).text($('._url', rowData).text()); 107 108 // categories 109 var cats; 110 if (cats = $('.link_category', rowData).text()) { 111 cats = cats.split(','); 112 $('ul.cat-checklist :radio', editRow).val(cats); 113 $('ul.cat-checklist :checkbox', editRow).val(cats); 114 115 // @TODO set scrollbar position 116 /* 117 var el = document.getElementById('category-' + cats[0]); 118 el.scrollIntoView(); 119 $(el).css('color','red'); 120 */ 121 } 122 123 // handle the status 124 var status = $('._status', rowData).text(); 125 126 // show/hide ban reasons 127 $('.inline-edit-reason').hide(); 128 $('select[name="_status"]').change(function(e) { 129 var status = $(this).val(); 130 if(status == 'deny') $('.inline-edit-reason').show(); 131 else $('.inline-edit-reason').hide(); 132 }); 133 134 135 $(editRow).attr('id', 'edit-' + id).addClass('inline-editor') 136 .show(); 137 $('.ptitle', editRow).focus(); 138 139 140 // enable autocomplete for tags 141 $('tr.inline-editor textarea[name="tags_input"]').suggest( 142 'admin-ajax.php?action=ajax-tag-search', { 143 delay : 500, 144 minchars : 2, 145 multiple : true, 146 multipleSep : ", " 147 }); 148 return false; 149 }, 150 151 save : function(id) { 152 if( typeof(id) == 'object' ) 153 id = this.getId(id); 154 155 $('table.widefat .inline-edit-save .waiting').show(); 156 157 var params = { 158 action: 'inline-link-save', 159 link_id: id, 160 }; 161 162 var fields = $('#edit-'+id+' :input').fieldSerialize(); 163 params = fields + '&' + $.param(params); 164 165 // make ajax request 166 $.post('admin-ajax.php', params, 167 function(r) { 168 $('table.widefat .inline-edit-save .waiting').hide(); 169 if (r) { 170 if ( -1 != r.indexOf('<tr') ) { 171 $(inlineEditLink.what+id).remove(); 172 $('#edit-'+id).before(r).remove(); 173 var row = $(inlineEditLink.what+id); 174 row.hide(); 175 row.find('.hide-if-no-js').removeClass('hide-if-no-js'); 176 inlineEditLink.addEvents(row); 177 row.fadeIn(); 178 } else { 179 r = r.replace( /<.[^<>]*?>/g, '' ); 180 $('#edit-'+id+' .inline-edit-save').append('<div class="error">'+r+'</div>'); 181 } 182 } else { 183 $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>'); 184 } 185 } 186 , 'html'); 187 return false; 188 }, 189 190 revert : function() { 191 var id; 192 193 if (id = $('table.widefat tr.inline-editor').attr('id')) { 194 $('table.widefat .inline-edit-save .waiting').hide(); 195 196 $('#' + id).remove(); 197 id = id.substr(id.lastIndexOf('-') + 1); 198 $(this.what + id).show(); 199 } 200 201 return false; 202 }, 203 204 getId : function(o) { 205 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'); 206 var parts = id.split('-'); 207 return parts[parts.length - 1]; 208 } 209 210 }; 211 212 $(document).ready( function() { 213 inlineEditLink.init(); 214 }); 215 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat May 30 23:51:06 2009 | Cross-referenced by PHPXref 0.7 |