Julio Biason
11 years ago
27 changed files with 1403 additions and 12 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,92 @@
|
||||
Copyright (c) 2010-2011 by tyPoland Lukasz Dziedzic with Reserved Font Name "Lato". |
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1. |
||||
This license is copied below, and is also available with a FAQ at: |
||||
http://scripts.sil.org/OFL |
||||
|
||||
|
||||
----------------------------------------------------------- |
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 |
||||
----------------------------------------------------------- |
||||
|
||||
PREAMBLE |
||||
The goals of the Open Font License (OFL) are to stimulate worldwide |
||||
development of collaborative font projects, to support the font creation |
||||
efforts of academic and linguistic communities, and to provide a free and |
||||
open framework in which fonts may be shared and improved in partnership |
||||
with others. |
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and |
||||
redistributed freely as long as they are not sold by themselves. The |
||||
fonts, including any derivative works, can be bundled, embedded, |
||||
redistributed and/or sold with any software provided that any reserved |
||||
names are not used by derivative works. The fonts and derivatives, |
||||
however, cannot be released under any other type of license. The |
||||
requirement for fonts to remain under this license does not apply |
||||
to any document created using the fonts or their derivatives. |
||||
|
||||
DEFINITIONS |
||||
"Font Software" refers to the set of files released by the Copyright |
||||
Holder(s) under this license and clearly marked as such. This may |
||||
include source files, build scripts and documentation. |
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the |
||||
copyright statement(s). |
||||
|
||||
"Original Version" refers to the collection of Font Software components as |
||||
distributed by the Copyright Holder(s). |
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting, |
||||
or substituting -- in part or in whole -- any of the components of the |
||||
Original Version, by changing formats or by porting the Font Software to a |
||||
new environment. |
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical |
||||
writer or other person who contributed to the Font Software. |
||||
|
||||
PERMISSION & CONDITIONS |
||||
Permission is hereby granted, free of charge, to any person obtaining |
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify, |
||||
redistribute, and sell modified and unmodified copies of the Font |
||||
Software, subject to the following conditions: |
||||
|
||||
1) Neither the Font Software nor any of its individual components, |
||||
in Original or Modified Versions, may be sold by itself. |
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled, |
||||
redistributed and/or sold with any software, provided that each copy |
||||
contains the above copyright notice and this license. These can be |
||||
included either as stand-alone text files, human-readable headers or |
||||
in the appropriate machine-readable metadata fields within text or |
||||
binary files as long as those fields can be easily viewed by the user. |
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font |
||||
Name(s) unless explicit written permission is granted by the corresponding |
||||
Copyright Holder. This restriction only applies to the primary font name as |
||||
presented to the users. |
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font |
||||
Software shall not be used to promote, endorse or advertise any |
||||
Modified Version, except to acknowledge the contribution(s) of the |
||||
Copyright Holder(s) and the Author(s) or with their explicit written |
||||
permission. |
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole, |
||||
must be distributed entirely under this license, and must not be |
||||
distributed under any other license. The requirement for fonts to |
||||
remain under this license does not apply to any document created |
||||
using the Font Software. |
||||
|
||||
TERMINATION |
||||
This license becomes null and void if any of the above conditions are |
||||
not met. |
||||
|
||||
DISCLAIMER |
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE |
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL |
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM |
||||
OTHER DEALINGS IN THE FONT SOFTWARE. |
@ -0,0 +1,2 @@
|
||||
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ |
||||
if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.className),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.className=this.toString()}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(o){o+="";if(g(this,o)===-1){this.push(o);this._updateClassName()}};e.remove=function(p){p+="";var o=g(this,p);if(o!==-1){this.splice(o,1);this._updateClassName()}};e.toggle=function(o){o+="";if(g(this,o)===-1){this.add(o)}else{this.remove(o)}};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))}; |
@ -0,0 +1,148 @@
|
||||
@import url(lato.css); |
||||
/** |
||||
* Default theme for reveal.js. |
||||
* |
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se |
||||
*/ |
||||
@font-face { |
||||
font-family: 'League Gothic'; |
||||
/* src: url("../../lib/font/league_gothic-webfont.eot"); */ |
||||
/* src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg"); */ |
||||
font-weight: normal; |
||||
font-style: normal; } |
||||
|
||||
/********************************************* |
||||
* GLOBAL STYLES |
||||
*********************************************/ |
||||
body { |
||||
background: #1c1e20; |
||||
background: -moz-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); |
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #555a5f), color-stop(100%, #1c1e20)); |
||||
background: -webkit-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); |
||||
background: -o-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); |
||||
background: -ms-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); |
||||
background: radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); |
||||
background-color: #2b2b2b; } |
||||
|
||||
.reveal { |
||||
font-family: "Lato", sans-serif; |
||||
font-size: 36px; |
||||
font-weight: normal; |
||||
letter-spacing: -0.02em; |
||||
color: #eeeeee; } |
||||
|
||||
::selection { |
||||
color: white; |
||||
background: #ff5e99; |
||||
text-shadow: none; } |
||||
|
||||
/********************************************* |
||||
* HEADERS |
||||
*********************************************/ |
||||
.reveal h1, |
||||
.reveal h2, |
||||
.reveal h3, |
||||
.reveal h4, |
||||
.reveal h5, |
||||
.reveal h6 { |
||||
margin: 0 0 20px 0; |
||||
color: #eeeeee; |
||||
font-family: "League Gothic", Impact, sans-serif; |
||||
line-height: 0.9em; |
||||
letter-spacing: 0.02em; |
||||
text-transform: uppercase; |
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); } |
||||
|
||||
.reveal h1 { |
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); } |
||||
|
||||
/********************************************* |
||||
* LINKS |
||||
*********************************************/ |
||||
.reveal a:not(.image) { |
||||
color: #13daec; |
||||
text-decoration: none; |
||||
-webkit-transition: color .15s ease; |
||||
-moz-transition: color .15s ease; |
||||
-ms-transition: color .15s ease; |
||||
-o-transition: color .15s ease; |
||||
transition: color .15s ease; } |
||||
|
||||
.reveal a:not(.image):hover { |
||||
color: #71e9f4; |
||||
text-shadow: none; |
||||
border: none; } |
||||
|
||||
.reveal .roll span:after { |
||||
color: #fff; |
||||
background: #0d99a5; } |
||||
|
||||
/********************************************* |
||||
* IMAGES |
||||
*********************************************/ |
||||
.reveal section img { |
||||
margin: 15px 0px; |
||||
background: rgba(255, 255, 255, 0.12); |
||||
border: 4px solid #eeeeee; |
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); |
||||
-webkit-transition: all .2s linear; |
||||
-moz-transition: all .2s linear; |
||||
-ms-transition: all .2s linear; |
||||
-o-transition: all .2s linear; |
||||
transition: all .2s linear; } |
||||
|
||||
.reveal a:hover img { |
||||
background: rgba(255, 255, 255, 0.2); |
||||
border-color: #13daec; |
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); } |
||||
|
||||
/********************************************* |
||||
* NAVIGATION CONTROLS |
||||
*********************************************/ |
||||
.reveal .controls div.navigate-left, |
||||
.reveal .controls div.navigate-left.enabled { |
||||
border-right-color: #13daec; } |
||||
|
||||
.reveal .controls div.navigate-right, |
||||
.reveal .controls div.navigate-right.enabled { |
||||
border-left-color: #13daec; } |
||||
|
||||
.reveal .controls div.navigate-up, |
||||
.reveal .controls div.navigate-up.enabled { |
||||
border-bottom-color: #13daec; } |
||||
|
||||
.reveal .controls div.navigate-down, |
||||
.reveal .controls div.navigate-down.enabled { |
||||
border-top-color: #13daec; } |
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover { |
||||
border-right-color: #71e9f4; } |
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover { |
||||
border-left-color: #71e9f4; } |
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover { |
||||
border-bottom-color: #71e9f4; } |
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover { |
||||
border-top-color: #71e9f4; } |
||||
|
||||
/********************************************* |
||||
* PROGRESS BAR |
||||
*********************************************/ |
||||
.reveal .progress { |
||||
background: rgba(0, 0, 0, 0.2); } |
||||
|
||||
.reveal .progress span { |
||||
background: #13daec; |
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); |
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); |
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); |
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); |
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); } |
||||
|
||||
/********************************************* |
||||
* SLIDE NUMBER |
||||
*********************************************/ |
||||
.reveal .slide-number { |
||||
color: #13daec; } |
@ -0,0 +1,8 @@
|
||||
/** |
||||
Head JS The only script in your <HEAD> |
||||
Copyright Tero Piirainen (tipiirai) |
||||
License MIT / http://bit.ly/mit-license
|
||||
Version 0.96 |
||||
|
||||
http://headjs.com
|
||||
*/(function(a){function z(){d||(d=!0,s(e,function(a){p(a)}))}function y(c,d){var e=a.createElement("script");e.type="text/"+(c.type||"javascript"),e.src=c.src||c,e.async=!1,e.onreadystatechange=e.onload=function(){var a=e.readyState;!d.done&&(!a||/loaded|complete/.test(a))&&(d.done=!0,d())},(a.body||b).appendChild(e)}function x(a,b){if(a.state==o)return b&&b();if(a.state==n)return k.ready(a.name,b);if(a.state==m)return a.onpreload.push(function(){x(a,b)});a.state=n,y(a.url,function(){a.state=o,b&&b(),s(g[a.name],function(a){p(a)}),u()&&d&&s(g.ALL,function(a){p(a)})})}function w(a,b){a.state===undefined&&(a.state=m,a.onpreload=[],y({src:a.url,type:"cache"},function(){v(a)}))}function v(a){a.state=l,s(a.onpreload,function(a){a.call()})}function u(a){a=a||h;var b;for(var c in a){if(a.hasOwnProperty(c)&&a[c].state!=o)return!1;b=!0}return b}function t(a){return Object.prototype.toString.call(a)=="[object Function]"}function s(a,b){if(!!a){typeof a=="object"&&(a=[].slice.call(a));for(var c=0;c<a.length;c++)b.call(a,a[c],c)}}function r(a){var b;if(typeof a=="object")for(var c in a)a[c]&&(b={name:c,url:a[c]});else b={name:q(a),url:a};var d=h[b.name];if(d&&d.url===b.url)return d;h[b.name]=b;return b}function q(a){var b=a.split("/"),c=b[b.length-1],d=c.indexOf("?");return d!=-1?c.substring(0,d):c}function p(a){a._done||(a(),a._done=1)}var b=a.documentElement,c,d,e=[],f=[],g={},h={},i=a.createElement("script").async===!0||"MozAppearance"in a.documentElement.style||window.opera,j=window.head_conf&&head_conf.head||"head",k=window[j]=window[j]||function(){k.ready.apply(null,arguments)},l=1,m=2,n=3,o=4;i?k.js=function(){var a=arguments,b=a[a.length-1],c={};t(b)||(b=null),s(a,function(d,e){d!=b&&(d=r(d),c[d.name]=d,x(d,b&&e==a.length-2?function(){u(c)&&p(b)}:null))});return k}:k.js=function(){var a=arguments,b=[].slice.call(a,1),d=b[0];if(!c){f.push(function(){k.js.apply(null,a)});return k}d?(s(b,function(a){t(a)||w(r(a))}),x(r(a[0]),t(d)?d:function(){k.js.apply(null,b)})):x(r(a[0]));return k},k.ready=function(b,c){if(b==a){d?p(c):e.push(c);return k}t(b)&&(c=b,b="ALL");if(typeof b!="string"||!t(c))return k;var f=h[b];if(f&&f.state==o||b=="ALL"&&u()&&d){p(c);return k}var i=g[b];i?i.push(c):i=g[b]=[c];return k},k.ready(a,function(){u()&&s(g.ALL,function(a){p(a)}),k.feature&&k.feature("domloaded",!0)});if(window.addEventListener)a.addEventListener("DOMContentLoaded",z,!1),window.addEventListener("load",z,!1);else if(window.attachEvent){a.attachEvent("onreadystatechange",function(){a.readyState==="complete"&&z()});var A=1;try{A=window.frameElement}catch(B){}!A&&b.doScroll&&function(){try{b.doScroll("left"),z()}catch(a){setTimeout(arguments.callee,1);return}}(),window.attachEvent("onload",z)}!a.readyState&&a.addEventListener&&(a.readyState="loading",a.addEventListener("DOMContentLoaded",handler=function(){a.removeEventListener("DOMContentLoaded",handler,!1),a.readyState="complete"},!1)),setTimeout(function(){c=!0,s(f,function(a){a()})},300)})(document) |
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
||||
@font-face { |
||||
font-family: 'Lato'; |
||||
font-style: normal; |
||||
font-weight: 400; |
||||
src: local('Lato Regular'), local('Lato-Regular'), url(9k-RPmcnxYEPm8CNFsH2gg.woff) format('woff'); |
||||
} |
||||
@font-face { |
||||
font-family: 'Lato'; |
||||
font-style: normal; |
||||
font-weight: 700; |
||||
src: local('Lato Bold'), local('Lato-Bold'), url(wkfQbvfT_02e2IWO3yYueQ.woff) format('woff'); |
||||
} |
||||
@font-face { |
||||
font-family: 'Lato'; |
||||
font-style: italic; |
||||
font-weight: 400; |
||||
src: local('Lato Italic'), local('Lato-Italic'), url(oUan5VrEkpzIazlUe5ieaA.woff) format('woff'); |
||||
} |
||||
@font-face { |
||||
font-family: 'Lato'; |
||||
font-style: italic; |
||||
font-weight: 700; |
||||
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(HkF_qI1x_noxlxhrhMQYED8E0i7KZn-EPnyo3HZu7kw.woff) format('woff'); |
||||
} |
@ -0,0 +1,392 @@
|
||||
/** |
||||
* The reveal.js markdown plugin. Handles parsing of |
||||
* markdown inside of presentations as well as loading |
||||
* of external markdown documents. |
||||
*/ |
||||
(function( root, factory ) { |
||||
if( typeof exports === 'object' ) { |
||||
module.exports = factory( require( './marked' ) ); |
||||
} |
||||
else { |
||||
// Browser globals (root is window)
|
||||
root.RevealMarkdown = factory( root.marked ); |
||||
root.RevealMarkdown.initialize(); |
||||
} |
||||
}( this, function( marked ) { |
||||
|
||||
if( typeof marked === 'undefined' ) { |
||||
throw 'The reveal.js Markdown plugin requires marked to be loaded'; |
||||
} |
||||
|
||||
if( typeof hljs !== 'undefined' ) { |
||||
marked.setOptions({ |
||||
highlight: function( lang, code ) { |
||||
return hljs.highlightAuto( lang, code ).value; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', |
||||
DEFAULT_NOTES_SEPARATOR = 'note:', |
||||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$', |
||||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$'; |
||||
|
||||
|
||||
/** |
||||
* Retrieves the markdown contents of a slide section |
||||
* element. Normalizes leading tabs/whitespace. |
||||
*/ |
||||
function getMarkdownFromSlide( section ) { |
||||
|
||||
var template = section.querySelector( 'script' ); |
||||
|
||||
// strip leading whitespace so it isn't evaluated as code
|
||||
var text = ( template || section ).textContent; |
||||
|
||||
var leadingWs = text.match( /^\n?(\s*)/ )[1].length, |
||||
leadingTabs = text.match( /^\n?(\t*)/ )[1].length; |
||||
|
||||
if( leadingTabs > 0 ) { |
||||
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' ); |
||||
} |
||||
else if( leadingWs > 1 ) { |
||||
text = text.replace( new RegExp('\\n? {' + leadingWs + '}','g'), '\n' ); |
||||
} |
||||
|
||||
return text; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Given a markdown slide section element, this will |
||||
* return all arguments that aren't related to markdown |
||||
* parsing. Used to forward any other user-defined arguments |
||||
* to the output markdown slide. |
||||
*/ |
||||
function getForwardedAttributes( section ) { |
||||
|
||||
var attributes = section.attributes; |
||||
var result = []; |
||||
|
||||
for( var i = 0, len = attributes.length; i < len; i++ ) { |
||||
var name = attributes[i].name, |
||||
value = attributes[i].value; |
||||
|
||||
// disregard attributes that are used for markdown loading/parsing
|
||||
if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue; |
||||
|
||||
if( value ) { |
||||
result.push( name + '=' + value ); |
||||
} |
||||
else { |
||||
result.push( name ); |
||||
} |
||||
} |
||||
|
||||
return result.join( ' ' ); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Inspects the given options and fills out default |
||||
* values for what's not defined. |
||||
*/ |
||||
function getSlidifyOptions( options ) { |
||||
|
||||
options = options || {}; |
||||
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR; |
||||
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR; |
||||
options.attributes = options.attributes || ''; |
||||
|
||||
return options; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Helper function for constructing a markdown slide. |
||||
*/ |
||||
function createMarkdownSlide( content, options ) { |
||||
|
||||
options = getSlidifyOptions( options ); |
||||
|
||||
var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) ); |
||||
|
||||
if( notesMatch.length === 2 ) { |
||||
content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>'; |
||||
} |
||||
|
||||
return '<script type="text/template">' + content + '</script>'; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Parses a data string into multiple slides based |
||||
* on the passed in separator arguments. |
||||
*/ |
||||
function slidify( markdown, options ) { |
||||
|
||||
options = getSlidifyOptions( options ); |
||||
|
||||
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ), |
||||
horizontalSeparatorRegex = new RegExp( options.separator ); |
||||
|
||||
var matches, |
||||
lastIndex = 0, |
||||
isHorizontal, |
||||
wasHorizontal = true, |
||||
content, |
||||
sectionStack = []; |
||||
|
||||
// iterate until all blocks between separators are stacked up
|
||||
while( matches = separatorRegex.exec( markdown ) ) { |
||||
notes = null; |
||||
|
||||
// determine direction (horizontal by default)
|
||||
isHorizontal = horizontalSeparatorRegex.test( matches[0] ); |
||||
|
||||
if( !isHorizontal && wasHorizontal ) { |
||||
// create vertical stack
|
||||
sectionStack.push( [] ); |
||||
} |
||||
|
||||
// pluck slide content from markdown input
|
||||
content = markdown.substring( lastIndex, matches.index ); |
||||
|
||||
if( isHorizontal && wasHorizontal ) { |
||||
// add to horizontal stack
|
||||
sectionStack.push( content ); |
||||
} |
||||
else { |
||||
// add to vertical stack
|
||||
sectionStack[sectionStack.length-1].push( content ); |
||||
} |
||||
|
||||
lastIndex = separatorRegex.lastIndex; |
||||
wasHorizontal = isHorizontal; |
||||
} |
||||
|
||||
// add the remaining slide
|
||||
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) ); |
||||
|
||||
var markdownSections = ''; |
||||
|
||||
// flatten the hierarchical stack, and insert <section data-markdown> tags
|
||||
for( var i = 0, len = sectionStack.length; i < len; i++ ) { |
||||
// vertical
|
||||
if( sectionStack[i] instanceof Array ) { |
||||
markdownSections += '<section '+ options.attributes +'>'; |
||||
|
||||
sectionStack[i].forEach( function( child ) { |
||||
markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>'; |
||||
} ); |
||||
|
||||
markdownSections += '</section>'; |
||||
} |
||||
else { |
||||
markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>'; |
||||
} |
||||
} |
||||
|
||||
return markdownSections; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Parses any current data-markdown slides, splits |
||||
* multi-slide markdown into separate sections and |
||||
* handles loading of external markdown. |
||||
*/ |
||||
function processSlides() { |
||||
|
||||
var sections = document.querySelectorAll( '[data-markdown]'), |
||||
section; |
||||
|
||||
for( var i = 0, len = sections.length; i < len; i++ ) { |
||||
|
||||
section = sections[i]; |
||||
|
||||
if( section.getAttribute( 'data-markdown' ).length ) { |
||||
|
||||
var xhr = new XMLHttpRequest(), |
||||
url = section.getAttribute( 'data-markdown' ); |
||||
|
||||
datacharset = section.getAttribute( 'data-charset' ); |
||||
|
||||
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
||||
if( datacharset != null && datacharset != '' ) { |
||||
xhr.overrideMimeType( 'text/html; charset=' + datacharset ); |
||||
} |
||||
|
||||
xhr.onreadystatechange = function() { |
||||
if( xhr.readyState === 4 ) { |
||||
if ( xhr.status >= 200 && xhr.status < 300 ) { |
||||
|
||||
section.outerHTML = slidify( xhr.responseText, { |
||||
separator: section.getAttribute( 'data-separator' ), |
||||
verticalSeparator: section.getAttribute( 'data-vertical' ), |
||||
notesSeparator: section.getAttribute( 'data-notes' ), |
||||
attributes: getForwardedAttributes( section ) |
||||
}); |
||||
|
||||
} |
||||
else { |
||||
|
||||
section.outerHTML = '<section data-state="alert">' + |
||||
'ERROR: The attempt to fetch ' + url + ' failed with HTTP status ' + xhr.status + '.' + |
||||
'Check your browser\'s JavaScript console for more details.' + |
||||
'<p>Remember that you need to serve the presentation HTML from a HTTP server.</p>' + |
||||
'</section>'; |
||||
|
||||
} |
||||
} |
||||
}; |
||||
|
||||
xhr.open( 'GET', url, false ); |
||||
|
||||
try { |
||||
xhr.send(); |
||||
} |
||||
catch ( e ) { |
||||
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e ); |
||||
} |
||||
|
||||
} |
||||
else if( section.getAttribute( 'data-separator' ) || section.getAttribute( 'data-vertical' ) || section.getAttribute( 'data-notes' ) ) { |
||||
|
||||
section.outerHTML = slidify( getMarkdownFromSlide( section ), { |
||||
separator: section.getAttribute( 'data-separator' ), |
||||
verticalSeparator: section.getAttribute( 'data-vertical' ), |
||||
notesSeparator: section.getAttribute( 'data-notes' ), |
||||
attributes: getForwardedAttributes( section ) |
||||
}); |
||||
|
||||
} |
||||
else { |
||||
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) ); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Check if a node value has the attributes pattern. |
||||
* If yes, extract it and add that value as one or several attributes |
||||
* the the terget element. |
||||
* |
||||
* You need Cache Killer on Chrome to see the effect on any FOM transformation |
||||
* directly on refresh (F5) |
||||
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
|
||||
*/ |
||||
function addAttributeInElement( node, elementTarget, separator ) { |
||||
|
||||
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' ); |
||||
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' ); |
||||
var nodeValue = node.nodeValue; |
||||
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) { |
||||
|
||||
var classes = matches[1]; |
||||
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex ); |
||||
node.nodeValue = nodeValue; |
||||
while( matchesClass = mardownClassRegex.exec( classes ) ) { |
||||
elementTarget.setAttribute( matchesClass[1], matchesClass[2] ); |
||||
} |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* Add attributes to the parent element of a text node, |
||||
* or the element of an attribute node. |
||||
*/ |
||||
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) { |
||||
|
||||
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) { |
||||
previousParentElement = element; |
||||
for( var i = 0; i < element.childNodes.length; i++ ) { |
||||
childElement = element.childNodes[i]; |
||||
if ( i > 0 ) { |
||||
j = i - 1; |
||||
while ( j >= 0 ) { |
||||
aPreviousChildElement = element.childNodes[j]; |
||||
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) { |
||||
previousParentElement = aPreviousChildElement; |
||||
break; |
||||
} |
||||
j = j - 1; |
||||
} |
||||
} |
||||
parentSection = section; |
||||
if( childElement.nodeName == "section" ) { |
||||
parentSection = childElement ; |
||||
previousParentElement = childElement ; |
||||
} |
||||
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) { |
||||
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ( element.nodeType == Node.COMMENT_NODE ) { |
||||
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) { |
||||
addAttributeInElement( element, section, separatorSectionAttributes ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Converts any current data-markdown slides in the |
||||
* DOM to HTML. |
||||
*/ |
||||
function convertSlides() { |
||||
|
||||
var sections = document.querySelectorAll( '[data-markdown]'); |
||||
|
||||
for( var i = 0, len = sections.length; i < len; i++ ) { |
||||
|
||||
var section = sections[i]; |
||||
|
||||
// Only parse the same slide once
|
||||
if( !section.getAttribute( 'data-markdown-parsed' ) ) { |
||||
|
||||
section.setAttribute( 'data-markdown-parsed', true ) |
||||
|
||||
var notes = section.querySelector( 'aside.notes' ); |
||||
var markdown = getMarkdownFromSlide( section ); |
||||
|
||||
section.innerHTML = marked( markdown ); |
||||
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) || |
||||
section.parentNode.getAttribute( 'data-element-attributes' ) || |
||||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR, |
||||
section.getAttribute( 'data-attributes' ) || |
||||
section.parentNode.getAttribute( 'data-attributes' ) || |
||||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR); |
||||
|
||||
// If there were notes, we need to re-add them after
|
||||
// having overwritten the section's HTML
|
||||
if( notes ) { |
||||
section.appendChild( notes ); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
// API
|
||||
return { |
||||
|
||||
initialize: function() { |
||||
processSlides(); |
||||
convertSlides(); |
||||
}, |
||||
|
||||
// TODO: Do these belong in the API?
|
||||
processSlides: processSlides, |
||||
convertSlides: convertSlides, |
||||
slidify: slidify |
||||
|
||||
}; |
||||
|
||||
})); |
@ -0,0 +1,37 @@
|
||||
/** |
||||
* marked - a markdown parser |
||||
* Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed) |
||||
* https://github.com/chjj/marked
|
||||
*/ |
||||
|
||||
(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, |
||||
text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|@)\\b";block.html=replace(block.html)("comment",/\x3c!--[\s\S]*?--\x3e/)("closed", |
||||
/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1", |
||||
"\\2")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm)if(this.options.tables)this.rules=block.tables;else this.rules=block.gfm}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)}; |
||||
Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1)this.tokens.push({type:"space"})}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm, |
||||
"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g, |
||||
"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]="center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].split(/ *\| */);this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src= |
||||
src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length); |
||||
bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+ |
||||
1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item[item.length-1]==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script",text:cap[0]});continue}if(top&& |
||||
(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]= |
||||
"center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1][cap[1].length-1]==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text", |
||||
text:cap[0]});continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^\x3c!--[\s\S]*?--\x3e|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, |
||||
code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, |
||||
em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal; |
||||
if(!this.links)throw new Error("Tokens array requires a `links` property.");if(this.options.gfm)if(this.options.breaks)this.rules=inline.breaks;else this.rules=inline.gfm;else if(this.options.pedantic)this.rules=inline.pedantic}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length); |
||||
out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1][6]===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.url.exec(src)){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.tag.exec(src)){src=src.substring(cap[0].length); |
||||
out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);out+=this.outputLink(cap,{href:cap[2],title:cap[3]});continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0][0];src=cap[0].substring(1)+src;continue}out+=this.outputLink(cap,link);continue}if(cap=this.rules.strong.exec(src)){src= |
||||
src.substring(cap[0].length);out+="<strong>"+this.output(cap[2]||cap[1])+"</strong>";continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+="<em>"+this.output(cap[2]||cap[1])+"</em>";continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+="<code>"+escape(cap[2],true)+"</code>";continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+="<br>";continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+="<del>"+ |
||||
this.output(cap[1])+"</del>";continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(cap[0]);continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return out};InlineLexer.prototype.outputLink=function(cap,link){if(cap[0][0]!=="!")return'<a href="'+escape(link.href)+'"'+(link.title?' title="'+escape(link.title)+'"':"")+">"+this.output(cap[1])+"</a>";else return'<img src="'+escape(link.href)+'" alt="'+escape(cap[1])+'"'+(link.title?' title="'+ |
||||
escape(link.title)+'"':"")+">"};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"\u2014").replace(/'([^']*)'/g,"\u2018$1\u2019").replace(/"([^"]*)"/g,"\u201c$1\u201d").replace(/\.{3}/g,"\u2026")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>0.5)ch="x"+ch.toString(16);out+="&#"+ch+";"}return out};function Parser(options){this.tokens=[];this.token=null; |
||||
this.options=options||marked.defaults}Parser.parse=function(src,options){var parser=new Parser(options);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options);this.tokens=src.reverse();var out="";while(this.next())out+=this.tok();return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text; |
||||
while(this.peek().type==="text")body+="\n"+this.next().text;return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case "space":return"";case "hr":return"<hr>\n";case "heading":return"<h"+this.token.depth+">"+this.inline.output(this.token.text)+"</h"+this.token.depth+">\n";case "code":if(this.options.highlight){var code=this.options.highlight(this.token.text,this.token.lang);if(code!=null&&code!==this.token.text){this.token.escaped=true;this.token.text=code}}if(!this.token.escaped)this.token.text= |
||||
escape(this.token.text,true);return"<pre><code"+(this.token.lang?' class="'+this.options.langPrefix+this.token.lang+'"':"")+">"+this.token.text+"</code></pre>\n";case "table":var body="",heading,i,row,cell,j;body+="<thead>\n<tr>\n";for(i=0;i<this.token.header.length;i++){heading=this.inline.output(this.token.header[i]);body+=this.token.align[i]?'<th align="'+this.token.align[i]+'">'+heading+"</th>\n":"<th>"+heading+"</th>\n"}body+="</tr>\n</thead>\n";body+="<tbody>\n";for(i=0;i<this.token.cells.length;i++){row= |
||||
this.token.cells[i];body+="<tr>\n";for(j=0;j<row.length;j++){cell=this.inline.output(row[j]);body+=this.token.align[j]?'<td align="'+this.token.align[j]+'">'+cell+"</td>\n":"<td>"+cell+"</td>\n"}body+="</tr>\n"}body+="</tbody>\n";return"<table>\n"+body+"</table>\n";case "blockquote_start":var body="";while(this.next().type!=="blockquote_end")body+=this.tok();return"<blockquote>\n"+body+"</blockquote>\n";case "list_start":var type=this.token.ordered?"ol":"ul",body="";while(this.next().type!=="list_end")body+= |
||||
this.tok();return"<"+type+">\n"+body+"</"+type+">\n";case "list_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.token.type==="text"?this.parseText():this.tok();return"<li>"+body+"</li>\n";case "loose_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.tok();return"<li>"+body+"</li>\n";case "html":return!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;case "paragraph":return"<p>"+this.inline.output(this.token.text)+ |
||||
"</p>\n";case "text":return"<p>"+this.parseText()+"</p>\n"}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i= |
||||
1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target)if(Object.prototype.hasOwnProperty.call(target,key))obj[key]=target[key]}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}if(opt)opt=merge({},marked.defaults,opt);var tokens=Lexer.lex(tokens,opt),highlight=opt.highlight,pending=0,l=tokens.length,i=0;if(!highlight||highlight.length<3)return callback(null,Parser.parse(tokens,opt));var done=function(){delete opt.highlight; |
||||
var out=Parser.parse(tokens,opt);opt.highlight=highlight;return callback(null,out)};for(;i<l;i++)(function(token){if(token.type!=="code")return;pending++;return highlight(token.text,token.lang,function(err,code){if(code==null||code===token.text)return--pending||done();token.text=code;token.escaped=true;--pending||done()})})(tokens[i]);return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked."; |
||||
if((opt||marked.defaults).silent)return"<p>An error occured:</p><pre>"+escape(e.message+"",true)+"</pre>";throw e;}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:""};marked.Parser=Parser;marked.parser=Parser.parse;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output; |
||||
marked.parse=marked;if(typeof exports==="object")module.exports=marked;else if(typeof define==="function"&&define.amd)define(function(){return marked});else this.marked=marked}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); |
@ -0,0 +1,78 @@
|
||||
/** |
||||
* Handles opening of and synchronization with the reveal.js |
||||
* notes window. |
||||
*/ |
||||
var RevealNotes = (function() { |
||||
|
||||
function openNotes() { |
||||
var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
|
||||
jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
|
||||
var notesPopup = window.open( jsFileLocation + 'notes.html', 'reveal.js - Notes', 'width=1120,height=850' ); |
||||
|
||||
// Fires when slide is changed
|
||||
Reveal.addEventListener( 'slidechanged', post ); |
||||
|
||||
// Fires when a fragment is shown
|
||||
Reveal.addEventListener( 'fragmentshown', post ); |
||||
|
||||
// Fires when a fragment is hidden
|
||||
Reveal.addEventListener( 'fragmenthidden', post ); |
||||
|
||||
/** |
||||
* Posts the current slide data to the notes window |
||||
*/ |
||||
function post() { |
||||
var slideElement = Reveal.getCurrentSlide(), |
||||
slideIndices = Reveal.getIndices(), |
||||
messageData; |
||||
|
||||
var notes = slideElement.querySelector( 'aside.notes' ), |
||||
nextindexh, |
||||
nextindexv; |
||||
|
||||
if( slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION' ) { |
||||
nextindexh = slideIndices.h; |
||||
nextindexv = slideIndices.v + 1; |
||||
} else { |
||||
nextindexh = slideIndices.h + 1; |
||||
nextindexv = 0; |
||||
} |
||||
|
||||
messageData = { |
||||
notes : notes ? notes.innerHTML : '', |
||||
indexh : slideIndices.h, |
||||
indexv : slideIndices.v, |
||||
indexf : slideIndices.f, |
||||
nextindexh : nextindexh, |
||||
nextindexv : nextindexv, |
||||
markdown : notes ? typeof notes.getAttribute( 'data-markdown' ) === 'string' : false |
||||
}; |
||||
|
||||
notesPopup.postMessage( JSON.stringify( messageData ), '*' ); |
||||
} |
||||
|
||||
// Navigate to the current slide when the notes are loaded
|
||||
notesPopup.addEventListener( 'load', function( event ) { |
||||
post(); |
||||
}, false ); |
||||
} |
||||
|
||||
// If the there's a 'notes' query set, open directly
|
||||
if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) { |
||||
openNotes(); |
||||
} |
||||
|
||||
// Open the notes when the 's' key is hit
|
||||
document.addEventListener( 'keydown', function( event ) { |
||||
// Disregard the event if the target is editable or a
|
||||
// modifier is present
|
||||
if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; |
||||
|
||||
if( event.keyCode === 83 ) { |
||||
event.preventDefault(); |
||||
openNotes(); |
||||
} |
||||
}, false ); |
||||
|
||||
return { open: openNotes }; |
||||
})(); |
Binary file not shown.
@ -0,0 +1,190 @@
|
||||
/* Default Print Stylesheet Template |
||||
by Rob Glazebrook of CSSnewbie.com |
||||
Last Updated: June 4, 2008 |
||||
|
||||
Feel free (nay, compelled) to edit, append, and |
||||
manipulate this file as you see fit. */ |
||||
|
||||
|
||||
/* SECTION 1: Set default width, margin, float, and |
||||
background. This prevents elements from extending |
||||
beyond the edge of the printed page, and prevents |
||||
unnecessary background images from printing */ |
||||
|
||||
* { |
||||
-webkit-print-color-adjust: exact; |
||||
} |
||||
|
||||
body { |
||||
font-size: 18pt; |
||||
width: 297mm; |
||||
height: 229mm; |
||||
margin: 0 auto !important; |
||||
border: 0; |
||||
padding: 0; |
||||
float: none !important; |
||||
overflow: visible; |
||||
} |
||||
|
||||
html { |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: visible; |
||||
} |
||||
|
||||
@page { |
||||
size: letter landscape; |
||||
margin: 0; |
||||
} |
||||
|
||||
/* SECTION 2: Remove any elements not needed in print. |
||||
This would include navigation, ads, sidebars, etc. */ |
||||
.nestedarrow, |
||||
.controls, |
||||
.reveal .progress, |
||||
.reveal.overview, |
||||
.fork-reveal, |
||||
.share-reveal, |
||||
.state-background { |
||||
display: none !important; |
||||
} |
||||
|
||||
/* SECTION 3: Set body font face, size, and color. |
||||
Consider using a serif font for readability. */ |
||||
body, p, td, li, div { |
||||
font-size: 18pt; |
||||
} |
||||
|
||||
/* SECTION 4: Set heading font face, sizes, and color. |
||||
Differentiate your headings from your body text. |
||||
Perhaps use a large sans-serif for distinction. */ |
||||
h1,h2,h3,h4,h5,h6 { |
||||
text-shadow: 0 0 0 #000 !important; |
||||
} |
||||
|
||||
/* SECTION 5: Make hyperlinks more usable. |
||||
Ensure links are underlined, and consider appending |
||||
the URL to the end of the link for usability. */ |
||||
a:link, |
||||
a:visited { |
||||
font-weight: normal; |
||||
text-decoration: underline; |
||||
} |
||||
|
||||
.reveal pre code { |
||||
overflow: hidden !important; |
||||
font-family: monospace !important; |
||||
} |
||||
|
||||
|
||||
/* SECTION 6: more reveal.js specific additions by @skypanther */ |
||||
ul, ol, div, p { |
||||
visibility: visible; |
||||
position: static; |
||||
width: auto; |
||||
height: auto; |
||||
display: block; |
||||
overflow: visible; |
||||
margin: auto; |
||||
} |
||||
.reveal { |
||||
width: auto !important; |
||||
height: auto !important; |
||||
overflow: hidden !important; |
||||
} |
||||
.reveal .slides { |
||||
position: static; |
||||
width: 100%; |
||||
height: auto; |
||||
|
||||
left: auto; |
||||
top: auto; |
||||
margin: 0 !important; |
||||
padding: 0 !important; |
||||
|
||||
overflow: visible; |
||||
display: block; |
||||
|
||||
text-align: center; |
||||
|
||||
-webkit-perspective: none; |
||||
-moz-perspective: none; |
||||
-ms-perspective: none; |
||||
perspective: none; |
||||
|
||||
-webkit-perspective-origin: 50% 50%; /* there isn't a none/auto value but 50-50 is the default */ |
||||
-moz-perspective-origin: 50% 50%; |
||||
-ms-perspective-origin: 50% 50%; |
||||
perspective-origin: 50% 50%; |
||||
} |
||||
.reveal .slides section { |
||||
|
||||
page-break-after: always !important; |
||||
|
||||
visibility: visible !important; |
||||
position: relative !important; |
||||
width: 100% !important; |
||||
height: 229mm !important; |
||||
min-height: 229mm !important; |
||||
display: block !important; |
||||
overflow: hidden !important; |
||||
|
||||
left: 0 !important; |
||||
top: 0 !important; |
||||
margin: 0 !important; |
||||
padding: 2cm 2cm 0 2cm !important; |
||||
box-sizing: border-box !important; |
||||
|
||||
opacity: 1 !important; |
||||
|
||||
-webkit-transform-style: flat !important; |
||||
-moz-transform-style: flat !important; |
||||
-ms-transform-style: flat !important; |
||||
transform-style: flat !important; |
||||
|
||||
-webkit-transform: none !important; |
||||
-moz-transform: none !important; |
||||
-ms-transform: none !important; |
||||
transform: none !important; |
||||
} |
||||
.reveal section.stack { |
||||
margin: 0 !important; |
||||
padding: 0 !important; |
||||
page-break-after: avoid !important; |
||||
height: auto !important; |
||||
min-height: auto !important; |
||||
} |
||||
.reveal .absolute-element { |
||||
margin-left: 2.2cm; |
||||
margin-top: 1.8cm; |
||||
} |
||||
.reveal section .fragment { |
||||
opacity: 1 !important; |
||||
visibility: visible !important; |
||||
|
||||
-webkit-transform: none !important; |
||||
-moz-transform: none !important; |
||||
-ms-transform: none !important; |
||||
transform: none !important; |
||||
} |
||||
.reveal section .slide-background { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
z-index: 0; |
||||
} |
||||
.reveal section>* { |
||||
position: relative; |
||||
z-index: 1; |
||||
} |
||||
.reveal img { |
||||
box-shadow: none; |
||||
} |
||||
.reveal .roll { |
||||
overflow: visible; |
||||
line-height: 1em; |
||||
} |
||||
.reveal small a { |
||||
font-size: 16pt !important; |
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,114 @@
|
||||
/* |
||||
|
||||
Zenburn style from voldmar.ru (c) Vladimir Epifanov <voldmar@voldmar.ru> |
||||
based on dark.css by Ivan Sagalaev |
||||
|
||||
*/ |
||||
|
||||
pre code { |
||||
display: block; padding: 0.5em; |
||||
background: #3F3F3F; |
||||
color: #DCDCDC; |
||||
} |
||||
|
||||
pre .keyword, |
||||
pre .tag, |
||||
pre .css .class, |
||||
pre .css .id, |
||||
pre .lisp .title, |
||||
pre .nginx .title, |
||||
pre .request, |
||||
pre .status, |
||||
pre .clojure .attribute { |
||||
color: #E3CEAB; |
||||
} |
||||
|
||||
pre .django .template_tag, |
||||
pre .django .variable, |
||||
pre .django .filter .argument { |
||||
color: #DCDCDC; |
||||
} |
||||
|
||||
pre .number, |
||||
pre .date { |
||||
color: #8CD0D3; |
||||
} |
||||
|
||||
pre .dos .envvar, |
||||
pre .dos .stream, |
||||
pre .variable, |
||||
pre .apache .sqbracket { |
||||
color: #EFDCBC; |
||||
} |
||||
|
||||
pre .dos .flow, |
||||
pre .diff .change, |
||||
pre .python .exception, |
||||
pre .python .built_in, |
||||
pre .literal, |
||||
pre .tex .special { |
||||
color: #EFEFAF; |
||||
} |
||||
|
||||
pre .diff .chunk, |
||||
pre .subst { |
||||
color: #8F8F8F; |
||||
} |
||||
|
||||
pre .dos .keyword, |
||||
pre .python .decorator, |
||||
pre .title, |
||||
pre .haskell .type, |
||||
pre .diff .header, |
||||
pre .ruby .class .parent, |
||||
pre .apache .tag, |
||||
pre .nginx .built_in, |
||||
pre .tex .command, |
||||
pre .prompt { |
||||
color: #efef8f; |
||||
} |
||||
|
||||
pre .dos .winutils, |
||||
pre .ruby .symbol, |
||||
pre .ruby .symbol .string, |
||||
pre .ruby .string { |
||||
color: #DCA3A3; |
||||
} |
||||
|
||||
pre .diff .deletion, |
||||
pre .string, |
||||
pre .tag .value, |
||||
pre .preprocessor, |
||||
pre .built_in, |
||||
pre .sql .aggregate, |
||||
pre .javadoc, |
||||
pre .smalltalk .class, |
||||
pre .smalltalk .localvars, |
||||
pre .smalltalk .array, |
||||
pre .css .rules .value, |
||||
pre .attr_selector, |
||||
pre .pseudo, |
||||
pre .apache .cbracket, |
||||
pre .tex .formula { |
||||
color: #CC9393; |
||||
} |
||||
|
||||
pre .shebang, |
||||
pre .diff .addition, |
||||
pre .comment, |
||||
pre .java .annotation, |
||||
pre .template_comment, |
||||
pre .pi, |
||||
pre .doctype { |
||||
color: #7F9F7F; |
||||
} |
||||
|
||||
pre .coffeescript .javascript, |
||||
pre .javascript .xml, |
||||
pre .tex .formula, |
||||
pre .xml .javascript, |
||||
pre .xml .vbscript, |
||||
pre .xml .css, |
||||
pre .xml .cdata { |
||||
opacity: 0.5; |
||||
} |
@ -0,0 +1,258 @@
|
||||
// Custom reveal.js integration
|
||||
(function(){ |
||||
var isEnabled = true; |
||||
|
||||
document.querySelector( '.reveal' ).addEventListener( 'mousedown', function( event ) { |
||||
var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key'; |
||||
|
||||
if( event[ modifier ] && isEnabled ) { |
||||
event.preventDefault(); |
||||
zoom.to({ element: event.target, pan: false }); |
||||
} |
||||
} ); |
||||
|
||||
Reveal.addEventListener( 'overviewshown', function() { isEnabled = false; } ); |
||||
Reveal.addEventListener( 'overviewhidden', function() { isEnabled = true; } ); |
||||
})(); |
||||
|
||||
/*! |
||||
* zoom.js 0.2 (modified version for use with reveal.js) |
||||
* http://lab.hakim.se/zoom-js
|
||||
* MIT licensed |
||||
* |
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/ |
||||
var zoom = (function(){ |
||||
|
||||
// The current zoom level (scale)
|
||||
var level = 1; |
||||
|
||||
// The current mouse position, used for panning
|
||||
var mouseX = 0, |
||||
mouseY = 0; |
||||
|
||||
// Timeout before pan is activated
|
||||
var panEngageTimeout = -1, |
||||
panUpdateInterval = -1; |
||||
|
||||
var currentOptions = null; |
||||
|
||||
// Check for transform support so that we can fallback otherwise
|
||||
var supportsTransforms = 'WebkitTransform' in document.body.style || |
||||
'MozTransform' in document.body.style || |
||||
'msTransform' in document.body.style || |
||||
'OTransform' in document.body.style || |
||||
'transform' in document.body.style; |
||||
|
||||
if( supportsTransforms ) { |
||||
// The easing that will be applied when we zoom in/out
|
||||
document.body.style.transition = 'transform 0.8s ease'; |
||||
document.body.style.OTransition = '-o-transform 0.8s ease'; |
||||
document.body.style.msTransition = '-ms-transform 0.8s ease'; |
||||
document.body.style.MozTransition = '-moz-transform 0.8s ease'; |
||||
document.body.style.WebkitTransition = '-webkit-transform 0.8s ease'; |
||||
} |
||||
|
||||
// Zoom out if the user hits escape
|
||||
document.addEventListener( 'keyup', function( event ) { |
||||
if( level !== 1 && event.keyCode === 27 ) { |
||||
zoom.out(); |
||||
} |
||||
}, false ); |
||||
|
||||
// Monitor mouse movement for panning
|
||||
document.addEventListener( 'mousemove', function( event ) { |
||||
if( level !== 1 ) { |
||||
mouseX = event.clientX; |
||||
mouseY = event.clientY; |
||||
} |
||||
}, false ); |
||||
|
||||
/** |
||||
* Applies the CSS required to zoom in, prioritizes use of CSS3 |
||||
* transforms but falls back on zoom for IE. |
||||
* |
||||
* @param {Number} pageOffsetX |
||||
* @param {Number} pageOffsetY |
||||
* @param {Number} elementOffsetX |
||||
* @param {Number} elementOffsetY |
||||
* @param {Number} scale |
||||
*/ |
||||
function magnify( pageOffsetX, pageOffsetY, elementOffsetX, elementOffsetY, scale ) { |
||||
|
||||
if( supportsTransforms ) { |
||||
var origin = pageOffsetX +'px '+ pageOffsetY +'px', |
||||
transform = 'translate('+ -elementOffsetX +'px,'+ -elementOffsetY +'px) scale('+ scale +')'; |
||||
|
||||
document.body.style.transformOrigin = origin; |
||||
document.body.style.OTransformOrigin = origin; |
||||
document.body.style.msTransformOrigin = origin; |
||||
document.body.style.MozTransformOrigin = origin; |
||||
document.body.style.WebkitTransformOrigin = origin; |
||||
|
||||
document.body.style.transform = transform; |
||||
document.body.style.OTransform = transform; |
||||
document.body.style.msTransform = transform; |
||||
document.body.style.MozTransform = transform; |
||||
document.body.style.WebkitTransform = transform; |
||||
} |
||||
else { |
||||
// Reset all values
|
||||
if( scale === 1 ) { |
||||
document.body.style.position = ''; |
||||
document.body.style.left = ''; |
||||
document.body.style.top = ''; |
||||
document.body.style.width = ''; |
||||
document.body.style.height = ''; |
||||
document.body.style.zoom = ''; |
||||
} |
||||
// Apply scale
|
||||
else { |
||||
document.body.style.position = 'relative'; |
||||
document.body.style.left = ( - ( pageOffsetX + elementOffsetX ) / scale ) + 'px'; |
||||
document.body.style.top = ( - ( pageOffsetY + elementOffsetY ) / scale ) + 'px'; |
||||
document.body.style.width = ( scale * 100 ) + '%'; |
||||
document.body.style.height = ( scale * 100 ) + '%'; |
||||
document.body.style.zoom = scale; |
||||
} |
||||
} |
||||
|
||||
level = scale; |
||||
|
||||
if( level !== 1 && document.documentElement.classList ) { |
||||
document.documentElement.classList.add( 'zoomed' ); |
||||
} |
||||
else { |
||||
document.documentElement.classList.remove( 'zoomed' ); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Pan the document when the mosue cursor approaches the edges |
||||
* of the window. |
||||
*/ |
||||
function pan() { |
||||
var range = 0.12, |
||||
rangeX = window.innerWidth * range, |
||||
rangeY = window.innerHeight * range, |
||||
scrollOffset = getScrollOffset(); |
||||
|
||||
// Up
|
||||
if( mouseY < rangeY ) { |
||||
window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) ); |
||||
} |
||||
// Down
|
||||
else if( mouseY > window.innerHeight - rangeY ) { |
||||
window.scroll( scrollOffset.x, scrollOffset.y + ( 1 - ( window.innerHeight - mouseY ) / rangeY ) * ( 14 / level ) ); |
||||
} |
||||
|
||||
// Left
|
||||
if( mouseX < rangeX ) { |
||||
window.scroll( scrollOffset.x - ( 1 - ( mouseX / rangeX ) ) * ( 14 / level ), scrollOffset.y ); |
||||
} |
||||
// Right
|
||||
else if( mouseX > window.innerWidth - rangeX ) { |
||||
window.scroll( scrollOffset.x + ( 1 - ( window.innerWidth - mouseX ) / rangeX ) * ( 14 / level ), scrollOffset.y ); |
||||
} |
||||
} |
||||
|
||||
function getScrollOffset() { |
||||
return { |
||||
x: window.scrollX !== undefined ? window.scrollX : window.pageXOffset, |
||||
y: window.scrollY !== undefined ? window.scrollY : window.pageXYffset |
||||
} |
||||
} |
||||
|
||||
return { |
||||
/** |
||||
* Zooms in on either a rectangle or HTML element. |
||||
* |
||||
* @param {Object} options |
||||
* - element: HTML element to zoom in on |
||||
* OR |
||||
* - x/y: coordinates in non-transformed space to zoom in on |
||||
* - width/height: the portion of the screen to zoom in on |
||||
* - scale: can be used instead of width/height to explicitly set scale |
||||
*/ |
||||
to: function( options ) { |
||||
// Due to an implementation limitation we can't zoom in
|
||||
// to another element without zooming out first
|
||||
if( level !== 1 ) { |
||||
zoom.out(); |
||||
} |
||||
else { |
||||
options.x = options.x || 0; |
||||
options.y = options.y || 0; |
||||
|
||||
// If an element is set, that takes precedence
|
||||
if( !!options.element ) { |
||||
// Space around the zoomed in element to leave on screen
|
||||
var padding = 20; |
||||
|
||||
options.width = options.element.getBoundingClientRect().width + ( padding * 2 ); |
||||
options.height = options.element.getBoundingClientRect().height + ( padding * 2 ); |
||||
options.x = options.element.getBoundingClientRect().left - padding; |
||||
options.y = options.element.getBoundingClientRect().top - padding; |
||||
} |
||||
|
||||
// If width/height values are set, calculate scale from those values
|
||||
if( options.width !== undefined && options.height !== undefined ) { |
||||
options.scale = Math.max( Math.min( window.innerWidth / options.width, window.innerHeight / options.height ), 1 ); |
||||
} |
||||
|
||||
if( options.scale > 1 ) { |
||||
options.x *= options.scale; |
||||
options.y *= options.scale; |
||||
|
||||
var scrollOffset = getScrollOffset(); |
||||
|
||||
if( options.element ) { |
||||
scrollOffset.x -= ( window.innerWidth - ( options.width * options.scale ) ) / 2; |
||||
} |
||||
|
||||
magnify( scrollOffset.x, scrollOffset.y, options.x, options.y, options.scale ); |
||||
|
||||
if( options.pan !== false ) { |
||||
|
||||
// Wait with engaging panning as it may conflict with the
|
||||
// zoom transition
|
||||
panEngageTimeout = setTimeout( function() { |
||||
panUpdateInterval = setInterval( pan, 1000 / 60 ); |
||||
}, 800 ); |
||||
|
||||
} |
||||
} |
||||
|
||||
currentOptions = options; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Resets the document zoom state to its default. |
||||
*/ |
||||
out: function() { |
||||
clearTimeout( panEngageTimeout ); |
||||
clearInterval( panUpdateInterval ); |
||||
|
||||
var scrollOffset = getScrollOffset(); |
||||
|
||||
if( currentOptions && currentOptions.element ) { |
||||
scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2; |
||||
} |
||||
|
||||
magnify( scrollOffset.x, scrollOffset.y, 0, 0, 1 ); |
||||
|
||||
level = 1; |
||||
}, |
||||
|
||||
// Alias
|
||||
magnify: function( options ) { this.to( options ) }, |
||||
reset: function() { this.out() }, |
||||
|
||||
zoomLevel: function() { |
||||
return level; |
||||
} |
||||
} |
||||
|
||||
})(); |
||||
|
Loading…
Reference in new issue