Skip to content

Commit a949d0e

Browse files
author
=
committed
bugfixes
1 parent f65239f commit a949d0e

File tree

3 files changed

+55
-41
lines changed

3 files changed

+55
-41
lines changed

demos/layout/nested.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
<script type="text/javascript">
1616

1717
$(function () {
18+
1819
var $outer_layout = $('#outer-layout').layout();
1920
var $inner_layout = $('#inner-layout').layout({type:'vertical', north: {sliding: true}});
21+
22+
// todo bug
23+
$outer_layout.layout('resizeElement')
24+
2025
$('.ui-layout-pane-west .toggleSlide').button().click(function(e){
2126
var self = $outer_layout.data('layout')
2227
e.preventDefault();
@@ -28,7 +33,7 @@
2833
self.options[data.paneName].height = self.panes['center'].outerHeight() + 15
2934
});
3035

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

demos/layout/vertical.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
</script>
2121
<style>
22+
html{
23+
margin:0;
24+
padding:0;
25+
}
26+
body{
27+
height: 100%;
28+
margin:0;
29+
padding:0;
30+
}
2231
#layout{
2332
margin: 10px;
2433
}

ui/jquery.ui.layout.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777
}
7878
return prop
7979
},
80-
_sizeProp: function(pane,prefix){
80+
_sizeProp: function(prefix){
8181
prefix = prefix || '';
82-
return toCamelCase(prefix +" " + (this.options[pane].resizable.handles.match(/e|w/) ? 'width' : 'height') );
82+
return toCamelCase(prefix +" " + (this.options.type == 'horizontal' ? 'width' : 'height' ));
8383
},
8484

8585
_create: function(){
@@ -114,7 +114,7 @@
114114
self._open(pane)
115115

116116
// set max width/height dynamically
117-
$pane.resizable('option', self._sizeProp(pane,'max'), self._maxSize(pane));
117+
$pane.resizable('option', self._sizeProp('max'), self._maxSize(pane));
118118
if ($pane.find('iframe').length){
119119
var $mask = $('<div class="iframe-mask"/>')
120120
$mask
@@ -154,7 +154,7 @@
154154

155155

156156
// prevent the pane to toggle after a mouseup event, if the orginal size has significantly been changed
157-
if (Math.abs(ui.size[self._sizeProp(pane)] - ui.originalSize[self._sizeProp(pane)]) > 3){
157+
if (Math.abs(ui.size[self._sizeProp()] - ui.originalSize[self._sizeProp()]) > 3){
158158
preventToggling = true;
159159
setTimeout(function(){
160160
preventToggling = false;
@@ -166,12 +166,12 @@
166166

167167

168168
// close the sidePane if not visible anymore, otherwise record its dimension
169-
if (ui.size[self._sizeProp(pane)] < self.options[pane][self._sizeProp(pane, 'closing')]){
169+
if (ui.size[self._sizeProp()] < self.options[pane][self._sizeProp('closing')]){
170170
self.close(pane)
171171
}
172172
else {
173173
self._opened(pane);
174-
self.options[pane][self._sizeProp(pane)] = ui.size[self._sizeProp(pane)]
174+
self.options[pane][self._sizeProp()] = ui.size[self._sizeProp()]
175175
}
176176

177177
});
@@ -195,84 +195,82 @@
195195
// set pane dimension
196196
if(self.options[pane].sliding){
197197
self._sliding(pane)
198-
$pane[self._sizeProp(pane)](0);
198+
$pane[self._sizeProp()](0);
199199
self._closed(pane);
200200

201201
}
202202
else if (self.options[pane].opened){
203203
self._open(pane, false);
204-
$pane[self._sizeProp(pane,'outer')](self.options[pane][self._sizeProp(pane)], true)
204+
$pane[self._sizeProp('outer')](self.options[pane][self._sizeProp()], true)
205205
}
206206

207207
}
208208
});
209209

210-
this._resizeElement();
211-
212210
if (this.element.hasClass('ui-layout-pane')){
213211
this.element.bind('resize',function(e){
214212
if (e.target == self.element[0]){
215-
self._resizeElement();
213+
self.resizeElement();
216214
}
217215
})
218216
}
219217
else {
220218
$(window).bind('resize', function(e){
221-
self._resizeElement();
219+
self.resizeElement();
222220
})
223221
}
222+
223+
this.resizeElement();
224+
224225
},
225226

226-
_resizeElement: function(){
227+
resizeElement: function(){
227228
var self = this;
228229

229230
if (this.element[0].tagName == "BODY"){
230-
this.element
231+
self.element
231232
.css({padding: '0', margin: '0'})
232233
.outerWidth($(window).width(), true)
233234
.outerHeight($(window).height(), true);
234-
} else if(!this.element.hasClass('ui-layout-pane')) {
235-
this.element
236-
.outerHeight(this.element.parent().innerHeight(), true)
237-
.outerWidth(this.element.parent().innerWidth(), true);
235+
} else if(!self.element.hasClass('ui-layout-pane')) {
236+
self.element
237+
.outerHeight(self.element.parent().innerHeight(), true)
238+
.outerWidth(self.element.parent().innerWidth(), true);
238239
}
239240

240-
this._panes().each(function() {
241+
self._panes().each(function() {
241242
if (self.options.type == 'horizontal')
242243
$(this).outerHeight(self.element.innerHeight(), true)
243244
else
244245
$(this).outerWidth(self.element.innerWidth(), true)
245246
});
246247

247248
// resize center pane
248-
this.resize();
249+
self.resize();
249250

251+
return this;
250252
},
251253
resize: function(){
252254
var self = this,
253255
$pane = this.panes['center'],
254256
$prev = $pane.prev('.ui-layout-pane');
255257

256-
var prefixedProp = function(prefix){
257-
var prop = self.options.type == 'horizontal' ? 'width' : 'height';
258-
return toCamelCase('outer '+ prop)
259-
}
260-
261-
var parseValue = function(text){
262-
return parseInt(text.match(/-*\d+/))
263-
}
264-
265258
var sum = 0;
266-
this.element.children(".ui-layout-pane:visible").not('.ui-layout-pane-center').each(function(){
267-
sum+= $(this).hasClass('ui-layout-pane-sliding') ? $(this)[prefixedProp('outer')](true) - $(this)[prefixedProp('inner')]() : $(this)[prefixedProp('outer')](true);
259+
this.element.children(".ui-layout-pane").not('.ui-layout-pane-center').each(function(){
260+
if ($(this).hasClass('ui-layout-pane-sliding')){
261+
sum+= $(this)[self._sizeProp('outer')](true) - $(this)[self._sizeProp('inner')]()
262+
}
263+
else{
264+
sum+= $(this)[self._sizeProp('outer')](true);
265+
}
268266
});
269267

270-
$pane[prefixedProp('outer')](this.element[prefixedProp('max')]() - sum, true );
271-
268+
$pane[self._sizeProp('outer')](this.element[self._sizeProp('inner')]() - sum, true );
272269

273270
var offset = function(){
274271
return self.options.type == 'horizontal' ? $prev.css('marginRight')+' 0' : '0 ' + $prev.css('marginBottom')
275272
}
273+
276274
if ($prev.length && !$prev.hasClass('ui-layout-pane-sliding')){
277275
$pane.position({
278276
offset: offset(),
@@ -284,17 +282,19 @@
284282
}
285283
else{
286284
$pane.position({
287-
offset: $prev.hasClass('ui-layout-pane-sliding') ? offset() : '',
285+
offset: $prev.hasClass('ui-layout-pane-sliding') ? offset() : '0 0',
288286
of: this.element,
289287
my: 'left top',
290-
at: 'left top'
288+
at: 'left top',
289+
collision: "none"
291290
})
292291
}
293292

294293
this._trigger('resize')
295294
// emulate a resize event from the center pane
296295
$pane.trigger('resize');
297-
return this.element
296+
297+
return this
298298
},
299299
_putForeground:function(pane){
300300
var $pane = this.panes[pane],
@@ -362,9 +362,9 @@
362362
_maxSize:function(pane){
363363
var options = this.options[pane],
364364
$pane = this.panes[pane],
365-
property = this._sizeProp(pane)
365+
property = this._sizeProp()
366366

367-
return Math.min(options.resizable[this._sizeProp(pane,'max')], this.element[this._sizeProp(pane,'inner')]() - ( this.options['center'].minWidth + this._panes().not($pane).not(this.panes['center'])[this._sizeProp(pane,'outer')](true) ))
367+
return Math.min(options.resizable[this._sizeProp('max')], this.element[this._sizeProp('inner')]() - ( this.options['center'].minWidth + this._panes().not($pane).not(this.panes['center'])[this._sizeProp('outer')](true) ))
368368
},
369369

370370
_removeInlineStyleAttr: function(pane){
@@ -398,7 +398,7 @@
398398
callback = callback || null ;
399399
if (this.options[pane].opened){
400400
this._close(pane)
401-
css[self._sizeProp(pane)] = 0;
401+
css[self._sizeProp()] = 0;
402402
this._animate(pane, css, function(){
403403
self._closed(pane);
404404
if (callback)
@@ -413,7 +413,7 @@
413413
css = {} ;
414414
if (!this.options[pane].opened){
415415
this._open(pane)
416-
css[self._sizeProp(pane)] = Math.min(this.options[pane][this._sizeProp(pane)], this._maxSize(pane)) ;
416+
css[self._sizeProp()] = Math.min(this.options[pane][this._sizeProp()], this._maxSize(pane)) ;
417417
this._animate(pane, css, function(){
418418
self._opened(pane)
419419
if (callback)

0 commit comments

Comments
 (0)