r112692 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112691‎ | r112692 | r112693 >
Date:14:59, 29 February 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Consistently indent, even though it leads to huge indentation, because I had problems understanding the code.
Not many non-whitespace changes.
Modified paths:
  • /trunk/extensions/Translate/resources/ext.translate.special.pagetranslation.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/resources/ext.translate.special.pagetranslation.js
@@ -7,71 +7,74 @@
88 * Credits: http://jqueryui.com/demos/autocomplete/#multiple
99 */
1010 jQuery( function( $ ) {
 11+ "use strict"
 12+
1113 $.widget( "ui.combobox", {
12 - _create: function() {
13 - var self = this,
14 - select = this.element.hide(),
15 - selected = select.children( ":selected" );
16 - function split( val ) {
17 - return val.split( /,\s*/ );
18 - }
19 - var input = this.input = $( '#tpt-prioritylangs' )
20 - .autocomplete( {
21 - delay: 0,
22 - minLength: 0,
23 - source: function( request, response ) {
24 - var term = split( request.term ).pop();
25 - var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
26 - response( select.children( "option" ).map(function() {
27 - var text = $( this ).text();
28 - var value = $( this ).val();
29 - var term = split( request.term ).pop();
30 - if ( this.value && ( !request.term || matcher.test(text) ) )
31 - return {
32 - label: text.replace(
33 - new RegExp(
34 - "(?![^&;]+;)(?!<[^<>]*)(" +
35 - $.ui.autocomplete.escapeRegex(term) +
36 - ")(?![^<>]*>)(?![^&;]+;)", "gi"
37 - ), "<strong>$1</strong>" ),
38 - value: value,
39 - option: this
40 - };
41 - }) );
42 - },
43 - select: function( event, ui ) {
44 - ui.item.option.selected = true;
45 - self._trigger( "selected", event, {
46 - item: ui.item.option
47 - });
48 - var terms = split( $(this).val() );
49 - // remove the current input
50 - terms.pop();
51 - // add the selected item
52 - terms.push( ui.item.value );
53 - // add placeholder to get the comma-and-space at the end
54 - terms.push( "" );
55 - $( this ).val( terms.join( ", " ) );
56 - return false;
 14+ _create: function() {
 15+ var self = this,
 16+ select = this.element.hide(),
 17+ selected = select.children( ":selected" );
 18+
 19+ function split( val ) {
 20+ return val.split( /,\s*/ );
5721 }
5822
59 - });
 23+ var input = this.input = $( '#tpt-prioritylangs' )
 24+ .autocomplete( {
 25+ delay: 0,
 26+ minLength: 0,
 27+ source: function( request, response ) {
 28+ var term = split( request.term ).pop();
 29+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
 30+ response( select.children( "option" ).map( function() {
 31+ var text = $( this ).text();
 32+ var value = $( this ).val();
 33+ var term = split( request.term ).pop();
 34+ if ( this.value && ( !request.term || matcher.test(text) ) ) {
 35+ return {
 36+ label: text.replace(
 37+ new RegExp(
 38+ "(?![^&;]+;)(?!<[^<>]*)(" +
 39+ $.ui.autocomplete.escapeRegex( term ) +
 40+ ")(?![^<>]*>)(?![^&;]+;)", "gi"
 41+ ), "<strong>$1</strong>" ),
 42+ value: value,
 43+ option: this
 44+ };
 45+ }
 46+ } ) );
 47+ },
 48+ select: function( event, ui ) {
 49+ ui.item.option.selected = true;
 50+ self._trigger( "selected", event, {
 51+ item: ui.item.option
 52+ });
 53+ var terms = split( $(this).val() );
 54+ // remove the current input
 55+ terms.pop();
 56+ // add the selected item
 57+ terms.push( ui.item.value );
 58+ // add placeholder to get the comma-and-space at the end
 59+ terms.push( "" );
 60+ $( this ).val( terms.join( ", " ) );
 61+ return false;
 62+ }
 63+ } );
6064
61 - input.data( "autocomplete" )._renderItem = function( ul, item ) {
62 - return $( "<li></li>" )
63 - .data( "item.autocomplete", item )
64 - .append( "<a>" + item.label + "</a>" )
65 - .appendTo( ul );
66 - };
 65+ input.data( "autocomplete" )._renderItem = function( ul, item ) {
 66+ return $( "<li>" )
 67+ .data( "item.autocomplete", item )
 68+ .append( "<a>" + item.label + "</a>" )
 69+ .appendTo( ul );
 70+ };
 71+ }, // End of _create
6772
68 - },
 73+ destroy: function() {
 74+ this.input.remove();
 75+ this.element.show();
 76+ $.Widget.prototype.destroy.call( this );
 77+ }
 78+ } );
6979
70 - destroy: function() {
71 - this.input.remove();
72 - this.element.show();
73 - $.Widget.prototype.destroy.call( this );
74 - }
75 - });
76 -
7780 $( "#wpUserLanguage" ).combobox();
7881 } );

Status & tagging log