diff --git a/.travis.yml b/.travis.yml index 12b2631..4ce8af0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: node_js node_js: - - 0.8 - - 0.6 + - 0.10 + - 0.8 \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..1aa0cdb --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,98 @@ +module.exports = function(grunt) { + // tasks + grunt.loadTasks('build/tasks'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-recess'); + grunt.loadNpmTasks('grunt-karma'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // configuration + grunt.initConfig({ + pkg: '', + meta: { + banner: '/**\n' + + ' * <%= pkg.description %>\n' + + ' * @version v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + ' * @link <%= pkg.homepage %>\n' + + ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' + + ' */' + }, + concat: { + dist: { + src: ['', 'src/ngx.js', 'src/deps/ecmascript/*.js', 'src/deps/head.js/*.js', 'src/modules/**/!(lang|test)/*.js', 'src/modules/**/lang/*.js'], + dest: 'dist/ngx.js' + } + }, + clean: { + build: ['dist/'] + }, + copy: { + dist: { + files: [ + {expand: true, src: ['src/modules/ui/**/*.html'], dest: 'dist/templates/ui' }, + {expand: true, src: ['libs/**'], dest: 'dist/libs'} + ] + } + }, + uglify: { + // Specify mangle: false to prevent changes to your variable and function names. + options: { + mangle: false + }, + dist: { + files: { + 'dist/ngx.min.js': ['dist/ngx.js'] + } + } + }, + recess: { + dist_css: { + src: 'src/**/*.less', + dest: 'dist/styles/ngx.css', + options: { + compile: true + } + }, + dist_min: { + src: 'src/**/*.less', + dest: 'dist/styles/ngx.min.css', + options: { + compile: true, + compress: true + } + } + }, + jshint: { + files: ['Gruntfile.js', 'src/ngx.js', 'src/modules/**/*.js'] + }, + watch: { + scripts: { + files: ['Gruntfile.js', 'src/*.js', 'src/**/*.js', 'test/**/*.js'], + tasks: ['lint', 'concat', 'min', 'karma'] + }, + styles: { + files: ['src/**/*.less'], + tasks: ['recess'] + }, + templates: { + files: ['src/modules/**/*.html'], + tasks: ['copy'] + } + }, + karma: { + unit: { + configFile: 'test/unit/config.js', + runnerPort: 9999, + singleRun: true, + browsers: ['PhantomJS'] + } + } + }); + + grunt.registerTask('default', ['jshint', 'clean', 'concat', 'copy', 'uglify', 'recess']); + grunt.registerTask('devel', ['karma', 'watch']); +}; diff --git a/build/tasks/clean.js b/build/tasks/clean.js deleted file mode 100644 index 2dcd4ff..0000000 --- a/build/tasks/clean.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Task: clean - * Description: Clear files and folders. - * Dependencies: rimraf - * Contributor: @tbranyen - */ - -module.exports = function(grunt) { - "use strict"; - - grunt.registerMultiTask("clean", "Clear files and folders", function() { - var options = grunt.helper("options", this); - - grunt.verbose.writeflags(options, "Options"); - - var paths = grunt.file.expand(this.file.src); - - paths.forEach(function(path) { - grunt.helper("clean", path); - }); - }); - - grunt.registerHelper("clean", function(path) { - grunt.log.write('Cleaning "' + path + '"...'); - - try { - require("rimraf").sync(path); - grunt.log.ok(); - } catch (e) { - grunt.log.error(); - grunt.verbose.error(e); - grunt.fail.warn("Clean operation failed."); - } - }); -}; \ No newline at end of file diff --git a/build/tasks/helpers.js b/build/tasks/helpers.js deleted file mode 100644 index 126cfc4..0000000 --- a/build/tasks/helpers.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Grunt Contrib Helpers - * Description: help make things consistent across tasks. - * Contributor: @tkellen - */ - -module.exports = function(grunt) { - "use strict"; - - // TODO: ditch this when grunt v0.4 is released - grunt.util = grunt.util || grunt.utils; - - // Helper for consistent options key access across contrib tasks. - grunt.registerHelper("options", function(data, defaults) { - var _ = grunt.util._; - var namespace = data.nameArgs.split(":"); - var task = grunt.config(_.flatten([namespace, "options"])); - var global_subtask = namespace.length > 1 ? grunt.config(_.flatten(["options", namespace])) : {}; - var global = grunt.config(["options", namespace[0]]); - - return _.defaults({}, task, global_subtask, global, defaults || {}); - }); - - // TODO: ditch this when grunt v0.4 is released - // Temporary helper for normalizing files object - grunt.registerHelper("normalizeMultiTaskFiles", function(data, target) { - var prop, obj; - var files = []; - if (grunt.util.kindOf(data) === 'object') { - if ('src' in data || 'dest' in data) { - obj = {}; - if ('src' in data) { obj.src = data.src; } - if ('dest' in data) { obj.dest = data.dest; } - files.push(obj); - } else if (grunt.util.kindOf(data.files) === 'object') { - for (prop in data.files) { - files.push({src: data.files[prop], dest: prop}); - } - } else if (Array.isArray(data.files)) { - data.files.forEach(function(obj) { - var prop; - if ('src' in obj || 'dest' in obj) { - files.push(obj); - } else { - for (prop in obj) { - files.push({src: obj[prop], dest: prop}); - } - } - }); - } - } else { - files.push({src: data, dest: target}); - } - - // Process each normalized file object as a template. - files.forEach(function(obj) { - // Process src as a template (recursively, if necessary). - if ('src' in obj) { - obj.src = grunt.util.recurse(obj.src, function(src) { - if (typeof src !== 'string') { return src; } - return grunt.template.process(src); - }); - } - if ('dest' in obj) { - // Process dest as a template. - obj.dest = grunt.template.process(obj.dest); - } - }); - - return files; - }); -}; \ No newline at end of file diff --git a/grunt.js b/grunt.js deleted file mode 100644 index d2459c1..0000000 --- a/grunt.js +++ /dev/null @@ -1,88 +0,0 @@ -module.exports = function(grunt) { - // tasks - grunt.loadTasks('build/tasks'); - grunt.loadNpmTasks('grunt-recess'); - grunt.loadNpmTasks('grunt-testacular'); - - // configuration - grunt.initConfig({ - pkg: '', - meta: { - banner: '/**\n' + - ' * <%= pkg.description %>\n' + - ' * @version v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + - ' * @link <%= pkg.homepage %>\n' + - ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' + - ' */' - }, - concat: { - dist: { - src: ['', 'src/ngx.js', 'src/deps/**/*.js', 'src/modules/**/!(lang|test)/*.js', 'src/modules/**/lang/*.js'], - dest: 'dist/ngx.js' - } - }, - clean: { - dist: ['dist/'] - }, - copy: { - dist: { - files: { - 'dist/templates/ui': ['src/modules/ui/**/*.html'], - 'dist/libs': ['libs/**'] - } - } - }, - min: { - dist: { - src: ['', ''], - dest: 'dist/ngx.min.js' - } - }, - recess: { - dist_css: { - src: 'src/**/*.less', - dest: 'dist/styles/ngx.css', - options: { - compile: true - } - }, - dist_min: { - src: '', - dest: 'dist/styles/ngx.min.css', - options: { - compress: true - } - } - }, - lint: { - files: ['grunt.js', 'src/ngx.js', 'src/modules/**/*.js'] - }, - watch: { - scripts: { - files: ['grunt.js', 'src/*.js', 'src/**/*.js', 'test/**/*.js'], - tasks: 'lint concat min testacularRun' - }, - styles: { - files: ['src/**/*.less'], - tasks: 'recess' - }, - templates: { - files: ['src/modules/**/*.html'], - tasks: 'copy' - } - }, - testacularServer: { - unit: { - configFile: 'test/unit/config.js' - } - }, - testacularRun: { - unit: { - runnerPort: 9100 - } - } - }); - - grunt.registerTask('default', 'lint clean concat copy min recess'); - grunt.registerTask('devel', 'testacularServer watch'); -}; \ No newline at end of file diff --git a/package.json b/package.json index bfb07b4..4f44071 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,34 @@ { - "author": "https://github.com/lmc-eu", - "name": "ngx-library", - "description": "NGX - extension library for AngularJS", - "version": "0.2.2", - "homepage": "http://github.com/lmc-eu/ngx-library", - "repository": { - "type": "git", - "url": "git://github.com/lmc-eu/ngx-library.git" - }, - "engines": { - "node": "~=0.8.0" - }, - "dependencies": { - "rimraf": "~=2.0.2", - "testacular": "~=0.4.0", - "grunt": "~=0.3.12", - "grunt-recess": "~=0.1.0", - "grunt-testacular": "~=0.2.0" - }, - "scripts" : { - "pretest": "grunt", - "test": "grunt testacularServer" - } + "author": "https://github.com/lmc-eu", + "name": "ngx-library", + "description": "NGX - extension library for AngularJS", + "version": "0.3.0", + "homepage": "http://github.com/lmc-eu/ngx-library", + "repository": { + "type": "git", + "url": "git://github.com/lmc-eu/ngx-library.git" + }, + "engines": { + "node": "~0.8.0" + }, + "dependencies": { + "grunt": "~0.4.1", + "grunt-recess": "~0.3.0", + "grunt-karma": "~0.4.0", + "grunt-contrib-jshint": "~0.4.0", + "grunt-contrib-watch": "~0.3.1", + "karma": "~0.8.0", + "istanbul": "~0.1.0", + "jshint": "~1.1.0", + "phantomjs" : "~1.9.0", + "grunt-cli": "~0.1.0", + "grunt-contrib-concat": "~0.2.0", + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-clean": "~0.4.1", + "grunt-contrib-copy": "~0.4.1" + }, + "scripts": { + "pretest": "grunt", + "test": "grunt karma" + } } diff --git a/src/modules/date/date.js b/src/modules/date/date.js index e4aa8ce..13ad3b2 100644 --- a/src/modules/date/date.js +++ b/src/modules/date/date.js @@ -7,6 +7,42 @@ var ngxDate = {}; + + ngxDate.ini_set = function (varname, newvalue) { + // http://kevin.vanzonneveld.net + // + original by: Brett Zamir (http://brett-zamir.me) + // % note 1: This will not set a global_value or access level for the ini item + // * example 1: ini_set('date.timezone', 'America/Chicago'); + // * returns 1: 'Asia/Hong_Kong' + + var oldval = '', + that = this; + this.php_js = this.php_js || {}; + this.php_js.ini = this.php_js.ini || {}; + this.php_js.ini[varname] = this.php_js.ini[varname] || {}; + oldval = this.php_js.ini[varname].local_value; + + var _setArr = function (oldval) { // Although these are set individually, they are all accumulated + if (typeof oldval === 'undefined') { + that.php_js.ini[varname].local_value = []; + } + that.php_js.ini[varname].local_value.push(newvalue); + }; + + switch (varname) { + case 'extension': + if (typeof this.dl === 'function') { + this.dl(newvalue); // This function is only experimental in php.js + } + _setArr(oldval, newvalue); + break; + default: + this.php_js.ini[varname].local_value = newvalue; + break; + } + return oldval; + }; + /** * Date formatter * @param format diff --git a/src/modules/date/test/date.test.js b/src/modules/date/test/date.test.js index a78a3fe..9d9dbf3 100644 --- a/src/modules/date/test/date.test.js +++ b/src/modules/date/test/date.test.js @@ -2,8 +2,10 @@ describe('ngx.date', function() { beforeEach(module('ngx.date', 'ngx.config')); it('should format datetime', inject(function(ngxDate) { - expect(ngxDate.format('Y-m-d', 1351375200)).toEqual('2012-10-28'); - expect(ngxDate.format('j.n.Y H:i:s', 1348815030)).toEqual('28.9.2012 08:50:30'); + var d = Math.floor(new Date(2012,9,28).getTime() / 1000); + expect(ngxDate.format('Y-m-d', d)).toEqual('2012-10-28'); + var t = Math.floor(new Date(2012,8,28,8,50,30).getTime() / 1000); + expect(ngxDate.format('j.n.Y H:i:s T', t)).toEqual('28.9.2012 08:50:30 UTC'); })); it('should check datetime', inject(function(ngxDate) { diff --git a/src/modules/ui/imageupload/imageupload.less b/src/modules/ui/imageupload/imageupload.less index 7a599b9..eb3b4ff 100644 --- a/src/modules/ui/imageupload/imageupload.less +++ b/src/modules/ui/imageupload/imageupload.less @@ -82,5 +82,4 @@ .scale-info { color: #999; } -} } \ No newline at end of file