Index: branches/REL1_17/phase3/docs/hooks.txt |
— | — | @@ -1110,7 +1110,9 @@ |
1111 | 1111 | $variableIDs: array of strings |
1112 | 1112 | |
1113 | 1113 | 'MakeGlobalVariablesScript': called right before Skin::makeVariablesScript |
1114 | | -is executed |
| 1114 | +is executed. Ideally, this hook should only be used to add variables that |
| 1115 | +depend on the current page/request; static configuration should be added |
| 1116 | +through ResourceLoaderConfigVars instead. |
1115 | 1117 | &$vars: variable (or multiple variables) to be added into the output |
1116 | 1118 | of Skin::makeVariablesScript |
1117 | 1119 | |
— | — | @@ -1362,9 +1364,15 @@ |
1363 | 1365 | &$obj: RawPage object |
1364 | 1366 | &$text: The text that's going to be the output |
1365 | 1367 | |
1366 | | -'RecentChange_save': called at the end of RecenChange::save() |
| 1368 | +'RecentChange_save': called at the end of RecentChange::save() |
1367 | 1369 | $recentChange: RecentChange object |
1368 | 1370 | |
| 1371 | +'ResourceLoaderConfigVars': called at the end of |
| 1372 | +ResourceLoaderStartUpModule::getConfig(). Use this to export static |
| 1373 | +configuration variables to JavaScript. Things that depend on the current |
| 1374 | +page/request state must be added through MakeGlobalVariablesScript instead. |
| 1375 | +&$vars: array( variable name => value ) |
| 1376 | + |
1369 | 1377 | 'RevisionInsertComplete': called after a revision is inserted into the DB |
1370 | 1378 | &$revision: the Revision |
1371 | 1379 | $data: the data stored in old_text. The meaning depends on $flags: if external |
Property changes on: branches/REL1_17/phase3/docs/hooks.txt |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1372 | 1380 | Merged /trunk/phase3/docs/hooks.txt:r79856,79877-79878,79885,79924,79926,79952 |
Index: branches/REL1_17/phase3/docs/export-0.5.xsd |
— | — | @@ -0,0 +1,213 @@ |
| 2 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 3 | +<!-- |
| 4 | + This is an XML Schema description of the format |
| 5 | + output by MediaWiki's Special:Export system. |
| 6 | + |
| 7 | + Version 0.2 adds optional basic file upload info support, |
| 8 | + which is used by our OAI export/import submodule. |
| 9 | + |
| 10 | + Version 0.3 adds some site configuration information such |
| 11 | + as a list of defined namespaces. |
| 12 | + |
| 13 | + Version 0.4 adds per-revision delete flags, log exports, |
| 14 | + discussion threading data, a per-page redirect flag, and |
| 15 | + per-namespace capitalization. |
| 16 | + |
| 17 | + The canonical URL to the schema document is: |
| 18 | + http://www.mediawiki.org/xml/export-0.5.xsd |
| 19 | + |
| 20 | + Use the namespace: |
| 21 | + http://www.mediawiki.org/xml/export-0.5/ |
| 22 | +--> |
| 23 | +<schema xmlns="http://www.w3.org/2001/XMLSchema" |
| 24 | + xmlns:mw="http://www.mediawiki.org/xml/export-0.5/" |
| 25 | + targetNamespace="http://www.mediawiki.org/xml/export-0.5/" |
| 26 | + elementFormDefault="qualified"> |
| 27 | + |
| 28 | + <annotation> |
| 29 | + <documentation xml:lang="en"> |
| 30 | + MediaWiki's page export format |
| 31 | + </documentation> |
| 32 | + </annotation> |
| 33 | + |
| 34 | + <!-- Need this to reference xml:lang --> |
| 35 | + <import namespace="http://www.w3.org/XML/1998/namespace" |
| 36 | + schemaLocation="http://www.w3.org/2001/xml.xsd"/> |
| 37 | + |
| 38 | + <!-- Our root element --> |
| 39 | + <element name="mediawiki" type="mw:MediaWikiType"/> |
| 40 | + |
| 41 | + <complexType name="MediaWikiType"> |
| 42 | + <sequence> |
| 43 | + <element name="siteinfo" type="mw:SiteInfoType" |
| 44 | + minOccurs="0" maxOccurs="1"/> |
| 45 | + <element name="page" type="mw:PageType" |
| 46 | + minOccurs="0" maxOccurs="unbounded"/> |
| 47 | + </sequence> |
| 48 | + <attribute name="version" type="string" use="required"/> |
| 49 | + <attribute ref="xml:lang" use="required"/> |
| 50 | + </complexType> |
| 51 | + |
| 52 | + <complexType name="SiteInfoType"> |
| 53 | + <sequence> |
| 54 | + <element name="sitename" type="string" minOccurs="0" /> |
| 55 | + <element name="base" type="anyURI" minOccurs="0" /> |
| 56 | + <element name="generator" type="string" minOccurs="0" /> |
| 57 | + <element name="case" type="mw:CaseType" minOccurs="0" /> |
| 58 | + <element name="namespaces" type="mw:NamespacesType" minOccurs="0" /> |
| 59 | + </sequence> |
| 60 | + </complexType> |
| 61 | + |
| 62 | + <simpleType name="CaseType"> |
| 63 | + <restriction base="NMTOKEN"> |
| 64 | + <!-- Cannot have two titles differing only by case of first letter. --> |
| 65 | + <!-- Default behavior through 1.5, $wgCapitalLinks = true --> |
| 66 | + <enumeration value="first-letter" /> |
| 67 | + |
| 68 | + <!-- Complete title is case-sensitive --> |
| 69 | + <!-- Behavior when $wgCapitalLinks = false --> |
| 70 | + <enumeration value="case-sensitive" /> |
| 71 | + |
| 72 | + <!-- Cannot have two titles differing only by case. --> |
| 73 | + <!-- Not yet implemented as of MediaWiki 1.5 --> |
| 74 | + <enumeration value="case-insensitive" /> |
| 75 | + </restriction> |
| 76 | + </simpleType> |
| 77 | + |
| 78 | + <simpleType name="DeletedFlagType"> |
| 79 | + <restriction base="NMTOKEN"> |
| 80 | + <enumeration value="deleted"/> |
| 81 | + </restriction> |
| 82 | + </simpleType> |
| 83 | + |
| 84 | + <complexType name="NamespacesType"> |
| 85 | + <sequence> |
| 86 | + <element name="namespace" type="mw:NamespaceType" |
| 87 | + minOccurs="0" maxOccurs="unbounded" /> |
| 88 | + </sequence> |
| 89 | + </complexType> |
| 90 | + |
| 91 | + <complexType name="NamespaceType"> |
| 92 | + <simpleContent> |
| 93 | + <extension base="string"> |
| 94 | + <attribute name="key" type="integer" /> |
| 95 | + <attribute name="case" type="mw:CaseType" /> |
| 96 | + </extension> |
| 97 | + </simpleContent> |
| 98 | + </complexType> |
| 99 | + |
| 100 | + <complexType name="PageType"> |
| 101 | + <sequence> |
| 102 | + <!-- Title in text form. (Using spaces, not underscores; with namespace ) --> |
| 103 | + <element name="title" type="string"/> |
| 104 | + |
| 105 | + <!-- optional page ID number --> |
| 106 | + <element name="id" type="positiveInteger" minOccurs="0"/> |
| 107 | + |
| 108 | + <!-- flag if the current revision is a redirect --> |
| 109 | + <element name="redirect" minOccurs="0"/> |
| 110 | + |
| 111 | + <!-- comma-separated list of string tokens, if present --> |
| 112 | + <element name="restrictions" type="string" minOccurs="0"/> |
| 113 | + |
| 114 | + <!-- Zero or more sets of revision or upload data --> |
| 115 | + <choice minOccurs="0" maxOccurs="unbounded"> |
| 116 | + <element name="revision" type="mw:RevisionType" /> |
| 117 | + <element name="upload" type="mw:UploadType" /> |
| 118 | + <element name="logitem" type="mw:LogItemType" /> |
| 119 | + </choice> |
| 120 | + |
| 121 | + <!-- Zero or One sets of discussion threading data --> |
| 122 | + <element name="discussionthreadinginfo" minOccurs="0" maxOccurs="1" type="mw:DiscussionThreadingInfo" /> |
| 123 | + </sequence> |
| 124 | + </complexType> |
| 125 | + |
| 126 | + <complexType name="RevisionType"> |
| 127 | + <sequence> |
| 128 | + <element name="id" type="positiveInteger" minOccurs="0"/> |
| 129 | + <element name="timestamp" type="dateTime"/> |
| 130 | + <element name="contributor" type="mw:ContributorType"/> |
| 131 | + <element name="minor" minOccurs="0" /> |
| 132 | + <element name="comment" type="mw:CommentType" minOccurs="0"/> |
| 133 | + <element name="text" type="mw:TextType" /> |
| 134 | + </sequence> |
| 135 | + </complexType> |
| 136 | + |
| 137 | + <complexType name="LogItemType"> |
| 138 | + <sequence> |
| 139 | + <element name="id" type="positiveInteger" minOccurs="0"/> |
| 140 | + <element name="timestamp" type="dateTime"/> |
| 141 | + <element name="contributor" type="mw:ContributorType"/> |
| 142 | + <element name="comment" type="mw:CommentType" minOccurs="0"/> |
| 143 | + <element name="type" type="string" /> |
| 144 | + <element name="action" type="string" /> |
| 145 | + <element name="text" type="mw:TextType" /> |
| 146 | + </sequence> |
| 147 | + </complexType> |
| 148 | + |
| 149 | + <complexType name="CommentType"> |
| 150 | + <simpleContent> |
| 151 | + <extension base="string"> |
| 152 | + <!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent --> |
| 153 | + <attribute name="deleted" use="optional" type="mw:DeletedFlagType"/> |
| 154 | + </extension> |
| 155 | + </simpleContent> |
| 156 | + </complexType> |
| 157 | + |
| 158 | + |
| 159 | + <complexType name="TextType"> |
| 160 | + <simpleContent> |
| 161 | + <extension base="string"> |
| 162 | + <attribute ref="xml:space" use="optional" default="preserve" /> |
| 163 | + <!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent --> |
| 164 | + <attribute name="deleted" use="optional" type="mw:DeletedFlagType"/> |
| 165 | + <attribute name="bytes" use="optional" type="nonNegativeInteger"/> |
| 166 | + </extension> |
| 167 | + </simpleContent> |
| 168 | + </complexType> |
| 169 | + |
| 170 | + <complexType name="ContributorType"> |
| 171 | + <sequence> |
| 172 | + <element name="username" type="string" minOccurs="0"/> |
| 173 | + <element name="id" type="positiveInteger" minOccurs="0" /> |
| 174 | + |
| 175 | + <element name="ip" type="string" minOccurs="0"/> |
| 176 | + </sequence> |
| 177 | + <!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent --> |
| 178 | + <attribute name="deleted" use="optional" type="mw:DeletedFlagType"/> |
| 179 | + </complexType> |
| 180 | + |
| 181 | + <complexType name="UploadType"> |
| 182 | + <sequence> |
| 183 | + <!-- Revision-style data... --> |
| 184 | + <element name="timestamp" type="dateTime"/> |
| 185 | + <element name="contributor" type="mw:ContributorType"/> |
| 186 | + <element name="comment" type="string" minOccurs="0"/> |
| 187 | + |
| 188 | + <!-- Filename. (Using underscores, not spaces. No 'Image:' namespace marker.) --> |
| 189 | + <element name="filename" type="string"/> |
| 190 | + |
| 191 | + <!-- URI at which this resource can be obtained --> |
| 192 | + <element name="src" type="anyURI"/> |
| 193 | + |
| 194 | + <element name="size" type="positiveInteger" /> |
| 195 | + |
| 196 | + <!-- TODO: add other metadata fields --> |
| 197 | + </sequence> |
| 198 | + </complexType> |
| 199 | + |
| 200 | + <!-- Discussion threading data for LiquidThreads --> |
| 201 | + <complexType name="DiscussionThreadingInfo"> |
| 202 | + <sequence> |
| 203 | + <element name="ThreadSubject" type="string" /> |
| 204 | + <element name="ThreadParent" type="positiveInteger" /> |
| 205 | + <element name="ThreadAncestor" type="positiveInteger" /> |
| 206 | + <element name="ThreadPage" type="string" /> |
| 207 | + <element name="ThreadID" type="positiveInteger" /> |
| 208 | + <element name="ThreadAuthor" type="string" /> |
| 209 | + <element name="ThreadEditStatus" type="string" /> |
| 210 | + <element name="ThreadType" type="string" /> |
| 211 | + </sequence> |
| 212 | + </complexType> |
| 213 | + |
| 214 | +</schema> |
Property changes on: branches/REL1_17/phase3/docs/export-0.5.xsd |
___________________________________________________________________ |
Added: svn:mergeinfo |
1 | 215 | Merged /branches/new-installer/phase3/docs/export-0.5.xsd:r43664-66004 |
2 | 216 | Merged /branches/REL1_15/phase3/docs/export-0.5.xsd:r51646 |
3 | 217 | Merged /branches/sqlite/docs/export-0.5.xsd:r58211-58321 |
4 | 218 | Merged /trunk/phase3/docs/export-0.5.xsd:r79878-79879 |
Added: svn:eol-style |
5 | 219 | + native |
Index: branches/REL1_17/phase3/includes/User.php |
— | — | @@ -652,7 +652,7 @@ |
653 | 653 | if( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) { |
654 | 654 | return $result; |
655 | 655 | } |
656 | | - $rfc5322_atext = "a-z0-9!#$%&'*+-\/=?^_`{|}—~" ; |
| 656 | + $rfc5322_atext = "a-z0-9!#$%&'*+-\/=?^_`{|}~" ; |
657 | 657 | $rfc1034_ldh_str = "a-z0-9-" ; |
658 | 658 | |
659 | 659 | $HTML5_email_regexp = "/ |
Index: branches/REL1_17/phase3/includes/Export.php |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | * @return string |
356 | 356 | */ |
357 | 357 | function schemaVersion() { |
358 | | - return "0.4"; |
| 358 | + return "0.5"; |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
— | — | @@ -511,12 +511,12 @@ |
512 | 512 | // Raw text from the database may have invalid chars |
513 | 513 | $text = strval( Revision::getRevisionText( $row ) ); |
514 | 514 | $out .= " " . Xml::elementClean( 'text', |
515 | | - array( 'xml:space' => 'preserve' ), |
| 515 | + array( 'xml:space' => 'preserve', 'bytes' => $row->rev_len ), |
516 | 516 | strval( $text ) ) . "\n"; |
517 | 517 | } else { |
518 | 518 | // Stub output |
519 | 519 | $out .= " " . Xml::element( 'text', |
520 | | - array( 'id' => $row->rev_text_id ), |
| 520 | + array( 'id' => $row->rev_text_id, 'bytes' => $row->rev_len ), |
521 | 521 | "" ) . "\n"; |
522 | 522 | } |
523 | 523 | |
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -85,6 +85,8 @@ |
86 | 86 | $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate(); |
87 | 87 | } |
88 | 88 | |
| 89 | + wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) ); |
| 90 | + |
89 | 91 | return $vars; |
90 | 92 | } |
91 | 93 | |
Index: branches/REL1_17/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -41,8 +41,8 @@ |
42 | 42 | // (but not Safari on Windows) |
43 | 43 | } else if ( !( profile.platform == 'win' && profile.name == 'safari' ) |
44 | 44 | && ( profile.name == 'safari' |
45 | | - || profile.platform == 'mac' |
46 | | - || profile.name == 'konqueror' ) ) { |
| 45 | + || profile.platform == 'mac' |
| 46 | + || profile.name == 'konqueror' ) ) { |
47 | 47 | mw.util.tooltipAccessKeyPrefix = 'ctrl-'; |
48 | 48 | |
49 | 49 | // Firefox 2.x |
— | — | @@ -208,26 +208,26 @@ |
209 | 209 | * ('#foobar') of that item. |
210 | 210 | * |
211 | 211 | * @example mw.util.addPortletLink( |
212 | | - * 'p-tb', 'http://mediawiki.org/', |
213 | | - * 'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', '#t-print' |
214 | | - * ) |
| 212 | + * 'p-tb', 'http://mediawiki.org/', |
| 213 | + * 'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', '#t-print' |
| 214 | + * ) |
215 | 215 | * |
216 | 216 | * @param portlet ID of the target portlet ('p-cactions' or 'p-personal' etc.) |
217 | 217 | * @param href Link URL |
218 | 218 | * @param text Link text (will be automatically converted to lower |
219 | | - * case by CSS for p-cactions in Monobook) |
| 219 | + * case by CSS for p-cactions in Monobook) |
220 | 220 | * @param id ID of the new item, should be unique and preferably have |
221 | | - * the appropriate prefix ('ca-', 'pt-', 'n-' or 't-') |
| 221 | + * the appropriate prefix ( 'ca-', 'pt-', 'n-' or 't-' ) |
222 | 222 | * @param tooltip Text to show when hovering over the link, without accesskey suffix |
223 | 223 | * @param accesskey Access key to activate this link (one character, try |
224 | | - * to avoid conflicts. Use $('[accesskey=x').get() in the console to |
225 | | - * see if 'x' is already used. |
| 224 | + * to avoid conflicts. Use $( '[accesskey=x' ).get() in the console to |
| 225 | + * see if 'x' is already used. |
226 | 226 | * @param nextnode DOM node or jQuery-selector of the item that the new |
227 | | - * item should be added before, should be another item in the same |
228 | | - * list will be ignored if not the so |
| 227 | + * item should be added before, should be another item in the same |
| 228 | + * list will be ignored if not the so |
229 | 229 | * |
230 | 230 | * @return The DOM node of the new item (a LI element, or A element for |
231 | | - * older skins) or null. |
| 231 | + * older skins) or null. |
232 | 232 | */ |
233 | 233 | 'addPortletLink' : function( portlet, href, text, id, tooltip, accesskey, nextnode ) { |
234 | 234 | |
— | — | @@ -314,6 +314,80 @@ |
315 | 315 | |
316 | 316 | return $item.get( 0 ); |
317 | 317 | } |
| 318 | + }, |
| 319 | + |
| 320 | + /** |
| 321 | + * Validate a string as representing a valid e-mail address |
| 322 | + * according to HTML5 specification. Please note the specification |
| 323 | + * does not validate a domain with one character. |
| 324 | + * |
| 325 | + * FIXME: should be moved to a JavaScript validation module. |
| 326 | + */ |
| 327 | + 'validateEmail' : function( mailtxt ) { |
| 328 | + if( mailtxt === '' ) { |
| 329 | + return null; |
| 330 | + } |
| 331 | + |
| 332 | + /** |
| 333 | + * HTML5 defines a string as valid e-mail address if it matches |
| 334 | + * the ABNF: |
| 335 | + * 1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str ) |
| 336 | + * With: |
| 337 | + * - atext : defined in RFC 5322 section 3.2.3 |
| 338 | + * - ldh-str : defined in RFC 1034 section 3.5 |
| 339 | + * |
| 340 | + * (see STD 68 / RFC 5234 http://tools.ietf.org/html/std68): |
| 341 | + */ |
| 342 | + |
| 343 | + /** |
| 344 | + * First, define the RFC 5322 'atext' which is pretty easy : |
| 345 | + * atext = ALPHA / DIGIT / ; Printable US-ASCII |
| 346 | + "!" / "#" / ; characters not including |
| 347 | + "$" / "%" / ; specials. Used for atoms. |
| 348 | + "&" / "'" / |
| 349 | + "*" / "+" / |
| 350 | + "-" / "/" / |
| 351 | + "=" / "?" / |
| 352 | + "^" / "_" / |
| 353 | + "`" / "{" / |
| 354 | + "|" / "}" / |
| 355 | + "~" |
| 356 | + */ |
| 357 | + var rfc5322_atext = "a-z0-9!#$%&'*+-/=?^_`{|}~", |
| 358 | + |
| 359 | + /** |
| 360 | + * Next define the RFC 1034 'ldh-str' |
| 361 | + * <domain> ::= <subdomain> | " " |
| 362 | + * <subdomain> ::= <label> | <subdomain> "." <label> |
| 363 | + * <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ] |
| 364 | + * <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str> |
| 365 | + * <let-dig-hyp> ::= <let-dig> | "-" |
| 366 | + * <let-dig> ::= <letter> | <digit> |
| 367 | + */ |
| 368 | + rfc1034_ldh_str = "a-z0-9-", |
| 369 | + |
| 370 | + HTML5_email_regexp = new RegExp( |
| 371 | + // start of string |
| 372 | + '^' |
| 373 | + + |
| 374 | + // User part which is liberal :p |
| 375 | + '[' + rfc5322_atext + '\\.' + ']' + '+' |
| 376 | + + |
| 377 | + // "at" |
| 378 | + '@' |
| 379 | + + |
| 380 | + // Domain first part |
| 381 | + '[' + rfc1034_ldh_str + ']+' |
| 382 | + + |
| 383 | + // Second part and following are separated by a dot |
| 384 | + '(?:\\.[' + rfc1034_ldh_str + ']+)+' |
| 385 | + + |
| 386 | + // End of string |
| 387 | + '$', |
| 388 | + // RegExp is case insensitive |
| 389 | + 'i' |
| 390 | + ); |
| 391 | + return (null !== mailtxt.match( HTML5_email_regexp ) ); |
318 | 392 | } |
319 | 393 | |
320 | 394 | }; |
Index: branches/REL1_17/phase3/resources/Resources.php |
— | — | @@ -339,6 +339,7 @@ |
340 | 340 | 'mediawiki.special.preferences' => array( |
341 | 341 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.preferences.js', |
342 | 342 | 'styles' => 'resources/mediawiki.special/mediawiki.special.preferences.css', |
| 343 | + 'messages' => array( 'email-address-validity-valid', 'email-address-validity-invalid' ), |
343 | 344 | ), |
344 | 345 | 'mediawiki.special.search' => array( |
345 | 346 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.search.js', |
Index: branches/REL1_17/phase3/resources/mediawiki.special/mediawiki.special.preferences.css |
— | — | @@ -2,12 +2,12 @@ |
3 | 3 | padding: 2px 1em; |
4 | 4 | } |
5 | 5 | body.ltr #mw-emailaddress-validity { |
6 | | - border-bottom-right-radius:0.8em; |
7 | | - border-top-right-radius:0.8em; |
| 6 | + border-bottom-right-radius: 0.8em; |
| 7 | + border-top-right-radius: 0.8em; |
8 | 8 | } |
9 | 9 | body.rtl #mw-emailaddress-validity { |
10 | | - border-bottom-left-radius:0.8em; |
11 | | - border-top-left-radius:0.8em; |
| 10 | + border-bottom-left-radius: 0.8em; |
| 11 | + border-top-left-radius: 0.8em; |
12 | 12 | } |
13 | 13 | #mw-emailaddress-validity.valid { |
14 | 14 | border: 1px solid #80FF80; |
Index: branches/REL1_17/phase3/resources/mediawiki.special/mediawiki.special.preferences.js |
— | — | @@ -7,121 +7,69 @@ |
8 | 8 | .addClass( 'jsprefs' ) |
9 | 9 | .before( $( '<ul id="preftoc"></ul>' ) ) |
10 | 10 | .children( 'fieldset' ) |
11 | | - .hide() |
12 | | - .addClass( 'prefsection' ) |
13 | | - .children( 'legend' ) |
14 | | - .addClass( 'mainLegend' ) |
15 | | - .each( function( i ) { |
16 | | - $(this).parent().attr( 'id', 'prefsection-' + i ); |
17 | | - if ( i === 0 ) { |
18 | | - $(this).parent().show(); |
19 | | - } |
20 | | - $( '#preftoc' ).append( |
21 | | - $( '<li></li>' ) |
22 | | - .addClass( i === 0 ? 'selected' : null ) |
23 | | - .append( |
24 | | - $( '<a></a>') |
25 | | - .text( $(this).text() ) |
26 | | - .attr( 'href', '#prefsection-' + i ) |
27 | | - .mousedown( function( e ) { |
28 | | - $(this).parent().parent().find( 'li' ).removeClass( 'selected' ); |
29 | | - $(this).parent().addClass( 'selected' ); |
30 | | - e.preventDefault(); |
31 | | - return false; |
32 | | - } ) |
33 | | - .click( function( e ) { |
34 | | - $( '#preferences > fieldset' ).hide(); |
35 | | - $( '#prefsection-' + i ).show(); |
36 | | - e.preventDefault(); |
37 | | - return false; |
38 | | - } ) |
39 | | - ) |
40 | | - ); |
41 | | - } ); |
| 11 | + .hide() |
| 12 | + .addClass( 'prefsection' ) |
| 13 | + .children( 'legend' ) |
| 14 | + .addClass( 'mainLegend' ) |
| 15 | + .each( function( i ) { |
| 16 | + $(this).parent().attr( 'id', 'prefsection-' + i ); |
| 17 | + if ( i === 0 ) { |
| 18 | + $(this).parent().show(); |
| 19 | + } |
| 20 | + $( '#preftoc' ).append( |
| 21 | + $( '<li></li>' ) |
| 22 | + .addClass( i === 0 ? 'selected' : null ) |
| 23 | + .append( |
| 24 | + $( '<a></a>') |
| 25 | + .text( $(this).text() ) |
| 26 | + .attr( 'href', '#prefsection-' + i ) |
| 27 | + .mousedown( function( e ) { |
| 28 | + $(this).parent().parent().find( 'li' ).removeClass( 'selected' ); |
| 29 | + $(this).parent().addClass( 'selected' ); |
| 30 | + e.preventDefault(); |
| 31 | + return false; |
| 32 | + } ) |
| 33 | + .click( function( e ) { |
| 34 | + $( '#preferences > fieldset' ).hide(); |
| 35 | + $( '#prefsection-' + i ).show(); |
| 36 | + e.preventDefault(); |
| 37 | + return false; |
| 38 | + } ) |
| 39 | + ) |
| 40 | + ); |
| 41 | + } |
| 42 | + ); |
42 | 43 | |
43 | | -// Lame tip to let user know if its email is valid. See bug 22449 |
44 | | -$( '#mw-input-emailaddress' ) |
45 | | - .keyup( function () { |
46 | | - if( $( "#mw-emailaddress-validity" ).length == 0 ) { |
47 | | - $(this).after( '<label for="mw-input-emailaddress" id="mw-emailaddress-validity"></label>' ); |
48 | | - } |
49 | | - var isValid = wfValidateEmail( $(this).val() ); |
50 | | - var class_to_add = isValid ? 'valid' : 'invalid'; |
51 | | - var class_to_remove = isValid ? 'invalid' : 'valid'; |
52 | | - $( '#mw-emailaddress-validity' ) |
53 | | - .text( isValid ? 'Looks valid' : 'Valid address required!' ) |
54 | | - .addClass( class_to_add ) |
55 | | - .removeClass( class_to_remove ); |
56 | | - } ); |
57 | | - |
58 | 44 | /** |
59 | | - * Validate a string as representing a valid e-mail address |
60 | | - * according to HTML5 specification. Please note the specification |
61 | | - * does not validate a domain with one character. |
62 | | - * |
63 | | - * FIXME: should be moved to a JavaScript validation module. |
| 45 | + * Given an email validity status (true, false, null) update the label CSS class |
64 | 46 | */ |
65 | | -wfValidateEmail = function( mailtxt ) { |
66 | | - if( mailtxt == '' ) { return null; } |
| 47 | +var updateMailValidityLabel = function( mail ) { |
| 48 | + var isValid = mw.util.validateEmail( mail ), |
| 49 | + $label = $( '#mw-emailaddress-validity' ); |
67 | 50 | |
68 | | - /** |
69 | | - * HTML 5 define a string as valid e-mail address if it matches |
70 | | - * the ABNF : |
71 | | - * 1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str ) |
72 | | - * With: |
73 | | - * - atext : defined in RFC 5322 section 3.2.3 |
74 | | - * - ldh-str : defined in RFC 1034 section 3.5 |
75 | | - * |
76 | | - * (see STD 68 / RFC 5234 http://tools.ietf.org/html/std68): |
77 | | - */ |
| 51 | + // We allow empty address |
| 52 | + if( isValid === null ) { |
| 53 | + $label.text( '' ).removeClass( 'valid invalid' ); |
78 | 54 | |
79 | | - /** |
80 | | - * First, define the RFC 5322 'atext' which is pretty easy : |
81 | | - * atext = ALPHA / DIGIT / ; Printable US-ASCII |
82 | | - "!" / "#" / ; characters not including |
83 | | - "$" / "%" / ; specials. Used for atoms. |
84 | | - "&" / "'" / |
85 | | - "*" / "+" / |
86 | | - "-" / "/" / |
87 | | - "=" / "?" / |
88 | | - "^" / "_" / |
89 | | - "`" / "{" / |
90 | | - "|" / "}" / |
91 | | - "~" |
92 | | - */ |
93 | | - var rfc5322_atext = "a-z0-9!#$%&'*+-/=?^_`{|}—~" ; |
| 55 | + // Valid |
| 56 | + } else if ( isValid ) { |
| 57 | + $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' ); |
94 | 58 | |
95 | | - /** |
96 | | - * Next define the RFC 1034 'ldh-str' |
97 | | - * <domain> ::= <subdomain> | " " |
98 | | - * <subdomain> ::= <label> | <subdomain> "." <label> |
99 | | - * <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ] |
100 | | - * <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str> |
101 | | - * <let-dig-hyp> ::= <let-dig> | "-" |
102 | | - * <let-dig> ::= <letter> | <digit> |
103 | | - */ |
104 | | - var rfc1034_ldh_str = "a-z0-9-" ; |
105 | | - |
106 | | - var HTML5_email_regexp = new RegExp( |
107 | | - // start of string |
108 | | - '^' |
109 | | - + |
110 | | - // User part which is liberal :p |
111 | | - '[' + rfc5322_atext + '\\.' + ']' + '+' |
112 | | - + |
113 | | - // "apostrophe" |
114 | | - '@' |
115 | | - + |
116 | | - // Domain first part |
117 | | - '[' + rfc1034_ldh_str + ']+' |
118 | | - + |
119 | | - // Second part and following are separated by a dot |
120 | | - '(\\.[' + rfc1034_ldh_str + ']+)+' |
121 | | - + |
122 | | - // End of string |
123 | | - '$', |
124 | | - // RegExp is case insensitive |
125 | | - 'i' |
126 | | - ); |
127 | | - return mailtxt.match( HTML5_email_regexp ); |
| 59 | + // Not valid |
| 60 | + } else { |
| 61 | + $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' ); |
| 62 | + } |
128 | 63 | }; |
| 64 | + |
| 65 | +// Lame tip to let user know if its email is valid. See bug 22449 |
| 66 | +// Only bind once for 'blur' so that the user can fill it in without errors |
| 67 | +// After that look at every keypress for direct feedback if it was invalid onblur |
| 68 | +$( '#mw-input-wpemailaddress' ).one( 'blur', function() { |
| 69 | + if ( $( '#mw-emailaddress-validity' ).length === 0 ) { |
| 70 | + $(this).after( '<label for="mw-input-wpemailaddress" id="mw-emailaddress-validity"></label>' ); |
| 71 | + } |
| 72 | + updateMailValidityLabel( $(this).val() ); |
| 73 | + $(this).keyup( function() { |
| 74 | + updateMailValidityLabel( $(this).val() ); |
| 75 | + } ); |
| 76 | +} ); |