about summary refs log tree commit diff stats
path: root/wiki/lib/plugins/extension/script.js
diff options
context:
space:
mode:
authorahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
committerahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
commit0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch)
treeb2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/lib/plugins/extension/script.js
parentf57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff)
downloadsite-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/lib/plugins/extension/script.js')
-rw-r--r--wiki/lib/plugins/extension/script.js145
1 files changed, 145 insertions, 0 deletions
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('<div id="plugin__extensionlightbox"><p>Click to close</p><div></div></div>')
+                .appendTo(jQuery('body'))
+                .hide()
+                .click(function(){
+                    $lightbox.hide();
+                });
+        }
+
+        // fill and show it
+        $lightbox
+            .show()
+            .find('div').html('<img src="' + image_href + '" />');
+
+
+        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('<p>', { 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( '<label></label>' )
+                .appendTo($displayOpts);
+            var $input = jQuery( '<input />', { type: 'checkbox', name: chkName })
+                .change(displayOptionsHandler)
+                .appendTo($label);
+
+            var previous = DokuCookie.getValue('ext_'+chkName);
+            if(typeof previous === "undefined" || previous == '1') {
+                $input.click();
+            }
+
+            jQuery( '<span/>' )
+                .append(' '+LANG.plugins.extension['display_'+chkName])
+                .appendTo($label);
+        });
+    }
+});