@@ -625,7 +625,6 @@ $(function() {
625625 scope . nv = scope . root . find ( '.t-navbar' ) ;
626626 scope . dcl_tables = scope . root . find ( '.t-dcl-begin' ) ;
627627 scope . dcl_rev_tables = scope . dcl_tables . filter ( '.t-dcl-rev-begin' ) ;
628- scope . dsc_tables = scope . root . find ( '.t-dsc-begin' ) ;
629628 scope . rev_tables = scope . root . find ( '.t-rev-begin' ) ;
630629 scope . rev_inl_tables = scope . root . find ( '.t-rev-inl' ) ;
631630 scope . list_items = scope . root . find ( '.t-li1' ) ;
@@ -660,7 +659,6 @@ $(function() {
660659 Scope . split_scope ( parent , scope , 'nv' ) ;
661660 Scope . split_scope ( parent , scope , 'dcl_tables' ) ;
662661 Scope . split_scope ( parent , scope , 'dcl_rev_tables' ) ;
663- Scope . split_scope ( parent , scope , 'dsc_tables' ) ;
664662 Scope . split_scope ( parent , scope , 'rev_tables' ) ;
665663 Scope . split_scope ( parent , scope , 'rev_inl_tables' ) ;
666664 Scope . split_scope ( parent , scope , 'list_items' ) ;
@@ -805,18 +803,6 @@ $(function() {
805803 } ) ;
806804 } ;
807805
808- /* Handles the description lists and their contents - inclusions of
809- Template:dsc_* ('t-dsc-*' CSS classes)
810-
811- Prepares items in dsc lists
812- */
813- StandardRevisionPlugin . prototype . prepare_all_dscs = function ( scope ) {
814- var self = this ;
815- scope . dsc_tables . each ( function ( ) {
816- self . prepare_dsc_table ( $ ( this ) ) ;
817- } ) ;
818- } ;
819-
820806 // Returns true if the given jQuery object defines a secondary visual object
821807 StandardRevisionPlugin . prototype . is_secondary = function ( el ) {
822808 if ( el . is ( 'h2' ) ||
@@ -861,24 +847,39 @@ $(function() {
861847 }
862848 } ;
863849
864- // Handles a description list
865- StandardRevisionPlugin . prototype . prepare_dsc_table = function ( el ) {
866- var section_tracker = new SectionContentsTracker ( ) ;
850+ /* Handles the section hierarchy in a scope as defined by description
851+ lists and their contents. Description lists are inclusions of
852+ Template:dsc_* ('t-dsc-*' CSS classes).
853+ See the documentation of SectionContentsTracker for more information.
867854
868- var start_el = el ;
869- while ( true ) {
870- var prev = start_el . prev ( ) ;
871- if ( prev . length === 0 || ! this . is_secondary ( prev ) )
872- break ;
873- start_el = prev ;
874- }
855+ Also prepares items in dsc lists
856+ */
857+ StandardRevisionPlugin . prototype . prepare_sections_and_dscs = function ( scope ) {
858+ var self = this ;
875859
876- while ( start_el [ 0 ] !== el [ 0 ] ) {
877- this . set_level_if_needed ( section_tracker , start_el ) ;
878- section_tracker . add_secondary ( start_el ) ;
879- start_el = start_el . next ( ) ;
880- }
860+ var section_tracker = new SectionContentsTracker ( ) ;
881861
862+ scope . root . children ( ) . each ( function ( ) {
863+ var el = $ ( this ) ;
864+ if ( el . hasClass ( 't-dsc-begin' ) ) {
865+ // currently this is the only element that may contain primary
866+ // elements. Note that the set of primary elements may be
867+ // expanded in the future.
868+ self . prepare_dsc_table ( section_tracker , el ) ;
869+ } else {
870+ self . set_level_if_needed ( section_tracker , el ) ;
871+ if ( self . is_secondary ( el ) ) {
872+ section_tracker . add_secondary ( el ) ;
873+ } else {
874+ section_tracker . add_unknown ( el ) ;
875+ }
876+ }
877+ } ) ;
878+ section_tracker . run ( this . tracker ) ;
879+ } ;
880+
881+ // Handles a description list
882+ StandardRevisionPlugin . prototype . prepare_dsc_table = function ( section_tracker , el ) {
882883 section_tracker . enter_container ( el ) ;
883884
884885 var rows = el . children ( 'tbody' ) . children ( ) ;
@@ -897,7 +898,6 @@ $(function() {
897898 }
898899 } ) ;
899900 section_tracker . exit_container ( ) ;
900- section_tracker . run ( this . tracker ) ;
901901 } ;
902902
903903 /* Handles one description list item (inclusion of Template:dsc_*,
@@ -1498,7 +1498,7 @@ $(function() {
14981498 self . prepare_navbar ( scope ) ;
14991499 self . prepare_all_revs ( scope ) ;
15001500 self . prepare_all_inl_revs ( scope ) ;
1501- self . prepare_all_dscs ( scope ) ;
1501+ self . prepare_sections_and_dscs ( scope ) ;
15021502
15031503 if ( scope . dcl_tables . length > 0 ) {
15041504 var num_map = self . prepare_all_dcls ( scope . dcl_tables . first ( ) ) ;
0 commit comments