Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
Reactivate master language if error
Browse files Browse the repository at this point in the history
  • Loading branch information
tonipinel committed May 26, 2015
1 parent d0f56db commit 4bdfe78
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FrontendCore.define('on-off-table', ['devicePackage' ], function () {
return {
oMasterLanguage : '',
setMasterLanguage: function() {
this.oMasterLanguage = $('[name=language-master]:checked')[0];
},
onStart: function () {

FrontendCore.requireAndStart('notification');

var self = this;

self.setMasterLanguage();

$('.switch input').each( function(){

var oTarget = this;
Expand All @@ -15,8 +23,10 @@ FrontendCore.define('on-off-table', ['devicePackage' ], function () {
sUrl = this.checked === true ? document.getElementById('enable-' + this.id).value : document.getElementById('disable-' + this.id).value;

$.ajax({
url: sUrl,
type: 'post'
url: sUrl,
type: 'post'
}).done( function() {
self.setMasterLanguage();
}).fail( function( response ) {

if ( sValue === true ) {
Expand All @@ -25,6 +35,10 @@ FrontendCore.define('on-off-table', ['devicePackage' ], function () {
oInput.checked = true;
}

if ( oInput.name === 'language-master' ) {
self.oMasterLanguage.checked = true;
}

var sMessage = response.responseJSON.message !== undefined ? response.responseJSON.message : 'Sorry, something was wrong.';
FrontendMediator.publish( 'notification', { type : 'ko', message: sMessage } );

Expand Down

0 comments on commit 4bdfe78

Please sign in to comment.