Last active
December 19, 2015 05:49
-
-
Save bodokaiser/5907059 to your computer and use it in GitHub Desktop.
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
(function() { | |
var router = new Router().map(function() { | |
this.route('index', '/', indexRoute); | |
this.route('outputs', '/outputs', outputsRoute); | |
this.route('outputs:list', '/outputs/list', outputsListRoute); | |
this.route('outputs:create', '/outputs/create', outputsCreateRoute); | |
}); | |
var outputs = new Repository('outputs'); | |
function indexRoute() { | |
var body = document.body; | |
var rootTpl = document.querySelector('script#root'); | |
while (body.hasChildNodes()) | |
body.removeChildNode(); | |
body.innerHTML = swig.compile(rootTpl.innerHTML); | |
} | |
function outputsRoute() { | |
// extend root layout | |
} | |
function outputsListRoute() { | |
outputs.find(function(err, outputs) { | |
var ctrl = new OutputsListController({ model: outputs }); | |
}); | |
} | |
function outputsCreateRoute() { | |
} | |
function OutputsListController() { | |
} | |
OutputsListController.prototype.checkInput = function() {}; | |
router.start(); | |
}).call(this); |
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
var users = new Repository('users', { | |
resource: '/users' | |
}); | |
users.find(function(err, models) { | |
}); | |
users.findOne('4874203', function(err, user) { | |
}); | |
users.findQuery({ search: 'babo' }, function(err, user) { | |
}); | |
users.persist({ username: 'bodo', password: '1234' }, function(err, user) { | |
}); | |
users.remove('4784232', function(err) { | |
}); |
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
var router = new Router(); | |
router.map(function() { | |
this.route('help', '/help*', helpRoute); | |
this.route('user', '/user', userRoute); | |
}); | |
function helpRoute() { | |
// setup some bindings | |
} | |
function userRoute() { | |
// setup some other stuff | |
} | |
router.route('index', '/*', function(fragment) { | |
}); | |
router.route('outputs', '/outputs', function() { | |
}); | |
router.navigate('outputs'); | |
router.navigateBack(); | |
router.navigateForward(); |
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
var linkView = View.create({ tagName: 'a', attributes: { href: '#/blabl' } }); | |
linkView.updateHrefPostfix = function(postfix) { | |
this.element.href = this.attributes.href; | |
this.element.href += postfix; | |
}; | |
var FormView = View.extend({ | |
idName: 'my-form' | |
tagName: 'form', | |
classNames: ['form', 'form-horizontal'], | |
attribures: { data-id: 22 }, | |
template: swig.compile('form'), | |
events: { | |
'submit': function() { | |
}, | |
'focus input': function() { | |
} | |
} | |
}); | |
var formView = new FormView({ model: { name: 'hallie'} , context: aController }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment