Index: trunk/extensions/WikiLove/wikiLove.js |
— | — | @@ -24,116 +24,114 @@ |
25 | 25 | if ( $.wikiLove.$dialog === null ) { |
26 | 26 | // Load local configuration |
27 | 27 | var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } ); |
28 | | - $.getScript( wikiLoveConfigUrl, function() { |
29 | | - // Test to see if the 'E-mail this user' link exists |
30 | | - $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false; |
| 28 | + mw.loader.load( wikiLoveConfigUrl ); |
| 29 | + |
| 30 | + // Test to see if the 'E-mail this user' link exists |
| 31 | + $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false; |
| 32 | + |
| 33 | + // Reusable spinner string |
| 34 | + var spinner = '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/spinner.gif' + '"/>'; |
| 35 | + |
| 36 | + // Build a type list like this: |
| 37 | + var $typeList = $( '<ul id="wlTypes"></ul>' ); |
| 38 | + for( var typeId in $.wikiLove.types ) { |
| 39 | + var $button = $( '<a href="#"></a>' ); |
| 40 | + var $buttonInside = $( '<div class="wlInside"></div>' ); |
31 | 41 | |
32 | | - // Reusable spinner string |
33 | | - var spinner = '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/spinner.gif' + '"/>'; |
34 | | - |
35 | | - // Build a type list like this: |
36 | | - var $typeList = $( '<ul id="wlTypes"></ul>' ); |
37 | | - for( var typeId in $.wikiLove.types ) { |
38 | | - var $button = $( '<a href="#"></a>' ); |
39 | | - var $buttonInside = $( '<div class="wlInside"></div>' ); |
40 | | - |
41 | | - if( typeof $.wikiLove.types[typeId].icon == 'string' ) { |
42 | | - $buttonInside.append( '<div class="wlIconBox"><img src="' |
43 | | - + mw.html.escape( $.wikiLove.types[typeId].icon ) + '"/></div>' ); |
44 | | - } |
45 | | - else { |
46 | | - $buttonInside.addClass( 'wlNoIcon' ); |
47 | | - } |
48 | | - |
49 | | - $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].name + '</div>' ); |
50 | | - |
51 | | - $button.append( '<div class="wlLeftCap"></div>'); |
52 | | - $button.append( $buttonInside ); |
53 | | - $button.append( '<div class="wlRightCap"></div>'); |
54 | | - $button.data( 'typeId', typeId ); |
55 | | - $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) ); |
| 42 | + if( typeof $.wikiLove.types[typeId].icon == 'string' ) { |
| 43 | + $buttonInside.append( '<div class="wlIconBox"><img src="' |
| 44 | + + mw.html.escape( $.wikiLove.types[typeId].icon ) + '"/></div>' ); |
56 | 45 | } |
| 46 | + else { |
| 47 | + $buttonInside.addClass( 'wlNoIcon' ); |
| 48 | + } |
57 | 49 | |
58 | | - $.wikiLove.$dialog = $( '\ |
| 50 | + $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].name + '</div>' ); |
| 51 | + |
| 52 | + $button.append( '<div class="wlLeftCap"></div>'); |
| 53 | + $button.append( $buttonInside ); |
| 54 | + $button.append( '<div class="wlRightCap"></div>'); |
| 55 | + $button.data( 'typeId', typeId ); |
| 56 | + $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) ); |
| 57 | + } |
| 58 | + |
| 59 | + $.wikiLove.$dialog = $( '\ |
59 | 60 | <div id="wikiLoveDialog">\ |
60 | | - <div id="wlSelectType">\ |
61 | | - <span class="wlNumber">1</span>\ |
62 | | - <h3><html:msg key="wikilove-select-type"/></h3>\ |
63 | | - <ul id="wlTypes"></ul>\ |
64 | | - </div>\ |
65 | | - <div id="wlGetStarted">\ |
66 | | - <h2><html:msg key="wikilove-get-started-header"/></h2>\ |
67 | | - <ol>\ |
68 | | - <li><html:msg key="wikilove-get-started-list-1"/></li>\ |
69 | | - <li><html:msg key="wikilove-get-started-list-2"/></li>\ |
70 | | - <li><html:msg key="wikilove-get-started-list-3"/></li>\ |
71 | | - </ol>\ |
72 | | - </div>\ |
73 | | - <div id="wlAddDetails">\ |
74 | | - <span class="wlNumber">2</span>\ |
75 | | - <h3><html:msg key="wikilove-add-details"/></h3>\ |
76 | | - <form id="wlPreviewForm">\ |
77 | | - <label for="wlSubtype" id="wlSubtypeLabel"></label>\ |
78 | | - <select id="wlSubtype"></select>\ |
79 | | - <div id="wlSubtypeDescription"></div>\ |
80 | | - <label id="wlGalleryLabel"><html:msg key="wikilove-image"/></label>\ |
81 | | - <div id="wlGallerySpinner">' + spinner + '</div>\ |
82 | | - <div id="wlGallery"></div>\ |
83 | | - <label for="wlHeader" id="wlHeaderLabel"><html:msg key="wikilove-header"/></label>\ |
84 | | - <input type="text" class="text" id="wlHeader"/>\ |
85 | | - <label for="wlTitle" id="wlTitleLabel"><html:msg key="wikilove-title"/></label>\ |
86 | | - <input type="text" class="text" id="wlTitle"/>\ |
87 | | - <label for="wlImage" id="wlImageLabel"><html:msg key="wikilove-image"/></label>\ |
88 | | - <input type="text" class="text" id="wlImage"/>\ |
89 | | - <label for="wlMessage" id="wlMessageLabel"><html:msg key="wikilove-enter-message"/></label>\ |
90 | | - <span class="wlNote"><html:msg key="wikilove-omit-sig"/></span>\ |
91 | | - <textarea id="wlMessage"></textarea>\ |
92 | | - <div id="wlNotify">\ |
93 | | - <input type="checkbox" id="wlNotifyCheckbox" name="notify"/>\ |
94 | | - <label for="wlNotifyCheckbox"><html:msg key="wikilove-notify"/></label>\ |
95 | | - </div>\ |
96 | | - <button class="submit" id="wlButtonPreview" type="submit"></button>\ |
97 | | - ' + spinner + '\ |
98 | | - </form>\ |
99 | | - </div>\ |
100 | | - <div id="wlPreview">\ |
101 | | - <span class="wlNumber">3</span>\ |
102 | | - <h3><html:msg key="wikilove-preview"/></h3>\ |
103 | | - <div id="wlPreviewArea"></div>\ |
104 | | - <form id="wlSendForm">\ |
105 | | - <button class="submit" id="wlButtonSend" type="submit"></button>\ |
106 | | - ' + spinner + '\ |
107 | | - </form>\ |
108 | | - </div>\ |
| 61 | +<div id="wlSelectType">\ |
| 62 | + <span class="wlNumber">1</span>\ |
| 63 | + <h3><html:msg key="wikilove-select-type"/></h3>\ |
| 64 | + <ul id="wlTypes"></ul>\ |
| 65 | +</div>\ |
| 66 | +<div id="wlGetStarted">\ |
| 67 | + <h2><html:msg key="wikilove-get-started-header"/></h2>\ |
| 68 | + <ol>\ |
| 69 | + <li><html:msg key="wikilove-get-started-list-1"/></li>\ |
| 70 | + <li><html:msg key="wikilove-get-started-list-2"/></li>\ |
| 71 | + <li><html:msg key="wikilove-get-started-list-3"/></li>\ |
| 72 | + </ol>\ |
| 73 | +</div>\ |
| 74 | +<div id="wlAddDetails">\ |
| 75 | + <span class="wlNumber">2</span>\ |
| 76 | + <h3><html:msg key="wikilove-add-details"/></h3>\ |
| 77 | + <form id="wlPreviewForm">\ |
| 78 | + <label for="wlSubtype" id="wlSubtypeLabel"></label>\ |
| 79 | + <select id="wlSubtype"></select>\ |
| 80 | + <div id="wlSubtypeDescription"></div>\ |
| 81 | + <label id="wlGalleryLabel"><html:msg key="wikilove-image"/></label>\ |
| 82 | + <div id="wlGallerySpinner">' + spinner + '</div>\ |
| 83 | + <div id="wlGallery"></div>\ |
| 84 | + <label for="wlHeader" id="wlHeaderLabel"><html:msg key="wikilove-header"/></label>\ |
| 85 | + <input type="text" class="text" id="wlHeader"/>\ |
| 86 | + <label for="wlTitle" id="wlTitleLabel"><html:msg key="wikilove-title"/></label>\ |
| 87 | + <input type="text" class="text" id="wlTitle"/>\ |
| 88 | + <label for="wlImage" id="wlImageLabel"><html:msg key="wikilove-image"/></label>\ |
| 89 | + <input type="text" class="text" id="wlImage"/>\ |
| 90 | + <label for="wlMessage" id="wlMessageLabel"><html:msg key="wikilove-enter-message"/></label>\ |
| 91 | + <span class="wlNote"><html:msg key="wikilove-omit-sig"/></span>\ |
| 92 | + <textarea id="wlMessage"></textarea>\ |
| 93 | + <div id="wlNotify">\ |
| 94 | + <input type="checkbox" id="wlNotifyCheckbox" name="notify"/>\ |
| 95 | + <label for="wlNotifyCheckbox"><html:msg key="wikilove-notify"/></label>\ |
| 96 | + </div>\ |
| 97 | + <button class="submit" id="wlButtonPreview" type="submit"></button>\ |
| 98 | + ' + spinner + '\ |
| 99 | + </form>\ |
| 100 | +</div>\ |
| 101 | +<div id="wlPreview">\ |
| 102 | + <span class="wlNumber">3</span>\ |
| 103 | + <h3><html:msg key="wikilove-preview"/></h3>\ |
| 104 | + <div id="wlPreviewArea"></div>\ |
| 105 | + <form id="wlSendForm">\ |
| 106 | + <button class="submit" id="wlButtonSend" type="submit"></button>\ |
| 107 | + ' + spinner + '\ |
| 108 | + </form>\ |
| 109 | +</div>\ |
109 | 110 | </div>' ); |
110 | | - $.wikiLove.$dialog.localize(); |
111 | | - |
112 | | - $.wikiLove.$dialog.dialog({ |
113 | | - width: 800, |
114 | | - position: ['center', 80], |
115 | | - autoOpen: false, |
116 | | - title: mw.msg( 'wikilove-dialog-title' ), |
117 | | - modal: true, |
118 | | - resizable: false |
119 | | - }); |
120 | | - |
121 | | - $( '#wlButtonPreview' ).button( { label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } } ); |
122 | | - $( '#wlButtonSend' ).button( { label: mw.msg( 'wikilove-button-send' ) } ); |
123 | | - $( '#wlAddDetails' ).hide(); |
124 | | - $( '#wlPreview' ).hide(); |
125 | | - $( '#wlTypes' ).replaceWith( $typeList ); |
126 | | - |
127 | | - $( '#wlTypes a' ).click( $.wikiLove.clickType ); |
128 | | - $( '#wlSubtype' ).change( $.wikiLove.changeSubtype ); |
129 | | - $( '#wlPreviewForm' ).submit( $.wikiLove.submitPreview ); |
130 | | - $( '#wlSendForm' ).click( $.wikiLove.submitSend ); |
131 | | - $( '#wlMessage' ).elastic(); // have the message textarea grow automatically |
132 | | - |
133 | | - $.wikiLove.$dialog.dialog( 'open' ); |
134 | | - }); |
135 | | - } else { |
136 | | - $.wikiLove.$dialog.dialog( 'open' ); |
| 111 | + $.wikiLove.$dialog.localize(); |
| 112 | + |
| 113 | + $.wikiLove.$dialog.dialog({ |
| 114 | + width: 800, |
| 115 | + position: ['center', 80], |
| 116 | + autoOpen: false, |
| 117 | + title: mw.msg( 'wikilove-dialog-title' ), |
| 118 | + modal: true, |
| 119 | + resizable: false |
| 120 | + }); |
| 121 | + |
| 122 | + $( '#wlButtonPreview' ).button( { label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } } ); |
| 123 | + $( '#wlButtonSend' ).button( { label: mw.msg( 'wikilove-button-send' ) } ); |
| 124 | + $( '#wlAddDetails' ).hide(); |
| 125 | + $( '#wlPreview' ).hide(); |
| 126 | + $( '#wlTypes' ).replaceWith( $typeList ); |
| 127 | + |
| 128 | + $( '#wlTypes a' ).click( $.wikiLove.clickType ); |
| 129 | + $( '#wlSubtype' ).change( $.wikiLove.changeSubtype ); |
| 130 | + $( '#wlPreviewForm' ).submit( $.wikiLove.submitPreview ); |
| 131 | + $( '#wlSendForm' ).click( $.wikiLove.submitSend ); |
| 132 | + $( '#wlMessage' ).elastic(); // have the message textarea grow automatically |
137 | 133 | } |
| 134 | + |
| 135 | + $.wikiLove.$dialog.dialog( 'open' ); |
138 | 136 | }, |
139 | 137 | |
140 | 138 | /* |