navigator 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/README.md +34 -1
- data/lib/navigator/tag_activator.rb +10 -6
- data/lib/navigator/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3406e04b869c54a3190d36e050584f18783976
|
4
|
+
data.tar.gz: 803ae60045de98fd39b8a5ad9609760073542f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2b2d1b48c57428212a5d11af23837ff1b8a2725a5fb6ed08d80c80c2eca10f6e6d0d90b94283766f1e0e197ff449de4df681f1635613615fe81b6c89e710b0
|
7
|
+
data.tar.gz: a1929bdc13a9c05e246e637a8c71aef7de80bd684474ae3d9be85ecf5489f93165bb4c3747630e4a7bbac7e5dd319c8f5bcb8cc0665975f6809047e519f04b59
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
r����Br,�<�I�o�`��$�R��5ҫ�L" q[��в���z�8��o��}�N�e��o���!Ћ��r����[��#��K���ѨA�ӿ�+�uI�F�8��'3F�>���+h9n�� �k`�H+��!����ei\�˜�Q��<��d��0��dx*=o�B�{��Yht��ħ_0�<�a���4�L��OA74�����2�Yq_��l��aZ�
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Enhances Rails with a DSL for menu navigation.
|
|
11
11
|
|
12
12
|
# Features
|
13
13
|
|
14
|
-
- Provides a
|
14
|
+
- Provides a DSL for building navigation menus.
|
15
15
|
- Supports auto-detection/highlighting of active menu items based on current path (customizable for non-path usage too).
|
16
16
|
- Supports sub-menus, nested tags, HTML attributes, etc.
|
17
17
|
- Supports the following HTML tags:
|
@@ -316,6 +316,39 @@ This customization allows for more sophisticated detection/updating of active HT
|
|
316
316
|
<a href="/about" data-id="789">About</a>
|
317
317
|
</nav>
|
318
318
|
|
319
|
+
Lastly, the search value can be a *regular expression* to make things easier when dealing with complicated routes, sub-
|
320
|
+
menus, etc. Example:
|
321
|
+
|
322
|
+
# Code
|
323
|
+
profile_activator = Navigator::TagActivator.new search_value: /^profile.+/
|
324
|
+
|
325
|
+
navigation do
|
326
|
+
item "Dashboard", dashboard_path
|
327
|
+
li activator: profile_activator do
|
328
|
+
link "Profile", '#'
|
329
|
+
|
330
|
+
ul do
|
331
|
+
item "Addresses", profile_addresses_path
|
332
|
+
item "Emails", profile_emails_path
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
<!-- Result -->
|
338
|
+
<ul>
|
339
|
+
<li><a href="/dashboard">Dashboard</a></li>
|
340
|
+
<li class="active">
|
341
|
+
<a href="#">Profile</a>
|
342
|
+
<ul>
|
343
|
+
<li><a href="profile/addresses">Addresses</a></li>
|
344
|
+
<li><a href="profile/emails">Emails</a></li>
|
345
|
+
</ul>
|
346
|
+
</li>
|
347
|
+
</ul>
|
348
|
+
|
349
|
+
Assuming either the `Addresses` or `Emails` menu item was clicked, the `Profile` menu item would be active due to the
|
350
|
+
regular expression (i.e. `/^profile.+/`) matching one of the the `profile/*` paths.
|
351
|
+
|
319
352
|
# Tests
|
320
353
|
|
321
354
|
To test, run:
|
@@ -11,17 +11,21 @@ module Navigator
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def activatable? attributes = {}
|
14
|
-
|
15
|
-
search_value.present? && attributes[search_key] == search_value
|
16
|
-
end
|
14
|
+
return false unless search_value.present?
|
17
15
|
|
18
|
-
def activate attributes = {}
|
19
16
|
attributes = attributes.with_indifferent_access
|
17
|
+
current_search_value = attributes[search_key]
|
20
18
|
|
21
|
-
if
|
22
|
-
|
19
|
+
if current_search_value.is_a?(Regexp) || search_value.is_a?(Regexp)
|
20
|
+
!!(current_search_value =~ search_value)
|
21
|
+
else
|
22
|
+
current_search_value == search_value
|
23
23
|
end
|
24
|
+
end
|
24
25
|
|
26
|
+
def activate attributes = {}
|
27
|
+
attributes = attributes.with_indifferent_access
|
28
|
+
attributes[target_key] = [attributes[target_key], target_value].compact.join(' ') if activatable? attributes
|
25
29
|
attributes
|
26
30
|
end
|
27
31
|
end
|
data/lib/navigator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navigator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
fMlZDUGx3lQarp/vPjK+6XH7DLXjBEKqeIGBIpLthYUvDxJRp23C+T3liGSL32vg
|
31
31
|
mSpxxwmK95GDFuEy2mNPaxnazdkw8c+7DbrSpzd/CnNZkRgitxOavs8=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-04-
|
33
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: pry-byebug
|
metadata.gz.sig
CHANGED
Binary file
|