sb-styleguide 0.0.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/.codoopts +10 -0
  2. data/.env +1 -0
  3. data/.gitignore +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +10 -3
  6. data/Gemfile.lock +134 -94
  7. data/Procfile +1 -0
  8. data/README.md +3 -5
  9. data/Rakefile +3 -0
  10. data/app/assets/images/layouts/basic-marketing-site.png +0 -0
  11. data/app/assets/images/layouts/jumbotron-site.png +0 -0
  12. data/app/assets/javascripts/base.js.coffee +3 -0
  13. data/app/assets/javascripts/grids.js.coffee +3 -0
  14. data/app/assets/javascripts/javascript.js.coffee +3 -0
  15. data/app/assets/javascripts/modules.js.coffee +3 -0
  16. data/app/assets/stylesheets/application-old-ie.css.scss +11 -0
  17. data/app/assets/stylesheets/application.css.scss +33 -30
  18. data/app/assets/stylesheets/base/_all.scss +6 -0
  19. data/app/assets/stylesheets/base/_reset.css.scss +16 -0
  20. data/app/assets/stylesheets/base/_type.scss +16 -0
  21. data/app/assets/stylesheets/{coderay_githubish.css.scss → modules/_coderay.css.scss} +40 -0
  22. data/app/assets/stylesheets/modules/_layout_examples.css.scss +13 -0
  23. data/app/assets/stylesheets/modules/_webfont_table.css.scss +47 -0
  24. data/app/assets/stylesheets/vanilla-normal-old-ie.css.scss +11 -0
  25. data/app/assets/stylesheets/vanilla-normal.css.scss +33 -0
  26. data/app/controllers/application_controller.rb +2 -0
  27. data/app/controllers/base_controller.rb +52 -0
  28. data/app/controllers/grids_controller.rb +48 -0
  29. data/app/controllers/javascript_controller.rb +20 -0
  30. data/app/controllers/modules_controller.rb +43 -0
  31. data/app/helpers/styleguide_helper.rb +33 -0
  32. data/app/views/base/_webfonts_social_standard.html +429 -0
  33. data/app/views/base/_webfonts_ss_standard.html +2413 -0
  34. data/app/views/base/buttons.html.haml +20 -0
  35. data/app/views/base/forms.html.haml +40 -0
  36. data/app/views/base/images.html.haml +1 -0
  37. data/app/views/base/index.html.haml +68 -0
  38. data/app/views/base/labels.html.haml +22 -0
  39. data/app/views/base/lists.html.haml +20 -0
  40. data/app/views/base/webfonts.html.haml +17 -0
  41. data/app/views/grids/index.html.haml +73 -0
  42. data/app/views/grids/layouts.html.haml +9 -0
  43. data/app/views/grids/layouts/basic-marketing-site.haml +69 -0
  44. data/app/views/grids/layouts/jumbotron-site.haml +92 -0
  45. data/app/views/layouts/_main_nav.html.haml +6 -6
  46. data/app/views/layouts/application.html.haml +6 -32
  47. data/app/views/modules/alerts.html.haml +12 -0
  48. data/app/views/modules/footer.html.haml +2 -0
  49. data/app/views/modules/index.html.haml +5 -0
  50. data/app/views/modules/nav.html.haml +12 -0
  51. data/app/views/modules/panels.html.haml +3 -0
  52. data/app/views/modules/tabs.html.haml +58 -0
  53. data/app/views/old_javascript/close.html.haml +2 -0
  54. data/app/views/old_javascript/forms.html.haml +2 -0
  55. data/app/views/old_javascript/ga_events.html.haml +2 -0
  56. data/app/views/old_javascript/index.html.haml +2 -0
  57. data/app/views/old_javascript/responsive_resize.html.haml +2 -0
  58. data/app/views/old_javascript/switch.html.haml +2 -0
  59. data/app/views/parts/base/_button.haml +3 -0
  60. data/app/views/parts/base/_button_colours.haml +4 -0
  61. data/app/views/parts/base/_button_group.haml +4 -0
  62. data/app/views/parts/base/_button_sizing.haml +3 -0
  63. data/app/views/parts/base/_button_states.haml +3 -0
  64. data/app/views/parts/base/_form_example.haml +26 -0
  65. data/app/views/parts/base/_form_example_horizontal.haml +26 -0
  66. data/app/views/parts/base/_form_group.haml +10 -0
  67. data/app/views/parts/base/_form_location.haml +3 -0
  68. data/app/views/parts/base/_labels.haml +5 -0
  69. data/app/views/parts/base/_labels_sizing.haml +3 -0
  70. data/app/views/parts/base/_list.haml +10 -0
  71. data/app/views/parts/base/_list_action.haml +5 -0
  72. data/app/views/parts/base/_list_nav.haml +12 -0
  73. data/app/views/parts/base/_list_unset.haml +10 -0
  74. data/app/views/parts/base/_type_body.haml +2 -0
  75. data/app/views/parts/base/_type_headings.haml +5 -0
  76. data/app/views/parts/base/_type_helpers.haml +3 -0
  77. data/app/views/parts/base/_type_links.haml +9 -0
  78. data/app/views/parts/base/_type_shouts.haml +4 -0
  79. data/app/views/parts/grids/_example_layout_1.haml +10 -0
  80. data/app/views/parts/grids/_live_grid.haml +29 -0
  81. data/app/views/parts/modules/_alerts.haml +11 -0
  82. data/app/views/parts/modules/_nav_footer.haml +34 -0
  83. data/app/views/parts/modules/_nav_header.haml +18 -0
  84. data/app/views/parts/modules/_panels.haml +9 -0
  85. data/app/views/parts/modules/_tabs_minimal.haml +11 -0
  86. data/app/views/parts/modules/_tabs_simple_group.haml +11 -0
  87. data/app/views/parts/modules/_tabs_simple_group_toggle.haml +11 -0
  88. data/app/views/parts/modules/_tabs_toggle.haml +5 -0
  89. data/app/views/parts/modules/_tabs_traditional.haml +11 -0
  90. data/app/views/shared/_title.html.haml +8 -0
  91. data/app/views/shared/_ui_nav.html.haml +5 -0
  92. data/app/views/ui/typography.html.haml +86 -96
  93. data/lib/sb-styleguide.rb +1 -1
  94. data/lib/sb-styleguide/version.rb +1 -1
  95. data/lib/templates/haml/scaffold/_form.html.haml +8 -0
  96. data/public/javascripts/LICENSE.html +158 -0
  97. data/public/javascripts/README.md.html +164 -0
  98. data/public/javascripts/assets/codo.css +1 -0
  99. data/public/javascripts/assets/codo.js +21 -0
  100. data/public/javascripts/assets/search_data.js +1 -0
  101. data/public/javascripts/class_index.html +215 -0
  102. data/public/javascripts/class_list.html +58 -0
  103. data/public/javascripts/classes/Close.html +259 -0
  104. data/public/javascripts/classes/GAEvent.html +231 -0
  105. data/public/javascripts/classes/ResizeHandler.html +225 -0
  106. data/public/javascripts/classes/Switch.html +318 -0
  107. data/public/javascripts/classes/TBGForm.html +373 -0
  108. data/public/javascripts/extra_list.html +36 -0
  109. data/public/javascripts/file_list.html +74 -0
  110. data/public/javascripts/files/styleguide/plugins/tbg-close.js.coffee.html +160 -0
  111. data/public/javascripts/files/styleguide/plugins/tbg-forms.js.coffee.html +160 -0
  112. data/public/javascripts/files/styleguide/plugins/tbg-ga-events.js.coffee.html +160 -0
  113. data/public/javascripts/files/styleguide/plugins/tbg-respinsiveresize.js.coffee.html +160 -0
  114. data/public/javascripts/files/styleguide/plugins/tbg-switch.js.coffee.html +160 -0
  115. data/public/javascripts/index.html +14 -0
  116. data/public/javascripts/method_list.html +187 -0
  117. data/public/javascripts/mixin_list.html +28 -0
  118. data/vendor/assets/javascripts/styleguide/plugins/doc/assets/codo.css +1 -0
  119. data/vendor/assets/javascripts/styleguide/plugins/doc/assets/codo.js +21 -0
  120. data/vendor/assets/javascripts/styleguide/plugins/doc/assets/search_data.js +1 -0
  121. data/vendor/assets/javascripts/styleguide/plugins/doc/class_index.html +194 -0
  122. data/vendor/assets/javascripts/styleguide/plugins/doc/class_list.html +58 -0
  123. data/vendor/assets/javascripts/styleguide/plugins/doc/classes/Close.html +215 -0
  124. data/vendor/assets/javascripts/styleguide/plugins/doc/classes/GAEvent.html +235 -0
  125. data/vendor/assets/javascripts/styleguide/plugins/doc/classes/ResizeHandler.html +192 -0
  126. data/vendor/assets/javascripts/styleguide/plugins/doc/classes/Switch.html +233 -0
  127. data/vendor/assets/javascripts/styleguide/plugins/doc/classes/TBGForm.html +318 -0
  128. data/vendor/assets/javascripts/styleguide/plugins/doc/extra_list.html +30 -0
  129. data/vendor/assets/javascripts/styleguide/plugins/doc/file_list.html +58 -0
  130. data/vendor/assets/javascripts/styleguide/plugins/doc/files/tbg-close.js.coffee.html +154 -0
  131. data/vendor/assets/javascripts/styleguide/plugins/doc/files/tbg-forms.js.coffee.html +154 -0
  132. data/vendor/assets/javascripts/styleguide/plugins/doc/files/tbg-ga-events.js.coffee.html +154 -0
  133. data/vendor/assets/javascripts/styleguide/plugins/doc/files/tbg-respinsiveresize.js.coffee.html +154 -0
  134. data/vendor/assets/javascripts/styleguide/plugins/doc/files/tbg-switch.js.coffee.html +154 -0
  135. data/vendor/assets/javascripts/styleguide/plugins/doc/index.html +14 -0
  136. data/vendor/assets/javascripts/styleguide/plugins/doc/method_list.html +163 -0
  137. data/vendor/assets/javascripts/styleguide/plugins/doc/mixin_list.html +28 -0
  138. data/vendor/assets/javascripts/styleguide/plugins/tbg-close.js.coffee +28 -4
  139. data/vendor/assets/javascripts/styleguide/plugins/tbg-forms.js.coffee +52 -5
  140. data/vendor/assets/javascripts/styleguide/plugins/tbg-ga-events.js.coffee +28 -8
  141. data/vendor/assets/javascripts/styleguide/plugins/tbg-respinsiveresize.js.coffee +21 -2
  142. data/vendor/assets/javascripts/styleguide/plugins/tbg-switch.js.coffee +37 -2
  143. data/vendor/assets/stylesheets/_mixins.css.scss +128 -35
  144. data/vendor/assets/stylesheets/_settings.css.scss +7 -4
  145. data/vendor/assets/stylesheets/styleguide/base/_labels.css.scss +22 -6
  146. data/vendor/assets/stylesheets/styleguide/base/_lists.css.scss +23 -18
  147. data/vendor/assets/stylesheets/styleguide/base/_type.css.scss +11 -5
  148. data/vendor/assets/stylesheets/styleguide/grid/_grid.css.scss +9 -9
  149. data/vendor/assets/stylesheets/styleguide/modules/_switch.css.scss +32 -16
  150. metadata +134 -18
  151. data/.rvmrc +0 -1
  152. data/app/helpers/application_helper.rb +0 -13
  153. data/app/helpers/javascripts_helper.rb +0 -2
  154. data/app/helpers/ui_helper.rb +0 -2
  155. data/app/mailers/.gitkeep +0 -0
  156. data/app/models/.gitkeep +0 -0
  157. data/app/views/javascripts/_js_nav.html.haml +0 -5
  158. data/app/views/javascripts/index.html.haml +0 -45
  159. data/app/views/type/_headings.haml +0 -6
  160. data/app/views/type/_paragraphs.haml +0 -4
  161. data/app/views/ui/_ui_nav.html.haml +0 -13
  162. data/vendor/assets/stylesheets/styleguide/layout/_all.css.scss +0 -5
  163. data/vendor/plugins/.gitkeep +0 -0
