From b54838463e9aa2c70932ae4f84c184c225b3031d Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Thu, 11 Oct 2012 14:14:00 -0700 Subject: [PATCH] fix issue #546 multiple jslint errors in developer-guide --- .../addons/view-engines/ejs.server.js | 59 +-- .../mojits/myMojit/controller.server.js | 52 +- .../developer-guide/binding_events/index.js | 4 +- .../mojits/PagerMojit/binders/index.js | 164 +++--- .../mojits/PagerMojit/controller.server.js | 134 ++--- .../mojits/PagerMojit/models/model.server.js | 94 ++-- .../mojits/RoutingMojit/binders/index.js | 7 +- .../mojits/RoutingMojit/controller.server.js | 82 +-- .../RoutingMojit/models/model.server.js | 10 +- .../mojits/device/controller.server.js | 62 +-- .../mojits/device/binders/index.js | 8 +- .../mojits/device/controller.server.js | 32 +- .../mojits/device/models/model.server.js | 10 +- .../mojits/framed/binders/index.js | 8 +- .../mojits/framed/controller.server.js | 40 +- .../mojits/framed/models/model.server.js | 10 +- .../mojits/MainMojit/binders/binder.js | 6 +- .../mojits/MainMojit/controller.server.js | 40 +- .../mojits/MainMojit/models/model.server.js | 8 +- .../mojits/GenURLMojit/binders/index.js | 8 +- .../mojits/GenURLMojit/controller.server.js | 28 +- .../mojits/GenURLMojit/models/model.server.js | 8 +- .../mojits/OhHai/controller.server.js | 6 +- .../hello/mojits/HelloMojit/binders/index.js | 8 +- .../mojits/HelloMojit/controller.server.js | 8 +- .../mojits/HelloMojit/models/model.server.js | 10 +- .../mojits/framed/binders/index.js | 8 +- .../mojits/framed/controller.server.js | 20 +- .../mojits/framed/models/model.server.js | 8 +- examples/developer-guide/inter-mojit/index.js | 8 +- .../mojits/MasterMojit/binders/index.js | 16 +- .../mojits/MasterMojit/controller.server.js | 8 +- .../mojits/ReceiverMojit/binders/index.js | 10 +- .../mojits/ReceiverMojit/controller.server.js | 8 +- .../mojits/SenderMojit/binders/index.js | 10 +- .../mojits/SenderMojit/controller.server.js | 6 +- .../locale_i18n/mojits/i18n/binders/index.js | 6 +- .../mojits/i18n/controller.server.js | 28 +- .../mojits/i18n/lang/i18n_en-AU.js | 20 +- .../mojits/i18n/lang/i18n_en-US.js | 20 +- .../mojits/i18n/lang/i18n_fr-FR.js | 20 +- .../mojits/i18n/models/model.server.js | 10 +- .../model_yql/mojits/flickr/binders/index.js | 6 +- .../mojits/flickr/controller.server.js | 63 +-- .../mojits/flickr/models/model.server.js | 99 ++-- .../mojits/BodyMojit/binders/index.js | 6 +- .../mojits/BodyMojit/controller.server.js | 20 +- .../mojits/BodyMojit/models/model.server.js | 10 +- .../mojits/FooterMojit/binders/index.js | 8 +- .../mojits/FooterMojit/controller.server.js | 20 +- .../mojits/FooterMojit/models/model.server.js | 8 +- .../mojits/FrameMojit/binders/index.js | 6 +- .../mojits/FrameMojit/controller.server.js | 18 +- .../mojits/FrameMojit/models/model.server.js | 10 +- .../mojits/HeaderMojit/binders/index.js | 8 +- .../mojits/HeaderMojit/controller.server.js | 20 +- .../mojits/HeaderMojit/models/model.server.js | 10 +- .../developer-guide/scroll_views/index.js | 10 +- .../mojits/scroll/binders/binder.js | 16 +- .../mojits/scroll/controller.server.js | 62 +-- .../mojits/scroll/lang/scroll_en.js | 2 + .../mojits/scroll/models/model.server.js | 20 +- .../mojits/simple/binders/index.js | 2 + .../mojits/simple/controller.server.js | 72 +-- .../mojits/simple/models/model.server.js | 10 +- .../mojits/SimpleMojit/binders/index.js | 8 +- .../mojits/SimpleMojit/controller.server.js | 8 +- .../mojits/SimpleMojit/models/model.server.js | 10 +- .../mojits/log/binders/index.js | 14 +- .../mojits/log/controller.server.js | 54 +- .../mojits/log/models/foo.server.js | 14 +- .../mojits/simple/binders/index.js | 8 +- .../mojits/simple/controller.server.js | 40 +- .../mojits/simple/models/model.server.js | 10 +- .../mojits/flickr/binders/index.js | 26 +- .../mojits/flickr/controller.server.js | 46 +- .../mojits/flickr/models/model.server.js | 99 ++-- .../mojits/ContactUs/controller.server.js | 10 +- .../mojits/CookieMojit/binders/index.js | 8 +- .../mojits/CookieMojit/controller.server.js | 38 +- .../mojits/CookieMojit/models/model.server.js | 10 +- .../mojits/QueryMojit/binders/index.js | 8 +- .../mojits/QueryMojit/controller.server.js | 148 +++--- .../mojits/QueryMojit/models/model.server.js | 10 +- .../autoload/storage-lite.client.js | 481 +++++++++--------- .../mojits/Notepad/binders/index.js | 8 +- .../mojits/Notepad/controller.server.js | 6 +- 87 files changed, 1428 insertions(+), 1254 deletions(-) diff --git a/examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js b/examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js index 558f17347..1f00499db 100644 --- a/examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js +++ b/examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js @@ -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: []}); \ No newline at end of file diff --git a/examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js b/examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js index b2d499db6..b2d5bc218 100644 --- a/examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js +++ b/examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js @@ -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']}); \ No newline at end of file diff --git a/examples/developer-guide/binding_events/index.js b/examples/developer-guide/binding_events/index.js index 06204ea01..815e177a8 100644 --- a/examples/developer-guide/binding_events/index.js +++ b/examples/developer-guide/binding_events/index.js @@ -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. diff --git a/examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js b/examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js index 02cc42019..d8fcd0b5c 100644 --- a/examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js +++ b/examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js @@ -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 = ''; - 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 = ''; + 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']}); diff --git a/examples/developer-guide/binding_events/mojits/PagerMojit/controller.server.js b/examples/developer-guide/binding_events/mojits/PagerMojit/controller.server.js index d2de3fe20..246f97261 100644 --- a/examples/developer-guide/binding_events/mojits/PagerMojit/controller.server.js +++ b/examples/developer-guide/binding_events/mojits/PagerMojit/controller.server.js @@ -4,70 +4,78 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('PagerMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - var PAGE_SIZE = 10; - /** - * Constructor for the Controller class. - * @class Controller - * @constructor - */ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - var page=0; - if(actionContext.params.hasOwnProperty('merged')){ - page = actionContext.params.merged('page'); - }else{ - page=actionContext.params.getFromUrl('page'); - } - var start; - page = parseInt(page) || 1; - if ((!page) || (page<1)) { - page = 1; - } - // Page param is 1 based, but the model is 0 based - start = (page - 1) * PAGE_SIZE; - var model = actionContext.models.PagerMojit; - // Data is an array of images - model.getData('mojito', start, PAGE_SIZE, function(data) { - Y.log('DATA: ' + Y.dump(data)); - var theData = { - data: data, // images - hasLink: false, - prev: { - title: "prev" // opportunity to localize - }, - next: { - link: createLink(actionContext, {page: page+1}), - title: "next" - }, - query: 'mojito' - }; - if (page > 1) { - theData.prev.link = createLink(actionContext, {page: page-1}); - theData.hasLink = true; +YUI.add('PagerMojit', function (Y, NAME) { + + var PAGE_SIZE = 10; + function createLink(actionContext, params) { + var params_to_copy, + mergedParams, + k; + if (actionContext.params.hasOwnProperty('merge')) { + params_to_copy = actionContext.params.merged(); + } else { + params_to_copy = actionContext.params.getFromMerged(); } - actionContext.done(theData); - }); - } - }; - // Generate the link to the next page based on: - // - mojit id - // - action - // - params - function createLink(actionContext, params) { - if(actionContext.params.hasOwnProperty('merge')){ - var params_to_copy=actionContext.params.merged(); - }else{ - var params_to_copy=actionContext.params.getFromMerged(); - } - var mergedParams = Y.mojito.util.copy(params_to_copy); - for (var k in params) { - mergedParams[k] = params[k]; + mergedParams = Y.mojito.util.copy(params_to_copy); + for (k in params) { + if (params.hasOwnProperty(k)) { + mergedParams[k] = params[k]; + } + } + return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams)); } - return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams)); - } + /** + * Constructor for the Controller class. + * @class Controller + * @constructor + */ + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(actionContext) { + var page = 0, + start, + model = actionContext.models.PagerMojit; + if (actionContext.params.hasOwnProperty('merged')) { + page = actionContext.params.merged('page'); + } else { + page = actionContext.params.getFromUrl('page'); + } + page = parseInt(page, 10) || 1; + if ((!page) || (page < 1)) { + page = 1; + } + // Page param is 1 based, but the model is 0 based + start = (page - 1) * PAGE_SIZE; + // Data is an array of images + model.getData('mojito', start, PAGE_SIZE, function(data) { + Y.log('DATA: ' + Y.dump(data)); + var theData = { + data: data, // images + hasLink: false, + prev: { + title: "prev" // opportunity to localize + }, + next: { + link: createLink(actionContext, {page: page + 1}), + title: "next" + }, + query: 'mojito' + }; + if (page > 1) { + theData.prev.link = createLink(actionContext, {page: page - 1}); + theData.hasLink = true; + } + actionContext.done(theData); + }); + } + }; + // Generate the link to the next page based on: + // - mojit id + // - action + // - params + }, '0.0.1', {requires: ['dump']}); diff --git a/examples/developer-guide/binding_events/mojits/PagerMojit/models/model.server.js b/examples/developer-guide/binding_events/mojits/PagerMojit/models/model.server.js index cb249300b..8e939abac 100644 --- a/examples/developer-guide/binding_events/mojits/PagerMojit/models/model.server.js +++ b/examples/developer-guide/binding_events/mojits/PagerMojit/models/model.server.js @@ -4,51 +4,57 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('PagerMojitModel', function(Y) { - var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; + var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; - /** - * The PagerMojitModel module. - * @module PagerMojitModel - */ - /** - * Constructor for the Model class. - * @class Model - * @constructor - */ - Y.mojito.models.PagerMojit = { - init: function(config) { - this.config = config; - }, - getData: function(query, start, count, callback) { - var q = null; - start = parseInt(start) || 0; - count = parseInt(count) || 10; - q = 'select * from flickr.photos.search(' + start + ',' + count + ') where text="%' + query + '%" and api_key="' + API_KEY + '"'; - Y.log('QUERY: ' + q); - Y.YQL(q, function(rawData) { - if (!rawData.query.results) { - callback([]); - return; - } - var rawImages = rawData.query.results.photo, - rawImage = null,images = [], image = null, i = 0; - for (; i', 'top'); - ac.assets.addBlob('', 'top'); - // Modify the style sheet name. - css += '.' + device; - } - // Attach the style sheet. - css += '.css'; - ac.assets.addCss(css, 'top'); - // Push data to the template. - ac.done({ - title: "Device Assets", - colors: [ - {id: "green", rgb: "#616536"}, - {id: "brown", rgb: "#593E1A"}, - {id: "grey", rgb: "#777B88"}, - {id: "blue", rgb: "#3D72A4"}, - {id: "red", rgb: "#990033"} - ] - }); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('device', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(ac) { + var device = ac.context.device, css = '/static/device/assets/simple'; + if (device === 'iphone') { + // Attach viewport meta-data + ac.assets.addBlob('', 'top'); + ac.assets.addBlob('', 'top'); + // Modify the style sheet name. + css += '.' + device; + } + // Attach the style sheet. + css += '.css'; + ac.assets.addCss(css, 'top'); + // Push data to the template. + ac.done({ + title: "Device Assets", + colors: [ + {id: "green", rgb: "#616536"}, + {id: "brown", rgb: "#593E1A"}, + {id: "grey", rgb: "#777B88"}, + {id: "blue", rgb: "#3D72A4"}, + {id: "red", rgb: "#990033"} + ] + }); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/device_views/mojits/device/binders/index.js b/examples/developer-guide/device_views/mojits/device/binders/index.js index ff022d825..6bbfd9087 100644 --- a/examples/developer-guide/device_views/mojits/device/binders/index.js +++ b/examples/developer-guide/device_views/mojits/device/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('deviceBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('deviceBinderIndex', function (Y, NAME) { /** * The deviceBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('deviceBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('deviceBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/device_views/mojits/device/controller.server.js b/examples/developer-guide/device_views/mojits/device/controller.server.js index cd2176d9c..aa54f914d 100644 --- a/examples/developer-guide/device_views/mojits/device/controller.server.js +++ b/examples/developer-guide/device_views/mojits/device/controller.server.js @@ -4,19 +4,21 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('device', function(Y, NAME) { - - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - /* Method corresponding to the 'index' action. - * - * @param ac {Object} The action context that - * provides access to the Mojito API. - */ - index: function(ac) { - ac.done({title: 'Device Views'}); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('device', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + /* Method corresponding to the 'index' action. + * + * @param ac {Object} The action context that + * provides access to the Mojito API. + */ + index: function (ac) { + ac.done({title: 'Device Views'}); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/device_views/mojits/device/models/model.server.js b/examples/developer-guide/device_views/mojits/device/models/model.server.js index 74dc1fd62..0dbf01256 100644 --- a/examples/developer-guide/device_views/mojits/device/models/model.server.js +++ b/examples/developer-guide/device_views/mojits/device/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('deviceModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('deviceModel', function (Y) { /** * The deviceModel module. @@ -20,7 +22,7 @@ YUI.add('deviceModel', function(Y) { */ Y.mojito.models.device = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('deviceModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/framed_assets/mojits/framed/binders/index.js b/examples/developer-guide/framed_assets/mojits/framed/binders/index.js index e77e24750..8dc7d3cc9 100644 --- a/examples/developer-guide/framed_assets/mojits/framed/binders/index.js +++ b/examples/developer-guide/framed_assets/mojits/framed/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('framedBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('framedBinderIndex', function (Y, NAME) { /** * The framedBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('framedBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('framedBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/framed_assets/mojits/framed/controller.server.js b/examples/developer-guide/framed_assets/mojits/framed/controller.server.js index 67016b774..0748ccd53 100644 --- a/examples/developer-guide/framed_assets/mojits/framed/controller.server.js +++ b/examples/developer-guide/framed_assets/mojits/framed/controller.server.js @@ -4,23 +4,25 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('framed', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - var data = { - title: "Framed Assets", - colors: [ - {id: "green", rgb: "#616536"}, - {id: "brown", rgb: "#593E1A"}, - {id: "grey", rgb: "#777B88"}, - {id: "blue", rgb: "#3D72A4"}, - {id: "red", rgb: "#990033"} - ] - }; - ac.done(data); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('framed', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (ac) { + var data = { + title: "Framed Assets", + colors: [ + {id: "green", rgb: "#616536"}, + {id: "brown", rgb: "#593E1A"}, + {id: "grey", rgb: "#777B88"}, + {id: "blue", rgb: "#3D72A4"}, + {id: "red", rgb: "#990033"} + ] + }; + ac.done(data); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/framed_assets/mojits/framed/models/model.server.js b/examples/developer-guide/framed_assets/mojits/framed/models/model.server.js index 64ffda41f..d3f6d1fd3 100644 --- a/examples/developer-guide/framed_assets/mojits/framed/models/model.server.js +++ b/examples/developer-guide/framed_assets/mojits/framed/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('framedModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('framedModel', function (Y) { /** * The framedModel module. @@ -20,7 +22,7 @@ YUI.add('framedModel', function(Y) { */ Y.mojito.models.framed = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('framedModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/framed_config/mojits/MainMojit/binders/binder.js b/examples/developer-guide/framed_config/mojits/MainMojit/binders/binder.js index a502cae6a..981b6da42 100644 --- a/examples/developer-guide/framed_config/mojits/MainMojit/binders/binder.js +++ b/examples/developer-guide/framed_config/mojits/MainMojit/binders/binder.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('MainMojitBinder', function(Y) { /** @@ -31,7 +33,7 @@ YUI.add('MainMojitBinder', function(Y) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function() { + init: function () { }, /** @@ -40,7 +42,7 @@ YUI.add('MainMojitBinder', function(Y) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/framed_config/mojits/MainMojit/controller.server.js b/examples/developer-guide/framed_config/mojits/MainMojit/controller.server.js index 71b111867..b9477f89c 100644 --- a/examples/developer-guide/framed_config/mojits/MainMojit/controller.server.js +++ b/examples/developer-guide/framed_config/mojits/MainMojit/controller.server.js @@ -4,29 +4,31 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('MainMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ -/** - * The MainMojit module. - * - * @module MainMojit - */ +YUI.add('MainMojit', function (Y, NAME) { + + /** + * The MainMojit module. + * + * @module MainMojit + */ /** - * Constructor for the Controller class. - * - * @class Controller - * @constructor - */ - Y.namespace('mojito.controllers')[NAME] = { + * Constructor for the Controller class. + * + * @class Controller + * @constructor + */ + Y.namespace('mojito.controllers')[NAME] = { - /** - * Method corresponding to the 'index' action. - * - * @param actionContext {Object} The action context that provides access - * to the Mojito API. - */ - index: function(actionContext) { + /** + * Method corresponding to the 'index' action. + * + * @param actionContext {Object} The action context that provides access + * to the Mojito API. + */ + index: function (actionContext) { actionContext.done({title: "HTML Frame Configuration Example"}); } diff --git a/examples/developer-guide/framed_config/mojits/MainMojit/models/model.server.js b/examples/developer-guide/framed_config/mojits/MainMojit/models/model.server.js index 0d6d23d1a..231b79695 100644 --- a/examples/developer-guide/framed_config/mojits/MainMojit/models/model.server.js +++ b/examples/developer-guide/framed_config/mojits/MainMojit/models/model.server.js @@ -4,12 +4,14 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('MainMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('MainMojitModel', function (Y) { Y.mojito.models.MainMojit = { - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/generating_urls/mojits/GenURLMojit/binders/index.js b/examples/developer-guide/generating_urls/mojits/GenURLMojit/binders/index.js index c1889d172..57a86ad09 100644 --- a/examples/developer-guide/generating_urls/mojits/GenURLMojit/binders/index.js +++ b/examples/developer-guide/generating_urls/mojits/GenURLMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('GenURLMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('GenURLMojitBinderIndex', function (Y, NAME) { /** * The GenURLMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('GenURLMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('GenURLMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/generating_urls/mojits/GenURLMojit/controller.server.js b/examples/developer-guide/generating_urls/mojits/GenURLMojit/controller.server.js index ec85f05b4..e44f7072e 100644 --- a/examples/developer-guide/generating_urls/mojits/GenURLMojit/controller.server.js +++ b/examples/developer-guide/generating_urls/mojits/GenURLMojit/controller.server.js @@ -4,18 +4,20 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('GenURLMojit', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - var url = actionContext.url.make('mymojit', 'contactus', ''); - actionContext.done({contactus_url: url}); - }, - contactus: function(actionContext) { - var currentTime = actionContext.intl.formatDate(new Date()); - actionContext.done({currentTime: currentTime}); - } - }; + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(actionContext) { + var url = actionContext.url.make('mymojit', 'contactus', ''); + actionContext.done({contactus_url: url}); + }, + contactus: function(actionContext) { + var currentTime = actionContext.intl.formatDate(new Date()); + actionContext.done({currentTime: currentTime}); + } + }; }, '0.0.1', {requires: ['mojito-intl-addon']}); diff --git a/examples/developer-guide/generating_urls/mojits/GenURLMojit/models/model.server.js b/examples/developer-guide/generating_urls/mojits/GenURLMojit/models/model.server.js index 11a819d1c..e3d12f498 100644 --- a/examples/developer-guide/generating_urls/mojits/GenURLMojit/models/model.server.js +++ b/examples/developer-guide/generating_urls/mojits/GenURLMojit/models/model.server.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('GenURLMojitModel', function(Y) { /** @@ -20,7 +22,7 @@ YUI.add('GenURLMojitModel', function(Y) { */ Y.mojito.models.GenURLMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('GenURLMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/global_assets/mojits/OhHai/controller.server.js b/examples/developer-guide/global_assets/mojits/OhHai/controller.server.js index ad4fb9d44..d20b10cf5 100644 --- a/examples/developer-guide/global_assets/mojits/OhHai/controller.server.js +++ b/examples/developer-guide/global_assets/mojits/OhHai/controller.server.js @@ -4,11 +4,13 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('OhHai', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('OhHai', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { - index: function(ac) { + index: function (ac) { ac.done(); } diff --git a/examples/developer-guide/hello/mojits/HelloMojit/binders/index.js b/examples/developer-guide/hello/mojits/HelloMojit/binders/index.js index 4c96a12c5..b577c0696 100644 --- a/examples/developer-guide/hello/mojits/HelloMojit/binders/index.js +++ b/examples/developer-guide/hello/mojits/HelloMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HelloMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HelloMojitBinderIndex', function (Y, NAME) { /** * The HelloMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('HelloMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('HelloMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/hello/mojits/HelloMojit/controller.server.js b/examples/developer-guide/hello/mojits/HelloMojit/controller.server.js index 7f51f0e40..5b53ceb88 100644 --- a/examples/developer-guide/hello/mojits/HelloMojit/controller.server.js +++ b/examples/developer-guide/hello/mojits/HelloMojit/controller.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HelloMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HelloMojit', function (Y, NAME) { /** * The HelloMojit module. @@ -20,7 +22,7 @@ YUI.add('HelloMojit', function(Y, NAME) { */ Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,7 +32,7 @@ YUI.add('HelloMojit', function(Y, NAME) { * @param ac {Object} The action context that provides access * to the Mojito API. */ - index: function(ac) { + index: function (ac) { ac.done('Hello World!'); } diff --git a/examples/developer-guide/hello/mojits/HelloMojit/models/model.server.js b/examples/developer-guide/hello/mojits/HelloMojit/models/model.server.js index 794d7c54c..2fd0b685a 100644 --- a/examples/developer-guide/hello/mojits/HelloMojit/models/model.server.js +++ b/examples/developer-guide/hello/mojits/HelloMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HelloMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HelloMojitModel', function (Y) { /** * The HelloMojitModel module. @@ -20,7 +22,7 @@ YUI.add('HelloMojitModel', function(Y) { */ Y.mojito.models.HelloMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('HelloMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/htmlframe_mojit/mojits/framed/binders/index.js b/examples/developer-guide/htmlframe_mojit/mojits/framed/binders/index.js index e77e24750..8dc7d3cc9 100644 --- a/examples/developer-guide/htmlframe_mojit/mojits/framed/binders/index.js +++ b/examples/developer-guide/htmlframe_mojit/mojits/framed/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('framedBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('framedBinderIndex', function (Y, NAME) { /** * The framedBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('framedBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('framedBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/htmlframe_mojit/mojits/framed/controller.server.js b/examples/developer-guide/htmlframe_mojit/mojits/framed/controller.server.js index 7d584481b..ff313984a 100644 --- a/examples/developer-guide/htmlframe_mojit/mojits/framed/controller.server.js +++ b/examples/developer-guide/htmlframe_mojit/mojits/framed/controller.server.js @@ -4,14 +4,16 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('framed', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - ac.done({app_name:'Framed Mojit'}); - } - }; +YUI.add('framed', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (ac) { + ac.done({app_name: 'Framed Mojit'}); + } + }; }, '0.0.1', {requires: ['']}); diff --git a/examples/developer-guide/htmlframe_mojit/mojits/framed/models/model.server.js b/examples/developer-guide/htmlframe_mojit/mojits/framed/models/model.server.js index 64ffda41f..931d38ea2 100644 --- a/examples/developer-guide/htmlframe_mojit/mojits/framed/models/model.server.js +++ b/examples/developer-guide/htmlframe_mojit/mojits/framed/models/model.server.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('framedModel', function(Y) { /** @@ -20,7 +22,7 @@ YUI.add('framedModel', function(Y) { */ Y.mojito.models.framed = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('framedModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/inter-mojit/index.js b/examples/developer-guide/inter-mojit/index.js index 6b97b032c..715914148 100644 --- a/examples/developer-guide/inter-mojit/index.js +++ b/examples/developer-guide/inter-mojit/index.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + process.chdir(__dirname); /** @@ -11,13 +13,13 @@ process.chdir(__dirname); * @param {object} token Token used to identify the application. */ module.exports = function(config, token) { - var server = require('./server.js'); - var YUI = require('mojito').YUI; + var server = require('./server.js'), + YUI = require('mojito').YUI; YUI().use('mojito-server', function(Y) { var app = server(Y); // Signal the app is ready, providing the token and app references. process.emit("application-ready", token, app); - }); + }); }; diff --git a/examples/developer-guide/inter-mojit/mojits/MasterMojit/binders/index.js b/examples/developer-guide/inter-mojit/mojits/MasterMojit/binders/index.js index d7d092304..fa963e112 100644 --- a/examples/developer-guide/inter-mojit/mojits/MasterMojit/binders/index.js +++ b/examples/developer-guide/inter-mojit/mojits/MasterMojit/binders/index.js @@ -4,19 +4,21 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('MasterMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace("mojito.binders")[NAME]= { +YUI.add('MasterMojitBinderIndex', function (Y, NAME) { - init: function(mojitProxy) { + Y.namespace("mojito.binders")[NAME] = { + + init: function (mojitProxy) { var mp = this.mp = this.mojitProxy = mojitProxy; Y.log("Entering MasterMojitBinderIndex"); this.mojitProxy.listen('fire-link', function(payload) { - var c = mp.getChildren(); - var receiverID = c["receiver"].viewId; + var c = mp.getChildren(), + receiverID = c.receiver.viewId; Y.log('intercepted fire-link event: ' + payload.data.url, 'info', NAME); mojitProxy.broadcast('broadcast-link', - {url: payload.data.url},{ target: {viewId:receiverID }}); + {url: payload.data.url}, { target: {viewId: receiverID }}); Y.log('broadcasted event to child mojit: ' + payload.data.url, 'info', NAME); }); }, @@ -27,7 +29,7 @@ YUI.add('MasterMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/inter-mojit/mojits/MasterMojit/controller.server.js b/examples/developer-guide/inter-mojit/mojits/MasterMojit/controller.server.js index df742abac..79ece2235 100644 --- a/examples/developer-guide/inter-mojit/mojits/MasterMojit/controller.server.js +++ b/examples/developer-guide/inter-mojit/mojits/MasterMojit/controller.server.js @@ -4,14 +4,16 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('MasterMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('MasterMojit', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { + init: function (config) { this.config = config; }, - "index": function(actionContext) { + "index": function (actionContext) { actionContext.composite.done(); } diff --git a/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/binders/index.js b/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/binders/index.js index a0340ac46..2db2f00b5 100644 --- a/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/binders/index.js +++ b/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/binders/index.js @@ -4,11 +4,13 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('ReceiverMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('ReceiverMojitBinderIndex', function (Y, NAME) { Y.namespace('mojito.binders')[NAME] = { - init: function(mojitProxy) { + init: function (mojitProxy) { var self = this; this.mojitProxy = mojitProxy; this.mojitProxy.listen('broadcast-link', function(payload) { @@ -34,10 +36,10 @@ YUI.add('ReceiverMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } }; -}, '0.0.1', {requires: ['mojito-client','event-custom','json']}); +}, '0.0.1', {requires: ['mojito-client', 'event-custom', 'json']}); diff --git a/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/controller.server.js b/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/controller.server.js index 01ea28b9d..0df24d141 100644 --- a/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/controller.server.js +++ b/examples/developer-guide/inter-mojit/mojits/ReceiverMojit/controller.server.js @@ -4,16 +4,18 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('ReceiverMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('ReceiverMojit', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { init: function(config) { this.config = config; }, - index: function(actionContext) { + index: function (actionContext) { actionContext.done({title: 'This is the receiver mojit'}); }, - show: function(actionContext) { + show: function (actionContext) { var url = actionContext.params.merged('url') || "http://farm1.static.flickr.com/21/35282840_8155ba1a22_o.jpg"; actionContext.done( { diff --git a/examples/developer-guide/inter-mojit/mojits/SenderMojit/binders/index.js b/examples/developer-guide/inter-mojit/mojits/SenderMojit/binders/index.js index f242514fc..480195a2e 100644 --- a/examples/developer-guide/inter-mojit/mojits/SenderMojit/binders/index.js +++ b/examples/developer-guide/inter-mojit/mojits/SenderMojit/binders/index.js @@ -4,15 +4,17 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('SenderMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('SenderMojitBinderIndex', function (Y, NAME) { Y.namespace('mojito.binders')[NAME] = { - init: function(mojitProxy) { + init: function (mojitProxy) { this.mp = mojitProxy; }, - bind: function(node) { + bind: function (node) { var mp = this.mp; this.node = node; // capture all events on "ul li a" @@ -27,4 +29,4 @@ YUI.add('SenderMojitBinderIndex', function(Y, NAME) { }; -}, '0.0.1', {requires: ['node','mojito-client']}); +}, '0.0.1', {requires: ['node', 'mojito-client']}); diff --git a/examples/developer-guide/inter-mojit/mojits/SenderMojit/controller.server.js b/examples/developer-guide/inter-mojit/mojits/SenderMojit/controller.server.js index 69064916a..0c7248ee1 100644 --- a/examples/developer-guide/inter-mojit/mojits/SenderMojit/controller.server.js +++ b/examples/developer-guide/inter-mojit/mojits/SenderMojit/controller.server.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('SenderMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('SenderMojit', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { init: function(config) { this.config = config; }, - "index": function(actionContext) { + "index": function (actionContext) { actionContext.done({title: 'List of images for testing'}); } }; diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/binders/index.js b/examples/developer-guide/locale_i18n/mojits/i18n/binders/index.js index 9acc1c462..07a0b28d3 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/binders/index.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('i18nBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('i18nBinderIndex', function (Y, NAME) { /** * The i18nBinderIndex module. @@ -37,7 +39,7 @@ YUI.add('i18nBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/controller.server.js b/examples/developer-guide/locale_i18n/mojits/i18n/controller.server.js index 5b59268af..54dd3aa19 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/controller.server.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/controller.server.js @@ -4,19 +4,19 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('i18n', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - // Default. - ac.done( - { - title: ac.intl.lang("TITLE"), - today: ac.intl.formatDate(new Date()) +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('i18n', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function (ac) { + // Default. + ac.done({ + title: ac.intl.lang("TITLE"), + today: ac.intl.formatDate(new Date()) + }); } - ); - } - }; + }; }, '0.0.1', { requires: ['mojito-intl-addon']}); diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-AU.js b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-AU.js index afb4ab098..e3e3ef9c6 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-AU.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-AU.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ -YUI.add("lang/i18n_en-AU", function(Y) { - Y.Intl.add( - "i18n", // associated module - "en-AU", // BCP 47 language tag - // key-value pairs for this module and language - { - TITLE: "G'day!" - } - ); +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add("lang/i18n_en-AU", function (Y) { + Y.Intl.add( + "i18n", // associated module + "en-AU", // BCP 47 language tag + // key-value pairs for this module and language + { + TITLE: "G'day!" + } + ); }, "3.1.0", {requires: ['intl']}); diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-US.js b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-US.js index f00a3087a..1df3cde20 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-US.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_en-US.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ -YUI.add("lang/i18n_en-US", function(Y) { - Y.Intl.add( - "i18n", // associated module - "en-US", // BCP 47 language tag - // key-value pairs for this module and language - { - TITLE: "Hello!" - } - ); +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add("lang/i18n_en-US", function (Y) { + Y.Intl.add( + "i18n", // associated module + "en-US", // BCP 47 language tag + // key-value pairs for this module and language + { + TITLE: "Hello!" + } + ); }, "3.1.0", {requires: ['intl']}); diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_fr-FR.js b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_fr-FR.js index 84f7d5b72..01b0b95ab 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_fr-FR.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/lang/i18n_fr-FR.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ -YUI.add("lang/i18n_fr-FR", function(Y) { - Y.Intl.add( - "i18n", // associated module - "fr-FR", // BCP 47 language tag - // key-value pairs for this module and language - { - TITLE: "Tiens!" - } - ); +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add("lang/i18n_fr-FR", function (Y) { + Y.Intl.add( + "i18n", // associated module + "fr-FR", // BCP 47 language tag + // key-value pairs for this module and language + { + TITLE: "Tiens!" + } + ); }, "3.1.0", {requires: ['intl']}); diff --git a/examples/developer-guide/locale_i18n/mojits/i18n/models/model.server.js b/examples/developer-guide/locale_i18n/mojits/i18n/models/model.server.js index 617af1418..09b0eda6b 100644 --- a/examples/developer-guide/locale_i18n/mojits/i18n/models/model.server.js +++ b/examples/developer-guide/locale_i18n/mojits/i18n/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('i18nModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('i18nModel', function (Y) { /** * The i18nModel module. @@ -20,7 +22,7 @@ YUI.add('i18nModel', function(Y) { */ Y.mojito.models.i18n = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('i18nModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/model_yql/mojits/flickr/binders/index.js b/examples/developer-guide/model_yql/mojits/flickr/binders/index.js index 2e525b30d..9788e8de3 100644 --- a/examples/developer-guide/model_yql/mojits/flickr/binders/index.js +++ b/examples/developer-guide/model_yql/mojits/flickr/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickrBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('flickrBinderIndex', function (Y, NAME) { /** * The flickrBinderIndex module. @@ -37,7 +39,7 @@ YUI.add('flickrBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/model_yql/mojits/flickr/controller.server.js b/examples/developer-guide/model_yql/mojits/flickr/controller.server.js index b397b5185..1134b424d 100644 --- a/examples/developer-guide/model_yql/mojits/flickr/controller.server.js +++ b/examples/developer-guide/model_yql/mojits/flickr/controller.server.js @@ -4,36 +4,37 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickr', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - // Use aliases to params addon - // if they exist. - if(ac.params.hasOwnProperty('url')){ - var q =ac.params.url('q') || 'muppet', - page = (ac.params.url('page') || 0) /1, - count = (ac.params.url('size') || 20) /1; - }else{ - var q =ac.params.getFromUrl('q') || 'muppet', - page = (ac.params.getFromUrl('page') || 0) / 1, - count = (ac.params.getFromUrl('count') || 20) / 1; - } - var start = page * count; - var model = ac.models.flickr; - model.search (q, start, count, function(photos) { - ac.done ( - { - photos: photos, - page: page, - count: count, - start: start - } - ); - }); - } - }; +YUI.add('flickr', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (ac) { + // Use aliases to params addon + // if they exist. + var q, page, count, start, model; + if (ac.params.hasOwnProperty('url')) { + q = ac.params.url('q') || 'muppet'; + page = (ac.params.url('page') || 0); + count = (ac.params.url('size') || 20); + } else { + q = ac.params.getFromUrl('q') || 'muppet'; + page = (ac.params.getFromUrl('page') || 0); + count = (ac.params.getFromUrl('count') || 20); + } + start = page * count; + model = ac.models.flickr; + model.search(q, start, count, function (photos) { + ac.done({ + photos: photos, + page: page, + count: count, + start: start + }); + }); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/model_yql/mojits/flickr/models/model.server.js b/examples/developer-guide/model_yql/mojits/flickr/models/model.server.js index 115626b2a..4cc281fa9 100644 --- a/examples/developer-guide/model_yql/mojits/flickr/models/model.server.js +++ b/examples/developer-guide/model_yql/mojits/flickr/models/model.server.js @@ -4,55 +4,54 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickrModel', function(Y) { - var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; - - Y.mojito.models.flickr = { - init: function(config) { - this.config = config; - }, - getData: function(callback) { - callback({some:'data'}); - }, - // Search for Flickr Images - search: function (search, start, count, callback) { // Handle empty. - if (null == search || 0 == search.length) { - callback([]); - } - // Build YQL select. - start /= 1; count /= 1; - var select = 'select * from '+ 'flickr.photos.search ' + '(' + (start || 0) + ',' + (count || 20) + ') ' + 'where '+ 'text="%' + (search || 'muppet') + '%" and api_key="' + API_KEY + '"'; - // Execute against YQL - Y.YQL (select, function(rawYql) { - // Handle empty response. - if (null == rawYql || 0 == rawYql.query.count) { - callback ([]); +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('flickrModel', function (Y) { + var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; + + Y.mojito.models.flickr = { + init: function (config) { + this.config = config; + }, + getData: function (callback) { + callback({some: 'data'}); + }, + // Search for Flickr Images + search: function (search, start, count, callback) { // Handle empty. + if (null === search || 0 === search.length) { + callback([]); + } + // Build YQL select. + start /= 1; + count /= 1; + var select = 'select * from ' + 'flickr.photos.search ' + '(' + (start || 0) + ',' + (count || 20) + ') ' + 'where ' + 'text="%' + (search || 'muppet') + '%" and api_key="' + API_KEY + '"'; + // Execute against YQL + Y.YQL(select, function(rawYql) { + // Handle empty response. + if (null === rawYql || 0 === rawYql.query.count) { + callback([]); + } + // Process data. + var photos = [], item = null, i; + // Force array. + if (!rawYql.query.results.photo.length) { + rawYql.query.results.photo = [rawYql.query.results.photo]; + } + // Assume array + for (i = 0; i < rawYql.query.count; i += 1) { + // Fix up the item. + item = rawYql.query.results.photo[i]; + item.url = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg'; + item.title = (!item.title) ? search + ':' + i : item.title; + // Attach the result. + photos.push({ + id: item.id, + title: item.title, + url: item.url + }); + } + callback(photos); + }); } - // Process data. - var photos = [], item = null; - // Force array. - if ( !rawYql.query.results.photo.length ) { - rawYql.query.results.photo = [ - rawYql.query.results.photo - ]; - } - // Assume array - for (var i=0; i < rawYql.query.count; i++) { - // Fix up the item. - item = rawYql.query.results.photo[i]; - item.url = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg'; - item.title = (!item.title) ? search + ':' + i : item.title; - // Attach the result. - photos.push ( - { - id: item.id, - title: item.title, - url: item.url - } - ); - } - callback (photos); - }); - } -}; + }; }, '0.0.1', { requires: ['mojito', 'yql']}); diff --git a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/binders/index.js b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/binders/index.js index 52143076a..fd21126af 100644 --- a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/binders/index.js +++ b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/binders/index.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('BodyMojitBinderIndex', function(Y, NAME) { /** @@ -27,7 +29,7 @@ YUI.add('BodyMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('BodyMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/controller.server.js b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/controller.server.js index d201d05ef..d927e7eb4 100644 --- a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/controller.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/controller.server.js @@ -4,14 +4,16 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('BodyMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - actionContext.done({title: "Body"}); - } - }; +YUI.add('BodyMojit', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (actionContext) { + actionContext.done({title: "Body"}); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/models/model.server.js b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/models/model.server.js index 157b055ac..bebc3654c 100644 --- a/examples/developer-guide/multiple_mojits/mojits/BodyMojit/models/model.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/BodyMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('BodyMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('BodyMojitModel', function (Y) { /** * The BodyMojitModel module. @@ -20,7 +22,7 @@ YUI.add('BodyMojitModel', function(Y) { */ Y.mojito.models.BodyMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('BodyMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/binders/index.js b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/binders/index.js index f003a17cc..daae70381 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/binders/index.js +++ b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('FooterMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('FooterMojitBinderIndex', function (Y, NAME) { /** * The FooterMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('FooterMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('FooterMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/controller.server.js b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/controller.server.js index 349698c56..a2c82b486 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/controller.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/controller.server.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('FooterMojit', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - actionContext.done({title: "Footer"}); - } - }; -}, '0.0.1', {requires: ['mojito']}) + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (actionContext) { + actionContext.done({title: "Footer"}); + } + }; +}, '0.0.1', {requires: ['mojito']}); diff --git a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/models/model.server.js b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/models/model.server.js index baefaa322..1710e4efc 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FooterMojit/models/model.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/FooterMojit/models/model.server.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('FooterMojitModel', function(Y) { /** @@ -20,7 +22,7 @@ YUI.add('FooterMojitModel', function(Y) { */ Y.mojito.models.FooterMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('FooterMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/binders/index.js b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/binders/index.js index 764f076e3..819c96cbc 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/binders/index.js +++ b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/binders/index.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('FrameMojitBinderIndex', function(Y, NAME) { /** @@ -27,7 +29,7 @@ YUI.add('FrameMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('FrameMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/controller.server.js b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/controller.server.js index 074d9a2df..5205b6d71 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/controller.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/controller.server.js @@ -4,14 +4,16 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('FrameMojit', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - actionContext.composite.done({template: {title: "Parent Frame"}}); - } - }; + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(actionContext) { + actionContext.composite.done({template: {title: "Parent Frame"}}); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/models/model.server.js b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/models/model.server.js index 96a87af6a..3cbdd169e 100644 --- a/examples/developer-guide/multiple_mojits/mojits/FrameMojit/models/model.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/FrameMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('FrameMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('FrameMojitModel', function (Y) { /** * The FrameMojitModel module. @@ -20,7 +22,7 @@ YUI.add('FrameMojitModel', function(Y) { */ Y.mojito.models.FrameMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('FrameMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/binders/index.js b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/binders/index.js index acd4d5f14..bf1d55c39 100644 --- a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/binders/index.js +++ b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HeaderMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HeaderMojitBinderIndex', function (Y, NAME) { /** * The HeaderMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('HeaderMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('HeaderMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/controller.server.js b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/controller.server.js index d7fa5fa5a..ad257e170 100644 --- a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/controller.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/controller.server.js @@ -4,13 +4,15 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HeaderMojit', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - actionContext.done({title: "Header"}); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HeaderMojit', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(actionContext) { + actionContext.done({title: "Header"}); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/models/model.server.js b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/models/model.server.js index efeffcf46..155ff4db9 100644 --- a/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/models/model.server.js +++ b/examples/developer-guide/multiple_mojits/mojits/HeaderMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('HeaderMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('HeaderMojitModel', function (Y) { /** * The HeaderMojitModel module. @@ -20,7 +22,7 @@ YUI.add('HeaderMojitModel', function(Y) { */ Y.mojito.models.HeaderMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('HeaderMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/scroll_views/index.js b/examples/developer-guide/scroll_views/index.js index e10ee6aa7..cba9ba97e 100644 --- a/examples/developer-guide/scroll_views/index.js +++ b/examples/developer-guide/scroll_views/index.js @@ -6,6 +6,8 @@ /*jslint anon:true, sloppy:true, nomen:true, node:true*/ +/*jslint anon:true, sloppy:true, nomen:true*/ + process.chdir(__dirname); /** @@ -13,13 +15,13 @@ process.chdir(__dirname); * @param {object} token Token used to identify the application. */ module.exports = function(config, token) { - var server = require('./server.js'); - var YUI = require('mojito').YUI; + var server = require('./server.js'), + YUI = require('mojito').YUI; - YUI().use('mojito-server', function(Y) { + YUI().use('mojito-server', function (Y) { var app = server(Y); // Signal the app is ready, providing the token and app references. process.emit("application-ready", token, app); - }); + }); }; diff --git a/examples/developer-guide/scroll_views/mojits/scroll/binders/binder.js b/examples/developer-guide/scroll_views/mojits/scroll/binders/binder.js index 0ed71069b..c0905fc1a 100644 --- a/examples/developer-guide/scroll_views/mojits/scroll/binders/binder.js +++ b/examples/developer-guide/scroll_views/mojits/scroll/binders/binder.js @@ -4,15 +4,17 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('scrollBinder', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.binders')[NAME] = { - init: function(mojitProxy){ - this.mojitProxy = mojitProxy; - }, - bind: function(node) { +YUI.add('scrollBinder', function (Y, NAME) { + + Y.namespace('mojito.binders')[NAME] = { + init: function (mojitProxy) { + this.mojitProxy = mojitProxy; + }, + bind: function (node) { this.node = node; Y.log('NODE: ' + Y.dump(this.node)); - } + } }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/scroll_views/mojits/scroll/controller.server.js b/examples/developer-guide/scroll_views/mojits/scroll/controller.server.js index adc516375..f87587e28 100644 --- a/examples/developer-guide/scroll_views/mojits/scroll/controller.server.js +++ b/examples/developer-guide/scroll_views/mojits/scroll/controller.server.js @@ -4,35 +4,37 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('scroll', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - // Populate Template - ac.done({ - title: 'Scroll View', - photos: [ - { - url: 'http://farm5.static.flickr.com/4136/4802088086_c621e0b501.jpg', - alt: 'Above The City II' - }, - { - url: 'http://farm5.static.flickr.com/4114/4801461321_1373a0ef89.jpg', - alt: 'Walls and Canyon' - }, - { - url: 'http://farm5.static.flickr.com/4100/4801614015_4303e8eaea.jpg', - alt: 'Stairs Using In Situ Stone' - }, - { - url: 'http://farm5.static.flickr.com/4076/4801368583_854e8c0ef3.jpg', - alt: 'Tree Silhouette' - } - ] - }); - } - }; +YUI.add('scroll', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (ac) { + // Populate Template + ac.done({ + title: 'Scroll View', + photos: [ + { + url: 'http://farm5.static.flickr.com/4136/4802088086_c621e0b501.jpg', + alt: 'Above The City II' + }, + { + url: 'http://farm5.static.flickr.com/4114/4801461321_1373a0ef89.jpg', + alt: 'Walls and Canyon' + }, + { + url: 'http://farm5.static.flickr.com/4100/4801614015_4303e8eaea.jpg', + alt: 'Stairs Using In Situ Stone' + }, + { + url: 'http://farm5.static.flickr.com/4076/4801368583_854e8c0ef3.jpg', + alt: 'Tree Silhouette' + } + ] + }); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/scroll_views/mojits/scroll/lang/scroll_en.js b/examples/developer-guide/scroll_views/mojits/scroll/lang/scroll_en.js index 6c6de9929..9e9d792c4 100644 --- a/examples/developer-guide/scroll_views/mojits/scroll/lang/scroll_en.js +++ b/examples/developer-guide/scroll_views/mojits/scroll/lang/scroll_en.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add("lang/scroll_en", function(Y) { Y.Intl.add( diff --git a/examples/developer-guide/scroll_views/mojits/scroll/models/model.server.js b/examples/developer-guide/scroll_views/mojits/scroll/models/model.server.js index 0663dfce0..0b05edf35 100644 --- a/examples/developer-guide/scroll_views/mojits/scroll/models/model.server.js +++ b/examples/developer-guide/scroll_views/mojits/scroll/models/model.server.js @@ -4,14 +4,16 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('scrollModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.mojito.models.scrollMojit = { - init: function(config) { - this.config = config; - }, - getData: function(callback) { - callback({some:'data'}); - } - }; +YUI.add('scrollModel', function (Y) { + + Y.mojito.models.scrollMojit = { + init: function (config) { + this.config = config; + }, + getData: function (callback) { + callback({some: 'data'}); + } + }; }, '0.0.1', {requires: ['mojito']}); diff --git a/examples/developer-guide/simple_assets/mojits/simple/binders/index.js b/examples/developer-guide/simple_assets/mojits/simple/binders/index.js index 177095167..98bc0303d 100644 --- a/examples/developer-guide/simple_assets/mojits/simple/binders/index.js +++ b/examples/developer-guide/simple_assets/mojits/simple/binders/index.js @@ -4,6 +4,8 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('simpleBinderIndex', function(Y, NAME) { /** diff --git a/examples/developer-guide/simple_assets/mojits/simple/controller.server.js b/examples/developer-guide/simple_assets/mojits/simple/controller.server.js index 931f5ccb7..fbd8f6e4e 100644 --- a/examples/developer-guide/simple_assets/mojits/simple/controller.server.js +++ b/examples/developer-guide/simple_assets/mojits/simple/controller.server.js @@ -4,39 +4,41 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('simple', function(Y, NAME) { - /** - * The simple module. - * - * @module simple - */ - /** - * Constructor for the Controller class. - * - * @class Controller - * @constructor - */ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - /** - * Method corresponding to the 'index' action. - * @param ac {Object} The action context that - * provides access to the Mojito API. - */ - index: function(ac) { - var data = { - title: "Simple Assets", - colors: [ - {id: "green", rgb: "#616536"}, - {id: "brown", rgb: "#593E1A"}, - {id: "grey", rgb: "#777B88"}, - {id: "blue", rgb: "#3D72A4"}, - {id: "red", rgb: "#990033"} - ] - }; - ac.done(data); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('simple', function (Y, NAME) { + /** + * The simple module. + * + * @module simple + */ + /** + * Constructor for the Controller class. + * + * @class Controller + * @constructor + */ + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + /** + * Method corresponding to the 'index' action. + * @param ac {Object} The action context that + * provides access to the Mojito API. + */ + index: function(ac) { + var data = { + title: "Simple Assets", + colors: [ + {id: "green", rgb: "#616536"}, + {id: "brown", rgb: "#593E1A"}, + {id: "grey", rgb: "#777B88"}, + {id: "blue", rgb: "#3D72A4"}, + {id: "red", rgb: "#990033"} + ] + }; + ac.done(data); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/simple_assets/mojits/simple/models/model.server.js b/examples/developer-guide/simple_assets/mojits/simple/models/model.server.js index fff6f48d6..3bbf45c17 100644 --- a/examples/developer-guide/simple_assets/mojits/simple/models/model.server.js +++ b/examples/developer-guide/simple_assets/mojits/simple/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('simpleModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('simpleModel', function (Y) { /** * The simpleModel module. @@ -20,7 +22,7 @@ YUI.add('simpleModel', function(Y) { */ Y.mojito.models.simple = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('simpleModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/simple_config/mojits/SimpleMojit/binders/index.js b/examples/developer-guide/simple_config/mojits/SimpleMojit/binders/index.js index 145460682..e0eea4606 100644 --- a/examples/developer-guide/simple_config/mojits/SimpleMojit/binders/index.js +++ b/examples/developer-guide/simple_config/mojits/SimpleMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('SimpleMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('SimpleMojitBinderIndex', function (Y, NAME) { /** * The SimpleMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('SimpleMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('SimpleMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/simple_config/mojits/SimpleMojit/controller.server.js b/examples/developer-guide/simple_config/mojits/SimpleMojit/controller.server.js index 78dedc7e3..b1ce595b2 100644 --- a/examples/developer-guide/simple_config/mojits/SimpleMojit/controller.server.js +++ b/examples/developer-guide/simple_config/mojits/SimpleMojit/controller.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('SimpleMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('SimpleMojit', function (Y, NAME) { /** * The SimpleMojit module. @@ -20,7 +22,7 @@ YUI.add('SimpleMojit', function(Y, NAME) { */ Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,7 +32,7 @@ YUI.add('SimpleMojit', function(Y, NAME) { * @param ac {Object} The action context that provides access * to the Mojito API. */ - index: function(ac) { + index: function (ac) { ac.done('Mojito is working.'); } diff --git a/examples/developer-guide/simple_config/mojits/SimpleMojit/models/model.server.js b/examples/developer-guide/simple_config/mojits/SimpleMojit/models/model.server.js index 92b1c6b54..c60716822 100644 --- a/examples/developer-guide/simple_config/mojits/SimpleMojit/models/model.server.js +++ b/examples/developer-guide/simple_config/mojits/SimpleMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('SimpleMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('SimpleMojitModel', function (Y) { /** * The SimpleMojitModel module. @@ -20,7 +22,7 @@ YUI.add('SimpleMojitModel', function(Y) { */ Y.mojito.models.SimpleMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('SimpleMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/simple_logging/mojits/log/binders/index.js b/examples/developer-guide/simple_logging/mojits/log/binders/index.js index 167e7300b..1d17c47aa 100644 --- a/examples/developer-guide/simple_logging/mojits/log/binders/index.js +++ b/examples/developer-guide/simple_logging/mojits/log/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('logBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('logBinderIndex', function (Y, NAME) { /** * The logBinderIndex module. @@ -22,13 +24,13 @@ YUI.add('logBinderIndex', function(Y, NAME) { * @constructor */ Y.namespace('mojito.binders')[NAME] = { - + /** * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { - Y.log('[BINDER]: Log message from init.',"info"); + init: function (mojitProxy) { + Y.log('[BINDER]: Log message from init.', "info"); this.mojitProxy = mojitProxy; }, @@ -38,8 +40,8 @@ YUI.add('logBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { - Y.log('[BINDER]: Log message from bind.',"info"); + bind: function (node) { + Y.log('[BINDER]: Log message from bind.', "info"); this.node = node; } diff --git a/examples/developer-guide/simple_logging/mojits/log/controller.server.js b/examples/developer-guide/simple_logging/mojits/log/controller.server.js index c8964036a..84700d38d 100644 --- a/examples/developer-guide/simple_logging/mojits/log/controller.server.js +++ b/examples/developer-guide/simple_logging/mojits/log/controller.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('log', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('log', function (Y, NAME) { /** * Constructor for the Controller class. @@ -14,10 +16,10 @@ YUI.add('log', function(Y, NAME) { */ Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { + init: function (config) { this.config = config; }, - + /** * Method corresponding to the 'index' action. * @@ -25,29 +27,29 @@ YUI.add('log', function(Y, NAME) { * to the Mojito API. */ - index: function(ac) { - Y.log('[CONTROLLER]: entering into controller index (...)',"info"); - var today = new Date(), - data = { - type : 'simple', - time : { - hours: today.getHours()%12, - minutes: today.getMinutes()<10 ? "0" + today.getMinutes() : today.getMinutes(), - period: today.getHours()>=12 ? "p.m." : "a.m." - }, - show : true, - hide : false, - list : [{ - id: 2 - }, { - id: 1 - }, { - id: 3 - } ], - hole : null, - html : "

