forked from adamjgrant/kickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
986f2a9
commit 802040b
Showing
171 changed files
with
13,313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
KS = require '../lib/coffee/app' | ||
Docs = require './docs' | ||
NavbarFixer = require './navbar-fixer' | ||
Index = require './index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
document.addEventListener 'DOMContentLoaded', -> | ||
|
||
window.$$ = (el) -> document.querySelectorAll(el) | ||
window.$ = (el) -> $$(el)[0] | ||
|
||
### | ||
CRUD DOCUMENTATION SETTINGS | ||
### | ||
|
||
# Default settings | ||
defaults = | ||
viewOptions: | ||
jquery: false | ||
semantic: true | ||
|
||
booleanViewOptions = ['jquery', 'semantic'] | ||
|
||
# Retrieve user's saved settings | ||
options = JSON.parse localStorage.getItem 'kickstartDocs' | ||
|
||
# Create shallow extend function | ||
# (http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/) | ||
extend = (destination, source) -> | ||
for property of source | ||
if source[property] and source[property].constructor and source[property].constructor is Object | ||
destination[property] = destination[property] or {} | ||
arguments.callee destination[property], source[property] | ||
else | ||
destination[property] = source[property] | ||
destination | ||
|
||
# Extend from defaults | ||
settings = if options then extend defaults, options else defaults | ||
|
||
# Create function to write to localStorage | ||
setSettings = (settings) -> | ||
localStorage.setItem 'kickstartDocs', JSON.stringify settings | ||
|
||
for option in booleanViewOptions | ||
if settings.viewOptions["#{option}"] | ||
document.body.classList.add "show-#{option}" | ||
else | ||
document.body.classList.remove "show-#{option}" | ||
|
||
# Write to localStorage | ||
setSettings(settings) | ||
|
||
els = [] | ||
for option in booleanViewOptions | ||
option = "#docs-#{option}" | ||
els.push option | ||
|
||
if $$(els).length | ||
# This page has checkboxes for view options. | ||
for option in booleanViewOptions | ||
# Closure needed for event listeners | ||
do (option) -> | ||
window["$opt#{option}"] = $ "#docs-#{option}" | ||
|
||
# Set state of buttons based on saved options in localStorage | ||
window["$opt#{option}"].checked = (if settings.viewOptions["#{option}"] then true else false) | ||
|
||
# Listen for checkbox changes | ||
window["$opt#{option}"].addEventListener 'click', -> | ||
settings.viewOptions["#{option}"] = this.checked | ||
setSettings settings | ||
|
||
# Show growls | ||
if k$.$('#example-showGrowl') | ||
k$.$('#example-showGrowl').addEventListener 'click', -> | ||
growls = [ | ||
{ | ||
title: 'Document Saved.', | ||
text: 'Your document was successfully saved.' | ||
type: 'alert-green' | ||
}, | ||
{ | ||
title: 'Library book not found' | ||
text: 'Sorry, we could find that library book.', | ||
type: 'alert-red' | ||
}, | ||
{ | ||
title: 'Wide clearance selection', | ||
text: 'Remember to check out our clearance', | ||
type: 'alert-blue' | ||
}, | ||
{ | ||
title: 'Deadline approaching', | ||
text: 'Friendly reminder that your deadline is quickly approaching.', | ||
type: 'alert-yellow' | ||
} | ||
] | ||
|
||
k$.exampleCounter++ | ||
k$.exampleCounter = 0 if not k$.exampleCounter or k$.exampleCounter > 3 | ||
|
||
k$.growl growls[k$.exampleCounter] | ||
|
||
# Show status message | ||
if k$.$('#example-showStatus') | ||
k$.$('#example-showStatus').addEventListener 'click', -> | ||
statuses = [ | ||
{ | ||
text: 'Document Saved.', | ||
type: 'status-green' | ||
}, | ||
{ | ||
text: 'Sorry, we could find that library book.', | ||
type: 'status-red' | ||
}, | ||
{ | ||
text: 'Remember to check out our clearance', | ||
type: 'status-blue' | ||
}, | ||
{ | ||
text: 'Deadline is approaching!', | ||
type: 'status-yellow' | ||
} | ||
] | ||
|
||
k$.exampleCounter++ | ||
k$.exampleCounter = 0 if not k$.exampleCounter or k$.exampleCounter > 3 | ||
|
||
k$.status(statuses[k$.exampleCounter]) | ||
|
||
k$.slugify = (str) -> | ||
`str.toLowerCase().replace(/ /g,'-').replace(/[^\w-]+/g,'')` | ||
|
||
# Create a table of contents | ||
|
||
if k$.$$('#toc').length | ||
k$.$('.creating-table').parentNode.removeChild k$.$('.creating-table') | ||
$toc = document.createElement 'ul' | ||
$toc.className = "list list-unstyled" | ||
$link = document.createElement('li') | ||
$link.innerHTML = '<a></a>' | ||
|
||
# Assuming proper html, start with h1. | ||
$headingLevel = 1 | ||
|
||
# The node we're currently appending to. Always a ul. | ||
$targetNode = $toc | ||
|
||
$documentContainer = k$.$('.document-container') | ||
for heading in $documentContainer.querySelectorAll('h1, h2, h3, h4, h5, h6') | ||
# Ignore headings that declare themselves as exempt from the TOC | ||
if not heading.classList.contains 'toc-exempt' | ||
# For extra unique names. | ||
# heading.id = "#{k$.slugify heading.innerHTML}-#{_k}" | ||
|
||
heading.id = k$.slugify heading.innerHTML | ||
|
||
# If this is a lower level. | ||
$thisHeadingLevel = parseInt(heading.tagName.substr(1, 2)) | ||
|
||
if $thisHeadingLevel > $headingLevel | ||
# Append a new submenu and make that the targetNode. | ||
$newSubmenu = document.createElement 'ul' | ||
$targetNode.children[$targetNode.children.length - 1].appendChild $newSubmenu | ||
$targetNode = $newSubmenu | ||
$headingLevel = $thisHeadingLevel | ||
|
||
# If this is a higher level | ||
if $thisHeadingLevel < $headingLevel | ||
$stepsUp = $headingLevel - $thisHeadingLevel | ||
|
||
while $stepsUp > -1 | ||
$targetNode = $targetNode.parentNode | ||
$stepsUp-- | ||
|
||
$headingLevel = $thisHeadingLevel | ||
|
||
# Make a new li and append it to the target ul node. | ||
$menuItem = $link.cloneNode true | ||
$menuItem.querySelector('a').href = "##{heading.id}" | ||
$menuItem.querySelector('a').innerHTML = heading.innerHTML | ||
$targetNode.appendChild $menuItem | ||
|
||
k$.$('#toc').appendChild $toc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
$button = k$.$('#preview-button') | ||
typeOut = (str, container, cb, startWith) -> | ||
i = 0 | ||
_str = "" | ||
|
||
@interval = setInterval -> | ||
i++ | ||
_str = str.substr(0, i) | ||
container.innerHTML = startWith + _str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/\|/g, '<br>').replace(/\+/g, '<span class="color">').replace(/\*/g, '</span>').replace(/%/g, ' ') | ||
if i > str.length - 1 | ||
clearInterval @interval | ||
cb() | ||
, 75 | ||
|
||
slide3 = -> | ||
$button.classList.add('button') | ||
$button.classList.add('button-primary') | ||
slide3TO = setTimeout -> | ||
$button.classList.remove('button') | ||
$button.classList.remove('button-primary') | ||
clearTimeout slide3TO | ||
slide1() | ||
, 1200 | ||
|
||
slide2 = -> | ||
$button.classList.add('button') | ||
$button.classList.add('button-primary') | ||
slide2TO = setTimeout -> | ||
$button.classList.remove('button') | ||
$button.classList.remove('button-primary') | ||
typeOut '<button class="+cta*">Call to Action</button>||.+cta* {|%%@include button($primary-color);|}', k$.$('#source'), slide3, "<!-- OR define your own --><br><br>" | ||
clearTimeout slide2TO | ||
, 1200 | ||
|
||
|
||
slide1 = -> | ||
typeOut '<button class="+button button-primary*">Call to Action</button>', k$.$('#source'), slide2, "<!-- Use predefined classes --><br><br>" | ||
|
||
slide1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
window.onscroll = -> | ||
$marker = k$.$('#marker') | ||
$fixedArea = k$.$('.fixed-area') | ||
$offset = $marker.getBoundingClientRect().top | ||
$isFixed = $fixedArea.classList.contains 'fixed' | ||
if $offset < 1 | ||
$fixedArea.classList.add 'fixed' if not $isFixed | ||
else | ||
$fixedArea.classList.remove 'fixed' if $isFixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
App = require './app' | ||
testDef = require '../tests/default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var browserSync = require('browser-sync'); | ||
var gulp = require('gulp'); | ||
|
||
gulp.task('browserSync', ['build'], function() { | ||
browserSync.init(['./public/**'], { | ||
server: { | ||
baseDir: ['public', 'lib'] | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var browserify = require('browserify'); | ||
var watchify = require('watchify'); | ||
var bundleLogger = require('../util/bundleLogger'); | ||
var gulp = require('gulp'); | ||
var handleErrors = require('../util/handleErrors'); | ||
var source = require('vinyl-source-stream'); | ||
|
||
gulp.task('browserify', function() { | ||
var bundler = browserify({ | ||
// Required watchify args | ||
cache: {}, packageCache: {}, fullPaths: true, | ||
// Specify the entry point of your app | ||
entries: ['./lib/coffee/app.coffee'], | ||
// Add file extentions to make optional in your requires | ||
extensions: ['.coffee'], | ||
// Enable source maps! | ||
debug: true | ||
}); | ||
|
||
var bundle = function() { | ||
// Log when bundling starts | ||
bundleLogger.start(); | ||
|
||
return bundler | ||
.bundle() | ||
// Report compile errors | ||
.on('error', handleErrors) | ||
// Use vinyl-source-stream to make the | ||
// stream gulp compatible. Specifiy the | ||
// desired output filename here. | ||
.pipe(source('kickstart.js')) | ||
// Specify the output destination | ||
.pipe(gulp.dest('./public/js/')) | ||
// Log when bundling completes! | ||
.on('end', bundleLogger.end); | ||
}; | ||
|
||
if(global.isWatching) { | ||
bundler = watchify(bundler); | ||
// Rebundle with watchify on changes. | ||
bundler.on('update', bundle); | ||
} | ||
|
||
return bundle(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var gulp = require('gulp'); | ||
|
||
gulp.task('build', ['browserify', 'jade', 'images', 'sass', 'coffee', 'minify']); | ||
gulp.task('build:docs', ['browserify', 'jade', 'images', 'sass', 'coffee', 'rails', 'iframes', 'minify']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var mocha = require('gulp-mocha'); | ||
var gutil = require('gulp-util'); | ||
var browserify = require('browserify'); | ||
var watchify = require('watchify'); | ||
var bundleLogger = require('../util/bundleLogger'); | ||
var gulp = require('gulp'); | ||
var handleErrors = require('../util/handleErrors'); | ||
var source = require('vinyl-source-stream'); | ||
var todo = require('gulp-todos'); | ||
|
||
gulp.task('bundle-tests', function() { | ||
var bundler = browserify({ | ||
// Required watchify args | ||
cache: {}, packageCache: {}, fullPaths: true, | ||
// Specify the entry point of your app | ||
entries: ['./lib/coffee/tests.coffee'], | ||
// Add file extentions to make optional in your requires | ||
extensions: ['.coffee'], | ||
// Enable source maps! | ||
debug: true | ||
}); | ||
|
||
var bundle = function() { | ||
// Log when bundling starts | ||
bundleLogger.start(); | ||
return bundler | ||
.bundle() | ||
// Report compile errors | ||
.on('error', handleErrors) | ||
// Use vinyl-source-stream to make the | ||
// stream gulp compatible. Specifiy the | ||
// desired output filename here. | ||
// Specify the output destination | ||
.pipe(source('test.js')) | ||
.pipe(gulp.dest('./public/js/')) | ||
// Log when bundling completes! | ||
.on('end', bundleLogger.end); | ||
}; | ||
|
||
if(global.isWatching) { | ||
bundler = watchify(bundler); | ||
// Rebundle with watchify on changes. | ||
bundler.on('update', bundle); | ||
} | ||
|
||
return bundle(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var gulp = require('gulp'), | ||
gulpif = require('gulp-if'), | ||
uglify = require('gulp-uglify'), | ||
coffee = require('gulp-coffee'); | ||
|
||
gulp.task('coffee', function() { | ||
gulp.src(['./lib/coffee/docs.coffee', './lib/coffee/navbar-fixer.coffee', './lib/coffee/index.coffee']) | ||
.pipe(gulpif(/[.]coffee$/, coffee())) | ||
.pipe(gulp.dest('./public/js')); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var gulp = require('gulp') | ||
|
||
gulp.task('default', ['watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var gulp = require('gulp'); | ||
|
||
gulp.task('iframes', function() { | ||
gulp.src(['./lib/iframes/**']) | ||
.pipe(gulp.dest('./public/iframes')); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var newer = require('gulp-newer'); | ||
var gulp = require('gulp'); | ||
var imagemin = require('gulp-imagemin'); | ||
|
||
gulp.task('images', function() { | ||
var dest = './public/img'; | ||
|
||
return gulp.src('./lib/img/**/*') | ||
.pipe(newer(dest)) // Ignore unchanged files | ||
.pipe(gulp.dest(dest)); | ||
}); |
Oops, something went wrong.