[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/extension/ -> script.js (source)

   1  jQuery(function(){
   2  
   3      var $extmgr = jQuery('#extension__manager');
   4  
   5      /**
   6       * Confirm uninstalling
   7       */
   8      $extmgr.find('button.uninstall').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').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                  .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').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              },
  70              function (data) {
  71                  $btn.css('cursor', '')
  72                      .removeAttr('disabled')
  73                      .removeClass('disable')
  74                      .removeClass('enable')
  75                      .text(data.label)
  76                      .addClass(data.reverse)
  77                  .parents('li')
  78                      .removeClass('disabled')
  79                      .removeClass('enabled')
  80                      .addClass(data.state);
  81              }
  82          );
  83      });
  84  
  85      /**
  86       * AJAX detail infos
  87       */
  88      $extmgr.find('a.info').click(function(e){
  89          e.preventDefault();
  90  
  91          var $link = jQuery(this);
  92          var $details = $link.parent().find('dl.details');
  93          if($details.length){
  94              $link.toggleClass('close');
  95              $details.toggle();
  96              return;
  97          }
  98  
  99          $link.addClass('close');
 100          jQuery.get(
 101              DOKU_BASE + 'lib/exe/ajax.php',
 102              {
 103                  call: 'plugin_extension',
 104                  ext: $link.data('extid'),
 105                  act: 'info'
 106              },
 107              function(data){
 108                  $link.parent().append(data);
 109              }
 110          );
 111      });
 112  
 113      /**
 114          Create section for enabling/disabling viewing options
 115       */
 116      if ( $extmgr.find('.plugins, .templates').hasClass('active') ) {
 117          var $extlist = jQuery('#extension__list');
 118          $extlist.addClass('hasDisplayOptions');
 119  
 120          var $displayOpts = jQuery('<p>', { id: 'extension__viewoptions'} ).appendTo($extmgr.find( '.panelHeader' ));
 121          $displayOpts.append(LANG.plugins.extension.display_viewoptions);
 122  
 123          var displayOptionsHandler = function(){
 124              $extlist.toggleClass( this.name );
 125              DokuCookie.setValue('ext_'+this.name, $extlist.hasClass(this.name) ? '1' : '0');
 126          };
 127  
 128          jQuery(['enabled', 'disabled', 'updatable']).each(function(index, chkName){
 129              var $label = jQuery( '<label></label>' )
 130                  .appendTo($displayOpts);
 131              var $input = jQuery( '<input />', { type: 'checkbox', name: chkName })
 132                  .change(displayOptionsHandler)
 133                  .appendTo($label);
 134  
 135              var previous = DokuCookie.getValue('ext_'+chkName);
 136              if(typeof previous === "undefined" || previous == '1') {
 137                  $input.click();
 138              }
 139  
 140              jQuery( '<span/>' )
 141                  .append(' '+LANG.plugins.extension['display_'+chkName])
 142                  .appendTo($label);
 143          });
 144      }
 145  });