Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #620 from lzhan/fixlinterr
Browse files Browse the repository at this point in the history
fix issue #546 multiple jslint errors in developer-guide
  • Loading branch information
lzhan committed Oct 11, 2012
2 parents 84931e8 + b548384 commit fb635e5
Show file tree
Hide file tree
Showing 87 changed files with 1,428 additions and 1,254 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
YUI.add('addons-viewengine-ejs', function(Y, NAME) {
/*jslint anon:true, sloppy:true, nomen:true, stupid:true*/

var ejs = require('ejs'),
fs = require('fs');
function EjsAdapter(viewId) {
this.viewId = viewId;
}
EjsAdapter.prototype = {
YUI.add('addons-viewengine-ejs', function (Y, NAME) {

render: function(data, mojitType, tmpl, adapter, meta, more) {
var me = this,
handleRender = function(output) {
var ejs = require('ejs'),
fs = require('fs');
function EjsAdapter(viewId) {
this.viewId = viewId;
}
EjsAdapter.prototype = {

output.addListener('data', function(c) {
adapter.flush(c, meta);
});
output.addListener('end', function() {
if (!more) {
adapter.done('', meta);
}
});
};
Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME);
var result = ejs.render(this.compiler(tmpl),data);
console.log(result);
adapter.done(result,meta);
},
compiler: function(tmpl) {
return fs.readFileSync(tmpl, 'utf8');
}
};
Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter;
render: function (data, mojitType, tmpl, adapter, meta, more) {
var me = this,
handleRender = function (output) {
output.addListener('data', function (c) {
adapter.flush(c, meta);
});
output.addListener('end', function () {
if (!more) {
adapter.done('', meta);
}
});
},
result = ejs.render(this.compiler(tmpl), data);
Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME);
console.log(result);
adapter.done(result, meta);
},
compiler: function (tmpl) {
return fs.readFileSync(tmpl, 'utf8');
}
};
Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter;
}, '0.1.0', {requires: []});
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
YUI.add('myMojit', function(Y, NAME) {
/*jslint anon:true, sloppy:true, nomen:true*/

Y.mojito.controllers[NAME] = {
YUI.add('myMojit', function (Y, NAME) {

init: function(config) {
this.config = config;
},
default_ve: function(ac) {
ac.done({
"title": "Handlebars at work!",
"view_engines": [
{"name": "EJS"},
{"name": "Jade"},
{"name": "dust"},
{"name": "underscore" }
],
"ul": { "title": 'Here are some of the other available rendering engines:' },
});
},
added_ve: function(ac) {
ac.done({
"title": "EJS at work!",
"view_engines": [ "Jade", "Dust","underscore" ],
"ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' }
});
}
};
Y.mojito.controllers[NAME] = {

init: function (config) {
this.config = config;
},
default_ve: function (ac) {
ac.done({
"title": "Handlebars at work!",
"view_engines": [
{"name": "EJS"},
{"name": "Jade"},
{"name": "dust"},
{"name": "underscore" }
],
"ul": { "title": 'Here are some of the other available rendering engines:' }
});
},
added_ve: function (ac) {
ac.done({
"title": "EJS at work!",
"view_engines": [ "Jade", "Dust", "underscore" ],
"ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' }
});
}
};
}, '0.0.1', {requires: ['mojito', 'myMojitModelFoo']});
4 changes: 3 additions & 1 deletion examples/developer-guide/binding_events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
* See the accompanying LICENSE file for terms.
*/

/*jslint anon:true, sloppy:true, nomen:true*/

process.chdir(__dirname);

/**
* @param {object} config The configuration object containing processing params.
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
module.exports = function (config, token) {
var app = require('./server.js');

// Signal the application is ready, providing the token and app references.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,100 @@
* See the accompanying LICENSE file for terms.
*/

/*jslint anon:true, sloppy:true, nomen:true*/

YUI.add('PagerMojitBinder', function (Y, NAME) {
var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';
var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';
function parseImageId(link) {
var matches = link.match(/com\/(\d+)\/(\d+)_([0-9a-z]+)\.jpg$/);
return matches[2];
}
function parsePage(link) {
var matches = link.match(/page=(\d+)/);
return matches[1];
}

/**
* The PagerMojitBinder module.
* @module PagerMojitBinder
*/
/**
* The PagerMojitBinder module.
* @module PagerMojitBinder
*/

/**
* Constructor for the Binder class.
*
* @param mojitProxy {Object} The proxy to allow
* the binder to interact with its owning mojit.
* @class Binder
* @constructor
*/
Y.namespace('mojito.binders')[NAME] = {
/**
* Constructor for the Binder class.
*
* @param mojitProxy {Object} The proxy to allow
* the binder to interact with its owning mojit.
* @class Binder
* @constructor
*/
Y.namespace('mojito.binders')[NAME] = {
/**
* Binder initialization method, invoked
* after all binders on the page have
* been constructed.
*/
init: function(mojitProxy) {
this.mojitProxy = mojitProxy;
},
*/
init: function(mojitProxy) {
this.mojitProxy = mojitProxy;
},
/**
* The binder method, invoked to allow the mojit
* to attach DOM event handlers.
* @param node {Node} The DOM node to which this
* mojit is attached.
*/
bind: function(node) {
var thatNode = node;
// define the action when user click on prev/next
var flipper = function(event) {
var target = event.target;
// get the link to the page
var page = parsePage(target.get('href'));
var updateDOM = function(markup) {
thatNode.set('innerHTML', markup);
thatNode.all('#nav a').on('click', flipper, this);
thatNode.all('#master ul li a').on('mouseover', showOverlay, this);
thatNode.all('#master ul li a').on('mouseout', showOverlay, this);
};
this.mojitProxy.invoke('index',
{
params: {page: page}
}, updateDOM
);
};
var showOverlay = function(event) {
var target = event.target;
var href = target.get('href');
var imageId = parseImageId(href);
if (target.hasClass('overlayed')) {
target.removeClass('overlayed');
thatNode.one('#display').setContent('');
} else {
target.addClass('overlayed');
// Query for the image metadata
var query = 'select * from flickr.photos.info where photo_id="' + imageId + '" and api_key="' + API_KEY + '"';
thatNode.one('#display').setContent('Loading ...');
Y.YQL(query, function(raw) {
if (!raw.query.results.photo) {
Y.log('No results found for photoId: ' + imageId);
return;
}
var props = raw.query.results.photo;
var snippet = '<ul style="list-style-type: square;">';
for (var key in props) {
if (typeof(props[key]) == 'object') {
continue;
}
snippet += '<li>' + key + ': ' + props[key] + '</li>';
}
snippet += '</ul>';
thatNode.one('#display').setContent(snippet); });
bind: function(node) {
var thatNode = node,
showOverlay = function(event) {
var target = event.target,
href = target.get('href'),
imageId = parseImageId(href),
// Query for the image metadata
query = 'select * from flickr.photos.info where photo_id="' + imageId + '" and api_key="' + API_KEY + '"';
if (target.hasClass('overlayed')) {
target.removeClass('overlayed');
thatNode.one('#display').setContent('');
} else {
target.addClass('overlayed');
thatNode.one('#display').setContent('Loading ...');
Y.YQL(query, function(raw) {
if (!raw.query.results.photo) {
Y.log('No results found for photoId: ' + imageId);
return;
}
var props = raw.query.results.photo,
snippet = '<ul style="list-style-type: square;">',
key;
for (key in props) {
if (props.hasOwnProperty(key)) {
if (typeof (props[key]) === 'object') {
continue;
}
snippet += '<li>' + key + ': ' + props[key] + '</li>';
}
}
snippet += '</ul>';
thatNode.one('#display').setContent(snippet);
});
}
},
// define the action when user click on prev/next
flipper = function(event) {
var target = event.target,
// get the link to the page
page = parsePage(target.get('href')),
updateDOM = function(markup) {
thatNode.set('innerHTML', markup);
thatNode.all('#nav a').on('click', flipper, this);
thatNode.all('#master ul li a').on('mouseover', showOverlay, this);
thatNode.all('#master ul li a').on('mouseout', showOverlay, this);
};
this.mojitProxy.invoke('index', { params: {page: page} }, updateDOM);
};
// Bind all the image links to showOverlay
thatNode.all('#master ul li a').on('mouseover', showOverlay, this);
thatNode.all('#master ul li a').on('mouseout', showOverlay, this);
// Bind the prev + next links to flipper
thatNode.all('#nav a').on('click', flipper, this);
}
};
// Bind all the image links to showOverlay
thatNode.all('#master ul li a').on('mouseover', showOverlay, this);
thatNode.all('#master ul li a').on('mouseout', showOverlay, this);
// Bind the prev + next links to flipper
thatNode.all('#nav a').on('click', flipper, this);
}
};
function parseImageId(link) {
var matches = link.match(/com\/(\d+)\/(\d+)_([0-9a-z]+)\.jpg$/);
return matches[2];
}
function parsePage(link) {
var matches = link.match(/page=(\d+)/);
return matches[1];
}
}, '0.0.1', {requires: ['yql', 'io', 'dump','mojito-client']});
};
}, '0.0.1', {requires: ['yql', 'io', 'dump', 'mojito-client']});
Loading

0 comments on commit fb635e5

Please sign in to comment.