Index: trunk/phase3/resources/jquery/jquery.makeCollapsible.js |
— | — | @@ -4,14 +4,12 @@ |
5 | 5 | * This will enable collapsible-functionality on all passed elements. |
6 | 6 | * Will prevent binding twice to the same element. |
7 | 7 | * Initial state is expanded by default, this can be overriden by adding class |
8 | | - * "kr-collapsed" to the "kr-collapsible" element. |
9 | | - * Elements made collapsible have class "kr-made-collapsible". |
10 | | - * Except for tables and lists, the inner content is wrapped in "kr-collapsible-content". |
| 8 | + * "mw-collapsed" to the "mw-collapsible" element. |
| 9 | + * Elements made collapsible have class "mw-made-collapsible". |
| 10 | + * Except for tables and lists, the inner content is wrapped in "mw-collapsible-content". |
11 | 11 | * |
12 | 12 | * @author Krinkle <krinklemail@gmail.com> |
13 | 13 | * |
14 | | - * @TODO: Remove old "kr-" prefix |
15 | | - * |
16 | 14 | * Dual license: |
17 | 15 | * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0> |
18 | 16 | * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html> |
— | — | @@ -21,18 +19,18 @@ |
22 | 20 | |
23 | 21 | return this.each(function() { |
24 | 22 | |
25 | | - var $that = $(this).addClass( 'kr-collapsible' ), // in case $( '#myAJAXelement' ).makeCollapsible() was called |
| 23 | + var $that = $(this).addClass( 'mw-collapsible' ), // in case $( '#myAJAXelement' ).makeCollapsible() was called |
26 | 24 | that = this, |
27 | 25 | collapsetext = $(this).attr( 'data-collapsetext' ), |
28 | 26 | expandtext = $(this).attr( 'data-expandtext' ), |
29 | 27 | toggleFunction = function( that ) { |
30 | 28 | var $that = $(that), |
31 | | - $collapsible = $that.closest( '.kr-collapsible.kr-made-collapsible' ).toggleClass( 'kr-collapsed' ); |
| 29 | + $collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' ); |
32 | 30 | |
33 | 31 | // It's expanded right now |
34 | | - if ( $that.hasClass( 'kr-collapsible-toggle-expanded' ) ) { |
| 32 | + if ( $that.hasClass( 'mw-collapsible-toggle-expanded' ) ) { |
35 | 33 | // Change link to "Show" |
36 | | - $that.removeClass( 'kr-collapsible-toggle-expanded' ).addClass( 'kr-collapsible-toggle-collapsed' ); |
| 34 | + $that.removeClass( 'mw-collapsible-toggle-expanded' ).addClass( 'mw-collapsible-toggle-collapsed' ); |
37 | 35 | if ( $that.find( '> a' ).size() ) { |
38 | 36 | $that.find( '> a' ).text( expandtext ); |
39 | 37 | } else { |
— | — | @@ -50,13 +48,13 @@ |
51 | 49 | $collapsible.find( '> li' ).not( $that.parent() ).stop( true, true ).slideUp(); |
52 | 50 | |
53 | 51 | } else { // <div>, <p> etc. |
54 | | - $collapsible.find( '> .kr-collapsible-content' ).slideUp(); |
| 52 | + $collapsible.find( '> .mw-collapsible-content' ).slideUp(); |
55 | 53 | } |
56 | 54 | |
57 | 55 | // It's collapsed right now |
58 | 56 | } else { |
59 | 57 | // Change link to "Hide" |
60 | | - $that.removeClass( 'kr-collapsible-toggle-collapsed' ).addClass( 'kr-collapsible-toggle-expanded' ); |
| 58 | + $that.removeClass( 'mw-collapsible-toggle-collapsed' ).addClass( 'mw-collapsible-toggle-expanded' ); |
61 | 59 | if ( $that.find( '> a' ).size() ) { |
62 | 60 | $that.find( '> a' ).text( collapsetext ); |
63 | 61 | } else { |
— | — | @@ -70,7 +68,7 @@ |
71 | 69 | $collapsible.find( '> li' ).not( $that.parent() ).stop( true, true ).slideDown(); |
72 | 70 | |
73 | 71 | } else { // <div>, <p> etc. |
74 | | - $collapsible.find( '> .kr-collapsible-content' ).slideDown(); |
| 72 | + $collapsible.find( '> .mw-collapsible-content' ).slideDown(); |
75 | 73 | } |
76 | 74 | } |
77 | 75 | return; |
— | — | @@ -85,23 +83,23 @@ |
86 | 84 | } |
87 | 85 | |
88 | 86 | // Create toggle link with a space around the brackets ( [text] ) |
89 | | - var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="kr-collapsible-toggle kr-collapsible-toggle-expanded">' ).parent().prepend( ' [' ).append( '] ' ).click( function(e){ |
| 87 | + var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="mw-collapsible-toggle mw-collapsible-toggle-expanded">' ).parent().prepend( ' [' ).append( '] ' ).click( function(e){ |
90 | 88 | e.preventDefault(); |
91 | 89 | toggleFunction( this ); |
92 | 90 | } ); |
93 | 91 | |
94 | 92 | // Skip if it has been enabled already. |
95 | | - if ( $that.hasClass( 'kr-made-collapsible' ) ) { |
| 93 | + if ( $that.hasClass( 'mw-made-collapsible' ) ) { |
96 | 94 | return; |
97 | 95 | } else { |
98 | | - $that.addClass( 'kr-made-collapsible' ); |
| 96 | + $that.addClass( 'mw-made-collapsible' ); |
99 | 97 | } |
100 | 98 | |
101 | 99 | // Elements are treated differently |
102 | 100 | if ( $that.is( 'table' ) ) { |
103 | 101 | // The toggle-link will be in the last cell (td or th) of the first row |
104 | 102 | var $lastCell = $( 'tr:first th, tr:first td', that ).eq(-1), |
105 | | - $toggle = $lastCell.find( '> .kr-collapsible-toggle' ); |
| 103 | + $toggle = $lastCell.find( '> .mw-collapsible-toggle' ); |
106 | 104 | |
107 | 105 | if ( !$toggle.size() ) { |
108 | 106 | $lastCell.prepend( $toggleLink ); |
— | — | @@ -115,14 +113,14 @@ |
116 | 114 | } else if ( $that.is( 'ul' ) || $that.is( 'ol' ) ) { |
117 | 115 | // The toggle-link will be in the first list-item |
118 | 116 | var $firstItem = $( 'li:first', $that), |
119 | | - $toggle = $firstItem.find( '> .kr-collapsible-toggle' ); |
| 117 | + $toggle = $firstItem.find( '> .mw-collapsible-toggle' ); |
120 | 118 | |
121 | 119 | if ( !$toggle.size() ) { |
122 | 120 | // Make sure the numeral order doesn't get messed up, reset to 1 unless value-attribute is already used |
123 | 121 | if ( $firstItem.attr( 'value' ) == '' ) { |
124 | 122 | $firstItem.attr( 'value', '1' ); |
125 | 123 | } |
126 | | - $that.prepend( $toggleLink.wrap( '<li class="kr-collapsibile-toggle-li">' ).parent() ); |
| 124 | + $that.prepend( $toggleLink.wrap( '<li class="mw-collapsibile-toggle-li">' ).parent() ); |
127 | 125 | } else { |
128 | 126 | $toggleLink = $toggle.unbind( 'click' ).click( function( e ){ |
129 | 127 | e.preventDefault(); |
— | — | @@ -133,12 +131,12 @@ |
134 | 132 | } else { // <div>, <p> etc. |
135 | 133 | // Is there an content-wrapper already made ? |
136 | 134 | // If a direct child with the class does not exists, create the wrap. |
137 | | - if ( !$that.find( '> .kr-collapsible-content' ).size() ) { |
138 | | - $that.wrapInner( '<div class="kr-collapsible-content">' ); |
| 135 | + if ( !$that.find( '> .mw-collapsible-content' ).size() ) { |
| 136 | + $that.wrapInner( '<div class="mw-collapsible-content">' ); |
139 | 137 | } |
140 | 138 | |
141 | 139 | // The toggle-link will be the first child of the element |
142 | | - var $toggle = $that.find( '> .kr-collapsible-toggle' ); |
| 140 | + var $toggle = $that.find( '> .mw-collapsible-toggle' ); |
143 | 141 | |
144 | 142 | if ( !$toggle.size() ) { |
145 | 143 | $that.prepend( $toggleLink ); |
— | — | @@ -152,11 +150,8 @@ |
153 | 151 | } |
154 | 152 | console.log( $toggleLink.get(0) ); |
155 | 153 | // Initial state |
156 | | - if ( $that.hasClass( 'kr-collapsed' ) ) { |
| 154 | + if ( $that.hasClass( 'mw-collapsed' ) ) { |
157 | 155 | $toggleLink.click(); |
158 | 156 | } |
159 | 157 | } ); |
160 | | -}; |
161 | | -$( function(){ |
162 | | - $( '.kr-collapsible' ).makeCollapsible(); |
163 | | -} ); |
\ No newline at end of file |
| 158 | +}; |
\ No newline at end of file |
Index: trunk/phase3/resources/jquery/jquery.makeCollapsible.css |
— | — | @@ -1,20 +1,20 @@ |
2 | 2 | /* See also jquery.makeCollapsible.js */ |
3 | | -.kr-collapsible-toggle { |
| 3 | +.mw-collapsible-toggle { |
4 | 4 | float:right; |
5 | 5 | } |
6 | | -.kr-collapsible-toggle-expanded, |
7 | | -.kr-collapsible-toggle-expanded a { |
| 6 | +.mw-collapsible-toggle-expanded, |
| 7 | +.mw-collapsible-toggle-expanded a { |
8 | 8 | cursor:n-resize; |
9 | 9 | } |
10 | | -.kr-collapsible-toggle-collapsed, |
11 | | -.kr-collapsible-toggle-collapsed a { |
| 10 | +.mw-collapsible-toggle-collapsed, |
| 11 | +.mw-collapsible-toggle-collapsed a { |
12 | 12 | cursor:s-resize; |
13 | 13 | } |
14 | 14 | /* list-items go as wide as their parent element, don't float them inside list items */ |
15 | | -li .kr-collapsible-toggle { |
| 15 | +li .mw-collapsible-toggle { |
16 | 16 | float:none; |
17 | 17 | } |
18 | 18 | /* the added list item should have no list-style */ |
19 | | -.kr-collapsibile-toggle-li { |
| 19 | +.mw-collapsibile-toggle-li { |
20 | 20 | list-style:none; |
21 | 21 | } |
\ No newline at end of file |
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -65,6 +65,9 @@ |
66 | 66 | } else { |
67 | 67 | mw.util.$content = $( '#content' ); |
68 | 68 | } |
| 69 | + |
| 70 | + /* Enable makeCollapse */ |
| 71 | + $( '.mw-collapsible' ).makeCollapsible(); |
69 | 72 | |
70 | 73 | /* Table of Contents toggle */ |
71 | 74 | var $tocContainer = $( '#toc' ), |