PluginProbe
Edit Flow / 0.7.2
Edit Flow v0.7.2
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
edit-flow / modules / user-groups / lib / user-groups-configure.js

user-groups-configure.js in Edit Flow 0.7.2, at modules/user-groups/lib/user-groups-configure.js

115 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 inlineEditUsergroup = {
3
4 init : function() {
5 var t = this, row = $('#inline-edit');
6
7 t.what = '#usergroup-';
8
9 $('.editinline').live('click', function(){
10 inlineEditUsergroup.edit(this);
11 return false;
12 });
13
14 // prepare the edit row
15 row.keyup(function(e) { if(e.which == 27) return inlineEditUsergroup.revert(); });
16
17 $('a.cancel', row).click(function() { return inlineEditUsergroup.revert(); });
18 $('a.save', row).click(function() { return inlineEditUsergroup.save(this); });
19 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditUsergroup.save(this); });
20
21 $('#posts-filter input[type="submit"]').mousedown(function(e){
22 t.revert();
23 });
24 },
25
26 toggle : function(el) {
27 var t = this;
28 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
29 },
30
31 edit : function(id) {
32 var t = this, editRow;
33 t.revert();
34
35 if ( typeof(id) == 'object' )
36 id = t.getId(id);
37
38 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
39 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
40
41 if ( $(t.what+id).hasClass('alternate') )
42 $(editRow).addClass('alternate');
43
44 $(t.what+id).hide().after(editRow);
45
46 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
47 $(':input[name="description"]', editRow).val( $('.description', rowData).text() );
48
49 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
50 $('.ptitle', editRow).eq(0).focus();
51
52 return false;
53 },
54
55 save : function(id) {
56 var params, fields, tax = $('input[name="taxonomy"]').val() || '';
57
58 if( typeof(id) == 'object' )
59 id = this.getId(id);
60
61 $('table.widefat .inline-edit-save .waiting').show();
62
63 params = {
64 action: 'inline_save_usergroup',
65 usergroup_id: id,
66 };
67
68 fields = $('#edit-'+id+' :input').serialize();
69 params = fields + '&' + $.param(params);
70
71
72 // make ajax request
73 $.post(ajaxurl, params,
74 function(r) {
75 var row, new_id;
76 $('table.widefat .inline-edit-save .waiting').hide();
77
78 if (r) {
79 if ( -1 != r.indexOf('<tr') ) {
80 $(inlineEditUsergroup.what+id).remove();
81 new_id = $(r).attr('id');
82
83 $('#edit-'+id).before(r).remove();
84 row = new_id ? $('#'+new_id) : $(inlineEditUsergroup.what+id);
85 row.hide().fadeIn();
86 } else
87 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
88 } else
89 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
90 }
91 );
92 return false;
93 },
94
95 revert : function() {
96 var id = $('table.widefat tr.inline-editor').attr('id');
97
98 if ( id ) {
99 $('table.widefat .inline-edit-save .waiting').hide();
100 $('#'+id).remove();
101 id = id.substr( id.lastIndexOf('-') + 1 );
102 $(this.what+id).show();
103 }
104
105 return false;
106 },
107
108 getId : function(o) {
109 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
110 return parts[parts.length - 1];
111 }
112 };
113
114 $(document).ready(function(){inlineEditUsergroup.init();});
115 })(jQuery);