EasyUI Forum
April 19, 2024, 11:55:37 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: New feature request for Tabs  (Read 8194 times)
mzeddd
Full Member
***
Posts: 223



View Profile
« on: September 21, 2016, 02:53:47 AM »

Hi,

I just wander would be good to have the following feature in Tabs.

When we have lots of open tabs special scroll buttons appear to let user get to first/last tab.
My proposal is to show menu with list of hidden tabs so user can activate any hidden tab in one click.

Thanks
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: September 21, 2016, 05:40:00 PM »

Extend a new method 'navmenu' to achieve this functionality.
Code:
<script>
(function($){
  $.extend($.fn.tabs.methods, {
    navmenu: function(jq){
      return jq.each(function(){
        var target = this;
        $(target).children('.tabs-header').find('.tabs-scroller-left,.tabs-scroller-right').unbind('.navmenu').bind('contextmenu.navmenu', function(e){
          e.preventDefault();
          var titles = $.map($(target).tabs('tabs'), function(t){
            return t.panel('options').title;
          });
          var menu = $('<div></div>').appendTo('body');
          menu.html($.map(titles,function(t){return '<div>'+t+'</div>';}).join(''));
          menu.menu({
            alignTo: this,
            onHide: function(){
              setTimeout(function(){
                menu.menu('destroy');
              })
            },
            onClick: function(item){
              var index = $(item.target).index();
              $(target).tabs('select', index-1);
            }
          }).menu('show');
        });
      });
    }
  });
})(jQuery);
</script>

After calling this method, you can right click on the scroller button of the header. The drop-down menu will display to allow the user to navigate to any tab panels.

Code:
$('#tt').tabs(...);
$('#tt').tabs('navmenu');
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #2 on: September 22, 2016, 02:04:43 AM »

Looks good.

Thanks stworthy!

Do you have any plans to make it part of EasyUI by default?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!