1/** 2 * DokuWiki Plugin inlineedit (Script Component) 3 * 4 * @author peterfromearth 5 */ 6jQuery(function(){ 7 // 8 if(JSINFO && JSINFO['acl_write']) { 9 var itemPos = jQuery('span.plugin__inlineedit[data-plugin-inlineedit-pageid="'+JSINFO['id']+'"]').addClass('active'); 10 11 } 12 13 14 jQuery('#dokuwiki__content').on('click', 'span.plugin__inlineedit.active', function() { 15 var $self = jQuery(this); 16 var input = prompt(LANG.plugins.inlineedit.promt_title, $self.html()); 17 if(input == null) return; 18 if(input == $self.html()) return; 19 var idx = null; 20 if(jQuery($self).parents('div.sortable').length != 0) { 21 idx = jQuery($self).data("plugin-inlineedit-itempos"); 22 } else { 23 idx = ajaxedit_getIdxBySelector($self,'span.plugin__inlineedit[data-plugin-inlineedit-pageid="'+JSINFO['id']+'"]'); 24 } 25 ajaxedit_send2( 26 'inlineedit', 27 idx, 28 function (data) { 29 var ret = ajaxedit_parse(data); 30 ajaxedit_checkResponse(ret); 31 32 $self.html(ret.text); 33 }, 34 { 35 input:input, 36 } 37 ); 38 }); 39 40}); 41 42function ajaxedit_getIdxBySelector($elem,selector) { 43 var id = $elem.attr('id'); 44 var $els = jQuery(selector); 45 46 for(var ii=0;ii<$els.size();ii++){ 47 if($els[ii].id == id) { 48 return ii; 49 } 50 } 51} 52 53 54