athena-ui-js 0.0.0-stage → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +280 -3
- package/package.json +58 -4
- package/src/athena-ui.js +78 -0
- package/src/libs/config/config.js +53 -0
- package/src/libs/config/hooks.js +34 -0
- package/src/libs/crypto-js/LICENSE +24 -0
- package/src/libs/crypto-js/crypto-js.js +6657 -0
- package/src/libs/hephaestus/HTMLControlGenerator/LICENSE +21 -0
- package/src/libs/hephaestus/HTMLControlGenerator/src/HTMLControlGenerator.min.js +5 -0
- package/src/libs/hephaestus/HTMLElementGenerator/LICENSE +21 -0
- package/src/libs/hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js +94 -0
- package/src/libs/hephaestus/HTMLElementGenerator/src/errors.js +46 -0
- package/src/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js +65 -0
- package/src/libs/hephaestus/LayoutGenerator/footerContentGenerator.js +38 -0
- package/src/libs/hephaestus/LayoutGenerator/headerContentGenerator.js +61 -0
- package/src/libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js +10 -0
- package/src/libs/hephaestus/MenuGenerator/basicMenuGenerator.js +52 -0
- package/src/libs/hephaestus/formGenerator/loginFormGenerator.js +90 -0
- package/src/libs/hephaestus/hephaestus.js +55 -0
- package/src/libs/hephaestus/modalGenerator/modalGenerator.js +22 -0
- package/src/libs/js-cookie/LICENSE +21 -0
- package/src/libs/js-cookie/src/api.mjs +103 -0
- package/src/libs/js-cookie/src/assign.mjs +10 -0
- package/src/libs/js-cookie/src/converter.mjs +14 -0
- package/src/libs/libs.js +13 -0
- package/src/res/themes/default/style.css +74 -0
- package/src/res/themes/themes.js +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Csaba Tóth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,280 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Athena UI
|
|
2
|
+
|
|
3
|
+
A small jQuery based UI framework for development and education purposes. It generates a page
|
|
4
|
+
layout (header, menu, content wrapper, footer), a login form and modal support from a single
|
|
5
|
+
`init()` call, and loads its own libraries and theme.
|
|
6
|
+
|
|
7
|
+
Current version: **0.4.1**
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Generated page layout: container, header (logo, title, menu), wrapper, footer (menu, copyright text)
|
|
12
|
+
- Menus built from your own item lists, with a navigation callback
|
|
13
|
+
- Login form with optional SHA-256 password hashing
|
|
14
|
+
- Modal open / close helpers
|
|
15
|
+
- Themes loaded at runtime, custom stylesheets supported
|
|
16
|
+
- Written as ES modules, no build step
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- [jQuery](https://jquery.com/) v4.0.0, loaded before Athena UI
|
|
21
|
+
- A browser with ES module support
|
|
22
|
+
- The page has to be served over HTTP(S). Modules do not load from `file://`.
|
|
23
|
+
|
|
24
|
+
Bundled as git submodules:
|
|
25
|
+
|
|
26
|
+
| Library | Version | Used for |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| [HTMLControlGenerator](https://github.com/csabatibortoth/HTMLControlGenerator) | 0.4.0 | inputs, lists |
|
|
29
|
+
| [HTMLElementGenerator](https://github.com/csabatibortoth/HTMLElementGenerator) | 0.3.0 | divs, headings, images |
|
|
30
|
+
| [crypto-js](https://github.com/brix/crypto-js) | 4.2.0 | password hashing |
|
|
31
|
+
| [js-cookie](https://github.com/js-cookie/js-cookie) | 3.0.8 | cookie handling |
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
git clone --recurse-submodules https://github.com/csabatibortoth/athena-ui.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In an existing clone, or after updating:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
git submodule update --init
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Serve the `src` folder with any static web server and open `index.html` to see the example.
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<script src="https://code.jquery.com/jquery-4.0.0.min.js"
|
|
51
|
+
integrity="sha256-OaVG6prZf4v69dPg6PhVattBXkcOWQB62pdZ3ORyrao=" crossorigin="anonymous"></script>
|
|
52
|
+
<script type="module">
|
|
53
|
+
import { init, clearWrapper, generateLoginForm } from "./athena-ui.js";
|
|
54
|
+
|
|
55
|
+
init({
|
|
56
|
+
theme: { id: 0 },
|
|
57
|
+
config: { header_title_text: "My App", login_enabled: true },
|
|
58
|
+
menuItems: {
|
|
59
|
+
headerMenu: [
|
|
60
|
+
{ id: "menu-home", class: "menu-item", text: "", inner_text: "Home" },
|
|
61
|
+
{ id: "menu-login", class: "menu-item", text: "", inner_text: "Login" }
|
|
62
|
+
],
|
|
63
|
+
footerMenu: []
|
|
64
|
+
},
|
|
65
|
+
nav: page => {
|
|
66
|
+
if (page === "Login") {
|
|
67
|
+
clearWrapper();
|
|
68
|
+
generateLoginForm();
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
login: ({ username, password }) => console.log(`${username} logged in`)
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`init()` returns a Promise that resolves with the effective configuration once the libraries and
|
|
77
|
+
the theme are loaded and the layout is generated.
|
|
78
|
+
|
|
79
|
+
### init options
|
|
80
|
+
|
|
81
|
+
| Option | Description |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `theme` | `{ id }` of a theme registered in `res/themes/themes.js`, or `{ href }` of a custom stylesheet. Defaults to the default theme. |
|
|
84
|
+
| `config` | Settings overriding the defaults, see [Configuration](#configuration). |
|
|
85
|
+
| `menuItems` | `{ headerMenu, footerMenu }`, arrays of `{ id, class, text, inner_text }`. Placeholder items are generated without it. |
|
|
86
|
+
| `nav` | Called without arguments when the wrapper is generated, and with the `inner_text` of the item on menu clicks. |
|
|
87
|
+
| `login` | Called with `{ username, password }` when the login button is clicked and `login_enabled` is set. |
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
| Setting | Default | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `header_title_text` | `"Athena UI"` | Title in the header |
|
|
94
|
+
| `header_img_url` | | Header logo URL |
|
|
95
|
+
| `copyright` | placeholder text | Footer text, the version is appended |
|
|
96
|
+
| `version` | `"0.4.1"` | Version shown in the footer |
|
|
97
|
+
| `bordered` | `true` | Draw a border around the layout blocks |
|
|
98
|
+
| `generateHeader`, `generateFooter` | `true` | Generate the header / footer block |
|
|
99
|
+
| `generateHeadercontent`, `generateFooterContent`, `generateWrappercontent` | `true` | Generate the content of the block |
|
|
100
|
+
| `login_enabled` | `false` | Call the `login` callback from the login form |
|
|
101
|
+
| `enable_encrypt_password` | `false` | SHA-256 hash the password before it is passed to `login` |
|
|
102
|
+
| `customLoader` | | URL of an extra classic script, loaded before the layout is generated |
|
|
103
|
+
| `container_class`, `header_class`, `header_menu_class`, `wrapper_class`, `footer_class`, `footer_menu_class`, `loginForm_class` | | CSS classes of the generated blocks |
|
|
104
|
+
|
|
105
|
+
### API
|
|
106
|
+
|
|
107
|
+
Everything is exported from `athena-ui.js`:
|
|
108
|
+
|
|
109
|
+
| Export | Description |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `init(options)` | Loads everything and generates the layout |
|
|
112
|
+
| `config` | The live configuration object |
|
|
113
|
+
| `generateBasicLayout()`, `generateHeader()`, `generateWrapper()`, `generateFooter()` | Layout generation |
|
|
114
|
+
| `clearHeader()`, `clearWrapper()`, `clearFooter()`, `clearHeaderMenu()`, `clearFooterMenu()` | Empty a block |
|
|
115
|
+
| `generateBasicMenu(options)` | Generate a menu into any parent |
|
|
116
|
+
| `generateLoginForm()`, `getLoginFormData()` | Login form into the wrapper, and its current values |
|
|
117
|
+
| `openModal(id)`, `closeModal(id)` | Show / hide a `.modal` element (default id: `myModal`). Elements with the `close` class close their modal. |
|
|
118
|
+
| `loadScript(src)` | Load a classic script once, returns a Promise |
|
|
119
|
+
| `Cookies` | The [js-cookie](https://github.com/js-cookie/js-cookie) API |
|
|
120
|
+
| `HTMLElementGenerator(options)` | The [HTMLElementGenerator](https://github.com/csabatibortoth/HTMLElementGenerator) function |
|
|
121
|
+
|
|
122
|
+
### Usage from classic scripts
|
|
123
|
+
|
|
124
|
+
The same API is available as globals (and as `AthenaUI`), so scripts written for earlier versions
|
|
125
|
+
keep working. Load `athena-ui.js` with `type="module"` and call the globals after the DOM is ready:
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<script>
|
|
129
|
+
var appConfig = { header_title_text: "My App", customLoader: "js/app.js" };
|
|
130
|
+
</script>
|
|
131
|
+
<script type="module" src="athena-ui/src/athena-ui.js"></script>
|
|
132
|
+
<script>
|
|
133
|
+
$(function () {
|
|
134
|
+
init({ theme: { id: 0 } });
|
|
135
|
+
});
|
|
136
|
+
</script>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The global `appConfig`, `menuItems`, `nav` and `login` are used when the matching `init` option is
|
|
140
|
+
not given. `appConfig.athenaUIFolder` is not needed anymore, paths are resolved relative to
|
|
141
|
+
`athena-ui.js`.
|
|
142
|
+
|
|
143
|
+
## Themes
|
|
144
|
+
|
|
145
|
+
A theme is a single stylesheet. Register it in `src/res/themes/themes.js` and select it with
|
|
146
|
+
`theme: { id }`, or pass any stylesheet directly with `theme: { href: "css/my-theme.css" }`.
|
|
147
|
+
The default theme is in `src/res/themes/default/style.css`.
|
|
148
|
+
|
|
149
|
+
## Project structure
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
src/
|
|
153
|
+
athena-ui.js entry point, exports the whole API
|
|
154
|
+
index.html, example.js example page
|
|
155
|
+
libs/
|
|
156
|
+
config/ default configuration, application hooks
|
|
157
|
+
hephaestus/ script and theme loader, layout / menu / form / modal generators
|
|
158
|
+
crypto-js/, js-cookie/ submodules
|
|
159
|
+
libs.js classic scripts loaded at runtime
|
|
160
|
+
res/themes/ themes
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Authors
|
|
164
|
+
|
|
165
|
+
* **Csaba Tóth** - *Initial work* - [csabatibortoth](https://github.com/csabatibortoth)
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
|
|
170
|
+
|
|
171
|
+
## Releases
|
|
172
|
+
|
|
173
|
+
### 0.4.1
|
|
174
|
+
#### Changed:
|
|
175
|
+
1. HTMLControlGenerator v0.4.0, HTMLElementGenerator v0.3.0, js-cookie updated to the latest master
|
|
176
|
+
2. HTMLElementGenerator is imported as an ES module instead of being loaded as a classic script
|
|
177
|
+
3. crypto-js follows the `master` branch, which holds the built release files
|
|
178
|
+
#### Added:
|
|
179
|
+
1. `HTMLElementGenerator` is exported from `athena-ui.js` (and stays available as a global)
|
|
180
|
+
#### Bugfix:
|
|
181
|
+
1. The label of a menu item without an `id` is not appended to the page body
|
|
182
|
+
|
|
183
|
+
### 0.4.0
|
|
184
|
+
#### Changed:
|
|
185
|
+
1. Rewritten as ES modules (no more chained `$.getScript` loading, no implicit globals)
|
|
186
|
+
2. JQuery v4.0.0, js-cookie v3.0.8, crypto-js v4.2.0
|
|
187
|
+
3. Libraries and theme load in parallel, the layout is generated when all of them are ready
|
|
188
|
+
4. Theme CSS merged into a single file
|
|
189
|
+
5. `init()` returns a Promise and accepts `config`, `nav`, `login`, `menuItems`
|
|
190
|
+
#### Bugfix:
|
|
191
|
+
1. Theme option (`theme` / `themes`) is respected, unknown theme falls back to the default
|
|
192
|
+
2. Menu class does not start with "undefined"
|
|
193
|
+
3. Modal script does not fail when the page has no modal
|
|
194
|
+
4. Login data is not written to the console
|
|
195
|
+
|
|
196
|
+
### 0.3.6
|
|
197
|
+
#### Added
|
|
198
|
+
1. submodule update
|
|
199
|
+
|
|
200
|
+
### 0.3.4
|
|
201
|
+
#### Added:
|
|
202
|
+
1. support for custom JS loading
|
|
203
|
+
#### Bugfix:
|
|
204
|
+
1. Theme name fix
|
|
205
|
+
|
|
206
|
+
### 0.3.3
|
|
207
|
+
#### Added:
|
|
208
|
+
1. Modal support
|
|
209
|
+
|
|
210
|
+
### 0.3.2
|
|
211
|
+
#### Added:
|
|
212
|
+
1. title change
|
|
213
|
+
2. copyright text change
|
|
214
|
+
|
|
215
|
+
### 0.3.1
|
|
216
|
+
#### Added:
|
|
217
|
+
1. Header element container added
|
|
218
|
+
|
|
219
|
+
### 0.3.0
|
|
220
|
+
#### Added:
|
|
221
|
+
1. Navigation Function call for menu
|
|
222
|
+
|
|
223
|
+
### 0.2.9
|
|
224
|
+
#### Bugfix:
|
|
225
|
+
1. Login form generation bugfix 2
|
|
226
|
+
|
|
227
|
+
### 0.2.8
|
|
228
|
+
#### Bugfix:
|
|
229
|
+
1. Login form generation bugfix
|
|
230
|
+
|
|
231
|
+
### 0.2.7
|
|
232
|
+
#### Added:
|
|
233
|
+
1. Basic layout div clear functions
|
|
234
|
+
|
|
235
|
+
### 0.2.6
|
|
236
|
+
#### Added:
|
|
237
|
+
1. Header Logo
|
|
238
|
+
2. Updated Submodules
|
|
239
|
+
|
|
240
|
+
### 0.2.5
|
|
241
|
+
#### Added
|
|
242
|
+
1. JS-Cookie
|
|
243
|
+
|
|
244
|
+
### 0.2.4
|
|
245
|
+
#### Added
|
|
246
|
+
1. Crypto-JS
|
|
247
|
+
2. Password encryption support
|
|
248
|
+
|
|
249
|
+
#### Bugfixes
|
|
250
|
+
1. Login form generation
|
|
251
|
+
|
|
252
|
+
### 0.2.3
|
|
253
|
+
#### Bugfixes
|
|
254
|
+
1. Bugfixes on login form generation
|
|
255
|
+
|
|
256
|
+
### 0.2.2
|
|
257
|
+
#### Added:
|
|
258
|
+
1. Login Form generation
|
|
259
|
+
|
|
260
|
+
#### Bugfix:
|
|
261
|
+
1. Config loading error fixed
|
|
262
|
+
|
|
263
|
+
### 0.2.1
|
|
264
|
+
#### Bugfix:
|
|
265
|
+
1. Some bugfixes on element generation
|
|
266
|
+
|
|
267
|
+
### 0.2.0
|
|
268
|
+
#### Added:
|
|
269
|
+
1. Element generation from external configuration
|
|
270
|
+
|
|
271
|
+
### 0.1.1
|
|
272
|
+
#### Added:
|
|
273
|
+
1. Fixes
|
|
274
|
+
|
|
275
|
+
### 0.1.0
|
|
276
|
+
#### Added:
|
|
277
|
+
1. basic html layout generation
|
|
278
|
+
2. header generation
|
|
279
|
+
3. footer generation
|
|
280
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "athena-ui-js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "A small jQuery based UI framework: generated page layout, menus, login form, modals and themes, written as ES modules.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/athena-ui.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/athena-ui.js",
|
|
9
|
+
"./themes/*": "./src/res/themes/*",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src/athena-ui.js",
|
|
14
|
+
"src/libs/libs.js",
|
|
15
|
+
"src/libs/config",
|
|
16
|
+
"src/libs/hephaestus/hephaestus.js",
|
|
17
|
+
"src/libs/hephaestus/LayoutGenerator",
|
|
18
|
+
"src/libs/hephaestus/MenuGenerator",
|
|
19
|
+
"src/libs/hephaestus/formGenerator",
|
|
20
|
+
"src/libs/hephaestus/modalGenerator",
|
|
21
|
+
"src/libs/hephaestus/HTMLControlGenerator/LICENSE",
|
|
22
|
+
"src/libs/hephaestus/HTMLControlGenerator/src/HTMLControlGenerator.min.js",
|
|
23
|
+
"src/libs/hephaestus/HTMLElementGenerator/LICENSE",
|
|
24
|
+
"src/libs/hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js",
|
|
25
|
+
"src/libs/hephaestus/HTMLElementGenerator/src/errors.js",
|
|
26
|
+
"src/libs/crypto-js/LICENSE",
|
|
27
|
+
"src/libs/crypto-js/crypto-js.js",
|
|
28
|
+
"src/libs/js-cookie/LICENSE",
|
|
29
|
+
"src/libs/js-cookie/src",
|
|
30
|
+
"src/res"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": true,
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ui",
|
|
35
|
+
"framework",
|
|
36
|
+
"jquery",
|
|
37
|
+
"layout",
|
|
38
|
+
"menu",
|
|
39
|
+
"login-form",
|
|
40
|
+
"modal",
|
|
41
|
+
"themes",
|
|
42
|
+
"es-modules"
|
|
43
|
+
],
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"jquery": "^4.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/csabatibortoth/athena-ui.git"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/csabatibortoth/athena-ui#readme",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/csabatibortoth/athena-ui/issues"
|
|
57
|
+
},
|
|
58
|
+
"author": "Csaba Tóth (https://github.com/csabatibortoth)",
|
|
59
|
+
"license": "MIT"
|
|
60
|
+
}
|
package/src/athena-ui.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//Athena UI
|
|
2
|
+
//Author: Csaba Tóth https://github.com/csabatibortoth/
|
|
3
|
+
//LICENCE: MIT
|
|
4
|
+
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
5
|
+
//Version: 0.4.1
|
|
6
|
+
|
|
7
|
+
/* global $ */
|
|
8
|
+
|
|
9
|
+
import config, { applyConfig } from "./libs/config/config.js";
|
|
10
|
+
import { getAppConfig, setHooks } from "./libs/config/hooks.js";
|
|
11
|
+
import { loadLibs, loadScript, loadTheme } from "./libs/hephaestus/hephaestus.js";
|
|
12
|
+
import * as layout from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
13
|
+
import * as header from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
14
|
+
import * as wrapper from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
15
|
+
import * as footer from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
16
|
+
import * as menu from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
17
|
+
import * as loginForm from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
18
|
+
import * as modal from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
19
|
+
import Cookies from "./libs/js-cookie/src/api.mjs";
|
|
20
|
+
import { HTMLElementGenerator } from "./libs/hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js";
|
|
21
|
+
|
|
22
|
+
if (typeof $ !== "function") {
|
|
23
|
+
throw new Error("Athena UI: jQuery has to be loaded before athena-ui.js");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Loads the libraries and the theme in parallel, then generates the layout.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} [options]
|
|
30
|
+
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
31
|
+
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
32
|
+
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
33
|
+
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
34
|
+
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
35
|
+
* @returns {Promise<object>} the effective configuration
|
|
36
|
+
*/
|
|
37
|
+
export async function init(options = {}) {
|
|
38
|
+
applyConfig(getAppConfig(), options.config);
|
|
39
|
+
setHooks(options);
|
|
40
|
+
|
|
41
|
+
await Promise.all([
|
|
42
|
+
loadLibs(config.customLoader ? [config.customLoader] : []),
|
|
43
|
+
loadTheme(options.theme ?? options.themes),
|
|
44
|
+
new Promise(resolve => $(resolve))
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
layout.generateBasicLayout();
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const AthenaUI = {
|
|
52
|
+
init,
|
|
53
|
+
config,
|
|
54
|
+
loadScript,
|
|
55
|
+
Cookies,
|
|
56
|
+
HTMLElementGenerator,
|
|
57
|
+
...layout,
|
|
58
|
+
...header,
|
|
59
|
+
...wrapper,
|
|
60
|
+
...footer,
|
|
61
|
+
...menu,
|
|
62
|
+
...loginForm,
|
|
63
|
+
...modal
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Classic scripts (the customLoader, inline handlers) keep working: the whole API
|
|
67
|
+
// stays reachable as globals, like in the pre-module versions.
|
|
68
|
+
Object.assign(globalThis, AthenaUI, { AthenaUI });
|
|
69
|
+
|
|
70
|
+
export { config, loadScript, Cookies, HTMLElementGenerator };
|
|
71
|
+
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
72
|
+
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
73
|
+
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
74
|
+
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
75
|
+
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
76
|
+
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
77
|
+
export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
78
|
+
export default AthenaUI;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//config for Athena UI
|
|
2
|
+
//Author: Csaba Tóth https://github.com/csabatibortoth/
|
|
3
|
+
//LICENCE: MIT
|
|
4
|
+
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
5
|
+
|
|
6
|
+
export const BORDERED_CLASS = "default-cointainer-bordered";
|
|
7
|
+
|
|
8
|
+
export const defaults = Object.freeze({
|
|
9
|
+
version: "0.4.1",
|
|
10
|
+
container_class: "container",
|
|
11
|
+
header_class: "header-container",
|
|
12
|
+
header_menu_class: "header-menu menu",
|
|
13
|
+
wrapper_class: "wrapper-container",
|
|
14
|
+
footer_class: "footer-container",
|
|
15
|
+
footer_menu_class: "footer-menu menu",
|
|
16
|
+
loginForm_class: "login-form form",
|
|
17
|
+
|
|
18
|
+
bordered: true,
|
|
19
|
+
generateHeader: true,
|
|
20
|
+
generateFooter: true,
|
|
21
|
+
generateHeadercontent: true,
|
|
22
|
+
generateFooterContent: true,
|
|
23
|
+
generateWrappercontent: true,
|
|
24
|
+
login_enabled: false,
|
|
25
|
+
enable_encrypt_password: false,
|
|
26
|
+
|
|
27
|
+
header_title_text: "Athena UI",
|
|
28
|
+
header_img_url: undefined,
|
|
29
|
+
copyright: "Here is the bottom Copyright Text for website",
|
|
30
|
+
|
|
31
|
+
// URL (relative to the page) of an extra classic script, loaded before the layout is generated
|
|
32
|
+
customLoader: undefined
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const config = { ...defaults };
|
|
36
|
+
|
|
37
|
+
export default config;
|
|
38
|
+
|
|
39
|
+
// Copies every known setting that is defined in the given sources onto the live config.
|
|
40
|
+
export function applyConfig(...sources) {
|
|
41
|
+
for (const source of sources) {
|
|
42
|
+
if (!source) continue;
|
|
43
|
+
for (const key of Object.keys(defaults)) {
|
|
44
|
+
if (source[key] !== undefined) config[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return config;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Appends the border class to a class list when borders are enabled.
|
|
51
|
+
export function withBorder(className) {
|
|
52
|
+
return config.bordered ? `${className} ${BORDERED_CLASS}` : className;
|
|
53
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//application hooks for Athena UI
|
|
2
|
+
//Author: Csaba Tóth https://github.com/csabatibortoth/
|
|
3
|
+
//LICENCE: MIT
|
|
4
|
+
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
5
|
+
|
|
6
|
+
/* global appConfig, menuItems, nav, login */
|
|
7
|
+
|
|
8
|
+
// Hooks can be passed to init({ nav, login, menuItems }). When they are not, the
|
|
9
|
+
// page-level globals of the same name (appConfig, menuItems, nav, login) are used.
|
|
10
|
+
// Globals are looked up on every call, so they may be defined after init().
|
|
11
|
+
|
|
12
|
+
const hooks = {};
|
|
13
|
+
|
|
14
|
+
export function setHooks(options = {}) {
|
|
15
|
+
for (const name of ["nav", "login", "menuItems"]) {
|
|
16
|
+
if (options[name] !== undefined) hooks[name] = options[name];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getAppConfig() {
|
|
21
|
+
return typeof appConfig !== "undefined" ? appConfig : undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getMenuItems() {
|
|
25
|
+
return hooks.menuItems ?? (typeof menuItems !== "undefined" ? menuItems : undefined);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getNav() {
|
|
29
|
+
return hooks.nav ?? (typeof nav === "function" ? nav : undefined);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getLogin() {
|
|
33
|
+
return hooks.login ?? (typeof login === "function" ? login : undefined);
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2009-2013 Jeff Mott
|
|
6
|
+
Copyright (c) 2013-2016 Evan Vosberg
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|