simple html

" - }; - Y.log('[CONTROLLER]: Today ' +today); + index: function (ac) { + Y.log('[CONTROLLER]: entering into controller index (...)', "info"); + var today = new Date(), + data = { + type : 'simple', + time : { + hours: today.getHours() % 12, + minutes: today.getMinutes() < 10 ? "0" + today.getMinutes() : today.getMinutes(), + period: today.getHours() >= 12 ? "p.m." : "a.m." + }, + show : true, + hide : false, + list : [{ + id: 2 + }, { + id: 1 + }, { + id: 3 + } ], + hole : null, + html : "

simple html

" + }; + Y.log('[CONTROLLER]: Today ' + today); ac.done(data); } diff --git a/examples/developer-guide/simple_logging/mojits/log/models/foo.server.js b/examples/developer-guide/simple_logging/mojits/log/models/foo.server.js index a11b120b4..b73f5cd3e 100644 --- a/examples/developer-guide/simple_logging/mojits/log/models/foo.server.js +++ b/examples/developer-guide/simple_logging/mojits/log/models/foo.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('logModelFoo', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('logModelFoo', function (Y) { /** * The logModelFoo module. @@ -19,9 +21,9 @@ YUI.add('logModelFoo', function(Y) { * @constructor */ Y.mojito.models.logModelFoo = { - - init: function(config) { - Y.log('model: entering into init (..)' +config,"INFO"); + + init: function (config) { + Y.log('model: entering into init (..)' + config, "INFO"); this.config = config; }, @@ -31,8 +33,8 @@ YUI.add('logModelFoo', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/simple_view/mojits/simple/binders/index.js b/examples/developer-guide/simple_view/mojits/simple/binders/index.js index 177095167..185e21992 100644 --- a/examples/developer-guide/simple_view/mojits/simple/binders/index.js +++ b/examples/developer-guide/simple_view/mojits/simple/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('simpleBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('simpleBinderIndex', function (Y, NAME) { /** * The simpleBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('simpleBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('simpleBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/simple_view/mojits/simple/controller.server.js b/examples/developer-guide/simple_view/mojits/simple/controller.server.js index dcdbcee59..57ca7eeb9 100644 --- a/examples/developer-guide/simple_view/mojits/simple/controller.server.js +++ b/examples/developer-guide/simple_view/mojits/simple/controller.server.js @@ -4,24 +4,26 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('simple', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - var today = new Date(), - data = { - type : 'simple', - time : { hours: today.getHours()%12, minutes: today.getMinutes()<10 ? "0" + today.getMinutes() : today.getMinutes(), period: today.getHours()>=12 ? "p.m." : "a.m."}, - show : true, - hide : false, - list : [{id: 2}, {id: 1}, {id: 3} ], - hole : null, - html : "

