1jQuery(function () { 2 3 const $extmgr = jQuery('#extension__manager'); 4 5 /** 6 * Confirm uninstalling 7 */ 8 $extmgr.on('click', 'button.uninstall', 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.on('click', 'a.extension_screenshot', function (e) { 21 e.preventDefault(); 22 23 //Get clicked link href 24 const image_href = jQuery(this).attr("href"); 25 26 // create lightbox if needed 27 let $lightbox = jQuery('#plugin__extensionlightbox'); 28 if (!$lightbox.length) { 29 $lightbox = jQuery( 30 '<div id="plugin__extensionlightbox"><p>' + LANG.plugins.extension.close + '</p><div></div></div>' 31 ) 32 .appendTo(jQuery('body')) 33 .hide() 34 .on('click', function () { 35 $lightbox.hide(); 36 }); 37 } 38 39 // fill and show it 40 $lightbox 41 .show() 42 .find('div').html('<img src="' + image_href + '" />'); 43 44 return false; 45 }); 46 47 /** 48 * Enable/Disable extension via AJAX 49 */ 50 $extmgr.on('click', 'button.disable, button.enable', function (e) { 51 e.preventDefault(); 52 const $btn = jQuery(this); 53 const $section = $btn.parents('section'); 54 55 // disable while we wait 56 $btn.attr('disabled', 'disabled'); 57 $btn.css('cursor', 'wait'); 58 59 // execute 60 jQuery.get( 61 DOKU_BASE + 'lib/exe/ajax.php', 62 { 63 call: 'plugin_extension', 64 ext: $section.data('ext'), 65 act: 'toggle', 66 sectok: $btn.parents('form').find('input[name=sectok]').val() 67 }, 68 function (html) { 69 $section.replaceWith(html); 70 } 71 ).fail(function (data) { 72 $btn.css('cursor', '').removeAttr('disabled'); 73 window.alert(data.responseText); 74 }); 75 }); 76 77 78 /** 79 Create section for enabling/disabling viewing options 80 */ 81 if ($extmgr.find('.plugins, .templates').hasClass('active')) { 82 const $extlist = jQuery('#extension__list'); 83 84 const $displayOpts = jQuery('<p>').appendTo($extmgr.find('.panelHeader')); 85 const $label = jQuery('<label />').appendTo($displayOpts); 86 const $checkbox = jQuery('<input />', {type: 'checkbox'}).appendTo($label); 87 $label.append(' ' + LANG.plugins.extension.filter); 88 89 let filter = !! window.localStorage.getItem('ext_filter'); 90 $checkbox.prop('checked', filter); 91 $extlist.toggleClass('filter', filter); 92 93 $checkbox.on('change', function () { 94 filter = this.checked; 95 window.localStorage.setItem('ext_filter', filter ? '1' : ''); 96 $extlist.toggleClass('filter', filter); 97 }); 98 99 100 } 101}); 102