Skip to content

Commit

Permalink
General updates
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jan 21, 2016
1 parent 3b2c3e4 commit 63b267c
Show file tree
Hide file tree
Showing 28 changed files with 846 additions and 541 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
.settings/
.sass-cache/
.project
grapes.sublime-project
grapes.sublime-workspace

private/
libs/
vendor/
node_modules/
bower_components/
80 changes: 55 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module.exports = function(grunt) {
var appPath = 'src',
buildPath = 'dist',
configPath = 'config/require-config.js';
module.exports = function(grunt) {

var appPath = 'src',
buildPath = 'dist',
configPath = 'config/require-config.js';

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-bowercopy');
grunt.loadNpmTasks('grunt-mocha');

grunt.initConfig({
appDir: appPath,
builtDir: buildPath,
Expand All @@ -27,20 +28,20 @@ module.exports = function(grunt) {
removeCombined: true,
findNestedDependencies: true,
keepBuildDir: true,
inlineText: true,
inlineText: true,
optimize: 'none'
//paths: { "jquery": "empty:" }, //try to exclude
}
}
},

jshint: {
all: [
'Gruntfile.js',
'<%= appDir %>/**/*.js',
]
},

uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
Expand All @@ -51,7 +52,7 @@ module.exports = function(grunt) {
}
}
},

sass: {
dist: {
files: [{
Expand All @@ -63,17 +64,17 @@ module.exports = function(grunt) {
}]
}
},

mocha: {
test: {
src: ['test/index.html'],
options: { log: true, },
},
},

connect: {
/*
app: {
dist: {
options: {
port: 8001,
open: {
Expand All @@ -91,7 +92,34 @@ module.exports = function(grunt) {
}
}
},


bowercopy: {
options: {
srcPrefix: 'bower_components'
},
scripts: {
options: {
destPrefix: 'vendor'
},
files: {
'jquery/jquery.js' : 'jquery/dist/jquery.min.js',
'jquery-ui/jquery-ui-core.js' : 'jquery.ui/ui/core.js',
'jquery-ui/jquery-ui-mouse.js' : 'jquery.ui/ui/mouse.js',
'jquery-ui/jquery-ui-widget.js' : 'jquery.ui/ui/widget.js',
'jquery-ui/jquery-ui.js' : 'jquery.ui/ui/resizable.js',
'underscore/underscore.js' : 'underscore/underscore-min.js',
'backbone/backbone.js' : 'backbone/backbone-min.js',
'backbone-undo/backbone-undo.js' : 'Backbone.Undo/Backbone.Undo.js',
'keymaster/keymaster.js' : 'keymaster/keymaster.js',
'require/require.js' : 'requirejs/require.js',
'require-text/text.js' : 'requirejs-text/text.js',
'spectrum/spectrum.js' : 'spectrum/spectrum.js',
'codemirror' : 'codemirror',
'codemirror-formatting' : 'codemirror-formatting/formatting.js',
},
}
},

watch: {
script: {
files: [ '<%= appDir %>/**/*.js' ],
Expand All @@ -102,17 +130,17 @@ module.exports = function(grunt) {
tasks: ['sass']
},
test: {
files: [ 'test/specs/**/*.js' ],
files: ['test/specs/**/*.js'],
tasks: ['mocha'],
options: { livereload: true }, //default port 35729
}
}

});

