spurs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.markdown +118 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/images/spurs/icons/16x16/accept.png +0 -0
  5. data/app/assets/images/spurs/icons/16x16/delete.png +0 -0
  6. data/app/assets/images/spurs/icons/16x16/info.png +0 -0
  7. data/app/assets/images/spurs/icons/16x16/warning.png +0 -0
  8. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  9. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  10. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  11. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  12. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  13. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
  14. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  15. data/app/assets/images/spurs/jquery_ui_theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
  16. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_222222_256x240.png +0 -0
  17. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_2e83ff_256x240.png +0 -0
  18. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_454545_256x240.png +0 -0
  19. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_888888_256x240.png +0 -0
  20. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  21. data/app/assets/images/spurs/jquery_ui_theme/images/ui-icons_f6cf3b_256x240.png +0 -0
  22. data/app/assets/javascripts/spurs/application.js +15 -0
  23. data/app/assets/javascripts/spurs/flashes.js.coffee +30 -0
  24. data/app/assets/javascripts/spurs/flashes.js.erb +32 -0
  25. data/app/assets/javascripts/spurs/sections.js.coffee +9 -0
  26. data/app/assets/javascripts/spurs/vars.js.coffee.erb +6 -0
  27. data/app/assets/javascripts/spurs/vars.js.erb +10 -0
  28. data/app/assets/javascripts/spurs.js +20 -0
  29. data/app/assets/stylesheets/spurs/application.css +13 -0
  30. data/app/assets/stylesheets/spurs/jquery-ui-theme.css +13 -0
  31. data/app/assets/stylesheets/spurs/jquery_ui_theme/jquery-ui-1.8.16.custom.css +1320 -0
  32. data/app/assets/stylesheets/spurs/jquery_ui_theme/jquery.ui.1.8.16.ie.css +6 -0
  33. data/app/assets/stylesheets/spurs/sections.css.sass +17 -0
  34. data/app/assets/stylesheets/spurs/vcenter.css.sass +11 -0
  35. data/app/assets/stylesheets/spurs.css +14 -0
  36. data/app/controllers/spurs/application_controller.rb +4 -0
  37. data/app/controllers/spurs/flashes_controller.rb +11 -0
  38. data/app/helpers/spurs/application_helper.rb +4 -0
  39. data/app/helpers/spurs/flashes_helper.rb +4 -0
  40. data/app/views/layouts/spurs/application.html.erb +14 -0
  41. data/app/views/spurs/flashes/add_message.js.erb +3 -0
  42. data/app/views/spurs/modals/spawn.js.erb +17 -0
  43. data/config/locales/en.yml +5 -0
  44. data/config/routes.rb +6 -0
  45. data/lib/spurs/engine.rb +10 -0
  46. data/lib/spurs/flash/builder.rb +55 -0
  47. data/lib/spurs/flash/controller_mods.rb +43 -0
  48. data/lib/spurs/flash/helper.rb +161 -0
  49. data/lib/spurs/flash.rb +54 -0
  50. data/lib/spurs/modal/builder.rb +118 -0
  51. data/lib/spurs/modal/controller_mods.rb +49 -0
  52. data/lib/spurs/modal/helper.rb +25 -0
  53. data/lib/spurs/modal.rb +16 -0
  54. data/lib/spurs/nav/builder.rb +213 -0
  55. data/lib/spurs/nav/helper.rb +42 -0
  56. data/lib/spurs/nav.rb +23 -0
  57. data/lib/spurs/popover/builder.rb +7 -0
  58. data/lib/spurs/popover/helper.rb +8 -0
  59. data/lib/spurs/popover.rb +5 -0
  60. data/lib/spurs/section/collapsible_section_builder.rb +31 -0
  61. data/lib/spurs/section/helper.rb +37 -0
  62. data/lib/spurs/section.rb +15 -0
  63. data/lib/spurs/version.rb +3 -0
  64. data/lib/spurs.rb +26 -0
  65. data/lib/tasks/spurs_tasks.rake +4 -0
  66. data/test/dummy/README.rdoc +261 -0
  67. data/test/dummy/Rakefile +7 -0
  68. data/test/dummy/app/assets/javascripts/application.js +15 -0
  69. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  70. data/test/dummy/app/controllers/application_controller.rb +3 -0
  71. data/test/dummy/app/helpers/application_helper.rb +2 -0
  72. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  73. data/test/dummy/config/application.rb +56 -0
  74. data/test/dummy/config/boot.rb +10 -0
  75. data/test/dummy/config/database.yml +25 -0
  76. data/test/dummy/config/environment.rb +5 -0
  77. data/test/dummy/config/environments/development.rb +37 -0
  78. data/test/dummy/config/environments/production.rb +67 -0
  79. data/test/dummy/config/environments/test.rb +37 -0
  80. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  81. data/test/dummy/config/initializers/inflections.rb +15 -0
  82. data/test/dummy/config/initializers/mime_types.rb +5 -0
  83. data/test/dummy/config/initializers/secret_token.rb +7 -0
  84. data/test/dummy/config/initializers/session_store.rb +8 -0
  85. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  86. data/test/dummy/config/locales/en.yml +5 -0
  87. data/test/dummy/config/routes.rb +4 -0
  88. data/test/dummy/config.ru +4 -0
  89. data/test/dummy/public/404.html +26 -0
  90. data/test/dummy/public/422.html +26 -0
  91. data/test/dummy/public/500.html +25 -0
  92. data/test/dummy/public/favicon.ico +0 -0
  93. data/test/dummy/script/rails +6 -0
  94. data/test/functional/spurs/flashes_controller_test.rb +9 -0
  95. data/test/integration/navigation_test.rb +10 -0
  96. data/test/spurs_test.rb +7 -0
  97. data/test/test_helper.rb +15 -0
  98. data/test/unit/helpers/spurs/flashes_helper_test.rb +6 -0
  99. 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
@@ -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,6 @@
1
+ if !window.spurs then window.spurs = {}
2
+
3
+ window.spurs.vars = flashes:
4
+ create_path: "spurs/flashes"
5
+ container_class: "<%=Spurs::Flash::Helper::flashes_container_class%>"
6
+ container_id_prefix: "<%=Spurs::Flash::Helper::flashes_container_id_prefix%>"
@@ -0,0 +1,10 @@
1
+ var spurs = spurs ? spurs : {};
2
+
3
+ spurs.vars = {
4
+ flashes: {
5
+ create_path:"spurs/flashes",
6
+ container_class:"<%=Spurs::Flash::Helper::flashes_container_class%>",
7
+ container_id_prefix:"<%=Spurs::Flash::Helper::flashes_container_id_prefix%>",
8
+ }
9
+
10
+ }
@@ -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
+ */