From 0ae8cbf5c0b1a198b963490985b7738392ebcb97 Mon Sep 17 00:00:00 2001 From: ahriman Date: Mon, 3 Dec 2018 19:22:25 -0500 Subject: installed dokuwiki, added to navbar, updated news --- wiki/lib/plugins/extension/script.js | 145 +++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 wiki/lib/plugins/extension/script.js (limited to 'wiki/lib/plugins/extension/script.js') diff --git a/wiki/lib/plugins/extension/script.js b/wiki/lib/plugins/extension/script.js new file mode 100644 index 0000000..8627db4 --- /dev/null +++ b/wiki/lib/plugins/extension/script.js @@ -0,0 +1,145 @@ +jQuery(function(){ + + var $extmgr = jQuery('#extension__manager'); + + /** + * Confirm uninstalling + */ + $extmgr.find('button.uninstall').click(function(e){ + if(!window.confirm(LANG.plugins.extension.reallydel)){ + e.preventDefault(); + return false; + } + return true; + }); + + /** + * very simple lightbox + * @link http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/super-simple-lightbox-with-css-and-jquery/ + */ + $extmgr.find('a.extension_screenshot').click(function(e) { + e.preventDefault(); + + //Get clicked link href + var image_href = jQuery(this).attr("href"); + + // create lightbox if needed + var $lightbox = jQuery('#plugin__extensionlightbox'); + if(!$lightbox.length){ + $lightbox = jQuery('

Click to close

') + .appendTo(jQuery('body')) + .hide() + .click(function(){ + $lightbox.hide(); + }); + } + + // fill and show it + $lightbox + .show() + .find('div').html(''); + + + return false; + }); + + /** + * Enable/Disable extension via AJAX + */ + $extmgr.find('button.disable, button.enable').click(function (e) { + e.preventDefault(); + var $btn = jQuery(this); + + // get current state + var extension = $btn.attr('name').split('[')[2]; + extension = extension.substr(0, extension.length - 1); + var act = ($btn.hasClass('disable')) ? 'disable' : 'enable'; + + // disable while we wait + $btn.attr('disabled', 'disabled'); + $btn.css('cursor', 'wait'); + + // execute + jQuery.get( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'plugin_extension', + ext: extension, + act: act + }, + function (data) { + $btn.css('cursor', '') + .removeAttr('disabled') + .removeClass('disable') + .removeClass('enable') + .text(data.label) + .addClass(data.reverse) + .parents('li') + .removeClass('disabled') + .removeClass('enabled') + .addClass(data.state); + } + ); + }); + + /** + * AJAX detail infos + */ + $extmgr.find('a.info').click(function(e){ + e.preventDefault(); + + var $link = jQuery(this); + var $details = $link.parent().find('dl.details'); + if($details.length){ + $link.toggleClass('close'); + $details.toggle(); + return; + } + + $link.addClass('close'); + jQuery.get( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'plugin_extension', + ext: $link.data('extid'), + act: 'info' + }, + function(data){ + $link.parent().append(data); + } + ); + }); + + /** + Create section for enabling/disabling viewing options + */ + if ( $extmgr.find('.plugins, .templates').hasClass('active') ) { + var $extlist = jQuery('#extension__list'); + $extlist.addClass('hasDisplayOptions'); + + var $displayOpts = jQuery('

', { id: 'extension__viewoptions'} ).appendTo($extmgr.find( '.panelHeader' )); + $displayOpts.append(LANG.plugins.extension.display_viewoptions); + + var displayOptionsHandler = function(){ + $extlist.toggleClass( this.name ); + DokuCookie.setValue('ext_'+this.name, $extlist.hasClass(this.name) ? '1' : '0'); + }; + + jQuery(['enabled', 'disabled', 'updatable']).each(function(index, chkName){ + var $label = jQuery( '' ) + .appendTo($displayOpts); + var $input = jQuery( '', { type: 'checkbox', name: chkName }) + .change(displayOptionsHandler) + .appendTo($label); + + var previous = DokuCookie.getValue('ext_'+chkName); + if(typeof previous === "undefined" || previous == '1') { + $input.click(); + } + + jQuery( '' ) + .append(' '+LANG.plugins.extension['display_'+chkName]) + .appendTo($label); + }); + } +}); -- cgit 1.4.1-2-gfad0