Skip to content

Instantly share code, notes, and snippets.

@iTonyYo
Last active August 29, 2015 13:57
Show Gist options
  • Save iTonyYo/9908093 to your computer and use it in GitHub Desktop.
Save iTonyYo/9908093 to your computer and use it in GitHub Desktop.
Scripts have to be inserted into ' <head/> '. Tags with jade template engine. Jade ' include ' allows you to insert the contents into another jade file simply.
//
Build Passing.
Doctype: HTML5
Jade: 1.3.0+
#TODO[x]: Public Script ( Miscellaneous Function ), Define
Have to be inserted into ' head ' tag
#TODO[x]: Librarys
HTML5 Shiv ( //github.com/aFarkas/html5shiv )
This script is the defacto way to enable use of HTML5
sectioning elements in legacy Internet Explorer.
Modernizr (//modernizr.com/)
A JavaScript library that detects HTML5 and CSS3 features
in the user’s browser.
WOW (//mynameismatthieu.com/WOW/)
Reveal Animations When You Scroll. Very Animate.css
Friend :-). Easily customize animation settings:
style, delay, length, offset, iterations...
maybe more ...
#TODO[x]: Librarys Setup Example
-var pubScriptPathInBowerComponents = {
html5shivUrl: dirLocal.bowerComponents + 'html5shiv/html5shiv.min.js',
modernizrUrl: dirLocal.bowerComponents + 'modernizr/modernizr.js',
wowUrl: dirLocal.bowerComponents + 'WOW/wow.min.js'
}
-var pubScriptLocalUrl = {
html5shivUrl: dirLocal._public + 'ajax/libs/js/html5shiv/3.7.2/html5shiv.min.js',
modernizrUrl: dirLocal._public + 'ajax/libs/js/modernizr/2.7.0/modernizr.min.js',
wowUrl: dirLocal._public + 'ajax/libs/js/wow/0.1.12/wow.min.js'
}
-var pubScriptOnlineUrl = {
html5shivUrl: selectedCDN + 'ajax/libs/js/html5shiv/3.7.2/html5shiv.min.js',
modernizrUrl: selectedCDN + 'ajax/libs/js/modernizr/2.7.0/modernizr.min.js',
wowUrl: selectedCDN + 'ajax/libs/js/wow/0.1.12/wow.min.js'
}
- var _default = {
html5shiv: {
active: true,
script: true,
condition: [true, 'if (gte IE 6)&(lte IE 9)]', '[endif'],
_defer: 'false',
url:
},
modernizr: {
active: true,
script: false,
condition: [false, '', ''],
_defer: 'true',
url:
},
wow: {
active: true,
script: false,
condition: [false, '', ''],
_defer: 'true',
url:
}
}
#TODO[x]: Dependencies
initialization.jade (//gist.github.com/Tony-Stark/9d7359ff69ef8336b151)
Author: 沈维忠 ( Shen Weizhong / Tony Stark )
Trello: //trello.com/shenweizhong/
Cell Phone: (+86) 15921299022
Gravatar: //en.gravatar.com/swzcowboy/
Twitter: @iTonyYo, //twitter.com/iTonyYo/
Google+: //plus.google.com/114960355664861539339/
Facebook: //www.facebook.com/shenweizhong/
Instagram: //instagram.com/itonyyo/
QQ: 563214029, //user.qzone.qq.com/563214029/
Sina Weibo: //weibo.com/itonyyo/
Email: [email protected], [email protected], [email protected], [email protected], [email protected]
Version: 0.1.9-alpha
Creation Date: ~ ( Tony ).
Last Update: 2014.07.03 17:06 ( Tony ).
-var pubScriptPathInBowerComponents = {html5shivUrl: dirLocal.bowerComponents + 'html5shiv/html5shiv.min.js', modernizrUrl: dirLocal.bowerComponents + 'modernizr/modernizr.js', wowUrl: dirLocal.bowerComponents + 'WOW/wow.min.js'}
-var pubScriptLocalUrl = {html5shivUrl: dirLocal._public + 'ajax/libs/js/html5shiv/3.7.2/html5shiv.min.js', modernizrUrl: dirLocal._public + 'ajax/libs/js/modernizr/2.7.0/modernizr.min.js', wowUrl: dirLocal._public + 'ajax/libs/js/wow/0.1.12/wow.min.js'}
-var pubScriptOnlineUrl = {html5shivUrl: selectedCDN + 'ajax/libs/js/html5shiv/3.7.2/html5shiv.min.js', modernizrUrl: selectedCDN + 'ajax/libs/js/modernizr/2.7.0/modernizr.min.js', wowUrl: selectedCDN + 'ajax/libs/js/wow/0.1.12/wow.min.js'}
mixin judgement (index, val)
- var bool = val.condition[0]
- var sCondition = val.condition[1]
- var eCondition = val.condition[2]
- var script = val.script
- var url = val.url
if !bool
if script
block
script(src=url)
else
script(src=url)
else
if script
+ie (sCondition, eCondition)
block
script(src=url)
else
+ie (sCondition, eCondition)
script(src=url)
// Default Iteration
mixin pubScriptIteration (opts)
- each val, index in opts
if val.active
+judgement (index, val)
case index
when 'html5shiv'
script.
window.html5 = {'shivCSS': false};
mixin setPubScript (bower)
if staticResourceOrigin === 'local'
if bower
- var _default = {html5shiv: {active: true, script: true, condition: [true, 'if (gte IE 6)&(lte IE 9)]', '[endif'], _defer: 'false', url: pubScriptPathInBowerComponents.html5shivUrl}, modernizr: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptPathInBowerComponents.modernizrUrl}, wow: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptPathInBowerComponents.wowUrl}}
+pubScriptIteration(_default)
else
- var _default = {html5shiv: {active: true, script: true, condition: [true, 'if (gte IE 6)&(lte IE 9)]', '[endif'], _defer: 'false', url: pubScriptLocalUrl.html5shivUrl}, modernizr: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptLocalUrl.modernizrUrl}, wow: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptLocalUrl.wowUrl}}
+pubScriptIteration(_default)
else
- var _default = {html5shiv: {active: true, script: true, condition: [true, 'if (gte IE 6)&(lte IE 9)]', '[endif'], _defer: 'false', url: pubScriptOnlineUrl.html5shivUrl}, modernizr: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptOnlineUrl.modernizrUrl}, wow: {active: true, script: false, condition: [false, '', ''], _defer: 'true', url: pubScriptOnlineUrl.wowUrl}}
+pubScriptIteration(_default)
+setPubScript(true)
script
:coffeescript
isIE = ->
agent = navigator.userAgent.toLowerCase()
!!agent.match(/msie/i)
isGteIE9 = ->
agent = navigator.userAgent.toLowerCase()
match = agent.match(/msie\D*([\.\d]*)/i)
version = 0
if match and match[1]
version = match[1]
version >= 9
init = ->
if isIE()
if isGteIE9()
new WOW().init()
else
new WOW().init()
return
init()
// Custom modules, here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment