spurs 0.0.4 → 0.0.5.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +61 -12
- data/app/views/spurs/modals/spawn.js.erb +42 -1
- data/lib/spurs/version.rb +1 -1
- metadata +10 -13
data/README.markdown
CHANGED
@@ -1,25 +1,37 @@
|
|
1
1
|
# Spurs
|
2
2
|
|
3
|
-
Spurs is a library that adds some bells and whistles to the Twitter Bootstrap GUI framework.
|
3
|
+
Spurs is a library that adds some bells and whistles to the Twitter Bootstrap GUI framework.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Installation
|
6
|
+
There are many independent components of spurs, and some require more set up than others.
|
7
|
+
|
8
|
+
To get started, in your gemfile, add
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'spurs'
|
12
|
+
```
|
13
|
+
|
14
|
+
and then run
|
6
15
|
|
7
|
-
|
8
|
-
|
9
|
-
<%= spurs_flash_helper %>
|
16
|
+
```ruby
|
17
|
+
bundle install
|
10
18
|
```
|
11
|
-
and flash messages will be automatically rendered on page loads
|
12
19
|
|
13
|
-
|
20
|
+
## Flash Messages
|
14
21
|
|
15
|
-
|
16
|
-
* :warning
|
17
|
-
* :info
|
18
|
-
* :error
|
22
|
+
From the rails side, you can create four types of messages: `:notice`, `:warning`, `:info` and `:error`
|
19
23
|
|
20
24
|
```ruby
|
21
25
|
flash_addItem(:notices,"A message about something successfully happening!")
|
22
26
|
```
|
27
|
+
It's especially easy to add model errors as flash messages. Here's a typical use
|
28
|
+
```ruby
|
29
|
+
m = Message.new(:title => "hello", :body => "world!")
|
30
|
+
if !m.save
|
31
|
+
flash_addModelErrors(m)
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
23
35
|
|
24
36
|
You can also use JavaScript to generate matching messages
|
25
37
|
```javascript
|
@@ -35,4 +47,41 @@ Spurs makes creation of bootstrap navigation easy!.
|
|
35
47
|
= nav.tab :user, :icon => :user, :href => "#user"
|
36
48
|
= nav.tab :settings, :icon => :cog, :onclick => "alert('hello');"
|
37
49
|
```
|
38
|
-
[More...](https://github.com/TrueNorth/spurs/wiki/Navigation)
|
50
|
+
[More...](https://github.com/TrueNorth/spurs/wiki/Navigation)
|
51
|
+
|
52
|
+
## Alerts
|
53
|
+
Alerts are styled to match flash messages. Creating an in-place alert is done as follows
|
54
|
+
```haml
|
55
|
+
= spurs_alert_box do
|
56
|
+
This is a basic alert
|
57
|
+
```
|
58
|
+
[More...](https://github.com/TrueNorth/spurs/wiki/Alerts)
|
59
|
+
|
60
|
+
## Asynchronous Modals
|
61
|
+
Spurs can present a modal as a response to an asynchronous request.
|
62
|
+
|
63
|
+
For example, if your request is
|
64
|
+
```javascript
|
65
|
+
$.get({url: '/blogs/MY_BLOG/posts/new.js'});
|
66
|
+
```
|
67
|
+
Your controller response might look like
|
68
|
+
```ruby
|
69
|
+
@blog = Blog.find(params[:blog_id])
|
70
|
+
respond_to do |format|
|
71
|
+
format.js {
|
72
|
+
spawn_modal("Create a new blog post", #Title of the modal
|
73
|
+
"blogs/posts/new", # Path to a partial to render in the modal body.
|
74
|
+
@blog, # Object that the partial is rendering. Can be nil if the previous argument is not a partial
|
75
|
+
:title_icon => '/assets/new_blog_post_icon.png' # Path to an icon shown in the title bar of the modal
|
76
|
+
:modal_options => {} # A hash passed to the partial as local variables
|
77
|
+
)
|
78
|
+
}
|
79
|
+
end
|
80
|
+
```
|
81
|
+
You can also use a method
|
82
|
+
```ruby
|
83
|
+
spawn_form_modal(...) #same arguments as spawn_modal
|
84
|
+
```
|
85
|
+
which will show a modal with an "OK" button in the footer. Pressing this button will submit any form in the .modal-body div.
|
86
|
+
|
87
|
+
|
@@ -17,6 +17,47 @@ $('body')[0].appendChild(modal_container);
|
|
17
17
|
%>
|
18
18
|
modal_container.innerHTML = "<%= modal_container_content %>";
|
19
19
|
|
20
|
+
if ($(modal_container.children[0]).find('.javascript-hooks').size() > 0) {
|
21
|
+
var js_hooks = $(modal_container.children[0]).find('.javascript-hooks');
|
22
|
+
var modal = $(modal_container.children[0]);
|
23
|
+
|
24
|
+
modal.on('hidden', function () {
|
25
|
+
js_hooks.each(function (idx, item) {
|
26
|
+
if ($(item).attr('onhidden')) {
|
27
|
+
eval($(item).attr('onhidden'));
|
28
|
+
}
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
modal.on('hide', function () {
|
33
|
+
js_hooks.each(function (idx, item) {
|
34
|
+
if ($(item).attr('onhide')) {
|
35
|
+
eval($(item).attr('onhide'));
|
36
|
+
}
|
37
|
+
});
|
38
|
+
});
|
39
|
+
|
40
|
+
modal.on('show', function () {
|
41
|
+
js_hooks.each(function (idx, item) {
|
42
|
+
if ($(item).attr('onShow')) {
|
43
|
+
eval($(item).attr('onShow'));
|
44
|
+
}
|
45
|
+
});
|
46
|
+
});
|
47
|
+
|
48
|
+
modal.on('shown', function () {
|
49
|
+
js_hooks.each(function (idx, item) {
|
50
|
+
if ($(item).attr('onshown')) {
|
51
|
+
console.log($(item));
|
52
|
+
eval($(item).attr('onshown'));
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
20
58
|
//activate the modal
|
21
59
|
$(modal_container.children[0]).modal();
|
22
|
-
|
60
|
+
|
61
|
+
if(window._asd != undefined) {
|
62
|
+
window._asd();
|
63
|
+
}
|
data/lib/spurs/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spurs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5.alpha.1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael North
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.2
|
21
|
+
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.2
|
29
|
+
version: '3.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: twitter-bootstrap-rails
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.1
|
53
|
+
version: '3.1'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.1
|
61
|
+
version: '3.1'
|
62
62
|
description: Helpers and extensions for the Twitter Bootstrap user interface
|
63
63
|
email:
|
64
64
|
- michael.north@truenorthapps.com
|
@@ -187,16 +187,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
segments:
|
189
189
|
- 0
|
190
|
-
hash:
|
190
|
+
hash: -3368848817584840058
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
none: false
|
193
193
|
requirements:
|
194
|
-
- - ! '
|
194
|
+
- - ! '>'
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
197
|
-
segments:
|
198
|
-
- 0
|
199
|
-
hash: 671741386239326010
|
196
|
+
version: 1.3.1
|
200
197
|
requirements: []
|
201
198
|
rubyforge_project:
|
202
199
|
rubygems_version: 1.8.24
|