@@ -188,7 +188,7 @@ Blockly.Backpack.backPackId = false;
188188 * @return {!Element } The backpack's SVG group.
189189 */
190190Blockly . Backpack . prototype . createDom = function ( opt_workspace ) {
191- var workspace = opt_workspace || Blockly . getMainWorkspace ( ) ;
191+ var workspace = opt_workspace || Blockly . common . getMainWorkspace ( ) ;
192192 // insert the flyout after the main workspace (except, there's no
193193 // svg.insertAfter method, so we need to insert before the thing following
194194 // the main workspace. Neil Fraser says: this is "less hacky than it looks".
@@ -200,8 +200,8 @@ Blockly.Backpack.prototype.createDom = function(opt_workspace) {
200200 workspace . getParentSvg ( ) . appendChild ( flyoutGroup ) ;
201201 }
202202
203- this . svgGroup_ = Blockly . utils . createSvgElement ( 'g' , { } , null ) ;
204- this . svgBody_ = Blockly . utils . createSvgElement ( 'image' ,
203+ this . svgGroup_ = Blockly . utils . dom . createSvgElement ( 'g' , { } , null ) ;
204+ this . svgBody_ = Blockly . utils . dom . createSvgElement ( 'image' ,
205205 { 'width' : this . WIDTH_ , 'height' : this . BODY_HEIGHT_ } ,
206206 this . svgGroup_ ) ;
207207 this . svgBody_ . setAttributeNS ( 'http://www.w3.org/1999/xlink' , 'xlink:href' ,
@@ -218,16 +218,16 @@ Blockly.Backpack.prototype.createDom = function(opt_workspace) {
218218Blockly . Backpack . prototype . init = function ( ) {
219219 this . position_ ( ) ;
220220 // If the document resizes, reposition the backpack.
221- Blockly . bindEvent_ ( window , 'resize' , this , this . position_ ) ;
221+ Blockly . browserEvents . bind ( window , 'resize' , this , this . position_ ) ;
222222 // Fixes a bug in Firefox where the backpack cannot be opened.
223- Blockly . bindEvent_ ( this . svgBody_ , 'mousedown' , this , function ( e ) { e . stopPropagation ( ) ; e . preventDefault ( ) ; } ) ;
224- Blockly . bindEvent_ ( this . svgBody_ , 'click' , this , this . openBackpack ) ;
225- Blockly . bindEvent_ ( this . svgBody_ , 'contextmenu' , this , this . openBackpackMenu ) ;
223+ Blockly . browserEvents . bind ( this . svgBody_ , 'mousedown' , this , function ( e ) { e . stopPropagation ( ) ; e . preventDefault ( ) ; } ) ;
224+ Blockly . browserEvents . bind ( this . svgBody_ , 'click' , this , this . openBackpack ) ;
225+ Blockly . browserEvents . bind ( this . svgBody_ , 'contextmenu' , this , this . openBackpackMenu ) ;
226226 this . flyout_ . init ( this . workspace_ ) ;
227227 this . flyout_ . workspace_ . isBackpack = true ;
228228
229229 // load files for sound effect
230- Blockly . getMainWorkspace ( ) . loadAudio_ ( [ 'static/media/backpack.mp3' , 'static/media/backpack.ogg' , 'static/media/backpack.wav' ] , 'backpack' ) ;
230+ Blockly . common . getMainWorkspace ( ) . getAudioManager ( ) . load ( [ 'static/media/backpack.mp3' , 'static/media/backpack.ogg' , 'static/media/backpack.wav' ] , 'backpack' ) ;
231231
232232 var p = this ;
233233 this . getContents ( function ( contents ) {
@@ -317,7 +317,7 @@ Blockly.Backpack.prototype.checkValidBlockTypes = function(block, arr) {
317317 *
318318 */
319319Blockly . Backpack . prototype . addAllToBackpack = function ( ) {
320- var topBlocks = Blockly . mainWorkspace . getTopBlocks ( false ) ;
320+ var topBlocks = Blockly . common . getMainWorkspace ( ) . getTopBlocks ( false ) ;
321321 var p = this ;
322322 this . getContents ( function ( contents ) {
323323 var saveAsync = p . NoAsync_ ;
@@ -361,7 +361,7 @@ Blockly.Backpack.prototype.addToBackpack = function(block, store) {
361361 // storage in the future.
362362 p . setContents ( bp_contents , store ) ;
363363 p . grow ( ) ;
364- Blockly . getMainWorkspace ( ) . playAudio ( 'backpack' ) ;
364+ Blockly . common . getMainWorkspace ( ) . playAudio ( 'backpack' ) ;
365365
366366 // update the flyout when it's visible
367367 if ( p . flyout_ . isVisible ( ) ) {
@@ -448,8 +448,8 @@ Blockly.Backpack.prototype.openBackpackMenu = function(e) {
448448 var backpackClear = { enabled : true } ;
449449 backpackClear . text = Blockly . Msg . BACKPACK_EMPTY ;
450450 backpackClear . callback = function ( ) {
451- if ( Blockly . getMainWorkspace ( ) . hasBackpack ( ) ) {
452- Blockly . getMainWorkspace ( ) . getBackpack ( ) . clear ( ) ;
451+ if ( Blockly . common . getMainWorkspace ( ) . hasBackpack ( ) ) {
452+ Blockly . common . getMainWorkspace ( ) . getBackpack ( ) . clear ( ) ;
453453 }
454454 } ;
455455 options . push ( backpackClear ) ;
@@ -492,10 +492,10 @@ Blockly.Backpack.prototype.openBackpack = function(e) {
492492 * @param {!goog.math.Coordinate } start coordinate of the mouseDown event
493493 */
494494Blockly . Backpack . prototype . onMouseUp = function ( e , start ) {
495- var xy = Blockly . selected . getRelativeToSurfaceXY ( ) ;
495+ var xy = Blockly . common . getSelected ( ) . getRelativeToSurfaceXY ( ) ;
496496 var diffXY = goog . math . Coordinate . difference ( start , xy ) ;
497- Blockly . selected . moveBy ( diffXY . x , diffXY . y ) ;
498- Blockly . getMainWorkspace ( ) . render ( ) ;
497+ Blockly . common . getSelected ( ) . moveBy ( diffXY . x , diffXY . y ) ;
498+ Blockly . common . getMainWorkspace ( ) . render ( ) ;
499499} ;
500500
501501/**
@@ -521,7 +521,7 @@ Blockly.Backpack.prototype.onMouseMove = function(e) {
521521} ;
522522
523523Blockly . Backpack . prototype . mouseIsOver = function ( e ) {
524- var xy = Blockly . convertCoordinates ( Blockly . getMainWorkspace ( ) , e . clientX , e . clientY , true ) ;
524+ var xy = Blockly . convertCoordinates ( Blockly . common . getMainWorkspace ( ) , e . clientX , e . clientY , true ) ;
525525 var mouseX = xy . x ;
526526 var mouseY = xy . y ;
527527 return ( mouseX > this . left_ ) &&
0 commit comments