purecss 0.0.2 → 0.0.3
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 +8 -8
- data/README.md +58 -15
- data/app/assets/javascripts/purecss-dropdown.js +172 -0
- data/lib/purecss/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGRlZWVmZGY4NGIyMDgwYzg0MjZjNTJlYTZjMzI5MTA1OGFhZGFiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjQyMDQxNTVlYjllNWY0MDUwOGFjNjc0MDFiNzVlNDlmM2IyOTNiNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2QyODljYzVmNjE2YzZlZDVlODUxYmRjZDdjMmQ1NjgwOTEwNmE2MDVmMzVk
|
10
|
+
NzdmOTJhZGQ5OWUzNDNiN2UzYzExOGQyOThkOGU5OTAzZjVkMGMzYzYyODli
|
11
|
+
YWQ2MTdiNDQzMzEwNWJhMWRhNzFmMDIwOTNjODZiYWQzMzQyYWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjM4M2IwZGQ1M2ZjZjA0Yzc4NWZhMzgxZDg5OWRhNWVlN2M4MmFhZThhNjk3
|
14
|
+
YWRmOGRjODgyMmM4NmU1ZDBkOWJhMzBhMWRkOWQ2NThkZjhiZmQwZDNhNDk0
|
15
|
+
NzU2OWIzMWRhZDg4NGNhYzg4ZjU4NDg3MWQ4MjMxYTZmZjZiZDA=
|
data/README.md
CHANGED
@@ -8,17 +8,6 @@ I cite directly from [purecss.io](http://purecss.io)
|
|
8
8
|
>
|
9
9
|
> Pure is ridiculously tiny. The entire set of modules clocks in at 5.7KB minified and gzipped, without forgoing responsive styles, design, or ease of use. Crafted with mobile devices in mind, it was important to us to keep our file sizes small, and every line of CSS was carefully considered. If you decide to only use a subset of these modules, you'll save even more bytes.
|
10
10
|
|
11
|
-
## TODO
|
12
|
-
|
13
|
-
I liked the idea of the light and functional Pure CSS and I think it is worthwile to create a gem for it.
|
14
|
-
I'd like to make something like [twitter-bootstrap-rails](https://github.com/seyhunak/twitter-bootstrap-rails) (and compatible with it)
|
15
|
-
|
16
|
-
I'd like to add
|
17
|
-
- Helpers for navigation bars, menus, forms, grids, ...
|
18
|
-
- Toolkit to set up website palette in an easy way
|
19
|
-
- Integration wit Rails SCSS
|
20
|
-
- System to keep the css updated
|
21
|
-
- Any ideas?
|
22
11
|
|
23
12
|
## Installation
|
24
13
|
|
@@ -33,18 +22,18 @@ And then execute:
|
|
33
22
|
|
34
23
|
Then you can add the following directives to your css manifest file (application.css):
|
35
24
|
|
36
|
-
|
25
|
+
*= require purecss
|
37
26
|
|
38
27
|
for the responsive bundle, or
|
39
28
|
|
40
|
-
|
29
|
+
*= require purecss-nr
|
41
30
|
|
42
31
|
for the non-responsive one.
|
43
32
|
|
44
33
|
|
45
34
|
If you want to include just an individual module (see [purecss.io](http://purecss.io)) add instead
|
46
35
|
|
47
|
-
|
36
|
+
*= require purecss/<module>.js
|
48
37
|
|
49
38
|
|
50
39
|
|
@@ -57,9 +46,58 @@ If it is too long for you, you can avoid touching the manifest files and run the
|
|
57
46
|
|
58
47
|
After the installation you can simply go to [purecss.io](http://purecss.io) and use (or extend) their predefined styles.
|
59
48
|
|
60
|
-
|
61
49
|
Enjoy!
|
62
50
|
|
51
|
+
### Dropdown Menu
|
52
|
+
|
53
|
+
For dropdown menu I developed a small workaround based on [bootstrap-dropdown.js](https://github.com/twitter/bootstrap/blob/master/js/bootstrap-dropdown.js).
|
54
|
+
It is enough to add the following directive to your js manifest file (application.js):
|
55
|
+
|
56
|
+
//= require purecss-dropdown
|
57
|
+
|
58
|
+
and then use the class ```pure-menu-has-children``` for the ```li``` that will contain the submenu,
|
59
|
+
add ```data-toggle="dropdown"``` to its label element (tipically an anchor),
|
60
|
+
and use the class ```pure-menu-children``` for the ```ul``` that contains the submenu.
|
61
|
+
|
62
|
+
I hope it is clear with the following example:
|
63
|
+
```
|
64
|
+
<header class="header pure-u-1">
|
65
|
+
<div class="pure-menu pure-menu-open pure-menu-fixed pure-menu-horizontal">
|
66
|
+
<ul>
|
67
|
+
<li><%= link_to "Home", root_path %></li>
|
68
|
+
<li><%= link_to "Help", help_path %></li>
|
69
|
+
<% if signed_in? %>
|
70
|
+
<li><%= link_to "Users", users_path %></li>
|
71
|
+
<li class="puren-menu-has-children">
|
72
|
+
<a href="#" data-toggle="dropdown">Account</a>
|
73
|
+
<ul class="pure-menu-children" role="menu">
|
74
|
+
<li><%= link_to "Profile", current_user %></li>
|
75
|
+
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
|
76
|
+
<li class="pure-menu-separator"></li>
|
77
|
+
<li>
|
78
|
+
<%= link_to "Sign Out", signout_path, method: "delete" %>
|
79
|
+
</li>
|
80
|
+
</ul>
|
81
|
+
</li>
|
82
|
+
<% else %>
|
83
|
+
<li><%= link_to "Sign In", signin_path %></li>
|
84
|
+
<% end %>
|
85
|
+
</ul>
|
86
|
+
</div>
|
87
|
+
</header>
|
88
|
+
```
|
89
|
+
|
90
|
+
## TODO
|
91
|
+
|
92
|
+
I liked the idea of the light and functional Pure CSS and I think it is worthwile to create a gem for it.
|
93
|
+
|
94
|
+
I'd like to add
|
95
|
+
- Helpers for navigation bars, menus, forms, grids, ...
|
96
|
+
- Integration wit Rails SCSS
|
97
|
+
- Toolkit to set up website palette in an easy way using SCSS
|
98
|
+
- Way to keep the css updated
|
99
|
+
- Any other ideas?
|
100
|
+
|
63
101
|
|
64
102
|
## Contributing
|
65
103
|
|
@@ -68,3 +106,8 @@ Enjoy!
|
|
68
106
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
107
|
4. Push to the branch (`git push origin my-new-feature`)
|
70
108
|
5. Create new Pull Request
|
109
|
+
|
110
|
+
## Changelog
|
111
|
+
|
112
|
+
0.0.2 GEM restructured following [Gemify Assets for Rails](http://prioritized.net/blog/gemify-assets-for-rails/), added individual modules, improved size
|
113
|
+
|
@@ -0,0 +1,172 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* purecss-dropdown.js v2.3.2
|
3
|
+
* ============================================================
|
4
|
+
* Copyright 2013 Marcello Seri
|
5
|
+
* Based on Twitter Bootstrap
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
|
21
|
+
!function ($) {
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* DROPDOWN CLASS DEFINITION
|
27
|
+
* ========================= */
|
28
|
+
|
29
|
+
var toggle = '[data-toggle=dropdown]'
|
30
|
+
, Dropdown = function (element) {
|
31
|
+
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
32
|
+
$('html').on('click.dropdown.data-api', function () {
|
33
|
+
$el.parent().removeClass('pure-menu-open')
|
34
|
+
$el.parent().children('.pure-menu-children').css({"left":"-10710px", "top":"-12216px"})
|
35
|
+
})
|
36
|
+
}
|
37
|
+
|
38
|
+
Dropdown.prototype = {
|
39
|
+
|
40
|
+
constructor: Dropdown
|
41
|
+
|
42
|
+
, toggle: function (e) {
|
43
|
+
var $this = $(this)
|
44
|
+
, $parent
|
45
|
+
, isActive
|
46
|
+
|
47
|
+
if ($this.is('.pure-menu-disabled, :disabled')) return
|
48
|
+
|
49
|
+
$parent = getParent($this)
|
50
|
+
|
51
|
+
isActive = $parent.hasClass('pure-menu-open')
|
52
|
+
|
53
|
+
clearMenus()
|
54
|
+
|
55
|
+
if (!isActive) {
|
56
|
+
if ('ontouchstart' in document.documentElement) {
|
57
|
+
// if mobile we we use a backdrop because click events don't delegate
|
58
|
+
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
|
59
|
+
}
|
60
|
+
$parent.toggleClass('pure-menu-open')
|
61
|
+
$parent.children('.pure-menu-children').css({"left":"0px", "top":"36px"})
|
62
|
+
}
|
63
|
+
|
64
|
+
$this.focus()
|
65
|
+
|
66
|
+
return false
|
67
|
+
}
|
68
|
+
|
69
|
+
, keydown: function (e) {
|
70
|
+
var $this
|
71
|
+
, $items
|
72
|
+
, $active
|
73
|
+
, $parent
|
74
|
+
, isActive
|
75
|
+
, index
|
76
|
+
|
77
|
+
if (!/(38|40|27)/.test(e.keyCode)) return
|
78
|
+
|
79
|
+
$this = $(this)
|
80
|
+
|
81
|
+
e.preventDefault()
|
82
|
+
e.stopPropagation()
|
83
|
+
|
84
|
+
if ($this.is('.pure-menu-disabled, :disabled')) return
|
85
|
+
|
86
|
+
$parent = getParent($this)
|
87
|
+
|
88
|
+
isActive = $parent.hasClass('pure-menu-open')
|
89
|
+
|
90
|
+
if (!isActive || (isActive && e.keyCode == 27)) {
|
91
|
+
if (e.which == 27) $parent.find(toggle).focus()
|
92
|
+
return $this.click()
|
93
|
+
}
|
94
|
+
|
95
|
+
$items = $('[role=menu] li:not(.divider):visible a', $parent)
|
96
|
+
|
97
|
+
if (!$items.length) return
|
98
|
+
|
99
|
+
index = $items.index($items.filter(':focus'))
|
100
|
+
|
101
|
+
if (e.keyCode == 38 && index > 0) index-- // up
|
102
|
+
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
103
|
+
if (!~index) index = 0
|
104
|
+
|
105
|
+
$items
|
106
|
+
.eq(index)
|
107
|
+
.focus()
|
108
|
+
}
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
function clearMenus() {
|
113
|
+
$('.dropdown-backdrop').remove()
|
114
|
+
$(toggle).each(function () {
|
115
|
+
getParent($(this)).removeClass('pure-menu-open')
|
116
|
+
getParent($(this)).children('.pure-menu-children').css({"left":"0px", "top":"36px"})
|
117
|
+
})
|
118
|
+
}
|
119
|
+
|
120
|
+
function getParent($this) {
|
121
|
+
var selector = $this.attr('data-target')
|
122
|
+
, $parent
|
123
|
+
|
124
|
+
if (!selector) {
|
125
|
+
selector = $this.attr('href')
|
126
|
+
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
127
|
+
}
|
128
|
+
|
129
|
+
$parent = selector && $(selector)
|
130
|
+
|
131
|
+
if (!$parent || !$parent.length) $parent = $this.parent()
|
132
|
+
|
133
|
+
return $parent
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
/* DROPDOWN PLUGIN DEFINITION
|
138
|
+
* ========================== */
|
139
|
+
|
140
|
+
var old = $.fn.dropdown
|
141
|
+
|
142
|
+
$.fn.dropdown = function (option) {
|
143
|
+
return this.each(function () {
|
144
|
+
var $this = $(this)
|
145
|
+
, data = $this.data('dropdown')
|
146
|
+
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
147
|
+
if (typeof option == 'string') data[option].call($this)
|
148
|
+
})
|
149
|
+
}
|
150
|
+
|
151
|
+
$.fn.dropdown.Constructor = Dropdown
|
152
|
+
|
153
|
+
|
154
|
+
/* DROPDOWN NO CONFLICT
|
155
|
+
* ==================== */
|
156
|
+
|
157
|
+
$.fn.dropdown.noConflict = function () {
|
158
|
+
$.fn.dropdown = old
|
159
|
+
return this
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
164
|
+
* =================================== */
|
165
|
+
|
166
|
+
$(document)
|
167
|
+
.on('click.dropdown.data-api', clearMenus)
|
168
|
+
.on('click.dropdown.data-api', '.puren-menu-has-children form', function (e) { e.stopPropagation() })
|
169
|
+
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
|
170
|
+
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
|
171
|
+
|
172
|
+
}(window.jQuery);
|
data/lib/purecss/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purecss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mseri
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- app/assets/javascripts/purecss-dropdown.js
|
62
63
|
- lib/purecss/engine.rb
|
63
64
|
- lib/purecss/generators/install_generator.rb
|
64
65
|
- lib/purecss/generators/templaets/application.css
|