-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5da77d8
Showing
31 changed files
with
1,129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": [ | ||
".eslintrc.main" | ||
], | ||
"env": { | ||
"es6": true, | ||
"browser": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"rules": { | ||
"eqeqeq": "error", | ||
"camelcase": "error", | ||
"curly": "error", | ||
"no-trailing-spaces": "error", | ||
"wrap-iife": "error", | ||
"no-use-before-define": "error", | ||
"new-cap": "error", | ||
"no-caller": "error", | ||
"strict": "error", | ||
"no-unused-vars": "warn", | ||
"quotes": ["error", "single"], | ||
"indent": ["error", 4] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": [ | ||
".eslintrc.main" | ||
], | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"fileExtensions": [ ".js" ], | ||
"excludeFiles": ["node_modules/**"], | ||
"requireCurlyBraces": true, | ||
"requireSpaceAfterKeywords": true, | ||
"requireSpaceBeforeBlockStatements": true, | ||
"requireParenthesesAroundIIFE": true, | ||
"requireSpacesInConditionalExpression": true, | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInAnonymousFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInNamedFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInFunctionDeclaration": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInFunction": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"disallowSpacesInCallExpression": true, | ||
"disallowMultipleVarDecl": true, | ||
"requireBlocksOnNewline": 1, | ||
"requirePaddingNewLinesInObjects": true, | ||
"disallowEmptyBlocks": true, | ||
|
||
"disallowQuotedKeysInObjects": true, | ||
|
||
"disallowSpaceAfterObjectKeys": true, | ||
"requireSpaceBeforeObjectValues": true, | ||
"requireCommaBeforeLineBreak": true, | ||
"requireOperatorBeforeLineBreak": true, | ||
"disallowSpaceAfterPrefixUnaryOperators": true, | ||
"disallowSpaceBeforePostfixUnaryOperators": true, | ||
"requireSpaceBeforeBinaryOperators": true, | ||
"requireSpaceAfterBinaryOperators": true, | ||
"disallowMultipleLineStrings": true, | ||
"disallowMultipleLineBreaks": true, | ||
"disallowMixedSpacesAndTabs": true, | ||
"disallowTrailingWhitespace": true, | ||
"disallowTrailingComma": true, | ||
"disallowKeywordsOnNewLine": ["else"], | ||
"requireLineFeedAtFileEnd": true, | ||
|
||
"requireCapitalizedConstructors": true, | ||
"requireDotNotation": true, | ||
"disallowYodaConditions": true, | ||
"requireSpaceAfterLineComment": true, | ||
"disallowFunctionDeclarations": true, | ||
"disallowNewlineBeforeBlockStatements": true, | ||
"validateQuoteMarks": { | ||
"mark": "'", | ||
"escape": true | ||
}, | ||
"validateIndentation": 4, | ||
"validateParameterSeparator": ", " | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
/* global module, require */ | ||
|
||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
if (grunt.option('help')) { | ||
// Load all tasks so they can be viewed in the help: grunt -h or --help. | ||
require('load-grunt-tasks')(grunt); | ||
} else { | ||
// Use jit-grunt to only load necessary tasks for each invocation of grunt. | ||
require('jit-grunt')(grunt, { | ||
swig: 'grunt-swig-templates', | ||
ngtemplates: 'grunt-angular-templates' | ||
}); | ||
} | ||
|
||
const ngTemplatesPaths = require('grunt-incuna-plugins')['ng-templates-paths'](); | ||
|
||
grunt.initConfig({ | ||
|
||
config: { | ||
baseDir: 'app', | ||
distDir: 'dist', | ||
testsDir: 'tests', | ||
tests: '<%= config.testsDir %>/**/*.js', | ||
libDir: '<%= config.baseDir %>/lib', | ||
|
||
scriptsDir: '<%= config.baseDir %>/scripts', | ||
srcScriptsDir: '<%= config.scriptsDir %>/src', | ||
compiledScriptsDir: '<%= config.scriptsDir %>/compiled-es5', | ||
|
||
templates: { | ||
sourceDir: 'templates/twig-source', | ||
sourceFiles: '<%= config.templates.sourceDir %>/**/*.html', | ||
generatedDir: 'templates/generated', | ||
generatedFiles: '<%= config.templates.generatedDir %>/**/*.html' | ||
}, | ||
|
||
lintFiles: { | ||
node: ['Gruntfile.js'], | ||
es: ['<%= config.srcScriptsDir %>'], | ||
tests: ['<%= config.testsDir %>'] | ||
} | ||
} | ||
|
||
}); | ||
|
||
grunt.config.merge({ | ||
watch: { | ||
es: { | ||
files: [ | ||
'<%= config.srcScriptsDir %>/**/*.es.js', | ||
'<%= config.compiledScriptsDir %>/**/templates.js' | ||
], | ||
tasks: [ | ||
'compilejs', | ||
'uglify' | ||
] | ||
}, | ||
swig: { | ||
files: [ | ||
'<%= config.templates.sourceFiles %>' | ||
], | ||
tasks: [ | ||
'orderedSwig' | ||
] | ||
}, | ||
ngtemplates: { | ||
files: ['<%= config.templates.generatedFiles %>'], | ||
tasks: ['ngtemplates'] | ||
} | ||
}, | ||
browserify: { | ||
all: { | ||
files: { | ||
'<%= config.distDir %>/language-select.js': '<%= config.compiledScriptsDir %>/**/*.js' | ||
} | ||
} | ||
}, | ||
babel: { | ||
all: { | ||
options: { | ||
presets: ['es2015'], | ||
resolveModuleSource: (source) => `./${source}.js` | ||
}, | ||
files: [{ | ||
expand: true, | ||
cwd: '<%= config.srcScriptsDir %>', | ||
src: ['**/*.es.js'], | ||
dest: '<%= config.compiledScriptsDir %>', | ||
ext: '.js' | ||
}] | ||
} | ||
}, | ||
eslint: { | ||
node: { | ||
options: { | ||
configFile: '.eslintrc.node' | ||
}, | ||
src: '<%= config.lintFiles.node %>' | ||
}, | ||
es: { | ||
options: { | ||
configFile: '.eslintrc.es' | ||
}, | ||
src: '<%= config.lintFiles.es %>' | ||
}, | ||
tests: { | ||
options: { | ||
configFile: '.eslintrc.es' | ||
}, | ||
src: '<%= config.lintFiles.tests %>' | ||
} | ||
}, | ||
jscs: { | ||
all: { | ||
files: ['<%= config.lintFiles %>'] | ||
} | ||
}, | ||
swig: { | ||
all: { | ||
expand: true, | ||
cwd: '<%= config.templates.sourceDir %>', | ||
src: [ | ||
'**/*.html' | ||
], | ||
dest: '<%= config.templates.generatedDir %>' | ||
} | ||
}, | ||
clean: { | ||
js: [ | ||
'<%= config.compiledScriptsDir %>', | ||
'<%= config.distDir %>' | ||
], | ||
swig: [ | ||
'<%= config.templates.generatedDir %>/*' | ||
] | ||
}, | ||
uglify: { | ||
dist: { | ||
files: { | ||
'<%= config.distDir %>/language-select.min.js': '<%= config.distDir %>/language-select.js' | ||
} | ||
} | ||
}, | ||
ngtemplates: ngTemplatesPaths.generate('', 'app', '<%= config.compiledScriptsDir %>') | ||
}); | ||
|
||
// - - - T A S K S - - - | ||
|
||
grunt.loadTasks('./grunt'); | ||
|
||
grunt.registerTask('default', 'dev'); | ||
|
||
grunt.registerTask('dev', function () { | ||
grunt.task.run([ | ||
'build', | ||
'watch' | ||
]); | ||
}); | ||
|
||
grunt.registerTask('compilejs', function () { | ||
grunt.task.run([ | ||
'babel', | ||
'browserify' | ||
]); | ||
}); | ||
|
||
grunt.registerTask('orderedSwig', [ | ||
'clean:swig', | ||
'swig:all' | ||
]); | ||
|
||
grunt.registerTask('compileTemplates', [ | ||
'orderedSwig', | ||
'ngtemplates' | ||
]); | ||
|
||
grunt.registerTask('test', function () { | ||
grunt.task.run([ | ||
'eslint', | ||
'jscs', | ||
'clean', | ||
'build', | ||
'karma:ci' | ||
]); | ||
}); | ||
|
||
grunt.registerTask('build', function () { | ||
var tasks = [ | ||
'clean', | ||
'compileTemplates', | ||
'compilejs', | ||
'uglify' | ||
]; | ||
grunt.task.run(tasks); | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# angular-language-selector | ||
|
||
Angular module for managing language / locale selection. | ||
|
||
|
||
## Configuration | ||
|
||
### Set the available and defaultLanguages. | ||
|
||
``` | ||
const module = angular.module('app', [ | ||
'language-select.config' | ||
]); | ||
module.config([ | ||
'languageSelectConfig' | ||
function ( | ||
languageSelectConfig | ||
) { | ||
languageSelectConfig.setAvailableLanguages([ | ||
{ | ||
'id': 'en', | ||
'label': 'English' | ||
}, | ||
{ | ||
'id': 'pl', | ||
'label': 'Polski' | ||
} | ||
]); | ||
languageSelectConfig.setDefaultLanguage('en'); | ||
} | ||
]); | ||
``` | ||
|
||
### languageInterceptor | ||
|
||
The `languageInterceptor` can be used to set the `Accept-Language` to the current language for each http request. | ||
|
||
``` | ||
const module = angular.module('app', [ | ||
'language-select.language-interceptor' | ||
]); | ||
module.config(['$httpProvider', function ($httpProvider) { | ||
$httpProvider.interceptors.push('languageInterceptor'); | ||
}]); | ||
``` | ||
|
||
### language-select:change event. | ||
|
||
Set other local services from the language-select:change event. | ||
|
||
``` | ||
const module = angular.module('app', [ | ||
'language-select.storage-service', | ||
'project_settings', | ||
'gettext' | ||
]); | ||
// Set the app language when it is changed | ||
module.run([ | ||
'$rootScope', | ||
'gettextCatalog', | ||
'languageStorage', | ||
function ( | ||
$rootScope, | ||
gettextCatalog, | ||
languageStorage | ||
) { | ||
// get the starting/selected app language and set gettext and momentJS to use it | ||
$rootScope.$on('language-select:change', function (event, selectedLanguage) { | ||
gettextCatalog.setCurrentLanguage(choice.id); | ||
moment.locale(choice.id); | ||
}); | ||
} | ||
]); | ||
``` |
Oops, something went wrong.