Line 175: | Line 175: | ||
var h = sec.find(hlvl || 'h3').first(), | var h = sec.find(hlvl || 'h3').first(), | ||
− | id = h.attr('id') | + | hid = h.attr('id'), secid = sec.attr('id'), id; |
+ | |||
+ | if(hid){ | ||
+ | if(!secid){ | ||
+ | secid = 'sec-'+hid; | ||
+ | sec.attr('id', secid); | ||
+ | id = hid; | ||
+ | } | ||
+ | }else if(secid){ | ||
+ | if(!hid){ | ||
+ | hid = 'h-'+secid; | ||
+ | h.attr('id', hid); | ||
+ | id = secid; | ||
+ | } | ||
+ | }else{ | ||
+ | id = 'collapser-'+(collapsers.nextId++); | ||
+ | secid = 'sec-'+id; | ||
+ | sec.attr('id', secid); | ||
+ | hid = 'h-'+id; | ||
+ | h.attr('id', hid); | ||
+ | } | ||
h.insertBefore(sec); | h.insertBefore(sec); | ||
Line 183: | Line 203: | ||
h.addClass('collapser'); | h.addClass('collapser'); | ||
sec.addClass('collapsible'); | sec.addClass('collapsible'); | ||
− | sec.data('the-h', | + | sec.data('the-h', hid); |
− | h.data('the-sec', | + | h.data('the-sec', secid); |
actual.push({sec: sec, h: h}); | actual.push({sec: sec, h: h}); | ||
Line 207: | Line 227: | ||
h = elm.data('the-h'); | h = elm.data('the-h'); | ||
if(h){ | if(h){ | ||
+ | h = $(h); | ||
sec = elm; | sec = elm; | ||
}else{ | }else{ | ||
h = elm; | h = elm; | ||
− | sec = elm.data('the-sec'); | + | sec = $(elm.data('the-sec')); |
} | } | ||
Line 229: | Line 250: | ||
collapsers.allow = []; | collapsers.allow = []; | ||
collapsers.all = []; | collapsers.all = []; | ||
+ | collapsers.nextId = 0; | ||
function memberate(){ | function memberate(){ |
Revision as of 13:46, 17 October 2016