|
1709 | 1709 | });
|
1710 | 1710 | });
|
1711 | 1711 | </script>
|
1712 |
| -<style> |
1713 |
| -.hidden { |
1714 |
| - display: none; |
1715 |
| -} |
1716 |
| -
|
1717 |
| -.switch { |
1718 |
| - border-width: 1px 1px 0 1px; |
1719 |
| - border-style: solid; |
1720 |
| - border-color: #7a2518; |
1721 |
| - display: inline-block; |
1722 |
| -} |
1723 |
| -
|
1724 |
| -.switch--item { |
1725 |
| - padding: 10px; |
1726 |
| - background-color: #ffffff; |
1727 |
| - color: #7a2518; |
1728 |
| - display: inline-block; |
1729 |
| - cursor: pointer; |
1730 |
| -} |
1731 |
| -
|
1732 |
| -.switch--item.selected { |
1733 |
| - background-color: #7a2519; |
1734 |
| - color: #ffffff; |
1735 |
| -} |
1736 |
| -
|
1737 |
| -</style> |
1738 |
| -<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script> |
1739 |
| -<script type="text/javascript"> |
1740 |
| -function addBlockSwitches() { |
1741 |
| - $('.primary').each(function() { |
1742 |
| - primary = $(this); |
1743 |
| - createSwitchItem(primary, createBlockSwitch(primary)).item.addClass("selected"); |
1744 |
| - primary.children('.title').remove(); |
1745 |
| - }); |
1746 |
| - $('.secondary').each(function(idx, node) { |
1747 |
| - secondary = $(node); |
1748 |
| - primary = findPrimary(secondary); |
1749 |
| - switchItem = createSwitchItem(secondary, primary.children('.switch')); |
1750 |
| - switchItem.content.addClass('hidden'); |
1751 |
| - findPrimary(secondary).append(switchItem.content); |
1752 |
| - secondary.remove(); |
1753 |
| - }); |
1754 |
| -} |
1755 |
| -
|
1756 |
| -function createBlockSwitch(primary) { |
1757 |
| - blockSwitch = $('<div class="switch"></div>'); |
1758 |
| - primary.prepend(blockSwitch); |
1759 |
| - return blockSwitch; |
1760 |
| -} |
1761 |
| -
|
1762 |
| -function findPrimary(secondary) { |
1763 |
| - candidate = secondary.prev(); |
1764 |
| - while (!candidate.is('.primary')) { |
1765 |
| - candidate = candidate.prev(); |
1766 |
| - } |
1767 |
| - return candidate; |
1768 |
| -} |
1769 |
| -
|
1770 |
| -function createSwitchItem(block, blockSwitch) { |
1771 |
| - blockName = block.children('.title').text(); |
1772 |
| - content = block.children('.content').first().append(block.next('.colist')); |
1773 |
| - item = $('<div class="switch--item">' + blockName + '</div>'); |
1774 |
| - item.on('click', '', content, function(e) { |
1775 |
| - $(this).addClass('selected'); |
1776 |
| - $(this).siblings().removeClass('selected'); |
1777 |
| - e.data.siblings('.content').addClass('hidden'); |
1778 |
| - e.data.removeClass('hidden'); |
1779 |
| - }); |
1780 |
| - blockSwitch.append(item); |
1781 |
| - return {'item': item, 'content': content}; |
1782 |
| -} |
1783 |
| -
|
1784 |
| -$(addBlockSwitches); |
1785 |
| -
|
1786 |
| -</script> |
| 1712 | +<style> |
| 1713 | +.hidden { |
| 1714 | + display: none; |
| 1715 | +} |
| 1716 | + |
| 1717 | +.switch { |
| 1718 | + border-width: 1px 1px 0 1px; |
| 1719 | + border-style: solid; |
| 1720 | + border-color: #7a2518; |
| 1721 | + display: inline-block; |
| 1722 | +} |
| 1723 | + |
| 1724 | +.switch--item { |
| 1725 | + padding: 10px; |
| 1726 | + background-color: #ffffff; |
| 1727 | + color: #7a2518; |
| 1728 | + display: inline-block; |
| 1729 | + cursor: pointer; |
| 1730 | +} |
| 1731 | + |
| 1732 | +.switch--item.selected { |
| 1733 | + background-color: #7a2519; |
| 1734 | + color: #ffffff; |
| 1735 | +} |
| 1736 | + |
| 1737 | +</style> |
| 1738 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script> |
| 1739 | +<script type="text/javascript"> |
| 1740 | +function addBlockSwitches() { |
| 1741 | + $('.primary').each(function() { |
| 1742 | + primary = $(this); |
| 1743 | + createSwitchItem(primary, createBlockSwitch(primary)).item.addClass("selected"); |
| 1744 | + primary.children('.title').remove(); |
| 1745 | + }); |
| 1746 | + $('.secondary').each(function(idx, node) { |
| 1747 | + secondary = $(node); |
| 1748 | + primary = findPrimary(secondary); |
| 1749 | + switchItem = createSwitchItem(secondary, primary.children('.switch')); |
| 1750 | + switchItem.content.addClass('hidden'); |
| 1751 | + findPrimary(secondary).append(switchItem.content); |
| 1752 | + secondary.remove(); |
| 1753 | + }); |
| 1754 | +} |
| 1755 | + |
| 1756 | +function createBlockSwitch(primary) { |
| 1757 | + blockSwitch = $('<div class="switch"></div>'); |
| 1758 | + primary.prepend(blockSwitch); |
| 1759 | + return blockSwitch; |
| 1760 | +} |
| 1761 | + |
| 1762 | +function findPrimary(secondary) { |
| 1763 | + candidate = secondary.prev(); |
| 1764 | + while (!candidate.is('.primary')) { |
| 1765 | + candidate = candidate.prev(); |
| 1766 | + } |
| 1767 | + return candidate; |
| 1768 | +} |
| 1769 | + |
| 1770 | +function createSwitchItem(block, blockSwitch) { |
| 1771 | + blockName = block.children('.title').text(); |
| 1772 | + content = block.children('.content').first().append(block.next('.colist')); |
| 1773 | + item = $('<div class="switch--item">' + blockName + '</div>'); |
| 1774 | + item.on('click', '', content, function(e) { |
| 1775 | + $(this).addClass('selected'); |
| 1776 | + $(this).siblings().removeClass('selected'); |
| 1777 | + e.data.siblings('.content').addClass('hidden'); |
| 1778 | + e.data.removeClass('hidden'); |
| 1779 | + }); |
| 1780 | + blockSwitch.append(item); |
| 1781 | + return {'item': item, 'content': content}; |
| 1782 | +} |
| 1783 | + |
| 1784 | +$(addBlockSwitches); |
| 1785 | + |
| 1786 | +</script> |
1787 | 1787 |
|
1788 | 1788 | </head>
|
1789 | 1789 | <body class="article toc2 toc-left">
|
|
0 commit comments