simple html

" - }; - ac.done(data); - } - }; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('simple', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function(ac) { + var today = new Date(), + data = { + type : 'simple', + time : { hours: today.getHours() % 12, minutes: today.getMinutes() < 10 ? "0" + today.getMinutes() : today.getMinutes(), period: today.getHours() >= 12 ? "p.m." : "a.m."}, + show : true, + hide : false, + list : [{id: 2}, {id: 1}, {id: 3} ], + hole : null, + html : "

simple html

" + }; + ac.done(data); + } + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/simple_view/mojits/simple/models/model.server.js b/examples/developer-guide/simple_view/mojits/simple/models/model.server.js index fff6f48d6..3bbf45c17 100644 --- a/examples/developer-guide/simple_view/mojits/simple/models/model.server.js +++ b/examples/developer-guide/simple_view/mojits/simple/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('simpleModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('simpleModel', function (Y) { /** * The simpleModel module. @@ -20,7 +22,7 @@ YUI.add('simpleModel', function(Y) { */ Y.mojito.models.simple = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('simpleModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/unittest_model_controller/mojits/flickr/binders/index.js b/examples/developer-guide/unittest_model_controller/mojits/flickr/binders/index.js index 6bec7bbcb..a42f253c1 100644 --- a/examples/developer-guide/unittest_model_controller/mojits/flickr/binders/index.js +++ b/examples/developer-guide/unittest_model_controller/mojits/flickr/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickrBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('flickrBinderIndex', function (Y, NAME) { /** * The flickrBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('flickrBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,20 +39,22 @@ YUI.add('flickrBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; - Y.log('NODE: ' + Y.dump(this.node)); - var nodeId = node.get('id'); - var binderId = this.mojitProxy._guid; + Y.log('NODE: ' + Y.dump(this.node)); + var nodeId = node.get('id'), + binderId = this.mojitProxy._guid, + handleClick = function() { + this.node.one('div').set('innerHTML', "clicked on " + new Date()); + }; Y.log(nodeId + ' node bound', 'debug', NAME); if (nodeId !== binderId) { - throw new Error("bad node binding to binder!"); } + throw new Error("bad node binding to binder!"); + } + this.node.append("

