-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Replaced toggleClass with add/removeClass where appropriate #3689
Changes from all commits
8135b19
8879b04
74fc733
dbc5164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,20 @@ define(function (require, exports, module) { | |
$displayElement.off("contentChanged.scroller-shadow"); | ||
} | ||
|
||
/** | ||
* Utility function to replace jQuery.toggleClass when used with the second argument, which needs to be a true boolean for jQuery | ||
* @param {!jQueryObject} $domElement The jQueryObject to toggle the Class on | ||
* @param {!string} className Class name or names (separated by spaces) to toggle | ||
* @param {!boolean} addClass A truthy value to add the class and a falsy value to remove the class | ||
*/ | ||
function toggleClass($domElement, className, addClass) { | ||
if (addClass) { | ||
$domElement.addClass(className); | ||
} else { | ||
$domElement.removeClass(className); | ||
} | ||
} | ||
|
||
/** | ||
* Within a scrolling DOMElement, creates and positions a styled selection | ||
* div to align a single selected list item from a ul list element. | ||
|
@@ -202,8 +216,8 @@ define(function (require, exports, module) { | |
|
||
$selectionTriangle.css("top", triangleTop); | ||
$selectionTriangle.css("left", $sidebar.width() - $selectionTriangle.outerWidth()); | ||
$selectionTriangle.toggleClass("triangle-visible", showTriangle); | ||
|
||
toggleClass($selectionTriangle, "triangle-visible", showTriangle); | ||
var triangleClipOffsetYBy = Math.floor((selectionMarkerHeight - triangleHeight) / 2), | ||
triangleBottom = triangleTop + triangleHeight + triangleClipOffsetYBy; | ||
|
||
|
@@ -351,4 +365,5 @@ define(function (require, exports, module) { | |
exports.sidebarList = sidebarList; | ||
exports.scrollElementIntoView = scrollElementIntoView; | ||
exports.getFileEntryDisplay = getFileEntryDisplay; | ||
exports.toggleClass = toggleClass; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ViewUtils seems like an odd place to put this, since the other code in here is so oriented around managing scrolling panels (mainly the sidebar). But short of creating a new DOMUtils module, there doesn't seem to be any better option. So we might as well leave it here for now... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ViewUtils seems like an odd place to put this, since the other code in here is so oriented around managing scrolling panels (mainly the sidebar). But short of creating a new DOMUtils module, there doesn't seem to be any better option. So we might as well leave it here for now... |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also port over the calls just above this, in
_checkedChanged()
.