diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ajax.js | 2 | ||||
-rw-r--r-- | misc/authorize.js | 1 | ||||
-rw-r--r-- | misc/autocomplete.js | 2 | ||||
-rw-r--r-- | misc/drupal.js | 26 |
4 files changed, 20 insertions, 11 deletions
diff --git a/misc/ajax.js b/misc/ajax.js index 830c8aa1c..900ca1d22 100644 --- a/misc/ajax.js +++ b/misc/ajax.js @@ -318,7 +318,7 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) { Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { // This function is left empty to make it simple to override for modules // that wish to add functionality here. -} +}; /** * Prepare the Ajax request before it is sent. diff --git a/misc/authorize.js b/misc/authorize.js index 66b789791..d522a5ba9 100644 --- a/misc/authorize.js +++ b/misc/authorize.js @@ -16,7 +16,6 @@ Drupal.behaviors.authorizeFileTransferForm = { // Removes the float on the select box (used for non-JS interface). if ($('.connection-settings-update-filetransfer-default-wrapper').length > 0) { - console.log($('.connection-settings-update-filetransfer-default-wrapper')); $('.connection-settings-update-filetransfer-default-wrapper').css('float', 'none'); } // Hides the submit button for non-js users. diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 5e85be44f..02a886c21 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -41,7 +41,7 @@ Drupal.autocompleteSubmit = function () { Drupal.jsAC = function ($input, db) { var ac = this; this.input = $input[0]; - this.ariaLive = $('#' + $input.attr('id') + '-autocomplete-aria-live'); + this.ariaLive = $('#' + this.input.id + '-autocomplete-aria-live'); this.db = db; $input diff --git a/misc/drupal.js b/misc/drupal.js index 7e2cc4d7b..83b088428 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -164,7 +164,7 @@ Drupal.formatString = function(str, args) { str = str.replace(key, args[key]); } return str; -} +}; /** * Translate strings to the page language or a given language. @@ -177,13 +177,21 @@ Drupal.formatString = function(str, args) { * An object of replacements pairs to make after translation. Incidences * of any key in this array are replaced with the corresponding value. * See Drupal.formatString(). + * + * @param options + * - 'context' (defaults to the empty context): The context the source string + * belongs to. + * * @return * The translated string. */ -Drupal.t = function (str, args) { +Drupal.t = function (str, args, options) { + options = options || {}; + options.context = options.context || ''; + // Fetch the localized version of the string. - if (Drupal.locale.strings && Drupal.locale.strings[str]) { - str = Drupal.locale.strings[str]; + if (Drupal.locale.strings && Drupal.locale.strings[options.context] && Drupal.locale.strings[options.context][str]) { + str = Drupal.locale.strings[options.context][str]; } if (args) { @@ -216,25 +224,27 @@ Drupal.t = function (str, args) { * See Drupal.formatString(). * Note that you do not need to include @count in this array. * This replacement is done automatically for the plural case. + * @param options + * The options to pass to the Drupal.t() function. * @return * A translated string. */ -Drupal.formatPlural = function (count, singular, plural, args) { +Drupal.formatPlural = function (count, singular, plural, args, options) { var args = args || {}; args['@count'] = count; // Determine the index of the plural form. var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] == 1) ? 0 : 1); if (index == 0) { - return Drupal.t(singular, args); + return Drupal.t(singular, args, options); } else if (index == 1) { - return Drupal.t(plural, args); + return Drupal.t(plural, args, options); } else { args['@count[' + index + ']'] = args['@count']; delete args['@count']; - return Drupal.t(plural.replace('@count', '@count[' + index + ']'), args); + return Drupal.t(plural.replace('@count', '@count[' + index + ']'), args, options); } }; |