spurs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +118 -0
- data/Rakefile +40 -0
- data/app/assets/images/spurs/icons/16x16/accept.png +0 -0
- data/app/assets/images/spurs/icons/16x16/delete.png +0 -0
- data/app/assets/images/spurs/icons/16x16/info.png +0 -0
- data/app/assets/images/spurs/icons/16x16/warning.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_f6cf3b_256x240.png +0 -0
- data/app/assets/javascripts/spurs/application.js +15 -0
- data/app/assets/javascripts/spurs/flashes.js.coffee +30 -0
- data/app/assets/javascripts/spurs/flashes.js.erb +32 -0
- data/app/assets/javascripts/spurs/sections.js.coffee +9 -0
- data/app/assets/javascripts/spurs/vars.js.coffee.erb +6 -0
- data/app/assets/javascripts/spurs/vars.js.erb +10 -0
- data/app/assets/javascripts/spurs.js +20 -0
- data/app/assets/stylesheets/spurs/application.css +13 -0
- data/app/assets/stylesheets/spurs/jquery-ui-theme.css +13 -0
- data/app/assets/stylesheets/spurs/jquery_ui_theme/jquery-ui-1.8.16.custom.css +1320 -0
- data/app/assets/stylesheets/spurs/jquery_ui_theme/jquery.ui.1.8.16.ie.css +6 -0
- data/app/assets/stylesheets/spurs/sections.css.sass +17 -0
- data/app/assets/stylesheets/spurs/vcenter.css.sass +11 -0
- data/app/assets/stylesheets/spurs.css +14 -0
- data/app/controllers/spurs/application_controller.rb +4 -0
- data/app/controllers/spurs/flashes_controller.rb +11 -0
- data/app/helpers/spurs/application_helper.rb +4 -0
- data/app/helpers/spurs/flashes_helper.rb +4 -0
- data/app/views/layouts/spurs/application.html.erb +14 -0
- data/app/views/spurs/flashes/add_message.js.erb +3 -0
- data/app/views/spurs/modals/spawn.js.erb +17 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +6 -0
- data/lib/spurs/engine.rb +10 -0
- data/lib/spurs/flash/builder.rb +55 -0
- data/lib/spurs/flash/controller_mods.rb +43 -0
- data/lib/spurs/flash/helper.rb +161 -0
- data/lib/spurs/flash.rb +54 -0
- data/lib/spurs/modal/builder.rb +118 -0
- data/lib/spurs/modal/controller_mods.rb +49 -0
- data/lib/spurs/modal/helper.rb +25 -0
- data/lib/spurs/modal.rb +16 -0
- data/lib/spurs/nav/builder.rb +213 -0
- data/lib/spurs/nav/helper.rb +42 -0
- data/lib/spurs/nav.rb +23 -0
- data/lib/spurs/popover/builder.rb +7 -0
- data/lib/spurs/popover/helper.rb +8 -0
- data/lib/spurs/popover.rb +5 -0
- data/lib/spurs/section/collapsible_section_builder.rb +31 -0
- data/lib/spurs/section/helper.rb +37 -0
- data/lib/spurs/section.rb +15 -0
- data/lib/spurs/version.rb +3 -0
- data/lib/spurs.rb +26 -0
- data/lib/tasks/spurs_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/functional/spurs/flashes_controller_test.rb +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/spurs_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/helpers/spurs/flashes_helper_test.rb +6 -0
- metadata +224 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 TrueNorth Applications, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Spurs
|
2
|
+
|
3
|
+
Spurs is a library that adds some bells and whistles to the Twitter Bootstrap GUI framework. I consists mostly of helpers and javascript, and thus is ORM agnostic.
|
4
|
+
|
5
|
+
## Flash Messages
|
6
|
+
|
7
|
+
Put this in your layout file wherever you want to render the flash messages
|
8
|
+
|
9
|
+
<%= spurs_flash_helper %>
|
10
|
+
|
11
|
+
and flash messages will be automatically rendered on page loads
|
12
|
+
|
13
|
+
### From the rails side
|
14
|
+
|
15
|
+
By default, you can create four types of messages
|
16
|
+
|
17
|
+
flash_addItem(:notices,"A message about something successfully happening!")
|
18
|
+
flash_addItem(:warnings, "Something is unusual, but not absolutely critical")
|
19
|
+
flash_addItem(:errors, "Something critical has happened")
|
20
|
+
flash_addItem(:infos, "Here's some information")
|
21
|
+
|
22
|
+
You can also create multiple messages for each type
|
23
|
+
|
24
|
+
flash_addItem(:errors, "Problem validating phone number")
|
25
|
+
flash_addItem(:errors, "Problem validating street address")
|
26
|
+
|
27
|
+
### From the javascript side
|
28
|
+
|
29
|
+
You can also create matching flash messages via javascript
|
30
|
+
|
31
|
+
spurs.flash.alert("Something has gone wrong!","error");
|
32
|
+
|
33
|
+
for the singular versions of each of the four types above ("info", "warning", "error", "notice")
|
34
|
+
|
35
|
+
## Navigation
|
36
|
+
|
37
|
+
Spurs makes creation of bootstrap navigation easy!.
|
38
|
+
|
39
|
+
spurs_nav :type => :pills do |nav|
|
40
|
+
|
41
|
+
# a simple nav item as a regular link
|
42
|
+
nav.tab :user, :icon => :user, :href => "#user"
|
43
|
+
|
44
|
+
# a nav item that runs some javascript
|
45
|
+
nav.tab :settings, :icon => :cog, :onclick => "alert('hello');"
|
46
|
+
|
47
|
+
# a nav item that only shows its icon (not its name)
|
48
|
+
nav.tab :secure, :icon => :lock, :icon_only => true
|
49
|
+
|
50
|
+
# a dropdown menu with two actions
|
51
|
+
nav.dropdown :menu,
|
52
|
+
:icon => :cog,
|
53
|
+
:icon_only => true,
|
54
|
+
:actions => [ {:name => "one", :icon => :plus, :href => "#one"},
|
55
|
+
{:name => "two", :icon => :minus, :href => "#two"}]
|
56
|
+
|
57
|
+
will generate a menu like this...
|
58
|
+
|
59
|
+
![image](https://github.com/TrueNorth/spurs/raw/master/docs/img/pic1.png)
|
60
|
+
|
61
|
+
or in HTML...
|
62
|
+
|
63
|
+
<ul class="nav nav-pills ">
|
64
|
+
<li>
|
65
|
+
<a href="#user">
|
66
|
+
<i class="icon-user"></i>User
|
67
|
+
</a>
|
68
|
+
</li>
|
69
|
+
<li>
|
70
|
+
<a onclick="alert('hello');">
|
71
|
+
<i class="icon-cog"></i>Settings
|
72
|
+
</a>
|
73
|
+
</li>
|
74
|
+
<li>
|
75
|
+
<a>
|
76
|
+
<i class="icon-lock"></i>Secure
|
77
|
+
</a>
|
78
|
+
</li>
|
79
|
+
<li class="dropdown" data-dropdown="dropdown">
|
80
|
+
<a class="dropdown-toggle" data-toggle="dropdown">
|
81
|
+
<i class="icon-cog"></i>
|
82
|
+
<b class="caret"></b>
|
83
|
+
</a>
|
84
|
+
<ul class="dropdown-menu">
|
85
|
+
<li>
|
86
|
+
<a href="#one">
|
87
|
+
<i class="icon-plus"></i>No Name
|
88
|
+
</a>
|
89
|
+
</li>
|
90
|
+
<li>
|
91
|
+
<a href="#two">
|
92
|
+
<i class="icon-minus"></i>No Name
|
93
|
+
</a>
|
94
|
+
</li>
|
95
|
+
</ul>
|
96
|
+
</li>
|
97
|
+
</ul>
|
98
|
+
|
99
|
+
You can specify some active criteria for menu items
|
100
|
+
|
101
|
+
spurs_nav :type => :pills do |nav|
|
102
|
+
|
103
|
+
# force this to be active with a boolean
|
104
|
+
nav.tab :user, :icon => :user, :href => "#user",
|
105
|
+
:active => true
|
106
|
+
|
107
|
+
# controller criteria (if controller_name == :settings)
|
108
|
+
nav.tab :settings, :icon => :cog, :onclick => "alert('hello');",
|
109
|
+
:active => {:controller => :settings}
|
110
|
+
|
111
|
+
# controller and action criteria (if controller_name == :settings && action_name == ;edit)
|
112
|
+
nav.tab :settings, :icon => :cog, :onclick => "alert('hello');",
|
113
|
+
:active => {:controller => :settings, :action => :edit}
|
114
|
+
|
115
|
+
# multiple controller/action criteria (if (controller_name == :settings && action_name == :edit) || (controller_name == :user && action_name == :edit)
|
116
|
+
nav.tab :settings, :icon => :cog, :onclick => "alert('hello');",
|
117
|
+
:active => [{:controller => :settings, :action => :edit},
|
118
|
+
{:controller => :users, :action => :edit}]
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Spurs'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,30 @@
|
|
1
|
+
if !window.spurs then window.spurs = {}
|
2
|
+
|
3
|
+
window.spurs.flashes =
|
4
|
+
highest_priority_flash_container: ->
|
5
|
+
highest = -100
|
6
|
+
highest_item = null
|
7
|
+
$("." + spurs.vars.flashes.container_class).each (idx, item) ->
|
8
|
+
priority = parseInt($(item).attr("id").substring($("." + spurs.vars.flashes.container_class).attr("id").indexOf(spurs.vars.flashes.container_id_prefix) + spurs.vars.flashes.container_id_prefix.length))
|
9
|
+
if priority > highest
|
10
|
+
highest = priority
|
11
|
+
highest_item = $(item)
|
12
|
+
highest_item
|
13
|
+
|
14
|
+
lowest_priority_flash_container: ->
|
15
|
+
lowest = 9999
|
16
|
+
lowest_item = null
|
17
|
+
$("." + spurs.vars.flashes.container_class).each (idx, item) ->
|
18
|
+
priority = parseInt($(item).attr("id").substring($("." + spurs.vars.flashes.container_class).attr("id").indexOf(spurs.vars.flashes.container_id_prefix) + spurs.vars.flashes.container_id_prefix.length))
|
19
|
+
if priority < lowest
|
20
|
+
lowest = priority
|
21
|
+
lowest_item = $(item)
|
22
|
+
lowest_item
|
23
|
+
|
24
|
+
alert: (message, flavor) ->
|
25
|
+
$.ajax
|
26
|
+
url: spurs.vars.flashes.create_path + ".js"
|
27
|
+
type: "POST"
|
28
|
+
data:
|
29
|
+
message: message
|
30
|
+
flavor: flavor
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
// All this logic will automatically be available in application.js.
|
3
|
+
var spurs = spurs ? spurs : {};
|
4
|
+
|
5
|
+
spurs.flashes = {
|
6
|
+
|
7
|
+
highest_priority_flash_container:function () {
|
8
|
+
var highest = -100;
|
9
|
+
var highest_item = null;
|
10
|
+
$('.' + spurs.vars.flashes.container_class).each(
|
11
|
+
function (idx, item) {
|
12
|
+
priority = parseInt($(item).attr('id').substring($('.' + spurs.vars.flashes.container_class).attr('id').indexOf(spurs.vars.flashes.container_id_prefix) + spurs.vars.flashes.container_id_prefix.length));
|
13
|
+
if (priority > highest) {
|
14
|
+
highest = priority;
|
15
|
+
highest_item = $(item);
|
16
|
+
}
|
17
|
+
|
18
|
+
});
|
19
|
+
return highest_item;
|
20
|
+
},
|
21
|
+
alert:function (message, flavor) {
|
22
|
+
$.ajax({
|
23
|
+
url: spurs.vars.flashes.create_path + '.js',
|
24
|
+
type:'POST',
|
25
|
+
data:{
|
26
|
+
message:message,
|
27
|
+
flavor:flavor
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
if !window.spurs then window.spurs = {}
|
2
|
+
|
3
|
+
window.spurs.sections = toggle: (section) ->
|
4
|
+
if section.hasClass("open")
|
5
|
+
section.removeClass "open"
|
6
|
+
section.find(".section_toggle").html "<i class=\"icon-chevron-right\"></i>"
|
7
|
+
else
|
8
|
+
section.addClass "open"
|
9
|
+
section.find(".section_toggle").html "<i class=\"icon-chevron-down\"></i>"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
|
16
|
+
//= require ./spurs/vars
|
17
|
+
//= require ./spurs/flashes
|
18
|
+
//= require ./spurs/sections
|
19
|
+
|
20
|
+
var spurs = window.spurs;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require ./jquery_ui_theme/jquery-ui-1.8.16.custom.css
|
13
|
+
*/
|