@@ -0,0 +1,154 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <title>CoffeeScript API Documentation</title>
6
+ <link rel='stylesheet' href='../assets/codo.css' type='text/css'>
7
+ <script src='../assets/codo.js'></script>
8
+ <script src='../assets/search_data.js'></script>
9
+ </head>
10
+ <body>
11
+ <div id='base' data-path='../'></div>
12
+ <div id='header'>
13
+ <div id='menu'>
14
+ <a href='../class_index.html' title='Index'>Index</a>
15
+ &raquo;
16
+ <span class='title'>tbg-switch.js.coffee</span>
17
+ <nav>
18
+ <ul>
19
+ <li class='noframes'>
20
+ (<a class='noframes' href='#'>no frames</a>)
21
+ </li>
22
+ </ul>
23
+ </nav>
24
+ <div id='search'>
25
+ <a id='class_list_link' href='../class_list.html'>Classes</a>
26
+ <a id='file_list_link' href='../file_list.html'>Files</a>
27
+ <a id='method_list_link' href='../method_list.html'>Methods</a>
28
+ <a id='extra_list_link' href='../extra_list.html'>Extras</a>
29
+ </div>
30
+ </div>
31
+ <iframe id='search_frame'></iframe>
32
+ <div id='fuzzySearch'>
33
+ <input type='text'>
34
+ <ol></ol>
35
+ </div>
36
+ <div id='help'>
37
+ <p>
38
+ Quickly fuzzy find classes, mixins, methods, file:
39
+ </p>
40
+ <ul>
41
+ <li>
42
+ <span>Ctrl-T</span>
43
+ Open fuzzy finder dialog
44
+ </li>
45
+ </ul>
46
+ <p>
47
+ In frame mode you can toggle the list naviation frame on the left side:
48
+ </p>
49
+ <ul>
50
+ <li>
51
+ <span>Ctrl-L</span>
52
+ Toggle list view
53
+ </li>
54
+ </ul>
55
+ <p>
56
+ You can focus a list in frame mode or toggle a tab in frameless mode:
57
+ </p>
58
+ <ul>
59
+ <li>
60
+ <span>Ctrl-C</span>
61
+ Class list
62
+ </li>
63
+ <li>
64
+ <span>Ctrl-I</span>
65
+ Mixin list
66
+ </li>
67
+ <li>
68
+ <span>Ctrl-F</span>
69
+ File list
70
+ </li>
71
+ <li>
72
+ <span>Ctrl-M</span>
73
+ Method list
74
+ </li>
75
+ <li>
76
+ <span>Ctrl-E</span>
77
+ Extras list
78
+ </li>
79
+ </ul>
80
+ <p>
81
+ You can focus and blur the search input:
82
+ </p>
83
+ <ul>
84
+ <li>
85
+ <span>Ctrl-S</span>
86
+ Focus search input
87
+ </li>
88
+ <li>
89
+ <span>Esc</span>
90
+ Blur search input
91
+ </li>
92
+ </ul>
93
+ <p>
94
+ In frameless mode you can close the list tab:
95
+ </p>
96
+ <ul>
97
+ <li>
98
+ <span>Esc</span>
99
+ Close list tab
100
+ </li>
101
+ </ul>
102
+ </div>
103
+ </div>
104
+ <div id='content'>
105
+ <h1>
106
+ File:
107
+ tbg-switch.js.coffee
108
+ </h1>
109
+ <table class='box'>
110
+ <tr>
111
+ <td>Defined in:</td>
112
+ <td></td>
113
+ </tr>
114
+ </table>
115
+ <h2>Method Summary</h2>
116
+ <ul class='summary'>
117
+ <li>
118
+ <span class='signature'>
119
+ <a href='#plugin-file'>
120
+ ? (void) <strong>plugin</strong>($)
121
+ </a>
122
+ </span>
123
+ <span class='desc'>
124
+
125
+ </span>
126
+ </li>
127
+ </ul>
128
+ <h2>Method Details</h2>
129
+ <div class='methods'>
130
+ <div class='method_details'>
131
+ <p class='signature' id='plugin-file'>
132
+ ? (void) <strong>plugin</strong>($)
133
+ </p>
134
+ <div class='tags'>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ <div id='footer'>
140
+ Generated on
141
+ Wed Mar 13 2013 11:03:06 GMT+0000 (GMT)
142
+ by
143
+ <a href='https://github.com/netzpirat/codo' title='CoffeeScript API documentation generator'>Codo</a>
144
+ v1.5.6
145
+ (Node.js v0.8.8).
146
+ &#10034;
147
+ Press Ctrl-h to see the keyboard shortcuts
148
+ &#10034;
149
+ <a href='http://twitter.com/#!/netzpirat'>@netzpirat</a>
150
+ &#10034;
151
+ <a href='https://mksoft.ch'>mksoft.ch</a>
152
+ </div>
153
+ </body>
154
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <title>CoffeeScript API Documentation</title>
6
+ <link rel='stylesheet' href='assets/codo.css' type='text/css'>
7
+ <script src='assets/codo.js'></script>
8
+ <script src='assets/search_data.js'></script>
9
+ </head>
10
+ <frameset cols='20%, *'>
11
+ <frame name='list' src='class_list.html'></frame>
12
+ <frame name='main' src='class_index.html'></frame>
13
+ </frameset>
14
+ </html>
@@ -0,0 +1,163 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <title>CoffeeScript API Documentation</title>
6
+ <link rel='stylesheet' href='assets/codo.css' type='text/css'>
7
+ <script src='assets/codo.js'></script>
8
+ <script src='assets/search_data.js'></script>
9
+ </head>
10
+ <body class='list'>
11
+ <div class='list' id='content'>
12
+ <h1 class='full_list_header'>Method List</h1>
13
+ <nav>
14
+ <a target='_self' href='class_list.html'>Classes</a>
15
+ <a target='_self' href='file_list.html'>Files</a>
16
+ <a target='_self' href='method_list.html'>Methods</a>
17
+ <a target='_self' href='extra_list.html'>Extras</a>
18
+ </nav>
19
+ <div id='search'>
20
+ Search:
21
+ <input type='text'>
22
+ </div>
23
+ <ul>
24
+ <li>
25
+ <a href='classes/Switch.html#_closeGroup-instance' target='main' title='_closeGroup'>
26
+ #_closeGroup
27
+ </a>
28
+ <small>
29
+ (Switch)
30
+ </small>
31
+ </li>
32
+ <li>
33
+ <a href='classes/Switch.html#_getContent-instance' target='main' title='_getContent'>
34
+ #_getContent
35
+ </a>
36
+ <small>
37
+ (Switch)
38
+ </small>
39
+ </li>
40
+ <li>
41
+ <a href='classes/Switch.html#changeStateTo-instance' target='main' title='changeStateTo'>
42
+ #changeStateTo
43
+ </a>
44
+ <small>
45
+ (Switch)
46
+ </small>
47
+ </li>
48
+ <li>
49
+ <a href='classes/Switch.html#click-instance' target='main' title='click'>
50
+ #click
51
+ </a>
52
+ <small>
53
+ (Switch)
54
+ </small>
55
+ </li>
56
+ <li>
57
+ <a href='classes/Close.html#close-instance' target='main' title='close'>
58
+ #close
59
+ </a>
60
+ <small>
61
+ (Close)
62
+ </small>
63
+ </li>
64
+ <li>
65
+ <a href='files/tbg-close.js.coffee.html#plugin-file' target='main' title='plugin'>
66
+ .plugin
67
+ </a>
68
+ <small>
69
+ (tbg-close.js.coffee)
70
+ </small>
71
+ </li>
72
+ <li>
73
+ <a href='files/tbg-forms.js.coffee.html#plugin-file' target='main' title='plugin'>
74
+ .plugin
75
+ </a>
76
+ <small>
77
+ (tbg-forms.js.coffee)
78
+ </small>
79
+ </li>
80
+ <li>
81
+ <a href='files/tbg-ga-events.js.coffee.html#plugin-file' target='main' title='plugin'>
82
+ .plugin
83
+ </a>
84
+ <small>
85
+ (tbg-ga-events.js.coffee)
86
+ </small>
87
+ </li>
88
+ <li>
89
+ <a href='files/tbg-respinsiveresize.js.coffee.html#plugin-file' target='main' title='plugin'>
90
+ .plugin
91
+ </a>
92
+ <small>
93
+ (tbg-respinsiveresize.js.coffee)
94
+ </small>
95
+ </li>
96
+ <li>
97
+ <a href='files/tbg-switch.js.coffee.html#plugin-file' target='main' title='plugin'>
98
+ .plugin
99
+ </a>
100
+ <small>
101
+ (tbg-switch.js.coffee)
102
+ </small>
103
+ </li>
104
+ <li>
105
+ <a href='classes/ResizeHandler.html#resize-instance' target='main' title='resize'>
106
+ #resize
107
+ </a>
108
+ <small>
109
+ (ResizeHandler)
110
+ </small>
111
+ </li>
112
+ <li>
113
+ <a href='classes/TBGForm.html#send-instance' target='main' title='send'>
114
+ #send
115
+ </a>
116
+ <small>
117
+ (TBGForm)
118
+ </small>
119
+ </li>
120
+ <li>
121
+ <a href='classes/GAEvent.html#sendEvent-instance' target='main' title='sendEvent'>
122
+ #sendEvent
123
+ </a>
124
+ <small>
125
+ (GAEvent)
126
+ </small>
127
+ </li>
128
+ <li>
129
+ <a href='classes/TBGForm.html#sendRequest-instance' target='main' title='sendRequest'>
130
+ #sendRequest
131
+ </a>
132
+ <small>
133
+ (TBGForm)
134
+ </small>
135
+ </li>
136
+ <li>
137
+ <a href='classes/TBGForm.html#showErrors-instance' target='main' title='showErrors'>
138
+ #showErrors
139
+ </a>
140
+ <small>
141
+ (TBGForm)
142
+ </small>
143
+ </li>
144
+ <li>
145
+ <a href='classes/TBGForm.html#showSuccess-instance' target='main' title='showSuccess'>
146
+ #showSuccess
147
+ </a>
148
+ <small>
149
+ (TBGForm)
150
+ </small>
151
+ </li>
152
+ <li>
153
+ <a href='classes/ResizeHandler.html#size-instance' target='main' title='size'>
154
+ #size
155
+ </a>
156
+ <small>
157
+ (ResizeHandler)
158
+ </small>
159
+ </li>
160
+ </ul>
161
+ </div>
162
+ </body>
163
+ </html>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <title>CoffeeScript API Documentation</title>
6
+ <link rel='stylesheet' href='assets/codo.css' type='text/css'>
7
+ <script src='assets/codo.js'></script>
8
+ <script src='assets/search_data.js'></script>
9
+ </head>
10
+ <body class='list'>
11
+ <div class='list tree' id='content'>
12
+ <h1 class='full_list_header'>Mixin List</h1>
13
+ <nav>
14
+ <a target='_self' href='class_list.html'>Classes</a>
15
+ <a target='_self' href='file_list.html'>Files</a>
16
+ <a target='_self' href='method_list.html'>Methods</a>
17
+ <a target='_self' href='extra_list.html'>Extras</a>
18
+ </nav>
19
+ <div id='search'>
20
+ Search:
21
+ <input type='text'>
22
+ </div>
23
+ <ul>
24
+ </ul>
25
+
26
+ </div>
27
+ </body>
28
+ </html>
@@ -22,20 +22,44 @@ plugin = ($)->
22
22
  "use strict"