/**
* Need to copy require configs cause r.js will try to load them from the path indicated inside
* main.js file. This is the only way I have found to do it and only for the pleasure of using separate config
* main.js file. This is the only way I have found to do it and only for the pleasure of using separate config
* requirejs file.
* */
grunt.registerTask('before-requirejs', function() {
Expand All @@ -121,17 +149,19 @@ module.exports = function(grunt) {
grunt.file.mkdir(buildPath);
grunt.file.copy(appPath + '/' + configPath, buildPath + '/' + appPath + '/' + configPath);
});

grunt.registerTask('after-requirejs', function() {
//grunt.file.copy(buildPath + '/main.js', buildPath + '/main.min.js');
});


grunt.registerTask('bower', ['bowercopy']);

grunt.registerTask('dev', ['connect', 'watch']);

grunt.registerTask('test', ['mocha']);

grunt.registerTask('deploy', ['jshint', 'before-requirejs', 'requirejs', 'after-requirejs', 'uglify']);

grunt.registerTask('default', ['dev']);

};
40 changes: 40 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "grapes",
"description": "Open source web template editor",
"version": "0.0.5",
"author": "Artur Arseniev",
"main": [
"dist/grapes.min.js"
],
"keywords": [
"grapes",
"wte",
"web template editor",
"site builder",
"newsletter builder",
"wysiwyg",
"template",
"editor"
],
"license": "BSD-3-Clause",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"backbone": "~1.2.3",
"Backbone.Undo": "~0.2.5",
"jquery": "~2.2.0",
"jquery.ui": "~1.11.4",
"keymaster": "~1.6.3",
"requirejs": "~2.1.22",
"requirejs-text": "~2.0.14",
"spectrum": "~1.8.0",
"underscore": "~1.8.3",
"codemirror": "~5.10.0",
"codemirror-formatting": "*"
}
}
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<link rel="stylesheet" href="styles/spectrum.css">
<link rel="stylesheet" href="styles/css/font-awesome.min.css">
<link rel="stylesheet" href="styles/css/main.css">
<link rel="stylesheet" href="libs/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="vendor/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="vendor/codemirror/theme/hopscotch.css">
</head>
<body>
<div id="wte-app"></div>
<script data-main="src/demo" src="libs/require-min.js"></script>
<script data-main="src/demo" src="vendor/require/require.js"></script>
</body>
</html>
43 changes: 29 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
{
"name": "grapes.js",
"name": "grapes",
"description": "Open source web template editor",
"version": "0.0.5",
"author": "Artur Arseniev",
"private": true,
"dependencies": {
"backbone": "1.2.0",
"backbone-undo": "0.2",
"backbone": "^1.2.3",
"backbone-undo": "^0.2.5",
"bootstrap-wysiwyg": "^1.0.4",
"codemirror": "^5.10.0",
"jquery": "^2.2.0",
"jquery-ui": "^1.10.5",
"keymaster": "^1.6.2",
"requirejs": "latest",
"spectrum-colorpicker": "1.7.1"
"requirejs": "^2.1.22",
"spectrum-colorpicker": "^1.8.0",
"text": "git://github.com/requirejs/text",
"underscore": "^1.8.3"
},
"devDependencies": {
"chai": "latest",
"grunt": "latest",
"chai": "^3.4.1",
"grunt": "^0.4.5",
"grunt-bowercopy": "^1.2.4",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "latest",
"grunt-contrib-requirejs": "latest",
"grunt-contrib-jshint": "^0.12.0",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-testem": "^0.5.16",
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-watch": "latest",
"grunt-mocha": "^0.4.15",
"grunt-testem": "^0.5.5",
"mocha": "latest"
"grunt-contrib-watch": "^0.6.1",
"grunt-mocha": "^0.4.15"
},
"license": "BSD-3-Clause",
"keywords": [
"grapes",
"wte",
"web template editor",
"site builder",
"newsletter builder",
"wysiwyg",
"template",
"editor"
],
"scripts": {
"grunt": "node_modules/.bin/grunt"
}
Expand Down
39 changes: 20 additions & 19 deletions src/asset_manager/view/AssetImageView.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
define(['./AssetView','text!./../template/assetImage.html'],
define(['./AssetView','text!./../template/assetImage.html'],
function (AssetView, assetTemplate) {
/**
/**
* @class AssetImageView
* */
return AssetView.extend({

events:{
'click' : 'selected',
'click' : 'selected',
'dblclick' : 'chosen',
},

template: _.template(assetTemplate),

initialize: function(o) {
AssetView.prototype.initialize.apply(this, arguments);
this.className += ' ' + this.pfx + 'asset-image';
this.events['click #' + this.pfx + 'close'] = 'removeItem';
this.delegateEvents();
},

/**
* Trigger when asset is been selected
*
*
* @return void
* */
selected: function(){
this.model.collection.trigger('deselectAll');
this.$el.addClass(this.pfx + 'highlight');

this.updateTarget(this.model.get('src'));
},

/**
* Trigger when asset is been chosen (double clicked)
*
*
* @return void
* */
chosen: function(){
Expand All @@ -42,11 +43,11 @@ define(['./AssetView','text!./../template/assetImage.html'],
f(this.model);
}
},

/**
* Update target if exists
* @param {String} v Value
*
*
* @return void
* */
updateTarget: function(v){
Expand All @@ -58,27 +59,27 @@ define(['./AssetView','text!./../template/assetImage.html'],
target.set('src', v );
}
},

/**
* Remove asset from collection
*
*
* @return void
* */
removeItem: function(e){
e.stopPropagation();
this.model.collection.remove(this.model);
},

render : function(){
var name = this.model.get('name'),
dim = this.model.get('width') && this.model.get('height') ?
dim = this.model.get('width') && this.model.get('height') ?
this.model.get('width')+' x '+this.model.get('height') : '';
name = name ? name : this.model.get('src').split("/").pop();
name = name && name.length > 30 ? name.substring(0, 30)+'...' : name;
dim = dim ? dim + (this.model.get('unitDim') ? this.model.get('unitDim') : ' px' ) : '';
this.$el.html( this.template({
name: name,
src: this.model.get('src'),
name: name,
src: this.model.get('src'),
dim: dim,
pfx: this.pfx
}));
Expand Down
Loading

0 comments on commit 63b267c

Please sign in to comment.