Removed summary and static TOC from article page [bug 607301]

Gracefully handle {for} without data-for attr [bug 607779]
This commit is contained in:
Ricky Rosario 2010-11-01 13:39:19 -04:00
Родитель 4ae173551c
Коммит d6a328e65f
6 изменённых файлов: 36 добавлений и 41 удалений

Просмотреть файл

@ -24,15 +24,6 @@
{{ _('(Redirected from <a href="{href}">{title}</a>)')|fe(href=redirected_from.get_absolute_url()|urlparams(redirect='no'), title=redirected_from.title) }}
</div>
{% endif %}
<section id="doc-summary">
{{ document.current_revision.summary }}
</section>
{% if document.current_revision %}
<section id="toc" class="hide-if-no-js" data-missing-msg="{{ missing_msg_json }}">
<h1>{{ _("Table of Contents") }}</h1>
<ol></ol>
</section>
{% endif %}
<section id="doc-content">
{% if document.current_revision %}
{{ document.html|safe }}

Просмотреть файл

@ -1,8 +1,4 @@
{# vim: set ts=2 et sts=2 sw=2: #}
<section id="toc" class="hide-if-no-js" data-missing-msg="{{ missing_msg_json }}">
<h1>{{ _('Table of Contents') }}</h1>
<ol></ol>
</section>
{% include 'wiki/includes/support_for_selectors.html' %}
<div id="doc-content">
{{ content|safe }}

Просмотреть файл

@ -51,13 +51,6 @@
{% endif %}
</ul>
</div>
<section id="doc-summary">
{{ document.current_revision.summary }}
</section>
<section id="toc" class="hide-if-no-js" data-missing-msg="{{ missing_msg_json }}">
<h1>{{ _("Table of Contents") }}</h1>
<ol></ol>
</section>
<div id="doc-content">
{{ revision.content_parsed|safe }}
</div>

Просмотреть файл

@ -35,7 +35,6 @@ OS_ABBR_JSON = json.dumps(dict([(o.slug, True)
for o in OPERATING_SYSTEMS]))
BROWSER_ABBR_JSON = json.dumps(dict([(v.slug, True)
for v in FIREFOX_VERSIONS]))
MISSING_MSG = _lazy('[missing header]')
def _version_groups(versions):
@ -68,7 +67,6 @@ SHOWFOR_DATA = {
'browsers': GROUPED_FIREFOX_VERSIONS,
'browsers_json': BROWSER_ABBR_JSON,
'version_group_json': VERSION_GROUP_JSON,
'missing_msg_json': json.dumps(unicode(MISSING_MSG)),
}

Просмотреть файл

@ -380,16 +380,15 @@ div.support-search input.submit {
}
#toc {
background: transparent url(../img/wiki/document.divider.jpg) no-repeat left bottom;
clear: both;
font-size: 13px;
left: -50px;
padding: 0 0 60px;
padding: 0 0 25px;
position: relative;
}
#related-articles h1,
#toc h1 {
#toc h1,
#toc h2 {
color: #333;
font-size: 18px;
font-style: italic;
@ -406,13 +405,6 @@ div.support-search input.submit {
background: none;
}
#doc-summary {
color: #666;
font-size: 14px;
line-height: 20px;
padding: 15px 0 30px;
}
html.no-js .hide-if-no-js {
display: none;
}
@ -421,23 +413,34 @@ article #toc ol li {
list-style-type: decimal;
}
article #toc ol li {
article #toc ol li,
article #toc ul li {
background: transparent url(../img/wiki/list.divider.png) no-repeat left bottom;
list-style-position: inside;
padding: 10px 0 10px 50px;
}
#toc ol li:last-child {
background: none;
article #toc ol,
article #toc ul {
margin: 0;
}
#toc ol ol {
article #toc ul li {
list-style: none;
}
#toc ol ol,
#toc ul ul {
margin: 0 0 0 20px;
}
#toc ol ol li {
background: none;
list-style-type: upper-alpha;
}
#toc ol ol li,
#toc ul ul li {
background: none;
padding: 0;
}

Просмотреть файл

@ -135,7 +135,7 @@
OSES = $.parseJSON($('select#os').attr('data-oses')); // {'mac': true, 'win': true, ...}
BROWSERS = $.parseJSON($('select#browser').attr('data-browsers')); // {'fx4': true, ...}
VERSIONS = $.parseJSON($('select#browser').attr('data-version-groups')); // {'fx': [[3.4999, '3'], [3.9999, '35']], 'm': [[1.0999, '1'], [1.9999, '11']]}
MISSING_MSG = $.parseJSON($('#toc').attr('data-missing-msg')); // l10nized "missing header" message
MISSING_MSG = gettext('[missing header]'); // l10nized "missing header" message
function updateForsAndToc() {
// Hide and show document sections accordingly:
@ -143,7 +143,8 @@
$('select#browser').attr('value'));
// Update the table of contents in case headers were hidden or shown:
$('#toc ol').empty().append(filteredToc($('#doc-content')).children());
$('#toc > :not(h2)').remove(); // __TOC__ generates <ul/>'s.
$('#toc').append(filteredToc($('#doc-content'), '#toc h2'));
return false;
}
@ -237,7 +238,10 @@
// top of the TOC: if $pageBody has h2s but no h1s, h2s will be used as the
// first level of the TOC. Missing headers (such as if you follow an h2
// directly with an h4) are noted prominently so you can fix them.
function filteredToc($pageBody) {
//
// excludesSelector is an optional jQuery selector for excluding certain
// headings from the table of contents.
function filteredToc($pageBody, excludesSelector) {
function headerLevel(index, hTag) {
return parseInt(hTag.tagName[1], 10);
}
@ -252,6 +256,11 @@
var h_level = headerLevel(0, this),
$h = $(this);
if (excludesSelector && $h.is(excludesSelector)) {
// Skip excluded headers.
return;
}
// If we're too far down the tree, walk up it.
for (; ol_level > h_level; ol_level--) {
$cur_ol = $cur_ol.parent().closest('ol');
@ -292,6 +301,11 @@
// Catch the "not" operator if it's there:
forData = $(this).attr('data-for');
if (!forData) {
// If the data-for attribute is missing, move on.
return;
}
isInverted = forData.substring(0, 4) == 'not ';
if (isInverted) {
forData = forData.substring(4); // strip off "not "