23
23
 
24
24
  # CLOSE CLASS DEFINITION
25
- # =========================
26
- class Close
25
+ #
26
+ # @example How to use the class
27
+ # closeInstance = new Close $('.my-element')
28
+ # # Close element
29
+ # closeInstance.close()
30
+ #
31
+ # @example How to use the class with jQuery
32
+ # $('.my-element').close('close')
33
+ #
34
+ # @example How to ensure plugin self initialises on element
35
+ # <div data-close> Close me </div>
36
+ #
37
+ class Close
38
+
39
+ # Construct a new Close instance
40
+ #
41
+ # @param [Object] element HTMLElement on which we will try to close
42
+ #
27
43
  constructor: ( element ) ->
28
44
  $el = $(element)
29
45
  @$target = @_getTarget $el
30
46
 
47
+ # Expose the Class
31
48
  _constructor: Close
32
-
49
+
50
+ # Close the element - Triggers 'close' event on this.$target then removes this.$target
51
+ #
33
52
  close : ->
34
53
  if not @$target then return false
35
54
  @$target.trigger 'close'
36
55
  @$target.remove()
37
56
 
38
- # private
57
+ # Get the target element to be closed
58
+ #
59
+ # @private
60
+ # @param [Object] $el jQuery wrapped HTMLElement to get target to be closed from
61
+ # @return [Object] jQuery wrapped HTMLElement to be closed
62
+ #
39
63
  _getTarget: ($el) ->
