tell-them 0.1.7 → 0.2.0

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: dd833b80ab13e9c68be09f645c5aea9c05e345f4
4
- data.tar.gz: f242dff34fad6a9fa853de1df8374175c79b2772
3
+ metadata.gz: e48b00bb54254cda19dc041da0a4d87d215b982c
4
+ data.tar.gz: 56f2998bd5f884028cd3ab4d39627c399fe0d3bf
5
5
  SHA512:
6
- metadata.gz: f6b8f7a23970f99355d534d559045b952d1381d79b0763ea737ee15d96f4495d8291e46d29282a7adceecb2c247a9ee59d7e45a69a2d2aaa93aa2b50279790bb
7
- data.tar.gz: a8a1663ae26e503841746a1d707bdb8509d680b440959dc53bcc8a807bae8ea14bdd9b08eba38ce44f889c55fb6482d54097bdcf4967bc9ae604ce878c4b9fb5
6
+ metadata.gz: 16af161d4bf57abc66a698475489d4c60aca33dd30f15d2a36fcc8fe731040550e7c245fface644c8d2c540470c4f92776c57f4e37de4d3aa5ccd3ff82c06a81
7
+ data.tar.gz: 4083657c5f9a193b7d636f458e2925c516b029a873b3c16f2095dd82705d89d3adf22f70341ac1a76f0c142d3b0cd441d73afc9c298207b46d5e75c73f732055
@@ -33,6 +33,7 @@ $pad: 2%
33
33
  +positionable-box($pad)
34
34
  z-index: 1000
35
35
  width: 5%
36
+ min-width: 4em
36
37
  padding-top: 1em
37
38
  cursor: pointer
38
39
  box-shadow: 0.2em 0.2em 1em rgba(128,64,0,0.8)
@@ -83,6 +84,10 @@ $pad: 2%
83
84
  &[data-target-corner="bottom-right"]
84
85
  bottom: 0
85
86
  right: 0
87
+ .media-flags
88
+ position: absolute
89
+ top: 40%
90
+ right: 45%
86
91
  .pin
87
92
  position: absolute
88
93
  top: 40%
@@ -10,6 +10,11 @@ module TellThem
10
10
  TellThemStore.instance.add(data)
11
11
  end
12
12
 
13
+ def self.enable_media_queries(data)
14
+ TellThemStore.instance.enable_media_queries(data)
15
+ end
16
+
17
+
13
18
  def self.has_data?
14
19
  TellThemStore.instance.has_data?
15
20
  end
@@ -18,6 +23,14 @@ module TellThem
18
23
  TellThemStore.instance.data
19
24
  end
20
25
 
26
+ def self.has_media_queries?
27
+ TellThemStore.instance.has_media_queries?
28
+ end
29
+
30
+ def self.media_queries
31
+ TellThemStore.instance.media_queries
32
+ end
33
+
21
34
  def self.html
22
35
  return '' unless has_data? && ::Rails.env.development?
23
36
  box_html.html_safe
@@ -26,7 +39,8 @@ module TellThem
26
39
  private
27
40
 
28
41
  def self.box_html
29
- box = '<div id="tell-them-box">'
42
+ box = media_queries_style_html
43
+ box += '<div id="tell-them-box">'
30
44
  box += ' <div class="contents">'
31
45
  box += ' <div class="controls">'
32
46
  box += ' <div class="corners">'
@@ -35,6 +49,7 @@ module TellThem
35
49
  box += ' <button data-target-corner="bottom-left"></button>'
36
50
  box += ' <button class="current" data-target-corner="bottom-right"></button>'
37
51
  box += ' </div>'
52
+ box += media_queries_flag_html
38
53
  box += ' <button class="pin">Pin</button>'
39
54
  box += ' </div>'
40
55
  box += ' <dl class="list">'
@@ -59,6 +74,30 @@ module TellThem
59
74
  value[0..MAX_URL_DISPLAY_LENGTH] + '...'
60
75
  end
61
76
 
77
+ def self.media_queries_style_html
78
+ return '' unless has_media_queries?
79
+ style_box = "<style>"
80
+ style_box += '#tell-them-box .media-flag { display: none; }' + "\n"
81
+
82
+ media_queries.each do |query_data|
83
+ style_box += '@media '
84
+ style_box += "(min-width: #{query_data[:min]}) " if query_data[:min]
85
+ style_box += ' and ' if query_data[:min] && query_data[:max]
86
+ style_box += "(max-width: #{query_data[:max]}) " if query_data[:max]
87
+ style_box += "{ \#tell-them-box .#{query_data[:name]} { display: block; } } \n"
88
+ end
89
+ style_box += "</style>"
90
+ end
91
+
92
+ def self.media_queries_flag_html
93
+ return '' unless has_media_queries?
94
+ flag_div = '<div class="media-flags">'
95
+ media_queries.each do |query_data|
96
+ flag_div += "<span class=\"media-flag #{query_data[:name]}\">#{query_data[:name].titleize}</span>"
97
+ end
98
+ flag_div += '</div>'
99
+ end
100
+
62
101
  class TellThemStore
63
102
  include Singleton
64
103
 
@@ -68,12 +107,17 @@ module TellThem
68
107
 
69
108
  def reset
70
109
  @data_store = {}
110
+ @media_queries = []
71
111
  end
72
112
 
73
113
  def add(data)
74
114
  data.each { |k,v| @data_store[k] = v }
75
115
  end
76
116
 
117
+ def enable_media_queries(data)
118
+ @media_queries = data
119
+ end
120
+
77
121
  def has_data?
78
122
  @data_store.any?
79
123
  end
@@ -81,5 +125,13 @@ module TellThem
81
125
  def data
82
126
  @data_store
83
127
  end
128
+
129
+ def has_media_queries?
130
+ @media_queries.any?
131
+ end
132
+
133
+ def media_queries
134
+ @media_queries
135
+ end
84
136
  end
85
137
  end
@@ -1,5 +1,5 @@
1
1
  module TellThem
2
2
  module Rails
3
- VERSION = "0.1.7"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tell-them
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - K M Lawrence
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties