Skip to content

Commit 802040b

Browse files
committed
Adding new docs dir
1 parent 986f2a9 commit 802040b

File tree

171 files changed

+13313
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+13313
-0
lines changed

docs/coffee/app.coffee

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
KS = require '../lib/coffee/app'
2+
Docs = require './docs'
3+
NavbarFixer = require './navbar-fixer'
4+
Index = require './index'

docs/coffee/docs.coffee

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
document.addEventListener 'DOMContentLoaded', ->
2+
3+
window.$$ = (el) -> document.querySelectorAll(el)
4+
window.$ = (el) -> $$(el)[0]
5+
6+
###
7+
CRUD DOCUMENTATION SETTINGS
8+
###
9+
10+
# Default settings
11+
defaults =
12+
viewOptions:
13+
jquery: false
14+
semantic: true
15+
16+
booleanViewOptions = ['jquery', 'semantic']
17+
18+
# Retrieve user's saved settings
19+
options = JSON.parse localStorage.getItem 'kickstartDocs'
20+
21+
# Create shallow extend function
22+
# (http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/)
23+
extend = (destination, source) ->
24+
for property of source
25+
if source[property] and source[property].constructor and source[property].constructor is Object
26+
destination[property] = destination[property] or {}
27+
arguments.callee destination[property], source[property]
28+
else
29+
destination[property] = source[property]
30+
destination
31+
32+
# Extend from defaults
33+
settings = if options then extend defaults, options else defaults
34+
35+
# Create function to write to localStorage
36+
setSettings = (settings) ->
37+
localStorage.setItem 'kickstartDocs', JSON.stringify settings
38+
39+
for option in booleanViewOptions
40+
if settings.viewOptions["#{option}"]
41+
document.body.classList.add "show-#{option}"
42+
else
43+
document.body.classList.remove "show-#{option}"
44+
45+
# Write to localStorage
46+
setSettings(settings)
47+
48+
els = []
49+
for option in booleanViewOptions
50+
option = "#docs-#{option}"
51+
els.push option
52+
53+
if $$(els).length
54+
# This page has checkboxes for view options.
55+
for option in booleanViewOptions
56+
# Closure needed for event listeners
57+
do (option) ->
58+
window["$opt#{option}"] = $ "#docs-#{option}"
59+
60+
# Set state of buttons based on saved options in localStorage
61+
window["$opt#{option}"].checked = (if settings.viewOptions["#{option}"] then true else false)
62+
63+
# Listen for checkbox changes
64+
window["$opt#{option}"].addEventListener 'click', ->
65+
settings.viewOptions["#{option}"] = this.checked
66+
setSettings settings
67+
68+
# Show growls
69+
if k$.$('#example-showGrowl')
70+
k$.$('#example-showGrowl').addEventListener 'click', ->
71+
growls = [
72+
{
73+
title: 'Document Saved.',
74+
text: 'Your document was successfully saved.'
75+
type: 'alert-green'
76+
},
77+
{
78+
title: 'Library book not found'
79+
text: 'Sorry, we could find that library book.',
80+
type: 'alert-red'
81+
},
82+
{
83+
title: 'Wide clearance selection',
84+
text: 'Remember to check out our clearance',
85+
type: 'alert-blue'
86+
},
87+
{
88+
title: 'Deadline approaching',
89+
text: 'Friendly reminder that your deadline is quickly approaching.',
90+
type: 'alert-yellow'
91+
}
92+
]
93+
94+
k$.exampleCounter++
95+
k$.exampleCounter = 0 if not k$.exampleCounter or k$.exampleCounter > 3
96+
97+
k$.growl growls[k$.exampleCounter]
98+
99+
# Show status message
100+
if k$.$('#example-showStatus')
101+
k$.$('#example-showStatus').addEventListener 'click', ->
102+
statuses = [
103+
{
104+
text: 'Document Saved.',
105+
type: 'status-green'
106+
},
107+
{
108+
text: 'Sorry, we could find that library book.',
109+
type: 'status-red'
110+
},
111+
{
112+
text: 'Remember to check out our clearance',
113+
type: 'status-blue'
114+
},
115+
{
116+
text: 'Deadline is approaching!',
117+
type: 'status-yellow'
118+
}
119+
]
120+
121+
k$.exampleCounter++
122+
k$.exampleCounter = 0 if not k$.exampleCounter or k$.exampleCounter > 3
123+
124+
k$.status(statuses[k$.exampleCounter])
125+
126+
k$.slugify = (str) ->
127+
`str.toLowerCase().replace(/ /g,'-').replace(/[^\w-]+/g,'')`
128+
129+
# Create a table of contents
130+
131+
if k$.$$('#toc').length
132+
k$.$('.creating-table').parentNode.removeChild k$.$('.creating-table')
133+
$toc = document.createElement 'ul'
134+
$toc.className = "list list-unstyled"
135+
$link = document.createElement('li')
136+
$link.innerHTML = '<a></a>'
137+
138+
# Assuming proper html, start with h1.
139+
$headingLevel = 1
140+
141+
# The node we're currently appending to. Always a ul.
142+
$targetNode = $toc
143+
144+
$documentContainer = k$.$('.document-container')
145+
for heading in $documentContainer.querySelectorAll('h1, h2, h3, h4, h5, h6')
146+
# Ignore headings that declare themselves as exempt from the TOC
147+
if not heading.classList.contains 'toc-exempt'
148+
# For extra unique names.
149+
# heading.id = "#{k$.slugify heading.innerHTML}-#{_k}"
150+
151+
heading.id = k$.slugify heading.innerHTML
152+
153+
# If this is a lower level.
154+
$thisHeadingLevel = parseInt(heading.tagName.substr(1, 2))
155+
156+
if $thisHeadingLevel > $headingLevel
157+
# Append a new submenu and make that the targetNode.
158+
$newSubmenu = document.createElement 'ul'
159+
$targetNode.children[$targetNode.children.length - 1].appendChild $newSubmenu
160+
$targetNode = $newSubmenu
161+
$headingLevel = $thisHeadingLevel
162+
163+
# If this is a higher level
164+
if $thisHeadingLevel < $headingLevel
165+
$stepsUp = $headingLevel - $thisHeadingLevel
166+
167+
while $stepsUp > -1
168+
$targetNode = $targetNode.parentNode
169+
$stepsUp--
170+
171+
$headingLevel = $thisHeadingLevel
172+
173+
# Make a new li and append it to the target ul node.
174+
$menuItem = $link.cloneNode true
175+
$menuItem.querySelector('a').href = "##{heading.id}"
176+
$menuItem.querySelector('a').innerHTML = heading.innerHTML
177+
$targetNode.appendChild $menuItem
178+
179+
k$.$('#toc').appendChild $toc

