Skip to content

Commit

Permalink
fix: rewriting with es6 and lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill-Hatalski committed Sep 4, 2023
1 parent f4d6fac commit 147988b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
24 changes: 9 additions & 15 deletions views/js/qtiCreator/widgets/helpers/responsiveMetaChange.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,19 @@
*
*/

define([], function () {
'use strict';

return function responsiveMetaChange(data, widget) {
var interaction = widget.element;
var $container = widget.$container;
if(data.key === 'responsive'){
if(data.value === true){
interaction.addClass('responsive');
define([], () => (
function responsiveMetaChange({ key, value }, widget) {
const { element, $container } = widget;
if(key === 'responsive'){
if(value === true){
element.addClass('responsive');
} else {
interaction.removeClass('responsive');
element.removeClass('responsive');
}
if($container.find('.qti-prompt [data-qti-class="figure"]').length) {
$container.on('graphicInteraction.ready', function (){
widget.rebuild();
});
return;
return $container.on('graphicInteraction.ready', () => widget.rebuild());
}
widget.rebuild();
}
}
});
));
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ define([
'use strict';

var initSleepState = function initSleepState(){
var widget = this.widget;
widget.on('metaChange', function(data){
const widget = this.widget;
widget.on('metaChange', data => {
responsiveMetaChange(data, widget);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ define([
'use strict';

var initSleepState = function initSleepState(){
var widget = this.widget;
widget.on('metaChange', function(data){
const widget = this.widget;
widget.on('metaChange', data => {
responsiveMetaChange(data, widget);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ define([
'use strict';

var initSleepState = function initSleepState(){
var widget = this.widget;
widget.on('metaChange', function(data){
const widget = this.widget;
widget.on('metaChange', data => {
responsiveMetaChange(data, widget);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
define([
'jquery',
'taoQtiItem/qtiCreator/widgets/states/factory',
'taoQtiItem/qtiCreator/widgets/interactions/states/Sleep',
'taoQtiItem/qtiCreator/widgets/helpers/responsiveMetaChange'
], function($, stateFactory, SleepState, responsiveMetaChange){
'taoQtiItem/qtiCreator/widgets/helpers/responsiveMetaChange',
'taoQtiItem/qtiCreator/widgets/interactions/states/Sleep'
], function($, stateFactory, responsiveMetaChange, SleepState){

'use strict';

var initSleepState = function initSleepState(){
var widget = this.widget;
widget.on('metaChange', function(data){
const widget = this.widget;
widget.on('metaChange', data => {
responsiveMetaChange(data, widget);
});
};
Expand Down

0 comments on commit 147988b

Please sign in to comment.