Dotclear

Changeset 2479:6883db18a27e


Ignore:
Timestamp:
10/22/13 14:22:06 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
2.6
Message:

Fix issue when hash not refer to existing div content. Closes #1794
Improve the way ton find anchor related to a div content, addresses #1723

Files:
2 edited

Legend:

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

    r2471 r2479  
    7676          if (tab=='') { 
    7777               tab = getHash($('ul li a', '.'+$.pageTabs.options.containerClass+':eq(0)').attr('href')); 
    78           } else if (($('#'+$.pageTabs.options.idTabPrefix+tab, '.'+$.pageTabs.options.containerClass).length==0) 
    79                   && ($('ul li.'+$.pageTabs.options.activeClass, '.'+$.pageTabs.options.containerClass).length==0)){ 
    80                tab = getHash($('ul li a', '.'+$.pageTabs.options.containerClass+':eq(0)').attr('href')); 
     78          } else if ($('#'+$.pageTabs.options.idTabPrefix+tab, '.'+$.pageTabs.options.containerClass).length==0) { 
     79               // try to find anchor in a .multi-part div 
     80               if ($('#'+tab).length==1) { 
     81                    var div_content = $('#'+tab).parents('.'+$.pageTabs.options.contentClass); 
     82                    if (div_content.length==1) { 
     83                         tab = div_content.attr('id').replace($.pageTabs.options.partPrefix,''); 
     84                    } else { 
     85                         tab = getHash($('ul li a', '.'+$.pageTabs.options.containerClass+':eq(0)').attr('href')); 
     86                    } 
     87               } else { 
     88                    tab = getHash($('ul li a', '.'+$.pageTabs.options.containerClass+':eq(0)').attr('href')); 
     89               } 
    8190          } 
    8291 
  • tests/functional/spec/page_tabs.js

    r2471 r2479  
    153153          expect($('#part-user-favorites')).not.toBeVisible(); 
    154154     }); 
    155  
    156      /* ticket 1794 */ 
    157      /* 
     155      
     156     /* ticket 1723 and 1794 
     157      * 
    158158      * The problem occurs when cliking an anchor in the page  
    159159      */ 
    160      it("Must not change opened tab when hash does not refer to an existing div content", function() { 
     160     it("Must try to find tab to open in page when hash refer ton an anchor and not to an existing div content", function() { 
    161161          loadFixtures('tabs.html'); 
    162162          loadStyleFixtures('default.css'); 
     163           
     164          var anchor_name = 'anchor-in-favorites'; 
     165          $('<div id="anchor-in-favorites"></div>').appendTo($('#user-favorites')); 
    163166           
    164167          $.pageTabs('user-profile'); 
     
    167170          expect($('#part-user-favorites')).not.toBeVisible(); 
    168171 
    169           spyOn(jQuery.pageTabs, 'getLocationHash').andReturn('dummy'); 
     172          spyOn(jQuery.pageTabs, 'getLocationHash').andReturn(anchor_name); 
    170173          jQuery.event.trigger('hashchange'); 
    171174          expect($('#part-user-options')).not.toBeVisible(); 
    172           expect($('#part-user-profile')).toBeVisible(); 
    173           expect($('#part-user-favorites')).not.toBeVisible(); 
     175          expect($('#part-user-profile')).not.toBeVisible(); 
     176          expect($('#part-user-favorites')).toBeVisible(); 
    174177     }); 
    175178 
    176      /* ticket 1723 */ 
    177      it("Must open first tab when hash does not refer to an existing div content and no tab is opened", function() { 
     179     it("Must open first tab when hash does not refer to an existing div content", function() { 
    178180          loadFixtures('tabs.html'); 
    179181          loadStyleFixtures('default.css'); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map