Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ components/
bower_components/
node_modules/
sandbox/**/bundle.js
.build*
29 changes: 29 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,37 @@ module.exports = function( grunt ) {
banner: banner
}
}
},

exec: {
'meteor-init': {
command: [
// Make sure Meteor is installed, per https://meteor.com/install.
// The curl'ed script is safe; takes 2 minutes to read source & check.
'type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }',
// Meteor expects package.js to be in the root directory of
// the checkout, so copy it there temporarily
'cp meteor/package.js .'
].join(';')
},
'meteor-cleanup': {
// remove build files and package.js
command: 'rm -rf .build.* versions.json package.js'
},
'meteor-test': {
command: 'spacejam --mongo-url mongodb:// test-packages ./'
},
'meteor-publish': {
command: 'meteor publish'
}
}

});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-requirejs');
grunt.loadNpmTasks('grunt-exec');

grunt.registerTask( 'pkgd-edit', function() {
var outFile = grunt.config.get('requirejs.pkgd.options.out');
Expand All @@ -77,6 +101,11 @@ module.exports = function( grunt ) {
grunt.log.writeln( 'Edited ' + outFile );
});

// Meteor tasks
grunt.registerTask('meteor-test', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-cleanup']);
grunt.registerTask('meteor-publish', ['exec:meteor-init', 'exec:meteor-publish', 'exec:meteor-cleanup']);
grunt.registerTask('meteor', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-publish', 'exec:meteor-cleanup']);

grunt.registerTask( 'default', [
'jshint',
'requirejs',
Expand Down
25 changes: 25 additions & 0 deletions meteor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Packaging [Isotope](http://isotope.metafizzy.co/) for [Meteor.js](http://meteor.com).


# Meteor

If you're new to Meteor, here's what the excitement is all about -
[watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28.

That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web
development framework. Read more at [Why Meteor](http://www.meteorpedia.com/read/Why_Meteor).


# Issues

If you encounter an issue while using this package, please CC @dandv when you file it in this repo.


# DONE

* Automated and visual test for the fitRows layout


# TODO

* Add other tests; however, that is overkill, and the responsibiity of Isotope, not of the Meteor integration.
3 changes: 3 additions & 0 deletions meteor/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*global Isotope:true*/ // Meteor.js creates a file-scope global for exporting. This comment prevents a potential JSHint warning.
Isotope = window.Isotope;
delete window.Isotope;
33 changes: 33 additions & 0 deletions meteor/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// package metadata file for Meteor.js
'use strict';

var packageName = 'isotope:isotope'; // http://atmospherejs.com/isotope/isotope
var where = 'client'; // where to install: 'client' or 'server'. For both, pass nothing.

var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json'));

Package.describe({
name: packageName,
summary: 'Isotope (official): filter and sort magical layouts: fit rows, packery, masonry, fit columns etc.', // limited to 100 characters
version: packageJson.version,
git: 'https://github.com/metafizzy/isotope.git'
});

Package.onUse(function (api) {
api.versionsFrom(['[email protected]', '[email protected]']);
api.export('Isotope');
api.addFiles([
'dist/isotope.pkgd.js',
'meteor/export.js'
], where);
});

Package.onTest(function (api) {
api.use(packageName, where);
api.use(['tinytest', 'http'], where);

api.addFiles([
'test/tests.css',
'meteor/test.js'
], where);
});
58 changes: 58 additions & 0 deletions meteor/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

Tinytest.addAsync('Isotope - fitRows', function (test, done) {
var isotopeDropZone = document.createElement('div');
document.body.appendChild(isotopeDropZone);

// TODO ideally we'd get the htmls straight from this repo, but no idea how to do this from TinyTest - http://stackoverflow.com/questions/27180892/pull-an-html-file-into-a-tinytest
HTTP.get('http://rawgit.com/metafizzy/isotope/master/test/index.html', function callback(error, result) {

// adapted from test/fit-rows.js
function checkPosition(item, x, y) {
var elem = item.element;
var left = parseInt(elem.style.left, 10);
var top = parseInt(elem.style.top, 10);
test.equal([ left, top ], [ x, y ], 'item position ' + x + ', ' + y);
}

if (error) {
test.fail({message: 'Error getting the test file. Do we have an Internet connection to rawgit.com?'});
} else {
// [^] matches across newlines. Stay within the <body>, or else the fragment will attempt to load resources on its own.
isotopeDropZone.innerHTML = result.content.match(/<h2>fitRows[^]+<\/div>/);

test.ok({message: 'Visual test passed if the fitRows look like two towers, and failed if they look like a rotated L'});

var iso = new Isotope('#fitrows-gutter', {
layoutMode: 'fitRows',
itemSelector: '.item',
transitionDuration: 0
});

checkPosition(iso.items[0], 0, 0);
checkPosition(iso.items[1], 60, 0);

// check gutter
iso.options.fitRows = {
gutter: 10
};
iso.layout();

checkPosition(iso.items[0], 0, 0);
checkPosition(iso.items[1], 70, 0);

// check gutter, with element sizing
iso.options.fitRows = {
gutter: '.gutter-sizer'
};
iso.layout();

checkPosition(iso.items[0], 0, 0);
checkPosition(iso.items[1], 78, 0);
}

done();

});

});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.4.1",
"grunt-contrib-uglify": "~0.1.1",
"grunt-requirejs": "~0.4.0"
"grunt-requirejs": "~0.4.0",
"grunt-exec": "^0.4.6",
"spacejam": "^1.1.1"
},
"repository": {
"type": "git",
Expand Down