Dotclear


Ignore:
Timestamp:
09/01/16 12:21:43 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Cope with settings URLs for modules (defined in _define.php).
The settings URLs are displayed on the plugins maganement page, and at the bottom of each plugin main page if any (index.php).

The URLs are set in _define.php, as a new property using this schema:

'settings' => array( <list of URLs> )

With:

<list of URLs> = '<type>' => '<location>', …
<type> = 'self' (own plugin page), 'blog' (in blog parameters page) or 'pref' (in user preferences page)
<location> = (empty) or #<tab>[.<id>] with <tab> = id of the corresponding tab, and <id> = id of fieldset, h4, h5, field, … of first corresponding field

The list of URLs are displayed in the order defined in the array above.

Examples:

Antispam plugin:

'settings' => array(

'self' => ,
'blog' => '#params.antispam_params'

)

self → for main settings of the plugin on its own page (index.php)
blog → for secondary settings in the blog parameters

Tags plugin:

'settings' => array(

'pref' => '#user-options.tags_prefs'

)

pref → for tags list format in user preferences

Maintenance plugin:

'settings' => array(

'self' => '#settings'

)

self → "settings" tab of its own page (index.php)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/jquery/jquery.pageTabs.js

    r2479 r3333  
    11(function($) { 
    22     'use strict'; 
    3      
     3 
    44     $.pageTabs = function(start_tab, opts) { 
    55          var defaults = { 
     
    1010               idTabPrefix: 'part-tabs-' 
    1111          }; 
    12            
     12 
    1313          $.pageTabs.options = $.extend({}, defaults, opts); 
    1414          var active_tab = start_tab || ''; 
    1515          var hash = $.pageTabs.getLocationHash(); 
     16          var subhash = $.pageTabs.getLocationSubhash(); 
    1617 
    1718          if (hash !== undefined && hash) { 
     
    2324 
    2425          createTabs(); 
    25            
     26 
    2627          $('ul li', '.'+$.pageTabs.options.containerClass).click(function(e) { 
    2728               if ($(this).hasClass($.pageTabs.options.activeClass)) { 
     
    4041                    part_to_activate.addClass('loaded'); 
    4142               } 
    42                 
     43 
    4344               part_to_activate.tabload(); 
    4445          }); 
     
    4950 
    5051          $.pageTabs.clickTab(active_tab); 
    51            
     52 
     53          if (subhash !== undefined) { 
     54               // Tab displayed, now scroll to the sub-part if defined in original document.location (#tab.sub-part) 
     55               document.getElementById(subhash).scrollIntoView(); 
     56          } 
     57 
    5258          return this; 
    5359     }; 
    54       
     60 
    5561     var createTabs = function createTabs() { 
    5662          var lis = [], li_class = ''; 
    57            
     63 
    5864          $('.'+$.pageTabs.options.contentClass).each(function() { 
    5965               $(this).hide(); 
     
    6268               $(this).attr('id', $.pageTabs.options.partPrefix + $(this).attr('id')).prop('title',''); 
    6369          }); 
    64            
     70 
    6571          $('<div class="'+$.pageTabs.options.containerClass+'"><ul>'+lis.join('')+'</ul></div>') 
    6672               .insertBefore($('.'+$.pageTabs.options.contentClass).get(0)); 
    6773     }; 
    68       
     74 
    6975     var getHash = function getHash(href) { 
    7076          var href = href || ''; 
     
    7278          return href.replace(/.*#/, ''); 
    7379     }; 
    74       
     80 
    7581     $.pageTabs.clickTab = function(tab) { 
    7682          if (tab=='') { 
     
    96102 
    97103     $.pageTabs.getLocationHash = function() { 
    98           return getHash(document.location.hash); 
     104          // Return the URL hash (without subhash — #hash[.subhash]) 
     105          var h = getHash(document.location.hash).split('.'); 
     106          return h[0]; 
     107     }; 
     108     $.pageTabs.getLocationSubhash = function() { 
     109          // Return the URL subhash if present (without hash — #hash[.subhash]) 
     110          var sh = getHash(document.location.hash).split('.'); 
     111          return sh[1]; 
    99112     }; 
    100113})(jQuery); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map