Skip to content

Commit

Permalink
Updated dependencies and published v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsboogaard-luminis committed Jan 25, 2023
1 parent b845f27 commit b600f97
Show file tree
Hide file tree
Showing 11 changed files with 4,024 additions and 5,318 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
npm-debug.log
node_modules/
.idea/
.idea/
*.iml
2 changes: 1 addition & 1 deletion dist/filepond-plugin-get-file.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePondPluginmediaPreview 1.0.7
* FilePondPluginmediaPreview 1.1.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit undefined for details.
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond-plugin-get-file.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePondPluginGetFile 1.0.7
* FilePondPluginGetFile 1.1.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit undefined for details.
*/
Expand Down Expand Up @@ -147,4 +147,4 @@ if (isBrowser) {
);
}

export default plugin;
export { plugin as default };
4 changes: 2 additions & 2 deletions dist/filepond-plugin-get-file.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 19 additions & 18 deletions dist/filepond-plugin-get-file.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePondPluginGetFile 1.0.7
* FilePondPluginGetFile 1.1.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit undefined for details.
*/
Expand Down Expand Up @@ -31,39 +31,37 @@
mainInfo = el.querySelector('.filepond--file-info-main'),
downloadIcon = getDownloadIcon(labelButtonDownload);
let container = el.querySelector('.filepond--file-info-main-container');

if (!container) {
container = document.createElement('div');
container.className = 'filepond--file-info-main-container';
container.append(mainInfo);
info.prepend(container);
}

container.prepend(downloadIcon);
downloadIcon.addEventListener('click', () =>
downloadFile(item, allowDownloadByUrl, downloadFunction)
);
};

/**
* Generates the download icon
*/

const getDownloadIcon = (labelButtonDownload) => {
let icon = document.createElement('span');
icon.className = 'filepond--download-icon';
icon.title = labelButtonDownload;
return icon;
};

/**
* Triggers the actual download of the uploaded file
*/

const downloadFile = (item, allowDownloadByUrl, downloadFunction) => {
if (downloadFunction && typeof downloadFunction === 'function') {
downloadFunction(item);
return;
} // if client want to download file from remote server

}
// if client want to download file from remote server
if (allowDownloadByUrl && item.getMetadata('url')) {
location.href = item.getMetadata('url'); // full path to remote server is stored in metadata with key 'url'
} else {
Expand All @@ -83,27 +81,27 @@
/**
* Download Plugin
*/

const plugin = (fpAPI) => {
const { addFilter, utils } = fpAPI;
const { Type, createRoute } = utils; // called for each view that is created right after the 'create' method
const { Type, createRoute } = utils;

// called for each view that is created right after the 'create' method
addFilter('CREATE_VIEW', (viewAPI) => {
// get reference to created view
const { is, view, query } = viewAPI; // only hook up to item view
const { is, view, query } = viewAPI;

// only hook up to item view
if (!is('file')) {
return;
} // create the get file plugin
}

// create the get file plugin
const didLoadItem = ({ root, props }) => {
const { id } = props;
const item = query('GET_ITEM', id);

if (!item || item.archived) {
return;
}

const labelButtonDownload = root.query(
'GET_LABEL_BUTTON_DOWNLOAD_ITEM'
);
Expand All @@ -116,35 +114,38 @@
allowDownloadByUrl,
downloadFunction
);
}; // start writing
};

// start writing
view.registerWriter(
createRoute(
{
DID_LOAD_ITEM: didLoadItem,
},
({ root, props }) => {
const { id } = props;
const item = query('GET_ITEM', id); // don't do anything while hidden
const item = query('GET_ITEM', id);

// don't do anything while hidden
if (root.rect.element.hidden) return;
}
)
);
}); // expose plugin
});

// expose plugin
return {
options: {
labelButtonDownloadItem: ['Download file', Type.STRING],
allowDownloadByUrl: [false, Type.BOOLEAN],
downloadFunction: [null, Type.FUNCTION],
},
};
}; // fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
};

// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
const isBrowser =
typeof window !== 'undefined' && typeof window.document !== 'undefined';

if (isBrowser) {
document.dispatchEvent(
new CustomEvent('FilePond:pluginloaded', {
Expand Down
2 changes: 1 addition & 1 deletion dist/filepond-plugin-get-file.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/filepond-plugin-get-file.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b600f97

Please sign in to comment.