Skip to content

Commit 572491f

Browse files
committed
fix global object and clean - fix destroy after use
1 parent 61bd3ff commit 572491f

File tree

5 files changed

+39
-30
lines changed

5 files changed

+39
-30
lines changed

views/js/pciCreator/ims/geogebrapci/interaction/creator/widget/states/Question.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,34 @@ define([
2121
var GGBPCIStateQuestion = stateFactory.extend(Question, function () {
2222

2323

24-
24+
console.log("STATEFACTORY 2 : First code to be read")
2525

2626

2727
}, function () {
2828

29-
29+
console.log("STATEFACTORY 1 : it is coming at the end of the loading")
30+
3031

3132
});
3233

3334
GGBPCIStateQuestion.prototype.initForm = function() {
3435

3536
//Rappel : interaction.prop() is a setter for config in renderer
3637
// interaction.properties = config in render
37-
38-
3938

4039
var _widget = this.widget,
4140
Sform = _widget.$form,
4241
interaction = _widget.element,
43-
response = interaction.getResponseDeclaration(),
42+
response = interaction.getResponseDeclaration(),
43+
//GGB - APP Parameters get from pciCreator
4444
param_appName = interaction.prop('param').appName,
4545
param_width = interaction.prop('param').width,
4646
param_height = interaction.prop('param').height,
4747
param_enableShiftDragZoom = interaction.prop('param').enableShiftDragZoom,
4848
param_showZoomButtons = interaction.prop('param').showZoomButtons,
4949
param_showFullscreenButton = interaction.prop('param').showFullscreenButton,
5050
param_language = interaction.prop('param').language,
51+
// param_country = interaction.prop('param').country,
5152
param_showMenuBar = interaction.prop('param').showMenuBar,
5253
param_showToolBar = interaction.prop('param').showToolBar,
5354
param_allowStyleBar = interaction.prop('param').allowStyleBar,
@@ -56,7 +57,11 @@ define([
5657
param_saveB64 = interaction.prop('resp').data,
5758
param_AnswerSet = interaction.prop('resp').answerSet;
5859

60+
61+
5962

63+
//response.correctResponse = 1
64+
6065
var correct = _.values(interaction.getResponseDeclaration().getCorrect());
6166

6267
//This is the responseDeclaration in XML
@@ -79,10 +84,13 @@ define([
7984
//init form javascript
8085
formElement.initWidget(Sform);
8186

87+
88+
8289
$(".saveAppData").on("click", function() {
8390

8491
interaction.properties.state = "modified";
85-
interaction.properties.param.filename="saved";
92+
interaction.properties.param.filename="saved";
93+
8694
interaction.triggerPci('dataChange', [interaction.properties]); // Send it to AMD for action
8795

8896
})
@@ -134,7 +142,6 @@ define([
134142

135143
Sform.find("#RightClick").on("click", function() {
136144
let toggle = $(this).prop("checked");
137-
console.log(toggle);
138145
interaction.triggerPci('RightClickChange', [toggle]); // Send it to AMD for action
139146
interaction.properties.param.enableRightClick = toggle;
140147

@@ -168,23 +175,13 @@ define([
168175
interaction.properties.param.showZoomButtons = GGBConfig.appShowZoomBT;
169176
interaction.properties.param.showFullscreenButton = GGBConfig.appShowFScreenBT;
170177
interaction.properties.param.language = GGBConfig.language;
171-
//interaction.properties.param.country = GGBConfig.country;
172178
interaction.properties.param.showMenuBar = GGBConfig.MenuBar;
173179
interaction.properties.param.showToolBar = GGBConfig.ToolBar;
174180
interaction.properties.param.algebraInputPosition = true;
175181
interaction.properties.param.allowStyleBar = GGBConfig.StyleBar;
176182
interaction.properties.param.enableRightClick = GGBConfig.RightClick;
177183
interaction.properties.param.enableUndoRedo = GGBConfig.UndoRedo;
178184

179-
/* try {
180-
console.log("NO DATA");
181-
//ggbApplet.getBase64(function(b) { GGBConfig.file = b });
182-
} catch (error) {
183-
//console.error(error);
184-
GGBConfig.file = "";
185-
console.log(error);
186-
} */
187-
188185
interaction.triggerPci('appChange', [GGBConfig]); // Send it to AMD for action
189186

190187
});

views/js/pciCreator/ims/geogebrapci/interaction/runtime/js/GGBInteraction.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ define(['qtiCustomInteractionContext',
4040
* @param {Object} [state] - the json serialized state object, returned by previous call to getStatus(), use to initialize an
4141
*/
4242
getInstance: function getInstance(dom, config, state) {
43-
4443
var response = config.boundTo;
44+
4545
config.properties.param = JSON.parse(config.properties.param)
4646
config.properties.resp = JSON.parse(config.properties.resp)
4747

@@ -159,9 +159,11 @@ define(['qtiCustomInteractionContext',
159159
* @param {Object} interaction
160160
*/
161161
destroy: function () {
162-
if (typeof this.api !== "undefined") {
163-
this.api.remove();
162+
if (typeof this.previewApplet !== "undefined") {
163+
this.previewApplet.remove();
164164
}
165+
166+
//window.ggbApplet.remove()
165167

166168
var $container = $(this.dom);
167169
$container.off().empty();
@@ -202,6 +204,7 @@ define(['qtiCustomInteractionContext',
202204
//renderer.render(_this, _this.dom, _this.config, assetManager);
203205
renderer.render(_this, _this.dom, config, assetManager);
204206

207+
205208
//Listening to Change Data called from Question after changing values for config
206209
this.on('dataChange', function (conf) {
207210

@@ -265,7 +268,8 @@ define(['qtiCustomInteractionContext',
265268

266269
} else {
267270
// Fail code
268-
271+
console.log(data.thumbUrl);
272+
console.log('No valid Thumbnail found ! Sorry')
269273
$('#miniat').html("");
270274
}
271275
});
@@ -326,9 +330,13 @@ define(['qtiCustomInteractionContext',
326330

327331
setTimeout(() => {
328332
$(_this.dom).find(".groupPanel").removeAttr("style");
333+
334+
// $(_this.dom).find(".groupPanel").css("backgroundColor", "red");
329335
$(_this.dom).find(".groupPanel").css("width", "");
336+
330337
$(_this.dom).find(".mowColorPlusButton").css("width", "");
331338
$(_this.dom).find(".mowColorPlusButton").css("top", "");
339+
//$(_this.dom).find(".groupPanel").css("width", "360px!important");
332340
}, 500);
333341
});
334342

views/js/pciCreator/ims/geogebrapci/interaction/runtime/js/instancer.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ define(['GGBPCI/interaction/runtime/js/lib/deployggb'], function(GGBApplet) {
1313
'use strict';
1414

1515
function instancer(pciObj, $container, config) {
16+
1617
var ggbdom = "ggb_" + Date.now();
1718
$container.find(".GGBPCI").append('<div class=' + ggbdom + '></div>');
1819

1920
if ($container.parent().hasClass('widget-box')) {
20-
21+
2122
initGGB(config);
2223
} else {
24+
2325
previeGGBPCI(config)
2426
}
2527

@@ -51,6 +53,7 @@ define(['GGBPCI/interaction/runtime/js/lib/deployggb'], function(GGBApplet) {
5153
function initGGB(config) {
5254
if (config.param.filename.length > 0) {
5355
var ggbApp = new GGBApplet({
56+
id: "ggbAssess",
5457
filename: config.param.filename,
5558
detachKeyboard: false,
5659
appName: config.param.appName,
@@ -87,10 +90,9 @@ define(['GGBPCI/interaction/runtime/js/lib/deployggb'], function(GGBApplet) {
8790
ggbApp.inject(ggbdom);
8891
cssCorrecter();
8992

90-
91-
9293
} else {
9394
var ggbApp = new GGBApplet({
95+
id: "ggbAssess",
9496
detachKeyboard : false,
9597
appName : config.param.appName,
9698
showToolBar : config.param.showToolBar,
@@ -129,8 +131,9 @@ define(['GGBPCI/interaction/runtime/js/lib/deployggb'], function(GGBApplet) {
129131
}
130132

131133
function previeGGBPCI(config) {
132-
134+
133135
var ggbApp = new GGBApplet({
136+
id: "ggbAssess",
134137
detachKeyboard: false,
135138
appName: config.param.appName,
136139
showToolBar: config.param.showToolBar,
@@ -161,12 +164,11 @@ define(['GGBPCI/interaction/runtime/js/lib/deployggb'], function(GGBApplet) {
161164
pciObj.previewApplet = api;
162165
} else {
163166
pciObj.previewApplet = api;
164-
}
167+
}
165168
}
166169
}, true);
167170

168171
ggbApp.inject(ggbdom);
169-
170172
cssCorrecter()
171173

172174
}

views/js/pciCreator/ims/geogebrapci/interaction/runtime/js/lib/deployggb.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,11 @@
383383
web3d.succeeded = web3d.succeeded || web3d() //JANFIX : Here is the launcher
384384
}
385385
scriptLoaded()
386-
console.log("JPTRACKER1")
386+
console.log("JPTRACKER100")
387387

388-
} else if (html5Codebase.requirejs) { require(["geogebra/runtime/js/web3d/web3d.nocache"], scriptLoaded); } else { // original
388+
} else if (html5Codebase.requirejs) {
389+
//require(["geogebra/runtime/js/web3d/web3d.nocache"], scriptLoaded);
390+
} else { // original
389391
script.onload = scriptLoaded;
390392
appletElem.appendChild(script)
391393
console.log("JPTRACKER2")

views/js/pciCreator/ims/geogebrapci/interaction/runtime/js/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define(['taoQtiItem/portableLib/jquery_2_1_1',
1515
'use strict';
1616

1717
function renderChoices(pciObj, $container, config) {
18-
18+
1919
instancer.ggb(pciObj, $container, config);
2020

2121
}

0 commit comments

Comments
 (0)