Skip to content

Commit

Permalink
Fix frond-end edit on-off button
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Jul 27, 2015
1 parent ffa921c commit 86592ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 deletions source/plg_system_t3/base-bs3/js/frontend-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$(document).ready(function(){

//frontend edit radio on/off - auto convert on-off radio if applicable
$('fieldset.radio').filter(function(){
var $onoff = $('fieldset.radio').filter(function(){

return $(this).find('input').length == 2 && $(this).find('input').filter(function(){
return $.inArray(this.value + '', ['0', '1']) !== -1;
Expand All @@ -25,8 +25,11 @@
}).addClass('t3onoff').removeClass('btn-group');

//add class on/off
$('fieldset.t3onoff').find('label').addClass(function(){
return $(this).hasClass('off') || $(this).prev('input').val() == '0' ? 'off' : 'on'
$onoff.find('label').addClass(function(){
var $this = $(this), $input = $this.prev('input'),
cls = $this.hasClass('off') || $input.val() == '0' ? 'off' : 'on';
cls += $input.prop('checked') ? ' active' : '';
return cls;
});

//listen to all
Expand All @@ -41,11 +44,6 @@
}
});

//initial state
$('.radio input[checked=checked]').each(function(){
$('label[for=' + $(this).attr('id') + ']').addClass('active');
});

});

}(jQuery);
14 changes: 6 additions & 8 deletions source/plg_system_t3/base/js/frontend-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$(document).ready(function(){

//frontend edit radio on/off - auto convert on-off radio if applicable
$('fieldset.radio').filter(function(){
var $onoff = $('fieldset.radio').filter(function(){

return $(this).find('input').length == 2 && $(this).find('input').filter(function(){
return $.inArray(this.value + '', ['0', '1']) !== -1;
Expand All @@ -25,8 +25,11 @@
}).addClass('t3onoff').removeClass('btn-group');

//add class on/off
$('fieldset.t3onoff').find('label').addClass(function(){
return $(this).hasClass('off') || $(this).prev('input').val() == '0' ? 'off' : 'on'
$onoff.find('label').addClass(function(){
var $this = $(this), $input = $this.prev('input'),
cls = $this.hasClass('off') || $input.val() == '0' ? 'off' : 'on';
cls += $input.prop('checked') ? ' active' : '';
return cls;
});

//listen to all
Expand All @@ -41,11 +44,6 @@
}
});

//initial state
$('.radio input[checked=checked]').each(function(){
$('label[for=' + $(this).attr('id') + ']').addClass('active');
});

});

}(jQuery);

0 comments on commit 86592ce

Please sign in to comment.