twitter_bootstrap_helpers 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,18 @@
1
1
  twitter_bootstrap_helpers
2
2
  =========================
3
3
 
4
- Хелперы для Twitter Bootstrap
4
+ nav_tabs
5
+ ========
6
+
7
+
8
+ ```
9
+ = nav_tabs do |tabs|
10
+ = tabs.pane 'id1', 'title', :active => true, :tooltip => 'tooltip' do
11
+ = 'content1'
12
+ = tabs.pane 'id2', 'title2', :tooltip => 'tooltip' do
13
+ = 'content1'
14
+ ```
15
+
16
+
17
+
18
+ Хелперы для Twitter Bootstrap
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -36,7 +36,7 @@ module BootstrapHelper
36
36
  #
37
37
  def error_notification(form)
38
38
  if form.error_notification
39
- alert :error, :close=>true do
39
+ show_alert :error, :close=>true do
40
40
  form.error_notification
41
41
  end
42
42
  end
@@ -62,7 +62,7 @@ module BootstrapHelper
62
62
  # = alert :close=>true, :block=>true do
63
63
  # Можно и так, без типа
64
64
 
65
- def alert type_or_options=nil, options={}, &block
65
+ def show_alert type_or_options=nil, options={}, &block
66
66
  alert_classes = ['alert']
67
67
 
68
68
  if type_or_options.is_a?(Hash)
@@ -84,7 +84,7 @@ module BootstrapHelper
84
84
  def show_flashes
85
85
  flashes=''
86
86
  flash.each do |type,content|
87
- flashes << alert(type, :close=>true) do
87
+ flashes << show_alert(type, :close=>true) do
88
88
  content
89
89
  end
90
90
  end
@@ -114,8 +114,8 @@ module BootstrapHelper
114
114
  # = g.button('Home')
115
115
  # = g.button('Posts')
116
116
  #
117
- def button_group(type, &block)
118
- builder = TwitterBootstrap::ButtonGroupBuilder.new(type, self)
117
+ def button_group(id,&block)
118
+ builder = TwitterBootstrap::ButtonGroupBuilder.new(id,self)
119
119
  builder.build(block)
120
120
  end
121
121
 
@@ -135,5 +135,43 @@ module BootstrapHelper
135
135
  builder = TwitterBootstrap::ButtonGroupWithTabsBuilder.new(self)
136
136
  builder.build(block)
137
137
  end
138
+
139
+ # Вывод кнопки с иконкой, можно и без иконки
140
+ def button(text, url = nil, options = {})
141
+ # ОПЦИИ
142
+ # :color цвет кнопки, может быть пустым,
143
+ # :red, :blue, :green, :yellow, :black, либо согласно bootstrap (напр. :primary)
144
+ #
145
+ # :icon имя иконки, символ или строка. если nil - иконки нет.
146
+ # список здесь: http://twitter.github.com/bootstrap/base-css.html#icons
147
+ #
148
+ # :icon_color в идеале - не используется, цвет иконки выбирается автоматически, если :color задан корректно.
149
+ # если нет, заменяет цвет иконки. может быть :white.
150
+ #
151
+ # другие параметры передаются напрямую хелперу link_to, можно использовать их
152
+ #
153
+ # ПРИМЕР
154
+ # button 'Обновить', items_path, color: :blue, icon: :refresh, remote: true
155
+ #
156
+ # !!!ВАЖНО!!!
157
+ # не вставлять в text пользовательский текст, он может содержать вредоносный код, вызывается html_safe
158
+ button_class = case options[:color]
159
+ when nil then 'btn'
160
+ when :red then 'btn btn-danger'
161
+ when :blue then 'btn btn-primary'
162
+ when :green then 'btn btn-success'
163
+ when :yellow then 'btn btn-warning'
164
+ when :black then 'btn btn-inverse'
165
+ else 'btn btn-'+options[:color].to_s
166
+ end
167
+ if options[:icon]
168
+ icon = '<i class="icon'+('-white' if options[:icon_color].to_s == "white" || [:red, :blue, :green, :black].include?(options[:color])).to_s+' icon-'+options[:icon].to_s+'"> </i> '
169
+ text = icon+text
170
+ end
171
+ options.delete_if{|k,v|[:color, :icon, :icon_color].include?(k)}
172
+ options[:class] = button_class
173
+ # если кто-то сильно против тега A и хочет BUTTON - можно сделать, но будет адский костыль.
174
+ link_to text.html_safe, url, options
175
+ end
138
176
 
139
177
  end
@@ -1,18 +1,19 @@
1
1
  # encoding: utf-8
2
2
 
3
+ include ::ActionView::Helpers::TagHelper
4
+
3
5
  module TwitterBootstrap
4
6
 
5
7
  class ButtonGroupBuilder
6
- def initialize(type, view_context)
7
- @type = type
8
+ def initialize(id,view_context)
9
+ @id = id
8
10
  @view_context = view_context
9
-
10
11
  @buttons = ""
11
12
  end
12
13
 
13
14
  def build(block)
14
15
  block.call(self)
