Skip to content

Commit

Permalink
fixed problem with multiple whiteboards on the same page being unable…
Browse files Browse the repository at this point in the history
… to dave/upload correctly
  • Loading branch information
justinhunt committed Jul 10, 2017
1 parent c4a7be0 commit 8756a4d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 52 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Change List
=========

Version 3.0.48(Build 2017071001)
-fixed error in whiteboads preventing multiple players on same page from saving properly

Version 3.0.47(Build 2017070401)
-fixed error in support info file from a bad SQL statement

Expand Down
2 changes: 1 addition & 1 deletion amd/build/drawingboard_amd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/literallycanvas_amd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/utils_amd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 27 additions & 25 deletions amd/src/drawingboard_amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ define(['jquery','core/log', 'filter_poodll/utils_amd', 'filter_poodll/uploader'
log.debug('Filter PoodLL: drawingboard.js initialising');

return {

whiteboard: null,

instanceprops: [],


// handle drawingboard whiteboard saves for Moodle
loaddrawingboard: function(opts) {
Expand Down Expand Up @@ -46,10 +47,8 @@ define(['jquery','core/log', 'filter_poodll/utils_amd', 'filter_poodll/uploader'
enlargeYourContainer: true,
eraserColor: erasercolor
});
this.whiteboard = db;
opts.db = db;

//init uploader
uploader.init(element, opts);

//restore previous drawing if any
//restore vectordata
Expand All @@ -62,21 +61,25 @@ define(['jquery','core/log', 'filter_poodll/utils_amd', 'filter_poodll/uploader'
}
}

//init uploader
opts.uploader = uploader.clone();
opts.uploader.init(element, opts);

//store opts in instance props, cos this is a singleton
this.instanceprops[opts['recorderid']]=opts;

//register the draw and save events that we need to handle
this.registerEvents();
this.registerEvents(opts['recorderid']);

},

registerEvents: function() {
registerEvents: function(recid) {
//register events. if autosave we need to do more.
var recid = this.config['recorderid'];
var that = this;
var opts = this.config;
if(this.config['autosave']){
var opts = this.instanceprops[recid];
if(opts['autosave']){
//autosave, clear messages and save callbacks on start drawing

this.whiteboard.ev.bind('board:startDrawing', function(){
opts.db.ev.bind('board:startDrawing', function(){
var m = document.getElementById(recid + '_messages');
if(m){
m.innerHTML = 'File has not been saved.';
Expand All @@ -85,28 +88,28 @@ define(['jquery','core/log', 'filter_poodll/utils_amd', 'filter_poodll/uploader'
var th = utils.timeouthandles[recid];
if(th){clearTimeout(th);}
utils.timeouthandles[recid] = setTimeout(
function(){ utils.WhiteboardUploadHandler(recid,that.whiteboard,opts);},
function(){ utils.WhiteboardUploadHandler(recid,opts.db,opts, opts.uploader);},
opts['autosave']);
}
}//end of start drawing function
);

//autosave, clear previous callbacks,set new save callbacks on stop drawing
this.whiteboard.ev.bind('board:stopDrawing', function(){
opts.db.ev.bind('board:stopDrawing', function(){
var m = document.getElementById(recid + '_messages');
if(m){
var th = utils.timeouthandles[recid];
if(th){clearTimeout(th);}
utils.timeouthandles[recid] = setTimeout(
function(){ utils.WhiteboardUploadHandler(recid,that.whiteboard,opts);},
function(){ utils.WhiteboardUploadHandler(recid,opts.db,opts,opts.uploader);},
opts['autosave']);
}
}//end of stop drawing function
);


}else{
this.whiteboard.ev.bind('board:stopDrawing', function(){
opts.db.ev.bind('board:stopDrawing', function(){
var m = document.getElementById(recid + '_messages');
if(m){
m.innerHTML = 'File has not been saved.';
Expand All @@ -116,21 +119,20 @@ define(['jquery','core/log', 'filter_poodll/utils_amd', 'filter_poodll/uploader'
}

//set up the upload/save button
var uploadbuttonstring = '#' + opts['recorderid'] + '_btn_upload_whiteboard';
var uploadbuttonstring = '#' + recid + '_btn_upload_whiteboard';
var uploadbutton = $(uploadbuttonstring);
if(uploadbutton){
if(opts['autosave']){
uploadbutton.click(function(){utils.WhiteboardUploadHandler(recid,that.whiteboard,opts);});
if(opts.autosave){
uploadbutton.click(function(){utils.WhiteboardUploadHandler(recid,opts.db,opts,opts.uploader);});
}else{
var cvs = utils.getCvs(opts['recorderid'],that.whiteboard,opts);
uploadbutton.click(
function(){
utils.pokeVectorData(opts['recorderid'],that.whiteboard,opts);
uploader.uploadFile(cvs.toDataURL(),'image');
},
false);
var cvs = utils.getCvs(recid,opts.db,opts);
utils.pokeVectorData(recid,opts.db,opts);
opts.uploader.uploadFile(cvs.toDataURL(),'image');
});
}
}//end of if upload button
}, //end of reg events
} //end of reg events
}
});
Loading

0 comments on commit 8756a4d

Please sign in to comment.