From 91bacd1dd9bdd9e96fdb3d846101ad7161b54575 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sun, 4 Aug 2013 18:27:32 +0200 Subject: [PATCH] Added concat and uglify tasks to grunt. Piskel on master will only be able to work in debug mode, by passing ?debug in URL. The minified version is built in /build, which has been added to .gitignore --- .gitignore | 6 +- Gruntfile.js | 105 ++++++++++++++++++------------ all.html | 39 ----------- index.html | 100 ++++++++++------------------ js/lib/jsColor_1_4_0/jscolor.js | 29 +-------- js/piskel.js | 56 ++++++++-------- js/service/LocalStorageService.js | 14 ++-- package.json | 4 +- script-load-list.js | 67 +++++++++++++++++++ 9 files changed, 212 insertions(+), 208 deletions(-) delete mode 100644 all.html create mode 100644 script-load-list.js diff --git a/.gitignore b/.gitignore index b54edf37..b785b0e8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,14 @@ # nodejs local installs node_modules +npm-debug.log # sublime text stuff (the -project should actually be shared, but then we'd have to share the same disk location) *.sublime-project *.sublime-workspace # git stackdumps -*.stackdump \ No newline at end of file +*.stackdump + +# builds +build \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 15a6ad5f..5765de14 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,56 +5,77 @@ * - run a grunt target defined in Gruntfiles.js, ex: 'grunt lint' * * Note: The 'ghost' grunt task have special deps on CasperJS and phantomjs. - * For now, It's configured to run only on TravisCI where these deps are + * For now, It's configured to run only on TravisCI where these deps are * correctly defined. - * If you run this task locally, it may require some env set up first. + * If you run this task locally, it may require some env set up first. */ -module.exports = function(grunt) { - grunt.initConfig({ - jshint: { - /*options: { +module.exports = function (grunt) { + grunt.initConfig({ + jshint : { + /*options: { "evil": true, "asi": true, "smarttabs": true, "eqnull": true },*/ - files: [ - 'Gruntfile.js', - 'package.json', - 'js/**/*.js', - '!js/lib/**/*.js' // Exclude lib folder (note the leading !) - ] - }, - connect: { - www: { - options: { - base: '.', - port: 4545 - } - } - }, - ghost: { - dist: { - filesSrc: ['tests/integration/casperjs/*_test.js'], - options: { - args: { - baseUrl: 'http://localhost:' + - '<%= connect.www.options.port %>/' - }, - direct: false, - logLevel: 'error', - printCommand: false, - printFilePaths: true - } - } - } - }); + files : [ + 'Gruntfile.js', + 'package.json', + 'js/**/*.js', + '!js/lib/**/*.js' // Exclude lib folder (note the leading !) + ] + }, + connect : { + www : { + options : { + base : '.', + port : 4545 + } + } + }, + ghost : { + dist : { + filesSrc : ['tests/integration/casperjs/*_test.js'], + options : { + args : { + baseUrl : 'http://localhost:' + '<%= connect.www.options.port %>/' + }, + direct : false, + logLevel : 'error', + printCommand : false, + printFilePaths : true + } + } + }, + concat : { + options : { + separator : ';', + }, + dist : { + src : require('./script-load-list.js').scripts, + dest : 'build/piskel-packaged.js', + }, + }, + uglify : { + options : { + mangle : true + }, + my_target : { + files : { + 'build/piskel-packaged-min.js' : ['build/piskel-packaged.js'] + } + } + } + }); - grunt.loadNpmTasks('grunt-contrib-connect'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-ghost'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-ghost'); - grunt.registerTask('lint', ['jshint']); - grunt.registerTask('test', ['jshint', 'connect', 'ghost']); + grunt.registerTask('default', ['jshint', 'concat', 'uglify']); + grunt.registerTask('lint', ['jshint']); + grunt.registerTask('test', ['jshint', 'connect', 'ghost']); }; diff --git a/all.html b/all.html deleted file mode 100644 index 85471c58..00000000 --- a/all.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - All piskels - - - - - \ No newline at end of file diff --git a/index.html b/index.html index 6eff0045..a14bfb1c 100644 --- a/index.html +++ b/index.html @@ -119,70 +119,42 @@ - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } else { + var script; + if (window.location.href.indexOf("pack") != -1) { + script = "build/piskel-packaged.js"; + } else { + script = "build/piskel-packaged-min.js"; + } + loadScript(script, "pskl.app.init()"); + } + })(); + + diff --git a/js/lib/jsColor_1_4_0/jscolor.js b/js/lib/jsColor_1_4_0/jscolor.js index 47cd4b1e..397fa747 100644 --- a/js/lib/jsColor_1_4_0/jscolor.js +++ b/js/lib/jsColor_1_4_0/jscolor.js @@ -35,34 +35,7 @@ var jscolor = { getDir : function() { - if(!jscolor.dir) { - var detected = jscolor.detectDir(); - jscolor.dir = detected!==false ? detected : 'jscolor/'; - } - return jscolor.dir; - }, - - - detectDir : function() { - var base = location.href; - - var e = document.getElementsByTagName('base'); - for(var i=0; i size=widthxheight var parts = sizeParam.split("x"); if (parts && parts.length == 2 && !isNaN(parts[0]) && !isNaN(parts[1])) { var width = parseInt(parts[0], 10), - height = parseInt(parts[1], 10); - + height = parseInt(parts[1], 10); + size = { height : Math.min(height, Constants.MAX_HEIGHT), width : Math.min(width, Constants.MAX_WIDTH) @@ -115,15 +118,15 @@ return size; }, - readFramesheetIdFromURL_ : function() { + readFramesheetIdFromURL_ : function () { return this.readUrlParameter_("frameId"); }, readUrlParameter_ : function (paramName) { var searchString = window.location.search.substring(1), - i, val, params = searchString.split("&"); + i, val, params = searchString.split("&"); - for (i=0;i + "js/rendering/DrawingLoop.js", + + // Models + "js/model/Frame.js", + "js/model/FrameSheet.js", + "js/selection/SelectionManager.js", + "js/selection/BaseSelection.js", + "js/selection/RectangularSelection.js", + "js/selection/ShapeSelection.js", + + // Rendering + "js/rendering/CanvasRenderer.js", + "js/rendering/FrameRenderer.js", + "js/rendering/SpritesheetRenderer.js", + + // Controllers + "js/controller/DrawingController.js", + "js/controller/PreviewFilmController.js", + "js/controller/AnimatedPreviewController.js", + "js/controller/ToolController.js", + "js/controller/PaletteController.js", + "js/controller/NotificationController.js", + "js/controller/SettingsController.js", + + // Services + "js/service/LocalStorageService.js", + "js/service/HistoryService.js", + "js/service/KeyboardEventService.js", + + // Tools + "js/drawingtools/BaseTool.js", + "js/drawingtools/SimplePen.js", + "js/drawingtools/VerticalMirrorPen.js", + "js/drawingtools/Eraser.js", + "js/drawingtools/Stroke.js", + "js/drawingtools/PaintBucket.js", + "js/drawingtools/Rectangle.js", + "js/drawingtools/Circle.js", + "js/drawingtools/Move.js", + "js/drawingtools/selectiontools/BaseSelect.js", + "js/drawingtools/selectiontools/RectangleSelect.js", + "js/drawingtools/selectiontools/ShapeSelect.js", + "js/drawingtools/ColorPicker.js", + + // Application controller and initialization + "js/piskel.js" +]; \ No newline at end of file