Skip to content

Commit 4b13d40

Browse files
committed
rtl support
1 parent 76f90a2 commit 4b13d40

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Changes
439439
- add options `disableDrag` and `disableResize`.
440440
- fix `batchUpdate`/`commit` (Thank to @radiolips)
441441
- remove dependency from FontAwesome
442+
- RTL support
442443

443444
#### v0.2.4 (2016-02-15)
444445

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ gridstack.js API
7272
- `placeholderClass` - class for placeholder (default: `'grid-stack-placeholder'`)
7373
- `placeholderText` - placeholder default content (default: `''`)
7474
- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`)
75+
- `rtl` - if `true` turns grid to RTL. Possible values `true`, `false`, `'auto'` (default `'auto'`) See [example](http://troolee.github.io/gridstack.js/demo/rtl.html)
7576
- `staticGrid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container.
7677
- `verticalMargin` - vertical gap size (default: `20`). Can be:
7778
- an integer (px)

src/gridstack.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,18 @@
528528
appendTo: 'body'
529529
}),
530530
disableDrag: opts.disableDrag || false,
531-
disableResize: opts.disableResize || false
531+
disableResize: opts.disableResize || false,
532+
rtl: 'auto'
532533
});
534+
535+
if (this.opts.rtl === 'auto') {
536+
this.opts.rtl = this.container.css('direction') === 'rtl';
537+
}
538+
539+
if (this.opts.rtl) {
540+
this.container.addClass('grid-stack-rtl');
541+
}
542+
533543
this.opts.isNested = isNested;
534544

535545
this.cellHeight(this.opts.cellHeight, true);

src/gridstack.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ $animation_speed: .3s !default;
1616
.grid-stack {
1717
position: relative;
1818

19+
&.grid-stack-rtl {
20+
direction: ltr;
21+
22+
> .grid-stack-item {
23+
direction: rtl;
24+
}
25+
}
26+
1927
.grid-stack-placeholder > .placeholder-content {
2028
border: 1px dashed lightgray;
2129
margin: 0;

0 commit comments

Comments
 (0)