This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// movies/movie-lister.js | |
var MovieLister = function(movieFinder) { | |
this.movieFinder = movieFinder; | |
}; | |
MovieLister.prototype.showMovies = function(query) { | |
var keywords = query.split(" "); | |
var movieResult = this.movieFinder.getMovies(keywords); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// movies/move-finder.js | |
define(["jquery"], function($) { | |
var MovieFinder = function() { | |
var self = this; | |
$(document).on("click", ".open-prefs", function() { | |
self.openPreferences(); | |
}); | |
}; | |
MovieFinder.prototype.openPreferences = function() { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app-config.js | |
define(function() { | |
return { | |
protos: { | |
movieLister: { | |
module: "movies/movie-lister", | |
args: [ | |
//injects a json movie finder which must implement the movieFinder interface | |
"*jsonMovieFinder [movieFinder]" | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app-config.js | |
define(function() { | |
return { | |
protos: { | |
movieLister: { | |
module: "movies/movie-lister", | |
args: [ | |
"*movieFinder" | |
] | |
mixin: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mixed.js | |
define(function() { | |
var Mixed = function(a, b) { | |
this.a = a; | |
this.b = b; | |
}; | |
Mixed.prototype.getA = function() { | |
return this.a; | |
}; | |
Mixed.prototype.getB = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//microdata polyfill (see https://github.com/termi/Microdata-JS) | |
casper.options.clientScripts.push("../../../support/a.js"); | |
casper.options.clientScripts.push("../../../support/microdata-js.js"); | |
/** | |
* Fetches microdata from the remote DOM environment, in a json object structure. | |
* @param itemType The item type of item scopes to fetch data for | |
* @returns {Object|mixed} | |
*/ | |
casper.fetchMicrodata = function(itemType) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Asserts a microdata item value matches the given expected value in the remote DOM environment | |
* Depends on the casper.fetchMicrodata method | |
* | |
* @param itemType {String} The item type of the item scopes to look for properties in | |
* @param property {String} The name of the property the compare the expected value against | |
* @param expectedItemValue {String} The expected value of the item property | |
* @param message {String} The assertion message | |
* @param itemTypeIndex {Number} A specific index of an item scope to use. If omitted or null, will look for matches in | |
* all item scopes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//little util to do tidier directory concatenation | |
function dir() { | |
var args = Array.prototype.slice.call(arguments); | |
var prefix = ""; | |
if(args[0] === "!") { | |
prefix = args[0]; | |
args.shift(); | |
} | |
return prefix + args.join("/"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var items = [{ | |
html: '<p>One</p>' | |
}, { | |
html: '<p>Two</p>' | |
}, { | |
html: '<p>Three</p>' | |
}]; | |
var html = items.reduce(function(html, item) { | |
html.push(item.html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require('casper').create({ | |
verbose: true, | |
logLevel: 'info' | |
}); | |
var page = require('webpage').create(); | |
var utils = require('utils'); | |
//args | |
var base = casper.cli.get('out'); | |
var width = parseInt(casper.cli.get("width")); |