40
64
  # Get target from data element
41
65
  target = (dataEl = $( $el.attr('data-close') )).length && dataEl
@@ -21,19 +21,42 @@ plugin = ($)->
21
21
 
22
22
  "use strict"
23
23
 
24
- # FORMs CLASS DEFINITION
25
- # =========================
24
+ # FORM CLASS DEFINITION
25
+ #
26
+ # @example How to use the class
27
+ # formInstance = new TBGForm $('.my-element')
28
+ # # Send form
29
+ # formInstance.send()
30
+ #
31
+ # @example How to use the class with jQuery
32
+ # $('.my-element').send()
33
+ #
34
+ # @example How to ensure plugin self initialises on element
35
+ # <form data-forms="/endpoint"> ... </form>
36
+ #
26
37
  class TBGForm
38
+
39
+ # Construct a new TBGForm instance
40
+ #
41
+ # @param [Object] element form we will attach the TBGForm to
42
+ #
27
43
  constructor: ( element ) ->
28
44
  @form = $(element)
29
45
  @send()
30
46
 
31
47
  _constructor: TBGForm
32
48
 
49
+ # Send the form, calls sendRequest passing form data and url to post to
50
+ #
33
51
  send : ->
34
52
  if not (url = @form.data('forms') || @form.attr('action')) then return false
