mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge from master + added more jshint checks (undef and latedef). Very helpful to catch post merge issues.
This commit is contained in:
24
Gruntfile.js
24
Gruntfile.js
@ -19,6 +19,14 @@ module.exports = function(grunt) {
|
|||||||
"smarttabs": true,
|
"smarttabs": true,
|
||||||
"eqnull": 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: [
|
files: [
|
||||||
'Gruntfile.js',
|
'Gruntfile.js',
|
||||||
'package.json',
|
'package.json',
|
||||||
@ -39,8 +47,7 @@ module.exports = function(grunt) {
|
|||||||
filesSrc: ['tests/integration/casperjs/*_test.js'],
|
filesSrc: ['tests/integration/casperjs/*_test.js'],
|
||||||
options: {
|
options: {
|
||||||
args: {
|
args: {
|
||||||
baseUrl: 'http://localhost:' +
|
baseUrl: 'http://localhost:' + '<%= connect.www.options.port %>/'
|
||||||
'<%= connect.www.options.port %>/'
|
|
||||||
},
|
},
|
||||||
direct: false,
|
direct: false,
|
||||||
logLevel: 'error',
|
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-connect');
|
||||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
grunt.loadNpmTasks('grunt-ghost');
|
grunt.loadNpmTasks('grunt-ghost');
|
||||||
|
|
||||||
|
grunt.registerTask('check-indent', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles']);
|
||||||
grunt.registerTask('lint', ['jshint']);
|
grunt.registerTask('lint', ['jshint']);
|
||||||
grunt.registerTask('test', ['jshint', 'connect', 'ghost']);
|
grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'connect', 'ghost']);
|
||||||
};
|
};
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
|
|
||||||
$.publish(Events.TOOL_RELEASED);
|
$.publish(Events.TOOL_RELEASED);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -196,7 +196,7 @@
|
|||||||
evtInfo.button = Constants.RIGHT_BUTTON;
|
evtInfo.button = Constants.RIGHT_BUTTON;
|
||||||
}
|
}
|
||||||
return evtInfo;
|
return evtInfo;
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
ns.ToolController.prototype.init = function() {
|
ns.ToolController.prototype.init = function() {
|
||||||
|
|
||||||
this.createToolMarkup_();
|
this.createToolMarkup_();
|
||||||
|
|
||||||
// Initialize tool:
|
// Initialize tool:
|
||||||
@ -67,16 +66,25 @@
|
|||||||
var clickedTool = target.closest(".tool-icon");
|
var clickedTool = target.closest(".tool-icon");
|
||||||
|
|
||||||
if(clickedTool.length) {
|
if(clickedTool.length) {
|
||||||
for(var tool in this.toolInstances) {
|
var toolId = clickedTool.data().toolId;
|
||||||
if (this.toolInstances[tool].toolId == clickedTool.data().toolId) {
|
var tool = this.getToolById_(toolId);
|
||||||
this.selectTool_(this.toolInstances[tool]);
|
if (tool) {
|
||||||
|
this.selectTool_(tool);
|
||||||
|
|
||||||
// Show tool as selected:
|
// Show tool as selected:
|
||||||
$('#tool-section .tool-icon.selected').removeClass('selected');
|
$('#tool-section .tool-icon.selected').removeClass('selected');
|
||||||
clickedTool.addClass('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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @require Constants
|
* @require Constants
|
||||||
* @require pskl.utils
|
* @require pskl.utils
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
var ns = $.namespace("pskl.drawingtools");
|
var ns = $.namespace("pskl.drawingtools");
|
||||||
|
|
||||||
ns.Eraser = function() {
|
ns.Eraser = function() {
|
||||||
|
@ -63,7 +63,6 @@
|
|||||||
*/
|
*/
|
||||||
ns.BaseSelect.prototype.releaseToolAt = function(col, row, color, frame, overlay) {
|
ns.BaseSelect.prototype.releaseToolAt = function(col, row, color, frame, overlay) {
|
||||||
if(this.mode == "select") {
|
if(this.mode == "select") {
|
||||||
|
|
||||||
this.onSelectEnd_(col, row, color, frame, overlay);
|
this.onSelectEnd_(col, row, color, frame, overlay);
|
||||||
} else if(this.mode == "moveSelection") {
|
} else if(this.mode == "moveSelection") {
|
||||||
|
|
||||||
@ -136,6 +135,7 @@
|
|||||||
// we clone it to have a reference for the later shifting process.
|
// we clone it to have a reference for the later shifting process.
|
||||||
this.overlayFrameReference = overlay.clone();
|
this.overlayFrameReference = overlay.clone();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @private */
|
/** @private */
|
||||||
ns.BaseSelect.prototype.onSelectionDrag_ = function (col, row, color, frame, overlay) {
|
ns.BaseSelect.prototype.onSelectionDrag_ = function (col, row, color, frame, overlay) {
|
||||||
var deltaCol = col - this.lastCol;
|
var deltaCol = col - this.lastCol;
|
||||||
@ -152,10 +152,9 @@
|
|||||||
this.lastCol = col;
|
this.lastCol = col;
|
||||||
this.lastRow = row;
|
this.lastRow = row;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @private */
|
/** @private */
|
||||||
ns.BaseSelect.prototype.onSelectionDragEnd_ = function (col, row, color, frame, overlay) {
|
ns.BaseSelect.prototype.onSelectionDragEnd_ = function (col, row, color, frame, overlay) {
|
||||||
this.onSelectionDrag_(col, row, color, frame, overlay);
|
this.onSelectionDrag_(col, row, color, frame, overlay);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
pskl.utils.inherit(ns.ShapeSelect, ns.BaseSelect);
|
pskl.utils.inherit(ns.ShapeSelect, ns.BaseSelect);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For the shape select tool, you just need to click one time to create a selection.
|
* 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_)
|
* So we jsut need to implement onSelectStart_ (no need for onSelect_ & onSelectEnd_)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
//import flash.net.URLRequest;
|
//import flash.net.URLRequest;
|
||||||
//import flash.net.navigateToURL;
|
//import flash.net.navigateToURL;
|
||||||
|
|
||||||
GIFEncoder = function()
|
window.GIFEncoder = function()
|
||||||
{
|
{
|
||||||
for(var i = 0, chr = {}; i < 256; i++)
|
for(var i = 0, chr = {}; i < 256; i++)
|
||||||
chr[i] = String.fromCharCode(i);
|
chr[i] = String.fromCharCode(i);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function encode64(input) {
|
window.encode64(input) {
|
||||||
var output = "", i = 0, l = input.length,
|
var output = "", i = 0, l = input.length,
|
||||||
key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
||||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
for (i=0;i<params.length;i++) {
|
for (i=0;i<params.length;i++) {
|
||||||
val = params[i].split("=");
|
val = params[i].split("=");
|
||||||
if (val[0] == paramName) {
|
if (val[0] == paramName) {
|
||||||
return unescape(val[1]);
|
return window.unescape(val[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.SpritesheetRenderer.prototype.renderAsImageDataAnimatedGIF = function (fps) {
|
ns.SpritesheetRenderer.prototype.renderAsImageDataAnimatedGIF = function (fps) {
|
||||||
var encoder = new GIFEncoder(), dpi = 10;
|
var encoder = new window.GIFEncoder(), dpi = 10;
|
||||||
encoder.setRepeat(0);
|
encoder.setRepeat(0);
|
||||||
encoder.setDelay(1000/fps);
|
encoder.setDelay(1000/fps);
|
||||||
|
|
||||||
@ -29,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
encoder.finish();
|
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;
|
return imageData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace("pskl.selection");
|
var ns = $.namespace("pskl.selection");
|
||||||
|
|
||||||
|
|
||||||
ns.SelectionManager = function (framesheet) {
|
ns.SelectionManager = function (framesheet) {
|
||||||
|
|
||||||
this.framesheet = framesheet;
|
this.framesheet = framesheet;
|
||||||
|
@ -41,8 +41,10 @@
|
|||||||
*/
|
*/
|
||||||
getOrderedRectangleCoordinates : function (x0, y0, x1, y1) {
|
getOrderedRectangleCoordinates : function (x0, y0, x1, y1) {
|
||||||
return {
|
return {
|
||||||
x0 : Math.min(x0, x1), y0 : Math.min(y0, y1),
|
x0 : Math.min(x0, x1),
|
||||||
x1 : Math.max(x0, x1), y1 : Math.max(y0, y1),
|
y0 : Math.min(y0, y1),
|
||||||
|
x1 : Math.max(x0, x1),
|
||||||
|
y1 : Math.max(y0, y1),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"grunt": "~0.4.1",
|
"grunt": "~0.4.1",
|
||||||
"grunt-contrib-connect": "0.3.0",
|
"grunt-contrib-connect": "0.3.0",
|
||||||
"grunt-contrib-jshint": "0.5.4",
|
"grunt-contrib-jshint": "0.5.4",
|
||||||
"grunt-ghost": "1.0.12"
|
"grunt-ghost": "1.0.12",
|
||||||
|
"grunt-leading-indent" : "0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user