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:
Santhosh Thottingal
2012-10-31 12:57:14 +05:30
parent b24d629780
commit fc29a7e587
9 changed files with 200 additions and 12 deletions

View File

@@ -114,4 +114,71 @@ button.button.blue.disabled:hover {
color: white;
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 );
}

View File

@@ -111,7 +111,7 @@
this.prepareUIFonts();
this.prepareContentFonts();
this.prepareWebfontsCheckbox();
this.$template.i18n();
this.listen();
},

View File

@@ -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();
}
} );

View File

@@ -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();
} );
},
/**