35
53
  @sendRequest @form.serialize(), url
36
54
 
55
+ # Execute ajax post
56
+ #
57
+ # @param [String] data serialized form data
58
+ # @param [String] url URL to post form to
59
+ #
37
60
  sendRequest : (data, url)->
38
61
  $.ajax
39
62
  type: 'POST'
@@ -45,7 +68,12 @@ plugin = ($)->
45
68
  error: (err) =>
46
69
  @showErrors $.parseJSON(err.responseText)
47
70
 
48
-
71
+ # Handle form post errors - called from sendRequest error callback.
72
+ #
73
+ # Clear previous errors, add error classes to relevent fields and labels and add error message summary
74
+ #
75
+ # @param [Object] errors errors object
76
+ #
49
77
  showErrors :( errors )->
50
78
  @form.find('.form-msg.is-error').remove()
51
79
  @form.find('.is-error').removeClass('is-error')
@@ -56,7 +84,14 @@ plugin = ($)->
56
84
  msg.text( "#{field} " + error.join(' & ') ).addClass('is-error')
57
85
  $this.siblings('label').addClass('is-error')
58
86
 
59
-
87
+ # Handle form post success - called from sendRequest success callback.
88
+ #
89
+ # Pass empty error object to showErrors; if Handlebars defined
90
+ # call _showSuccessTemplated with data object otherwise call
91
+ # _showSuccessPlain; trigger 'tbgform-success' event with form data; fade form if necessary
92
+ #
93
+ # @param [Object] data response from ajax post
94
+ #
60
95
  showSuccess: (data)->
61
96
  @showErrors {}
62
97
  if Handlebars?
@@ -66,12 +101,24 @@ plugin = ($)->
66
101
  $('body').trigger 'tbgform-success', [@form]
67
102
  if @form.data 'formsSuccessFormfade' then @form.fadeOut()
68
103
 
104
+ # Display compiled success template
105
+ #
106
+ # Compile template from data-formsSuccessContent; display with data object
107
+ #
108
+ # @private
109
+ # @param [Object] data data object from showSuccess
110
+ #
69
111
  _showSuccessTemplated: (data)->
70
112
  template = Handlebars.compile @form.data('formsSuccessContent')
71
113
  successArea = $(@form.data 'formsSuccessReplace')
72
114
  successArea.fadeOut().html( template(data) ).fadeIn()
73
115
 
74
-
116
+ # Display success with replaced content
117
+ #
118
+ # Display data-formsSuccessContent HTML
119
+ #
120
+ # @private
121
+ #
75
122
  _showSuccessPlain: ->
76
123
  @successArea = $(@form.data 'formsSuccessReplace')
77
124
  @successHTML = @form.data 'formsSuccessContent'