Option for disabling the IME system
* It can be a user preference using the ULS Input method settings * It can be a mediaWiki configuration $wgULSIMEEnabled Change-Id: Ic5fb4932d62ab18db5d3b10ca81c0f6bfe9fd29e
This commit is contained in:
@@ -165,6 +165,8 @@ class UniversalLanguageSelectorHooks {
|
||||
global $wgULSGeoService;
|
||||
$vars['wgULSGeoService'] = $wgULSGeoService;
|
||||
|
||||
$vars['wgULSIMEEnabled']= wgULSIMEEnabled;
|
||||
|
||||
// ULS is localized using jquery.i18n library. Unless it knows
|
||||
// the localized locales, it can create 404 response. To avoid that,
|
||||
// send the locales available at server. Also avoid directory scanning
|
||||
|
||||
@@ -56,6 +56,11 @@ $wgExtensionCredits['other'][] = array(
|
||||
*/
|
||||
$wgULSGeoService = 'http://freegeoip.net/json/';
|
||||
|
||||
/**
|
||||
* IME system of ULS can be disabled by setting this value false;
|
||||
*/
|
||||
$wgULSIMEEnabled = true;
|
||||
|
||||
/**
|
||||
* Try to use preferred interface language for anonymous users.
|
||||
* Do not use if you are caching anonymous page views without
|
||||
|
||||
@@ -33,5 +33,10 @@
|
||||
"ext-uls-input-more-settings" : "More settings",
|
||||
"jquery-ime-other-languages": "Other languages",
|
||||
"jquery-ime-disable-text": "Disable input method",
|
||||
"jquery-ime-help": "Help"
|
||||
"jquery-ime-help": "Help",
|
||||
"ext-uls-input-disable": "Disable input method tools",
|
||||
"ext-uls-input-enable": "Enable input method tools",
|
||||
"ext-uls-input-disable-info": "Input method tools are disabled.",
|
||||
"ext-uls-input-enable-info": "Input method tools are enabled."
|
||||
}
|
||||
|
||||
|
||||
@@ -31,5 +31,6 @@
|
||||
"ext-uls-input-settings-more-languages-tooltip": "\u0d15\u0d42\u0d1f\u0d41\u0d24\u0d7d \u0d2d\u0d3e\u0d37\u0d15\u0d7e",
|
||||
"ext-uls-input-more-settings": "\u0d15\u0d42\u0d1f\u0d41\u0d24\u0d7d \u0d15\u0d4d\u0d30\u0d2e\u0d40\u0d15\u0d30\u0d23\u0d19\u0d4d\u0d19\u0d7e",
|
||||
"jquery-ime-other-languages": "\u0d2e\u0d31\u0d4d\u0d31\u0d41 \u0d2d\u0d3e\u0d37\u0d15\u0d7e",
|
||||
"jquery-ime-disable-text": "\u0d0e\u0d34\u0d41\u0d24\u0d4d\u0d24\u0d41\u0d2a\u0d15\u0d30\u0d23\u0d02 \u0d35\u0d47\u0d23\u0d4d\u0d1f\u0d46\u0d28\u0d4d\u0d28\u0d41\u0d35\u0d46\u0d2f\u0d4d\u0d15\u0d4d\u0d15\u0d41\u0d15"
|
||||
"jquery-ime-disable-text": "\u0d0e\u0d34\u0d41\u0d24\u0d4d\u0d24\u0d41\u0d2a\u0d15\u0d30\u0d23\u0d02 \u0d35\u0d47\u0d23\u0d4d\u0d1f\u0d46\u0d28\u0d4d\u0d28\u0d41\u0d35\u0d46\u0d2f\u0d4d\u0d15\u0d4d\u0d15\u0d41\u0d15",
|
||||
"ext-uls-input-disable": "എഴുത്തുപകരണം വേണ്ട"
|
||||
}
|
||||
@@ -34,5 +34,9 @@
|
||||
"ext-uls-input-more-settings": "Menu item lable displayed in the input method selector menu",
|
||||
"jquery-ime-other-languages": "Title text used for language list in the input method selector menu",
|
||||
"jquery-ime-disable-text": "Label used for disabling input method from input method selector menu",
|
||||
"jquery-ime-help": "Text for help link"
|
||||
"jquery-ime-help": "Text for help link",
|
||||
"ext-uls-input-disable": "Label for disable input tools button",
|
||||
"ext-uls-input-enable": "Label for enable input tools button",
|
||||
"ext-uls-input-disable-info": "Info text for disable input tools button",
|
||||
"ext-uls-input-enable-info": "Info text for disable input tools button"
|
||||
}
|
||||
@@ -115,3 +115,70 @@ button.button.blue.disabled:hover {
|
||||
cursor: default;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
button.button.green {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #008740;
|
||||
background-image: -ms-linear-gradient(top, #00974b, #008740);
|
||||
background-image: -moz-linear-gradient(top, #00974b, #008740);
|
||||
background-image: linear-gradient(#00974b, #008740);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #00974b),
|
||||
color-stop(100%, #008740) );
|
||||
background-image: -webkit-linear-gradient(top, #00974b, #008740);
|
||||
border: 1px #0f9b3b solid;
|
||||
-ms-filter:
|
||||
"progid:DXImageTransform.Microsoft.gradient(startColorstr='#00974b', endColorstr='#008740', GradientType=0)";
|
||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#00974b',
|
||||
endColorstr='#008740', GradientType=0 );
|
||||
}
|
||||
|
||||
button.button.green:hover {
|
||||
background-color: #119750;
|
||||
background-image: -moz-linear-gradient(top, #10a65b, #119750);
|
||||
background-image: -ms-linear-gradient(top, #10a65b, #119750);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #10a65b),
|
||||
color-stop(100%, #119750) );
|
||||
background-image: -webkit-linear-gradient(top, #10a65b, #119750);
|
||||
background-image: linear-gradient(#10a65b, #119750);
|
||||
-ms-filter:
|
||||
"progid:DXImageTransform.Microsoft.gradient(startColorstr='#10a65b', endColorstr='#119750', GradientType=0)";
|
||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#10a65b',
|
||||
endColorstr='#119750', GradientType=0 );
|
||||
}
|
||||
|
||||
button.button.green:active {
|
||||
background-color: #007236;
|
||||
background-image: -moz-linear-gradient(top, #007236, #007236);
|
||||
background-image: -ms-linear-gradient(top, #007236, #007236);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #007236),
|
||||
color-stop(100%, #007236) );
|
||||
background-image: -webkit-linear-gradient(top, #007236, #007236);
|
||||
background-image: linear-gradient(#007236, #007236);
|
||||
-ms-filter:
|
||||
"progid:DXImageTransform.Microsoft.gradient(startColorstr='#007236', endColorstr='#007236', GradientType=0)";
|
||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#007236',
|
||||
endColorstr='#007236', GradientType=0 );
|
||||
}
|
||||
|
||||
button.button.green:disabled,
|
||||
button.button.green:disabled.hover,
|
||||
button.button.green.disabled,
|
||||
button.button.green.disabled:hover
|
||||
{
|
||||
color: white;
|
||||
text-shadow: none;
|
||||
cursor: default;
|
||||
background-color: #2ca368;
|
||||
background-image: -moz-linear-gradient(top, #2ca368, #2ca368);
|
||||
background-image: -ms-linear-gradient(top, #2ca368, #2ca368);
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #2ca368),
|
||||
color-stop(100%, #2ca368) );
|
||||
background-image: -webkit-linear-gradient(top, #2ca368, #2ca368);
|
||||
background-image: linear-gradient(#2ca368, #2ca368);
|
||||
border-color: #278f5b;
|
||||
-ms-filter:
|
||||
"progid:DXImageTransform.Microsoft.gradient(startColorstr='#2ca368', endColorstr='#2ca368', GradientType=0)";
|
||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#2ca368',
|
||||
endColorstr='#2ca368', GradientType=0 );
|
||||
}
|
||||
@@ -111,7 +111,7 @@
|
||||
this.prepareUIFonts();
|
||||
this.prepareContentFonts();
|
||||
this.prepareWebfontsCheckbox();
|
||||
|
||||
this.$template.i18n();
|
||||
this.listen();
|
||||
},
|
||||
|
||||
|
||||
@@ -67,7 +67,29 @@
|
||||
|
||||
load: function () {
|
||||
this.registry = inputPreferences.get( 'ime' ) || this.registry;
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
this.registry['enable'] = false;
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
this.registry['enable'] = true;
|
||||
},
|
||||
|
||||
isEnabled: function () {
|
||||
|
||||
if ( this.registry['enable'] === false ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( mw.config.get( 'wgULSIMEEnabled' ) === false ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// MediaWiki specific overrides for jquery.ime
|
||||
@@ -105,9 +127,13 @@
|
||||
return $moreSettingsLink;
|
||||
};
|
||||
|
||||
$( document ).ready( function () {
|
||||
mw.ime.disable = function () {
|
||||
$( inputSelector ).unbind( '.ime' );
|
||||
};
|
||||
|
||||
$( 'body' ).on( 'focus', inputSelector, function () {
|
||||
mw.ime.setup = function () {
|
||||
|
||||
$( 'body' ).on( 'focus.ime', inputSelector, function () {
|
||||
var $input = $( this );
|
||||
|
||||
$input.ime( {
|
||||
@@ -135,8 +161,17 @@
|
||||
} );
|
||||
} );
|
||||
|
||||
};
|
||||
|
||||
$( document ).ready( function () {
|
||||
|
||||
// Load the ime preferences
|
||||
$.ime.preferences.load();
|
||||
|
||||
if ( $.ime.preferences.isEnabled() ) {
|
||||
mw.ime.setup();
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,14 @@
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
|
||||
// Disable IME system button
|
||||
+ '<div class="row">'
|
||||
+ '<div class="eleven columns button uls-input-settings-disable-info"></div>'
|
||||
+ '<div class="six columns button uls-input-settings-toggle">'
|
||||
+ '<button class="active green button uls-input-toggle-button"></button>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
|
||||
// Separator
|
||||
+ '<div class="row"></div>'
|
||||
|
||||
@@ -82,6 +90,7 @@
|
||||
this.$parent.$settingsPanel.append( this.$template );
|
||||
this.prepareLanguages();
|
||||
this.prepareInputmethods( this.imeLanguage );
|
||||
this.prepareToggleButton();
|
||||
this.$template.i18n();
|
||||
this.listen();
|
||||
},
|
||||
@@ -278,6 +287,29 @@
|
||||
} );
|
||||
},
|
||||
|
||||
prepareToggleButton: function () {
|
||||
var inputsettings, $toggleButton, $toggleButtonDesc ;
|
||||
|
||||
inputsettings = this;
|
||||
|
||||
$toggleButton = inputsettings.$template
|
||||
.find( 'button.uls-input-toggle-button' );
|
||||
|
||||
$toggleButtonDesc = inputsettings.$template
|
||||
.find( 'div.uls-input-settings-disable-info' );
|
||||
|
||||
if ( $.ime.preferences.isEnabled() ) {
|
||||
$toggleButton.data( 'i18n', 'ext-uls-input-disable' );
|
||||
$toggleButtonDesc.data( 'i18n', 'ext-uls-input-enable-info' );
|
||||
} else {
|
||||
$toggleButton.data( 'i18n', 'ext-uls-input-enable' );
|
||||
$toggleButtonDesc.data( 'i18n', 'ext-uls-input-disable-info' );
|
||||
}
|
||||
|
||||
$toggleButton.i18n();
|
||||
$toggleButtonDesc.i18n();
|
||||
},
|
||||
|
||||
/**
|
||||
* Get previous languages
|
||||
* @returns {Array}
|
||||
@@ -307,26 +339,63 @@
|
||||
* Register general event listeners
|
||||
*/
|
||||
listen: function () {
|
||||
var that = this, $imeListContainer;
|
||||
var inputSettings = this, $imeListContainer;
|
||||
|
||||
$imeListContainer = this.$template.find( '.uls-input-settings-inputmethods-list' );
|
||||
|
||||
// Apply and close buttons
|
||||
this.$template.find( 'button.uls-input-settings-apply' ).on( 'click', function () {
|
||||
that.apply();
|
||||
inputSettings.$template.find( 'button.uls-input-settings-apply' ).on( 'click', function () {
|
||||
inputSettings.apply();
|
||||
} );
|
||||
|
||||
this.$template.find( 'button.uls-input-settings-close' ).on( 'click', function () {
|
||||
that.close();
|
||||
inputSettings.$template.find( 'button.uls-input-settings-close' ).on( 'click', function () {
|
||||
inputSettings.close();
|
||||
} );
|
||||
|
||||
$imeListContainer.on( 'change', 'input:radio[name=ime]:checked', function () {
|
||||
var ime = $( this ).val();
|
||||
|
||||
$.ime.preferences.setLanguage( that.imeLanguage );
|
||||
$.ime.preferences.setLanguage( inputSettings.imeLanguage );
|
||||
$.ime.preferences.setIM( ime );
|
||||
} );
|
||||
|
||||
inputSettings.$template.find( 'button.uls-input-toggle-button' )
|
||||
.on( 'click', function () {
|
||||
if ( $.ime.preferences.isEnabled() ) {
|
||||
inputSettings.disableInputTools();
|
||||
} else {
|
||||
inputSettings.enableInputTools();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Disable input tools
|
||||
*/
|
||||
disableInputTools: function () {
|
||||
var inputSettings = this;
|
||||
|
||||
$.ime.preferences.disable();
|
||||
$.ime.preferences.save( function() {
|
||||
// Update the toggle button
|
||||
inputSettings.prepareToggleButton();
|
||||
mw.ime.disable();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable input tools
|
||||
*/
|
||||
enableInputTools: function () {
|
||||
var inputSettings = this;
|
||||
|
||||
$.ime.preferences.enable();
|
||||
$.ime.preferences.save( function() {
|
||||
// Update the toggle button
|
||||
inputSettings.prepareToggleButton();
|
||||
mw.ime.setup();
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user