Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit bf6b9f6

Browse files
committed
Enclosing sidebar and search js in immediately invoked function expressions to avoid conflicts
1 parent a9cff2e commit bf6b9f6

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PatternFly",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"authors": "Red Hat",
55
"license": "Apache-2.0",
66
"homepage": "https://www.patternfly.org",

dist/js/patternfly.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
// PatternFly Namespace
22
var PatternFly = PatternFly || {};
33

4-
$(document).ready(function() {
5-
// Call sidebar() on ready if .sidebar-pf exists and .datatable does not exist
6-
if ($('.sidebar-pf').length > 0 && $('.datatable').length == 0) {
7-
//if ($('.sidebar-pf').length > 0) {
8-
sidebar();
9-
}
10-
});
11-
12-
$(window).resize(function() {
13-
// Call sidebar() on resize if .sidebar-pf exists
14-
if ($('.sidebar-pf').length > 0) {
15-
sidebar();
16-
}
17-
});
18-
19-
// PatternFly Sidebar
4+
// Util: PatternFly Sidebar
205
// Set height of sidebar-pf to height of document minus height of navbar-pf if not mobile
21-
function sidebar() {
22-
var documentHeight = 0;
23-
var navbarpfHeight = 0;
24-
var colHeight = 0;
25-
if ( $('.navbar-pf .navbar-toggle').is(':hidden') ) {
26-
documentHeight = $(document).height();
27-
navbarpfHeight = $('.navbar-pf').outerHeight();
28-
colHeight = documentHeight - navbarpfHeight;
6+
(function($) {
7+
sidebar = function() {
8+
var documentHeight = 0;
9+
var navbarpfHeight = 0;
10+
var colHeight = 0;
11+
if ( $('.navbar-pf .navbar-toggle').is(':hidden') ) {
12+
documentHeight = $(document).height();
13+
navbarpfHeight = $('.navbar-pf').outerHeight();
14+
colHeight = documentHeight - navbarpfHeight;
15+
}
16+
$('.sidebar-pf').parent('.row').children('[class*="col-"]').css({ "min-height":colHeight});
2917
}
30-
$('.sidebar-pf').parent('.row').children('[class*="col-"]').css({ "min-height":colHeight});
31-
}
18+
$(document).ready(function() {
19+
// Call sidebar() on ready if .sidebar-pf exists and .datatable does not exist
20+
if ($('.sidebar-pf').length > 0 && $('.datatable').length == 0) {
21+
sidebar();
22+
}
23+
});
24+
$(window).resize(function() {
25+
// Call sidebar() on resize if .sidebar-pf exists
26+
if ($('.sidebar-pf').length > 0) {
27+
sidebar();
28+
}
29+
});
30+
})(jQuery);
3231

3332
// Util: PatternFly Popovers
3433
// Add data-close="true" to insert close X icon

dist/js/patternfly.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PatternFly",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"author": "Red Hat",
55
"license": "Apache-2.0",
66
"devDependencies": {

tests/search.html

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@
2020
<script src="../components/bootstrap/dist/js/bootstrap.min.js"></script>
2121
<script src="../dist/js/patternfly.min.js"></script>
2222
<script>
23-
$(document).ready(function() {
24-
// Hide the clear button
25-
$(".search-pf .clear").hide($(this).prev('input').val());
26-
// Show the clear button upon entering text in the search input
27-
$(".search-pf .has-clear .form-control").keyup(function () {
28-
var t = $(this);
29-
t.next('button').toggle(Boolean(t.val()));
23+
(function($) {
24+
$(document).ready(function() {
25+
// Hide the clear button
26+
$(".search-pf .clear").hide($(this).prev('input').val());
27+
// Show the clear button upon entering text in the search input
28+
$(".search-pf .has-clear .form-control").keyup(function () {
29+
var t = $(this);
30+
t.next('button').toggle(Boolean(t.val()));
31+
});
32+
// Upon clicking the clear button, empty the entered text and hide the clear button
33+
$(".search-pf .clear").click(function () {
34+
$(this).prev('input').val('').focus();
35+
$(this).hide();
36+
});
3037
});
31-
// Upon clicking the clear button, empty the entered text and hide the clear button
32-
$(".search-pf .clear").click(function () {
33-
$(this).prev('input').val('').focus();
34-
$(this).hide();
35-
});
36-
});
38+
})(jQuery);
3739
</script>
3840
</head>
3941
<body>

0 commit comments

Comments
 (0)