1/** 2 * Rename dialog for end users 3 * 4 * @author Andreas Gohr <gohr@cosmocode.de> 5 */ 6if(JSINFO && JSINFO.move_renameokay) { 7 jQuery('.plugin_move_page') 8 .show() 9 .click(function(e) { 10 e.preventDefault(); 11 12 var renameFN = function () { 13 var self = this; 14 var newid = $dialog.find('input[name=id]').val(); 15 if (!newid) return false; 16 17 // remove buttons and show throbber 18 $dialog.html( 19 '<img src="'+DOKU_BASE+'lib/images/throbber.gif" /> '+ 20 LANG.plugins.move.inprogress 21 ); 22 $dialog.dialog('option', 'buttons', []); 23 24 // post the data 25 jQuery.post( 26 DOKU_BASE + 'lib/exe/ajax.php', 27 { 28 call: 'plugin_move_rename', 29 id: JSINFO.id, 30 newid: newid 31 }, 32 // redirect or display error 33 function (result) { 34 if(result.error){ 35 $dialog.html(result.error.msg); 36 } else { 37 window.location.href = result.redirect_url; 38 } 39 } 40 ); 41 42 return false; 43 }; 44 45 // basic dialog template 46 var $dialog = jQuery( 47 '<div>' + 48 '<form>' + 49 '<label>' + LANG.plugins.move.newname + '<br>' + 50 '<input type="text" name="id" style="width:100%">' + 51 '</label>' + 52 '</form>' + 53 '</div>' 54 ); 55 $dialog.find('input[name=id]').val(JSINFO.id); 56 $dialog.find('form').submit(renameFN); 57 58 // set up the dialog 59 $dialog.dialog({ 60 title: LANG.plugins.move.rename+' '+JSINFO.id, 61 width: 800, 62 height: 180, 63 dialogClass: 'plugin_move_dialog', 64 modal: true, 65 buttons: [ 66 { 67 text: LANG.plugins.move.cancel, 68 click: function () { 69 $dialog.dialog("close"); 70 } 71 }, 72 { 73 text: LANG.plugins.move.rename, 74 click: renameFN 75 } 76 ], 77 // remove HTML from DOM again 78 close: function () { 79 jQuery(this).remove(); 80 } 81 }) 82 }); 83} 84