guides_style_18f 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +19 -0
  3. data/LICENSE.md +31 -0
  4. data/README.md +91 -0
  5. data/assets/favicons/18f-center-114.png +0 -0
  6. data/assets/favicons/18f-center-144.png +0 -0
  7. data/assets/favicons/18f-center-16.png +0 -0
  8. data/assets/favicons/18f-center-192.png +0 -0
  9. data/assets/favicons/18f-center-200.png +0 -0
  10. data/assets/favicons/18f-center-32.png +0 -0
  11. data/assets/favicons/18f-center-57.png +0 -0
  12. data/assets/favicons/18f-center-72.png +0 -0
  13. data/assets/favicons/favicon.ico +0 -0
  14. data/assets/favicons/favicon.png +0 -0
  15. data/assets/img/18f-logo.png +0 -0
  16. data/assets/js/accordion.js +53 -0
  17. data/assets/js/html5shiv.js +301 -0
  18. data/assets/js/respond.js +341 -0
  19. data/lib/guides_style_18f.rb +8 -0
  20. data/lib/guides_style_18f/assets.rb +35 -0
  21. data/lib/guides_style_18f/generator.rb +12 -0
  22. data/lib/guides_style_18f/includes.rb +19 -0
  23. data/lib/guides_style_18f/includes/analytics.html +16 -0
  24. data/lib/guides_style_18f/includes/footer.html +9 -0
  25. data/lib/guides_style_18f/includes/header.html +21 -0
  26. data/lib/guides_style_18f/includes/scripts.html +5 -0
  27. data/lib/guides_style_18f/includes/sidebar.html +30 -0
  28. data/lib/guides_style_18f/layouts.rb +37 -0
  29. data/lib/guides_style_18f/layouts/default.html +40 -0
  30. data/lib/guides_style_18f/sass.rb +12 -0
  31. data/lib/guides_style_18f/sass/_guides_style_18f_custom.scss +50 -0
  32. data/lib/guides_style_18f/sass/_guides_style_18f_main.scss +606 -0
  33. data/lib/guides_style_18f/sass/_guides_style_18f_syntax.scss +60 -0
  34. data/lib/guides_style_18f/sass/guides_style_18f.scss +3 -0
  35. data/lib/guides_style_18f/version.rb +5 -0
  36. metadata +148 -0
