Skip to content

Commit

Permalink
Fix box inside box collapsing error (ColorlibHQ#1681) (ColorlibHQ#1685)
Browse files Browse the repository at this point in the history
* Previously, with a .box inside a .box, any clicking on a
  collapse/expand button in either .box would cause both of them to
  collapse/expand.  This commit makes sure parent and child boxes
  do not interfere with each other.
  • Loading branch information
bmanifold authored and almasaeed2010 committed Oct 26, 2017
1 parent b98b591 commit a667b95
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions build/js/BoxWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var Selector = {
data : '.box',
collapsed: '.collapsed-box',
header : '.box-header',
body : '.box-body',
footer : '.box-footer',
tools : '.box-tools'
Expand Down Expand Up @@ -65,12 +66,13 @@
$(this.element).removeClass(ClassName.collapsed)

$(this.element)
.find(Selector.tools)
.children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
.children(Selector.tools)
.find('.' + expandIcon)
.removeClass(expandIcon)
.addClass(collapseIcon)

$(this.element).find(Selector.body + ', ' + Selector.footer)
$(this.element).children(Selector.body + ', ' + Selector.footer)
.slideDown(this.options.animationSpeed, function () {
$(this.element).trigger(expandedEvent)
}.bind(this))
Expand All @@ -82,12 +84,13 @@
var expandIcon = this.options.expandIcon

$(this.element)
.find(Selector.tools)
.children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
.children(Selector.tools)
.find('.' + collapseIcon)
.removeClass(collapseIcon)
.addClass(expandIcon)

$(this.element).find(Selector.body + ', ' + Selector.footer)
$(this.element).children(Selector.body + ', ' + Selector.footer)
.slideUp(this.options.animationSpeed, function () {
$(this.element).addClass(ClassName.collapsed)
$(this.element).trigger(collapsedEvent)
Expand All @@ -110,12 +113,14 @@

$(this.element).on('click', this.options.collapseTrigger, function (event) {
if (event) event.preventDefault()
that.toggle()
that.toggle($(this))
return false
})

$(this.element).on('click', this.options.removeTrigger, function (event) {
if (event) event.preventDefault()
that.remove()
that.remove($(this))
return false
})
}

Expand Down

0 comments on commit a667b95

Please sign in to comment.