deactivate : function(noButton, anim){ if (!this.currentPanel) return; if (anim === false || !apf.isTrue(settings.model.queryValue('general/@animateui'))) { this.currentPanel.panel.hide(); colLeft.hide(); ide.dispatchEvent("panels.animate", {noanim : true}); apf.layout.forceResize(); } else if (anim) this.animate(this.currentPanel.panel); if (!noButton && this.currentPanel.button) this.currentPanel.button.setValue(false); //Quick Fix if (apf.isGecko) apf.layout.forceResize(vbMain.$ext); ide.dispatchEvent("hidepanel." + this.currentPanel.path); this.currentPanel = null; if (anim != undefined) { settings.model.setQueryValue("auto/panels/@active", "none"); this.mnuPanelsNone.select(); } },
activate : function(panelExt, noButton, noAnim){ if (this.currentPanel == panelExt) return; ext.initExtension(panelExt); var lastPanel = this.currentPanel; if (this.currentPanel && (this.currentPanel != this)) this.deactivate(); var width = settings.model.queryValue("auto/panels/panel[@path='" + panelExt.path + "']/@width") || panelExt.defaultWidth; if (noAnim || !apf.isTrue(settings.model.queryValue('general/@animateui'))) { panelExt.panel.show(); colLeft.setWidth(width); } else if (!noAnim) this.animate(lastPanel && lastPanel.panel, panelExt.panel, width); colLeft.show(); if (!noButton) panelExt.button.setValue(true); splitterPanelLeft.show(); this.currentPanel = panelExt; //settings.model.setQueryValue("auto/panels/@active", panelExt.path); ide.dispatchEvent("showpanel." + panelExt.path); panelExt.mnuItem.select(); //Will set setting too },
initTour: function(){ this.animateui = settings.model.queryValue('general/@animateui'); settings.model.setQueryValue('general/@animateui', false); ext.initExtension(require("ext/console/console")); /*ide.addEventListener("settings.load", function(e){ _self.animateui = settings.model.queryValue('general/@animateui'); settings.model.setQueryValue('general/@animateui', false); });*/ !self["winFilesViewer"] && panels.activate(require("ext/tree/tree")); var demoFile = trFiles.$model.queryNode("//file[@path='" + ide.davPrefix + "/helloWorld-quideTour.js']"); if (demoFile && !deletedFile && false) { txtConsoleInput.setValue("rm helloWorld-quideTour.js"); deletedFile = true; require("ext/console/console").commandTextHandler({ keyCode: 13, currentTarget: txtConsoleInput }); trFiles.confirmed = true; trFiles.remove(demoFile); trFiles.confirmed = false; require("ext/tree/tree").refresh(); } },
initTour: function() { // Remember the states of everything this.cliBoxState = settings.model.queryValue("auto/console/@showinput"); ideConsole.showInput(); this.gutterState = settings.model.queryValue("editors/code/@gutter"); this.statusBarState = settings.model.queryValue("auto/statusbar/@show"); this.projectFilesState = settings.model.queryValue("auto/panels/@active"); panels.activate(require("ext/tree/tree")); var demoFile = trFiles.$model.queryNode("//file[@path='" + ide.davPrefix + "/helloWorld-quideTour.js']"); if (demoFile && !deletedFile && false) { txtConsoleInput.setValue("rm helloWorld-quideTour.js"); deletedFile = true; ideConsole.commandTextHandler({ keyCode: 13, currentTarget: txtConsoleInput }); trFiles.confirmed = true; trFiles.remove(demoFile); trFiles.confirmed = false; require("ext/tree/tree").refresh(); } },
toggleTabs : function(force, preview, noAnim, mouse){ if (typeof noAnim == "undefined") { noAnim = apf.isFalse(settings.model.queryValue("general/@animateui")); } if (!force || force > 0) { if (!preview) { settings.model.setQueryValue("auto/tabs/@show", "true"); this.showTabs = true; ide.dispatchEvent("tabs.visible", {value: true, noanim: noAnim}); } this.setTabResizeValues(tabEditors.parentNode.$ext, force == 1, !noAnim, mouse, 1); } else { if (!preview) { settings.model.setQueryValue("auto/tabs/@show", "false"); this.showTabs = false; ide.dispatchEvent("tabs.visible", {value: false, noanim: noAnim}); } this.setTabResizeValues(tabEditors.parentNode.$ext, force == 1, !noAnim, mouse, 0); } },
deactivate : function(noButton, anim){ if (!this.currentPanel) return; if (!apf.isTrue(settings.model.queryValue('general/@animateui'))) { this.currentPanel.panel.hide(); } else if (anim) this.animate(this.currentPanel.panel); if (!noButton) this.currentPanel.button.setValue(false); splitterPanelLeft.hide(); //Quick Fix if (apf.isGecko) apf.layout.forceResize(ide.vbMain.$ext); settings.model.setQueryValue("auto/panels/@active", ""); ide.dispatchEvent("hidepanel." + this.currentPanel.path); this.currentPanel = null; },
ide.addEventListener("loadsettings", function(){ if (!settings.model.queryNode("auto/panels/panel[@path='" + panelExt.path + "']")) { settings.model.appendXml("<panel path='" + panelExt.path + "' width='" + panelExt.defaultWidth + "' />", "auto/panels"); } });
ide.addEventListener("settings.load", function(){ if (!settings.model.queryNode("auto/panels/panel[@path=" + util.escapeXpathString(panelExt.path) + "]")) { settings.model.appendXml(apf.n("<panel/>") .attr("path", panelExt.path) .attr("width", panelExt.defaultWidth) .node(), "auto/panels"); } });
timer = setTimeout(function(){ if (!_self.currentPanel) return; var query = "auto/panels/panel[@path='" + _self.currentPanel.path + "']/@width"; if (settings.model.queryValue(query) != colLeft.getWidth()) settings.model.setQueryValue(query, colLeft.getWidth()); }, 500);
splitterPanelLeft.addEventListener("dragdrop", function(e){ if (!_self.currentPanel) return; var query = "auto/panels/panel[@path=" + util.escapeXpathString(_self.currentPanel.path) + "]/@width"; if (settings.model.queryValue(query) != colLeft.getWidth()) settings.model.setQueryValue(query, colLeft.getWidth()); });
colLeft.addEventListener("resize", function(){ if (!_self.currentPanel || _self.animating) return; var query = "auto/panels/panel[@path='" + _self.currentPanel.path + "']/@width"; if (settings.model.queryValue(query) != colLeft.getWidth()) settings.model.setQueryValue(query, colLeft.getWidth()); });
ide.addEventListener("settings.load", function(){ if (apf.isGecko) settings.model.setQueryValue("general/@animateui", false); if (!settings.model.queryNode("auto/panels/panel[@path='" + panelExt.path + "']")) { settings.model.appendXml("<panel path='" + panelExt.path + "' width='" + panelExt.defaultWidth + "' />", "auto/panels"); } });
scp.openFile = function(filePath, active, drill) { editors.gotoDocument({path: "/workspace/"+window.courseUUID+filePath, active : active}); ide.dispatchEvent("track_action", {type: "fileopen"}); settings.model.setQueryValue("editors/code/@gutter", true); // has to be here to force show when new editor opens settings.model.setQueryValue("auto/statusbar/@show", true); require("ext/statusbar/statusbar").preinit(); if(drill) tabBehaviors.revealtab(); //tabBehaviors.revealtab(ide.getActivePage, true);// noFocus has no effect? editors.currentEditor.amlEditor.focus(); };
init : function(amlNode){ jsonQuickStart = { identifiers: [ { el : navbar, name : "qsProjectBar", pos: "right", before: function(){ if(!require("ext/panels/panels").currentPanel) navbar.childNodes[1].dispatchEvent("mousedown"); return false; } }, { el : logobar, name : "qsMenuBar", pos: "bottom" }, { el : tabEditors, name : "qsToolbar", pos: "left", visible: function(){ return hboxDockPanel.childNodes[0]; } }, { el : self["txtConsoleInput"], name : "qsCLI", pos: "top", before: function(){ require("ext/console/console").showInput(); return self["txtConsoleInput"]; } } ] }; this.animateui = settings.model.queryValue('general/@animateui'); settings.model.setQueryValue('general/@animateui', false); for (var i = 0; i < jsonQuickStart.identifiers.length; i++) { var idn = jsonQuickStart.identifiers[i]; if(idn.before) { idn.el = idn.before() || idn.el; } } this.overlay = document.createElement("div"); this.overlay.setAttribute("style", "z-index:9016;display:none;position:fixed;left: 0px;top: 0px;width:100%;height:100%;opacity:0.6;background:#000;"); document.body.appendChild(this.overlay); },
initTour: function() { // Remember the states of everything this.cliBoxState = settings.model.queryValue("auto/console/@showinput"); ideConsole.showInput(); this.gutterState = settings.model.queryValue("editors/code/@gutter"); this.statusBarState = settings.model.queryValue("auto/statusbar/@show"); this.projectFilesState = settings.model.queryValue("auto/panels/@active"); panels.activate(require("ext/tree/tree")); },
tabEditors.addEventListener("afterswitch", function(e) { var page = e.nextPage; if (!_self.cycleKeyPressed) { _self.accessList.remove(page); _self.accessList.unshift(page); _self.accessList.changed = true; settings.save(); } if (settings.model.queryValue("auto/panels/@active") == "ext/tree/tree" && apf.isTrue(settings.model.queryValue('general/@revealfile'))) { _self.revealtab(page); } });
activate : function(panelExt, noButton, noAnim){ if (this.currentPanel == panelExt) return; ext.initExtension(panelExt); lastPanel = this.currentPanel; if (this.currentPanel && (this.currentPanel != this)) this.deactivate(); var width = settings.model.queryValue("auto/panels/panel[@path=" + util.escapeXpathString(panelExt.path) + "]/@width") || panelExt.defaultWidth; colLeft.show(); if (noAnim || !apf.isTrue(settings.model.queryValue('general/@animateui'))) { panelExt.panel.show(); colLeft.show(); colLeft.setAttribute("minwidth", panelExt.panel.minwidth); colLeft.setWidth(width); ide.dispatchEvent("panels.animate", {noanim : true, toWidth: width}); apf.layout.forceResize(); } else if (!noAnim) { var _self = this; setTimeout(function(){ _self.animate(lastPanel && lastPanel.panel, panelExt.panel, width); }, 10); } if (!noButton && panelExt.button) panelExt.button.setValue(true); this.currentPanel = panelExt; this.lastPanel = panelExt; settings.model.setQueryValue("auto/panels/@active", panelExt.path); ide.dispatchEvent("showpanel." + panelExt.path); this.mnuPanelsNone.setAttribute("selected", false); panelExt.mnuItem.select(); //Will set setting too panelExt.panel.setTitle(panelExt.button && panelExt.button.caption || "Workspace Files"); },
animateToFullWidth : function(cb){ if (this.animateControl) this.animateControl.stop(); editors.pauseTabResize(); var i = 0, toWidth = navbar.$int.scrollWidth + (editors.showTabs? 6 : 9); if (apf.isTrue(settings.model.queryValue('general/@animateui'))) { apf.tween.single(navbar.$ext, { type: "width", from: navbar.getWidth(), to: toWidth, steps : 10, interval : apf.isChrome ? 0 : 5, control : this.animateControl = {}, anim : apf.tween.easeOutCubic, oneach : function(){ apf.layout.forceResize(); } }); } else { navbar.$ext.style.width = toWidth + "px"; apf.layout.forceResize(); } },
setSearchSelection: function(e){ var selectedNode, name; if (trFiles) { // If originating from an event if (e && e.selected) selectedNode = e.selected; else selectedNode = this.getSelectedTreeNode(); var filepath = selectedNode.getAttribute("path").split("/"); name = ""; // get selected node in tree and set it as selection if (selectedNode.getAttribute("type") == "folder") name = filepath[filepath.length - 1]; else if (selectedNode.getAttribute("type") == "file") name = filepath[filepath.length - 2]; if (name.length > 25) name = name.substr(0, 22) + "..."; } else { var path = settings.model.queryValue("auto/tree_selection/@path"); if (!path) return; var p; if ((name = (p = path.split("/")).pop()).indexOf(".") > -1) name = p.pop(); } rbSFSelection.setAttribute("label", apf.escapeXML("Selection ( " + name + " )")); },
run : function(path, args, debug, nodeVersion) { var runner; if (stProcessRunning.active || typeof path != "string") return false; // TODO there should be a way to set state to waiting stProcessRunning.activate(); path = path.trim(); if (nodeVersion == 'default' || !nodeVersion) { runner = this.detectRunner(path); nodeVersion = runner == 'node' ? settings.model.queryValue("auto/node-version/@version") || this.NODE_VERSION : 'auto'; } else { runner = nodeVersion.split(" ")[0]; nodeVersion = nodeVersion.split(" ")[1] || 'auto'; } var page = ide.getActivePageModel(); var command = { "command" : apf.isTrue(debug) ? "RunDebugBrk" : "Run", "file" : path.replace(/^\/+/, ""), "runner" : runner, "args" : args || [], "version" : nodeVersion, "env" : { "C9_SELECTED_FILE": page ? page.getAttribute("path").slice(ide.davPrefix.length) : "" } }; ide.send(command); },
startTour: function(){ var _self = this; this.currentStep = -1; winTourGuide.hide(); tourControlsDialog.show(); this.stepForward(); this.overlay.style = 'block'; settings.model.setQueryValue('general/@animateui', false); apf.removeEventListener("keyup", _self.keyUpEvent); apf.addEventListener("keyup", _self.keyUpEvent = function(e){ if(e.keyCode == 39) _self.stepForward(); else if(e.keyCode == 37) _self.stepBack(); }); // remove the modal overlay, but keep it around to block input //var modalBackground = document.getElementsByClassName("bk-window-cover"); //modalBackground[modalBackground.length - 1].style.opacity = "0"; },
stProcessRunning.addEventListener("activate", function() { _self.showOutput(); var autoshow = settings.model.queryValue("auto/console/@autoshow"); if (_self.autoOpen && apf.isTrue(autoshow)) _self.show(); });
animateToDefaultWidth : function(){ if (this.animateControl) this.animateControl.stop(); var i = 0, toWidth = colLeft.getWidth(); if (apf.isTrue(settings.model.queryValue('general/@animateui'))) { apf.tween.single(navbar.$ext, { type: "width", from: navbar.getWidth(), to: toWidth, steps : 10, interval : apf.isChrome ? 0 : 5, control : this.animateControl = {}, anim : apf.tween.easeOutCubic, oneach : function(){ if (i++ == 4 && colLeft.getWidth() == 0) apf.setStyleClass(navbar.$ext, "closed"); apf.layout.forceResize(); }, onfinish : function(){ apf.layout.forceResize(); editors.continueTabResize(); } }); } else { navbar.$ext.style.width = toWidth + "px"; apf.layout.forceResize(); editors.continueTabResize(); } },
showInput : function(temporary){ if (!this.hiddenInput) return; ext.initExtension(this); this.$collapsedHeight = this.collapsedHeight; if (this.hidden) winDbgConsole.setAttribute("height", this.collapsedHeight + "px") txtConsoleInput.parentNode.show(); apf.layout.forceResize(); if (temporary) { var _self = this; txtConsoleInput.addEventListener("blur", function(){ if (_self.hiddenInput) _self.hideInput(true); txtConsoleInput.removeEventListener("blur", arguments.callee); }); txtConsoleInput.focus() } else { settings.model.setQueryValue("auto/console/@showinput", true); this.hiddenInput = false; } },
on(pgTerminal, 'mousedown', function() { if(console.hiddenInput == false && settings.model.queryValue("auto/console/@showinput") == 'true') { console.hideInput(); settings.model.setQueryValue("auto/console/@showinput", true); on(document.getElementsByClassName('pgOutput')[0], 'click', function() { if(settings.model.queryValue("auto/console/@showinput") == 'true') console.showInput(); }); var length = document.getElementsByClassName('pgConsole').length; for (var i = 0; i < length; i++) { on(document.getElementsByClassName('pgConsole')[i], 'click', function() { if(settings.model.queryValue("auto/console/@showinput") == 'true') console.showInput(); }); } } });
_self.searchConsole.addEventListener("keyup", function(e) { if (e.keyCode >= 37 && e.keyCode <= 40) { // KEYUP or KEYDOWN if (apf.isTrue(settings.model.queryValue("editors/code/filesearch/@consolelaunch"))) { _self.launchFileFromSearch(_self.searchConsole.$editor); _self.returnFocus = true; return false; } } });
hideInput : function(force, immediate){ var _self = this; if (!force && (!this.inited || this.hiddenInput)) return; this.$collapsedHeight = 0; var timing = "cubic-bezier(.10, .10, .25, .90)"; var cliExt = cliBox.$ext; if (_self.hidden) { cliExt.style.minHeight = (_self.collapsedHeight - apf.getHeightDiff(cliExt)) + "px"; cliExt.style.bottom = ""; document.body.scrollTop = 0; anims.animateSplitBoxNode(winDbgConsole, { height: "0px", timingFunction: timing, duration: 0.2, immediate: immediate }, function(){ cliExt.style.minHeight = ""; cliExt.style.bottom = 0; cliBox.hide(); apf.layout.forceResize(); }); } else { cliExt.scrollTop = 0; document.body.scrollTop = 0; anims.animate(tabConsole, { bottom : "0px", timingFunction: timing, duration: 0.2, immediate: immediate }); anims.animate(cliBox, { bottom: "-" + _self.collapsedHeight + "px", timingFunction: timing, duration: 0.2, immediate: immediate }, function(){ cliBox.parentNode.$ext.style.overflow = ""; cliBox.setHeight(0); cliBox.hide(); apf.layout.forceResize(); }); } settings.model.setQueryValue("auto/console/@showinput", false); this.hiddenInput = true; },
setCustomType: function(ext, mime) { var node; if (typeof ext === "string") { node = settings.model.queryNode('auto/customtypes/mime[@ext="' + ext + '"]'); if (!node) settings.model.appendXml('<mime name="' + mime + '" ext="' + ext + '" />', "auto/customtypes"); } else { var name = ext.getAttribute("name") || ""; node = settings.model.queryNode('auto/customtypes/mime[@filename="' + name + '"]'); if (node) apf.xmldb.removeAttribute(node, "ext"); else settings.model.appendXml('<mime name="' + mime + '" filename="' + name + '" />', "auto/customtypes"); } apf.xmldb.setAttribute(node, "name", mime); settings.save(); },
getPattern : function(){ return settings.model.queryValue("auto/testpanel/pattern/text()") || "// Enter any code below that returns the paths of the tests in an array of strings.\n" + "// You have access to the 'path' variable.\n" + "// Save this file to store the pattern.\n" + "var tests = [];\n" + "return tests.pushUnique(\n" + " path.replace(/(?:_test)?\.js$/, \"_test.js\"),\n" + " path.replace(/(?:_Test)?\.js$/, \"Test.js\")\n" + ");"; },
closeStart : function() { //debugPanelCompact.hide(); quickStartDialog.hide(); this.overlay.style.display = "none"; var imgDiv; for (var i = 0; i < jsonQuickStart.identifiers.length; i++) { imgDiv = apf.document.getElementById(jsonQuickStart.identifiers[i].name); imgDiv.hide(); } settings.model.setQueryValue('general/@animateui', this.animateui); },