6 дней назад
История
README.md
calendar-js
Entry
Property | Description |
---|---|
calendar |
Instance of Calendar ; it is enough for work |
From dist
-script it will be placed into window.CalendarJs
.
Classes and types
Calendar
Property/Method | Description |
---|---|
[static] readonly Class<I18n> i18n |
Link to I18n ; use: Calendar.i18n.addPhrases() and so on |
[static] readonly Array<String> languages |
Registered languages; proxy to I18n.list() |
[static] readonly Array<String> pageSizes |
Allowed page sizes |
[static] readonly Object yearRange |
Object like { min: …, max: … } ; min/max allowed years |
[static] readonly Class<Notations> Notations |
Link to Notations ; use: Calendar.Notations.create() and so on |
readonly String basePath |
Path to theme and its images |
readonly String language |
Selected language |
readonly Array<String> notations |
Selected notations |
readonly Boolean rotation |
Is enabled rotation for letters? |
readonly String size |
Page size: A4 , A5 etc (see constants) |
readonly Theme theme |
Calendar theme (images for months and seasons) |
readonly Number year |
Selected year |
readonly Object<Image> months |
Proxy to property months from theme |
readonly Object<Image> seasons |
Proxy to property seasons from theme |
self constructor ({ basePath, language, notations, rotation, size, theme, year } = {}) |
Constructor; see setters |
this setBasePath (?String basePath) |
Set basePath; default is empty |
this setLanguage (?I18n|String language) |
Set language/translator; default is en |
this setNotations (?Notations|Number|String|Array<String> notations) |
Set notations; default is all available |
this setRotation (?Boolean rotation) |
Set rotation; default is TRUE |
this setSize (?String size) |
Set page size; default is A4 |
this setTheme (?Theme theme) |
Set theme; default is empty |
this setYear (?Number year) |
Set year; default is current |
Object toObject () |
Object like { basePath, language, notations, rotation, size, theme, year } |
Object toJSON () |
All calendar settings to stringify into JSON |
String toString () |
Generate HTML ; use only after wait() |
Promise wait () |
Wait processing all theme images (size, colors etc) |
Sample see in public/index.js
; to open in browser: make vm-build vm-up server
.
I18n
Property/Method | Description |
---|---|
static readonly Number count |
Count of all registered languages |
static readonly Array<String> list |
Codes of all registered languages |
static readonly String default |
Default language |
static self create (?String language) |
Static constructor |
static void addLanguage (String language, Object<String> phrases, ?String parent) |
Add new language |
static void addPhrases (String language, Object<String> phrases) |
Add new phrases |
static void addPhrase (String language, String phrase, String translate) |
Add new phrase translation |
readonly ?String language |
This language |
self constructor (?String language) |
Constructor |
self set (?String language) |
New instance with other language |
?String get (String phrase) |
Get translation of phrase |
Notations
Property/Method | Description |
---|---|
[static] readonly Object<String> strings |
Available notations; object like { binary: <string>, … } |
[static] readonly Object<String> symbols |
Available notations; object like { octal: <symbol>, … } |
[static] readonly Object<Number> numbers |
Available notations; object like { decimal: <bitmask>, … } |
[static] readonly Array<String> default |
Default notations; array like ["decimal", "binary", …] |
static self create (?Number|String|Array<String> values) |
Static constructor |
static self all (Boolean flag = true) |
Static constructor with (by default) or w/o all notations |
static self none (Boolean flag = true) |
Static constructor w/o (by default) or with all notations |
static String convert (Number value, String notation) |
Convert number to string using selected number system |
readonly Array<String> values |
Selected notations (array of strings) |
readonly Number count |
Count of selected notations |
self constructor (?Number|String|Array<String> values) |
Constructor with bitmask/string with symbols/array of strings |
this all (Boolean flag = true) |
Enable (by default) or disable all notations |
this none (Boolean flag = true) |
Disable (by default) or enable all notations |
this|Boolean binary (?Boolean flag) |
On/off binary notation or check is it enabled |
this|Boolean octal (?Boolean flag) |
On/off octal notation or check is it enabled |
this|Boolean decimal (?Boolean flag) |
On/off decimal notation or check is it enabled |
this|Boolean hexadecimal (?Boolean flag) |
On/off hexadecimal notation or check is it enabled |
this|Boolean roman (?Boolean flag) |
On/off roman notation or check is it enabled |
console.log(Notations.create([Notations.strings.binary, Notations.strings.hexadecimal]).values); // ▶ (2) ['binary', 'hexadecimal']
console.log(new Notations(Notations.symbols.decimal + Notations.symbols.roman).values); // ▶ (2) ['decimal', 'roman']
console.log(new Notations(Notations.numbers.decimal | Notations.numbers.binary).values); // ▶ (2) ['binary', 'decimal']
console.log(Notations.all().roman(false).values); // ▶ (4) ['binary', 'octal', 'decimal', 'hexadecimal']
console.log(new Notations().none().octal(true).values); // ▶ (1) ['octal']
Theme
:Root | Req/Opt | Type | Description |
---|---|---|---|
months |
✔ | Object<Image> |
All months images (12 required; { "january": <Image>, … } |
seasons |
✔ | Object<Image> |
All seasons images (4 required; { "winter": <Image>, … } |
Image | Req/Opt | Type | Description |
---|---|---|---|
path |
✔ | String |
Absolute or relative path to image file/URL to image source |
info |
ImageInfo |
Image info; if not presented will be automatically detected by path |
ImageInfo | Req/Opt | Type | Description |
---|---|---|---|
width |
✔ | Number |
Image width in pixels |
height |
✔ | Number |
Image height in pixels |
gradient |
Array<Color> |
Colors based on image to create gradient; required minimum 1 for seasons only |
Color | Req/Opt | Type | Description |
---|---|---|---|
red |
✔ | Number |
Red-component of RGB ; an integer between 0 and 255 |
green |
✔ | Number |
Green-component of RGB ; an integer between 0 and 255 |
blue |
✔ | Number |
Blue-component of RGB ; an integer between 0 and 255 |
alpha |
Number |
Alpha-component of RGB ; a float number between 0 and 1 |
Dependencies
- @jzucen/asserts-js: required for checking and validation input data;
- @jzucen/colors-js: required for making of colors (format, invert colors and so on);
- @jzucen/image-color-js: required for fetching of image (its part) dominant color;
- @jzucen/varname-case-js: required for converting names of style properties.
Sources of paintings
Great thanks to @gudoshnik for his paintings (see sample in public
folder).
Zodiac paintings were generated with help of Fusion Brain.
Описание
Calendar
Конвейеры
0 успешных
0 с ошибкой