tablets 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -9
- data/app/assets/javascripts/tablets/callbacks.js.coffee +12 -3
- data/app/assets/javascripts/tablets/details.js.coffee +1 -1
- data/app/assets/javascripts/tablets/navigation.js.coffee +1 -1
- data/app/assets/javascripts/tablets/store.js.coffee +1 -1
- data/app/assets/javascripts/tablets/tablet.js.coffee +13 -3
- data/lib/tablets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08132fccd6b5eb432ef7cad745f40235ab6b6bde
|
4
|
+
data.tar.gz: fe36e379b7c6157a90fd8e5e218fd205838daa30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad3e1ab54407056b782808eb5ee9c11e0ca58822e9dcc0e2d08842e76e6a281e8e53b1af72dc46ee7c819a0bdc12fbb175a19bfbdba0b96750f64828bcefa97
|
7
|
+
data.tar.gz: 6a3b5dc7ebbc29fa564376c290c796baa42b0cbd9884017c8af269f26137e4730761b24b2413d552decea370a0e53dc45ba11690affc9ce945ae2ab599a4704b
|
data/README.md
CHANGED
@@ -88,32 +88,46 @@ In `app/views/posts/index.html.erb`:
|
|
88
88
|
In `app/assets/javascripts/posts.js`:
|
89
89
|
|
90
90
|
``` javascript
|
91
|
-
$('.tablet[name="posts"]').on('click', 'tbody > tr[role=row]', function() {
|
91
|
+
$('.tablet[data-name="posts"]').on('click', 'tbody > tr[role=row]', function() {
|
92
92
|
Tablets.toggleDetails($(this).closest('tr'));
|
93
93
|
});
|
94
|
-
|
95
94
|
```
|
96
95
|
|
97
96
|
Use `'.tablet.has-details'` for all tablets that has details.
|
98
97
|
|
99
|
-
## JavaScript
|
98
|
+
## JavaScript API
|
99
|
+
|
100
|
+
Fields:
|
101
|
+
|
102
|
+
``` javascript
|
103
|
+
tablet.element // root element
|
104
|
+
tablet.table // jquery datatable object
|
105
|
+
```
|
106
|
+
|
107
|
+
Open details for row.
|
108
|
+
|
109
|
+
``` javascript
|
110
|
+
Tablets.toggleDetails($tr);
|
111
|
+
```
|
112
|
+
|
113
|
+
### JavaScript callbacks
|
114
|
+
|
115
|
+
Callbacks called on tablet. You can use `this` to access tablet from callback.
|
100
116
|
|
101
117
|
Called just before datatable initialization.
|
102
118
|
|
103
119
|
``` javascript
|
104
|
-
Tablets.
|
120
|
+
Tablets.on('beforeInit', function(options) {});
|
105
121
|
```
|
106
122
|
|
107
123
|
Called after datatable initialization.
|
108
124
|
|
109
125
|
``` javascript
|
110
|
-
Tablets.
|
126
|
+
Tablets.on('afterInit', function() {});
|
111
127
|
```
|
112
128
|
|
113
|
-
|
114
|
-
|
115
|
-
Open details for row.
|
129
|
+
Called before AJAX request.
|
116
130
|
|
117
131
|
``` javascript
|
118
|
-
Tablets.
|
132
|
+
Tablets.on('beforeRequest', function(params) {});
|
119
133
|
```
|
@@ -1,3 +1,12 @@
|
|
1
|
-
Tablets
|
2
|
-
|
3
|
-
|
1
|
+
$.extend Tablets,
|
2
|
+
callbacks:
|
3
|
+
beforeInit: []
|
4
|
+
afterInit: []
|
5
|
+
beforeRequest: []
|
6
|
+
|
7
|
+
on: (event, callback) ->
|
8
|
+
@callbacks[event].push callback
|
9
|
+
|
10
|
+
trigger: (event, tablet, args = []) ->
|
11
|
+
for callback in @callbacks[event]
|
12
|
+
callback.apply(tablet, args)
|
@@ -7,16 +7,23 @@ class Tablets.Tablet
|
|
7
7
|
dataTableOptions: ->
|
8
8
|
$.extend {}, @options,
|
9
9
|
fnServerParams: (data) =>
|
10
|
-
data.params = @
|
10
|
+
data.params = @serverParams()
|
11
|
+
|
12
|
+
serverParams: ->
|
13
|
+
params = $.extend({}, @params)
|
14
|
+
|
15
|
+
@trigger('beforeRequest', params)
|
16
|
+
|
17
|
+
params
|
11
18
|
|
12
19
|
initTable: ->
|
13
20
|
options = @dataTableOptions()
|
14
21
|
|
15
|
-
|
22
|
+
@trigger('beforeInit', options)
|
16
23
|
|
17
24
|
@table = $(@element).DataTable(options)
|
18
25
|
|
19
|
-
|
26
|
+
@trigger('afterInit')
|
20
27
|
|
21
28
|
toggleDetails: (tr) ->
|
22
29
|
row = @table.row tr
|
@@ -30,3 +37,6 @@ class Tablets.Tablet
|
|
30
37
|
row.child("<span>#{data}</span>").show()
|
31
38
|
tr.addClass 'expanded'
|
32
39
|
tr.addClass 'shown'
|
40
|
+
|
41
|
+
trigger: (event, params...) ->
|
42
|
+
Tablets.trigger(event, this, params)
|
data/lib/tablets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tablets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yevhen Shemet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|