@@ -0,0 +1,341 @@
1
+ /*! Respond.js v1.4.0: min/max-width media query polyfill. (c) Scott Jehl. MIT Lic. j.mp/respondjs */
2
+ (function( w ){
3
+
4
+ "use strict";
5
+
6
+ //exposed namespace
7
+ var respond = {};
8
+ w.respond = respond;
9
+
10
+ //define update even in native-mq-supporting browsers, to avoid errors
11
+ respond.update = function(){};
12
+
13
+ //define ajax obj
14
+ var requestQueue = [],
15
+ xmlHttp = (function() {
16
+ var xmlhttpmethod = false;
17
+ try {
18
+ xmlhttpmethod = new w.XMLHttpRequest();
19
+ }
20
+ catch( e ){
21
+ xmlhttpmethod = new w.ActiveXObject( "Microsoft.XMLHTTP" );
22
+ }
23
+ return function(){
24
+ return xmlhttpmethod;
25
+ };
26
+ })(),
27
+
28
+ //tweaked Ajax functions from Quirksmode
29
+ ajax = function( url, callback ) {
30
+ var req = xmlHttp();
31
+ if (!req){
32
+ return;
33
+ }
34
+ req.open( "GET", url, true );
35
+ req.onreadystatechange = function () {
36
+ if ( req.readyState !== 4 || req.status !== 200 && req.status !== 304 ){
37
+ return;
38
+ }
39
+ callback( req.responseText );
40
+ };
41
+ if ( req.readyState === 4 ){
42
+ return;
43
+ }
44
+ req.send( null );
45
+ };
46
+
47
+ //expose for testing
48
+ respond.ajax = ajax;
49
+ respond.queue = requestQueue;
50
+
51
+ // expose for testing
52
+ respond.regex = {
53
+ media: /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,
54
+ keyframes: /@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,
55
+ urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,
56
+ findStyles: /@media *([^\{]+)\{([\S\s]+?)$/,
57
+ only: /(only\s+)?([a-zA-Z]+)\s?/,
58
+ minw: /\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,
59
+ maxw: /\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/
60
+ };
61
+
62
+ //expose media query support flag for external use
63
+ respond.mediaQueriesSupported = w.matchMedia && w.matchMedia( "only all" ) !== null && w.matchMedia( "only all" ).matches;
64
+
65
+ //if media queries are supported, exit here
66
+ if( respond.mediaQueriesSupported ){
67
+ return;
68
+ }
69
+
70
+ //define vars
71
+ var doc = w.document,
72
+ docElem = doc.documentElement,
73
+ mediastyles = [],
74
+ rules = [],
75
+ appendedEls = [],
76
+ parsedSheets = {},
77
+ resizeThrottle = 30,
78
+ head = doc.getElementsByTagName( "head" )[0] || docElem,
79
+ base = doc.getElementsByTagName( "base" )[0],
80
+ links = head.getElementsByTagName( "link" ),
81
+
82
+ lastCall,
83
+ resizeDefer,
84
+
85
+ //cached container for 1em value, populated the first time it's needed
86
+ eminpx,
87
+
88
+ // returns the value of 1em in pixels
89
+ getEmValue = function() {
90
+ var ret,
91
+ div = doc.createElement('div'),
92
+ body = doc.body,
93
+ originalHTMLFontSize = docElem.style.fontSize,
94
+ originalBodyFontSize = body && body.style.fontSize,
95
+ fakeUsed = false;
96
+
97
+ div.style.cssText = "position:absolute;font-size:1em;width:1em";
98
+
99
+ if( !body ){
100
+ body = fakeUsed = doc.createElement( "body" );
101
+ body.style.background = "none";
102
+ }
103
+
104
+ // 1em in a media query is the value of the default font size of the browser
105
+ // reset docElem and body to ensure the correct value is returned
106
+ docElem.style.fontSize = "100%";
107
+ body.style.fontSize = "100%";
108
+
109
+ body.appendChild( div );
110
+
111
+ if( fakeUsed ){
112
+ docElem.insertBefore( body, docElem.firstChild );
113
+ }
114
+
115
+ ret = div.offsetWidth;
116
+
117
+ if( fakeUsed ){
118
+ docElem.removeChild( body );
119
+ }
120
+ else {
121
+ body.removeChild( div );
122
+ }
123
+
124
+ // restore the original values
125
+ docElem.style.fontSize = originalHTMLFontSize;
126
+ if( originalBodyFontSize ) {
127
+ body.style.fontSize = originalBodyFontSize;
128
+ }
129
+
130
+
131
+ //also update eminpx before returning
132
+ ret = eminpx = parseFloat(ret);
133
+
134
+ return ret;
135
+ },
136
+
137
+ //enable/disable styles
138
+ applyMedia = function( fromResize ){
139
+ var name = "clientWidth",
140
+ docElemProp = docElem[ name ],
141
+ currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp,
142
+ styleBlocks = {},
143
+ lastLink = links[ links.length-1 ],
144
+ now = (new Date()).getTime();
145
+
146
+ //throttle resize calls
147
+ if( fromResize && lastCall && now - lastCall < resizeThrottle ){
148
+ w.clearTimeout( resizeDefer );
149
+ resizeDefer = w.setTimeout( applyMedia, resizeThrottle );
150
+ return;
151
+ }
152
+ else {
153
+ lastCall = now;
154
+ }
155
+
156
+ for( var i in mediastyles ){
157
+ if( mediastyles.hasOwnProperty( i ) ){
158
+ var thisstyle = mediastyles[ i ],
159
+ min = thisstyle.minw,
160
+ max = thisstyle.maxw,
161
+ minnull = min === null,
162
+ maxnull = max === null,
163
+ em = "em";
164
+
165
+ if( !!min ){
166
+ min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 );
167
+ }
168
+ if( !!max ){
169
+ max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 );
170
+ }
171
+
172
+ // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true
173
+ if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){
174
+ if( !styleBlocks[ thisstyle.media ] ){
175
+ styleBlocks[ thisstyle.media ] = [];
176
+ }
177
+ styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] );
178
+ }
179
+ }
180
+ }
181
+
182
+ //remove any existing respond style element(s)
183
+ for( var j in appendedEls ){
184
+ if( appendedEls.hasOwnProperty( j ) ){
185
+ if( appendedEls[ j ] && appendedEls[ j ].parentNode === head ){
186
+ head.removeChild( appendedEls[ j ] );
187
+ }
188
+ }
189
+ }
190
+ appendedEls.length = 0;
191
+
192
+ //inject active styles, grouped by media type
193
+ for( var k in styleBlocks ){
194
+ if( styleBlocks.hasOwnProperty( k ) ){
195
+ var ss = doc.createElement( "style" ),
196
+ css = styleBlocks[ k ].join( "\n" );
197
+
198
+ ss.type = "text/css";
199
+ ss.media = k;
200
+
201
+ //originally, ss was appended to a documentFragment and sheets were appended in bulk.
202
+ //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one!
203
+ head.insertBefore( ss, lastLink.nextSibling );
204
+
205
+ if ( ss.styleSheet ){
206
+ ss.styleSheet.cssText = css;
207
+ }
208
+ else {
209
+ ss.appendChild( doc.createTextNode( css ) );
210
+ }
211
+
212
+ //push to appendedEls to track for later removal
213
+ appendedEls.push( ss );
214
+ }
215
+ }
216
+ },
217
+ //find media blocks in css text, convert to style blocks
218
+ translate = function( styles, href, media ){
219
+ var qs = styles.replace( respond.regex.keyframes, '' ).match( respond.regex.media ),
220
+ ql = qs && qs.length || 0;
221
+
222
+ //try to get CSS path
223
+ href = href.substring( 0, href.lastIndexOf( "/" ) );
224
+
225
+ var repUrls = function( css ){
226
+ return css.replace( respond.regex.urls, "$1" + href + "$2$3" );
227
+ },
228
+ useMedia = !ql && media;
229
+
230
+ //if path exists, tack on trailing slash
231
+ if( href.length ){ href += "/"; }
232
+
233
+ //if no internal queries exist, but media attr does, use that
234
+ //note: this currently lacks support for situations where a media attr is specified on a link AND
235
+ //its associated stylesheet has internal CSS media queries.
236
+ //In those cases, the media attribute will currently be ignored.
237
+ if( useMedia ){
238
+ ql = 1;
239
+ }
240
+
241
+ for( var i = 0; i < ql; i++ ){
242
+ var fullq, thisq, eachq, eql;
243
+
244
+ //media attr
245
+ if( useMedia ){
246
+ fullq = media;
247
+ rules.push( repUrls( styles ) );
248
+ }
249
+ //parse for styles
250
+ else{
251
+ fullq = qs[ i ].match( respond.regex.findStyles ) && RegExp.$1;
252
+ rules.push( RegExp.$2 && repUrls( RegExp.$2 ) );
253
+ }
254
+
255
+ eachq = fullq.split( "," );
256
+ eql = eachq.length;
257
+
258
+ for( var j = 0; j < eql; j++ ){
259
+ thisq = eachq[ j ];
260
+ mediastyles.push( {
261
+ media : thisq.split( "(" )[ 0 ].match( respond.regex.only ) && RegExp.$2 || "all",
262
+ rules : rules.length - 1,
263
+ hasquery : thisq.indexOf("(") > -1,
264
+ minw : thisq.match( respond.regex.minw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ),
265
+ maxw : thisq.match( respond.regex.maxw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" )
266
+ } );
267
+ }
268
+ }
269
+
270
+ applyMedia();
271
+ },
272
+
273
+ //recurse through request queue, get css text
274
+ makeRequests = function(){
275
+ if( requestQueue.length ){
276
+ var thisRequest = requestQueue.shift();
277
+
278
+ ajax( thisRequest.href, function( styles ){
279
+ translate( styles, thisRequest.href, thisRequest.media );
280
+ parsedSheets[ thisRequest.href ] = true;
281
+
282
+ // by wrapping recursive function call in setTimeout
283
+ // we prevent "Stack overflow" error in IE7
284
+ w.setTimeout(function(){ makeRequests(); },0);
285
+ } );
286
+ }
287
+ },
288
+
289
+ //loop stylesheets, send text content to translate
290
+ ripCSS = function(){
291
+
292
+ for( var i = 0; i < links.length; i++ ){
293
+ var sheet = links[ i ],
294
+ href = sheet.href,
295
+ media = sheet.media,
296
+ isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet";
297
+
298
+ //only links plz and prevent re-parsing
299
+ if( !!href && isCSS && !parsedSheets[ href ] ){
300
+ // selectivizr exposes css through the rawCssText expando
301
+ if (sheet.styleSheet && sheet.styleSheet.rawCssText) {
302
+ translate( sheet.styleSheet.rawCssText, href, media );
303
+ parsedSheets[ href ] = true;
304
+ } else {
305
+ if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) ||
306
+ href.replace( RegExp.$1, "" ).split( "/" )[0] === w.location.host ){
307
+ // IE7 doesn't handle urls that start with '//' for ajax request
308
+ // manually add in the protocol
309
+ if ( href.substring(0,2) === "//" ) { href = w.location.protocol + href; }
310
+ requestQueue.push( {
311
+ href: href,
312
+ media: media
313
+ } );
314
+ }
315
+ }
316
+ }
317
+ }
318
+ makeRequests();
319
+ };
320
+
321
+ //translate CSS
322
+ ripCSS();
323
+
324
+ //expose update for re-running respond later on
325
+ respond.update = ripCSS;
326
+
327
+ //expose getEmValue
328
+ respond.getEmValue = getEmValue;
329
+
330
+ //adjust on resize
331
+ function callMedia(){
332
+ applyMedia( true );
333
+ }
334
+
335
+ if( w.addEventListener ){
336
+ w.addEventListener( "resize", callMedia, false );
337
+ }
338
+ else if( w.attachEvent ){
339
+ w.attachEvent( "onresize", callMedia );
340
+ }
341
+ })(this);
@@ -0,0 +1,8 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require 'guides_style_18f/assets'
4
+ require 'guides_style_18f/generator'
5
+ require 'guides_style_18f/includes'
6
+ require 'guides_style_18f/layouts'
7
+ require 'guides_style_18f/sass'
8
+ require 'guides_style_18f/version'
@@ -0,0 +1,35 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require 'jekyll/static_file'
4
+ require 'liquid'
5
+
6
+ module GuidesStyle18F
7
+ class Assets
8
+ SOURCE = File.realpath File.join(__FILE__, '..', '..', '..')
9
+ BEGIN_PATH = SOURCE.size + File::SEPARATOR.size
10
+
11
+ def self.copy_to_site(site)
12
+ Dir.glob File.join(SOURCE, 'assets', '**', '*') do |asset|
13
+ next unless File.file? asset
14
+ asset = asset[BEGIN_PATH..-1]
15
+ site.static_files << ::Jekyll::StaticFile.new(
16
+ site, SOURCE, File.dirname(asset), File.basename(asset))
17
+ end
18
+ end
19
+ end
20
+
21
+ class AssetRootTag < ::Liquid::Tag
22
+ ::Liquid::Template.register_tag 'guides_style_18f_asset_root', self
23
+
24
+ def render(context)
25
+ self.class.do_render context
26
+ end
27
+
28
+ def self.do_render(context)
29
+ @asset_root ||= begin
30
+ config = context.registers[:site].config
31
+ config['asset_root'] || config['baseurl']
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require 'jekyll/generator'
4
+
5
+ module GuidesStyle18F
6
+ class Generator < ::Jekyll::Generator
7
+ def generate(site)
8
+ Layouts.register site
9
+ Assets.copy_to_site site
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require 'jekyll/tags/include'
4
+ require 'liquid'
5
+
6
+ module GuidesStyle18F
7
+ class IncludeTag < ::Jekyll::Tags::IncludeTag
8
+ ::Liquid::Template.register_tag 'guides_style_18f_include', self
9
+
10
+ def initialize(_tag_name, _name, _tokens)
11
+ super
12
+ @includes_dir = File.join File.dirname(__FILE__), 'includes'
13
+ end
14
+
15
+ def resolved_includes_dir(_context)
16
+ includes_dir
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ {% if site.google_analytics_ua %}<!-- Google Analytics -->
2
+ <script>
3
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7
+ ga('create', '{{ site.google_analytics_ua }}', 'gsa.gov');
8
+
9
+ // anonymize user IPs (chops off the last IP triplet)
10
+ ga('set', 'anonymizeIp', true);
11
+
12
+ ga('send', 'pageview');
13
+ </script>
14
+
15
+ <!-- Digital Analytics Program roll-up, see https://analytics.usa.gov for data -->
16
+ <script id="_fed_an_ua_tag" src="https://analytics.usa.gov/dap/dap.min.js" async></script>{% endif %}
@@ -0,0 +1,9 @@
1
+ <footer role="contentinfo">
2
+ <div class="wrap">
3
+ <p>This project is maintained by <a href="{{ site.author.url }}">{{ site.author.name }}</a>.</p>
4
+
5
+ <p>Hosted on <a href="https://github.com/18F/pages/">18F Pages</a>.
6
+ The <a href="https://github.com/18F/guides-template/">18F Guides theme</a> is based on <a href="https://github.com/cfpb/docter/">DOCter</a> from <a href="http://cfpb.github.io/">CFPB</a>.</p>
7
+ <p><a href="{{ site.repos[0].url }}/edit/18f-pages/{{ page.path }}">Edit this page</a> or <a href="{{ site.repos[0].url }}/issues">file an issue</a> on GitHub.</p>
8
+ </div><!--/.wrap -->
9
+ </footer>