Merge from master + added more jshint checks (undef and latedef). Very helpful to catch post merge issues.

This commit is contained in:
jdescottes
2013-08-10 14:28:10 +02:00
42 changed files with 2240 additions and 2214 deletions

View File

@ -19,6 +19,14 @@ module.exports = function(grunt) {
"smarttabs": true,
"eqnull": true
},*/
options: {
indent:2,
undef : true,
latedef : true,
browser : true,
jquery : true,
globals : {'pskl':true, 'Events':true, 'Constants':true, 'console' : true, 'module':true}
},
files: [
'Gruntfile.js',
'package.json',
@ -39,8 +47,7 @@ module.exports = function(grunt) {
filesSrc: ['tests/integration/casperjs/*_test.js'],
options: {
args: {
baseUrl: 'http://localhost:' +
'<%= connect.www.options.port %>/'
baseUrl: 'http://localhost:' + '<%= connect.www.options.port %>/'
},
direct: false,
logLevel: 'error',
@ -51,10 +58,21 @@ module.exports = function(grunt) {
}
});
grunt.config.set('leadingIndent.indentation', 'spaces');
grunt.config.set('leadingIndent.jsFiles', {
src: ['js/**/*.js','!js/lib/**/*.js']
});
grunt.config.set('leadingIndent.cssFiles', {
src: ['css/**/*.css']
});
grunt.loadNpmTasks('grunt-leading-indent');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-ghost');
grunt.registerTask('check-indent', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles']);
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['jshint', 'connect', 'ghost']);
grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'connect', 'ghost']);
};

View File

@ -183,7 +183,7 @@
$.publish(Events.TOOL_RELEASED);
}
},
};
/**
* @private
@ -196,7 +196,7 @@
evtInfo.button = Constants.RIGHT_BUTTON;
}
return evtInfo;
},
};
/**
* @private

View File

@ -26,7 +26,6 @@
* @public
*/
ns.ToolController.prototype.init = function() {
this.createToolMarkup_();
// Initialize tool:
@ -67,16 +66,25 @@
var clickedTool = target.closest(".tool-icon");
if(clickedTool.length) {
for(var tool in this.toolInstances) {
if (this.toolInstances[tool].toolId == clickedTool.data().toolId) {
this.selectTool_(this.toolInstances[tool]);
var toolId = clickedTool.data().toolId;
var tool = this.getToolById_(toolId);
if (tool) {
this.selectTool_(tool);
// Show tool as selected:
$('#tool-section .tool-icon.selected').removeClass('selected');
clickedTool.addClass('selected');
}
}
};
ns.ToolController.prototype.getToolById_ = function (toolId) {
for(var key in this.toolInstances) {
if (this.toolInstances[key].toolId == toolId) {
return this.toolInstances[key];
}
}
return null;
};
/**

View File

@ -4,7 +4,7 @@
* @require Constants
* @require pskl.utils
*/
(function() {
(function() {
var ns = $.namespace("pskl.drawingtools");
ns.Eraser = function() {

View File

@ -63,7 +63,6 @@
*/
ns.BaseSelect.prototype.releaseToolAt = function(col, row, color, frame, overlay) {
if(this.mode == "select") {
this.onSelectEnd_(col, row, color, frame, overlay);
} else if(this.mode == "moveSelection") {
@ -136,6 +135,7 @@
// we clone it to have a reference for the later shifting process.
this.overlayFrameReference = overlay.clone();
};
/** @private */
ns.BaseSelect.prototype.onSelectionDrag_ = function (col, row, color, frame, overlay) {
var deltaCol = col - this.lastCol;
@ -152,10 +152,9 @@
this.lastCol = col;
this.lastRow = row;
};
/** @private */
ns.BaseSelect.prototype.onSelectionDragEnd_ = function (col, row, color, frame, overlay) {
this.onSelectionDrag_(col, row, color, frame, overlay);
};
})();

View File

@ -15,7 +15,6 @@
pskl.utils.inherit(ns.ShapeSelect, ns.BaseSelect);
/**
* For the shape select tool, you just need to click one time to create a selection.
* So we jsut need to implement onSelectStart_ (no need for onSelect_ & onSelectEnd_)

View File

@ -16,7 +16,7 @@
//import flash.net.URLRequest;
//import flash.net.navigateToURL;
GIFEncoder = function()
window.GIFEncoder = function()
{
for(var i = 0, chr = {}; i < 256; i++)
chr[i] = String.fromCharCode(i);

View File

@ -1,4 +1,4 @@
function encode64(input) {
window.encode64(input) {
var output = "", i = 0, l = input.length,
key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
chr1, chr2, chr3, enc1, enc2, enc3, enc4;

View File

@ -119,7 +119,7 @@
for (i=0;i<params.length;i++) {
val = params[i].split("=");
if (val[0] == paramName) {
return unescape(val[1]);
return window.unescape(val[1]);
}
}
return "";

View File

@ -16,7 +16,7 @@
};
ns.SpritesheetRenderer.prototype.renderAsImageDataAnimatedGIF = function (fps) {
var encoder = new GIFEncoder(), dpi = 10;
var encoder = new window.GIFEncoder(), dpi = 10;
encoder.setRepeat(0);
encoder.setDelay(1000/fps);
@ -29,7 +29,7 @@
}
encoder.finish();
var imageData = 'data:image/gif;base64,' + encode64(encoder.stream().getData());
var imageData = 'data:image/gif;base64,' + window.encode64(encoder.stream().getData());
return imageData;
};

View File

@ -1,7 +1,6 @@
(function () {
var ns = $.namespace("pskl.selection");
ns.SelectionManager = function (framesheet) {
this.framesheet = framesheet;

View File

@ -41,8 +41,10 @@
*/
getOrderedRectangleCoordinates : function (x0, y0, x1, y1) {
return {
x0 : Math.min(x0, x1), y0 : Math.min(y0, y1),
x1 : Math.max(x0, x1), y1 : Math.max(y0, y1),
x0 : Math.min(x0, x1),
y0 : Math.min(y0, y1),
x1 : Math.max(x0, x1),
y1 : Math.max(y0, y1),
};
},

View File

@ -15,6 +15,7 @@
"grunt": "~0.4.1",
"grunt-contrib-connect": "0.3.0",
"grunt-contrib-jshint": "0.5.4",
"grunt-ghost": "1.0.12"
"grunt-ghost": "1.0.12",
"grunt-leading-indent" : "0.1.0"
}
}