docs/coffee/index.coffee

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
$button = k$.$('#preview-button')
2+
typeOut = (str, container, cb, startWith) ->
3+
i = 0
4+
_str = ""
5+
6+
@interval = setInterval ->
7+
i++
8+
_str = str.substr(0, i)
9+
container.innerHTML = startWith + _str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\|/g, '<br>').replace(/\+/g, '<span class="color">').replace(/\*/g, '</span>').replace(/%/g, '&nbsp;')
10+
if i > str.length - 1
11+
clearInterval @interval
12+
cb()
13+
, 75
14+
15+
slide3 = ->
16+
$button.classList.add('button')
17+
$button.classList.add('button-primary')
18+
slide3TO = setTimeout ->
19+
$button.classList.remove('button')
20+
$button.classList.remove('button-primary')
21+
clearTimeout slide3TO
22+
slide1()
23+
, 1200
24+
25+
slide2 = ->
26+
$button.classList.add('button')
27+
$button.classList.add('button-primary')
28+
slide2TO = setTimeout ->
29+
$button.classList.remove('button')
30+
$button.classList.remove('button-primary')
31+
typeOut '<button class="+cta*">Call to Action</button>||.+cta* {|%%@include button($primary-color);|}', k$.$('#source'), slide3, "&lt;!-- OR define your own --&gt;<br><br>"
32+
clearTimeout slide2TO
33+
, 1200
34+
35+
36+
slide1 = ->
37+
typeOut '<button class="+button button-primary*">Call to Action</button>', k$.$('#source'), slide2, "&lt;!-- Use predefined classes --&gt;<br><br>"
38+
39+
slide1()

docs/coffee/navbar-fixer.coffee

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
window.onscroll = ->
2+
$marker = k$.$('#marker')
3+
$fixedArea = k$.$('.fixed-area')
4+
$offset = $marker.getBoundingClientRect().top
5+
$isFixed = $fixedArea.classList.contains 'fixed'
6+
if $offset < 1
7+
$fixedArea.classList.add 'fixed' if not $isFixed
8+
else
9+
$fixedArea.classList.remove 'fixed' if $isFixed

docs/coffee/tests.coffee

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
App = require './app'
2+
testDef = require '../tests/default'

docs/gulp/tasks/browserSync.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var browserSync = require('browser-sync');
2+
var gulp = require('gulp');
3+
4+
gulp.task('browserSync', ['build'], function() {
5+
browserSync.init(['./public/**'], {
6+
server: {
7+
baseDir: ['public', 'lib']
8+
}
9+
});
10+
});

