Skip to content

Instantly share code, notes, and snippets.

View apipkin's full-sized avatar
🤖
^_^

Anthony Pipkin apipkin

🤖
^_^
View GitHub Profile

Paginator

Objective

Provide a module with core paginator methods (next, prev, first, last, page) as well as the ability to calculate the total number of pages given the total number of items and the items to display per page.

Provide a module with the ability to interchange views to fit the UI needs of the paginator instance.

<!DOCTYPE html>
<html>
<head>
<title>Winter 2013 - Wk2</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../reset.css">
<style>
.accView {
position: relative;
<!DOCTYPE html>
<html>
<head>
<title>Winter 2013 - Wk2</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../reset.css">
<style>
.tabView {
position: relative;
}
@apipkin
apipkin / _getOffsetAndFinish.js
Created November 6, 2012 23:37 — forked from mattparker/_getOffsetAndFinish.js
idea for kb refactor of Y.Color.Harmony
/**
Generates a series of colors from startColor at various offsets
@protected
@method _getOffsetAndFinish
@param {String} startColor Start color
@param {Array} arrOffsets Array of colors
@param {String} [to]
@returns {Array} Of offsetted and finished colors
**/
_getOffsetAndFinish: function (startColor, arrOffsets, to) {
yui@yuivm:/data/web/api$ ./server.js
watch module is not installed, run `npm i` inside the api directory to update it for development
spawning worker
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
_onItemClick: function(e) {
var menuNode = e.currentTarget,
menuItem = this.get('menuItems')[menuNode.getData('item-name')],
attachedNode = this.get('node');
menuItem.action(e, menuNode, attachedNode, menuNode);
}
Y.MyWidget = Y.Base.create(NAME, Y.Widget, [], {
initializer: function() {
this._node = null;
},
activate: function(ct) {
// ...
this._node = ct;
// ...
},
YUI.add(NAME, function(Y){
Y.MyWidget = Y.Base.create(NAME, Y.Widget, [], {
initializer: function() {
// set up anything initially that's not handled with the config
},
destructor: function() {
// tear down any thing that needs it

Callbacks

Callbacks are functions that are called within another function. Because functions in javascript can be passed around through variables, this makes it pretty painless.

Setting it up

function myFn(callbackFn) {
    if (callbackFn) {
        (callbackFn());
 }
Y.Base.create('name', Y.ExtendedClass, [Y.Mixins], { prototype }, { statics });