From 257a0352dba6af3e88de4377395df8a083f48f3b Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 8 Oct 2017 15:16:38 +1300 Subject: [PATCH] sdk: rename some methods --- static/sdk.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/static/sdk.js b/static/sdk.js index abd1740..8f40e17 100644 --- a/static/sdk.js +++ b/static/sdk.js @@ -17,24 +17,22 @@ var contented = (function ($, currentScriptPath) { }; /** - * contented_SupportsDrop returns whether drag-and-drop is supported by this - * browser. + * supportsDrop returns whether drag-and-drop is supported by this browser. * * @return bool */ - var contented_SupportsDrop = function () { + var supportsDrop = function () { return ('ondrop' in window && 'FormData' in window && 'FileReader' in window); } /** - * contented_EnableDrop enables drag-and-drop upload on a DOM element. - * The class "is-dragover" will be toggled on the target element. + * initArea shows the contented upload widget over the top of a target DOM element. * * @param any element Drop target (string selector / DOMElement / jQuery) - * @param Function onUploaded Called with a property object for every uploaded file - * @param Function onClose Called when the widget should be destroyed + * @param Function onUploaded Called with an array of upload IDs + * @param Function onClose Called when the widget is being destroyed */ - var contented_EnableDrop = function (elementSelector, onUploaded, onClose) { + var initArea = function (elementSelector, onUploaded, onClose) { onUploaded = onUploaded || function () { }; onClose = onClose || function () { }; @@ -79,7 +77,7 @@ var contented = (function ($, currentScriptPath) { setType($(this).attr('data-upload-type')); }); - if (!contented_SupportsDrop()) { + if (!supportsDrop()) { // switch default setType('file'); } @@ -190,8 +188,8 @@ var contented = (function ($, currentScriptPath) { // return { - 'supportsDrop': contented_SupportsDrop, - 'init': contented_EnableDrop + 'supportsDrop': supportsDrop, + 'init': initArea }; })(