// jQuery
$(document).ready(function() {
// code
})
var smoothScroll = function(id) { | |
var target = $(id).offset().top - 60; | |
$('html, body').animate({scrollTop:target}, 500); | |
}; | |
/* | |
* Use | |
*/ | |
$('a#link').on('click', function(e) { |
<div class="row"> | |
<div class="col-1-3"> | |
<img src="something.jpg"> | |
</div> | |
<div class="col-1-3"> | |
<img src="something.jpg"> | |
</div> | |
<div class="col-1-3"> | |
<img src="something.jpg"> | |
</div> |
Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.
Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.
At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
### INSTALLATION NOTES ### | |
# 1. Install Homebrew (https://github.com/mxcl/homebrew) | |
# 2. brew install zsh | |
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh) | |
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace | |
# 5. Install iTerm2 | |
# 6. In iTerm2 preferences for your profile set: | |
# Character Encoding: Unicode (UTF-8) | |
# Report Terminal Type: xterm-256color | |
# 7. Put itunesartist and itunestrack into PATH |
set nocompatible | |
" set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< | |
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< | |
nmap <leader>l :set list!<CR> | |
" set listchars=tab:▸\ ,eol:¬ | |
" pathogen | |
call pathogen#infect() | |
call pathogen#helptags() |
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs | |
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6 | |
window.$ = function(s) { | |
var c = { | |
'#': 'ById', | |
'.': 'sByClassName', | |
'@': 'sByName', | |
'=': 'sByTagName'}[s[0]]; | |
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1)) | |
}; |
mkdir heroku | |
cd heroku/ | |
virtualenv --no-site-packages env | |
source env/bin/activate | |
pip install bottle gevent | |
pip freeze > requirements.txt | |
cat >app.py <<EOF | |
import bottle | |
import os |
#!/usr/bin/env python | |
# bottle.py boilerplate project | |
from bottle import route, run, template, static_file, request, response | |
from bs4 import BeautifulSoup | |
import requests, simplejson as json, webbrowser, os, lxml, re | |
# the decorator | |
def enable_cors(fn): | |
def _enable_cors(*args, **kwargs): |