twitter_bootstrap_markup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/README.md +29 -0
  4. data/Rakefile +1 -0
  5. data/lib/twitter_bootstrap_markup.rb +45 -0
  6. data/lib/twitter_bootstrap_markup/add_on.rb +9 -0
  7. data/lib/twitter_bootstrap_markup/alert.rb +35 -0
  8. data/lib/twitter_bootstrap_markup/badge.rb +4 -0
  9. data/lib/twitter_bootstrap_markup/brand.rb +9 -0
  10. data/lib/twitter_bootstrap_markup/breadcrumb.rb +21 -0
  11. data/lib/twitter_bootstrap_markup/button.rb +16 -0
  12. data/lib/twitter_bootstrap_markup/button_base.rb +41 -0
  13. data/lib/twitter_bootstrap_markup/control_group.rb +26 -0
  14. data/lib/twitter_bootstrap_markup/divider.rb +30 -0
  15. data/lib/twitter_bootstrap_markup/dropdown_button.rb +59 -0
  16. data/lib/twitter_bootstrap_markup/extended_input.rb +11 -0
  17. data/lib/twitter_bootstrap_markup/extension/hash.rb +11 -0
  18. data/lib/twitter_bootstrap_markup/fieldset.rb +18 -0
  19. data/lib/twitter_bootstrap_markup/form.rb +27 -0
  20. data/lib/twitter_bootstrap_markup/grid_column.rb +14 -0
  21. data/lib/twitter_bootstrap_markup/grid_row.rb +9 -0
  22. data/lib/twitter_bootstrap_markup/help.rb +24 -0
  23. data/lib/twitter_bootstrap_markup/icon.rb +18 -0
  24. data/lib/twitter_bootstrap_markup/input.rb +31 -0
  25. data/lib/twitter_bootstrap_markup/label.rb +4 -0
  26. data/lib/twitter_bootstrap_markup/label_base.rb +29 -0
  27. data/lib/twitter_bootstrap_markup/link.rb +17 -0
  28. data/lib/twitter_bootstrap_markup/link_button.rb +17 -0
  29. data/lib/twitter_bootstrap_markup/nav_bar.rb +32 -0
  30. data/lib/twitter_bootstrap_markup/nav_container.rb +10 -0
  31. data/lib/twitter_bootstrap_markup/nav_header.rb +9 -0
  32. data/lib/twitter_bootstrap_markup/nav_list.rb +11 -0
  33. data/lib/twitter_bootstrap_markup/nav_list_container.rb +10 -0
  34. data/lib/twitter_bootstrap_markup/nav_tab.rb +10 -0
  35. data/lib/twitter_bootstrap_markup/nav_tab_container.rb +13 -0
  36. data/lib/twitter_bootstrap_markup/page_header.rb +17 -0
  37. data/lib/twitter_bootstrap_markup/pagination.rb +29 -0
  38. data/lib/twitter_bootstrap_markup/popover.rb +20 -0
  39. data/lib/twitter_bootstrap_markup/progress_bar.rb +43 -0
  40. data/lib/twitter_bootstrap_markup/select.rb +67 -0
  41. data/lib/twitter_bootstrap_markup/side_position.rb +15 -0
  42. data/lib/twitter_bootstrap_markup/submit.rb +10 -0
  43. data/lib/twitter_bootstrap_markup/tab.rb +14 -0
  44. data/lib/twitter_bootstrap_markup/tab_content.rb +29 -0
  45. data/lib/twitter_bootstrap_markup/table.rb +28 -0
  46. data/lib/twitter_bootstrap_markup/tag.rb +51 -0
  47. data/lib/twitter_bootstrap_markup/tooltip.rb +19 -0
  48. data/lib/twitter_bootstrap_markup/ul_container.rb +21 -0
  49. data/lib/twitter_bootstrap_markup/version.rb +3 -0
  50. data/lib/twitter_bootstrap_markup/well.rb +27 -0
  51. data/markup/alerts.html +75 -0
  52. data/markup/badges.html +65 -0
  53. data/markup/breadcrumbs.html +59 -0
  54. data/markup/buttons.html +95 -0
  55. data/markup/control_groups.html +77 -0
  56. data/markup/css/bootstrap-responsive.css +815 -0
  57. data/markup/css/bootstrap-responsive.min.css +9 -0
  58. data/markup/css/bootstrap.css +4983 -0
  59. data/markup/css/bootstrap.min.css +9 -0
  60. data/markup/dropdown_buttons.html +248 -0
  61. data/markup/form_fields.html +88 -0
  62. data/markup/forms.html +81 -0
  63. data/markup/grid_system.html +87 -0
  64. data/markup/img/glyphicons-halflings-white.png +0 -0
  65. data/markup/img/glyphicons-halflings.png +0 -0
  66. data/markup/index.html +37 -0
  67. data/markup/js/bootstrap.js +1825 -0
  68. data/markup/js/bootstrap.min.js +6 -0
  69. data/markup/js/jquery-1.7.2.js +9402 -0
  70. data/markup/labels.html +65 -0
  71. data/markup/link_buttons.html +95 -0
  72. data/markup/nav_bars.html +104 -0
  73. data/markup/nav_lists.html +54 -0
  74. data/markup/paginations.html +68 -0
  75. data/markup/popovers.html +56 -0
  76. data/markup/progress_bars.html +93 -0
  77. data/markup/selects.html +124 -0
  78. data/markup/tabs.html +46 -0
  79. data/markup/textboxes.html +95 -0
  80. data/markup/tooltips.html +56 -0
  81. data/spec/add_on_spec.rb +10 -0
  82. data/spec/alert_spec.rb +77 -0
  83. data/spec/badge_spec.rb +29 -0
  84. data/spec/brand_spec.rb +10 -0
  85. data/spec/breadcrumb_spec.rb +32 -0
  86. data/spec/button_spec.rb +52 -0
  87. data/spec/control_group_spec.rb +29 -0
  88. data/spec/divider_spec.rb +17 -0
  89. data/spec/dropdown_button_spec.rb +101 -0
  90. data/spec/fieldset_spec.rb +22 -0
  91. data/spec/form_fields_spec.rb +71 -0
  92. data/spec/form_spec.rb +35 -0
  93. data/spec/grid_system_spec.rb +69 -0
  94. data/spec/help_spec.rb +13 -0
  95. data/spec/icon_spec.rb +18 -0
  96. data/spec/input_spec.rb +11 -0
  97. data/spec/label_spec.rb +29 -0
  98. data/spec/link_button_spec.rb +52 -0
  99. data/spec/link_spec.rb +29 -0
  100. data/spec/nav_bar_spec.rb +27 -0
  101. data/spec/nav_list_spec.rb +27 -0
  102. data/spec/page_header_spec.rb +13 -0
  103. data/spec/pagination_spec.rb +18 -0
  104. data/spec/popover_spec.rb +15 -0
  105. data/spec/progress_bar_spec.rb +53 -0
  106. data/spec/select_spec.rb +61 -0
  107. data/spec/spec_helper.rb +12 -0
  108. data/spec/support/helpers/html_helper.rb +11 -0
  109. data/spec/table_spec.rb +29 -0
  110. data/spec/tabs_spec.rb +22 -0
  111. data/spec/tag_spec.rb +40 -0
  112. data/spec/textbox_spec.rb +60 -0
  113. data/spec/tooltip_spec.rb +15 -0
  114. data/spec/well_spec.rb +17 -0
  115. data/twitter_bootstrap_markup.gemspec +23 -0
  116. metadata +182 -0