" + nodeId + " bound

"); - this.node.on('click',handleClick, this); + this.node.on('click', handleClick, this); - var handleClick= function() { - this.node.one('div').set('innerHTML', "clicked on " + new Date()); - }; }, _updateId: function(msg) { var nodeId = this.node.get('id'); diff --git a/examples/developer-guide/unittest_model_controller/mojits/flickr/controller.server.js b/examples/developer-guide/unittest_model_controller/mojits/flickr/controller.server.js index 89ab7c79b..89bb003a7 100644 --- a/examples/developer-guide/unittest_model_controller/mojits/flickr/controller.server.js +++ b/examples/developer-guide/unittest_model_controller/mojits/flickr/controller.server.js @@ -4,28 +4,28 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickr', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(ac) { - var q = ac.params.getFromUrl('q') || 'muppet', - page = (ac.params.getFromUrl('page') || 0) / 1, - count = (ac.params.getFromUrl('size') || 20) / 1, - start = page * count; - var model = ac.models.flickr; - model.search (q, start, count, function(photos) { - ac.done ( - { - photos: photos, - page: page, - count: count, - start: start - } - ); - }); - } - }; +YUI.add('flickr', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (ac) { + var q = ac.params.getFromUrl('q') || 'muppet', + page = (ac.params.getFromUrl('page') || 0), + count = (ac.params.getFromUrl('size') || 20), + start = page * count, + model = ac.models.flickr; + model.search(q, start, count, function (photos) { + ac.done({ + photos: photos, + page: page, + count: count, + start: start + }); + }); + } + }; }, '0.0.1', {requires: ['flickrModel']}); diff --git a/examples/developer-guide/unittest_model_controller/mojits/flickr/models/model.server.js b/examples/developer-guide/unittest_model_controller/mojits/flickr/models/model.server.js index 9a935e49f..911345613 100644 --- a/examples/developer-guide/unittest_model_controller/mojits/flickr/models/model.server.js +++ b/examples/developer-guide/unittest_model_controller/mojits/flickr/models/model.server.js @@ -4,55 +4,56 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('flickrModel', function(Y) { -var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; - Y.mojito.models.flickr = { - init: function(config) { - this.config = config; - }, - getData: function(callback) { - callback({some:'data'}); - }, - // Search for Flickr Images - search: function (search, start, count, callback) { - // Handle empty. - if (null == search || 0 == search.length) { - callback([]); - } - // Build YQL select. - start /= 1; count /= 1; - var select = 'select * from '+ 'flickr.photos.search ' + '(' + (start || 0) + ',' + (count || 20) + ') ' + 'where '+ 'text="%' + (search || 'muppet') + '%" and api_key="' + API_KEY + '"'; - // Execute against YQL - Y.YQL (select, function(rawYql) { - // Handle empty response. - if (null == rawYql || 0 == rawYql.query.count) { - callback ([]); - } - // Process data. - var photos = [], item = null; - // Force array. - if ( !rawYql.query.results.photo.length ) { - rawYql.query.results.photo = [ - rawYql.query.results.photo - ]; - } - // Assume array - for (var i=0; i < rawYql.query.count; i++) { - // Fix up the item. - item = rawYql.query.results.photo[i]; - item.url = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg'; - item.title = (!item.title) ? search + ':' + i : item.title; - // Attach the result. - photos.push ( - { - id: item.id, - title: item.title, - url: item.url +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('flickrModel', function (Y) { + var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e'; + Y.mojito.models.flickr = { + init: function (config) { + this.config = config; + }, + getData: function(callback) { + callback({some: 'data'}); + }, + // Search for Flickr Images + search: function (search, start, count, callback) { + // Handle empty. + if (null === search || 0 === search.length) { + callback([]); } - ); + // Build YQL select. + start /= 1; + count /= 1; + var select = 'select * from ' + 'flickr.photos.search ' + '(' + (start || 0) + ',' + (count || 20) + ') ' + 'where ' + 'text="%' + (search || 'muppet') + '%" and api_key="' + API_KEY + '"'; + // Execute against YQL + Y.YQL(select, function(rawYql) { + // Handle empty response. + if (null === rawYql || 0 === rawYql.query.count) { + callback([]); + } + // Process data. + var photos = [], item = null, i; + // Force array. + if (!rawYql.query.results.photo.length) { + rawYql.query.results.photo = [ rawYql.query.results.photo ]; + } + // Assume array + for (i = 0; i < rawYql.query.count; i += 1) { + // Fix up the item. + item = rawYql.query.results.photo[i]; + item.url = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg'; + item.title = (!item.title) ? search + ':' + i : item.title; + // Attach the result. + photos.push( + { + id: item.id, + title: item.title, + url: item.url + } + ); + } + callback(photos); + }); } - callback (photos); - }); - } - }; + }; }, '0.0.1', {requires: ['mojito', 'yql']}); diff --git a/examples/developer-guide/using_configs/mojits/ContactUs/controller.server.js b/examples/developer-guide/using_configs/mojits/ContactUs/controller.server.js index fc7e21128..e323160e2 100644 --- a/examples/developer-guide/using_configs/mojits/ContactUs/controller.server.js +++ b/examples/developer-guide/using_configs/mojits/ContactUs/controller.server.js @@ -4,20 +4,22 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('ContactUs', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('ContactUs', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { + init: function (config) { this.config = config; }, - index: function(ac) { + index: function (ac) { var vudata = { 'company': ac.config.get("company"), 'copyright': this.config.copyright, 'depts': ac.config.getDefinition(this.config.key) - } + }; ac.done(vudata); } diff --git a/examples/developer-guide/using_cookies/mojits/CookieMojit/binders/index.js b/examples/developer-guide/using_cookies/mojits/CookieMojit/binders/index.js index 4df6499b3..9809a4a45 100644 --- a/examples/developer-guide/using_cookies/mojits/CookieMojit/binders/index.js +++ b/examples/developer-guide/using_cookies/mojits/CookieMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('CookieMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('CookieMojitBinderIndex', function (Y, NAME) { /** * The CookieMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('CookieMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('CookieMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/using_cookies/mojits/CookieMojit/controller.server.js b/examples/developer-guide/using_cookies/mojits/CookieMojit/controller.server.js index d58d1ce61..0e3eef35a 100644 --- a/examples/developer-guide/using_cookies/mojits/CookieMojit/controller.server.js +++ b/examples/developer-guide/using_cookies/mojits/CookieMojit/controller.server.js @@ -4,24 +4,26 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('CookieMojit', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - var requestCookieValue = actionContext.cookie.get('request_cookie'); - - // Or use this API to set a session cookie - // with default properties set by Mojito - actionContext.cookie.set("response_cookie", "Hello from the server!"); - actionContext.done( - { - title: "Cookie Demo", - request_cookie_value: requestCookieValue +YUI.add('CookieMojit', function (Y, NAME) { + + Y.namespace('mojito.controllers')[NAME] = { + init: function (config) { + this.config = config; + }, + index: function (actionContext) { + var requestCookieValue = actionContext.cookie.get('request_cookie'); + + // Or use this API to set a session cookie + // with default properties set by Mojito + actionContext.cookie.set("response_cookie", "Hello from the server!"); + actionContext.done( + { + title: "Cookie Demo", + request_cookie_value: requestCookieValue + } + ); } - ); - } - }; + }; }, '0.0.1', {requires: []}); diff --git a/examples/developer-guide/using_cookies/mojits/CookieMojit/models/model.server.js b/examples/developer-guide/using_cookies/mojits/CookieMojit/models/model.server.js index 9b622da29..f9725bd66 100644 --- a/examples/developer-guide/using_cookies/mojits/CookieMojit/models/model.server.js +++ b/examples/developer-guide/using_cookies/mojits/CookieMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('CookieMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('CookieMojitModel', function (Y) { /** * The CookieMojitModel module. @@ -20,7 +22,7 @@ YUI.add('CookieMojitModel', function(Y) { */ Y.mojito.models.CookieMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('CookieMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/using_parameters/mojits/QueryMojit/binders/index.js b/examples/developer-guide/using_parameters/mojits/QueryMojit/binders/index.js index 3569386cb..4b3a34580 100644 --- a/examples/developer-guide/using_parameters/mojits/QueryMojit/binders/index.js +++ b/examples/developer-guide/using_parameters/mojits/QueryMojit/binders/index.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('QueryMojitBinderIndex', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('QueryMojitBinderIndex', function (Y, NAME) { /** * The QueryMojitBinderIndex module. @@ -27,7 +29,7 @@ YUI.add('QueryMojitBinderIndex', function(Y, NAME) { * Binder initialization method, invoked after all binders on the page * have been constructed. */ - init: function(mojitProxy) { + init: function (mojitProxy) { this.mojitProxy = mojitProxy; }, @@ -37,7 +39,7 @@ YUI.add('QueryMojitBinderIndex', function(Y, NAME) { * * @param node {Node} The DOM node to which this mojit is attached. */ - bind: function(node) { + bind: function (node) { this.node = node; } diff --git a/examples/developer-guide/using_parameters/mojits/QueryMojit/controller.server.js b/examples/developer-guide/using_parameters/mojits/QueryMojit/controller.server.js index e54fadbb2..a673db1d1 100644 --- a/examples/developer-guide/using_parameters/mojits/QueryMojit/controller.server.js +++ b/examples/developer-guide/using_parameters/mojits/QueryMojit/controller.server.js @@ -4,77 +4,79 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('QueryMojit', function(Y, NAME) { - Y.namespace('mojito.controllers')[NAME] = { - init: function(config) { - this.config = config; - }, - index: function(actionContext) { - actionContext.done('Mojito is working.'); - }, - // Read from query string - // e.g. GET /example1?foo=bar - example1: function(actionContext) { - var params = actionContext.params.url(), - paramsArray = []; - Y.Object.each(params, function(param, key) { - paramsArray.push({key: key, value: param}); - }); - actionContext.done( - { - title: "Show all query string parameters", - params: paramsArray - }, - {name: 'index'} - ); - }, - // Read parameters from POST body - // e.g. POST /example2 with POST body - example2: function(actionContext) { - var params = actionContext.params.body(), - paramsArray = []; - Y.Object.each(params, function(param, key) { - paramsArray.push({key: key, value: param}); - }); - actionContext.done( - { - title: "Show all POST parameters", - params: paramsArray - }, - {name: 'index'} - ); - }, - // Read parameters from routing system - example3: function(actionContext) { - var params = actionContext.params.route(), - paramsArray = []; - Y.Object.each(params, function(param, key) { - paramsArray.push({key: key, value: param}); - }); - actionContext.done( - { - title: "Show all ROUTING parameters (see routes.json)", - params: paramsArray - }, - { name: 'index'} - ); - }, - // Read the merged map created by Mojito - // of all input parameters from URL query string (GET), // the POST body, and any routing parameters - // that may have been attached during routing lookup // Priority of merging is : Route -> GET -> POST\ - example4: function(actionContext) { - var params = actionContext.params.merged(), - paramsArray = []; - Y.Object.each(params, function(param, key) { - paramsArray.push({key: key, value: param}); - }); - actionContext.done( - { - title: "Show all ROUTING parameters (see routes.json)", - params: paramsArray - }, - {name: 'index'} - ); - } -}; +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('QueryMojit', function (Y, NAME) { + Y.namespace('mojito.controllers')[NAME] = { + init: function(config) { + this.config = config; + }, + index: function (actionContext) { + actionContext.done('Mojito is working.'); + }, + // Read from query string + // e.g. GET /example1?foo=bar + example1: function (actionContext) { + var params = actionContext.params.url(), + paramsArray = []; + Y.Object.each(params, function(param, key) { + paramsArray.push({key: key, value: param}); + }); + actionContext.done( + { + title: "Show all query string parameters", + params: paramsArray + }, + {name: 'index'} + ); + }, + // Read parameters from POST body + // e.g. POST /example2 with POST body + example2: function (actionContext) { + var params = actionContext.params.body(), + paramsArray = []; + Y.Object.each(params, function(param, key) { + paramsArray.push({key: key, value: param}); + }); + actionContext.done( + { + title: "Show all POST parameters", + params: paramsArray + }, + {name: 'index'} + ); + }, + // Read parameters from routing system + example3: function (actionContext) { + var params = actionContext.params.route(), + paramsArray = []; + Y.Object.each(params, function(param, key) { + paramsArray.push({key: key, value: param}); + }); + actionContext.done( + { + title: "Show all ROUTING parameters (see routes.json)", + params: paramsArray + }, + { name: 'index'} + ); + }, + // Read the merged map created by Mojito + // of all input parameters from URL query string (GET), // the POST body, and any routing parameters + // that may have been attached during routing lookup // Priority of merging is : Route -> GET -> POST\ + example4: function (actionContext) { + var params = actionContext.params.merged(), + paramsArray = []; + Y.Object.each(params, function(param, key) { + paramsArray.push({key: key, value: param}); + }); + actionContext.done( + { + title: "Show all ROUTING parameters (see routes.json)", + params: paramsArray + }, + {name: 'index'} + ); + } + }; }, '0.0.1', {requires: ['dump']}); diff --git a/examples/developer-guide/using_parameters/mojits/QueryMojit/models/model.server.js b/examples/developer-guide/using_parameters/mojits/QueryMojit/models/model.server.js index e71c8f228..7d299d394 100644 --- a/examples/developer-guide/using_parameters/mojits/QueryMojit/models/model.server.js +++ b/examples/developer-guide/using_parameters/mojits/QueryMojit/models/model.server.js @@ -4,7 +4,9 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('QueryMojitModel', function(Y) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('QueryMojitModel', function (Y) { /** * The QueryMojitModel module. @@ -20,7 +22,7 @@ YUI.add('QueryMojitModel', function(Y) { */ Y.mojito.models.QueryMojit = { - init: function(config) { + init: function (config) { this.config = config; }, @@ -30,8 +32,8 @@ YUI.add('QueryMojitModel', function(Y) { * @param callback {Function} The callback function to call when the * data has been retrieved. */ - getData: function(callback) { - callback({some:'data'}); + getData: function (callback) { + callback({some: 'data'}); } }; diff --git a/examples/developer-guide/yui_module/autoload/storage-lite.client.js b/examples/developer-guide/yui_module/autoload/storage-lite.client.js index d311657a7..665dc62eb 100644 --- a/examples/developer-guide/yui_module/autoload/storage-lite.client.js +++ b/examples/developer-guide/yui_module/autoload/storage-lite.client.js @@ -5,7 +5,7 @@ */ /*global YUI */ -/*jslint onevar: true, browser: true, undef: true, bitwise: true, regexp: true, newcap: true, immed: true */ +/*jslint anon:true, sloppy:true, nomen:true*/ /** * Implements a persistent local key/value data store similar to HTML5's @@ -17,307 +17,308 @@ YUI.add('gallery-storage-lite', function (Y) { -// -- Shorthand ---------------------------------------------------------------- -var d = Y.config.doc, - w = Y.config.win, - StorageLite = Y.namespace('StorageLite'), - -// -- Private Constants -------------------------------------------------------- -DB_NAME = 'yui_storage_lite', -DB_DISPLAYNAME = 'YUI StorageLite data', -DB_MAXSIZE = 1048576, -DB_VERSION = '1.0', - -EVT_READY = 'ready', - -MODE_NOOP = 0, -MODE_HTML5 = 1, -MODE_GECKO = 2, -MODE_DB = 3, -MODE_USERDATA = 4, - -USERDATA_PATH = 'yui_storage_lite', -USERDATA_NAME = 'data', - -// -- Private Variables -------------------------------------------------------- -data = {}, -storageDriver, -storageMode; - -// -- Implementation ----------------------------------------------------------- - -// Determine the best available storage mode. -if (w.localStorage) { - storageMode = MODE_HTML5; -} else if (w.globalStorage) { - storageMode = MODE_GECKO; -} else if (w.openDatabase && navigator.userAgent.indexOf('Chrome') === -1) { - storageMode = MODE_DB; -} else if (Y.UA.ie >= 5) { - storageMode = MODE_USERDATA; -} else { - storageMode = MODE_NOOP; -} - -Y.StorageFullError = function (message) { - Y.StorageFullError.superclass.constructor.call(message); - - this.name = 'StorageFullError'; - this.message = message || 'Maximum storage capacity reached'; - - if (Y.UA.ie) { - this.description = this.message; + // -- Shorthand ---------------------------------------------------------------- + var d = Y.config.doc, + w = Y.config.win, + StorageLite = Y.namespace('StorageLite'), + + // -- Private Constants -------------------------------------------------------- + DB_NAME = 'yui_storage_lite', + DB_DISPLAYNAME = 'YUI StorageLite data', + DB_MAXSIZE = 1048576, + DB_VERSION = '1.0', + + EVT_READY = 'ready', + + MODE_NOOP = 0, + MODE_HTML5 = 1, + MODE_GECKO = 2, + MODE_DB = 3, + MODE_USERDATA = 4, + + USERDATA_PATH = 'yui_storage_lite', + USERDATA_NAME = 'data', + + // -- Private Variables -------------------------------------------------------- + data = {}, + storageDriver, + storageMode; + + // -- Implementation ----------------------------------------------------------- + + // Determine the best available storage mode. + if (w.localStorage) { + storageMode = MODE_HTML5; + } else if (w.globalStorage) { + storageMode = MODE_GECKO; + } else if (w.openDatabase && navigator.userAgent.indexOf('Chrome') === -1) { + storageMode = MODE_DB; + } else if (Y.UA.ie >= 5) { + storageMode = MODE_USERDATA; + } else { + storageMode = MODE_NOOP; } -}; -Y.extend(Y.StorageFullError, Error); + Y.StorageFullError = function (message) { + Y.StorageFullError.superclass.constructor.call(message); -/** - * Provides a persistent local key/value data store similar to HTML5's - * localStorage. - * - * @class StorageLite - * @static - */ + this.name = 'StorageFullError'; + this.message = message || 'Maximum storage capacity reached'; -// -- Public Events ------------------------------------------------------------ -Y.augment(StorageLite, Y.EventTarget, true, null, { - emitFacade : true, - prefix : 'storage-lite', - preventable: false -}); - -/** - * Fired when the storage interface is loaded and ready for use. - * - * @event storage-lite:ready - */ -StorageLite.publish(EVT_READY, {fireOnce: true}); + if (Y.UA.ie) { + this.description = this.message; + } + }; -Y.mix(StorageLite, { - // -- Public Methods ------------------------------------------------------- + Y.extend(Y.StorageFullError, Error); /** - * Removes all items from the data store. + * Provides a persistent local key/value data store similar to HTML5's + * localStorage. * - * @method clear + * @class StorageLite + * @static */ - clear: function () {}, - /** - * Returns the item with the specified key, or null if the item - * was not found. - * - * @method getItem - * @param {String} key - * @param {bool} json (optional) true if the item is a JSON - * string and should be parsed before being returned - * @return {Object|null} item or null if not found - */ - getItem: function (key, json) { return null; }, + // -- Public Events ------------------------------------------------------------ + Y.augment(StorageLite, Y.EventTarget, true, null, { + emitFacade : true, + prefix : 'storage-lite', + preventable: false + }); /** - * Returns the number of items in the data store. + * Fired when the storage interface is loaded and ready for use. * - * @method length - * @return {Number} number of items in the data store + * @event storage-lite:ready */ - length: function () { return 0; }, + StorageLite.publish(EVT_READY, {fireOnce: true}); - /** - * Removes the item with the specified key. - * - * @method removeItem - * @param {String} key - */ - removeItem: function (key) {}, + Y.mix(StorageLite, { + // -- Public Methods ------------------------------------------------------- + + /** + * Removes all items from the data store. + * + * @method clear + */ + clear: function () {}, + + /** + * Returns the item with the specified key, or null if the item + * was not found. + * + * @method getItem + * @param {String} key + * @param {bool} json (optional) true if the item is a JSON + * string and should be parsed before being returned + * @return {Object|null} item or null if not found + */ + getItem: function (key, json) { return null; }, + + /** + * Returns the number of items in the data store. + * + * @method length + * @return {Number} number of items in the data store + */ + length: function () { return 0; }, + + /** + * Removes the item with the specified key. + * + * @method removeItem + * @param {String} key + */ + removeItem: function (key) {}, + + /** + * Stores an item under the specified key. If the key already exists in the + * data store, it will be replaced. + * + * @method setItem + * @param {String} key + * @param {Object} value + * @param {bool} json (optional) true if the item should be + * serialized to a JSON string before being stored + */ + setItem: function (key, value) {} + + }); + + if (storageMode === MODE_HTML5 || storageMode === MODE_GECKO) { + + // Common methods shared by the HTML5 and Gecko implementations. + Y.mix(StorageLite, { + length: function () { + return storageDriver.length; + }, - /** - * Stores an item under the specified key. If the key already exists in the - * data store, it will be replaced. - * - * @method setItem - * @param {String} key - * @param {Object} value - * @param {bool} json (optional) true if the item should be - * serialized to a JSON string before being stored - */ - setItem: function (key, value) {} + removeItem: function (key) { + storageDriver.removeItem(key); + }, -}); + setItem: function (key, value, json) { + storageDriver.setItem(key, json ? Y.JSON.stringify(value) : value); + } + }, true); -if (storageMode === MODE_HTML5 || storageMode === MODE_GECKO) { + if (storageMode === MODE_HTML5) { - // Common methods shared by the HTML5 and Gecko implementations. - Y.mix(StorageLite, { - length: function () { - return storageDriver.length; - }, + // HTML5 localStorage methods. Currently supported by IE8, Firefox 3.5+, + // Safari 4+, Chrome 4+, and Opera 10.5+. + storageDriver = w.localStorage; - removeItem: function (key) { - storageDriver.removeItem(key); - }, + Y.mix(StorageLite, { + clear: function () { + storageDriver.clear(); + }, - setItem: function (key, value, json) { - storageDriver.setItem(key, json ? Y.JSON.stringify(value) : value); - } - }, true); + getItem: function (key, json) { + try { + return json ? Y.JSON.parse(storageDriver.getItem(key)) : + storageDriver.getItem(key); + } catch (ex) { + return null; + } + } + }, true); - if (storageMode === MODE_HTML5) { + } else if (storageMode === MODE_GECKO) { - // HTML5 localStorage methods. Currently supported by IE8, Firefox 3.5+, - // Safari 4+, Chrome 4+, and Opera 10.5+. - storageDriver = w.localStorage; + // Gecko globalStorage methods. Supported by Firefox 2 and 3.0. + storageDriver = w.globalStorage[w.location.hostname]; - Y.mix(StorageLite, { - clear: function () { - storageDriver.clear(); - }, + Y.mix(StorageLite, { + clear: function () { + var key; + for (key in storageDriver) { + if (storageDriver.hasOwnProperty(key)) { + storageDriver.removeItem(key); + delete storageDriver[key]; + } + } + }, - getItem: function (key, json) { - try { - return json ? Y.JSON.parse(storageDriver.getItem(key)) : - storageDriver.getItem(key); - } catch (ex) { - return null; + getItem: function (key, json) { + try { + return json ? Y.JSON.parse(storageDriver[key].value) : + storageDriver[key].value; + } catch (ex) { + return null; + } } - } - }, true); + }, true); - } else if (storageMode === MODE_GECKO) { + } - // Gecko globalStorage methods. Supported by Firefox 2 and 3.0. - storageDriver = w.globalStorage[w.location.hostname]; + StorageLite.fire(EVT_READY); + } else if (storageMode === MODE_DB || storageMode === MODE_USERDATA) { + + // Common methods shared by the database and userdata implementations. Y.mix(StorageLite, { clear: function () { - for (var key in storageDriver) { - if (storageDriver.hasOwnProperty(key)) { - storageDriver.removeItem(key); - delete storageDriver[key]; - } - } + data = {}; + StorageLite._save(); }, getItem: function (key, json) { - try { - return json ? Y.JSON.parse(storageDriver[key].value) : - storageDriver[key].value; - } catch (ex) { - return null; - } - } - }, true); - - } - - StorageLite.fire(EVT_READY); + return data.hasOwnProperty(key) ? data[key] : null; + }, -} else if (storageMode === MODE_DB || storageMode === MODE_USERDATA) { + length: function () { + var count = 0, key; - // Common methods shared by the database and userdata implementations. - Y.mix(StorageLite, { - clear: function () { - data = {}; - StorageLite._save(); - }, + for (key in data) { + if (data.hasOwnProperty(key)) { + count += 1; + } + } - getItem: function (key, json) { - return data.hasOwnProperty(key) ? data[key] : null; - }, + return count; + }, - length: function () { - var count = 0, key; + removeItem: function (key) { + delete data[key]; + StorageLite._save(); + }, - for (key in data) { - if (data.hasOwnProperty(key)) { - count += 1; - } + setItem: function (key, value, json) { + data[key] = value; + StorageLite._save(); } - return count; - }, + }, true); - removeItem: function (key) { - delete data[key]; - StorageLite._save(); - }, + if (storageMode === MODE_DB) { - setItem: function (key, value, json) { - data[key] = value; - StorageLite._save(); - } + // Database storage methods. Supported by Safari 3.1 and 3.2. + storageDriver = w.openDatabase(DB_NAME, DB_VERSION, DB_DISPLAYNAME, DB_MAXSIZE); - }, true); + Y.mix(StorageLite, { + _save: function () { + storageDriver.transaction(function (t) { + t.executeSql("REPLACE INTO " + DB_NAME + " (name, value) VALUES ('data', ?)", [Y.JSON.stringify(data)]); + }); + } + }, true); + + storageDriver.transaction(function (t) { + t.executeSql("CREATE TABLE IF NOT EXISTS " + DB_NAME + "(name TEXT PRIMARY KEY, value TEXT NOT NULL)"); + t.executeSql("SELECT value FROM " + DB_NAME + " WHERE name = 'data'", [], function (t, results) { + if (results.rows.length) { + try { + data = Y.JSON.parse(results.rows.item(0).value); + } catch (ex) { + data = {}; + } + } - if (storageMode === MODE_DB) { + StorageLite.fire(EVT_READY); + }); + }); - // Database storage methods. Supported by Safari 3.1 and 3.2. - storageDriver = w.openDatabase(DB_NAME, DB_VERSION, DB_DISPLAYNAME, DB_MAXSIZE); + } else if (storageMode === MODE_USERDATA) { - Y.mix(StorageLite, { - _save: function () { - storageDriver.transaction(function (t) { - t.executeSql("REPLACE INTO " + DB_NAME + " (name, value) VALUES ('data', ?)", [Y.JSON.stringify(data)]); - }); - } - }, true); + // userData storage methods. Supported by IE5, 6, and 7. + storageDriver = d.createElement('span'); + storageDriver.addBehavior('#default#userData'); + + Y.mix(StorageLite, { + _save: function () { + var mydata = Y.JSON.stringify(data); - storageDriver.transaction(function (t) { - t.executeSql("CREATE TABLE IF NOT EXISTS " + DB_NAME + "(name TEXT PRIMARY KEY, value TEXT NOT NULL)"); - t.executeSql("SELECT value FROM " + DB_NAME + " WHERE name = 'data'", [], function (t, results) { - if (results.rows.length) { try { - data = Y.JSON.parse(results.rows.item(0).value); + storageDriver.setAttribute(USERDATA_NAME, mydata); + storageDriver.save(USERDATA_PATH); } catch (ex) { - data = {}; + throw new Y.StorageFullError(); } } + }, true); - StorageLite.fire(EVT_READY); - }); - }); - - } else if (storageMode === MODE_USERDATA) { - - // userData storage methods. Supported by IE5, 6, and 7. - storageDriver = d.createElement('span'); - storageDriver.addBehavior('#default#userData'); - - Y.mix(StorageLite, { - _save: function () { - var _data = Y.JSON.stringify(data); + Y.on('domready', function () { + d.body.appendChild(storageDriver); + storageDriver.load(USERDATA_PATH); try { - storageDriver.setAttribute(USERDATA_NAME, _data); - storageDriver.save(USERDATA_PATH); + data = Y.JSON.parse(storageDriver.getAttribute(USERDATA_NAME) || '{}'); } catch (ex) { - throw new Y.StorageFullError(); + data = {}; } - } - }, true); - - Y.on('domready', function () { - d.body.appendChild(storageDriver); - storageDriver.load(USERDATA_PATH); - - try { - data = Y.JSON.parse(storageDriver.getAttribute(USERDATA_NAME) || '{}'); - } catch (ex) { - data = {}; - } - StorageLite.fire(EVT_READY); - }); + StorageLite.fire(EVT_READY); + }); - } + } -} else { + } else { - // Fire the ready event for browsers that only support the noop mode. - StorageLite.fire(EVT_READY); + // Fire the ready event for browsers that only support the noop mode. + StorageLite.fire(EVT_READY); -} + } }, '1.0.0', { requires: ['event-base', 'event-custom', 'event-custom-complex', 'json'] diff --git a/examples/developer-guide/yui_module/mojits/Notepad/binders/index.js b/examples/developer-guide/yui_module/mojits/Notepad/binders/index.js index 94452800a..44b89143f 100644 --- a/examples/developer-guide/yui_module/mojits/Notepad/binders/index.js +++ b/examples/developer-guide/yui_module/mojits/Notepad/binders/index.js @@ -4,11 +4,13 @@ * See the accompanying LICENSE file for terms. */ +/*jslint anon:true, sloppy:true, nomen:true*/ + YUI.add('NotepadBinderIndex', function (Y, NAME) { Y.namespace('mojito.binders')[NAME] = { - init: function(mojitProxy) { + init: function (mojitProxy) { this.mp = mojitProxy; }, @@ -16,7 +18,7 @@ YUI.add('NotepadBinderIndex', function (Y, NAME) { * @method bind * @param {Node} YUI Node */ - bind: function(node) { + bind: function (node) { // Based on http://yuilibrary.com/gallery/show/storage-lite var keyname = 'storage-lite-example', @@ -26,7 +28,7 @@ YUI.add('NotepadBinderIndex', function (Y, NAME) { notes.set('value', Y.StorageLite.getItem(keyname) || ''); // Save the contents of the textarea after each keystroke. - notes.on('keyup', function() { + notes.on('keyup', function () { Y.StorageLite.setItem(keyname, notes.get('value')); }); diff --git a/examples/developer-guide/yui_module/mojits/Notepad/controller.server.js b/examples/developer-guide/yui_module/mojits/Notepad/controller.server.js index b5bd9ba09..9347339f9 100644 --- a/examples/developer-guide/yui_module/mojits/Notepad/controller.server.js +++ b/examples/developer-guide/yui_module/mojits/Notepad/controller.server.js @@ -4,11 +4,13 @@ * See the accompanying LICENSE file for terms. */ -YUI.add('Notepad', function(Y, NAME) { +/*jslint anon:true, sloppy:true, nomen:true*/ + +YUI.add('Notepad', function (Y, NAME) { Y.namespace('mojito.controllers')[NAME] = { - index: function(ac) { + index: function (ac) { ac.done(); }