bwdefine("whiteboardcommon",["config","widgetstorage","whiteboard_helper","StudentWorkSubmitter","modernizr","jquery","bw/tr","bw/dialog","bw/sharehandler"],function(e,o,t,a,n,r,i,s,d){"use strict";function c(n,c,u){function h(o){"yes"===e.save_answers&&o.hasOwnProperty("data.whiteboard")&&(console.log("loading data"),l.loadData(o["data.whiteboard"]))}function g(o){var t=[];return t.push({question:e.question||"Whiteboard",answer:f,correctness:-2,score:0,outof:"yes"==e.email_should_have_grading?parseFloat(e.maximum_score)||0:0,config:{Type:"Photo"}}),t}function p(){return l.imgData()}function b(e){console.log("Image uploaded to "+e),f=e}t.addWidthButtons("#width-buttons-container","no"!=c),t.addColorButtons("#colors-container","no"!=n),t.addZoomButtons("#zoom-container","yes"===e.enable_pan),t.addDrawToolButtons("#draw-tools-container","yes"==e.enable_photo,"yes"===e.enable_pan,"no"!=u),t.addClearUndoRedoButtons("#undo-redo-container"),t.addPhotoEditingButtons("#photo-buttons-container");var w=r("#drawingarea").height(),m=r(".photo-placer"),_=Math.round(4*(w-100)/3),y=w-100;m.css("height",y+"px"),m.css("width",_+"px"),m.attr("data-start-height",y),m.attr("data-start-width",_),l=t.createWhiteboard({topselector:"#container",canvasselector:"#drawingarea",createCanvas:!0,width:r("#drawingarea").width,height:w,background_image:e.background,background_resize_policy:e["resize-policy"],image_on_top:"yes"===e.image_on_top,maintoolbar:r("#maintoolbar"),phototoolbar:r("#phototoolbar"),colorsaspopup:n,widthaspopup:c,toolsaspopup:c,enablephoto:"yes"==e.enable_photo,allow_pan:"yes"===e.enable_pan,allow_zoom:"yes"===e.enable_pan}),o.init({type:"Whiteboard",group:""==e.book_title?"_no_name_":e.book_title,name:e.pagename,id:e.uuid2,updateCallback:h,singleKey:!1}),r("#clearbutton").click(function(){l.clear()}),"None"!=e.provide_calculator&&""!=e.provide_calculator&&r("#calcbutton").show();var f="";return d({config:e,submitName:e.pagename,getAnswers:g,assetFetcherCB:p,assetUploadCompleteCB:b,submitSuccessMessage:i("Your drawing was sent successfully!"),submitFailedTitle:i("Drawing not accepted."),submitFailedMessage:i("Unable to send drawing. Make sure you're connected to the internet."),sendDialogMessage:i("Complete the form and click send to submit your drawing to your teacher."),shareDialogMessage:i("Complete the form and click send to email your drawing.")},a,s),l.onChange(function(){"yes"===e.save_answers&&o.write({"data.whiteboard":l.saveData()})}),l.resize=function(){var e=r("#drawingarea"),o=e.find("canvas")[0];o.width=e.width(),o.height=e.height(),this.redrawOnResize()},l.resize(),l}r(function(){if("right-to-left"==e.direction){var o=document.documentElement;o.style.direction="rtl"}});var l,u={whiteboardCommonInit:c};return u});