Skip to content

Commit

Permalink
Merge pull request #19 from amire80/cleanup/2012/11/29
Browse files Browse the repository at this point in the history
Cleanup: Rename "that" to meaningful names
  • Loading branch information
santhoshtr committed Dec 11, 2012
2 parents 095b643 + fa3ca55 commit 3b269dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/jquery.i18n.emitter.js
Expand Up @@ -35,7 +35,7 @@
*/
emit: function ( node, replacements ) {
var ret, subnodes, operation,
that = this;
messageParserEmitter = this;

switch (typeof node) {
case 'string':
Expand All @@ -45,11 +45,11 @@
case 'object':
// node is an array of nodes
subnodes = $.map( node.slice( 1 ), function ( n ) {
return that.emit( n, replacements );
return messageParserEmitter.emit( n, replacements );
} );
operation = node[0].toLowerCase();
if ( typeof that[operation] === 'function' ) {
ret = that[operation]( subnodes, replacements );
if ( typeof messageParserEmitter[operation] === 'function' ) {
ret = messageParserEmitter[operation]( subnodes, replacements );
} else {
throw new Error( 'unknown operation "' + operation + '"' );
}
Expand Down
6 changes: 3 additions & 3 deletions src/jquery.i18n.messages.js
Expand Up @@ -220,14 +220,14 @@
},

jsonMessageLoader: function ( url ) {
var that = this;
var messageStore = this;
return $.ajax( {
url: url,
dataType: "json",
async: false
// that is unfortunate
// This is unfortunate.
} ).fail( function ( jqxhr, settings, exception ) {
that.log( "Error in loading messages from " + url + " Exception: " + exception );
messageStore.log( "Error in loading messages from " + url + " Exception: " + exception );
} );
},

Expand Down
12 changes: 7 additions & 5 deletions src/jquery.i18n.parser.js
Expand Up @@ -131,11 +131,13 @@
var regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ );
var regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ );

// There is a general pattern -- parse a thing, if that worked,
// apply transform, otherwise return null.
// But using this as a combinator seems to cause problems when
// combined with nOrMore().
// May be some scoping issue
// There is a general pattern:
// parse a thing;
// if it worked, apply transform,
// otherwise return null.
// But using this as a combinator seems to cause problems
// when combined with nOrMore().
// May be some scoping issue.
function transform ( p, fn ) {
return function () {
var result = p();
Expand Down

0 comments on commit 3b269dc

Please sign in to comment.