tablets 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c16295c7952e93818cdfe4e8eb3db65889879bf7
4
- data.tar.gz: 1769e84891acd0f0ba1a75d2b4c7c3689626283e
3
+ metadata.gz: 97e71e5740bc66535ca26f9ff8f6f9514b73f8ef
4
+ data.tar.gz: 16a6e51c2fd93d931ba938dcdf4bdb2c3c62c90c
5
5
  SHA512:
6
- metadata.gz: a8e5821d44780f8576f17b373aaf67c7748c324a07ced3340e6a4cdea8634998d079fc340df9a74d66bd96f1c4cfd6e8d229676334b0ebe4a7df2d1cc4e3ed04
7
- data.tar.gz: c110e90941a1d1550b5c14b64db1bb39faf8c289e1a7f945363540b166667afb1c4af00112c5976d4d3745722e7b63a72175c08f9ffc58df8f50e1a0c738b0d1
6
+ metadata.gz: d0b9a058a8f0d73c41d14b86801236a6a167ccdd0595625fed4c07e4bf63ae2fcbd5dd877a58267b1d1b4d2689b6695d56cd4066bf7dc0c3024b6b753dfaa148
7
+ data.tar.gz: 92bde44a6a394c1d83bd2f9c9fc5ebd93f8aa406ac4c22d39ef6c03a47fc219a08231d5c0aee468d7531b5d44a6eaf02a129fd6ce108f63d617e2065124d55f9
@@ -1,11 +1,16 @@
1
1
  class Tablets.Tablet
2
- constructor: (@element, @options, @params) ->
2
+ constructor: (@element, options = {}) ->
3
3
  @initVars()
4
4
  @initHandlers()
5
+ @datatableOptions = options.datatableOptions
6
+ @params = options.params
7
+ initializeInstantly = options.initializeInstantly
5
8
 
6
9
  Tablets.set(@id, this)
7
10
 
8
- if Turbolinks && Turbolinks.supported
11
+ if initializeInstantly
12
+ @initTable()
13
+ else if Turbolinks && Turbolinks.supported
9
14
  $(document).one 'page:change', =>
10
15
  @initTable()
11
16
  else
@@ -13,7 +18,7 @@ class Tablets.Tablet
13
18
  @initTable()
14
19
 
15
20
  dataTableOptions: ->
16
- $.extend {}, @options,
21
+ $.extend {}, @datatableOptions,
17
22
  fnServerParams: (data) =>
18
23
  data.params = @serverParams()
19
24
  fnRowCallback: (row, data) =>
@@ -15,7 +15,10 @@
15
15
  <script>
16
16
  new Tablets.Tablet(
17
17
  $('#<%= id %>'),
18
- <%= raw options.to_json %>,
19
- <%= raw params.to_json %>
18
+ {
19
+ datatableOptions: <%= raw options.to_json %>,
20
+ params: <%= raw params.to_json %>,
21
+ initializeInstantly: <%= raw initialize_instantly %>
22
+ }
20
23
  );
21
24
  </script>
@@ -6,9 +6,10 @@ module Tablets
6
6
  # Prepares markup. Renders table without any data
7
7
  class Renderer
8
8
  # Initializes renderer with tablet and params
9
- def initialize(tablet, params = {})
9
+ def initialize(tablet, params, opts = {})
10
10
  @tablet = tablet
11
11
  @params = params
12
+ @initialize_instantly = opts.fetch(:initialize_instantly, false)
12
13
  end
13
14
 
14
15
  # Renders table in view_context
@@ -18,7 +19,7 @@ module Tablets
18
19
 
19
20
  private
20
21
 
21
- attr_reader :params, :tablet
22
+ attr_reader :params, :tablet, :initialize_instantly
22
23
 
23
24
  # Prepares locals for tablet partial
24
25
  def locals
@@ -27,7 +28,8 @@ module Tablets
27
28
  name: tablet.name,
28
29
  columns: tablet.columns,
29
30
  options: resulting_options,
30
- params: params
31
+ params: params,
32
+ initialize_instantly: initialize_instantly
31
33
  }
32
34
  end
33
35
 
@@ -3,7 +3,7 @@ module Tablets
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- TINY = 12
6
+ TINY = 13
7
7
  PRE = nil
8
8
 
9
9
  class << self
@@ -7,8 +7,12 @@ module Tablets
7
7
  #
8
8
  # <%= render_tablet :posts, user_id: @user.id %>
9
9
  #
10
- def render_tablet(name, params = {})
11
- Tablets::Renderer.new(Tablets[name], params).render(self)
10
+ # initialize_instantly option skips waiting for page:change event and initializes tablet instantly
11
+ def render_tablet(name, opts = {})
12
+ locals = opts.fetch(:locals, {})
13
+ initialize_instantly = opts.fetch(:initialize_instantly, false)
14
+
15
+ Tablets::Renderer.new(Tablets[name], locals, initialize_instantly: initialize_instantly).render(self)
12
16
  end
13
17
  end
14
18
  end
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.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yevhen Shemet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.4.8
167
+ rubygems_version: 2.5.1
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Wrapper around jquery-datatables.