Skip to content

Commit f65239f

Browse files
author
=
committed
overrided this.option to toggle sliding and hiding, increased handlebar width for hidden closed pane
1 parent fccb8d0 commit f65239f

File tree

3 files changed

+50
-32
lines changed

3 files changed

+50
-32
lines changed

demos/layout/nested.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
<script type="text/javascript">
1616

1717
$(function () {
18-
var $outer_layout = $('#outer-layout').layout({west: {hiding: true}});
18+
var $outer_layout = $('#outer-layout').layout();
1919
var $inner_layout = $('#inner-layout').layout({type:'vertical', north: {sliding: true}});
2020
$('.ui-layout-pane-west .toggleSlide').button().click(function(e){
21+
var self = $outer_layout.data('layout')
2122
e.preventDefault();
22-
$outer_layout.layout('toggleSlide', 'west');
23+
$outer_layout.layout('option', 'west', 'sliding', !self.options['west'].sliding);
24+
$outer_layout.layout('option', 'west', 'hiding', !self.options['west'].hiding);
2325
});
2426
$inner_layout.bind('layoutnorthopen', function(e,data){
2527
var self = $inner_layout.data('layout')
@@ -28,11 +30,15 @@
2830

2931
//set the margin to 0 after the west pane has been closed
3032
$('.ui-layout-pane-west').bind('mouseenter', function(){
31-
$outer_layout.layout('open','west');
33+
var self = $outer_layout.data('layout');
34+
if (self.options['west'].sliding){
35+
$outer_layout.layout('open','west');
36+
}
3237
});
3338

3439
$outer_layout.bind('click',function(e){
35-
if (!$(e.target).closest('.ui-layout-pane-west').length){
40+
var self = $outer_layout.data('layout');
41+
if (self.options['west'].sliding && !$(e.target).closest('.ui-layout-pane-west, .ui-resizable-handle').length){
3642
$outer_layout.layout('close','west');
3743
}
3844
});

themes/base/jquery.ui.layout.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,38 @@
4040
}
4141

4242
.ui-layout-pane-west.ui-layout-pane-close.ui-layout-pane-hiding > .ui-resizable-e {
43-
right: -1px;
44-
width: 1px;
43+
right: -5px;
44+
width: 5px;
4545
}
4646
.ui-layout-pane-east.ui-layout-pane-close.ui-layout-pane-hiding > .ui-resizable-w {
47-
left: -1px;
48-
width: 1px;
47+
left: -5px;
48+
width: 5px;
4949
}
5050
.ui-layout-pane-south.ui-layout-pane-close.ui-layout-pane-hiding > .ui-resizable-n {
51-
top: -1px;
52-
width: 1px;
51+
top: -5px;
52+
width: 5px;
5353
}
5454
.ui-layout-pane-north.ui-layout-pane-close.ui-layout-pane-hiding > .ui-resizable-s {
55-
bottom: -1px;
56-
width: 1px;
55+
bottom: -5px;
56+
width: 5px;
5757
}
5858

5959

6060
.ui-layout-pane-west.ui-layout-pane-sliding.ui-layout-pane-hiding,
6161
.ui-layout-pane-west.ui-layout-pane-close.ui-layout-pane-hiding{
62-
margin-right: 1px;
62+
margin-right: 0;
6363
}
6464
.ui-layout-pane-east.ui-layout-pane-sliding.ui-layout-pane-hiding,
6565
.ui-layout-pane-east.ui-layout-pane-close.ui-layout-pane-hiding{
66-
margin-left: 1px;
66+
margin-left: 0;
6767
}
6868
.ui-layout-pane-north.ui-layout-pane-sliding.ui-layout-pane-hiding,
6969
.ui-layout-pane-north.ui-layout-pane-close.ui-layout-pane-hiding{
70-
margin-bottom: 1px;
70+
margin-bottom: 0;
7171
}
7272
.ui-layout-pane-south.ui-layout-pane-sliding.ui-layout-pane-hiding,
7373
.ui-layout-pane-south.ui-layout-pane-close.ui-layout-pane-hiding{
74-
margin-bottom: 1px;
74+
margin-bottom: 0;
7575
}
7676

7777

ui/jquery.ui.layout.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
defaults: {
3131
closingWidth: 20,
3232
closingHeight: 20,
33+
hiding: false,
34+
sliding: false,
3335
toggleEvent: 'click',
3436
toggleSelector: '.ui-resizable-handle'
3537
},
@@ -188,7 +190,7 @@
188190
self.panes[pane] = $pane ;
189191

190192

191-
self._hiding(pane, self.options[pane].hiding) ;
193+
self._hiding(pane) ;
192194

193195
// set pane dimension
194196
if(self.options[pane].sliding){
@@ -300,27 +302,37 @@
300302
this.options[pane].zIndex = $pane.zIndex();
301303
$pane.zIndex(this.element.zIndex() + 10 - depth)
302304
},
303-
_sliding: function(pane, sliding){
304-
sliding = ("undefined" == typeof sliding) ? true : sliding;
305-
this.panes[pane][sliding ? 'addClass' : 'removeClass']('ui-layout-pane-sliding');
306-
if (sliding)
305+
_sliding: function(pane){
306+
this.panes[pane][this.options[pane].sliding ? 'addClass' : 'removeClass']('ui-layout-pane-sliding');
307+
if (this.options[pane].sliding)
307308
this._putForeground(pane);
308309
},
309-
toggleSlide: function(pane){
310-
this.options[pane].sliding = !this.options[pane].sliding;
311-
this._sliding(pane, this.options[pane].sliding);
312-
this.resize();
313-
return this.element
310+
_hiding: function(pane){
311+
this.panes[pane][this.options[pane].hiding ? 'addClass' : 'removeClass']('ui-layout-pane-hiding');
314312
},
315-
_hiding: function(pane, hiding){
316-
hiding = ("undefined" == typeof hiding) ? false : hiding;
317-
this.panes[pane][hiding ? 'addClass' : 'removeClass']('ui-layout-pane-hiding');
318-
},
313+
option: function( pane, key, value ) {
314+
if ($.inArray(pane, ['center', 'north', 'south', 'east', 'west'])){
315+
this.options[pane][key] = value;
316+
switch(key){
317+
case 'hiding':
318+
this._hiding(pane);
319+
this.resize();
320+
break;
321+
case 'sliding':
322+
this._sliding(pane);
323+
this.resize();
324+
break;
325+
}
326+
}
327+
else{
328+
this._super('option', pane, key)
329+
}
330+
return this;
331+
},
332+
319333
_ui:function(pane){
320334
return {pane: this.panes[pane], paneName: pane, options: this.options}
321335
},
322-
323-
324336
_open: function(pane, trigg){
325337
trigg = ("undefined" == typeof trigg ) ? true : trigg;
326338
this.panes[pane].addClass('ui-layout-pane-open')

0 commit comments

Comments
 (0)