(e)
| 537 | } |
| 538 | |
| 539 | onPlayLevel (e) { |
| 540 | let left, newClassMode |
| 541 | const team = $(e.target).data('team') |
| 542 | const opponentSessionID = $(e.target).data('opponent') |
| 543 | if ($(e.target).data('classroom') === 'home') { |
| 544 | newClassMode = (this.lastNewClassMode = undefined) |
| 545 | } else if ($(e.target).data('classroom')) { |
| 546 | newClassMode = (this.lastNewClassMode = true) |
| 547 | } else { |
| 548 | newClassMode = this.lastNewClassMode |
| 549 | } |
| 550 | const newClassLanguage = (this.lastNewClassLanguage = ((left = $(e.target).data('code-language')) != null ? left : this.lastNewClassLanguage) || undefined) |
| 551 | if (utils.isOzaria && this.childWindow && (this.childWindow.closed || !this.childWindow.onPlayLevelViewLoaded)) { |
| 552 | __guardMethod__(this.childWindow, 'close', o => o.close()) |
| 553 | return noty({ timeout: 4000, text: 'Error: child window disconnected, you will have to reload this page to preview.', type: 'error', layout: 'top' }) |
| 554 | } |
| 555 | const sendLevel = () => { |
| 556 | return this.childWindow.Backbone.Mediator.publish('level:reload-from-data', { level: this.level, supermodel: this.supermodel }) |
| 557 | } |
| 558 | if (this.childWindow && !this.childWindow.closed && (this.playClassMode === newClassMode) && (this.playClassLanguage === newClassLanguage)) { |
| 559 | // Reset the LevelView's world, but leave the rest of the state alone |
| 560 | sendLevel() |
| 561 | } else { |
| 562 | // Create a new Window with a blank LevelView |
| 563 | let scratchLevelID = this.level.get('slug') + '?dev=true' |
| 564 | if (team) { scratchLevelID += `&team=${team}` } |
| 565 | if (opponentSessionID) { scratchLevelID += `&opponent=${opponentSessionID}` } |
| 566 | this.playClassMode = newClassMode |
| 567 | this.playClassLanguage = newClassLanguage |
| 568 | if (this.playClassMode) { |
| 569 | scratchLevelID += `&course=${this.courseID}` |
| 570 | scratchLevelID += `&codeLanguage=${this.playClassLanguage}` |
| 571 | } |
| 572 | if (utils.isOzaria) { |
| 573 | this.childWindow = window.open(`/play/level/${scratchLevelID}`, 'child_window') |
| 574 | } else if (me.get('name') === 'Nick') { |
| 575 | this.childWindow = window.open(`/play/level/${scratchLevelID}`, 'child_window', 'width=2560,height=1080,left=0,top=-1600,location=1,menubar=1,scrollbars=1,status=0,titlebar=1,toolbar=1', true) |
| 576 | } else { |
| 577 | this.childWindow = window.open(`/play/level/${scratchLevelID}`, 'child_window', 'width=1280,height=640,left=10,top=10,location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0', true) |
| 578 | } |
| 579 | this.childWindow.onPlayLevelViewLoaded = e => sendLevel() // still a hack |
| 580 | } |
| 581 | return this.childWindow.focus() |
| 582 | } |
| 583 | |
| 584 | onUndo () { |
| 585 | return __guard__(TreemaNode.getLastTreemaWithFocus(), x => x.undo()) |
no test coverage detected