This file contains hidden or 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
| // Example: | |
| JavaScript.load("/javascripts/something.js"); | |
| // With callback (that’s the good thing): | |
| JavaScript.load("http://www.someawesomedomain.com/api.js", function() { | |
| API.use(); // or whatever api.js provides ... | |
| }); |
This file contains hidden or 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
| # usage: app.use "/[collectionName]", require("./routes/[collectionName]") | |
| express = require('express') | |
| class ModelRestfulRouter | |
| findOne:(req,res)-> | |
| @model.findById req.params.id,(err,data)-> | |
| unless err then res.json(data) | |
| find:(req,res)-> | |
| query = req?.query or {} |
This file contains hidden or 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
| class BaseView | |
| constructor:(options)-> | |
| @options = options | |
| @el = options.el | |
| @$el = $(@el) | |
| @initialize?(options) |
This file contains hidden or 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
| if typeof define == 'function' && define.amd then define(["jquery"],factory) | |
| else factory(jQuery) | |
| factory = ($)-> | |
| ## Do Something |
This file contains hidden or 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
| View = do -> | |
| extend = (obj,objs...)-> | |
| while o = objs.shift() | |
| obj[k] = o[k] for k of o | |
| return obj | |
| class BaseView | |
| constructor:(o={})-> | |
| @el = o.el | |
| @$el = $(o.el) | |
| @initialize?() |
This file contains hidden or 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
| <IfModule mod_rewrite.c> | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^(.*)$ index.html?/$1 [L] | |
| </IfModule> | |
| <IfModule !mod_rewrite.c> | |
| ErrorDocument 404 /index.php | |
| </IfModule> |
This file contains hidden or 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
| ### | |
| Gruntfile example for requirejs optimizing and less files watching | |
| ### | |
| module.exports = (grunt) -> | |
| out = (path)-> "../public-dist/#{path}" | |
| grunt.initConfig | |
| requirejs: | |
| options: | |
| mainConfigFile: "../public/require-config.js" | |
| baseUrl: "../public" |
This file contains hidden or 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
| timer = do -> | |
| start = (new Date).getTime() | |
| (log...)-> | |
| time = ((new Date).getTime()-start)/1000 | |
| console.warn "timer: ",time, log... |
This file contains hidden or 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
| // based on requirejs and backbone style views currently | |
| $.fn.directive = (method,options)-> | |
| $dom = $(this) | |
| if not method #init | |
| viewName = $dom.attr("directive") | |
| if viewName then require ["directive/#{viewName}"], (View)-> | |
| view = new View(el:$dom[0]) | |
| isRender = $dom.attr("render") | |
| if isRender=="" or isRender | |
| view.render() |
OlderNewer