@@ -0,0 +1,15 @@
1
+ module TwitterBootstrapMarkup
2
+ module SidePosition
3
+
4
+ def pull_right
5
+ attributes.append!(:class, 'pull-right')
6
+ self
7
+ end
8
+
9
+ def pull_left
10
+ attributes.append!(:class, 'pull-left')
11
+ self
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module TwitterBootstrapMarkup
2
+ class Submit < Button
3
+
4
+ def initialize(*args, &block)
5
+ super(*args, &block)
6
+ attributes[:type] = 'submit'
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module TwitterBootstrapMarkup
2
+ class Tab < Tag
3
+ attr_reader :nav
4
+ attr_reader :content
5
+
6
+ def initialize(attributes={}, &block)
7
+ super(:div, attributes.prepend!(:class, 'tab')) {}
8
+ @nav = append NavTabContainer.new
9
+ @content = append TabContent.new
10
+ instance_eval &block if block_given?
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module TwitterBootstrapMarkup
2
+ class TabContent < Tag
3
+ alias :internal_append :append
4
+
5
+ def initialize(attributes={}, &block)
6
+ if block_given?
7
+ super(:div, attributes.prepend!(:class, 'tab-content'), &block)
8
+ else
9
+ super(:div, attributes.prepend!(:class, 'tab-content')) {}
10
+ end
11
+ end
12
+
13
+ def append(*args, &block)
14
+ id = args.shift
15
+ element = block_given? ? instance_eval(&block) : args.shift
16
+ mode = args.shift || :inactive
17
+
18
+ if element.is_a?(Tag) && element.name == :div && element.attributes[:class].include?('tab-pane')
19
+ element.attributes[:id] = id
20
+ element.attributes.append!(:class, 'active') if mode == :active
21
+ internal_append element
22
+ else
23
+ attributes = {:class => 'tab-pane', :id => id}
24
+ attributes.append!(:class, :active) if mode == :active
25
+ internal_append Tag.block(:div, attributes) { append element }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ module TwitterBootstrapMarkup
2
+ class Table < Tag
3
+ TYPES = [:bordered, :striped, :condensed]
4
+
5
+ def initialize(attributes={}, &block)
6
+ attributes.prepend!(:class, 'table')
7
+ if block_given?
8
+ super(:table, attributes, &block)
9
+ else
10
+ super(:table, attributes) {}
11
+ end
12
+ end
13
+
14
+ TYPES.each do |type|
15
+ define_method type do
16
+ attributes.append!(:class, "table-#{type}")
17
+ self
18
+ end
19
+ end
20
+
21
+ TYPES.each do |type|
22
+ define_singleton_method type do |*args, &block|
23
+ self.new(*args, &block).send(type)
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,51 @@
1
+ module TwitterBootstrapMarkup
2
+ class Tag
3
+ include Tooltip
4
+ include Popover
5
+ include SidePosition
6
+
7
+ attr_reader :name
8
+ attr_reader :attributes
9
+ attr_reader :children
10
+
11
+ def self.inline(name, attributes={})
12
+ Tag.new(name, attributes)
13
+ end
14
+
15
+ def self.block(name, attributes={}, &block)
16
+ if block_given?
17
+ Tag.new(name, attributes, &block)
18
+ else
19
+ Tag.new(name, attributes) {}
20
+ end
21
+ end
22
+
23
+ def initialize(name, attributes={}, &block)
24
+ @name = name
25
+ @attributes = attributes
26
+ @children = []
27
+ @is_block = block_given?
28
+ instance_eval &block if block_given?
29
+ end
30
+
31
+ def append(element=nil, &block)
32
+ element = instance_eval(&block) if block_given?
33
+ @children << element
34
+ element
35
+ end
36
+
37
+ def prepend(element)
38
+ @children.insert 0, element
39
+ end
40
+
41
+ def to_s
42
+ attributes_markup = attributes.empty? ? '' : " #{attributes.map{|key, value| "#{key}#{value ? "=\"#{value}\"" : ''}"}.join(' ')}"
43
+ if @is_block
44
+ "<#{name}#{attributes_markup}>#{children.map(&:to_s).join}</#{name}>"
45
+ else
46
+ "<#{name}#{attributes_markup}>"
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,19 @@
1
+ module TwitterBootstrapMarkup
2
+ module Tooltip
3
+ POSITIONS = [:top, :bottom, :left, :right]
4
+
5
+ def tooltip(title)
6
+ tooltip_top(title)
7
+ end
8
+
9
+ POSITIONS.each do |position|
10
+ define_method "tooltip_#{position}" do |title|
11
+ attributes[:rel] = 'tooltip'
12
+ attributes['data-original-title'] = title
13
+ attributes['data-placement'] = position
14
+ self
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module TwitterBootstrapMarkup
2
+ class UlContainer < Tag
3
+ alias :internal_append :append
4
+
5
+ def initialize(attributes={}, &block)
6
+ super(:ul, attributes, &block)
7
+ end
8
+
9
+ def append(element=nil, mode=:inactive, &block)
10
+ element = instance_eval(&block) if block_given?
11
+ if element.is_a?(Tag) && element.name == :li
12
+ element.attributes.append!(:class, 'active') if mode == :active
13
+ internal_append element
14
+ else
15
+ attributes = mode == :active ? {:class => 'active'} : {}
16
+ internal_append Tag.block(:li, attributes) { append element }
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module TwitterBootstrapMarkup
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ module TwitterBootstrapMarkup
2
+ class Well < Tag
3
+
4
+ def initialize(attributes={}, &block)
5
+ super(:div, attributes.prepend!(:class, 'well'), &block)
6
+ end
7
+
8
+ def small
9
+ attributes.append!(:class, 'well-small')
10
+ self
11
+ end
12
+
13
+ def large
14
+ attributes.append!(:class, 'well-large')
15
+ self
16
+ end
17
+
18
+ def self.small(*args, &block)
19
+ self.new(*args, &block).small
20
+ end
21
+
22
+ def self.large(*args, &block)
23
+ self.new(*args, &block).large
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Twitter Bootstrap Markup</title>
5
+ <!--[if lt IE 9]>
6
+ <script src='http://html5shim.googlecode/svn/trunk/html5.js' type='text/javascript'></script>
7
+ <![endif]-->
8
+ <link href="css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"/>
9
+ <meta content='width=device-width, initial-scale=1.0' name='viewport'>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <h2>Alerts</h2>
14
+ <table class="table table-bordered table-striped">
15
+ <thead>
16
+ <tr>
17
+ <th class="span2">Name</th>
18
+ <th>Component</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Warning</td>
24
+ <td id="warning">
25
+ <div class="alert">
26
+ <strong>Alert!</strong>
27
+ Message
28
+ </div>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td>Info</td>
33
+ <td id="info">
34
+ <div class="alert alert-info">
35
+ <strong>Alert!</strong>
36
+ Message
37
+ </div>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td>Success</td>
42
+ <td id="success">
43
+ <div class="alert alert-success">
44
+ <strong>Alert!</strong>
45
+ Message
46
+ </div>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td>Danger</td>
51
+ <td id="danger">
52
+ <div class="alert alert-danger">
53
+ <strong>Alert!</strong>
54
+ Message
55
+ </div>
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <td>Closable</td>
60
+ <td id="closable">
61
+ <div class="alert">
62
+ <button class="close" data-dismiss="alert">&times</button>
63
+ <strong>Alert!</strong>
64
+ Message
65
+ </div>
66
+ </td>
67
+ </tr>
68
+ </tbody>
69
+ </table>
70
+ <a href="index.html">back to index</a>
71
+ </div>
72
+ <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
73
+ <script src="js/bootstrap.js" type="text/javascript"></script>
74
+ </body>
75
+ </html>
@@ -0,0 +1,65 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Twitter Bootstrap Markup</title>
5
+ <!--[if lt IE 9]>
6
+ <script src='http://html5shim.googlecode/svn/trunk/html5.js' type='text/javascript'></script>
7
+ <![endif]-->
8
+ <link href="css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"/>
9
+ <meta content='width=device-width, initial-scale=1.0' name='viewport'>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <h2>Badges</h2>
14
+ <table class="table table-bordered table-striped">
15
+ <thead>
16
+ <tr>
17
+ <th class="span2">Name</th>
18
+ <th>Component</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Default</td>
24
+ <td id="default">
25
+ <span class="badge">1</span>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td>Success</td>
30
+ <td id="success">
31
+ <span class="badge badge-success">1</span>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td>Warning</td>
36
+ <td id="warning">
37
+ <span class="badge badge-warning">1</span>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td>Important</td>
42
+ <td id="important">
43
+ <span class="badge badge-important">1</span>
44
+ </td>
45
+ </tr>
46
+ <tr>
47
+ <td>Info</td>
48
+ <td id="info">
49
+ <span class="badge badge-info">1</span>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td>Inverse</td>
54
+ <td id="inverse">
55
+ <span class="badge badge-inverse">1</span>
56
+ </td>
57
+ </tr>
58
+ </tbody>
59
+ </table>
60
+ <a href="index.html">back to index</a>
61
+ </div>
62
+ <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
63
+ <script src="js/bootstrap.js" type="text/javascript"></script>
64
+ </body>
65
+ </html>
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Twitter Bootstrap Markup</title>
5
+ <!--[if lt IE 9]>
6
+ <script src='http://html5shim.googlecode/svn/trunk/html5.js' type='text/javascript'></script>
7
+ <![endif]-->
8
+ <link href="css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"/>
9
+ <meta content='width=device-width, initial-scale=1.0' name='viewport'>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <h2>Breadcrumbs</h2>
14
+ <table class="table table-bordered table-striped">
15
+ <thead>
16
+ <tr>
17
+ <th class="span2">Name</th>
18
+ <th>Component</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>One level</td>
24
+ <td id="one">
25
+ <ul class="breadcrumb">
26
+ <li>Home</li>
27
+ </ul>
28
+ </td>
29
+ </tr>
30
+ <tr>
31
+ <td>Two levels</td>
32
+ <td id="two">
33
+ <ul class="breadcrumb">
34
+ <li><a href="#">Home</a></li>
35
+ <li><span class="divider">/</span></li>
36
+ <li>Page</li>
37
+ </ul>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td>Three levels</td>
42
+ <td id="three">
43
+ <ul class="breadcrumb">
44
+ <li><a href="#">Home</a></li>
45
+ <li><span class="divider">/</span></li>
46
+ <li><a href="#">Page</a></li>
47
+ <li><span class="divider">/</span></li>
48
+ <li>Data</li>
49
+ </ul>
50
+ </td>
51
+ </tr>
52
+ </tbody>
53
+ </table>
54
+ <a href="index.html">back to index</a>
55
+ </div>
56
+ <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
57
+ <script src="js/bootstrap.js" type="text/javascript"></script>
58
+ </body>
59
+ </html>
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Twitter Bootstrap Markup</title>
5
+ <!--[if lt IE 9]>
6
+ <script src='http://html5shim.googlecode/svn/trunk/html5.js' type='text/javascript'></script>
7
+ <![endif]-->
8
+ <link href="css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"/>
9
+ <meta content='width=device-width, initial-scale=1.0' name='viewport'>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <h2>Buttons</h2>
14
+ <table class="table table-bordered table-striped">
15
+ <thead>
16
+ <tr>
17
+ <th class="span2">Name</th>
18
+ <th>Component</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Default</td>
24
+ <td id="default">
25
+ <button class="btn">Click me</button>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td>Primary</td>
30
+ <td id="primary">
31
+ <button class="btn btn-primary">Click me</button>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td>Info</td>
36
+ <td id="info">
37
+ <button class="btn btn-info">Click me</button>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td>Success</td>
42
+ <td id="success">
43
+ <button class="btn btn-success">Click me</button>
44
+ </td>
45
+ </tr>
46
+ <tr>
47
+ <td>Warning</td>
48
+ <td id="warning">
49
+ <button class="btn btn-warning">Click me</button>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td>Danger</td>
54
+ <td id="danger">
55
+ <button class="btn btn-danger">Click me</button>
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <td>Inverse</td>
60
+ <td id="inverse">
61
+ <button class="btn btn-inverse">Click me</button>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td>Large</td>
66
+ <td id="large">
67
+ <button class="btn btn-large">Click me</button>
68
+ </td>
69
+ </tr>
70
+ <tr>
71
+ <td>Small</td>
72
+ <td id="small">
73
+ <button class="btn btn-small">Click me</button>
74
+ </td>
75
+ </tr>
76
+ <tr>
77
+ <td>Mini</td>
78
+ <td id="mini">
79
+ <button class="btn btn-mini">Click me</button>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <td>Mixed</td>
84
+ <td id="mixed">
85
+ <button class="btn btn-primary btn-large">Click me</button>
86
+ </td>
87
+ </tr>
88
+ </tbody>
89
+ </table>
90
+ <a href="index.html">back to index</a>
91
+ </div>
92
+ <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
93
+ <script src="js/bootstrap.js" type="text/javascript"></script>
94
+ </body>
95
+ </html>