govuk_admin_template 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # 0.0.5
2
+
3
+ * Fix gem.files to include all needed files (routes)
4
+
5
+ # 0.0.4
6
+
7
+ * Put style guide through parent application controller for accurate rendering
8
+
9
+ # 0.0.3
10
+
11
+ * Make style guide available as a mounted route
12
+
13
+ # 0.0.2
14
+
15
+ * Add lightweight Javascript framework and modules, ported from Transition
16
+
17
+ # 0.0.1
18
+
19
+ * Original gem release including template, styles, jQuery and Bootstrap
data/JAVASCRIPT.md ADDED
@@ -0,0 +1,106 @@
1
+ # Admin Javascript
2
+
3
+ `govuk_admin_template` comes with a lightweight javascript framework that makes it easy to write re-usable modular components, without having to worry about messy instantiation.
4
+
5
+ ## Usage
6
+
7
+ Javascript modules are specified in markup using `data-` attributes:
8
+
9
+ ```html
10
+ <div data-module="some-module">
11
+ <strong>Some other markup inside the module</strong>
12
+ </div>
13
+ ```
14
+
15
+ When javascript runs on the page the framework will look for a module at `GOVUKAdmin.Modules.SomeModule`. Note the value of the data attribute has been converted to _camelCase_.
16
+
17
+ The module will first be instantiated and then will automatically call the module’s `start` method, passing it the element the `data` attribute is on:
18
+
19
+ ```javascript
20
+ module = new GOVUKAdmin.Modules[type]();
21
+ module.start(element);
22
+ ```
23
+
24
+ This automatically limits modules to their containing elements and removes the need for messy inline script tags.
25
+
26
+ The simplest of modules looks like this:
27
+
28
+ ```javascript
29
+ (function(Modules) {
30
+ "use strict";
31
+ Modules.SomeModule = function() {
32
+ var that = this;
33
+ that.start = function(element) {
34
+ // module code
35
+ }
36
+ };
37
+ })(window.GOVUKAdmin.Modules);
38
+ ```
39
+
40
+ ## Writing modules
41
+
42
+ Whilst this isn’t prescriptive, it helps if modules look and behave in a similar manner. Modules should live within your app’s `app\assets\javascripts\modules` directory.
43
+
44
+ ### Use `js-` prefixed classes for interaction hooks
45
+
46
+ Make it clear where a javascript module will be applying behaviour:
47
+
48
+ ```html
49
+ <div data-module="toggle-thing">
50
+ <a href="/" class="js-toggle">Toggle</a>
51
+ <div class="js-toggle-target">Target</div>
52
+ </div>
53
+ ```
54
+
55
+ ### Declare event listeners at the start
56
+
57
+ Beginning with a set of event listeners clearly indicates the module’s intentions.
58
+
59
+ ```js
60
+ that.start = function(element) {
61
+ element.on('click', '.js-toggle', toggle);
62
+ element.on('click', '.js-cancel', cancel);
63
+ }
64
+ ```
65
+
66
+ Where possible, assign listeners to the module element to minimise the number of listeners and to allow for flexible markup:
67
+
68
+ ```html
69
+ <div data-module="toggle-thing">
70
+ <a href="/" class="js-toggle">This toggles</a>
71
+ <div class="js-toggle-target">
72
+ <p>Some content</p>
73
+ <a href="/" class="js-toggle">This also toggles</a>
74
+ </div>
75
+ </div>
76
+ ```
77
+
78
+ ### Use data-attributes for configuration
79
+
80
+ Keep modules flexible by moving configuration to data attributes on the module’s element:
81
+
82
+ ```html
83
+ <div
84
+ data-module="html-stream"
85
+ data-url="/some/endpoint"
86
+ data-refresh-ms="5000">
87
+ <!-- updates with content from end point -->
88
+ </div>
89
+ ```
90
+
91
+ ### Include Jasmine specs
92
+
93
+ Modules should have their own tests, whether they’re being included with the gem or are app specific.
94
+
95
+ ## Included modules
96
+
97
+ Found in the [app/assets/javascripts/modules](app/assets/javascripts/modules) directory, with tests in [spec/javascripts/spec/](spec/javascripts/spec/).
98
+
99
+ File | Module | Attribute | Description
100
+ ------ | ------ | --------- | -----------
101
+ auto_show_modal.js | AutoShowModal | auto-show-modal | Initialise a Boostrap modal on page load and remove markup when closed
102
+ auto_track_event.js | AutoTrackEvent | auto-track-event | Use data attributes to track events in Google Analytics on page load
103
+ filterable_table.js | FilterableTable | filterable-table | Filter the contents of a table, showing only matching rows
104
+ fixed_table_header.js | FixedTableHeader | fixed-table-header | Fix the `<thead>` portion of a table when scrolling offscreen
105
+ selectable_table.js | SelectableTable | selectable-table | Select rows in a table and perform an action on them
106
+ toggle.js | Toggle | toggle | A simple toggle
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ GovukAdminTemplate::Engine.routes.draw do
2
+ root :to => 'govuk_admin_template/style_guide#index'
3
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukAdminTemplate
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_admin_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-23 00:00:00.000000000 Z
12
+ date: 2014-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -170,11 +170,14 @@ files:
170
170
  - app/assets/javascripts/govuk-admin-template.js
171
171
  - app/controllers/govuk_admin_template/application_controller.rb
172
172
  - app/controllers/govuk_admin_template/style_guide_controller.rb
173
+ - config/routes.rb
173
174
  - lib/govuk_admin_template/engine.rb
174
175
  - lib/govuk_admin_template/version.rb
175
176
  - lib/govuk_admin_template.rb
176
- - LICENCE.txt
177
+ - JAVASCRIPT.md
178
+ - CHANGELOG.md
177
179
  - README.md
180
+ - LICENCE.txt
178
181
  homepage: https://github.com/alphagov/govuk_admin_template
179
182
  licenses: []
180
183
  post_install_message:
@@ -189,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
192
  version: '0'
190
193
  segments:
191
194
  - 0
192
- hash: 1997371940354407231
195
+ hash: -2415206504534781364
193
196
  required_rubygems_version: !ruby/object:Gem::Requirement
194
197
  none: false
195
198
  requirements:
@@ -198,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
201
  version: '0'
199
202
  segments:
200
203
  - 0
201
- hash: 1997371940354407231
204
+ hash: -2415206504534781364
202
205
  requirements: []
203
206
  rubyforge_project:
204
207
  rubygems_version: 1.8.23