Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateSplitView: function(previous, next) {
var editor;
var doc = next.$doc;
var at = next.$at;
// check if this is a valid clone session
var split = Splits.get(next)[0];
// hide the previous split view
if (previous && previous.$model) {
var oldSplit = Splits.get(previous)[0];
//console.log("got old split?",oldSplit);
if (oldSplit && (!split || oldSplit.gridLayout != split.gridLayout))
Splits.hide(oldSplit);
}
// enable split view ONLY for code editors for now...
if (next.$editor.name.indexOf("Code Editor") > -1) {
mnuCloneView.enable();
mnuSplitAlign.enable();
}
else {
mnuCloneView.disable();
ide.addEventListener("tab.beforeswitch", function(e) {
// the return value actually does something!
var cancelSwitch = _self.updateSplitView(e.previousPage, e.nextPage);
var split = Splits.get(e.nextPage)[0];
if (split)
Splits.update(split);
if (cancelSwitch) {
var page = e.nextPage;
var editorPage = tabs.getPage(page.type);
if (editorPage.model != page.$model)
editorPage.setAttribute("model", page.$model);
if (editorPage.actiontracker != page.$at)
editorPage.setAttribute("actiontracker", page.$at);
}
return cancelSwitch;
});
updateSplitView: function(previous, next) {
//if (restoring)
// return;
var editor;
var doc = next.$doc;
var at = next.$at;
// check if this is a valid clone session
var split = splits.get(next)[0];
// hide the previous split view
if (previous && previous.$model) {
var oldSplit = splits.get(previous)[0];
if (oldSplit && (!split || oldSplit.gridLayout != split.gridLayout))
splits.hide(oldSplit);
}
// enable split view ONLY for code editors for now...
if (this.isSupportedEditor(next.$editor)) {
mnuCloneView.enable();
mnuSplitAlign.enable();
}
else {
mnuCloneView.disable();
mnuSplitAlign.disable();
updateSplitView: function(previous, next) {
//if (restoring)
// return;
var editor;
var doc = next.$doc;
var at = next.$at;
// check if this is a valid clone session
var split = splits.get(next)[0];
// hide the previous split view
if (previous && previous.$model) {
var oldSplit = splits.get(previous)[0];
if (oldSplit && (!split || oldSplit.gridLayout != split.gridLayout))
splits.hide(oldSplit);
}
// enable split view ONLY for code editors for now...
if (this.isSupportedEditor(next.$editor)) {
mnuCloneView.enable();
mnuSplitAlign.enable();
}
else {
mnuCloneView.disable();
mnuSplitAlign.disable();
}
mnuCloneView.setAttribute("checked", false);
mnuSplitAlign.setAttribute("checked", false);
function onAccessTabbing(e) {
var split = splits.get(e.page)[0];
return !splits.isActive(split);
}
function onAccessTabbing(e) {
var split = Splits.get(e.page)[0];
return !Splits.isActive(split);
}
getCloneView: function(page) {
//@todo this can never work. Local variable...
var splits = Splits.get(page);
if (!splits.length)
return null;
for (var i = 0, l = splits.length; i < l; ++i) {
if (splits[i] && splits[i].clone)
return splits[i];
}
return null;
},
ide.addEventListener("activepagemodel", function(e) {
var page = tabs.getPage();
var split = splits.get(page)[0];
if (!split || !splits.isActive(split))
return;
e.returnValue = split.pairs[split.activePage || 0].page.$model;
});
save: function() {
if (!Settings.model)
return;
var node = apf.createNodeFromXpath(Settings.model.data, "splits");
var i, l;
for (i = node.childNodes.length - 1; i >= 0; --i)
node.removeChild(node.childNodes[i]);
var splits = Splits.get();
var splitEl;
for (i = 0, l = splits.length; i < l; ++i) {
splitEl = apf.getXml("");
splitEl.setAttribute("pages", splits[i].pairs.map(function(pair) {
return pair.page.id;
}).join(","));
splitEl.setAttribute("active", Splits.isActive(splits[i]) ? "true" : "false");
splitEl.setAttribute("layout", splits[i].gridLayout);
node.appendChild(splitEl);
}
apf.xmldb.applyChanges("synchronize", node);
},
onFileClose: function(e) {
var page = e.page;
var splits = Splits.get(page);
for (var i = 0, l = splits.length; i < l; ++i)
Splits.mutate(splits[i], page);
this.save();
},