Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kalamu/media-manager
Javascript library for media managment on top of a RESTfull API
https://github.com/kalamu/media-manager
Last synced: 6 days ago
JSON representation
Javascript library for media managment on top of a RESTfull API
- Host: GitHub
- URL: https://github.com/kalamu/media-manager
- Owner: kalamu
- License: mit
- Created: 2019-06-14T06:06:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T06:22:27.000Z (almost 2 years ago)
- Last Synced: 2024-04-21T12:26:44.351Z (7 months ago)
- Language: JavaScript
- Size: 971 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kalamu / Media Manager
This library is a JavaScript media manager based on top of a RESTFull API.
The library include only the client side library.The goal is to provide a simple interface for :
* consulting medias
* uploadind/downloading files
* making simple changes on medias
* selecting files (in a form context)__For the moment, the library only work for images, but we plan to manage more
types of files shortly__# KalamuMediaManager
## Constructor
```js
var manager = new KalamuMediaManager(config);
```Config is a object with the following properties.
| Parameter | Required ? | Description |
|----------------------|:----------:|---------------------------------------------------------------------------------------------------------|
| `lang` | optional | Define the interface language. If not set, `navigator.language` is used. Accepted values are : en, fr |
| `dropZone` | required | DOM Element to add files (by drag'n drop or file input) |
| `displayZone` | required | DOM Element to display the file list |
| `infoZone` | required | DOM Element that must be a bootstrap modal to display file informations |
| `apiEntryPoint` | required | URL address of the RESTfull API |
| `selectable` | optional | Define if the files can be selected. Accepted values are : none, single, multiple |
| `onStart` | optional | Function triggered at startup, once the file list has been fetched from the API |
| `onSelectionChanged` | optional | Function triggered when the user change the file selection |## Methods
### getImages()
Return the list of image objects that are on the manager.
Exemple :
``` js
console.log(manager.getImages());
// > Array(4) [ {...}, {...}, {...}, {...} ]// get the uniq identifier of an image
console.log(manager.getImages()[0].config.identifier);
// > "0be916c4219e1a26c..."
```### getSelection()
Return an array containing the identifier of each image selected.
Exemple :
``` js
console.log(manager.getSelection());
// > Array(2) [ "0be916c4219e1a26c...", "15b8669705ab106b00bfc..." ]
```### setSelection(identifiers)
This method allow to set which files are selected.
Exemple :
``` js
console.log(manager.getSelection());
// > Array(2) [ "0be916c4219e1a26c...", "15b8669705ab106b00bfc..." ]manager.setSelection(["0be916c4219e1a26c..."]); // change the selection
console.log(manager.getSelection());
// > Array(1) [ "0be916c4219e1a26c..." ]
```