repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
adobe/brackets
|
src/command/Menus.js
|
removeMenuItemEventListeners
|
function removeMenuItemEventListeners(menuItem) {
menuItem._command
.off("enabledStateChange", menuItem._enabledChanged)
.off("checkedStateChange", menuItem._checkedChanged)
.off("nameChange", menuItem._nameChanged)
.off("keyBindingAdded", menuItem._keyBindingAdded)
.off("keyBindingRemoved", menuItem._keyBindingRemoved);
}
|
javascript
|
function removeMenuItemEventListeners(menuItem) {
menuItem._command
.off("enabledStateChange", menuItem._enabledChanged)
.off("checkedStateChange", menuItem._checkedChanged)
.off("nameChange", menuItem._nameChanged)
.off("keyBindingAdded", menuItem._keyBindingAdded)
.off("keyBindingRemoved", menuItem._keyBindingRemoved);
}
|
[
"function",
"removeMenuItemEventListeners",
"(",
"menuItem",
")",
"{",
"menuItem",
".",
"_command",
".",
"off",
"(",
"\"enabledStateChange\"",
",",
"menuItem",
".",
"_enabledChanged",
")",
".",
"off",
"(",
"\"checkedStateChange\"",
",",
"menuItem",
".",
"_checkedChanged",
")",
".",
"off",
"(",
"\"nameChange\"",
",",
"menuItem",
".",
"_nameChanged",
")",
".",
"off",
"(",
"\"keyBindingAdded\"",
",",
"menuItem",
".",
"_keyBindingAdded",
")",
".",
"off",
"(",
"\"keyBindingRemoved\"",
",",
"menuItem",
".",
"_keyBindingRemoved",
")",
";",
"}"
] |
Removes the attached event listeners from the corresponding object.
@param {ManuItem} menuItem
|
[
"Removes",
"the",
"attached",
"event",
"listeners",
"from",
"the",
"corresponding",
"object",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L186-L193
|
train
|
adobe/brackets
|
src/command/Menus.js
|
_insertInList
|
function _insertInList($list, $element, position, $relativeElement) {
// Determine where to insert. Default is LAST.
var inserted = false;
if (position) {
// Adjust relative position for menu section positions since $relativeElement
// has already been resolved by _getRelativeMenuItem() to a menuItem
if (position === FIRST_IN_SECTION) {
position = BEFORE;
} else if (position === LAST_IN_SECTION) {
position = AFTER;
}
if (position === FIRST) {
$list.prepend($element);
inserted = true;
} else if ($relativeElement && $relativeElement.length > 0) {
if (position === AFTER) {
$relativeElement.after($element);
inserted = true;
} else if (position === BEFORE) {
$relativeElement.before($element);
inserted = true;
}
}
}
// Default to LAST
if (!inserted) {
$list.append($element);
}
}
|
javascript
|
function _insertInList($list, $element, position, $relativeElement) {
// Determine where to insert. Default is LAST.
var inserted = false;
if (position) {
// Adjust relative position for menu section positions since $relativeElement
// has already been resolved by _getRelativeMenuItem() to a menuItem
if (position === FIRST_IN_SECTION) {
position = BEFORE;
} else if (position === LAST_IN_SECTION) {
position = AFTER;
}
if (position === FIRST) {
$list.prepend($element);
inserted = true;
} else if ($relativeElement && $relativeElement.length > 0) {
if (position === AFTER) {
$relativeElement.after($element);
inserted = true;
} else if (position === BEFORE) {
$relativeElement.before($element);
inserted = true;
}
}
}
// Default to LAST
if (!inserted) {
$list.append($element);
}
}
|
[
"function",
"_insertInList",
"(",
"$list",
",",
"$element",
",",
"position",
",",
"$relativeElement",
")",
"{",
"var",
"inserted",
"=",
"false",
";",
"if",
"(",
"position",
")",
"{",
"if",
"(",
"position",
"===",
"FIRST_IN_SECTION",
")",
"{",
"position",
"=",
"BEFORE",
";",
"}",
"else",
"if",
"(",
"position",
"===",
"LAST_IN_SECTION",
")",
"{",
"position",
"=",
"AFTER",
";",
"}",
"if",
"(",
"position",
"===",
"FIRST",
")",
"{",
"$list",
".",
"prepend",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"$relativeElement",
"&&",
"$relativeElement",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"position",
"===",
"AFTER",
")",
"{",
"$relativeElement",
".",
"after",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"position",
"===",
"BEFORE",
")",
"{",
"$relativeElement",
".",
"before",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"inserted",
")",
"{",
"$list",
".",
"append",
"(",
"$element",
")",
";",
"}",
"}"
] |
Help function for inserting elements into a list
|
[
"Help",
"function",
"for",
"inserting",
"elements",
"into",
"a",
"list"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L256-L287
|
train
|
adobe/brackets
|
src/command/Menus.js
|
MenuItem
|
function MenuItem(id, command) {
this.id = id;
this.isDivider = (command === DIVIDER);
this.isNative = false;
if (!this.isDivider && command !== SUBMENU) {
// Bind event handlers
this._enabledChanged = this._enabledChanged.bind(this);
this._checkedChanged = this._checkedChanged.bind(this);
this._nameChanged = this._nameChanged.bind(this);
this._keyBindingAdded = this._keyBindingAdded.bind(this);
this._keyBindingRemoved = this._keyBindingRemoved.bind(this);
this._command = command;
this._command
.on("enabledStateChange", this._enabledChanged)
.on("checkedStateChange", this._checkedChanged)
.on("nameChange", this._nameChanged)
.on("keyBindingAdded", this._keyBindingAdded)
.on("keyBindingRemoved", this._keyBindingRemoved);
}
}
|
javascript
|
function MenuItem(id, command) {
this.id = id;
this.isDivider = (command === DIVIDER);
this.isNative = false;
if (!this.isDivider && command !== SUBMENU) {
// Bind event handlers
this._enabledChanged = this._enabledChanged.bind(this);
this._checkedChanged = this._checkedChanged.bind(this);
this._nameChanged = this._nameChanged.bind(this);
this._keyBindingAdded = this._keyBindingAdded.bind(this);
this._keyBindingRemoved = this._keyBindingRemoved.bind(this);
this._command = command;
this._command
.on("enabledStateChange", this._enabledChanged)
.on("checkedStateChange", this._checkedChanged)
.on("nameChange", this._nameChanged)
.on("keyBindingAdded", this._keyBindingAdded)
.on("keyBindingRemoved", this._keyBindingRemoved);
}
}
|
[
"function",
"MenuItem",
"(",
"id",
",",
"command",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"isDivider",
"=",
"(",
"command",
"===",
"DIVIDER",
")",
";",
"this",
".",
"isNative",
"=",
"false",
";",
"if",
"(",
"!",
"this",
".",
"isDivider",
"&&",
"command",
"!==",
"SUBMENU",
")",
"{",
"this",
".",
"_enabledChanged",
"=",
"this",
".",
"_enabledChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_checkedChanged",
"=",
"this",
".",
"_checkedChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_nameChanged",
"=",
"this",
".",
"_nameChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_keyBindingAdded",
"=",
"this",
".",
"_keyBindingAdded",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_keyBindingRemoved",
"=",
"this",
".",
"_keyBindingRemoved",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_command",
"=",
"command",
";",
"this",
".",
"_command",
".",
"on",
"(",
"\"enabledStateChange\"",
",",
"this",
".",
"_enabledChanged",
")",
".",
"on",
"(",
"\"checkedStateChange\"",
",",
"this",
".",
"_checkedChanged",
")",
".",
"on",
"(",
"\"nameChange\"",
",",
"this",
".",
"_nameChanged",
")",
".",
"on",
"(",
"\"keyBindingAdded\"",
",",
"this",
".",
"_keyBindingAdded",
")",
".",
"on",
"(",
"\"keyBindingRemoved\"",
",",
"this",
".",
"_keyBindingRemoved",
")",
";",
"}",
"}"
] |
MenuItem represents a single menu item that executes a Command or a menu divider. MenuItems
may have a sub-menu. A MenuItem may correspond to an HTML-based
menu item or a native menu item if Brackets is running in a native application shell
Since MenuItems may have a native implementation clients should create MenuItems through
addMenuItem() and should NOT construct a MenuItem object directly.
Clients should also not access HTML content of a menu directly and instead use
the MenuItem API to query and modify menus items.
MenuItems are views on to Command objects so modify the underlying Command to modify the
name, enabled, and checked state of a MenuItem. The MenuItem will update automatically
@constructor
@private
@param {string} id
@param {string|Command} command - the Command this MenuItem will reflect.
Use DIVIDER to specify a menu divider
|
[
"MenuItem",
"represents",
"a",
"single",
"menu",
"item",
"that",
"executes",
"a",
"Command",
"or",
"a",
"menu",
"divider",
".",
"MenuItems",
"may",
"have",
"a",
"sub",
"-",
"menu",
".",
"A",
"MenuItem",
"may",
"correspond",
"to",
"an",
"HTML",
"-",
"based",
"menu",
"item",
"or",
"a",
"native",
"menu",
"item",
"if",
"Brackets",
"is",
"running",
"in",
"a",
"native",
"application",
"shell"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L309-L330
|
train
|
adobe/brackets
|
src/command/Menus.js
|
addMenu
|
function addMenu(name, id, position, relativeID) {
name = _.escape(name);
var $menubar = $("#titlebar .nav"),
menu;
if (!name || !id) {
console.error("call to addMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (menuMap[id]) {
console.log("Menu added with same name and id of existing Menu: " + id);
return null;
}
menu = new Menu(id);
menuMap[id] = menu;
if (!_isHTMLMenu(id)) {
brackets.app.addMenu(name, id, position, relativeID, function (err) {
switch (err) {
case NO_ERROR:
// Make sure name is up to date
brackets.app.setMenuTitle(id, name, function (err) {
if (err) {
console.error("setMenuTitle() -- error: " + err);
}
});
break;
case ERR_UNKNOWN:
console.error("addMenu(): Unknown Error when adding the menu " + id);
break;
case ERR_INVALID_PARAMS:
console.error("addMenu(): Invalid Parameters when adding the menu " + id);
break;
case ERR_NOT_FOUND:
console.error("addMenu(): Menu with command " + relativeID + " could not be found when adding the menu " + id);
break;
default:
console.error("addMenu(): Unknown Error (" + err + ") when adding the menu " + id);
}
});
return menu;
}
var $toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'>" + name + "</a>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$newMenu = $("<li class='dropdown' id='" + id + "'></li>").append($toggle).append($popUp);
// Insert menu
var $relativeElement = relativeID && $(_getHTMLMenu(relativeID));
_insertInList($menubar, $newMenu, position, $relativeElement);
// Install ESC key handling
PopUpManager.addPopUp($popUp, closeAll, false);
// todo error handling
return menu;
}
|
javascript
|
function addMenu(name, id, position, relativeID) {
name = _.escape(name);
var $menubar = $("#titlebar .nav"),
menu;
if (!name || !id) {
console.error("call to addMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (menuMap[id]) {
console.log("Menu added with same name and id of existing Menu: " + id);
return null;
}
menu = new Menu(id);
menuMap[id] = menu;
if (!_isHTMLMenu(id)) {
brackets.app.addMenu(name, id, position, relativeID, function (err) {
switch (err) {
case NO_ERROR:
// Make sure name is up to date
brackets.app.setMenuTitle(id, name, function (err) {
if (err) {
console.error("setMenuTitle() -- error: " + err);
}
});
break;
case ERR_UNKNOWN:
console.error("addMenu(): Unknown Error when adding the menu " + id);
break;
case ERR_INVALID_PARAMS:
console.error("addMenu(): Invalid Parameters when adding the menu " + id);
break;
case ERR_NOT_FOUND:
console.error("addMenu(): Menu with command " + relativeID + " could not be found when adding the menu " + id);
break;
default:
console.error("addMenu(): Unknown Error (" + err + ") when adding the menu " + id);
}
});
return menu;
}
var $toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'>" + name + "</a>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$newMenu = $("<li class='dropdown' id='" + id + "'></li>").append($toggle).append($popUp);
// Insert menu
var $relativeElement = relativeID && $(_getHTMLMenu(relativeID));
_insertInList($menubar, $newMenu, position, $relativeElement);
// Install ESC key handling
PopUpManager.addPopUp($popUp, closeAll, false);
// todo error handling
return menu;
}
|
[
"function",
"addMenu",
"(",
"name",
",",
"id",
",",
"position",
",",
"relativeID",
")",
"{",
"name",
"=",
"_",
".",
"escape",
"(",
"name",
")",
";",
"var",
"$menubar",
"=",
"$",
"(",
"\"#titlebar .nav\"",
")",
",",
"menu",
";",
"if",
"(",
"!",
"name",
"||",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"call to addMenu() is missing required parameters\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"menuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Menu added with same name and id of existing Menu: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"menu",
"=",
"new",
"Menu",
"(",
"id",
")",
";",
"menuMap",
"[",
"id",
"]",
"=",
"menu",
";",
"if",
"(",
"!",
"_isHTMLMenu",
"(",
"id",
")",
")",
"{",
"brackets",
".",
"app",
".",
"addMenu",
"(",
"name",
",",
"id",
",",
"position",
",",
"relativeID",
",",
"function",
"(",
"err",
")",
"{",
"switch",
"(",
"err",
")",
"{",
"case",
"NO_ERROR",
":",
"brackets",
".",
"app",
".",
"setMenuTitle",
"(",
"id",
",",
"name",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"setMenuTitle() -- error: \"",
"+",
"err",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"case",
"ERR_UNKNOWN",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Unknown Error when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"case",
"ERR_INVALID_PARAMS",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Invalid Parameters when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"case",
"ERR_NOT_FOUND",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Menu with command \"",
"+",
"relativeID",
"+",
"\" could not be found when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"default",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Unknown Error (\"",
"+",
"err",
"+",
"\") when adding the menu \"",
"+",
"id",
")",
";",
"}",
"}",
")",
";",
"return",
"menu",
";",
"}",
"var",
"$toggle",
"=",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'>\"",
"+",
"name",
"+",
"\"</a>\"",
")",
",",
"$popUp",
"=",
"$",
"(",
"\"<ul class='dropdown-menu'></ul>\"",
")",
",",
"$newMenu",
"=",
"$",
"(",
"\"<li class='dropdown' id='\"",
"+",
"id",
"+",
"\"'></li>\"",
")",
".",
"append",
"(",
"$toggle",
")",
".",
"append",
"(",
"$popUp",
")",
";",
"var",
"$relativeElement",
"=",
"relativeID",
"&&",
"$",
"(",
"_getHTMLMenu",
"(",
"relativeID",
")",
")",
";",
"_insertInList",
"(",
"$menubar",
",",
"$newMenu",
",",
"position",
",",
"$relativeElement",
")",
";",
"PopUpManager",
".",
"addPopUp",
"(",
"$popUp",
",",
"closeAll",
",",
"false",
")",
";",
"return",
"menu",
";",
"}"
] |
Adds a top-level menu to the application menu bar which may be native or HTML-based.
@param {!string} name - display text for menu
@param {!string} id - unique identifier for a menu.
Core Menus in Brackets use a simple title as an id, for example "file-menu".
Extensions should use the following format: "author.myextension.mymenuname".
@param {?string} position - constant defining the position of new the Menu relative
to other Menus. Default is LAST (see Insertion position constants).
@param {?string} relativeID - id of Menu the new Menu will be positioned relative to. Required
when position is AFTER or BEFORE, ignored when position is FIRST or LAST
@return {?Menu} the newly created Menu
|
[
"Adds",
"a",
"top",
"-",
"level",
"menu",
"to",
"the",
"application",
"menu",
"bar",
"which",
"may",
"be",
"native",
"or",
"HTML",
"-",
"based",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1044-L1104
|
train
|
adobe/brackets
|
src/command/Menus.js
|
removeMenu
|
function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
}
|
javascript
|
function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
}
|
[
"function",
"removeMenu",
"(",
"id",
")",
"{",
"var",
"menu",
",",
"commandID",
"=",
"\"\"",
";",
"if",
"(",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu(): missing required parameter: id\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"menuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu(): menu id not found: %s\"",
",",
"id",
")",
";",
"return",
";",
"}",
"menu",
"=",
"getMenu",
"(",
"id",
")",
";",
"_",
".",
"forEach",
"(",
"menuItemMap",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"_",
".",
"startsWith",
"(",
"key",
",",
"id",
")",
")",
"{",
"if",
"(",
"value",
".",
"isDivider",
")",
"{",
"menu",
".",
"removeMenuDivider",
"(",
"key",
")",
";",
"}",
"else",
"{",
"commandID",
"=",
"value",
".",
"getCommand",
"(",
")",
";",
"menu",
".",
"removeMenuItem",
"(",
"commandID",
")",
";",
"}",
"}",
"}",
")",
";",
"if",
"(",
"_isHTMLMenu",
"(",
"id",
")",
")",
"{",
"$",
"(",
"_getHTMLMenu",
"(",
"id",
")",
")",
".",
"remove",
"(",
")",
";",
"}",
"else",
"{",
"brackets",
".",
"app",
".",
"removeMenu",
"(",
"id",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu() -- id not found: \"",
"+",
"id",
"+",
"\" (error: \"",
"+",
"err",
"+",
"\")\"",
")",
";",
"}",
"}",
")",
";",
"}",
"delete",
"menuMap",
"[",
"id",
"]",
";",
"}"
] |
Removes a top-level menu from the application menu bar which may be native or HTML-based.
@param {!string} id - unique identifier for a menu.
Core Menus in Brackets use a simple title as an id, for example "file-menu".
Extensions should use the following format: "author.myextension.mymenuname".
|
[
"Removes",
"a",
"top",
"-",
"level",
"menu",
"from",
"the",
"application",
"menu",
"bar",
"which",
"may",
"be",
"native",
"or",
"HTML",
"-",
"based",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1113-L1152
|
train
|
adobe/brackets
|
src/command/Menus.js
|
ContextMenu
|
function ContextMenu(id) {
Menu.apply(this, arguments);
var $newMenu = $("<li class='dropdown context-menu' id='" + StringUtils.jQueryIdEscape(id) + "'></li>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>").hide();
// assemble the menu fragments
$newMenu.append($toggle).append($popUp);
// insert into DOM
$("#context-menu-bar > ul").append($newMenu);
var self = this;
PopUpManager.addPopUp($popUp,
function () {
self.close();
},
false);
// Listen to ContextMenu's beforeContextMenuOpen event to first close other popups
PopUpManager.listenToContextMenu(this);
}
|
javascript
|
function ContextMenu(id) {
Menu.apply(this, arguments);
var $newMenu = $("<li class='dropdown context-menu' id='" + StringUtils.jQueryIdEscape(id) + "'></li>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>").hide();
// assemble the menu fragments
$newMenu.append($toggle).append($popUp);
// insert into DOM
$("#context-menu-bar > ul").append($newMenu);
var self = this;
PopUpManager.addPopUp($popUp,
function () {
self.close();
},
false);
// Listen to ContextMenu's beforeContextMenuOpen event to first close other popups
PopUpManager.listenToContextMenu(this);
}
|
[
"function",
"ContextMenu",
"(",
"id",
")",
"{",
"Menu",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"$newMenu",
"=",
"$",
"(",
"\"<li class='dropdown context-menu' id='\"",
"+",
"StringUtils",
".",
"jQueryIdEscape",
"(",
"id",
")",
"+",
"\"'></li>\"",
")",
",",
"$popUp",
"=",
"$",
"(",
"\"<ul class='dropdown-menu'></ul>\"",
")",
",",
"$toggle",
"=",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>\"",
")",
".",
"hide",
"(",
")",
";",
"$newMenu",
".",
"append",
"(",
"$toggle",
")",
".",
"append",
"(",
"$popUp",
")",
";",
"$",
"(",
"\"#context-menu-bar > ul\"",
")",
".",
"append",
"(",
"$newMenu",
")",
";",
"var",
"self",
"=",
"this",
";",
"PopUpManager",
".",
"addPopUp",
"(",
"$popUp",
",",
"function",
"(",
")",
"{",
"self",
".",
"close",
"(",
")",
";",
"}",
",",
"false",
")",
";",
"PopUpManager",
".",
"listenToContextMenu",
"(",
"this",
")",
";",
"}"
] |
Represents a context menu that can open at a specific location in the UI.
Clients should not create this object directly and should instead use registerContextMenu()
to create new ContextMenu objects.
Context menus in brackets may be HTML-based or native so clients should not reach into
the HTML and should instead manipulate ContextMenus through the API.
Events:
- beforeContextMenuOpen
- beforeContextMenuClose
@constructor
@extends {Menu}
|
[
"Represents",
"a",
"context",
"menu",
"that",
"can",
"open",
"at",
"a",
"specific",
"location",
"in",
"the",
"UI",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1170-L1192
|
train
|
adobe/brackets
|
src/command/Menus.js
|
registerContextMenu
|
function registerContextMenu(id) {
if (!id) {
console.error("call to registerContextMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (contextMenuMap[id]) {
console.log("Context Menu added with same name and id of existing Context Menu: " + id);
return null;
}
var cmenu = new ContextMenu(id);
contextMenuMap[id] = cmenu;
return cmenu;
}
|
javascript
|
function registerContextMenu(id) {
if (!id) {
console.error("call to registerContextMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (contextMenuMap[id]) {
console.log("Context Menu added with same name and id of existing Context Menu: " + id);
return null;
}
var cmenu = new ContextMenu(id);
contextMenuMap[id] = cmenu;
return cmenu;
}
|
[
"function",
"registerContextMenu",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"call to registerContextMenu() is missing required parameters\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"contextMenuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Context Menu added with same name and id of existing Context Menu: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"var",
"cmenu",
"=",
"new",
"ContextMenu",
"(",
"id",
")",
";",
"contextMenuMap",
"[",
"id",
"]",
"=",
"cmenu",
";",
"return",
"cmenu",
";",
"}"
] |
Registers new context menu with Brackets.
Extensions should generally use the predefined context menus built into Brackets. Use this
API to add a new context menu to UI that is specific to an extension.
After registering a new context menu clients should:
- use addMenuItem() to add items to the context menu
- call open() to show the context menu.
For example:
$("#my_ID").contextmenu(function (e) {
if (e.which === 3) {
my_cmenu.open(e);
}
});
To make menu items be contextual to things like selection, listen for the "beforeContextMenuOpen"
to make changes to Command objects before the context menu is shown. MenuItems are views of
Commands, which control a MenuItem's name, enabled state, and checked state.
@param {string} id - unique identifier for context menu.
Core context menus in Brackets use a simple title as an id.
Extensions should use the following format: "author.myextension.mycontextmenu name"
@return {?ContextMenu} the newly created context menu
|
[
"Registers",
"new",
"context",
"menu",
"with",
"Brackets",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1371-L1386
|
train
|
adobe/brackets
|
src/LiveDevelopment/LiveDevServerManager.js
|
getServer
|
function getServer(localPath) {
var provider, server, i;
for (i = 0; i < _serverProviders.length; i++) {
provider = _serverProviders[i];
server = provider.create();
if (server.canServe(localPath)) {
return server;
}
}
return null;
}
|
javascript
|
function getServer(localPath) {
var provider, server, i;
for (i = 0; i < _serverProviders.length; i++) {
provider = _serverProviders[i];
server = provider.create();
if (server.canServe(localPath)) {
return server;
}
}
return null;
}
|
[
"function",
"getServer",
"(",
"localPath",
")",
"{",
"var",
"provider",
",",
"server",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"_serverProviders",
".",
"length",
";",
"i",
"++",
")",
"{",
"provider",
"=",
"_serverProviders",
"[",
"i",
"]",
";",
"server",
"=",
"provider",
".",
"create",
"(",
")",
";",
"if",
"(",
"server",
".",
"canServe",
"(",
"localPath",
")",
")",
"{",
"return",
"server",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Determines which provider can serve a file with a local path.
@param {string} localPath A local path to file being served.
@return {?BaseServer} A server no null if no servers can serve the file
|
[
"Determines",
"which",
"provider",
"can",
"serve",
"a",
"file",
"with",
"a",
"local",
"path",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L63-L76
|
train
|
adobe/brackets
|
src/LiveDevelopment/LiveDevServerManager.js
|
registerServer
|
function registerServer(provider, priority) {
if (!provider.create) {
console.error("Incompatible live development server provider");
return;
}
var providerObj = {};
providerObj.create = provider.create;
providerObj.priority = priority || 0;
_serverProviders.push(providerObj);
_serverProviders.sort(_providerSort);
return providerObj;
}
|
javascript
|
function registerServer(provider, priority) {
if (!provider.create) {
console.error("Incompatible live development server provider");
return;
}
var providerObj = {};
providerObj.create = provider.create;
providerObj.priority = priority || 0;
_serverProviders.push(providerObj);
_serverProviders.sort(_providerSort);
return providerObj;
}
|
[
"function",
"registerServer",
"(",
"provider",
",",
"priority",
")",
"{",
"if",
"(",
"!",
"provider",
".",
"create",
")",
"{",
"console",
".",
"error",
"(",
"\"Incompatible live development server provider\"",
")",
";",
"return",
";",
"}",
"var",
"providerObj",
"=",
"{",
"}",
";",
"providerObj",
".",
"create",
"=",
"provider",
".",
"create",
";",
"providerObj",
".",
"priority",
"=",
"priority",
"||",
"0",
";",
"_serverProviders",
".",
"push",
"(",
"providerObj",
")",
";",
"_serverProviders",
".",
"sort",
"(",
"_providerSort",
")",
";",
"return",
"providerObj",
";",
"}"
] |
The method by which a server registers itself. It returns an
object handler that can be used to remove that server from the list.
@param {BaseServer|{create: function():BaseServer}} provider
The provider to be registered, described below.
@param {number} priority
A non-negative number used to break ties among providers for a
particular url. Providers that register with a higher priority will
have the opportunity to provide a given url before those with a
lower priority. The higher the number, the higher the priority.
@return {{object}}
|
[
"The",
"method",
"by",
"which",
"a",
"server",
"registers",
"itself",
".",
"It",
"returns",
"an",
"object",
"handler",
"that",
"can",
"be",
"used",
"to",
"remove",
"that",
"server",
"from",
"the",
"list",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L91-L106
|
train
|
adobe/brackets
|
src/LiveDevelopment/LiveDevServerManager.js
|
removeServer
|
function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
}
|
javascript
|
function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
}
|
[
"function",
"removeServer",
"(",
"provider",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"_serverProviders",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"provider",
"===",
"_serverProviders",
"[",
"i",
"]",
")",
"{",
"_serverProviders",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"}",
"}"
] |
Remove a server from the list of the registered providers.
@param {{object}} provider The provider to be removed.
|
[
"Remove",
"a",
"server",
"from",
"the",
"list",
"of",
"the",
"registered",
"providers",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L113-L120
|
train
|
adobe/brackets
|
src/JSUtils/Preferences.js
|
settingsToRegExp
|
function settingsToRegExp(settings, baseRegExp, defaultRegExp) {
var regExpString = "";
if (settings instanceof Array && settings.length > 0) {
// Append base settings to user settings. The base
// settings are builtin and cannot be overridden.
if (baseRegExp) {
settings.push("/" + baseRegExp.source + "/");
}
// convert each string, with optional wildcards to an equivalent
// string in a regular expression.
settings.forEach(function (value, index) {
if (typeof value === "string") {
var isRegExp = value[0] === '/' && value[value.length - 1] === '/';
if (isRegExp) {
value = value.substring(1, value.length - 1);
} else {
value = StringUtils.regexEscape(value);
// convert user input wildcard, "*" or "?", to a regular
// expression. We can just replace the escaped "*" or "?"
// since we know it is a wildcard.
value = value.replace("\\?", ".?");
value = value.replace("\\*", ".*");
// Add "^" and "$" to prevent matching in the middle of strings.
value = "^" + value + "$";
}
if (index > 0) {
regExpString += "|";
}
regExpString = regExpString.concat(value);
}
});
}
if (!regExpString) {
var defaultParts = [];
if (baseRegExp) {
defaultParts.push(baseRegExp.source);
}
if (defaultRegExp) {
defaultParts.push(defaultRegExp.source);
}
if (defaultParts.length > 0) {
regExpString = defaultParts.join("|");
} else {
return null;
}
}
return new RegExp(regExpString);
}
|
javascript
|
function settingsToRegExp(settings, baseRegExp, defaultRegExp) {
var regExpString = "";
if (settings instanceof Array && settings.length > 0) {
// Append base settings to user settings. The base
// settings are builtin and cannot be overridden.
if (baseRegExp) {
settings.push("/" + baseRegExp.source + "/");
}
// convert each string, with optional wildcards to an equivalent
// string in a regular expression.
settings.forEach(function (value, index) {
if (typeof value === "string") {
var isRegExp = value[0] === '/' && value[value.length - 1] === '/';
if (isRegExp) {
value = value.substring(1, value.length - 1);
} else {
value = StringUtils.regexEscape(value);
// convert user input wildcard, "*" or "?", to a regular
// expression. We can just replace the escaped "*" or "?"
// since we know it is a wildcard.
value = value.replace("\\?", ".?");
value = value.replace("\\*", ".*");
// Add "^" and "$" to prevent matching in the middle of strings.
value = "^" + value + "$";
}
if (index > 0) {
regExpString += "|";
}
regExpString = regExpString.concat(value);
}
});
}
if (!regExpString) {
var defaultParts = [];
if (baseRegExp) {
defaultParts.push(baseRegExp.source);
}
if (defaultRegExp) {
defaultParts.push(defaultRegExp.source);
}
if (defaultParts.length > 0) {
regExpString = defaultParts.join("|");
} else {
return null;
}
}
return new RegExp(regExpString);
}
|
[
"function",
"settingsToRegExp",
"(",
"settings",
",",
"baseRegExp",
",",
"defaultRegExp",
")",
"{",
"var",
"regExpString",
"=",
"\"\"",
";",
"if",
"(",
"settings",
"instanceof",
"Array",
"&&",
"settings",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"baseRegExp",
")",
"{",
"settings",
".",
"push",
"(",
"\"/\"",
"+",
"baseRegExp",
".",
"source",
"+",
"\"/\"",
")",
";",
"}",
"settings",
".",
"forEach",
"(",
"function",
"(",
"value",
",",
"index",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"string\"",
")",
"{",
"var",
"isRegExp",
"=",
"value",
"[",
"0",
"]",
"===",
"'/'",
"&&",
"value",
"[",
"value",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
";",
"if",
"(",
"isRegExp",
")",
"{",
"value",
"=",
"value",
".",
"substring",
"(",
"1",
",",
"value",
".",
"length",
"-",
"1",
")",
";",
"}",
"else",
"{",
"value",
"=",
"StringUtils",
".",
"regexEscape",
"(",
"value",
")",
";",
"value",
"=",
"value",
".",
"replace",
"(",
"\"\\\\?\"",
",",
"\\\\",
")",
";",
"\".?\"",
"value",
"=",
"value",
".",
"replace",
"(",
"\"\\\\*\"",
",",
"\\\\",
")",
";",
"}",
"\".*\"",
"value",
"=",
"\"^\"",
"+",
"value",
"+",
"\"$\"",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"index",
">",
"0",
")",
"{",
"regExpString",
"+=",
"\"|\"",
";",
"}",
"regExpString",
"=",
"regExpString",
".",
"concat",
"(",
"value",
")",
";",
"}"
] |
Convert an array of strings with optional wildcards, to an equivalent
regular expression.
@param {Array.<string|RegExp>} settings from the file (note: this may be mutated by this function)
@param {?RegExp} baseRegExp - base regular expression that is always used
@param {?RegExp} defaultRegExp - additional regular expression that is only used if the user has not configured settings
@return {RegExp} Regular expression that captures the array of string
with optional wildcards.
|
[
"Convert",
"an",
"array",
"of",
"strings",
"with",
"optional",
"wildcards",
"to",
"an",
"equivalent",
"regular",
"expression",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/Preferences.js#L80-L138
|
train
|
adobe/brackets
|
src/JSUtils/Preferences.js
|
Preferences
|
function Preferences(prefs) {
var BASE_EXCLUDED_DIRECTORIES = null, /* if the user has settings, we don't exclude anything by default */
// exclude node_modules for performance reasons and because we don't do full hinting for those anyhow.
DEFAULT_EXCLUDED_DIRECTORIES = /node_modules/,
// exclude require and jquery since we have special knowledge of those
BASE_EXCLUDED_FILES = /^require.*\.js$|^jquery.*\.js$/,
DEFAULT_MAX_FILE_COUNT = 100,
DEFAULT_MAX_FILE_SIZE = 512 * 1024;
if (prefs) {
this._excludedDirectories = settingsToRegExp(prefs["excluded-directories"],
BASE_EXCLUDED_DIRECTORIES,
DEFAULT_EXCLUDED_DIRECTORIES);
this._excludedFiles = settingsToRegExp(prefs["excluded-files"],
BASE_EXCLUDED_FILES);
this._maxFileCount = prefs["max-file-count"];
this._maxFileSize = prefs["max-file-size"];
// sanity check values
if (!this._maxFileCount || this._maxFileCount < 0) {
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
}
if (!this._maxFileSize || this._maxFileSize < 0) {
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} else {
this._excludedDirectories = DEFAULT_EXCLUDED_DIRECTORIES;
this._excludedFiles = BASE_EXCLUDED_FILES;
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
}
|
javascript
|
function Preferences(prefs) {
var BASE_EXCLUDED_DIRECTORIES = null, /* if the user has settings, we don't exclude anything by default */
// exclude node_modules for performance reasons and because we don't do full hinting for those anyhow.
DEFAULT_EXCLUDED_DIRECTORIES = /node_modules/,
// exclude require and jquery since we have special knowledge of those
BASE_EXCLUDED_FILES = /^require.*\.js$|^jquery.*\.js$/,
DEFAULT_MAX_FILE_COUNT = 100,
DEFAULT_MAX_FILE_SIZE = 512 * 1024;
if (prefs) {
this._excludedDirectories = settingsToRegExp(prefs["excluded-directories"],
BASE_EXCLUDED_DIRECTORIES,
DEFAULT_EXCLUDED_DIRECTORIES);
this._excludedFiles = settingsToRegExp(prefs["excluded-files"],
BASE_EXCLUDED_FILES);
this._maxFileCount = prefs["max-file-count"];
this._maxFileSize = prefs["max-file-size"];
// sanity check values
if (!this._maxFileCount || this._maxFileCount < 0) {
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
}
if (!this._maxFileSize || this._maxFileSize < 0) {
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} else {
this._excludedDirectories = DEFAULT_EXCLUDED_DIRECTORIES;
this._excludedFiles = BASE_EXCLUDED_FILES;
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
}
|
[
"function",
"Preferences",
"(",
"prefs",
")",
"{",
"var",
"BASE_EXCLUDED_DIRECTORIES",
"=",
"null",
",",
"DEFAULT_EXCLUDED_DIRECTORIES",
"=",
"/",
"node_modules",
"/",
",",
"BASE_EXCLUDED_FILES",
"=",
"/",
"^require.*\\.js$|^jquery.*\\.js$",
"/",
",",
"DEFAULT_MAX_FILE_COUNT",
"=",
"100",
",",
"DEFAULT_MAX_FILE_SIZE",
"=",
"512",
"*",
"1024",
";",
"if",
"(",
"prefs",
")",
"{",
"this",
".",
"_excludedDirectories",
"=",
"settingsToRegExp",
"(",
"prefs",
"[",
"\"excluded-directories\"",
"]",
",",
"BASE_EXCLUDED_DIRECTORIES",
",",
"DEFAULT_EXCLUDED_DIRECTORIES",
")",
";",
"this",
".",
"_excludedFiles",
"=",
"settingsToRegExp",
"(",
"prefs",
"[",
"\"excluded-files\"",
"]",
",",
"BASE_EXCLUDED_FILES",
")",
";",
"this",
".",
"_maxFileCount",
"=",
"prefs",
"[",
"\"max-file-count\"",
"]",
";",
"this",
".",
"_maxFileSize",
"=",
"prefs",
"[",
"\"max-file-size\"",
"]",
";",
"if",
"(",
"!",
"this",
".",
"_maxFileCount",
"||",
"this",
".",
"_maxFileCount",
"<",
"0",
")",
"{",
"this",
".",
"_maxFileCount",
"=",
"DEFAULT_MAX_FILE_COUNT",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_maxFileSize",
"||",
"this",
".",
"_maxFileSize",
"<",
"0",
")",
"{",
"this",
".",
"_maxFileSize",
"=",
"DEFAULT_MAX_FILE_SIZE",
";",
"}",
"}",
"else",
"{",
"this",
".",
"_excludedDirectories",
"=",
"DEFAULT_EXCLUDED_DIRECTORIES",
";",
"this",
".",
"_excludedFiles",
"=",
"BASE_EXCLUDED_FILES",
";",
"this",
".",
"_maxFileCount",
"=",
"DEFAULT_MAX_FILE_COUNT",
";",
"this",
".",
"_maxFileSize",
"=",
"DEFAULT_MAX_FILE_SIZE",
";",
"}",
"}"
] |
Constructor to create a default preference object.
@constructor
@param {Object=} prefs - preference object
|
[
"Constructor",
"to",
"create",
"a",
"default",
"preference",
"object",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/Preferences.js#L146-L179
|
train
|
adobe/brackets
|
src/widgets/InlineMenu.js
|
InlineMenu
|
function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
}
|
javascript
|
function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
}
|
[
"function",
"InlineMenu",
"(",
"editor",
",",
"menuText",
")",
"{",
"this",
".",
"items",
"=",
"[",
"]",
";",
"this",
".",
"selectedIndex",
"=",
"-",
"1",
";",
"this",
".",
"opened",
"=",
"false",
";",
"this",
".",
"editor",
"=",
"editor",
";",
"this",
".",
"handleSelect",
"=",
"null",
";",
"this",
".",
"handleClose",
"=",
"null",
";",
"this",
".",
"$menu",
"=",
"$",
"(",
"\"<li class='dropdown inlinemenu-menu'></li>\"",
")",
".",
"append",
"(",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>\"",
")",
".",
"hide",
"(",
")",
")",
".",
"append",
"(",
"\"<ul class='dropdown-menu'>\"",
"+",
"\"<li class='inlinemenu-header'>\"",
"+",
"\"<a>\"",
"+",
"menuText",
"+",
"\"</a>\"",
"+",
"\"</li>\"",
"+",
"\"</ul>\"",
")",
";",
"this",
".",
"_keydownHook",
"=",
"this",
".",
"_keydownHook",
".",
"bind",
"(",
"this",
")",
";",
"}"
] |
Displays a popup list of items for a given editor context
@constructor
@param {Editor} editor
@param {string} menuText
|
[
"Displays",
"a",
"popup",
"list",
"of",
"items",
"for",
"a",
"given",
"editor",
"context"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/InlineMenu.js#L46-L108
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_findFileInMRUList
|
function _findFileInMRUList(paneId, file) {
return _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId === paneId);
});
}
|
javascript
|
function _findFileInMRUList(paneId, file) {
return _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId === paneId);
});
}
|
[
"function",
"_findFileInMRUList",
"(",
"paneId",
",",
"file",
")",
"{",
"return",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
")",
";",
"}"
] |
Locates the first MRU entry of a file for the requested pane
@param {!string} paneId - the paneId
@param {!File} File - the file
@return {{file:File, paneId:string}}
@private
|
[
"Locates",
"the",
"first",
"MRU",
"entry",
"of",
"a",
"file",
"for",
"the",
"requested",
"pane"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L260-L264
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
isExclusiveToPane
|
function isExclusiveToPane(file, paneId) {
paneId = paneId === ACTIVE_PANE && _activePaneId ? _activePaneId : paneId;
var index = _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId !== paneId);
});
return index === -1;
}
|
javascript
|
function isExclusiveToPane(file, paneId) {
paneId = paneId === ACTIVE_PANE && _activePaneId ? _activePaneId : paneId;
var index = _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId !== paneId);
});
return index === -1;
}
|
[
"function",
"isExclusiveToPane",
"(",
"file",
",",
"paneId",
")",
"{",
"paneId",
"=",
"paneId",
"===",
"ACTIVE_PANE",
"&&",
"_activePaneId",
"?",
"_activePaneId",
":",
"paneId",
";",
"var",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"!==",
"paneId",
")",
";",
"}",
")",
";",
"return",
"index",
"===",
"-",
"1",
";",
"}"
] |
Checks whether a file is listed exclusively in the provided pane
@param {!File} File - the file
@return {{file:File, paneId:string}}
|
[
"Checks",
"whether",
"a",
"file",
"is",
"listed",
"exclusively",
"in",
"the",
"provided",
"pane"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L271-L277
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_getPane
|
function _getPane(paneId) {
paneId = _resolvePaneId(paneId);
if (_panes[paneId]) {
return _panes[paneId];
}
return null;
}
|
javascript
|
function _getPane(paneId) {
paneId = _resolvePaneId(paneId);
if (_panes[paneId]) {
return _panes[paneId];
}
return null;
}
|
[
"function",
"_getPane",
"(",
"paneId",
")",
"{",
"paneId",
"=",
"_resolvePaneId",
"(",
"paneId",
")",
";",
"if",
"(",
"_panes",
"[",
"paneId",
"]",
")",
"{",
"return",
"_panes",
"[",
"paneId",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieves the Pane object for the given paneId
@param {!string} paneId - id of the pane to retrieve
@return {?Pane} the Pane object or null if a pane object doesn't exist for the pane
@private
|
[
"Retrieves",
"the",
"Pane",
"object",
"for",
"the",
"given",
"paneId"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L306-L314
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_makeFileMostRecent
|
function _makeFileMostRecent(paneId, file) {
var index,
entry,
pane = _getPane(paneId);
if (!_traversingFileList) {
pane.makeViewMostRecent(file);
index = _findFileInMRUList(pane.id, file);
entry = _makeMRUListEntry(file, pane.id);
if (index !== -1) {
_mruList.splice(index, 1);
}
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
// add it to the front of the list
_mruList.unshift(entry);
}
}
|
javascript
|
function _makeFileMostRecent(paneId, file) {
var index,
entry,
pane = _getPane(paneId);
if (!_traversingFileList) {
pane.makeViewMostRecent(file);
index = _findFileInMRUList(pane.id, file);
entry = _makeMRUListEntry(file, pane.id);
if (index !== -1) {
_mruList.splice(index, 1);
}
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
// add it to the front of the list
_mruList.unshift(entry);
}
}
|
[
"function",
"_makeFileMostRecent",
"(",
"paneId",
",",
"file",
")",
"{",
"var",
"index",
",",
"entry",
",",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"!",
"_traversingFileList",
")",
"{",
"pane",
".",
"makeViewMostRecent",
"(",
"file",
")",
";",
"index",
"=",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"entry",
"=",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"log",
"(",
"file",
".",
"fullPath",
"+",
"\" duplicated in mru list\"",
")",
";",
"}",
"_mruList",
".",
"unshift",
"(",
"entry",
")",
";",
"}",
"}"
] |
Makes the file the most recent for the pane and the global mru lists
@param {!string} paneId - id of the pane to mae th file most recent or ACTIVE_PANE
@param {!File} file - File object to make most recent
@private
|
[
"Makes",
"the",
"file",
"the",
"most",
"recent",
"for",
"the",
"pane",
"and",
"the",
"global",
"mru",
"lists"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L338-L361
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_makePaneMostRecent
|
function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
}
|
javascript
|
function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
}
|
[
"function",
"_makePaneMostRecent",
"(",
"paneId",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
")",
"{",
"_makeFileMostRecent",
"(",
"paneId",
",",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
")",
";",
"}",
"}"
] |
Makes the Pane's current file the most recent
@param {!string} paneId - id of the pane to make the file most recent, or ACTIVE_PANE
@param {!File} file - File object to make most recent
@private
|
[
"Makes",
"the",
"Pane",
"s",
"current",
"file",
"the",
"most",
"recent"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L369-L375
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_activeEditorChange
|
function _activeEditorChange(e, current) {
if (current) {
var $container = current.$el.parent().parent(),
pane = _getPaneFromElement($container);
if (pane) {
// Editor is a full editor
if (pane.id !== _activePaneId) {
// we just need to set the active pane in this case
// it will dispatch the currentFileChange message as well
// as dispatching other events when the active pane changes
setActivePaneId(pane.id);
}
} else {
// Editor is an inline editor, find the parent pane
var parents = $container.parents(".view-pane");
if (parents.length === 1) {
$container = $(parents[0]);
pane = _getPaneFromElement($container);
if (pane) {
if (pane.id !== _activePaneId) {
// activate the pane which will put focus in the pane's doc
setActivePaneId(pane.id);
// reset the focus to the inline editor
current.focus();
}
}
}
}
}
}
|
javascript
|
function _activeEditorChange(e, current) {
if (current) {
var $container = current.$el.parent().parent(),
pane = _getPaneFromElement($container);
if (pane) {
// Editor is a full editor
if (pane.id !== _activePaneId) {
// we just need to set the active pane in this case
// it will dispatch the currentFileChange message as well
// as dispatching other events when the active pane changes
setActivePaneId(pane.id);
}
} else {
// Editor is an inline editor, find the parent pane
var parents = $container.parents(".view-pane");
if (parents.length === 1) {
$container = $(parents[0]);
pane = _getPaneFromElement($container);
if (pane) {
if (pane.id !== _activePaneId) {
// activate the pane which will put focus in the pane's doc
setActivePaneId(pane.id);
// reset the focus to the inline editor
current.focus();
}
}
}
}
}
}
|
[
"function",
"_activeEditorChange",
"(",
"e",
",",
"current",
")",
"{",
"if",
"(",
"current",
")",
"{",
"var",
"$container",
"=",
"current",
".",
"$el",
".",
"parent",
"(",
")",
".",
"parent",
"(",
")",
",",
"pane",
"=",
"_getPaneFromElement",
"(",
"$container",
")",
";",
"if",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"!==",
"_activePaneId",
")",
"{",
"setActivePaneId",
"(",
"pane",
".",
"id",
")",
";",
"}",
"}",
"else",
"{",
"var",
"parents",
"=",
"$container",
".",
"parents",
"(",
"\".view-pane\"",
")",
";",
"if",
"(",
"parents",
".",
"length",
"===",
"1",
")",
"{",
"$container",
"=",
"$",
"(",
"parents",
"[",
"0",
"]",
")",
";",
"pane",
"=",
"_getPaneFromElement",
"(",
"$container",
")",
";",
"if",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"!==",
"_activePaneId",
")",
"{",
"setActivePaneId",
"(",
"pane",
".",
"id",
")",
";",
"current",
".",
"focus",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
EditorManager.activeEditorChange handler
This event is triggered when an visible editor gains focus
Therefore we need to Activate the pane that the active editor belongs to
@private
@param {!jQuery.Event} e - jQuery Event object
@param {Editor=} current - editor being made the current editor
|
[
"EditorManager",
".",
"activeEditorChange",
"handler",
"This",
"event",
"is",
"triggered",
"when",
"an",
"visible",
"editor",
"gains",
"focus",
"Therefore",
"we",
"need",
"to",
"Activate",
"the",
"pane",
"that",
"the",
"active",
"editor",
"belongs",
"to"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L446-L476
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_forEachPaneOrPanes
|
function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
}
|
javascript
|
function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
}
|
[
"function",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"callback",
")",
"{",
"if",
"(",
"paneId",
"===",
"ALL_PANES",
")",
"{",
"_",
".",
"forEach",
"(",
"_panes",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"_getPane",
"(",
"paneId",
")",
")",
";",
"}",
"}"
] |
Iterates over the pane or ALL_PANES and calls the callback function for each.
@param {!string} paneId - id of the pane in which to adjust the scroll state, ALL_PANES or ACTIVE_PANE
@param {!function(!pane:Pane):boolean} callback - function to callback on to perform work.
The callback will receive a Pane and should return false to stop iterating.
@private
|
[
"Iterates",
"over",
"the",
"pane",
"or",
"ALL_PANES",
"and",
"calls",
"the",
"callback",
"function",
"for",
"each",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L486-L492
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
cacheScrollState
|
function cacheScrollState(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
_paneScrollStates[pane.id] = pane.getScrollState();
});
}
|
javascript
|
function cacheScrollState(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
_paneScrollStates[pane.id] = pane.getScrollState();
});
}
|
[
"function",
"cacheScrollState",
"(",
"paneId",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
"=",
"pane",
".",
"getScrollState",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Caches the specified pane's current scroll state
If there was already cached state for the specified pane, it is discarded and overwritten
@param {!string} paneId - id of the pane in which to cache the scroll state,
ALL_PANES or ACTIVE_PANE
|
[
"Caches",
"the",
"specified",
"pane",
"s",
"current",
"scroll",
"state",
"If",
"there",
"was",
"already",
"cached",
"state",
"for",
"the",
"specified",
"pane",
"it",
"is",
"discarded",
"and",
"overwritten"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L500-L504
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
restoreAdjustedScrollState
|
function restoreAdjustedScrollState(paneId, heightDelta) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.restoreAndAdjustScrollState(_paneScrollStates[pane.id], heightDelta);
delete _paneScrollStates[pane.id];
});
}
|
javascript
|
function restoreAdjustedScrollState(paneId, heightDelta) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.restoreAndAdjustScrollState(_paneScrollStates[pane.id], heightDelta);
delete _paneScrollStates[pane.id];
});
}
|
[
"function",
"restoreAdjustedScrollState",
"(",
"paneId",
",",
"heightDelta",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"pane",
".",
"restoreAndAdjustScrollState",
"(",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
",",
"heightDelta",
")",
";",
"delete",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
";",
"}",
")",
";",
"}"
] |
Restores the scroll state from cache and applies the heightDelta
The view implementation is responsible for applying or ignoring the heightDelta.
This is used primarily when a modal bar opens to keep the editor from scrolling the current
page out of view in order to maintain the appearance.
The state is removed from the cache after calling this function.
@param {!string} paneId - id of the pane in which to adjust the scroll state,
ALL_PANES or ACTIVE_PANE
@param {!number} heightDelta - delta H to apply to the scroll state
|
[
"Restores",
"the",
"scroll",
"state",
"from",
"cache",
"and",
"applies",
"the",
"heightDelta",
"The",
"view",
"implementation",
"is",
"responsible",
"for",
"applying",
"or",
"ignoring",
"the",
"heightDelta",
".",
"This",
"is",
"used",
"primarily",
"when",
"a",
"modal",
"bar",
"opens",
"to",
"keep",
"the",
"editor",
"from",
"scrolling",
"the",
"current",
"page",
"out",
"of",
"view",
"in",
"order",
"to",
"maintain",
"the",
"appearance",
".",
"The",
"state",
"is",
"removed",
"from",
"the",
"cache",
"after",
"calling",
"this",
"function",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L517-L522
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
getWorkingSet
|
function getWorkingSet(paneId) {
var result = [];
_forEachPaneOrPanes(paneId, function (pane) {
var viewList = pane.getViewList();
result = _.union(result, viewList);
});
return result;
}
|
javascript
|
function getWorkingSet(paneId) {
var result = [];
_forEachPaneOrPanes(paneId, function (pane) {
var viewList = pane.getViewList();
result = _.union(result, viewList);
});
return result;
}
|
[
"function",
"getWorkingSet",
"(",
"paneId",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"viewList",
"=",
"pane",
".",
"getViewList",
"(",
")",
";",
"result",
"=",
"_",
".",
"union",
"(",
"result",
",",
"viewList",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Retrieves the WorkingSet for the given paneId not including temporary views
@param {!string} paneId - id of the pane in which to get the view list, ALL_PANES or ACTIVE_PANE
@return {Array.<File>}
|
[
"Retrieves",
"the",
"WorkingSet",
"for",
"the",
"given",
"paneId",
"not",
"including",
"temporary",
"views"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L530-L539
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
getAllOpenFiles
|
function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
}
|
javascript
|
function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
}
|
[
"function",
"getAllOpenFiles",
"(",
")",
"{",
"var",
"result",
"=",
"getWorkingSet",
"(",
"ALL_PANES",
")",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"file",
"=",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
";",
"if",
"(",
"file",
")",
"{",
"result",
"=",
"_",
".",
"union",
"(",
"result",
",",
"[",
"file",
"]",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Retrieves the list of all open files including temporary views
@return {array.<File>} the list of all open files in all open panes
|
[
"Retrieves",
"the",
"list",
"of",
"all",
"open",
"files",
"including",
"temporary",
"views"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L546-L555
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
getWorkingSetSize
|
function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
}
|
javascript
|
function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
}
|
[
"function",
"getWorkingSetSize",
"(",
"paneId",
")",
"{",
"var",
"result",
"=",
"0",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"result",
"+=",
"pane",
".",
"getViewListSize",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Retrieves the size of the selected pane's view list
@param {!string} paneId - id of the pane in which to get the workingset size.
Can use `ALL_PANES` or `ACTIVE_PANE`
@return {!number} the number of items in the specified pane
|
[
"Retrieves",
"the",
"size",
"of",
"the",
"selected",
"pane",
"s",
"view",
"list"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L571-L577
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
findInAllWorkingSets
|
function findInAllWorkingSets(fullPath) {
var index,
result = [];
_.forEach(_panes, function (pane) {
index = pane.findInViewList(fullPath);
if (index >= 0) {
result.push({paneId: pane.id, index: index});
}
});
return result;
}
|
javascript
|
function findInAllWorkingSets(fullPath) {
var index,
result = [];
_.forEach(_panes, function (pane) {
index = pane.findInViewList(fullPath);
if (index >= 0) {
result.push({paneId: pane.id, index: index});
}
});
return result;
}
|
[
"function",
"findInAllWorkingSets",
"(",
"fullPath",
")",
"{",
"var",
"index",
",",
"result",
"=",
"[",
"]",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"index",
"=",
"pane",
".",
"findInViewList",
"(",
"fullPath",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"result",
".",
"push",
"(",
"{",
"paneId",
":",
"pane",
".",
"id",
",",
"index",
":",
"index",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Finds all instances of the specified file in all working sets.
If there is a temporary view of the file, it is not part of the result set
@param {!string} fullPath - path of the file to find views of
@return {Array.<{pane:string, index:number}>} an array of paneId/index records
|
[
"Finds",
"all",
"instances",
"of",
"the",
"specified",
"file",
"in",
"all",
"working",
"sets",
".",
"If",
"there",
"is",
"a",
"temporary",
"view",
"of",
"the",
"file",
"it",
"is",
"not",
"part",
"of",
"the",
"result",
"set"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L623-L635
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
addToWorkingSet
|
function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
}
|
javascript
|
function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
}
|
[
"function",
"addToWorkingSet",
"(",
"paneId",
",",
"file",
",",
"index",
",",
"force",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"!",
"pane",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"invalid pane id: \"",
"+",
"paneId",
")",
";",
"}",
"var",
"result",
"=",
"pane",
".",
"reorderItem",
"(",
"file",
",",
"index",
",",
"force",
")",
",",
"entry",
"=",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
";",
"if",
"(",
"result",
"===",
"pane",
".",
"ITEM_FOUND_NEEDS_SORT",
")",
"{",
"console",
".",
"warn",
"(",
"\"pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen \"",
"+",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"}",
"else",
"if",
"(",
"result",
"===",
"pane",
".",
"ITEM_NOT_FOUND",
")",
"{",
"index",
"=",
"pane",
".",
"addToViewList",
"(",
"file",
",",
"index",
")",
";",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"===",
"-",
"1",
")",
"{",
"if",
"(",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
"===",
"file",
")",
"{",
"_mruList",
".",
"unshift",
"(",
"entry",
")",
";",
"}",
"else",
"{",
"_mruList",
".",
"push",
"(",
"entry",
")",
";",
"}",
"}",
"exports",
".",
"trigger",
"(",
"\"workingSetAdd\"",
",",
"file",
",",
"index",
",",
"pane",
".",
"id",
")",
";",
"}",
"}"
] |
Adds the given file to the end of the workingset, if it is not already there.
This API does not create a view of the file, it just adds it to the working set
Views of files in the working set are persisted and are not destroyed until the user
closes the file using FILE_CLOSE; Views are created using FILE_OPEN and, when opened, are
made the current view. If a File is already opened then the file is just made current
and its view is shown.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!File} file - The File object to add to the workingset
@param {number=} index - Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw - If true, a workingset change notification is always sent
(useful if suppressRedraw was used with removeView() earlier)
|
[
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"workingset",
"if",
"it",
"is",
"not",
"already",
"there",
".",
"This",
"API",
"does",
"not",
"create",
"a",
"view",
"of",
"the",
"file",
"it",
"just",
"adds",
"it",
"to",
"the",
"working",
"set",
"Views",
"of",
"files",
"in",
"the",
"working",
"set",
"are",
"persisted",
"and",
"are",
"not",
"destroyed",
"until",
"the",
"user",
"closes",
"the",
"file",
"using",
"FILE_CLOSE",
";",
"Views",
"are",
"created",
"using",
"FILE_OPEN",
"and",
"when",
"opened",
"are",
"made",
"the",
"current",
"view",
".",
"If",
"a",
"File",
"is",
"already",
"opened",
"then",
"the",
"file",
"is",
"just",
"made",
"current",
"and",
"its",
"view",
"is",
"shown",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L709-L739
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
addListToWorkingSet
|
function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
}
|
javascript
|
function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
}
|
[
"function",
"addListToWorkingSet",
"(",
"paneId",
",",
"fileList",
")",
"{",
"var",
"uniqueFileList",
",",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"uniqueFileList",
"=",
"pane",
".",
"addListToViewList",
"(",
"fileList",
")",
";",
"uniqueFileList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"log",
"(",
"file",
".",
"fullPath",
"+",
"\" duplicated in mru list\"",
")",
";",
"}",
"_mruList",
".",
"push",
"(",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetAddList\"",
",",
"uniqueFileList",
",",
"pane",
".",
"id",
")",
";",
"var",
"unsolvedList",
"=",
"fileList",
".",
"filter",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"(",
"pane",
".",
"findInViewList",
"(",
"item",
".",
"fullPath",
")",
"===",
"-",
"1",
"&&",
"_getPaneIdForPath",
"(",
"item",
".",
"fullPath",
")",
")",
";",
"}",
")",
";",
"if",
"(",
"unsolvedList",
".",
"length",
")",
"{",
"addListToWorkingSet",
"(",
"_getPaneIdForPath",
"(",
"unsolvedList",
"[",
"0",
"]",
".",
"fullPath",
")",
",",
"unsolvedList",
")",
";",
"}",
"}"
] |
Adds the given file list to the end of the workingset.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!Array.<File>} fileList - Array of files to add to the pane
|
[
"Adds",
"the",
"given",
"file",
"list",
"to",
"the",
"end",
"of",
"the",
"workingset",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L746-L772
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_removeFileFromMRU
|
function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
}
|
javascript
|
function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
}
|
[
"function",
"_removeFileFromMRU",
"(",
"paneId",
",",
"file",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
";",
"do",
"{",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"compare",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
";",
"}"
] |
Removes a file from the global MRU list. Future versions of this
implementation may support the ALL_PANES constant but FOCUS_PANE is not allowed
@param {!string} paneId - Must be a valid paneId (not a shortcut e.g. ALL_PANES)
@ @param {File} file The file object to remove.
@private
|
[
"Removes",
"a",
"file",
"from",
"the",
"global",
"MRU",
"list",
".",
"Future",
"versions",
"of",
"this",
"implementation",
"may",
"support",
"the",
"ALL_PANES",
"constant",
"but",
"FOCUS_PANE",
"is",
"not",
"allowed"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L781-L794
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_removeView
|
function _removeView(paneId, file, suppressRedraw) {
var pane = _getPane(paneId);
if (pane.removeView(file)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, suppressRedraw, pane.id);
}
}
|
javascript
|
function _removeView(paneId, file, suppressRedraw) {
var pane = _getPane(paneId);
if (pane.removeView(file)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, suppressRedraw, pane.id);
}
}
|
[
"function",
"_removeView",
"(",
"paneId",
",",
"file",
",",
"suppressRedraw",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"pane",
".",
"removeView",
"(",
"file",
")",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemove\"",
",",
"file",
",",
"suppressRedraw",
",",
"pane",
".",
"id",
")",
";",
"}",
"}"
] |
Removes a file the specified pane
@param {!string} paneId - Must be a valid paneId (not a shortcut e.g. ALL_PANES)
@param {!File} file - the File to remove
@param {boolean=} suppressRedraw - true to tell listeners not to redraw
Use the suppressRedraw flag when calling this function along with many changes to prevent flicker
@private
|
[
"Removes",
"a",
"file",
"the",
"specified",
"pane"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L804-L811
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_moveView
|
function _moveView(sourcePaneId, destinationPaneId, file, destinationIndex) {
var result = new $.Deferred(),
sourcePane = _getPane(sourcePaneId),
destinationPane = _getPane(destinationPaneId);
sourcePane.moveView(file, destinationPane, destinationIndex)
.done(function () {
// remove existing entry from mrulist for the same document if present
_removeFileFromMRU(destinationPane.id, file);
// update the mru list
_mruList.every(function (record) {
if (record.file === file && record.paneId === sourcePane.id) {
record.paneId = destinationPane.id;
return false;
}
return true;
});
exports.trigger("workingSetMove", file, sourcePane.id, destinationPane.id);
result.resolve();
});
return result.promise();
}
|
javascript
|
function _moveView(sourcePaneId, destinationPaneId, file, destinationIndex) {
var result = new $.Deferred(),
sourcePane = _getPane(sourcePaneId),
destinationPane = _getPane(destinationPaneId);
sourcePane.moveView(file, destinationPane, destinationIndex)
.done(function () {
// remove existing entry from mrulist for the same document if present
_removeFileFromMRU(destinationPane.id, file);
// update the mru list
_mruList.every(function (record) {
if (record.file === file && record.paneId === sourcePane.id) {
record.paneId = destinationPane.id;
return false;
}
return true;
});
exports.trigger("workingSetMove", file, sourcePane.id, destinationPane.id);
result.resolve();
});
return result.promise();
}
|
[
"function",
"_moveView",
"(",
"sourcePaneId",
",",
"destinationPaneId",
",",
"file",
",",
"destinationIndex",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"sourcePane",
"=",
"_getPane",
"(",
"sourcePaneId",
")",
",",
"destinationPane",
"=",
"_getPane",
"(",
"destinationPaneId",
")",
";",
"sourcePane",
".",
"moveView",
"(",
"file",
",",
"destinationPane",
",",
"destinationIndex",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"_removeFileFromMRU",
"(",
"destinationPane",
".",
"id",
",",
"file",
")",
";",
"_mruList",
".",
"every",
"(",
"function",
"(",
"record",
")",
"{",
"if",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"sourcePane",
".",
"id",
")",
"{",
"record",
".",
"paneId",
"=",
"destinationPane",
".",
"id",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetMove\"",
",",
"file",
",",
"sourcePane",
".",
"id",
",",
"destinationPane",
".",
"id",
")",
";",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] |
moves a view from one pane to another
@param {!string} sourcePaneId - id of the source pane
@param {!string} destinationPaneId - id of the destination pane
@param {!File} file - the File to move
@param {Number} destinationIndex - the working set index of the file in the destination pane
@return {jQuery.Promise} a promise that resolves when the move has completed.
@private
|
[
"moves",
"a",
"view",
"from",
"one",
"pane",
"to",
"another"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L822-L844
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_removeDeletedFileFromMRU
|
function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
}
|
javascript
|
function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
}
|
[
"function",
"_removeDeletedFileFromMRU",
"(",
"e",
",",
"fullPath",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"fullPath",
")",
";",
"}",
";",
"do",
"{",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"compare",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
";",
"}"
] |
DocumentManager.pathDeleted Event handler to remove a file
from the MRU list
@param {!jQuery.event} e -
@param {!string} fullPath - path of the file to remove
@private
|
[
"DocumentManager",
".",
"pathDeleted",
"Event",
"handler",
"to",
"remove",
"a",
"file",
"from",
"the",
"MRU",
"list"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L866-L879
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_sortWorkingSet
|
function _sortWorkingSet(paneId, compareFn) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.sortViewList(compareFn);
exports.trigger("workingSetSort", pane.id);
});
}
|
javascript
|
function _sortWorkingSet(paneId, compareFn) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.sortViewList(compareFn);
exports.trigger("workingSetSort", pane.id);
});
}
|
[
"function",
"_sortWorkingSet",
"(",
"paneId",
",",
"compareFn",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"pane",
".",
"sortViewList",
"(",
"compareFn",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] |
sorts the pane's view list
@param {!string} paneId - id of the pane to sort, ALL_PANES or ACTIVE_PANE
@param {sortFunctionCallback} compareFn - callback to determine sort order (called on each item)
@see {@link Pane#sortViewList} for more information
@see {@link https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort|Sort Array - MDN}
@private
|
[
"sorts",
"the",
"pane",
"s",
"view",
"list"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L889-L894
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_moveWorkingSetItem
|
function _moveWorkingSetItem(paneId, fromIndex, toIndex) {
var pane = _getPane(paneId);
pane.moveWorkingSetItem(fromIndex, toIndex);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
}
|
javascript
|
function _moveWorkingSetItem(paneId, fromIndex, toIndex) {
var pane = _getPane(paneId);
pane.moveWorkingSetItem(fromIndex, toIndex);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
}
|
[
"function",
"_moveWorkingSetItem",
"(",
"paneId",
",",
"fromIndex",
",",
"toIndex",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"pane",
".",
"moveWorkingSetItem",
"(",
"fromIndex",
",",
"toIndex",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"_workingSetDisableAutoSort\"",
",",
"pane",
".",
"id",
")",
";",
"}"
] |
moves a working set item from one index to another shifting the items
after in the working set up and reinserting it at the desired location
@param {!string} paneId - id of the pane to sort
@param {!number} fromIndex - the index of the item to move
@param {!number} toIndex - the index to move to
@private
|
[
"moves",
"a",
"working",
"set",
"item",
"from",
"one",
"index",
"to",
"another",
"shifting",
"the",
"items",
"after",
"in",
"the",
"working",
"set",
"up",
"and",
"reinserting",
"it",
"at",
"the",
"desired",
"location"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L904-L910
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_swapWorkingSetListIndexes
|
function _swapWorkingSetListIndexes(paneId, index1, index2) {
var pane = _getPane(paneId);
pane.swapViewListIndexes(index1, index2);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
}
|
javascript
|
function _swapWorkingSetListIndexes(paneId, index1, index2) {
var pane = _getPane(paneId);
pane.swapViewListIndexes(index1, index2);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
}
|
[
"function",
"_swapWorkingSetListIndexes",
"(",
"paneId",
",",
"index1",
",",
"index2",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"pane",
".",
"swapViewListIndexes",
"(",
"index1",
",",
"index2",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"_workingSetDisableAutoSort\"",
",",
"pane",
".",
"id",
")",
";",
"}"
] |
Mutually exchanges the files at the indexes passed by parameters.
@param {!string} paneId - id of the pane to swap indices or ACTIVE_PANE
@param {!number} index1 - the index on the left
@param {!number} index2 - the index on the rigth
@private
|
[
"Mutually",
"exchanges",
"the",
"files",
"at",
"the",
"indexes",
"passed",
"by",
"parameters",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L919-L925
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
traverseToNextViewByMRU
|
function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
}
|
javascript
|
function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
}
|
[
"function",
"traverseToNextViewByMRU",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"paneId",
"=",
"getActivePaneId",
"(",
")",
",",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
")",
";",
"return",
"ViewUtils",
".",
"traverseViewArray",
"(",
"_mruList",
",",
"index",
",",
"direction",
")",
";",
"}"
] |
Get the next or previous file in the MRU list.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse.
|
[
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"the",
"MRU",
"list",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L933-L941
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
traverseToNextViewInListOrder
|
function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
}
|
javascript
|
function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
}
|
[
"function",
"traverseToNextViewInListOrder",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"curPaneId",
"=",
"getActivePaneId",
"(",
")",
",",
"allFiles",
"=",
"[",
"]",
",",
"index",
";",
"getPaneIdList",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"paneId",
")",
"{",
"var",
"paneFiles",
"=",
"getWorkingSet",
"(",
"paneId",
")",
".",
"map",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"{",
"file",
":",
"file",
",",
"pane",
":",
"paneId",
"}",
";",
"}",
")",
";",
"allFiles",
"=",
"allFiles",
".",
"concat",
"(",
"paneFiles",
")",
";",
"}",
")",
";",
"index",
"=",
"_",
".",
"findIndex",
"(",
"allFiles",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"pane",
"===",
"curPaneId",
")",
";",
"}",
")",
";",
"return",
"ViewUtils",
".",
"traverseViewArray",
"(",
"allFiles",
",",
"index",
",",
"direction",
")",
";",
"}"
] |
Get the next or previous file in list order.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse.
|
[
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"list",
"order",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L949-L967
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_synchronizePaneSize
|
function _synchronizePaneSize(pane, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
// Update the pane's sizer element if it has one and update the max size
Resizer.resyncSizer(pane.$el);
pane.$el.data("maxsize", available - MIN_PANE_SIZE);
pane.updateLayout(forceRefresh);
}
|
javascript
|
function _synchronizePaneSize(pane, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
// Update the pane's sizer element if it has one and update the max size
Resizer.resyncSizer(pane.$el);
pane.$el.data("maxsize", available - MIN_PANE_SIZE);
pane.updateLayout(forceRefresh);
}
|
[
"function",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
"{",
"var",
"available",
";",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"}",
"Resizer",
".",
"resyncSizer",
"(",
"pane",
".",
"$el",
")",
";",
"pane",
".",
"$el",
".",
"data",
"(",
"\"maxsize\"",
",",
"available",
"-",
"MIN_PANE_SIZE",
")",
";",
"pane",
".",
"updateLayout",
"(",
"forceRefresh",
")",
";",
"}"
] |
Synchronizes the pane's sizer element, updates the pane's resizer maxsize value
and tells the pane to update its layout
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private
|
[
"Synchronizes",
"the",
"pane",
"s",
"sizer",
"element",
"updates",
"the",
"pane",
"s",
"resizer",
"maxsize",
"value",
"and",
"tells",
"the",
"pane",
"to",
"update",
"its",
"layout"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L997-L1010
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_updateLayout
|
function _updateLayout(event, viewAreaHeight, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
_.forEach(_panes, function (pane) {
// For VERTICAL orientation, we set the second pane to be width: auto
// so that it resizes to fill the available space in the containing div
// unfortunately, that doesn't work in the HORIZONTAL orientation so we
// must update the height and convert it into a percentage
if (pane.id === SECOND_PANE && _orientation === HORIZONTAL) {
var percentage = ((_panes[FIRST_PANE].$el.height() + 1) / available);
pane.$el.css("height", 100 - (percentage * 100) + "%");
}
_synchronizePaneSize(pane, forceRefresh);
});
}
|
javascript
|
function _updateLayout(event, viewAreaHeight, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
_.forEach(_panes, function (pane) {
// For VERTICAL orientation, we set the second pane to be width: auto
// so that it resizes to fill the available space in the containing div
// unfortunately, that doesn't work in the HORIZONTAL orientation so we
// must update the height and convert it into a percentage
if (pane.id === SECOND_PANE && _orientation === HORIZONTAL) {
var percentage = ((_panes[FIRST_PANE].$el.height() + 1) / available);
pane.$el.css("height", 100 - (percentage * 100) + "%");
}
_synchronizePaneSize(pane, forceRefresh);
});
}
|
[
"function",
"_updateLayout",
"(",
"event",
",",
"viewAreaHeight",
",",
"forceRefresh",
")",
"{",
"var",
"available",
";",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"}",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"===",
"SECOND_PANE",
"&&",
"_orientation",
"===",
"HORIZONTAL",
")",
"{",
"var",
"percentage",
"=",
"(",
"(",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"height",
"(",
")",
"+",
"1",
")",
"/",
"available",
")",
";",
"pane",
".",
"$el",
".",
"css",
"(",
"\"height\"",
",",
"100",
"-",
"(",
"percentage",
"*",
"100",
")",
"+",
"\"%\"",
")",
";",
"}",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
";",
"}",
")",
";",
"}"
] |
Event handler for "workspaceUpdateLayout" to update the layout
@param {jQuery.Event} event - jQuery event object
@param {number} viewAreaHeight - unused
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private
|
[
"Event",
"handler",
"for",
"workspaceUpdateLayout",
"to",
"update",
"the",
"layout"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1020-L1041
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_initialLayout
|
function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
}
|
javascript
|
function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
}
|
[
"function",
"_initialLayout",
"(",
"forceRefresh",
")",
"{",
"var",
"panes",
"=",
"Object",
".",
"keys",
"(",
"_panes",
")",
",",
"size",
"=",
"100",
"/",
"panes",
".",
"length",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"===",
"FIRST_PANE",
")",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"\"100%\"",
",",
"width",
":",
"size",
"+",
"\"%\"",
",",
"float",
":",
"\"left\"",
"}",
")",
";",
"}",
"else",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"size",
"+",
"\"%\"",
",",
"width",
":",
"\"100%\"",
"}",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"\"100%\"",
",",
"width",
":",
"\"auto\"",
",",
"float",
":",
"\"none\"",
"}",
")",
";",
"}",
"else",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"width",
":",
"\"100%\"",
",",
"height",
":",
"\"50%\"",
"}",
")",
";",
"}",
"}",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
";",
"}",
")",
";",
"}"
] |
Sets up the initial layout so panes are evenly distributed
This also sets css properties that aid in the layout when _updateLayout is called
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private
|
[
"Sets",
"up",
"the",
"initial",
"layout",
"so",
"panes",
"are",
"evenly",
"distributed",
"This",
"also",
"sets",
"css",
"properties",
"that",
"aid",
"in",
"the",
"layout",
"when",
"_updateLayout",
"is",
"called"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1049-L1080
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_createPaneIfNecessary
|
function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
}
|
javascript
|
function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
}
|
[
"function",
"_createPaneIfNecessary",
"(",
"paneId",
")",
"{",
"var",
"newPane",
";",
"if",
"(",
"!",
"_panes",
".",
"hasOwnProperty",
"(",
"paneId",
")",
")",
"{",
"newPane",
"=",
"new",
"Pane",
"(",
"paneId",
",",
"_$el",
")",
";",
"_panes",
"[",
"paneId",
"]",
"=",
"newPane",
";",
"exports",
".",
"trigger",
"(",
"\"paneCreate\"",
",",
"newPane",
".",
"id",
")",
";",
"newPane",
".",
"$el",
".",
"on",
"(",
"\"click.mainview dragover.mainview\"",
",",
"function",
"(",
")",
"{",
"setActivePaneId",
"(",
"newPane",
".",
"id",
")",
";",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"viewListChange.mainview\"",
",",
"function",
"(",
")",
"{",
"_updatePaneHeaders",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetUpdate\"",
",",
"newPane",
".",
"id",
")",
";",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"currentViewChange.mainview\"",
",",
"function",
"(",
"e",
",",
"newView",
",",
"oldView",
")",
"{",
"_updatePaneHeaders",
"(",
")",
";",
"if",
"(",
"_activePaneId",
"===",
"newPane",
".",
"id",
")",
"{",
"exports",
".",
"trigger",
"(",
"\"currentFileChange\"",
",",
"newView",
"&&",
"newView",
".",
"getFile",
"(",
")",
",",
"newPane",
".",
"id",
",",
"oldView",
"&&",
"oldView",
".",
"getFile",
"(",
")",
",",
"newPane",
".",
"id",
")",
";",
"}",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"viewDestroy.mainView\"",
",",
"function",
"(",
"e",
",",
"view",
")",
"{",
"_removeFileFromMRU",
"(",
"newPane",
".",
"id",
",",
"view",
".",
"getFile",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"newPane",
";",
"}"
] |
Creates a pane for paneId if one doesn't already exist
@param {!string} paneId - id of the pane to create
@private
@return {?Pane} - the pane object of the new pane, or undefined if no pane created
|
[
"Creates",
"a",
"pane",
"for",
"paneId",
"if",
"one",
"doesn",
"t",
"already",
"exist"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1098-L1130
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_makeFirstPaneResizable
|
function _makeFirstPaneResizable() {
var firstPane = _panes[FIRST_PANE];
Resizer.makeResizable(firstPane.$el,
_orientation === HORIZONTAL ? Resizer.DIRECTION_VERTICAL : Resizer.DIRECTION_HORIZONTAL,
_orientation === HORIZONTAL ? Resizer.POSITION_BOTTOM : Resizer.POSITION_RIGHT,
MIN_PANE_SIZE, false, false, false, true, true);
firstPane.$el.on("panelResizeUpdate", function () {
_updateLayout();
});
}
|
javascript
|
function _makeFirstPaneResizable() {
var firstPane = _panes[FIRST_PANE];
Resizer.makeResizable(firstPane.$el,
_orientation === HORIZONTAL ? Resizer.DIRECTION_VERTICAL : Resizer.DIRECTION_HORIZONTAL,
_orientation === HORIZONTAL ? Resizer.POSITION_BOTTOM : Resizer.POSITION_RIGHT,
MIN_PANE_SIZE, false, false, false, true, true);
firstPane.$el.on("panelResizeUpdate", function () {
_updateLayout();
});
}
|
[
"function",
"_makeFirstPaneResizable",
"(",
")",
"{",
"var",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
";",
"Resizer",
".",
"makeResizable",
"(",
"firstPane",
".",
"$el",
",",
"_orientation",
"===",
"HORIZONTAL",
"?",
"Resizer",
".",
"DIRECTION_VERTICAL",
":",
"Resizer",
".",
"DIRECTION_HORIZONTAL",
",",
"_orientation",
"===",
"HORIZONTAL",
"?",
"Resizer",
".",
"POSITION_BOTTOM",
":",
"Resizer",
".",
"POSITION_RIGHT",
",",
"MIN_PANE_SIZE",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
",",
"true",
")",
";",
"firstPane",
".",
"$el",
".",
"on",
"(",
"\"panelResizeUpdate\"",
",",
"function",
"(",
")",
"{",
"_updateLayout",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Makes the first pane resizable
@private
|
[
"Makes",
"the",
"first",
"pane",
"resizable"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1136-L1146
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_doSplit
|
function _doSplit(orientation) {
var firstPane, newPane;
if (orientation === _orientation) {
return;
}
firstPane = _panes[FIRST_PANE];
Resizer.removeSizable(firstPane.$el);
if (_orientation) {
_$el.removeClass("split-" + _orientation.toLowerCase());
}
_$el.addClass("split-" + orientation.toLowerCase());
_orientation = orientation;
newPane = _createPaneIfNecessary(SECOND_PANE);
_makeFirstPaneResizable();
// reset the layout to 50/50 split
// if we changed orientation then
// the percentages are reset as well
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if new pane was created, and original pane is not empty, make new pane the active pane
if (newPane && getCurrentlyViewedFile(firstPane.id)) {
setActivePaneId(newPane.id);
}
}
|
javascript
|
function _doSplit(orientation) {
var firstPane, newPane;
if (orientation === _orientation) {
return;
}
firstPane = _panes[FIRST_PANE];
Resizer.removeSizable(firstPane.$el);
if (_orientation) {
_$el.removeClass("split-" + _orientation.toLowerCase());
}
_$el.addClass("split-" + orientation.toLowerCase());
_orientation = orientation;
newPane = _createPaneIfNecessary(SECOND_PANE);
_makeFirstPaneResizable();
// reset the layout to 50/50 split
// if we changed orientation then
// the percentages are reset as well
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if new pane was created, and original pane is not empty, make new pane the active pane
if (newPane && getCurrentlyViewedFile(firstPane.id)) {
setActivePaneId(newPane.id);
}
}
|
[
"function",
"_doSplit",
"(",
"orientation",
")",
"{",
"var",
"firstPane",
",",
"newPane",
";",
"if",
"(",
"orientation",
"===",
"_orientation",
")",
"{",
"return",
";",
"}",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
";",
"Resizer",
".",
"removeSizable",
"(",
"firstPane",
".",
"$el",
")",
";",
"if",
"(",
"_orientation",
")",
"{",
"_$el",
".",
"removeClass",
"(",
"\"split-\"",
"+",
"_orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"_$el",
".",
"addClass",
"(",
"\"split-\"",
"+",
"orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"_orientation",
"=",
"orientation",
";",
"newPane",
"=",
"_createPaneIfNecessary",
"(",
"SECOND_PANE",
")",
";",
"_makeFirstPaneResizable",
"(",
")",
";",
"_initialLayout",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"paneLayoutChange\"",
",",
"_orientation",
")",
";",
"if",
"(",
"newPane",
"&&",
"getCurrentlyViewedFile",
"(",
"firstPane",
".",
"id",
")",
")",
"{",
"setActivePaneId",
"(",
"newPane",
".",
"id",
")",
";",
"}",
"}"
] |
Creates a split for the specified orientation
@private
@param {!string} orientation (VERTICAL|HORIZONTAL)
|
[
"Creates",
"a",
"split",
"for",
"the",
"specified",
"orientation"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1154-L1184
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_open
|
function _open(paneId, file, optionsIn) {
var result = new $.Deferred(),
options = optionsIn || {};
function doPostOpenActivation() {
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
}
if (!file || !_getPane(paneId)) {
return result.reject("bad argument").promise();
}
// See if there is already a view for the file
var pane = _getPane(paneId);
// See if there is a factory to create a view for this file
// we want to do this first because, we don't want our internal
// editor to edit files for which there are suitable viewfactories
var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);
if (factory) {
file.exists(function (fileError, fileExists) {
if (fileExists) {
// let the factory open the file and create a view for it
factory.openFile(file, pane)
.done(function () {
// if we opened a file that isn't in the project
// then add the file to the working set
if (!ProjectManager.isWithinProject(file.fullPath)) {
addToWorkingSet(paneId, file);
}
doPostOpenActivation();
result.resolve(file);
})
.fail(function (fileError) {
result.reject(fileError);
});
} else {
result.reject(fileError || FileSystemError.NOT_FOUND);
}
});
} else {
DocumentManager.getDocumentForPath(file.fullPath, file)
.done(function (doc) {
if (doc) {
_edit(paneId, doc, $.extend({}, options, {
noPaneActivate: true
}));
doPostOpenActivation();
result.resolve(doc.file);
} else {
result.resolve(null);
}
})
.fail(function (fileError) {
result.reject(fileError);
});
}
result.done(function () {
_makeFileMostRecent(paneId, file);
});
return result;
}
|
javascript
|
function _open(paneId, file, optionsIn) {
var result = new $.Deferred(),
options = optionsIn || {};
function doPostOpenActivation() {
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
}
if (!file || !_getPane(paneId)) {
return result.reject("bad argument").promise();
}
// See if there is already a view for the file
var pane = _getPane(paneId);
// See if there is a factory to create a view for this file
// we want to do this first because, we don't want our internal
// editor to edit files for which there are suitable viewfactories
var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);
if (factory) {
file.exists(function (fileError, fileExists) {
if (fileExists) {
// let the factory open the file and create a view for it
factory.openFile(file, pane)
.done(function () {
// if we opened a file that isn't in the project
// then add the file to the working set
if (!ProjectManager.isWithinProject(file.fullPath)) {
addToWorkingSet(paneId, file);
}
doPostOpenActivation();
result.resolve(file);
})
.fail(function (fileError) {
result.reject(fileError);
});
} else {
result.reject(fileError || FileSystemError.NOT_FOUND);
}
});
} else {
DocumentManager.getDocumentForPath(file.fullPath, file)
.done(function (doc) {
if (doc) {
_edit(paneId, doc, $.extend({}, options, {
noPaneActivate: true
}));
doPostOpenActivation();
result.resolve(doc.file);
} else {
result.resolve(null);
}
})
.fail(function (fileError) {
result.reject(fileError);
});
}
result.done(function () {
_makeFileMostRecent(paneId, file);
});
return result;
}
|
[
"function",
"_open",
"(",
"paneId",
",",
"file",
",",
"optionsIn",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"function",
"doPostOpenActivation",
"(",
")",
"{",
"if",
"(",
"!",
"options",
".",
"noPaneActivate",
")",
"{",
"setActivePaneId",
"(",
"paneId",
")",
";",
"}",
"}",
"if",
"(",
"!",
"file",
"||",
"!",
"_getPane",
"(",
"paneId",
")",
")",
"{",
"return",
"result",
".",
"reject",
"(",
"\"bad argument\"",
")",
".",
"promise",
"(",
")",
";",
"}",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"var",
"factory",
"=",
"MainViewFactory",
".",
"findSuitableFactoryForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"if",
"(",
"factory",
")",
"{",
"file",
".",
"exists",
"(",
"function",
"(",
"fileError",
",",
"fileExists",
")",
"{",
"if",
"(",
"fileExists",
")",
"{",
"factory",
".",
"openFile",
"(",
"file",
",",
"pane",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"ProjectManager",
".",
"isWithinProject",
"(",
"file",
".",
"fullPath",
")",
")",
"{",
"addToWorkingSet",
"(",
"paneId",
",",
"file",
")",
";",
"}",
"doPostOpenActivation",
"(",
")",
";",
"result",
".",
"resolve",
"(",
"file",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"fileError",
")",
"{",
"result",
".",
"reject",
"(",
"fileError",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"fileError",
"||",
"FileSystemError",
".",
"NOT_FOUND",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"file",
".",
"fullPath",
",",
"file",
")",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"doc",
")",
"{",
"_edit",
"(",
"paneId",
",",
"doc",
",",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"options",
",",
"{",
"noPaneActivate",
":",
"true",
"}",
")",
")",
";",
"doPostOpenActivation",
"(",
")",
";",
"result",
".",
"resolve",
"(",
"doc",
".",
"file",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
"null",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"fileError",
")",
"{",
"result",
".",
"reject",
"(",
"fileError",
")",
";",
"}",
")",
";",
"}",
"result",
".",
"done",
"(",
"function",
"(",
")",
"{",
"_makeFileMostRecent",
"(",
"paneId",
",",
"file",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Opens a file in the specified pane this can be used to open a file with a custom viewer
or a document for editing. If it's a document for editing, edit is called on the document
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to open
@param {{noPaneActivate:boolean=}=} optionsIn - options
@return {jQuery.Promise} promise that resolves to a File object or
rejects with a File error or string
|
[
"Opens",
"a",
"file",
"in",
"the",
"specified",
"pane",
"this",
"can",
"be",
"used",
"to",
"open",
"a",
"file",
"with",
"a",
"custom",
"viewer",
"or",
"a",
"document",
"for",
"editing",
".",
"If",
"it",
"s",
"a",
"document",
"for",
"editing",
"edit",
"is",
"called",
"on",
"the",
"document"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1227-L1294
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_mergePanes
|
function _mergePanes() {
if (_panes.hasOwnProperty(SECOND_PANE)) {
var firstPane = _panes[FIRST_PANE],
secondPane = _panes[SECOND_PANE],
fileList = secondPane.getViewList(),
lastViewed = getCurrentlyViewedFile();
Resizer.removeSizable(firstPane.$el);
firstPane.mergeFrom(secondPane);
exports.trigger("workingSetRemoveList", fileList, secondPane.id);
setActivePaneId(firstPane.id);
secondPane.$el.off(".mainview");
secondPane.off(".mainview");
secondPane.destroy();
delete _panes[SECOND_PANE];
exports.trigger("paneDestroy", secondPane.id);
exports.trigger("workingSetAddList", fileList, firstPane.id);
_mruList.forEach(function (record) {
if (record.paneId === secondPane.id) {
record.paneId = firstPane.id;
}
});
_$el.removeClass("split-" + _orientation.toLowerCase());
_orientation = null;
// this will set the remaining pane to 100%
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if the current view before the merger was in the pane
// that went away then reopen it so that it's now the current view again
if (lastViewed && getCurrentlyViewedFile() !== lastViewed) {
exports._open(firstPane.id, lastViewed);
}
}
}
|
javascript
|
function _mergePanes() {
if (_panes.hasOwnProperty(SECOND_PANE)) {
var firstPane = _panes[FIRST_PANE],
secondPane = _panes[SECOND_PANE],
fileList = secondPane.getViewList(),
lastViewed = getCurrentlyViewedFile();
Resizer.removeSizable(firstPane.$el);
firstPane.mergeFrom(secondPane);
exports.trigger("workingSetRemoveList", fileList, secondPane.id);
setActivePaneId(firstPane.id);
secondPane.$el.off(".mainview");
secondPane.off(".mainview");
secondPane.destroy();
delete _panes[SECOND_PANE];
exports.trigger("paneDestroy", secondPane.id);
exports.trigger("workingSetAddList", fileList, firstPane.id);
_mruList.forEach(function (record) {
if (record.paneId === secondPane.id) {
record.paneId = firstPane.id;
}
});
_$el.removeClass("split-" + _orientation.toLowerCase());
_orientation = null;
// this will set the remaining pane to 100%
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if the current view before the merger was in the pane
// that went away then reopen it so that it's now the current view again
if (lastViewed && getCurrentlyViewedFile() !== lastViewed) {
exports._open(firstPane.id, lastViewed);
}
}
}
|
[
"function",
"_mergePanes",
"(",
")",
"{",
"if",
"(",
"_panes",
".",
"hasOwnProperty",
"(",
"SECOND_PANE",
")",
")",
"{",
"var",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
",",
"secondPane",
"=",
"_panes",
"[",
"SECOND_PANE",
"]",
",",
"fileList",
"=",
"secondPane",
".",
"getViewList",
"(",
")",
",",
"lastViewed",
"=",
"getCurrentlyViewedFile",
"(",
")",
";",
"Resizer",
".",
"removeSizable",
"(",
"firstPane",
".",
"$el",
")",
";",
"firstPane",
".",
"mergeFrom",
"(",
"secondPane",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"fileList",
",",
"secondPane",
".",
"id",
")",
";",
"setActivePaneId",
"(",
"firstPane",
".",
"id",
")",
";",
"secondPane",
".",
"$el",
".",
"off",
"(",
"\".mainview\"",
")",
";",
"secondPane",
".",
"off",
"(",
"\".mainview\"",
")",
";",
"secondPane",
".",
"destroy",
"(",
")",
";",
"delete",
"_panes",
"[",
"SECOND_PANE",
"]",
";",
"exports",
".",
"trigger",
"(",
"\"paneDestroy\"",
",",
"secondPane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetAddList\"",
",",
"fileList",
",",
"firstPane",
".",
"id",
")",
";",
"_mruList",
".",
"forEach",
"(",
"function",
"(",
"record",
")",
"{",
"if",
"(",
"record",
".",
"paneId",
"===",
"secondPane",
".",
"id",
")",
"{",
"record",
".",
"paneId",
"=",
"firstPane",
".",
"id",
";",
"}",
"}",
")",
";",
"_$el",
".",
"removeClass",
"(",
"\"split-\"",
"+",
"_orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"_orientation",
"=",
"null",
";",
"_initialLayout",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"paneLayoutChange\"",
",",
"_orientation",
")",
";",
"if",
"(",
"lastViewed",
"&&",
"getCurrentlyViewedFile",
"(",
")",
"!==",
"lastViewed",
")",
"{",
"exports",
".",
"_open",
"(",
"firstPane",
".",
"id",
",",
"lastViewed",
")",
";",
"}",
"}",
"}"
] |
Merges second pane into first pane and opens the current file
@private
|
[
"Merges",
"second",
"pane",
"into",
"first",
"pane",
"and",
"opens",
"the",
"current",
"file"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1300-L1342
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_close
|
function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
}
|
javascript
|
function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
}
|
[
"function",
"_close",
"(",
"paneId",
",",
"file",
",",
"optionsIn",
")",
"{",
"var",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"removeView",
"(",
"file",
",",
"options",
".",
"noOpenNextFile",
")",
"&&",
"(",
"paneId",
"===",
"ACTIVE_PANE",
"||",
"pane",
".",
"id",
"===",
"paneId",
")",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemove\"",
",",
"file",
",",
"false",
",",
"pane",
".",
"id",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] |
Closes a file in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to close
@param {Object={noOpenNextFile:boolean}} optionsIn - options
This function does not fail if the file is not open
|
[
"Closes",
"a",
"file",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1351-L1360
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_closeList
|
function _closeList(paneId, fileList) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.removeViews(fileList);
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
}
|
javascript
|
function _closeList(paneId, fileList) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.removeViews(fileList);
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
}
|
[
"function",
"_closeList",
"(",
"paneId",
",",
"fileList",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"closedList",
"=",
"pane",
".",
"removeViews",
"(",
"fileList",
")",
";",
"closedList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"closedList",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] |
Closes a list of file in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
@param {!Array.<File>} fileList - files to close
This function does not fail if the file is not open
|
[
"Closes",
"a",
"list",
"of",
"file",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1368-L1377
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_closeAll
|
function _closeAll(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.getViewList();
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
pane._reset();
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
}
|
javascript
|
function _closeAll(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.getViewList();
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
pane._reset();
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
}
|
[
"function",
"_closeAll",
"(",
"paneId",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"closedList",
"=",
"pane",
".",
"getViewList",
"(",
")",
";",
"closedList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"}",
")",
";",
"pane",
".",
"_reset",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"closedList",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] |
Closes all files in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
This function does not fail if the file is not open
|
[
"Closes",
"all",
"files",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1384-L1394
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_findPaneForDocument
|
function _findPaneForDocument(document) {
// First check for an editor view of the document
var pane = _getPaneFromElement($(document._masterEditor.$el.parent().parent()));
if (!pane) {
// No view of the document, it may be in a working set and not yet opened
var info = findInAllWorkingSets(document.file.fullPath).shift();
if (info) {
pane = _panes[info.paneId];
}
}
return pane;
}
|
javascript
|
function _findPaneForDocument(document) {
// First check for an editor view of the document
var pane = _getPaneFromElement($(document._masterEditor.$el.parent().parent()));
if (!pane) {
// No view of the document, it may be in a working set and not yet opened
var info = findInAllWorkingSets(document.file.fullPath).shift();
if (info) {
pane = _panes[info.paneId];
}
}
return pane;
}
|
[
"function",
"_findPaneForDocument",
"(",
"document",
")",
"{",
"var",
"pane",
"=",
"_getPaneFromElement",
"(",
"$",
"(",
"document",
".",
"_masterEditor",
".",
"$el",
".",
"parent",
"(",
")",
".",
"parent",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"pane",
")",
"{",
"var",
"info",
"=",
"findInAllWorkingSets",
"(",
"document",
".",
"file",
".",
"fullPath",
")",
".",
"shift",
"(",
")",
";",
"if",
"(",
"info",
")",
"{",
"pane",
"=",
"_panes",
"[",
"info",
".",
"paneId",
"]",
";",
"}",
"}",
"return",
"pane",
";",
"}"
] |
Finds which pane a document belongs to
@param {!Document} document - the document to locate
@return {?Pane} the pane where the document lives or NULL if it isn't in a pane
@private
|
[
"Finds",
"which",
"pane",
"a",
"document",
"belongs",
"to"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1403-L1416
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_destroyEditorIfNotNeeded
|
function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
}
|
javascript
|
function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
}
|
[
"function",
"_destroyEditorIfNotNeeded",
"(",
"document",
")",
"{",
"if",
"(",
"!",
"(",
"document",
"instanceof",
"DocumentManager",
".",
"Document",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_destroyEditorIfUnneeded() should be passed a Document\"",
")",
";",
"}",
"if",
"(",
"document",
".",
"_masterEditor",
")",
"{",
"var",
"pane",
"=",
"_findPaneForDocument",
"(",
"document",
")",
";",
"if",
"(",
"pane",
")",
"{",
"pane",
".",
"destroyViewIfNotNeeded",
"(",
"document",
".",
"_masterEditor",
")",
";",
"}",
"else",
"{",
"document",
".",
"_masterEditor",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"}"
] |
Destroys an editor object if a document is no longer referenced
@param {!Document} doc - document to destroy
|
[
"Destroys",
"an",
"editor",
"object",
"if",
"a",
"document",
"is",
"no",
"longer",
"referenced"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1422-L1441
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_saveViewState
|
function _saveViewState() {
function _computeSplitPercentage() {
var available,
used;
if (getPaneCount() === 1) {
// just short-circuit here and
// return 100% to avoid any rounding issues
return 1;
} else {
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
used = _panes[FIRST_PANE].$el.width();
} else {
available = _$el.innerHeight();
used = _panes[FIRST_PANE].$el.height();
}
return used / available;
}
}
var projectRoot = ProjectManager.getProjectRoot(),
context = { location : { scope: "user",
layer: "project",
layerID: projectRoot.fullPath } },
state = {
orientation: _orientation,
activePaneId: getActivePaneId(),
splitPercentage: _computeSplitPercentage(),
panes: {
}
};
if (!projectRoot) {
return;
}
_.forEach(_panes, function (pane) {
state.panes[pane.id] = pane.saveState();
});
PreferencesManager.setViewState(PREFS_NAME, state, context);
}
|
javascript
|
function _saveViewState() {
function _computeSplitPercentage() {
var available,
used;
if (getPaneCount() === 1) {
// just short-circuit here and
// return 100% to avoid any rounding issues
return 1;
} else {
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
used = _panes[FIRST_PANE].$el.width();
} else {
available = _$el.innerHeight();
used = _panes[FIRST_PANE].$el.height();
}
return used / available;
}
}
var projectRoot = ProjectManager.getProjectRoot(),
context = { location : { scope: "user",
layer: "project",
layerID: projectRoot.fullPath } },
state = {
orientation: _orientation,
activePaneId: getActivePaneId(),
splitPercentage: _computeSplitPercentage(),
panes: {
}
};
if (!projectRoot) {
return;
}
_.forEach(_panes, function (pane) {
state.panes[pane.id] = pane.saveState();
});
PreferencesManager.setViewState(PREFS_NAME, state, context);
}
|
[
"function",
"_saveViewState",
"(",
")",
"{",
"function",
"_computeSplitPercentage",
"(",
")",
"{",
"var",
"available",
",",
"used",
";",
"if",
"(",
"getPaneCount",
"(",
")",
"===",
"1",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"used",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"width",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"used",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"height",
"(",
")",
";",
"}",
"return",
"used",
"/",
"available",
";",
"}",
"}",
"var",
"projectRoot",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
",",
"context",
"=",
"{",
"location",
":",
"{",
"scope",
":",
"\"user\"",
",",
"layer",
":",
"\"project\"",
",",
"layerID",
":",
"projectRoot",
".",
"fullPath",
"}",
"}",
",",
"state",
"=",
"{",
"orientation",
":",
"_orientation",
",",
"activePaneId",
":",
"getActivePaneId",
"(",
")",
",",
"splitPercentage",
":",
"_computeSplitPercentage",
"(",
")",
",",
"panes",
":",
"{",
"}",
"}",
";",
"if",
"(",
"!",
"projectRoot",
")",
"{",
"return",
";",
"}",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"state",
".",
"panes",
"[",
"pane",
".",
"id",
"]",
"=",
"pane",
".",
"saveState",
"(",
")",
";",
"}",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"PREFS_NAME",
",",
"state",
",",
"context",
")",
";",
"}"
] |
Saves the workingset state
@private
|
[
"Saves",
"the",
"workingset",
"state"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1567-L1612
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
_initialize
|
function _initialize($container) {
if (_activePaneId) {
throw new Error("MainViewManager has already been initialized");
}
_$el = $container;
_createPaneIfNecessary(FIRST_PANE);
_activePaneId = FIRST_PANE;
// One-time init so the pane has the "active" appearance
_panes[FIRST_PANE]._handleActivePaneChange(undefined, _activePaneId);
_initialLayout();
// This ensures that unit tests that use this function
// get an event handler for workspace events and we don't listen
// to the event before we've been initialized
WorkspaceManager.on("workspaceUpdateLayout", _updateLayout);
// Listen to key Alt-W to toggle between panes
CommandManager.register(Strings.CMD_SWITCH_PANE_FOCUS, Commands.CMD_SWITCH_PANE_FOCUS, switchPaneFocus);
KeyBindingManager.addBinding(Commands.CMD_SWITCH_PANE_FOCUS, {key: 'Alt-W'});
}
|
javascript
|
function _initialize($container) {
if (_activePaneId) {
throw new Error("MainViewManager has already been initialized");
}
_$el = $container;
_createPaneIfNecessary(FIRST_PANE);
_activePaneId = FIRST_PANE;
// One-time init so the pane has the "active" appearance
_panes[FIRST_PANE]._handleActivePaneChange(undefined, _activePaneId);
_initialLayout();
// This ensures that unit tests that use this function
// get an event handler for workspace events and we don't listen
// to the event before we've been initialized
WorkspaceManager.on("workspaceUpdateLayout", _updateLayout);
// Listen to key Alt-W to toggle between panes
CommandManager.register(Strings.CMD_SWITCH_PANE_FOCUS, Commands.CMD_SWITCH_PANE_FOCUS, switchPaneFocus);
KeyBindingManager.addBinding(Commands.CMD_SWITCH_PANE_FOCUS, {key: 'Alt-W'});
}
|
[
"function",
"_initialize",
"(",
"$container",
")",
"{",
"if",
"(",
"_activePaneId",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"MainViewManager has already been initialized\"",
")",
";",
"}",
"_$el",
"=",
"$container",
";",
"_createPaneIfNecessary",
"(",
"FIRST_PANE",
")",
";",
"_activePaneId",
"=",
"FIRST_PANE",
";",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"_handleActivePaneChange",
"(",
"undefined",
",",
"_activePaneId",
")",
";",
"_initialLayout",
"(",
")",
";",
"WorkspaceManager",
".",
"on",
"(",
"\"workspaceUpdateLayout\"",
",",
"_updateLayout",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"Commands",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"switchPaneFocus",
")",
";",
"KeyBindingManager",
".",
"addBinding",
"(",
"Commands",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"{",
"key",
":",
"'Alt-W'",
"}",
")",
";",
"}"
] |
Initializes the MainViewManager's view state
@param {jQuery} $container - the container where the main view will live
@private
|
[
"Initializes",
"the",
"MainViewManager",
"s",
"view",
"state"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1619-L1639
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
setLayoutScheme
|
function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
}
|
javascript
|
function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
}
|
[
"function",
"setLayoutScheme",
"(",
"rows",
",",
"columns",
")",
"{",
"if",
"(",
"(",
"rows",
"<",
"1",
")",
"||",
"(",
"rows",
">",
"2",
")",
"||",
"(",
"columns",
"<",
"1",
")",
"||",
"(",
"columns",
">",
"2",
")",
"||",
"(",
"columns",
"===",
"2",
"&&",
"rows",
"===",
"2",
")",
")",
"{",
"console",
".",
"error",
"(",
"\"setLayoutScheme unsupported layout \"",
"+",
"rows",
"+",
"\", \"",
"+",
"columns",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"rows",
"===",
"columns",
")",
"{",
"_mergePanes",
"(",
")",
";",
"}",
"else",
"if",
"(",
"rows",
">",
"columns",
")",
"{",
"_doSplit",
"(",
"HORIZONTAL",
")",
";",
"}",
"else",
"{",
"_doSplit",
"(",
"VERTICAL",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Changes the layout scheme
@param {!number} rows (may be 1 or 2)
@param {!number} columns (may be 1 or 2)
@summay Rows or Columns may be 1 or 2 but both cannot be 2. 1x2, 2x1 or 1x1 are the legal values
|
[
"Changes",
"the",
"layout",
"scheme"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1647-L1661
|
train
|
adobe/brackets
|
src/view/MainViewManager.js
|
getLayoutScheme
|
function getLayoutScheme() {
var result = {
rows: 1,
columns: 1
};
if (_orientation === HORIZONTAL) {
result.rows = 2;
} else if (_orientation === VERTICAL) {
result.columns = 2;
}
return result;
}
|
javascript
|
function getLayoutScheme() {
var result = {
rows: 1,
columns: 1
};
if (_orientation === HORIZONTAL) {
result.rows = 2;
} else if (_orientation === VERTICAL) {
result.columns = 2;
}
return result;
}
|
[
"function",
"getLayoutScheme",
"(",
")",
"{",
"var",
"result",
"=",
"{",
"rows",
":",
"1",
",",
"columns",
":",
"1",
"}",
";",
"if",
"(",
"_orientation",
"===",
"HORIZONTAL",
")",
"{",
"result",
".",
"rows",
"=",
"2",
";",
"}",
"else",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"result",
".",
"columns",
"=",
"2",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieves the current layout scheme
@return {!{rows: number, columns: number>}}
|
[
"Retrieves",
"the",
"current",
"layout",
"scheme"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1667-L1680
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/InlineTimingFunctionEditor.js
|
InlineTimingFunctionEditor
|
function InlineTimingFunctionEditor(timingFunction, startBookmark, endBookmark) {
this._timingFunction = timingFunction;
this._startBookmark = startBookmark;
this._endBookmark = endBookmark;
this._isOwnChange = false;
this._isHostChange = false;
this._origin = "+InlineTimingFunctionEditor_" + (lastOriginId++);
this._handleTimingFunctionChange = this._handleTimingFunctionChange.bind(this);
this._handleHostDocumentChange = this._handleHostDocumentChange.bind(this);
InlineWidget.call(this);
}
|
javascript
|
function InlineTimingFunctionEditor(timingFunction, startBookmark, endBookmark) {
this._timingFunction = timingFunction;
this._startBookmark = startBookmark;
this._endBookmark = endBookmark;
this._isOwnChange = false;
this._isHostChange = false;
this._origin = "+InlineTimingFunctionEditor_" + (lastOriginId++);
this._handleTimingFunctionChange = this._handleTimingFunctionChange.bind(this);
this._handleHostDocumentChange = this._handleHostDocumentChange.bind(this);
InlineWidget.call(this);
}
|
[
"function",
"InlineTimingFunctionEditor",
"(",
"timingFunction",
",",
"startBookmark",
",",
"endBookmark",
")",
"{",
"this",
".",
"_timingFunction",
"=",
"timingFunction",
";",
"this",
".",
"_startBookmark",
"=",
"startBookmark",
";",
"this",
".",
"_endBookmark",
"=",
"endBookmark",
";",
"this",
".",
"_isOwnChange",
"=",
"false",
";",
"this",
".",
"_isHostChange",
"=",
"false",
";",
"this",
".",
"_origin",
"=",
"\"+InlineTimingFunctionEditor_\"",
"+",
"(",
"lastOriginId",
"++",
")",
";",
"this",
".",
"_handleTimingFunctionChange",
"=",
"this",
".",
"_handleTimingFunctionChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleHostDocumentChange",
"=",
"this",
".",
"_handleHostDocumentChange",
".",
"bind",
"(",
"this",
")",
";",
"InlineWidget",
".",
"call",
"(",
"this",
")",
";",
"}"
] |
Constructor for inline widget containing a BezierCurveEditor control
@param {!RegExpMatch} timingFunction RegExp match object of initially selected timingFunction
@param {!CodeMirror.Bookmark} startBookmark
@param {!CodeMirror.Bookmark} endBookmark
|
[
"Constructor",
"for",
"inline",
"widget",
"containing",
"a",
"BezierCurveEditor",
"control"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/InlineTimingFunctionEditor.js#L43-L55
|
train
|
adobe/brackets
|
src/extensibility/node/npm-installer.js
|
performNpmInstallIfRequired
|
function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
}
|
javascript
|
function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
}
|
[
"function",
"performNpmInstallIfRequired",
"(",
"npmOptions",
",",
"validationResult",
",",
"callback",
")",
"{",
"function",
"finish",
"(",
")",
"{",
"callback",
"(",
"null",
",",
"validationResult",
")",
";",
"}",
"var",
"installDirectory",
"=",
"path",
".",
"join",
"(",
"validationResult",
".",
"extractDir",
",",
"validationResult",
".",
"commonPrefix",
")",
";",
"var",
"packageJson",
";",
"try",
"{",
"packageJson",
"=",
"fs",
".",
"readJsonSync",
"(",
"path",
".",
"join",
"(",
"installDirectory",
",",
"\"package.json\"",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"packageJson",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"packageJson",
"||",
"!",
"packageJson",
".",
"dependencies",
"||",
"!",
"Object",
".",
"keys",
"(",
"packageJson",
".",
"dependencies",
")",
".",
"length",
")",
"{",
"return",
"finish",
"(",
")",
";",
"}",
"_performNpmInstall",
"(",
"installDirectory",
",",
"npmOptions",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"validationResult",
".",
"errors",
".",
"push",
"(",
"[",
"Errors",
".",
"NPM_INSTALL_FAILED",
",",
"err",
".",
"toString",
"(",
")",
"]",
")",
";",
"}",
"finish",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Checks package.json of the extracted extension for npm dependencies
and runs npm install when required.
@param {Object} validationResult return value of the validation procedure
@param {Function} callback function to be called after the end of validation procedure
|
[
"Checks",
"package",
".",
"json",
"of",
"the",
"extracted",
"extension",
"for",
"npm",
"dependencies",
"and",
"runs",
"npm",
"install",
"when",
"required",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/npm-installer.js#L93-L118
|
train
|
adobe/brackets
|
src/view/ThemeSettings.js
|
showDialog
|
function showDialog() {
var currentSettings = getValues();
var newSettings = {};
var themes = _.map(loadedThemes, function (theme) { return theme; });
var template = $("<div>").append($settings).html();
var $template = $(Mustache.render(template, {"settings": currentSettings, "themes": themes, "Strings": Strings}));
// Select the correct theme.
var $currentThemeOption = $template
.find("[value='" + currentSettings.theme + "']");
if ($currentThemeOption.length === 0) {
$currentThemeOption = $template.find("[value='" + defaults.theme + "']");
}
$currentThemeOption.attr("selected", "selected");
$template
.find("[data-toggle=tab].default")
.tab("show");
$template
.on("change", "[data-target]:checkbox", function () {
var $target = $(this);
var attr = $target.attr("data-target");
newSettings[attr] = $target.is(":checked");
})
.on("input", "[data-target='fontSize']", function () {
var target = this;
var targetValue = $(this).val();
var $btn = $("#theme-settings-done-btn")[0];
// Make sure that the font size is expressed in terms
// we can handle (px or em). If not, 'done' button is
// disabled until input has been corrected.
if (target.checkValidity() === true) {
$btn.disabled = false;
newSettings["fontSize"] = targetValue;
} else {
$btn.disabled = true;
}
})
.on("input", "[data-target='fontFamily']", function () {
var targetValue = $(this).val();
newSettings["fontFamily"] = targetValue;
})
.on("change", "select", function () {
var $target = $(":selected", this);
var attr = $target.attr("data-target");
if (attr) {
prefs.set(attr, $target.val());
}
});
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
var setterFn;
if (id === "save") {
// Go through each new setting and apply it
Object.keys(newSettings).forEach(function (setting) {
if (defaults.hasOwnProperty(setting)) {
prefs.set(setting, newSettings[setting]);
} else {
// Figure out if the setting is in the ViewCommandHandlers, which means it is
// a font setting
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1);
if (typeof ViewCommandHandlers[setterFn] === "function") {
ViewCommandHandlers[setterFn](newSettings[setting]);
}
}
});
} else if (id === "cancel") {
// Make sure we revert any changes to theme selection
prefs.set("theme", currentSettings.theme);
}
});
}
|
javascript
|
function showDialog() {
var currentSettings = getValues();
var newSettings = {};
var themes = _.map(loadedThemes, function (theme) { return theme; });
var template = $("<div>").append($settings).html();
var $template = $(Mustache.render(template, {"settings": currentSettings, "themes": themes, "Strings": Strings}));
// Select the correct theme.
var $currentThemeOption = $template
.find("[value='" + currentSettings.theme + "']");
if ($currentThemeOption.length === 0) {
$currentThemeOption = $template.find("[value='" + defaults.theme + "']");
}
$currentThemeOption.attr("selected", "selected");
$template
.find("[data-toggle=tab].default")
.tab("show");
$template
.on("change", "[data-target]:checkbox", function () {
var $target = $(this);
var attr = $target.attr("data-target");
newSettings[attr] = $target.is(":checked");
})
.on("input", "[data-target='fontSize']", function () {
var target = this;
var targetValue = $(this).val();
var $btn = $("#theme-settings-done-btn")[0];
// Make sure that the font size is expressed in terms
// we can handle (px or em). If not, 'done' button is
// disabled until input has been corrected.
if (target.checkValidity() === true) {
$btn.disabled = false;
newSettings["fontSize"] = targetValue;
} else {
$btn.disabled = true;
}
})
.on("input", "[data-target='fontFamily']", function () {
var targetValue = $(this).val();
newSettings["fontFamily"] = targetValue;
})
.on("change", "select", function () {
var $target = $(":selected", this);
var attr = $target.attr("data-target");
if (attr) {
prefs.set(attr, $target.val());
}
});
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
var setterFn;
if (id === "save") {
// Go through each new setting and apply it
Object.keys(newSettings).forEach(function (setting) {
if (defaults.hasOwnProperty(setting)) {
prefs.set(setting, newSettings[setting]);
} else {
// Figure out if the setting is in the ViewCommandHandlers, which means it is
// a font setting
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1);
if (typeof ViewCommandHandlers[setterFn] === "function") {
ViewCommandHandlers[setterFn](newSettings[setting]);
}
}
});
} else if (id === "cancel") {
// Make sure we revert any changes to theme selection
prefs.set("theme", currentSettings.theme);
}
});
}
|
[
"function",
"showDialog",
"(",
")",
"{",
"var",
"currentSettings",
"=",
"getValues",
"(",
")",
";",
"var",
"newSettings",
"=",
"{",
"}",
";",
"var",
"themes",
"=",
"_",
".",
"map",
"(",
"loadedThemes",
",",
"function",
"(",
"theme",
")",
"{",
"return",
"theme",
";",
"}",
")",
";",
"var",
"template",
"=",
"$",
"(",
"\"<div>\"",
")",
".",
"append",
"(",
"$settings",
")",
".",
"html",
"(",
")",
";",
"var",
"$template",
"=",
"$",
"(",
"Mustache",
".",
"render",
"(",
"template",
",",
"{",
"\"settings\"",
":",
"currentSettings",
",",
"\"themes\"",
":",
"themes",
",",
"\"Strings\"",
":",
"Strings",
"}",
")",
")",
";",
"var",
"$currentThemeOption",
"=",
"$template",
".",
"find",
"(",
"\"[value='\"",
"+",
"currentSettings",
".",
"theme",
"+",
"\"']\"",
")",
";",
"if",
"(",
"$currentThemeOption",
".",
"length",
"===",
"0",
")",
"{",
"$currentThemeOption",
"=",
"$template",
".",
"find",
"(",
"\"[value='\"",
"+",
"defaults",
".",
"theme",
"+",
"\"']\"",
")",
";",
"}",
"$currentThemeOption",
".",
"attr",
"(",
"\"selected\"",
",",
"\"selected\"",
")",
";",
"$template",
".",
"find",
"(",
"\"[data-toggle=tab].default\"",
")",
".",
"tab",
"(",
"\"show\"",
")",
";",
"$template",
".",
"on",
"(",
"\"change\"",
",",
"\"[data-target]:checkbox\"",
",",
"function",
"(",
")",
"{",
"var",
"$target",
"=",
"$",
"(",
"this",
")",
";",
"var",
"attr",
"=",
"$target",
".",
"attr",
"(",
"\"data-target\"",
")",
";",
"newSettings",
"[",
"attr",
"]",
"=",
"$target",
".",
"is",
"(",
"\":checked\"",
")",
";",
"}",
")",
".",
"on",
"(",
"\"input\"",
",",
"\"[data-target='fontSize']\"",
",",
"function",
"(",
")",
"{",
"var",
"target",
"=",
"this",
";",
"var",
"targetValue",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"var",
"$btn",
"=",
"$",
"(",
"\"#theme-settings-done-btn\"",
")",
"[",
"0",
"]",
";",
"if",
"(",
"target",
".",
"checkValidity",
"(",
")",
"===",
"true",
")",
"{",
"$btn",
".",
"disabled",
"=",
"false",
";",
"newSettings",
"[",
"\"fontSize\"",
"]",
"=",
"targetValue",
";",
"}",
"else",
"{",
"$btn",
".",
"disabled",
"=",
"true",
";",
"}",
"}",
")",
".",
"on",
"(",
"\"input\"",
",",
"\"[data-target='fontFamily']\"",
",",
"function",
"(",
")",
"{",
"var",
"targetValue",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"newSettings",
"[",
"\"fontFamily\"",
"]",
"=",
"targetValue",
";",
"}",
")",
".",
"on",
"(",
"\"change\"",
",",
"\"select\"",
",",
"function",
"(",
")",
"{",
"var",
"$target",
"=",
"$",
"(",
"\":selected\"",
",",
"this",
")",
";",
"var",
"attr",
"=",
"$target",
".",
"attr",
"(",
"\"data-target\"",
")",
";",
"if",
"(",
"attr",
")",
"{",
"prefs",
".",
"set",
"(",
"attr",
",",
"$target",
".",
"val",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"Dialogs",
".",
"showModalDialogUsingTemplate",
"(",
"$template",
")",
".",
"done",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"setterFn",
";",
"if",
"(",
"id",
"===",
"\"save\"",
")",
"{",
"Object",
".",
"keys",
"(",
"newSettings",
")",
".",
"forEach",
"(",
"function",
"(",
"setting",
")",
"{",
"if",
"(",
"defaults",
".",
"hasOwnProperty",
"(",
"setting",
")",
")",
"{",
"prefs",
".",
"set",
"(",
"setting",
",",
"newSettings",
"[",
"setting",
"]",
")",
";",
"}",
"else",
"{",
"setterFn",
"=",
"\"set\"",
"+",
"setting",
"[",
"0",
"]",
".",
"toLocaleUpperCase",
"(",
")",
"+",
"setting",
".",
"substr",
"(",
"1",
")",
";",
"if",
"(",
"typeof",
"ViewCommandHandlers",
"[",
"setterFn",
"]",
"===",
"\"function\"",
")",
"{",
"ViewCommandHandlers",
"[",
"setterFn",
"]",
"(",
"newSettings",
"[",
"setting",
"]",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"id",
"===",
"\"cancel\"",
")",
"{",
"prefs",
".",
"set",
"(",
"\"theme\"",
",",
"currentSettings",
".",
"theme",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Opens the settings dialog
|
[
"Opens",
"the",
"settings",
"dialog"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/ThemeSettings.js#L78-L155
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
getCurrentDocument
|
function getCurrentDocument() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
return getOpenDocumentForPath(file.fullPath);
}
return null;
}
|
javascript
|
function getCurrentDocument() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
return getOpenDocumentForPath(file.fullPath);
}
return null;
}
|
[
"function",
"getCurrentDocument",
"(",
")",
"{",
"var",
"file",
"=",
"MainViewManager",
".",
"getCurrentlyViewedFile",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
";",
"if",
"(",
"file",
")",
"{",
"return",
"getOpenDocumentForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the Document that is currently open in the editor UI. May be null.
@return {?Document}
|
[
"Returns",
"the",
"Document",
"that",
"is",
"currently",
"open",
"in",
"the",
"editor",
"UI",
".",
"May",
"be",
"null",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L140-L148
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
getWorkingSet
|
function getWorkingSet() {
DeprecationWarning.deprecationWarning("Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()", true);
return MainViewManager.getWorkingSet(MainViewManager.ALL_PANES)
.filter(function (file) {
// Legacy didn't allow for files with custom viewers
return !MainViewFactory.findSuitableFactoryForPath(file.fullPath);
});
}
|
javascript
|
function getWorkingSet() {
DeprecationWarning.deprecationWarning("Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()", true);
return MainViewManager.getWorkingSet(MainViewManager.ALL_PANES)
.filter(function (file) {
// Legacy didn't allow for files with custom viewers
return !MainViewFactory.findSuitableFactoryForPath(file.fullPath);
});
}
|
[
"function",
"getWorkingSet",
"(",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()\"",
",",
"true",
")",
";",
"return",
"MainViewManager",
".",
"getWorkingSet",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"!",
"MainViewFactory",
".",
"findSuitableFactoryForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
")",
";",
"}"
] |
Returns a list of items in the working set in UI list order. May be 0-length, but never null.
@deprecated Use MainViewManager.getWorkingSet() instead
@return {Array.<File>}
|
[
"Returns",
"a",
"list",
"of",
"items",
"in",
"the",
"working",
"set",
"in",
"UI",
"list",
"order",
".",
"May",
"be",
"0",
"-",
"length",
"but",
"never",
"null",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L156-L163
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
findInWorkingSet
|
function findInWorkingSet(fullPath) {
DeprecationWarning.deprecationWarning("Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()", true);
return MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, fullPath);
}
|
javascript
|
function findInWorkingSet(fullPath) {
DeprecationWarning.deprecationWarning("Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()", true);
return MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, fullPath);
}
|
[
"function",
"findInWorkingSet",
"(",
"fullPath",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()\"",
",",
"true",
")",
";",
"return",
"MainViewManager",
".",
"findInWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"fullPath",
")",
";",
"}"
] |
Returns the index of the file matching fullPath in the working set.
@deprecated Use MainViewManager.findInWorkingSet() instead
@param {!string} fullPath
@return {number} index, -1 if not found
|
[
"Returns",
"the",
"index",
"of",
"the",
"file",
"matching",
"fullPath",
"in",
"the",
"working",
"set",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L171-L174
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
addToWorkingSet
|
function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
}
|
javascript
|
function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
}
|
[
"function",
"addToWorkingSet",
"(",
"file",
",",
"index",
",",
"forceRedraw",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()\"",
",",
"true",
")",
";",
"MainViewManager",
".",
"addToWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"file",
",",
"index",
",",
"forceRedraw",
")",
";",
"}"
] |
Adds the given file to the end of the working set list.
@deprecated Use MainViewManager.addToWorkingSet() instead
@param {!File} file
@param {number=} index Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw If true, a working set change notification is always sent
(useful if suppressRedraw was used with removeFromWorkingSet() earlier)
|
[
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"working",
"set",
"list",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L202-L205
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
removeListFromWorkingSet
|
function removeListFromWorkingSet(list) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()", true);
CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list});
}
|
javascript
|
function removeListFromWorkingSet(list) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()", true);
CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list});
}
|
[
"function",
"removeListFromWorkingSet",
"(",
"list",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE_LIST",
",",
"{",
"PaneId",
":",
"MainViewManager",
".",
"ALL_PANES",
",",
"fileList",
":",
"list",
"}",
")",
";",
"}"
] |
closes a list of files
@deprecated Use CommandManager.execute(Commands.FILE_CLOSE_LIST) instead
@param {!Array.<File>} list - list of File objectgs to close
|
[
"closes",
"a",
"list",
"of",
"files"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L228-L231
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
closeAll
|
function closeAll() {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()", true);
CommandManager.execute(Commands.FILE_CLOSE_ALL, {PaneId: MainViewManager.ALL_PANES});
}
|
javascript
|
function closeAll() {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()", true);
CommandManager.execute(Commands.FILE_CLOSE_ALL, {PaneId: MainViewManager.ALL_PANES});
}
|
[
"function",
"closeAll",
"(",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE_ALL",
",",
"{",
"PaneId",
":",
"MainViewManager",
".",
"ALL_PANES",
"}",
")",
";",
"}"
] |
closes all open files
@deprecated CommandManager.execute(Commands.FILE_CLOSE_ALL) instead
|
[
"closes",
"all",
"open",
"files"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L237-L240
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
closeFullEditor
|
function closeFullEditor(file) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()", true);
CommandManager.execute(Commands.FILE_CLOSE, {File: file});
}
|
javascript
|
function closeFullEditor(file) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()", true);
CommandManager.execute(Commands.FILE_CLOSE, {File: file});
}
|
[
"function",
"closeFullEditor",
"(",
"file",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE",
",",
"{",
"File",
":",
"file",
"}",
")",
";",
"}"
] |
closes the specified file file
@deprecated use CommandManager.execute(Commands.FILE_CLOSE, {File: file}) instead
@param {!File} file - the file to close
|
[
"closes",
"the",
"specified",
"file",
"file"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L247-L250
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
setCurrentDocument
|
function setCurrentDocument(doc) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()", true);
CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath});
}
|
javascript
|
function setCurrentDocument(doc) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()", true);
CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath});
}
|
[
"function",
"setCurrentDocument",
"(",
"doc",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"CMD_OPEN",
",",
"{",
"fullPath",
":",
"doc",
".",
"file",
".",
"fullPath",
"}",
")",
";",
"}"
] |
opens the specified document for editing in the currently active pane
@deprecated use CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath}) instead
@param {!Document} document The Document to make current.
|
[
"opens",
"the",
"specified",
"document",
"for",
"editing",
"in",
"the",
"currently",
"active",
"pane"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L257-L260
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
notifyPathDeleted
|
function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
}
|
javascript
|
function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
}
|
[
"function",
"notifyPathDeleted",
"(",
"fullPath",
")",
"{",
"FileSyncManager",
".",
"syncOpenDocuments",
"(",
"Strings",
".",
"FILE_DELETED_TITLE",
")",
";",
"var",
"projectRoot",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
",",
"context",
"=",
"{",
"location",
":",
"{",
"scope",
":",
"\"user\"",
",",
"layer",
":",
"\"project\"",
",",
"layerID",
":",
"projectRoot",
".",
"fullPath",
"}",
"}",
";",
"var",
"encoding",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"encoding\"",
",",
"context",
")",
";",
"delete",
"encoding",
"[",
"fullPath",
"]",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"encoding\"",
",",
"encoding",
",",
"context",
")",
";",
"if",
"(",
"!",
"getOpenDocumentForPath",
"(",
"fullPath",
")",
"&&",
"!",
"MainViewManager",
".",
"findInAllWorkingSets",
"(",
"fullPath",
")",
".",
"length",
")",
"{",
"exports",
".",
"trigger",
"(",
"\"pathDeleted\"",
",",
"fullPath",
")",
";",
"}",
"}"
] |
Called after a file or folder has been deleted. This function is responsible
for updating underlying model data and notifying all views of the change.
@param {string} fullPath The path of the file/folder that has been deleted
|
[
"Called",
"after",
"a",
"file",
"or",
"folder",
"has",
"been",
"deleted",
".",
"This",
"function",
"is",
"responsible",
"for",
"updating",
"underlying",
"model",
"data",
"and",
"notifying",
"all",
"views",
"of",
"the",
"change",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L497-L522
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
notifyPathNameChanged
|
function notifyPathNameChanged(oldName, newName) {
// Notify all open documents
_.forEach(_openDocuments, function (doc) {
// TODO: Only notify affected documents? For now _notifyFilePathChange
// just updates the language if the extension changed, so it's fine
// to call for all open docs.
doc._notifyFilePathChanged();
});
// Send a "fileNameChange" event. This will trigger the views to update.
exports.trigger("fileNameChange", oldName, newName);
}
|
javascript
|
function notifyPathNameChanged(oldName, newName) {
// Notify all open documents
_.forEach(_openDocuments, function (doc) {
// TODO: Only notify affected documents? For now _notifyFilePathChange
// just updates the language if the extension changed, so it's fine
// to call for all open docs.
doc._notifyFilePathChanged();
});
// Send a "fileNameChange" event. This will trigger the views to update.
exports.trigger("fileNameChange", oldName, newName);
}
|
[
"function",
"notifyPathNameChanged",
"(",
"oldName",
",",
"newName",
")",
"{",
"_",
".",
"forEach",
"(",
"_openDocuments",
",",
"function",
"(",
"doc",
")",
"{",
"doc",
".",
"_notifyFilePathChanged",
"(",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"fileNameChange\"",
",",
"oldName",
",",
"newName",
")",
";",
"}"
] |
Called after a file or folder name has changed. This function is responsible
for updating underlying model data and notifying all views of the change.
@param {string} oldName The old name of the file/folder
@param {string} newName The new name of the file/folder
|
[
"Called",
"after",
"a",
"file",
"or",
"folder",
"name",
"has",
"changed",
".",
"This",
"function",
"is",
"responsible",
"for",
"updating",
"underlying",
"model",
"data",
"and",
"notifying",
"all",
"views",
"of",
"the",
"change",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L531-L542
|
train
|
adobe/brackets
|
src/document/DocumentManager.js
|
_proxyDeprecatedEvent
|
function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
}
|
javascript
|
function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
}
|
[
"function",
"_proxyDeprecatedEvent",
"(",
"eventName",
")",
"{",
"DeprecationWarning",
".",
"deprecateEvent",
"(",
"exports",
",",
"MainViewManager",
",",
"eventName",
",",
"eventName",
",",
"\"DocumentManager.\"",
"+",
"eventName",
",",
"\"MainViewManager.\"",
"+",
"eventName",
")",
";",
"}"
] |
Listens for the given event on MainViewManager, and triggers a copy of the event on DocumentManager whenever it occurs
|
[
"Listens",
"for",
"the",
"given",
"event",
"on",
"MainViewManager",
"and",
"triggers",
"a",
"copy",
"of",
"the",
"event",
"on",
"DocumentManager",
"whenever",
"it",
"occurs"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L651-L658
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
marker
|
function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
}
|
javascript
|
function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
}
|
[
"function",
"marker",
"(",
"spec",
")",
"{",
"var",
"elt",
"=",
"window",
".",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"elt",
".",
"className",
"=",
"spec",
";",
"return",
"elt",
";",
"}"
] |
Utility for creating fold markers in fold gutter
@param {string} spec the className for the marker
@return {HTMLElement} a htmlelement representing the fold marker
|
[
"Utility",
"for",
"creating",
"fold",
"markers",
"in",
"fold",
"gutter"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L29-L33
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
updateFoldInfo
|
function updateFoldInfo(cm, from, to) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var opts = cm.state.foldGutter.options;
var fade = prefs.getSetting("hideUntilMouseover");
var $gutter = $(cm.getGutterElement());
var i = from;
function clear(m) {
return m.clear();
}
/**
* @private
* helper function to check if the given line is in a folded region in the editor.
* @param {number} line the
* @return {Object} the range that hides the specified line or undefine if the line is not hidden
*/
function _isCurrentlyFolded(line) {
var keys = Object.keys(cm._lineFolds), i = 0, range;
while (i < keys.length) {
range = cm._lineFolds[keys[i]];
if (range.from.line < line && range.to.line >= line) {
return range;
}
i++;
}
}
/**
This case is needed when unfolding a region that does not cause the viewport to change.
For instance in a file with about 15 lines, if some code regions are folded and unfolded, the
viewport change event isn't fired by CodeMirror. The setTimeout is a workaround to trigger the
gutter update after the viewport has been drawn.
*/
if (i === to) {
window.setTimeout(function () {
var vp = cm.getViewport();
updateFoldInfo(cm, vp.from, vp.to);
}, 200);
}
while (i < to) {
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
range;
var mark = marker("CodeMirror-foldgutter-blank");
var pos = CodeMirror.Pos(i, 0),
func = opts.rangeFinder || CodeMirror.fold.auto;
// don't look inside collapsed ranges
if (sr) {
i = sr.to.line + 1;
} else {
range = cm._lineFolds[i] || (func && func(cm, pos));
if (!fade || (fade && $gutter.is(":hover"))) {
if (cm.isFolded(i)) {
// expand fold if invalid
if (range) {
mark = marker(opts.indicatorFolded);
} else {
cm.findMarksAt(pos).filter(isFold)
.forEach(clear);
}
} else {
if (range && range.to.line - range.from.line >= minFoldSize) {
mark = marker(opts.indicatorOpen);
}
}
}
cm.setGutterMarker(i, opts.gutter, mark);
i++;
}
}
}
|
javascript
|
function updateFoldInfo(cm, from, to) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var opts = cm.state.foldGutter.options;
var fade = prefs.getSetting("hideUntilMouseover");
var $gutter = $(cm.getGutterElement());
var i = from;
function clear(m) {
return m.clear();
}
/**
* @private
* helper function to check if the given line is in a folded region in the editor.
* @param {number} line the
* @return {Object} the range that hides the specified line or undefine if the line is not hidden
*/
function _isCurrentlyFolded(line) {
var keys = Object.keys(cm._lineFolds), i = 0, range;
while (i < keys.length) {
range = cm._lineFolds[keys[i]];
if (range.from.line < line && range.to.line >= line) {
return range;
}
i++;
}
}
/**
This case is needed when unfolding a region that does not cause the viewport to change.
For instance in a file with about 15 lines, if some code regions are folded and unfolded, the
viewport change event isn't fired by CodeMirror. The setTimeout is a workaround to trigger the
gutter update after the viewport has been drawn.
*/
if (i === to) {
window.setTimeout(function () {
var vp = cm.getViewport();
updateFoldInfo(cm, vp.from, vp.to);
}, 200);
}
while (i < to) {
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
range;
var mark = marker("CodeMirror-foldgutter-blank");
var pos = CodeMirror.Pos(i, 0),
func = opts.rangeFinder || CodeMirror.fold.auto;
// don't look inside collapsed ranges
if (sr) {
i = sr.to.line + 1;
} else {
range = cm._lineFolds[i] || (func && func(cm, pos));
if (!fade || (fade && $gutter.is(":hover"))) {
if (cm.isFolded(i)) {
// expand fold if invalid
if (range) {
mark = marker(opts.indicatorFolded);
} else {
cm.findMarksAt(pos).filter(isFold)
.forEach(clear);
}
} else {
if (range && range.to.line - range.from.line >= minFoldSize) {
mark = marker(opts.indicatorOpen);
}
}
}
cm.setGutterMarker(i, opts.gutter, mark);
i++;
}
}
}
|
[
"function",
"updateFoldInfo",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"minFoldSize",
"=",
"prefs",
".",
"getSetting",
"(",
"\"minFoldSize\"",
")",
"||",
"2",
";",
"var",
"opts",
"=",
"cm",
".",
"state",
".",
"foldGutter",
".",
"options",
";",
"var",
"fade",
"=",
"prefs",
".",
"getSetting",
"(",
"\"hideUntilMouseover\"",
")",
";",
"var",
"$gutter",
"=",
"$",
"(",
"cm",
".",
"getGutterElement",
"(",
")",
")",
";",
"var",
"i",
"=",
"from",
";",
"function",
"clear",
"(",
"m",
")",
"{",
"return",
"m",
".",
"clear",
"(",
")",
";",
"}",
"function",
"_isCurrentlyFolded",
"(",
"line",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"cm",
".",
"_lineFolds",
")",
",",
"i",
"=",
"0",
",",
"range",
";",
"while",
"(",
"i",
"<",
"keys",
".",
"length",
")",
"{",
"range",
"=",
"cm",
".",
"_lineFolds",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"range",
".",
"from",
".",
"line",
"<",
"line",
"&&",
"range",
".",
"to",
".",
"line",
">=",
"line",
")",
"{",
"return",
"range",
";",
"}",
"i",
"++",
";",
"}",
"}",
"if",
"(",
"i",
"===",
"to",
")",
"{",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"updateFoldInfo",
"(",
"cm",
",",
"vp",
".",
"from",
",",
"vp",
".",
"to",
")",
";",
"}",
",",
"200",
")",
";",
"}",
"while",
"(",
"i",
"<",
"to",
")",
"{",
"var",
"sr",
"=",
"_isCurrentlyFolded",
"(",
"i",
")",
",",
"range",
";",
"var",
"mark",
"=",
"marker",
"(",
"\"CodeMirror-foldgutter-blank\"",
")",
";",
"var",
"pos",
"=",
"CodeMirror",
".",
"Pos",
"(",
"i",
",",
"0",
")",
",",
"func",
"=",
"opts",
".",
"rangeFinder",
"||",
"CodeMirror",
".",
"fold",
".",
"auto",
";",
"if",
"(",
"sr",
")",
"{",
"i",
"=",
"sr",
".",
"to",
".",
"line",
"+",
"1",
";",
"}",
"else",
"{",
"range",
"=",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
"||",
"(",
"func",
"&&",
"func",
"(",
"cm",
",",
"pos",
")",
")",
";",
"if",
"(",
"!",
"fade",
"||",
"(",
"fade",
"&&",
"$gutter",
".",
"is",
"(",
"\":hover\"",
")",
")",
")",
"{",
"if",
"(",
"cm",
".",
"isFolded",
"(",
"i",
")",
")",
"{",
"if",
"(",
"range",
")",
"{",
"mark",
"=",
"marker",
"(",
"opts",
".",
"indicatorFolded",
")",
";",
"}",
"else",
"{",
"cm",
".",
"findMarksAt",
"(",
"pos",
")",
".",
"filter",
"(",
"isFold",
")",
".",
"forEach",
"(",
"clear",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"range",
"&&",
"range",
".",
"to",
".",
"line",
"-",
"range",
".",
"from",
".",
"line",
">=",
"minFoldSize",
")",
"{",
"mark",
"=",
"marker",
"(",
"opts",
".",
"indicatorOpen",
")",
";",
"}",
"}",
"}",
"cm",
".",
"setGutterMarker",
"(",
"i",
",",
"opts",
".",
"gutter",
",",
"mark",
")",
";",
"i",
"++",
";",
"}",
"}",
"}"
] |
Updates the gutter markers for the specified range
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!number} from the starting line for the update
@param {!number} to the ending line for the update
|
[
"Updates",
"the",
"gutter",
"markers",
"for",
"the",
"specified",
"range"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L50-L122
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
updateInViewport
|
function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
}
|
javascript
|
function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
}
|
[
"function",
"updateInViewport",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
",",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"from",
"=",
"isNaN",
"(",
"from",
")",
"?",
"vp",
".",
"from",
":",
"from",
";",
"to",
"=",
"isNaN",
"(",
"to",
")",
"?",
"vp",
".",
"to",
":",
"to",
";",
"if",
"(",
"!",
"state",
")",
"{",
"return",
";",
"}",
"cm",
".",
"operation",
"(",
"function",
"(",
")",
"{",
"updateFoldInfo",
"(",
"cm",
",",
"from",
",",
"to",
")",
";",
"}",
")",
";",
"state",
".",
"from",
"=",
"from",
";",
"state",
".",
"to",
"=",
"to",
";",
"}"
] |
Updates the fold information in the viewport for the specified range
@param {CodeMirror} cm the instance of the CodeMirror object
@param {?number} from the starting line number for the update
@param {?number} to the end line number for the update
|
[
"Updates",
"the",
"fold",
"information",
"in",
"the",
"viewport",
"for",
"the",
"specified",
"range"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L130-L141
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
getFoldOnLine
|
function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
}
|
javascript
|
function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
}
|
[
"function",
"getFoldOnLine",
"(",
"cm",
",",
"line",
")",
"{",
"var",
"pos",
"=",
"CodeMirror",
".",
"Pos",
"(",
"line",
",",
"0",
")",
";",
"var",
"folds",
"=",
"cm",
".",
"findMarksAt",
"(",
"pos",
")",
"||",
"[",
"]",
";",
"folds",
"=",
"folds",
".",
"filter",
"(",
"isFold",
")",
";",
"return",
"folds",
".",
"length",
"?",
"folds",
"[",
"0",
"]",
":",
"undefined",
";",
"}"
] |
Helper function to return the fold text marker on a line in an editor
@param {CodeMirror} cm The CodeMirror instance for the active editor
@param {Number} line The line number representing the position of the fold marker
@returns {TextMarker} A CodeMirror TextMarker object
|
[
"Helper",
"function",
"to",
"return",
"the",
"fold",
"text",
"marker",
"on",
"a",
"line",
"in",
"an",
"editor"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L149-L154
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
syncDocToFoldsCache
|
function syncDocToFoldsCache(cm, from, lineAdded) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var i, fold, range;
if (lineAdded <= 0) {
return;
}
for (i = from; i <= from + lineAdded; i = i + 1) {
fold = getFoldOnLine(cm, i);
if (fold) {
range = fold.find();
if (range && range.to.line - range.from.line >= minFoldSize) {
cm._lineFolds[i] = range;
i = range.to.line;
} else {
delete cm._lineFolds[i];
}
}
}
}
|
javascript
|
function syncDocToFoldsCache(cm, from, lineAdded) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var i, fold, range;
if (lineAdded <= 0) {
return;
}
for (i = from; i <= from + lineAdded; i = i + 1) {
fold = getFoldOnLine(cm, i);
if (fold) {
range = fold.find();
if (range && range.to.line - range.from.line >= minFoldSize) {
cm._lineFolds[i] = range;
i = range.to.line;
} else {
delete cm._lineFolds[i];
}
}
}
}
|
[
"function",
"syncDocToFoldsCache",
"(",
"cm",
",",
"from",
",",
"lineAdded",
")",
"{",
"var",
"minFoldSize",
"=",
"prefs",
".",
"getSetting",
"(",
"\"minFoldSize\"",
")",
"||",
"2",
";",
"var",
"i",
",",
"fold",
",",
"range",
";",
"if",
"(",
"lineAdded",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"i",
"=",
"from",
";",
"i",
"<=",
"from",
"+",
"lineAdded",
";",
"i",
"=",
"i",
"+",
"1",
")",
"{",
"fold",
"=",
"getFoldOnLine",
"(",
"cm",
",",
"i",
")",
";",
"if",
"(",
"fold",
")",
"{",
"range",
"=",
"fold",
".",
"find",
"(",
")",
";",
"if",
"(",
"range",
"&&",
"range",
".",
"to",
".",
"line",
"-",
"range",
".",
"from",
".",
"line",
">=",
"minFoldSize",
")",
"{",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
"=",
"range",
";",
"i",
"=",
"range",
".",
"to",
".",
"line",
";",
"}",
"else",
"{",
"delete",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
";",
"}",
"}",
"}",
"}"
] |
Synchronises the code folding states in the CM doc to cm._lineFolds cache.
When an undo operation is done, if folded code fragments are restored, then
we need to update cm._lineFolds with the fragments
@param {Object} cm cm the CodeMirror instance for the active editor
@param {Object} from starting position in the doc to sync the fold states from
@param {[[Type]]} lineAdded a number to show how many lines where added to the document
|
[
"Synchronises",
"the",
"code",
"folding",
"states",
"in",
"the",
"CM",
"doc",
"to",
"cm",
".",
"_lineFolds",
"cache",
".",
"When",
"an",
"undo",
"operation",
"is",
"done",
"if",
"folded",
"code",
"fragments",
"are",
"restored",
"then",
"we",
"need",
"to",
"update",
"cm",
".",
"_lineFolds",
"with",
"the",
"fragments"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L164-L183
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
moveRange
|
function moveRange(range, numLines) {
return {from: CodeMirror.Pos(range.from.line + numLines, range.from.ch),
to: CodeMirror.Pos(range.to.line + numLines, range.to.ch)};
}
|
javascript
|
function moveRange(range, numLines) {
return {from: CodeMirror.Pos(range.from.line + numLines, range.from.ch),
to: CodeMirror.Pos(range.to.line + numLines, range.to.ch)};
}
|
[
"function",
"moveRange",
"(",
"range",
",",
"numLines",
")",
"{",
"return",
"{",
"from",
":",
"CodeMirror",
".",
"Pos",
"(",
"range",
".",
"from",
".",
"line",
"+",
"numLines",
",",
"range",
".",
"from",
".",
"ch",
")",
",",
"to",
":",
"CodeMirror",
".",
"Pos",
"(",
"range",
".",
"to",
".",
"line",
"+",
"numLines",
",",
"range",
".",
"to",
".",
"ch",
")",
"}",
";",
"}"
] |
Helper function to move a fold range object by the specified number of lines
@param {Object} range An object specifying the fold range to move. It contains {from, to} which are CodeMirror.Pos objects.
@param {Number} numLines A positive or negative number representing the numbe of lines to move the range by
|
[
"Helper",
"function",
"to",
"move",
"a",
"fold",
"range",
"object",
"by",
"the",
"specified",
"number",
"of",
"lines"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L190-L193
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
onCursorActivity
|
function onCursorActivity(cm) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
window.clearTimeout(state.changeUpdate);
state.changeUpdate = window.setTimeout(function () {
//need to render the entire visible viewport to remove fold marks rendered from previous selections if any
updateInViewport(cm, vp.from, vp.to);
}, 400);
}
|
javascript
|
function onCursorActivity(cm) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
window.clearTimeout(state.changeUpdate);
state.changeUpdate = window.setTimeout(function () {
//need to render the entire visible viewport to remove fold marks rendered from previous selections if any
updateInViewport(cm, vp.from, vp.to);
}, 400);
}
|
[
"function",
"onCursorActivity",
"(",
"cm",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"window",
".",
"clearTimeout",
"(",
"state",
".",
"changeUpdate",
")",
";",
"state",
".",
"changeUpdate",
"=",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"updateInViewport",
"(",
"cm",
",",
"vp",
".",
"from",
",",
"vp",
".",
"to",
")",
";",
"}",
",",
"400",
")",
";",
"}"
] |
Triggered when the cursor moves in the editor and used to detect text selection changes
in the editor.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
|
[
"Triggered",
"when",
"the",
"cursor",
"moves",
"in",
"the",
"editor",
"and",
"used",
"to",
"detect",
"text",
"selection",
"changes",
"in",
"the",
"editor",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L327-L335
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
onFold
|
function onFold(cm, from, to) {
var state = cm.state.foldGutter;
updateFoldInfo(cm, from.line, from.line + 1);
}
|
javascript
|
function onFold(cm, from, to) {
var state = cm.state.foldGutter;
updateFoldInfo(cm, from.line, from.line + 1);
}
|
[
"function",
"onFold",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"updateFoldInfo",
"(",
"cm",
",",
"from",
".",
"line",
",",
"from",
".",
"line",
"+",
"1",
")",
";",
"}"
] |
Triggered when a code segment is folded.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!Object} from the ch and line position that designates the start of the region
@param {!Object} to the ch and line position that designates the end of the region
|
[
"Triggered",
"when",
"a",
"code",
"segment",
"is",
"folded",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L343-L346
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
onUnFold
|
function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
}
|
javascript
|
function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
}
|
[
"function",
"onUnFold",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"delete",
"cm",
".",
"_lineFolds",
"[",
"from",
".",
"line",
"]",
";",
"updateFoldInfo",
"(",
"cm",
",",
"from",
".",
"line",
",",
"to",
".",
"line",
"||",
"vp",
".",
"to",
")",
";",
"}"
] |
Triggered when a folded code segment is unfolded.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!{line:number, ch:number}} from the ch and line position that designates the start of the region
@param {!{line:number, ch:number}} to the ch and line position that designates the end of the region
|
[
"Triggered",
"when",
"a",
"folded",
"code",
"segment",
"is",
"unfolded",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L354-L359
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
|
init
|
function init() {
CodeMirror.defineOption("foldGutter", false, function (cm, val, old) {
if (old && old !== CodeMirror.Init) {
cm.clearGutter(cm.state.foldGutter.options.gutter);
cm.state.foldGutter = null;
cm.off("gutterClick", old.onGutterClick);
cm.off("change", onChange);
cm.off("viewportChange", onViewportChange);
cm.off("cursorActivity", onCursorActivity);
cm.off("fold", onFold);
cm.off("unfold", onUnFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
updateInViewport(cm);
cm.on("gutterClick", val.onGutterClick);
cm.on("change", onChange);
cm.on("viewportChange", onViewportChange);
cm.on("cursorActivity", onCursorActivity);
cm.on("fold", onFold);
cm.on("unfold", onUnFold);
cm.on("swapDoc", updateInViewport);
}
});
}
|
javascript
|
function init() {
CodeMirror.defineOption("foldGutter", false, function (cm, val, old) {
if (old && old !== CodeMirror.Init) {
cm.clearGutter(cm.state.foldGutter.options.gutter);
cm.state.foldGutter = null;
cm.off("gutterClick", old.onGutterClick);
cm.off("change", onChange);
cm.off("viewportChange", onViewportChange);
cm.off("cursorActivity", onCursorActivity);
cm.off("fold", onFold);
cm.off("unfold", onUnFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
updateInViewport(cm);
cm.on("gutterClick", val.onGutterClick);
cm.on("change", onChange);
cm.on("viewportChange", onViewportChange);
cm.on("cursorActivity", onCursorActivity);
cm.on("fold", onFold);
cm.on("unfold", onUnFold);
cm.on("swapDoc", updateInViewport);
}
});
}
|
[
"function",
"init",
"(",
")",
"{",
"CodeMirror",
".",
"defineOption",
"(",
"\"foldGutter\"",
",",
"false",
",",
"function",
"(",
"cm",
",",
"val",
",",
"old",
")",
"{",
"if",
"(",
"old",
"&&",
"old",
"!==",
"CodeMirror",
".",
"Init",
")",
"{",
"cm",
".",
"clearGutter",
"(",
"cm",
".",
"state",
".",
"foldGutter",
".",
"options",
".",
"gutter",
")",
";",
"cm",
".",
"state",
".",
"foldGutter",
"=",
"null",
";",
"cm",
".",
"off",
"(",
"\"gutterClick\"",
",",
"old",
".",
"onGutterClick",
")",
";",
"cm",
".",
"off",
"(",
"\"change\"",
",",
"onChange",
")",
";",
"cm",
".",
"off",
"(",
"\"viewportChange\"",
",",
"onViewportChange",
")",
";",
"cm",
".",
"off",
"(",
"\"cursorActivity\"",
",",
"onCursorActivity",
")",
";",
"cm",
".",
"off",
"(",
"\"fold\"",
",",
"onFold",
")",
";",
"cm",
".",
"off",
"(",
"\"unfold\"",
",",
"onUnFold",
")",
";",
"cm",
".",
"off",
"(",
"\"swapDoc\"",
",",
"updateInViewport",
")",
";",
"}",
"if",
"(",
"val",
")",
"{",
"cm",
".",
"state",
".",
"foldGutter",
"=",
"new",
"State",
"(",
"parseOptions",
"(",
"val",
")",
")",
";",
"updateInViewport",
"(",
"cm",
")",
";",
"cm",
".",
"on",
"(",
"\"gutterClick\"",
",",
"val",
".",
"onGutterClick",
")",
";",
"cm",
".",
"on",
"(",
"\"change\"",
",",
"onChange",
")",
";",
"cm",
".",
"on",
"(",
"\"viewportChange\"",
",",
"onViewportChange",
")",
";",
"cm",
".",
"on",
"(",
"\"cursorActivity\"",
",",
"onCursorActivity",
")",
";",
"cm",
".",
"on",
"(",
"\"fold\"",
",",
"onFold",
")",
";",
"cm",
".",
"on",
"(",
"\"unfold\"",
",",
"onUnFold",
")",
";",
"cm",
".",
"on",
"(",
"\"swapDoc\"",
",",
"updateInViewport",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Initialises the fold gutter and registers event handlers for changes to document, viewport
and user interactions.
|
[
"Initialises",
"the",
"fold",
"gutter",
"and",
"registers",
"event",
"handlers",
"for",
"changes",
"to",
"document",
"viewport",
"and",
"user",
"interactions",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L365-L391
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_getCondensedForm
|
function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
}
|
javascript
|
function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
}
|
[
"function",
"_getCondensedForm",
"(",
"filter",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"filter",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"filter",
".",
"length",
">",
"2",
")",
"{",
"return",
"filter",
".",
"slice",
"(",
"0",
",",
"2",
")",
".",
"join",
"(",
"\", \"",
")",
"+",
"\" \"",
"+",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"FILE_FILTER_CLIPPED_SUFFIX",
",",
"filter",
".",
"length",
"-",
"2",
")",
";",
"}",
"return",
"filter",
".",
"join",
"(",
"\", \"",
")",
";",
"}"
] |
Get the condensed form of the filter set by joining the first two in the set with
a comma separator and appending a short message with the number of filters being clipped.
@param {Array.<string>} filter
@return {string} Condensed form of filter set if `filter` is a valid array.
Otherwise, return an empty string.
|
[
"Get",
"the",
"condensed",
"form",
"of",
"the",
"filter",
"set",
"by",
"joining",
"the",
"first",
"two",
"in",
"the",
"set",
"with",
"a",
"comma",
"separator",
"and",
"appending",
"a",
"short",
"message",
"with",
"the",
"number",
"of",
"filters",
"being",
"clipped",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L74-L85
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_doPopulate
|
function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
}
|
javascript
|
function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
}
|
[
"function",
"_doPopulate",
"(",
")",
"{",
"var",
"dropdownItems",
"=",
"[",
"Strings",
".",
"NEW_FILE_FILTER",
",",
"Strings",
".",
"CLEAR_FILE_FILTER",
"]",
",",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
";",
"if",
"(",
"filterSets",
".",
"length",
")",
"{",
"dropdownItems",
".",
"push",
"(",
"\"---\"",
")",
";",
"filterSets",
"=",
"filterSets",
".",
"filter",
"(",
"function",
"(",
"filter",
")",
"{",
"return",
"(",
"_getCondensedForm",
"(",
"filter",
".",
"patterns",
")",
"!==",
"\"\"",
")",
";",
"}",
")",
";",
"dropdownItems",
"=",
"dropdownItems",
".",
"concat",
"(",
"filterSets",
")",
";",
"}",
"_picker",
".",
"items",
"=",
"dropdownItems",
";",
"}"
] |
Populate the list of dropdown menu with two filter commands and
the list of saved filter sets.
|
[
"Populate",
"the",
"list",
"of",
"dropdown",
"menu",
"with",
"two",
"filter",
"commands",
"and",
"the",
"list",
"of",
"saved",
"filter",
"sets",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L91-L108
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_getFilterIndex
|
function _getFilterIndex(filterSets, filter) {
var index = -1;
if (!filter || !filterSets.length) {
return index;
}
return _.findIndex(filterSets, _.partial(_.isEqual, filter));
}
|
javascript
|
function _getFilterIndex(filterSets, filter) {
var index = -1;
if (!filter || !filterSets.length) {
return index;
}
return _.findIndex(filterSets, _.partial(_.isEqual, filter));
}
|
[
"function",
"_getFilterIndex",
"(",
"filterSets",
",",
"filter",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"if",
"(",
"!",
"filter",
"||",
"!",
"filterSets",
".",
"length",
")",
"{",
"return",
"index",
";",
"}",
"return",
"_",
".",
"findIndex",
"(",
"filterSets",
",",
"_",
".",
"partial",
"(",
"_",
".",
"isEqual",
",",
"filter",
")",
")",
";",
"}"
] |
Find the index of a filter set in the list of saved filter sets.
@param {Array.<{name: string, patterns: Array.<string>}>} filterSets
@return {{name: string, patterns: Array.<string>}} filter
|
[
"Find",
"the",
"index",
"of",
"a",
"filter",
"set",
"in",
"the",
"list",
"of",
"saved",
"filter",
"sets",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L115-L123
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
filterFileList
|
function filterFileList(compiledFilter, files) {
if (!compiledFilter) {
return files;
}
var re = new RegExp(compiledFilter);
return files.filter(function (f) {
return !re.test(f.fullPath);
});
}
|
javascript
|
function filterFileList(compiledFilter, files) {
if (!compiledFilter) {
return files;
}
var re = new RegExp(compiledFilter);
return files.filter(function (f) {
return !re.test(f.fullPath);
});
}
|
[
"function",
"filterFileList",
"(",
"compiledFilter",
",",
"files",
")",
"{",
"if",
"(",
"!",
"compiledFilter",
")",
"{",
"return",
"files",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"compiledFilter",
")",
";",
"return",
"files",
".",
"filter",
"(",
"function",
"(",
"f",
")",
"{",
"return",
"!",
"re",
".",
"test",
"(",
"f",
".",
"fullPath",
")",
";",
"}",
")",
";",
"}"
] |
Returns a copy of 'files' filtered to just those that don't match any of the exclusion globs in the filter.
@param {?string} compiledFilter 'Compiled' filter object as returned by compile(), or null to no-op
@param {!Array.<File>} files
@return {!Array.<File>}
|
[
"Returns",
"a",
"copy",
"of",
"files",
"filtered",
"to",
"just",
"those",
"that",
"don",
"t",
"match",
"any",
"of",
"the",
"exclusion",
"globs",
"in",
"the",
"filter",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L285-L294
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
getPathsMatchingFilter
|
function getPathsMatchingFilter(compiledFilter, filePaths) {
if (!compiledFilter) {
return filePaths;
}
var re = new RegExp(compiledFilter);
return filePaths.filter(function (f) {
return f.match(re);
});
}
|
javascript
|
function getPathsMatchingFilter(compiledFilter, filePaths) {
if (!compiledFilter) {
return filePaths;
}
var re = new RegExp(compiledFilter);
return filePaths.filter(function (f) {
return f.match(re);
});
}
|
[
"function",
"getPathsMatchingFilter",
"(",
"compiledFilter",
",",
"filePaths",
")",
"{",
"if",
"(",
"!",
"compiledFilter",
")",
"{",
"return",
"filePaths",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"compiledFilter",
")",
";",
"return",
"filePaths",
".",
"filter",
"(",
"function",
"(",
"f",
")",
"{",
"return",
"f",
".",
"match",
"(",
"re",
")",
";",
"}",
")",
";",
"}"
] |
Returns a copy of 'file path' strings that match any of the exclusion globs in the filter.
@param {?string} compiledFilter 'Compiled' filter object as returned by compile(), or null to no-op
@param {!Array.<string>} An array with a list of full file paths that matches atleast one of the filter.
@return {!Array.<string>}
|
[
"Returns",
"a",
"copy",
"of",
"file",
"path",
"strings",
"that",
"match",
"any",
"of",
"the",
"exclusion",
"globs",
"in",
"the",
"filter",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L303-L312
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_handleDeleteFilter
|
function _handleDeleteFilter(e) {
// Remove the filter set from the preferences and
// clear the active filter set index from view state.
var filterSets = PreferencesManager.get("fileFilters") || [],
activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
filterSets.splice(filterIndex, 1);
PreferencesManager.set("fileFilters", filterSets);
if (activeFilterIndex === filterIndex) {
// Removing the active filter, so clear the active filter
// both in the view state.
setActiveFilter(null);
} else if (activeFilterIndex > filterIndex) {
// Adjust the active filter index after the removal of a filter set before it.
--activeFilterIndex;
setActiveFilter(filterSets[activeFilterIndex], activeFilterIndex);
}
_updatePicker();
_doPopulate();
_picker.refresh();
}
|
javascript
|
function _handleDeleteFilter(e) {
// Remove the filter set from the preferences and
// clear the active filter set index from view state.
var filterSets = PreferencesManager.get("fileFilters") || [],
activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
filterSets.splice(filterIndex, 1);
PreferencesManager.set("fileFilters", filterSets);
if (activeFilterIndex === filterIndex) {
// Removing the active filter, so clear the active filter
// both in the view state.
setActiveFilter(null);
} else if (activeFilterIndex > filterIndex) {
// Adjust the active filter index after the removal of a filter set before it.
--activeFilterIndex;
setActiveFilter(filterSets[activeFilterIndex], activeFilterIndex);
}
_updatePicker();
_doPopulate();
_picker.refresh();
}
|
[
"function",
"_handleDeleteFilter",
"(",
"e",
")",
"{",
"var",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
",",
"activeFilterIndex",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"activeFileFilter\"",
")",
",",
"filterIndex",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"data",
"(",
"\"index\"",
")",
"-",
"FIRST_FILTER_INDEX",
";",
"e",
".",
"stopPropagation",
"(",
")",
";",
"filterSets",
".",
"splice",
"(",
"filterIndex",
",",
"1",
")",
";",
"PreferencesManager",
".",
"set",
"(",
"\"fileFilters\"",
",",
"filterSets",
")",
";",
"if",
"(",
"activeFilterIndex",
"===",
"filterIndex",
")",
"{",
"setActiveFilter",
"(",
"null",
")",
";",
"}",
"else",
"if",
"(",
"activeFilterIndex",
">",
"filterIndex",
")",
"{",
"--",
"activeFilterIndex",
";",
"setActiveFilter",
"(",
"filterSets",
"[",
"activeFilterIndex",
"]",
",",
"activeFilterIndex",
")",
";",
"}",
"_updatePicker",
"(",
")",
";",
"_doPopulate",
"(",
")",
";",
"_picker",
".",
"refresh",
"(",
")",
";",
"}"
] |
Remove the target item from the filter dropdown list and update dropdown button
and dropdown list UI.
@param {!Event} e Mouse events
|
[
"Remove",
"the",
"target",
"item",
"from",
"the",
"filter",
"dropdown",
"list",
"and",
"update",
"dropdown",
"button",
"and",
"dropdown",
"list",
"UI",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L434-L460
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_handleEditFilter
|
function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
}
|
javascript
|
function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
}
|
[
"function",
"_handleEditFilter",
"(",
"e",
")",
"{",
"var",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
",",
"filterIndex",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"data",
"(",
"\"index\"",
")",
"-",
"FIRST_FILTER_INDEX",
";",
"e",
".",
"stopPropagation",
"(",
")",
";",
"_picker",
".",
"closeDropdown",
"(",
")",
";",
"editFilter",
"(",
"filterSets",
"[",
"filterIndex",
"]",
",",
"filterIndex",
")",
";",
"}"
] |
Close filter dropdwon list and launch edit filter dialog.
@param {!Event} e Mouse events
|
[
"Close",
"filter",
"dropdwon",
"list",
"and",
"launch",
"edit",
"filter",
"dialog",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L466-L479
|
train
|
adobe/brackets
|
src/search/FileFilters.js
|
_handleListRendered
|
function _handleListRendered(event, $dropdown) {
var activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
checkedItemIndex = (activeFilterIndex > -1) ? (activeFilterIndex + FIRST_FILTER_INDEX) : -1;
_picker.setChecked(checkedItemIndex, true);
$dropdown.find(".filter-trash-icon")
.on("click", _handleDeleteFilter);
$dropdown.find(".filter-edit-icon")
.on("click", _handleEditFilter);
}
|
javascript
|
function _handleListRendered(event, $dropdown) {
var activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
checkedItemIndex = (activeFilterIndex > -1) ? (activeFilterIndex + FIRST_FILTER_INDEX) : -1;
_picker.setChecked(checkedItemIndex, true);
$dropdown.find(".filter-trash-icon")
.on("click", _handleDeleteFilter);
$dropdown.find(".filter-edit-icon")
.on("click", _handleEditFilter);
}
|
[
"function",
"_handleListRendered",
"(",
"event",
",",
"$dropdown",
")",
"{",
"var",
"activeFilterIndex",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"activeFileFilter\"",
")",
",",
"checkedItemIndex",
"=",
"(",
"activeFilterIndex",
">",
"-",
"1",
")",
"?",
"(",
"activeFilterIndex",
"+",
"FIRST_FILTER_INDEX",
")",
":",
"-",
"1",
";",
"_picker",
".",
"setChecked",
"(",
"checkedItemIndex",
",",
"true",
")",
";",
"$dropdown",
".",
"find",
"(",
"\".filter-trash-icon\"",
")",
".",
"on",
"(",
"\"click\"",
",",
"_handleDeleteFilter",
")",
";",
"$dropdown",
".",
"find",
"(",
"\".filter-edit-icon\"",
")",
".",
"on",
"(",
"\"click\"",
",",
"_handleEditFilter",
")",
";",
"}"
] |
Set up mouse click event listeners for 'Delete' and 'Edit' buttons
when the dropdown is open. Also set check mark on the active filter.
@param {!Event>} event listRendered event triggered when the dropdown is open
@param {!jQueryObject} $dropdown the jQuery DOM node of the dropdown list
|
[
"Set",
"up",
"mouse",
"click",
"event",
"listeners",
"for",
"Delete",
"and",
"Edit",
"buttons",
"when",
"the",
"dropdown",
"is",
"open",
".",
"Also",
"set",
"check",
"mark",
"on",
"the",
"active",
"filter",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L487-L497
|
train
|
adobe/brackets
|
src/search/FindInFilesUI.js
|
searchAndShowResults
|
function searchAndShowResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: show results
if (FindInFiles.searchModel.hasResults()) {
_resultsView.open();
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
} else {
_resultsView.close();
if (_findBar) {
var showMessage = false;
_findBar.enable(true);
if (zeroFilesToken === FindInFiles.ZERO_FILES_TO_SEARCH) {
_findBar.showError(StringUtils.format(Strings.FIND_IN_FILES_ZERO_FILES,
FindUtils.labelForScope(FindInFiles.searchModel.scope)), true);
} else {
showMessage = true;
}
_findBar.showNoResults(true, showMessage);
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("find in files failed: ", err);
StatusBar.hideBusyIndicator();
});
}
|
javascript
|
function searchAndShowResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: show results
if (FindInFiles.searchModel.hasResults()) {
_resultsView.open();
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
} else {
_resultsView.close();
if (_findBar) {
var showMessage = false;
_findBar.enable(true);
if (zeroFilesToken === FindInFiles.ZERO_FILES_TO_SEARCH) {
_findBar.showError(StringUtils.format(Strings.FIND_IN_FILES_ZERO_FILES,
FindUtils.labelForScope(FindInFiles.searchModel.scope)), true);
} else {
showMessage = true;
}
_findBar.showNoResults(true, showMessage);
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("find in files failed: ", err);
StatusBar.hideBusyIndicator();
});
}
|
[
"function",
"searchAndShowResults",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"return",
"FindInFiles",
".",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
".",
"done",
"(",
"function",
"(",
"zeroFilesToken",
")",
"{",
"if",
"(",
"FindInFiles",
".",
"searchModel",
".",
"hasResults",
"(",
")",
")",
"{",
"_resultsView",
".",
"open",
"(",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"_findBar",
".",
"focus",
"(",
")",
";",
"}",
"}",
"else",
"{",
"_resultsView",
".",
"close",
"(",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"var",
"showMessage",
"=",
"false",
";",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"if",
"(",
"zeroFilesToken",
"===",
"FindInFiles",
".",
"ZERO_FILES_TO_SEARCH",
")",
"{",
"_findBar",
".",
"showError",
"(",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"FIND_IN_FILES_ZERO_FILES",
",",
"FindUtils",
".",
"labelForScope",
"(",
"FindInFiles",
".",
"searchModel",
".",
"scope",
")",
")",
",",
"true",
")",
";",
"}",
"else",
"{",
"showMessage",
"=",
"true",
";",
"}",
"_findBar",
".",
"showNoResults",
"(",
"true",
",",
"showMessage",
")",
";",
"}",
"}",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"find in files failed: \"",
",",
"err",
")",
";",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Does a search in the given scope with the given filter. Shows the result list once the search is complete.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes.
|
[
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Shows",
"the",
"result",
"list",
"once",
"the",
"search",
"is",
"complete",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L81-L115
|
train
|
adobe/brackets
|
src/search/FindInFilesUI.js
|
searchAndReplaceResults
|
function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
}
|
javascript
|
function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
}
|
[
"function",
"searchAndReplaceResults",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"return",
"FindInFiles",
".",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
".",
"done",
"(",
"function",
"(",
"zeroFilesToken",
")",
"{",
"if",
"(",
"FindInFiles",
".",
"searchModel",
".",
"hasResults",
"(",
")",
")",
"{",
"_finishReplaceBatch",
"(",
"FindInFiles",
".",
"searchModel",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"_findBar",
".",
"focus",
"(",
")",
";",
"}",
"}",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"replace all failed: \"",
",",
"err",
")",
";",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Does a search in the given scope with the given filter. Replace the result list once the search is complete.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes.
|
[
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Replace",
"the",
"result",
"list",
"once",
"the",
"search",
"is",
"complete",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L127-L146
|
train
|
adobe/brackets
|
src/search/FindInFilesUI.js
|
_defferedSearch
|
function _defferedSearch() {
if (_findBar && _findBar._options.multifile && !_findBar._options.replace) {
_findBar.redoInstantSearch();
}
}
|
javascript
|
function _defferedSearch() {
if (_findBar && _findBar._options.multifile && !_findBar._options.replace) {
_findBar.redoInstantSearch();
}
}
|
[
"function",
"_defferedSearch",
"(",
")",
"{",
"if",
"(",
"_findBar",
"&&",
"_findBar",
".",
"_options",
".",
"multifile",
"&&",
"!",
"_findBar",
".",
"_options",
".",
"replace",
")",
"{",
"_findBar",
".",
"redoInstantSearch",
"(",
")",
";",
"}",
"}"
] |
Issues a search if find bar is visible and is multi file search and not instant search
|
[
"Issues",
"a",
"search",
"if",
"find",
"bar",
"is",
"visible",
"and",
"is",
"multi",
"file",
"search",
"and",
"not",
"instant",
"search"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L437-L441
|
train
|
adobe/brackets
|
src/widgets/ModalBar.js
|
ModalBar
|
function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
}
|
javascript
|
function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
}
|
[
"function",
"ModalBar",
"(",
"template",
",",
"autoClose",
",",
"animate",
")",
"{",
"if",
"(",
"animate",
"===",
"undefined",
")",
"{",
"animate",
"=",
"true",
";",
"}",
"this",
".",
"_handleKeydown",
"=",
"this",
".",
"_handleKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleFocusChange",
"=",
"this",
".",
"_handleFocusChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_$root",
"=",
"$",
"(",
"\"<div class='modal-bar'/>\"",
")",
".",
"html",
"(",
"template",
")",
".",
"insertBefore",
"(",
"\"#editor-holder\"",
")",
";",
"if",
"(",
"animate",
")",
"{",
"this",
".",
"_$root",
".",
"addClass",
"(",
"\"popout offscreen\"",
")",
";",
"window",
".",
"getComputedStyle",
"(",
"this",
".",
"_$root",
".",
"get",
"(",
"0",
")",
")",
".",
"getPropertyValue",
"(",
"\"top\"",
")",
";",
"this",
".",
"_$root",
".",
"removeClass",
"(",
"\"popout offscreen\"",
")",
";",
"}",
"MainViewManager",
".",
"focusActivePane",
"(",
")",
";",
"if",
"(",
"autoClose",
")",
"{",
"this",
".",
"_autoClose",
"=",
"true",
";",
"this",
".",
"_$root",
".",
"on",
"(",
"\"keydown\"",
",",
"this",
".",
"_handleKeydown",
")",
";",
"window",
".",
"document",
".",
"body",
".",
"addEventListener",
"(",
"\"focusin\"",
",",
"this",
".",
"_handleFocusChange",
",",
"true",
")",
";",
"var",
"$firstInput",
"=",
"$",
"(",
"\"input[type='text']\"",
",",
"this",
".",
"_$root",
")",
".",
"first",
"(",
")",
";",
"if",
"(",
"$firstInput",
".",
"length",
">",
"0",
")",
"{",
"$firstInput",
".",
"focus",
"(",
")",
";",
"}",
"else",
"{",
"$",
"(",
"\"button\"",
",",
"this",
".",
"_$root",
")",
".",
"first",
"(",
")",
".",
"focus",
"(",
")",
";",
"}",
"}",
"MainViewManager",
".",
"cacheScrollState",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
";",
"WorkspaceManager",
".",
"recomputeLayout",
"(",
")",
";",
"MainViewManager",
".",
"restoreAdjustedScrollState",
"(",
"MainViewManager",
".",
"ALL_PANES",
",",
"this",
".",
"height",
"(",
")",
")",
";",
"}"
] |
Creates a modal bar whose contents are the given template.
Dispatches one event:
- close - When the bar is closed, either via close() or via autoClose. After this event, the
bar may remain visible and in the DOM while its closing animation is playing. However,
by the time "close" is fired, the bar has been "popped out" of the layout and the
editor scroll position has already been restored.
Second argument is the reason for closing (one of ModalBar.CLOSE_*).
Third argument is the Promise that close() will be returning.
@constructor
@param {string} template The HTML contents of the modal bar.
@param {boolean} autoClose If true, then close the dialog if the user hits Esc
or if the bar loses focus.
@param {boolean} animate If true (the default), animate the dialog closed, otherwise
close it immediately.
|
[
"Creates",
"a",
"modal",
"bar",
"whose",
"contents",
"are",
"the",
"given",
"template",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/ModalBar.js#L56-L102
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/Prefs.js
|
simplify
|
function simplify(folds) {
if (!folds) {
return;
}
var res = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]];
});
return res;
}
|
javascript
|
function simplify(folds) {
if (!folds) {
return;
}
var res = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]];
});
return res;
}
|
[
"function",
"simplify",
"(",
"folds",
")",
"{",
"if",
"(",
"!",
"folds",
")",
"{",
"return",
";",
"}",
"var",
"res",
"=",
"{",
"}",
",",
"range",
";",
"Object",
".",
"keys",
"(",
"folds",
")",
".",
"forEach",
"(",
"function",
"(",
"line",
")",
"{",
"range",
"=",
"folds",
"[",
"line",
"]",
";",
"res",
"[",
"line",
"]",
"=",
"Array",
".",
"isArray",
"(",
"range",
")",
"?",
"range",
":",
"[",
"[",
"range",
".",
"from",
".",
"line",
",",
"range",
".",
"from",
".",
"ch",
"]",
",",
"[",
"range",
".",
"to",
".",
"line",
",",
"range",
".",
"to",
".",
"ch",
"]",
"]",
";",
"}",
")",
";",
"return",
"res",
";",
"}"
] |
Simplifies the fold ranges into an array of pairs of numbers.
@param {!Object} folds the raw fold ranges indexed by line numbers
@return {Object} an object whose keys are line numbers and the values are array
of two 2-element arrays. First array contains [from.line, from.ch] and the second contains [to.line, to.ch]
|
[
"Simplifies",
"the",
"fold",
"ranges",
"into",
"an",
"array",
"of",
"pairs",
"of",
"numbers",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L49-L59
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/Prefs.js
|
getFolds
|
function getFolds(path) {
var context = getViewStateContext();
var folds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
return inflate(folds[path]);
}
|
javascript
|
function getFolds(path) {
var context = getViewStateContext();
var folds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
return inflate(folds[path]);
}
|
[
"function",
"getFolds",
"(",
"path",
")",
"{",
"var",
"context",
"=",
"getViewStateContext",
"(",
")",
";",
"var",
"folds",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"FOLDS_PREF_KEY",
",",
"context",
")",
";",
"return",
"inflate",
"(",
"folds",
"[",
"path",
"]",
")",
";",
"}"
] |
Gets the line folds saved for the specified path.
@param {string} path the document path
@return {Object} the line folds for the document at the specified path
|
[
"Gets",
"the",
"line",
"folds",
"saved",
"for",
"the",
"specified",
"path",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L97-L101
|
train
|
adobe/brackets
|
src/extensions/default/CodeFolding/Prefs.js
|
setFolds
|
function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
}
|
javascript
|
function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
}
|
[
"function",
"setFolds",
"(",
"path",
",",
"folds",
")",
"{",
"var",
"context",
"=",
"getViewStateContext",
"(",
")",
";",
"var",
"allFolds",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"FOLDS_PREF_KEY",
",",
"context",
")",
";",
"allFolds",
"[",
"path",
"]",
"=",
"simplify",
"(",
"folds",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"FOLDS_PREF_KEY",
",",
"allFolds",
",",
"context",
")",
";",
"}"
] |
Saves the line folds for the specified path
@param {!string} path the path to the document
@param {Object} folds the fold ranges to save for the current document
|
[
"Saves",
"the",
"line",
"folds",
"for",
"the",
"specified",
"path"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L108-L113
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
_convertToNumber
|
function _convertToNumber(str) {
if (typeof str !== "string") {
return { isNumber: false, value: null };
}
var val = parseFloat(+str, 10),
isNum = (typeof val === "number") && !isNaN(val) &&
(val !== Infinity) && (val !== -Infinity);
return {
isNumber: isNum,
value: val
};
}
|
javascript
|
function _convertToNumber(str) {
if (typeof str !== "string") {
return { isNumber: false, value: null };
}
var val = parseFloat(+str, 10),
isNum = (typeof val === "number") && !isNaN(val) &&
(val !== Infinity) && (val !== -Infinity);
return {
isNumber: isNum,
value: val
};
}
|
[
"function",
"_convertToNumber",
"(",
"str",
")",
"{",
"if",
"(",
"typeof",
"str",
"!==",
"\"string\"",
")",
"{",
"return",
"{",
"isNumber",
":",
"false",
",",
"value",
":",
"null",
"}",
";",
"}",
"var",
"val",
"=",
"parseFloat",
"(",
"+",
"str",
",",
"10",
")",
",",
"isNum",
"=",
"(",
"typeof",
"val",
"===",
"\"number\"",
")",
"&&",
"!",
"isNaN",
"(",
"val",
")",
"&&",
"(",
"val",
"!==",
"Infinity",
")",
"&&",
"(",
"val",
"!==",
"-",
"Infinity",
")",
";",
"return",
"{",
"isNumber",
":",
"isNum",
",",
"value",
":",
"val",
"}",
";",
"}"
] |
If string is a number, then convert it.
@param {string} str value parsed from page.
@return { isNumber: boolean, value: ?number }
|
[
"If",
"string",
"is",
"a",
"number",
"then",
"convert",
"it",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L64-L77
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
_getValidBezierParams
|
function _getValidBezierParams(match) {
var param,
// take ease-in-out as default value in case there are no params yet (or they are invalid)
def = [ ".42", "0", ".58", "1" ],
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0],
i;
if (match) {
match = match[1].split(",");
}
if (match) {
for (i = 0; i <= 3; i++) {
if (match[i]) {
match[i] = match[i].trim();
param = _convertToNumber(match[i]);
// Verify the param is a number
// If not, replace it with the default value
if (!param.isNumber) {
match[i] = undefined;
// Verify x coordinates are in 0-1 range
// If not, set them to the closest value in range
} else if (i === 0 || i === 2) {
if (param.value < 0) {
match[i] = "0";
} else if (param.value > 1) {
match[i] = "1";
}
}
}
if (!match[i]) {
match[i] = def[i];
}
}
} else {
match = def;
}
match = match.splice(0, 4); // make sure there are only 4 params
match = "cubic-bezier(" + match.join(", ") + ")";
match = match.match(BEZIER_CURVE_VALID_REGEX);
if (match) {
match.index = oldIndex; // re-set the index here to get the right context
match.originalString = originalString;
return match;
}
return null;
}
|
javascript
|
function _getValidBezierParams(match) {
var param,
// take ease-in-out as default value in case there are no params yet (or they are invalid)
def = [ ".42", "0", ".58", "1" ],
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0],
i;
if (match) {
match = match[1].split(",");
}
if (match) {
for (i = 0; i <= 3; i++) {
if (match[i]) {
match[i] = match[i].trim();
param = _convertToNumber(match[i]);
// Verify the param is a number
// If not, replace it with the default value
if (!param.isNumber) {
match[i] = undefined;
// Verify x coordinates are in 0-1 range
// If not, set them to the closest value in range
} else if (i === 0 || i === 2) {
if (param.value < 0) {
match[i] = "0";
} else if (param.value > 1) {
match[i] = "1";
}
}
}
if (!match[i]) {
match[i] = def[i];
}
}
} else {
match = def;
}
match = match.splice(0, 4); // make sure there are only 4 params
match = "cubic-bezier(" + match.join(", ") + ")";
match = match.match(BEZIER_CURVE_VALID_REGEX);
if (match) {
match.index = oldIndex; // re-set the index here to get the right context
match.originalString = originalString;
return match;
}
return null;
}
|
[
"function",
"_getValidBezierParams",
"(",
"match",
")",
"{",
"var",
"param",
",",
"def",
"=",
"[",
"\".42\"",
",",
"\"0\"",
",",
"\".58\"",
",",
"\"1\"",
"]",
",",
"oldIndex",
"=",
"match",
".",
"index",
",",
"originalString",
"=",
"match",
"[",
"0",
"]",
",",
"i",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"match",
"[",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"match",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<=",
"3",
";",
"i",
"++",
")",
"{",
"if",
"(",
"match",
"[",
"i",
"]",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"match",
"[",
"i",
"]",
".",
"trim",
"(",
")",
";",
"param",
"=",
"_convertToNumber",
"(",
"match",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"param",
".",
"isNumber",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"undefined",
";",
"}",
"else",
"if",
"(",
"i",
"===",
"0",
"||",
"i",
"===",
"2",
")",
"{",
"if",
"(",
"param",
".",
"value",
"<",
"0",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"\"0\"",
";",
"}",
"else",
"if",
"(",
"param",
".",
"value",
">",
"1",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"\"1\"",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"match",
"[",
"i",
"]",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"def",
"[",
"i",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"match",
"=",
"def",
";",
"}",
"match",
"=",
"match",
".",
"splice",
"(",
"0",
",",
"4",
")",
";",
"match",
"=",
"\"cubic-bezier(\"",
"+",
"match",
".",
"join",
"(",
"\", \"",
")",
"+",
"\")\"",
";",
"match",
"=",
"match",
".",
"match",
"(",
"BEZIER_CURVE_VALID_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
".",
"index",
"=",
"oldIndex",
";",
"match",
".",
"originalString",
"=",
"originalString",
";",
"return",
"match",
";",
"}",
"return",
"null",
";",
"}"
] |
Get valid params for an invalid cubic-bezier.
@param {RegExp.match} match (Invalid) matches from cubicBezierMatch()
@return {?RegExp.match} Valid match or null if the output is not valid
|
[
"Get",
"valid",
"params",
"for",
"an",
"invalid",
"cubic",
"-",
"bezier",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L85-L136
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
_getValidStepsParams
|
function _getValidStepsParams(match) {
var param,
def = [ "5", "end" ],
params = def,
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0];
if (match) {
match = match[1].split(",");
}
if (match) {
if (match[0]) {
param = match[0].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = _convertToNumber(param);
// Verify number_of_params is a number
// If not, replace it with the default value
if (!param.isNumber) {
param.value = def[0];
// Round number_of_params to an integer
} else if (param.value) {
param.value = Math.floor(param.value);
}
// Verify number_of_steps is >= 1
// If not, set them to the default value
if (param.value < 1) {
param.value = def[0];
}
params[0] = param.value;
}
if (match[1]) {
// little autocorrect feature: leading s gets 'start', everything else gets 'end'
param = match[1].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = param.substr(0, 1);
if (param === "s") {
params[1] = "start";
} else {
params[1] = "end";
}
}
}
params = "steps(" + params.join(", ") + ")";
params = params.match(STEPS_VALID_REGEX);
if (params) {
params.index = oldIndex; // re-set the index here to get the right context
params.originalString = originalString;
return params;
}
return null;
}
|
javascript
|
function _getValidStepsParams(match) {
var param,
def = [ "5", "end" ],
params = def,
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0];
if (match) {
match = match[1].split(",");
}
if (match) {
if (match[0]) {
param = match[0].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = _convertToNumber(param);
// Verify number_of_params is a number
// If not, replace it with the default value
if (!param.isNumber) {
param.value = def[0];
// Round number_of_params to an integer
} else if (param.value) {
param.value = Math.floor(param.value);
}
// Verify number_of_steps is >= 1
// If not, set them to the default value
if (param.value < 1) {
param.value = def[0];
}
params[0] = param.value;
}
if (match[1]) {
// little autocorrect feature: leading s gets 'start', everything else gets 'end'
param = match[1].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = param.substr(0, 1);
if (param === "s") {
params[1] = "start";
} else {
params[1] = "end";
}
}
}
params = "steps(" + params.join(", ") + ")";
params = params.match(STEPS_VALID_REGEX);
if (params) {
params.index = oldIndex; // re-set the index here to get the right context
params.originalString = originalString;
return params;
}
return null;
}
|
[
"function",
"_getValidStepsParams",
"(",
"match",
")",
"{",
"var",
"param",
",",
"def",
"=",
"[",
"\"5\"",
",",
"\"end\"",
"]",
",",
"params",
"=",
"def",
",",
"oldIndex",
"=",
"match",
".",
"index",
",",
"originalString",
"=",
"match",
"[",
"0",
"]",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"match",
"[",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"match",
")",
"{",
"if",
"(",
"match",
"[",
"0",
"]",
")",
"{",
"param",
"=",
"match",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"[\\s\\\"']",
"/",
"g",
",",
"\"\"",
")",
";",
"param",
"=",
"_convertToNumber",
"(",
"param",
")",
";",
"if",
"(",
"!",
"param",
".",
"isNumber",
")",
"{",
"param",
".",
"value",
"=",
"def",
"[",
"0",
"]",
";",
"}",
"else",
"if",
"(",
"param",
".",
"value",
")",
"{",
"param",
".",
"value",
"=",
"Math",
".",
"floor",
"(",
"param",
".",
"value",
")",
";",
"}",
"if",
"(",
"param",
".",
"value",
"<",
"1",
")",
"{",
"param",
".",
"value",
"=",
"def",
"[",
"0",
"]",
";",
"}",
"params",
"[",
"0",
"]",
"=",
"param",
".",
"value",
";",
"}",
"if",
"(",
"match",
"[",
"1",
"]",
")",
"{",
"param",
"=",
"match",
"[",
"1",
"]",
".",
"replace",
"(",
"/",
"[\\s\\\"']",
"/",
"g",
",",
"\"\"",
")",
";",
"param",
"=",
"param",
".",
"substr",
"(",
"0",
",",
"1",
")",
";",
"if",
"(",
"param",
"===",
"\"s\"",
")",
"{",
"params",
"[",
"1",
"]",
"=",
"\"start\"",
";",
"}",
"else",
"{",
"params",
"[",
"1",
"]",
"=",
"\"end\"",
";",
"}",
"}",
"}",
"params",
"=",
"\"steps(\"",
"+",
"params",
".",
"join",
"(",
"\", \"",
")",
"+",
"\")\"",
";",
"params",
"=",
"params",
".",
"match",
"(",
"STEPS_VALID_REGEX",
")",
";",
"if",
"(",
"params",
")",
"{",
"params",
".",
"index",
"=",
"oldIndex",
";",
"params",
".",
"originalString",
"=",
"originalString",
";",
"return",
"params",
";",
"}",
"return",
"null",
";",
"}"
] |
Get valid params for an invalid steps function.
@param {RegExp.match} match (Invalid) matches from stepsMatch()
@return {?RegExp.match} Valid match or null if the output is not valid
|
[
"Get",
"valid",
"params",
"for",
"an",
"invalid",
"steps",
"function",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L170-L223
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
showHideHint
|
function showHideHint(hint, show, documentCode, editorCode) {
if (!hint || !hint.elem) {
return;
}
if (show) {
hint.shown = true;
hint.animationInProgress = false;
hint.elem.removeClass("fadeout");
hint.elem.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
hint.elem.css("display", "block");
} else if (hint.shown) {
hint.animationInProgress = true;
AnimationUtils.animateUsingClass(hint.elem[0], "fadeout", 750)
.done(function () {
if (hint.animationInProgress) { // do this only if the animation was not cancelled
hint.elem.hide();
}
hint.shown = false;
hint.animationInProgress = false;
});
} else {
hint.elem.hide();
}
}
|
javascript
|
function showHideHint(hint, show, documentCode, editorCode) {
if (!hint || !hint.elem) {
return;
}
if (show) {
hint.shown = true;
hint.animationInProgress = false;
hint.elem.removeClass("fadeout");
hint.elem.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
hint.elem.css("display", "block");
} else if (hint.shown) {
hint.animationInProgress = true;
AnimationUtils.animateUsingClass(hint.elem[0], "fadeout", 750)
.done(function () {
if (hint.animationInProgress) { // do this only if the animation was not cancelled
hint.elem.hide();
}
hint.shown = false;
hint.animationInProgress = false;
});
} else {
hint.elem.hide();
}
}
|
[
"function",
"showHideHint",
"(",
"hint",
",",
"show",
",",
"documentCode",
",",
"editorCode",
")",
"{",
"if",
"(",
"!",
"hint",
"||",
"!",
"hint",
".",
"elem",
")",
"{",
"return",
";",
"}",
"if",
"(",
"show",
")",
"{",
"hint",
".",
"shown",
"=",
"true",
";",
"hint",
".",
"animationInProgress",
"=",
"false",
";",
"hint",
".",
"elem",
".",
"removeClass",
"(",
"\"fadeout\"",
")",
";",
"hint",
".",
"elem",
".",
"html",
"(",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"INLINE_TIMING_EDITOR_INVALID",
",",
"documentCode",
",",
"editorCode",
")",
")",
";",
"hint",
".",
"elem",
".",
"css",
"(",
"\"display\"",
",",
"\"block\"",
")",
";",
"}",
"else",
"if",
"(",
"hint",
".",
"shown",
")",
"{",
"hint",
".",
"animationInProgress",
"=",
"true",
";",
"AnimationUtils",
".",
"animateUsingClass",
"(",
"hint",
".",
"elem",
"[",
"0",
"]",
",",
"\"fadeout\"",
",",
"750",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"hint",
".",
"animationInProgress",
")",
"{",
"hint",
".",
"elem",
".",
"hide",
"(",
")",
";",
"}",
"hint",
".",
"shown",
"=",
"false",
";",
"hint",
".",
"animationInProgress",
"=",
"false",
";",
"}",
")",
";",
"}",
"else",
"{",
"hint",
".",
"elem",
".",
"hide",
"(",
")",
";",
"}",
"}"
] |
Show, hide or update the hint text
@param {object} hint Editor.hint object of the current InlineTimingFunctionEditor
@param {boolean} show Whether the hint should be shown or hidden
@param {string=} documentCode The invalid code from the document (can be omitted when hiding)
@param {string=} editorCode The valid code that is shown in the Inline Editor (can be omitted when hiding)
|
[
"Show",
"hide",
"or",
"update",
"the",
"hint",
"text"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L254-L278
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
_tagMatch
|
function _tagMatch(match, type) {
switch (type) {
case BEZIER:
match.isBezier = true;
break;
case STEP:
match.isStep = true;
break;
}
return match;
}
|
javascript
|
function _tagMatch(match, type) {
switch (type) {
case BEZIER:
match.isBezier = true;
break;
case STEP:
match.isStep = true;
break;
}
return match;
}
|
[
"function",
"_tagMatch",
"(",
"match",
",",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BEZIER",
":",
"match",
".",
"isBezier",
"=",
"true",
";",
"break",
";",
"case",
"STEP",
":",
"match",
".",
"isStep",
"=",
"true",
";",
"break",
";",
"}",
"return",
"match",
";",
"}"
] |
Tag this match with type and return it for chaining
@param {!RegExp.match} match RegExp Match object with steps function parameters
in array position 1 (and optionally 2).
@param {number} type Either BEZIER or STEP
@return {RegExp.match} Same object that was passed in.
|
[
"Tag",
"this",
"match",
"with",
"type",
"and",
"return",
"it",
"for",
"chaining"
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L288-L299
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
bezierCurveMatch
|
function bezierCurveMatch(str, lax) {
var match;
// First look for any cubic-bezier().
match = str.match(BEZIER_CURVE_VALID_REGEX);
if (match && _validateCubicBezierParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, BEZIER);
}
match = str.match(BEZIER_CURVE_GENERAL_REGEX);
if (match) {
match = _getValidBezierParams(match);
if (match && _validateCubicBezierParams(match)) {
return _tagMatch(match, BEZIER);
} else { // this should not happen!
window.console.log("brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code");
}
}
// Next look for the ease functions (which are special cases of cubic-bezier())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(EASE_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(EASE_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(EASE_LAX_REGEX), BEZIER);
}
}
// Final case is linear.
if (lax) {
// For lax parsing, just look for the keyword
match = str.match(LINEAR_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// The linear keyword can occur in other values, so for strict parsing we
// only detect when it's on same line as "transition" or "animation"
match = str.match(LINEAR_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(LINEAR_LAX_REGEX), BEZIER);
}
}
return null;
}
|
javascript
|
function bezierCurveMatch(str, lax) {
var match;
// First look for any cubic-bezier().
match = str.match(BEZIER_CURVE_VALID_REGEX);
if (match && _validateCubicBezierParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, BEZIER);
}
match = str.match(BEZIER_CURVE_GENERAL_REGEX);
if (match) {
match = _getValidBezierParams(match);
if (match && _validateCubicBezierParams(match)) {
return _tagMatch(match, BEZIER);
} else { // this should not happen!
window.console.log("brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code");
}
}
// Next look for the ease functions (which are special cases of cubic-bezier())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(EASE_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(EASE_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(EASE_LAX_REGEX), BEZIER);
}
}
// Final case is linear.
if (lax) {
// For lax parsing, just look for the keyword
match = str.match(LINEAR_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// The linear keyword can occur in other values, so for strict parsing we
// only detect when it's on same line as "transition" or "animation"
match = str.match(LINEAR_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(LINEAR_LAX_REGEX), BEZIER);
}
}
return null;
}
|
[
"function",
"bezierCurveMatch",
"(",
"str",
",",
"lax",
")",
"{",
"var",
"match",
";",
"match",
"=",
"str",
".",
"match",
"(",
"BEZIER_CURVE_VALID_REGEX",
")",
";",
"if",
"(",
"match",
"&&",
"_validateCubicBezierParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"match",
"=",
"str",
".",
"match",
"(",
"BEZIER_CURVE_GENERAL_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"_getValidBezierParams",
"(",
"match",
")",
";",
"if",
"(",
"match",
"&&",
"_validateCubicBezierParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"else",
"{",
"window",
".",
"console",
".",
"log",
"(",
"\"brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code\"",
")",
";",
"}",
"}",
"if",
"(",
"lax",
")",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"EASE_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"}",
"else",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"EASE_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"EASE_LAX_REGEX",
")",
",",
"BEZIER",
")",
";",
"}",
"}",
"if",
"(",
"lax",
")",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"LINEAR_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"}",
"else",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"LINEAR_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"LINEAR_LAX_REGEX",
")",
",",
"BEZIER",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Match a bezier curve function value from a CSS Declaration or Value.
Matches returned from this function must be handled in
BezierCurveEditor._getCubicBezierCoords().
@param {string} str Input string.
@param {!boolean} lax Parsing mode where:
lax=false Input is a Full or partial line containing CSS Declaration.
This is the more strict search used for initial detection.
lax=true Input is a previously parsed value. This is the less strict search
used to convert previously parsed values to RegExp match format.
@return {!RegExpMatch}
|
[
"Match",
"a",
"bezier",
"curve",
"function",
"value",
"from",
"a",
"CSS",
"Declaration",
"or",
"Value",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L315-L368
|
train
|
adobe/brackets
|
src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
|
stepsMatch
|
function stepsMatch(str, lax) {
var match;
// First look for any steps().
match = str.match(STEPS_VALID_REGEX);
if (match && _validateStepsParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, STEP);
}
match = str.match(STEPS_GENERAL_REGEX);
if (match) {
match = _getValidStepsParams(match);
if (match && _validateStepsParams(match)) {
return _tagMatch(match, STEP);
} else { // this should not happen!
window.console.log("brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code");
}
}
// Next look for the step functions (which are special cases of steps())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(STEP_LAX_REGEX);
if (match) {
return _tagMatch(match, STEP);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(STEP_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(STEP_LAX_REGEX), STEP);
}
}
return null;
}
|
javascript
|
function stepsMatch(str, lax) {
var match;
// First look for any steps().
match = str.match(STEPS_VALID_REGEX);
if (match && _validateStepsParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, STEP);
}
match = str.match(STEPS_GENERAL_REGEX);
if (match) {
match = _getValidStepsParams(match);
if (match && _validateStepsParams(match)) {
return _tagMatch(match, STEP);
} else { // this should not happen!
window.console.log("brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code");
}
}
// Next look for the step functions (which are special cases of steps())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(STEP_LAX_REGEX);
if (match) {
return _tagMatch(match, STEP);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(STEP_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(STEP_LAX_REGEX), STEP);
}
}
return null;
}
|
[
"function",
"stepsMatch",
"(",
"str",
",",
"lax",
")",
"{",
"var",
"match",
";",
"match",
"=",
"str",
".",
"match",
"(",
"STEPS_VALID_REGEX",
")",
";",
"if",
"(",
"match",
"&&",
"_validateStepsParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"match",
"=",
"str",
".",
"match",
"(",
"STEPS_GENERAL_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"_getValidStepsParams",
"(",
"match",
")",
";",
"if",
"(",
"match",
"&&",
"_validateStepsParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"else",
"{",
"window",
".",
"console",
".",
"log",
"(",
"\"brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code\"",
")",
";",
"}",
"}",
"if",
"(",
"lax",
")",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"STEP_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"}",
"else",
"{",
"match",
"=",
"str",
".",
"match",
"(",
"STEP_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"STEP_LAX_REGEX",
")",
",",
"STEP",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Match a steps function value from a CSS Declaration or Value.
Matches returned from this function must be handled in
BezierCurveEditor._getCubicBezierCoords().
@param {string} str Input string.
@param {!boolean} lax Parsing mode where:
lax=false Input is a Full or partial line containing CSS Declaration.
This is the more strict search used for initial detection.
lax=true Input is a previously parsed value. This is the less strict search
used to convert previously parsed values to RegExp match format.
@return {!RegExpMatch}
|
[
"Match",
"a",
"steps",
"function",
"value",
"from",
"a",
"CSS",
"Declaration",
"or",
"Value",
"."
] |
d5d00d43602c438266d32b8eda8f8a3ca937b524
|
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L384-L420
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.