docs/gulp/tasks/browserify.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var browserify = require('browserify');
2+
var watchify = require('watchify');
3+
var bundleLogger = require('../util/bundleLogger');
4+
var gulp = require('gulp');
5+
var handleErrors = require('../util/handleErrors');
6+
var source = require('vinyl-source-stream');
7+
8+
gulp.task('browserify', function() {
9+
var bundler = browserify({
10+
// Required watchify args
11+
cache: {}, packageCache: {}, fullPaths: true,
12+
// Specify the entry point of your app
13+
entries: ['./lib/coffee/app.coffee'],
14+
// Add file extentions to make optional in your requires
15+
extensions: ['.coffee'],
16+
// Enable source maps!
17+
debug: true
18+
});
19+
20+
var bundle = function() {
21+
// Log when bundling starts
22+
bundleLogger.start();
23+
24+
return bundler
25+
.bundle()
26+
// Report compile errors
27+
.on('error', handleErrors)
28+
// Use vinyl-source-stream to make the
29+
// stream gulp compatible. Specifiy the
30+
// desired output filename here.
31+
.pipe(source('kickstart.js'))
32+
// Specify the output destination
33+
.pipe(gulp.dest('./public/js/'))
34+
// Log when bundling completes!
35+
.on('end', bundleLogger.end);
36+
};
37+
38+
if(global.isWatching) {
39+
bundler = watchify(bundler);
40+
// Rebundle with watchify on changes.
41+
bundler.on('update', bundle);
42+
}
43+
44+
return bundle();
45+
});

docs/gulp/tasks/build.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var gulp = require('gulp');
2+
3+
gulp.task('build', ['browserify', 'jade', 'images', 'sass', 'coffee', 'minify']);
4+
gulp.task('build:docs', ['browserify', 'jade', 'images', 'sass', 'coffee', 'rails', 'iframes', 'minify']);

docs/gulp/tasks/bundle-tests.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var mocha = require('gulp-mocha');
2+
var gutil = require('gulp-util');
3+
var browserify = require('browserify');
4+
var watchify = require('watchify');
5+
var bundleLogger = require('../util/bundleLogger');
6+
var gulp = require('gulp');
7+
var handleErrors = require('../util/handleErrors');
8+
var source = require('vinyl-source-stream');
9+
var todo = require('gulp-todos');
10+
11+
gulp.task('bundle-tests', function() {
12+
var bundler = browserify({
13+
// Required watchify args
14+
cache: {}, packageCache: {}, fullPaths: true,
15+
// Specify the entry point of your app
16+
entries: ['./lib/coffee/tests.coffee'],
17+
// Add file extentions to make optional in your requires
18+
extensions: ['.coffee'],
19+
// Enable source maps!
20+
debug: true
21+
});
22+
23+
var bundle = function() {
24+
// Log when bundling starts
25+
bundleLogger.start();
26+
return bundler
27+
.bundle()
28+
// Report compile errors
29+
.on('error', handleErrors)
30+
// Use vinyl-source-stream to make the
31+
// stream gulp compatible. Specifiy the
32+
// desired output filename here.
33+
// Specify the output destination
34+
.pipe(source('test.js'))
35+
.pipe(gulp.dest('./public/js/'))
36+
// Log when bundling completes!
37+
.on('end', bundleLogger.end);
38+
};
39+
40+
if(global.isWatching) {
41+
bundler = watchify(bundler);
42+
// Rebundle with watchify on changes.
43+
bundler.on('update', bundle);
44+
}
45+
46+
return bundle();
47+
});

docs/gulp/tasks/coffee.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var gulp = require('gulp'),
2+
gulpif = require('gulp-if'),
3+
uglify = require('gulp-uglify'),
4+
coffee = require('gulp-coffee');
5+
6+
gulp.task('coffee', function() {
7+
gulp.src(['./lib/coffee/docs.coffee', './lib/coffee/navbar-fixer.coffee', './lib/coffee/index.coffee'])
8+
.pipe(gulpif(/[.]coffee$/, coffee()))
9+
.pipe(gulp.dest('./public/js'));
10+
})

docs/gulp/tasks/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var gulp = require('gulp')
2+
3+
gulp.task('default', ['watch']);

docs/gulp/tasks/iframes.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var gulp = require('gulp');
2+
3+
gulp.task('iframes', function() {
4+
gulp.src(['./lib/iframes/**'])
5+
.pipe(gulp.dest('./public/iframes'));
6+
})

docs/gulp/tasks/images.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var newer = require('gulp-newer');
2+
var gulp = require('gulp');
3+
var imagemin = require('gulp-imagemin');
4+
5+
gulp.task('images', function() {
6+
var dest = './public/img';
7+
8+
return gulp.src('./lib/img/**/*')
9+
.pipe(newer(dest)) // Ignore unchanged files
10+
.pipe(gulp.dest(dest));
11+
});

0 commit comments

Comments
 (0)