15
- @view_context.content_tag(:div, @buttons.html_safe, class: 'btn-group', data: {toggle: "buttons-#{@type}"})
16
+ @view_context.content_tag(:div, @buttons.html_safe, class: 'btn-group',id: @id);
16
17
  end
17
18
 
18
19
  def button(label, options = {})
@@ -30,6 +31,13 @@ module TwitterBootstrap
30
31
 
31
32
  ""
32
33
  end
34
+
35
+ def dropdown_button(item_title,dropdown_menu)
36
+ title = (item_title << ' ' << content_tag(:span, nil, class: 'caret')).html_safe
37
+ link = content_tag(:a, title, :href => '#', :class => 'btn btn-mini dropdown-toggle', 'data-toggle' => 'dropdown')
38
+
39
+ @buttons << (link << dropdown_menu)
40
+ end
33
41
  end
34
42
 
35
43
  class ButtonGroupWithTabsBuilder < ButtonGroupBuilder
@@ -5,24 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "twitter_bootstrap_helpers"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Danil Pismenny"]
12
- s.date = "2012-05-21"
12
+ s.date = "2012-09-02"
13
13
  s.description = "\u{425}\u{435}\u{43b}\u{43f}\u{435}\u{440}\u{44b} \u{434}\u{43b}\u{44f} Twitter Bootstrap"
14
14
  s.email = "danil@orionet.ru"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.md",
18
- "README.rdoc"
17
+ "README.md"
19
18
  ]
20
19
  s.files = [
21
20
  "Gemfile",
22
21
  "Gemfile.lock",
23
22
  "LICENSE.txt",
24
23
  "README.md",
25
- "README.rdoc",
26
24
  "Rakefile",
27
25
  "VERSION",
28
26
  "app/helpers/bootstrap_helper.rb",
@@ -30,6 +28,7 @@ Gem::Specification.new do |s|
30
28
  "lib/twitter_bootstrap_helpers/button_group_builder.rb",
31
29
  "lib/twitter_bootstrap_helpers/engine.rb",
32
30
  "lib/twitter_bootstrap_helpers/tabs_generator.rb",
31
+ "pkg/twitter_bootstrap_helpers-0.1.0.gem",
33
32
  "test/helper.rb",
34
33
  "test/test_twitter_bootstrap_helpers.rb",
35
34
  "twitter_bootstrap_helpers.gemspec",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_bootstrap_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000Z
12
+ date: 2012-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &23121800 !ruby/object:Gem::Requirement
16
+ requirement: &13973260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23121800
24
+ version_requirements: *13973260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &23117100 !ruby/object:Gem::Requirement
27
+ requirement: &13969200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *23117100
35
+ version_requirements: *13969200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: actionpack
38
- requirement: &23115660 !ruby/object:Gem::Requirement
38
+ requirement: &13967620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *23115660
46
+ version_requirements: *13967620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &23113220 !ruby/object:Gem::Requirement
49
+ requirement: &13981280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *23113220
57
+ version_requirements: *13981280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &23111820 !ruby/object:Gem::Requirement
60
+ requirement: &13977640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *23111820
68
+ version_requirements: *13977640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &23006580 !ruby/object:Gem::Requirement
71
+ requirement: &13990600 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *23006580
79
+ version_requirements: *13990600
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &23003260 !ruby/object:Gem::Requirement
82
+ requirement: &13986520 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *23003260
90
+ version_requirements: *13986520
91
91
  description: Хелперы для Twitter Bootstrap
92
92
  email: danil@orionet.ru
93
93
  executables: []
@@ -95,13 +95,11 @@ extensions: []
95
95
  extra_rdoc_files:
96
96
  - LICENSE.txt
97
97
  - README.md
98
- - README.rdoc
99
98
  files:
100
99
  - Gemfile
101
100
  - Gemfile.lock
102
101
  - LICENSE.txt
103
102
  - README.md
104
- - README.rdoc
105
103
  - Rakefile
106
104
  - VERSION
107
105
  - app/helpers/bootstrap_helper.rb
@@ -109,6 +107,7 @@ files:
109
107
  - lib/twitter_bootstrap_helpers/button_group_builder.rb
110
108
  - lib/twitter_bootstrap_helpers/engine.rb
111
109
  - lib/twitter_bootstrap_helpers/tabs_generator.rb
110
+ - pkg/twitter_bootstrap_helpers-0.1.0.gem
112
111
  - test/helper.rb
113
112
  - test/test_twitter_bootstrap_helpers.rb
114
113
  - twitter_bootstrap_helpers.gemspec
@@ -128,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
127
  version: '0'
129
128
  segments:
130
129
  - 0
131
- hash: 4016655193622081367
130
+ hash: 3120713679349540384
132
131
  required_rubygems_version: !ruby/object:Gem::Requirement
133
132
  none: false
134
133
  requirements:
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = twitter_bootstrap_helpers
2
-
3
- Description goes here.
4
-
5
- == Contributing to twitter_bootstrap_helpers
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 Danil Pismenny. See LICENSE.txt for
18
- further details.
19
-