Commit 49f3124b authored by Terion's avatar Terion
Browse files

first comit

parents
class ExampleController
constructor: (@container)->
@init()
@bind()
init: ->
bind: ->
\ No newline at end of file
fit = (fromW, fromH, toW, toH, round)->
targetW = 0
targetH = 0
ratio1 = fromW / fromH
ratio2 = toW / toH
leading = if ratio1 > ratio2 then 'w' else 'h'
if leading == 'w'
targetW = toW
targetH = targetW / ratio1
else
targetH = toH
targetW = targetH * ratio1
return [Math.round(targetW), Math.round(targetH)] if round
return [targetW, targetH]
fill = (fromW, fromH, toW, toH, round)->
targetW = 0
targetH = 0
marginLeft = 0
marginTop = 0
ratio1 = fromW / fromH
ratio2 = toW / toH
leading = if ratio1 < ratio2 then 'w' else 'h'
if leading == 'w'
targetW = toW
targetH = targetW / ratio1
marginTop = (toH - targetH) / 2
else
targetH = toH
targetW = targetH * ratio1
marginLeft = (toW - targetW) / 2
return [Math.round(targetW), Math.round(targetH), Math.round(marginLeft), Math.round(marginTop)] if round
return [targetW, targetH, marginLeft, marginTop]
addClass = (o, c) ->
re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g')
if re.test(o.className)
return
o.className = (o.className + ' ' + c).replace(/\s+/g, ' ').replace(/(^ | $)/g, '')
return
removeClass = (o, c) ->
re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g')
o.className = o.className.replace(re, '$1').replace(/\s+/g, ' ').replace(/(^ | $)/g, '')
return
hasClass = (o, c) ->
re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g')
return re.test(o.className)
nodeListToArray = (nodeList)->
arr = []
# seems this is faster then Array.prototype.slice
for node in nodeList
arr.push node
return arr
### inspired by https://gist.github.com/1129031 ###
###global document, DOMParser###
do (DOMParser) ->
'use strict'
proto = DOMParser.prototype
nativeParse = proto.parseFromString
# Firefox/Opera/IE throw errors on unsupported types
try
# WebKit returns null on unsupported types
if (new DOMParser).parseFromString('', 'text/html')
# text/html parsing is natively supported
return
catch ex
proto.parseFromString = (markup, type) ->
if /^\s*text\/html\s*(?:;|$)/i.test(type)
doc = document.implementation.createHTMLDocument('')
if markup.toLowerCase().indexOf('<!doctype') > -1
doc.documentElement.innerHTML = markup
else
doc.body.innerHTML = markup
doc
else
nativeParse.apply this, arguments
return
trim = (str, charlist) ->
# Strip whitespace (or other characters) from the beginning and end of a string
#
# + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
# + improved by: mdsjack (http://www.mdsjack.bo.it)
# + improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
# + input by: Erkekjetter
# + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
charlist = if !charlist then ' s ' else charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1')
re = new RegExp('^[' + charlist + ']+|[' + charlist + ']+$', 'g')
str.replace re, ''
getQueryParams = (queryString)->
assoc = {}
decode = (s) -> decodeURIComponent s.replace(/\+/g, ' ')
queryString = location.search.substring(1) unless queryString
keyValues = queryString.split('&')
for i of keyValues
key = keyValues[i].split('=')
if key.length > 1
assoc[decode(key[0])] = decode(key[1])
assoc
transitionEndEventName = ->
el = document.createElement('div')
transitions =
'transition': 'transitionend'
'OTransition': 'otransitionend'
'MozTransition': 'transitionend'
'WebkitTransition': 'webkitTransitionEnd'
for i of transitions
if transitions.hasOwnProperty(i) and el.style[i] != undefined
return transitions[i]
#TODO: throw 'TransitionEnd event is not supported in this browser';
return
once = (node, type, callback)->
# create event
node.addEventListener type, (e) ->
# remove event
e.target.removeEventListener e.type, arguments.callee
# call handler
callback e
return
getLocation = (href) ->
match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/)
match and
protocol: match[1]
host: match[2]
hostname: match[3]
port: match[4]
pathname: match[5]
search: match[6]
hash: match[7]
\ No newline at end of file
#= require_tree _classes
# do stuff here
\ No newline at end of file
include ../mixins/menu.jade
include ../mixins/likes.jade
include ../mixins/ga.jade
include ../mixins/facebook_init.jade
include ../mixins/vk_init.jade
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
meta( name="viewport", content="width=device-width")
block title
title Site title
link(rel="stylesheet", href="/fonts/stylesheet.css")
link(rel="stylesheet", href="/css/styles.css")
link(rel="icon", type="image/png", href="/img/favicon.png")
//- vendor scripts
script(src="/vendor/promise-ajax-js/promise.min.js")
//- script(src="/vendor/velocity/velocity.min.js")
block socials
meta(property="og:url", content="http://#{site_domain}")
meta(property="og:title", content="Site title")
meta(property="og:description", content="")
meta(property="og:image", content="http://#{site_domain}/img/fb_share.png")
meta(property="og:type", content="website")
meta(property="og:site_name", content="Site title")
//- meta(property="og:locale", content="en_US")
meta(property="fb:app_id", content="")
+vk_init('')
+ga('')
body
<!--[if lte IE 9]>
style.
body { overflow: hidden }
.oldie#oldie
.txt Your browser is too old, outdated and insecure.<br>Please update
<![endif]-->
+facebook_init('')
#header
img.logo(src='/img/logo.svg', alt='', title='')
block menu
+menu('home')
#container
block content
script(src="/js/scripts.js")
\ No newline at end of file
mixin facebook_init(appId)
#fb-root
script.
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4&appId=#{appId}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
mixin ga(id)
script.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q || []).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', "#{id}", 'auto');
ga('send', 'pageview');
\ No newline at end of file
mixin likes(url, inverted)
.likes-widget(class=(inverted ? 'inverted' : ''))
.fb
.holder like
.container
.fb-like(data-href="#{url}", data-width='100', data-layout='button_count', data-action='like', data-show-faces='false', data-share='false')
.vk
.holder like
.container
.vk-like
script(type='text/javascript').
(function () {
var i, j, len, like, liker, likers, randomId, results, results1;
likers = document.getElementsByClassName('vk-like');
if (typeof VK !== "undefined" && VK !== null) {
i = 0;
results = [];
while (i < likers.length) {
liker = likers[i];
if (!liker.getAttribute('id')) {
randomId = 'vk_like_' + Math.ceil(Math.random() * Math.random() * 10000);
liker.setAttribute('id', randomId);
VK.Widgets.Like(randomId, {
height: 20,
type: "mini",
locale: 'en_US',
pageUrl: "#{url}"
});
}
results.push(i++);
}
return results;
} else {
results1 = [];
for (j = 0, len = likers.length; j < len; j++) {
like = likers[j];
results1.push(like.style.display = 'none');
}
return results1;
}
})();
.tw
.holder tweet
.container
a.twitter-share-button(href="#{url}", data-text='', data-via='terion_fallen') Tweet
script.
!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + '://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'twitter-wjs');
mixin menu(active)
nav.menu
ul
li(class=(active == 'home' ? 'active' : '')): a(data-screen='0', href='/') Home
\ No newline at end of file
mixin vk_init(appId)
script(type='text/javascript', src='//vk.com/js/api/openapi.js?116')
script(type='text/javascript').
VK.init({apiId: "#{appId}", onlyWidgets: true});
extends ../layouts/main
block content
h1 Hello
\ No newline at end of file
=middler
&:before
content: ''
vertical-align: middle
height: 100%
display: inline-block
width: 0
margin-left: -0.25ex
\ No newline at end of file
@import "compass"
@import "normalize"
@import "bootstrap-sprockets"
//@import "bootstrap"
@import "_partials/mixins"
body
margin-top: 0
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment