[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 jQuery(function(){ 2 3 var $extmgr = jQuery('#extension__manager'); 4 5 /** 6 * Confirm uninstalling 7 */ 8 $extmgr.find('button.uninstall').on('click', function(e){ 9 if(!window.confirm(LANG.plugins.extension.reallydel)){ 10 e.preventDefault(); 11 return false; 12 } 13 return true; 14 }); 15 16 /** 17 * very simple lightbox 18 * @link http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/super-simple-lightbox-with-css-and-jquery/ 19 */ 20 $extmgr.find('a.extension_screenshot').on('click', function(e) { 21 e.preventDefault(); 22 23 //Get clicked link href 24 var image_href = jQuery(this).attr("href"); 25 26 // create lightbox if needed 27 var $lightbox = jQuery('#plugin__extensionlightbox'); 28 if(!$lightbox.length){ 29 $lightbox = jQuery('<div id="plugin__extensionlightbox"><p>Click to close</p><div></div></div>') 30 .appendTo(jQuery('body')) 31 .hide() 32 .on('click', function(){ 33 $lightbox.hide(); 34 }); 35 } 36 37 // fill and show it 38 $lightbox 39 .show() 40 .find('div').html('<img src="' + image_href + '" />'); 41 42 43 return false; 44 }); 45 46 /** 47 * Enable/Disable extension via AJAX 48 */ 49 $extmgr.find('button.disable, button.enable').on('click', function (e) { 50 e.preventDefault(); 51 var $btn = jQuery(this); 52 53 // get current state 54 var extension = $btn.attr('name').split('[')[2]; 55 extension = extension.substr(0, extension.length - 1); 56 var act = ($btn.hasClass('disable')) ? 'disable' : 'enable'; 57 58 // disable while we wait 59 $btn.attr('disabled', 'disabled'); 60 $btn.css('cursor', 'wait'); 61 62 // execute 63 jQuery.get( 64 DOKU_BASE + 'lib/exe/ajax.php', 65 { 66 call: 'plugin_extension', 67 ext: extension, 68 act: act, 69 sectok: $btn.parents('form').find('input[name=sectok]').val() 70 }, 71 function (data) { 72 $btn.css('cursor', '') 73 .removeAttr('disabled') 74 .removeClass('disable') 75 .removeClass('enable') 76 .text(data.label) 77 .addClass(data.reverse) 78 .parents('li') 79 .removeClass('disabled') 80 .removeClass('enabled') 81 .addClass(data.state); 82 } 83 ).fail(function() { 84 $btn.css('cursor', '') 85 .removeAttr('disabled'); 86 }); 87 }); 88 89 /** 90 * AJAX detail infos 91 */ 92 $extmgr.find('a.info').on('click', function(e){ 93 e.preventDefault(); 94 95 var $link = jQuery(this); 96 var $details = $link.parent().find('dl.details'); 97 if($details.length){ 98 $link.toggleClass('close'); 99 $details.toggle(); 100 return; 101 } 102 103 $link.addClass('close'); 104 jQuery.get( 105 DOKU_BASE + 'lib/exe/ajax.php', 106 { 107 call: 'plugin_extension', 108 ext: $link.data('extid'), 109 act: 'info' 110 }, 111 function(data){ 112 $link.parent().append(data); 113 } 114 ); 115 }); 116 117 /** 118 Create section for enabling/disabling viewing options 119 */ 120 if ( $extmgr.find('.plugins, .templates').hasClass('active') ) { 121 var $extlist = jQuery('#extension__list'); 122 $extlist.addClass('hasDisplayOptions'); 123 124 var $displayOpts = jQuery('<p>', { id: 'extension__viewoptions'} ).appendTo($extmgr.find( '.panelHeader' )); 125 $displayOpts.append(LANG.plugins.extension.display_viewoptions); 126 127 var displayOptionsHandler = function(){ 128 $extlist.toggleClass( this.name ); 129 DokuCookie.setValue('ext_'+this.name, $extlist.hasClass(this.name) ? '1' : '0'); 130 }; 131 132 jQuery(['enabled', 'disabled', 'updatable']).each(function(index, chkName){ 133 var $label = jQuery( '<label></label>' ) 134 .appendTo($displayOpts); 135 var $input = jQuery( '<input />', { type: 'checkbox', name: chkName }) 136 .on('change', displayOptionsHandler) 137 .appendTo($label); 138 139 var previous = DokuCookie.getValue('ext_'+chkName); 140 if(typeof previous === "undefined" || previous == '1') { 141 $input.trigger('click'); 142 } 143 144 jQuery( '<span/>' ) 145 .append(' '+LANG.plugins.extension['display_'+chkName]) 146 .appendTo($label); 147 }); 148 } 149 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body