commit c4d7a685a8c572e8b2f322459f5e7005f76fb4bf Author: Dmitri Akatov Date: Wed Jun 12 18:35:58 2013 +0100 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2cdfb8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2125666 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccd7911 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +dist +.tmp +.sass-cache +app/components diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..64b7ce8 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,25 @@ +{ + "node": true, + "browser": true, + "es5": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "globals": { + "angular": false + } +} diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 0000000..8a96469 --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,69 @@ +# global module:false + +module.exports = (grunt) -> + + # Project configuration. + grunt.initConfig + # Metadata. + pkg: grunt.file.readJSON 'package.json' + banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n' + meta: + src: 'src/' + test: 'test/' + target: 'dist/' + coffeelint: src: + files: src: ['<%= meta.src %>**/*.coffee'] + options: max_line_length: level: 'warn' + coffee: src: + options: bare: true + files: + '<%= meta.target %>radians.js': [ + '<%= meta.src %>**/*.coffee' + ] + clean: target: src: ['<%= meta.target %>*js'] + mochacli: + options: + require: ['should'] + compilers: ['coffee:coffee-script'] + reporter: 'spec' + coffee: ['test/*.coffee'] + + # Task configuration. + # concat: + # options: + # banner: '<%= banner %>' + # stripBanners: true + # dist: + # src: ['lib/<%= pkg.name %>.js'] + # dest: 'dist/<%= pkg.name %>.js' + # uglify: + # options: + # banner: '<%= banner %>' + # dist: + # src: '<%= concat.dist.dest %>' + # dest: 'dist/<%= pkg.name %>.min.js' + # watch: + # gruntfile: + # files: '<%= jshint.gruntfile.src %>' + # tasks: ['jshint:gruntfile'] + # lib_test: + # files: '<%= jshint.lib_test.src %>' + # tasks: ['jshint:lib_test', 'qunit'] + + # These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-contrib-clean') + grunt.loadNpmTasks('grunt-contrib-coffee') + grunt.loadNpmTasks('grunt-coffeelint') + grunt.loadNpmTasks('grunt-contrib-watch') + grunt.loadNpmTasks('grunt-mocha-cli') + grunt.loadNpmTasks('grunt-contrib-jshint') + + + grunt.registerTask 'test', ['mochacli'] + grunt.registerTask 'lint', ['coffeelint'] + grunt.registerTask 'build', ['clean', 'lint'] + grunt.registerTask 'default', ['lint' , 'test', 'build', 'jshint'] diff --git a/package.json b/package.json new file mode 100644 index 0000000..35b8b9b --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "angular-radians", + "version": "0.0.0", + "description": "angular extensions", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "grunt test" + }, + "repository": "", + "keywords": [ + "angular", + "extension" + ], + "author": "Dmitri Akatov", + "license": "BSD", + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-concat": "~0.3.0", + "grunt-mocha-cli": "~1.0.6", + "should": "~1.2.2", + "grunt-coffee-redux": "~0.2.3", + "grunt-contrib-coffee": "~0.7.0", + "grunt-contrib-clean": "~0.4.1", + "grunt-contrib-watch": "~0.4.4", + "grunt-contrib-jshint": "~0.6.0", + "grunt-coffeelint": "0.0.6", + "coffee-script": "~1.6.3" + } +} diff --git a/src/radians.coffee b/src/radians.coffee new file mode 100644 index 0000000..bf25b80 --- /dev/null +++ b/src/radians.coffee @@ -0,0 +1 @@ +angular.module('radians', ['radians.contenteditable']) diff --git a/src/radians/contenteditable.coffee b/src/radians/contenteditable.coffee new file mode 100644 index 0000000..c09542f --- /dev/null +++ b/src/radians/contenteditable.coffee @@ -0,0 +1,25 @@ +angular.module('radians.contenteditable', []) +.directive('contenteditable', -> + require: 'ngModel', + link: (scope, elm, attrs, ctrl) -> + # view -> model + elm.bind 'blur', -> + console.log elm + console.log "blur()" + scope.$apply -> + ctrl.$setViewValue elm.html() + + elm.bind 'input', (e) -> + console.log 'input', e + t = elm.html() + console.log 'elm contents', t + scope.$apply -> + ctrl.$setViewValue t + + # model -> view + ctrl.$render = (v) -> + console.log @ + console.log "model: #{@$modelValue}, view: #{@$viewValue}" + console.log "$render()", v + elm.html ctrl.$viewValue +) diff --git a/test/test.coffee b/test/test.coffee new file mode 100644 index 0000000..e459f8c --- /dev/null +++ b/test/test.coffee @@ -0,0 +1,5 @@ +describe 'radians', -> + describe 'contenteditable', -> + it 'is nice', -> + console.log 'ohai' + 1.should.equal 1