Rewrote uploader without flow.js and prototype.js #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in OpenMage/magento-lts#2433 (comment), the usage of flow.js is rather pointless. It was probably just a quick solution to replace the old Flash uploader.
Commits
Misc library updates
no-display
class andstyle="display: none"
. Also added acheckVisibility
function since some places were using theElement.visible()
method from Prototype.adviceContainer
validation option and allow both the old typo'd name as well as the corrected name.xssFilter
function that was used in the uploader code, except rewritten in vanilla js.Rewrite uploader without flow.js and prototypejs
public/js/mage/adminhtml/uploader/instance.js
without flow.jsRewrite Downloadable Information Product Tab
Manage Products > Downloadable Information
tab needed some updates to work with the new uploader, but this code was so messy that I also rewrote it without PrototypeJS. The code was so old it checked to see ifconsole.log
was even a function.Other updates
Backwards Compatibility
There are some differences between the old uploader and new one:
The main difference is the events since the old code used Prototype's
fire()
method. Now that it is using native events, you must useaddEventListener
either ondocument.body
or on the uploader object itself (which extends theEventTarget
class). Also instead ofevent.memo
which is a prototype thing, you'll useevent.detail
which is native. It also passes an actual object instead of a JSON string for thefileSuccess
event. There are also a lot of new events that weren't exposed in the old code. So the whole thing is more flexible.Another change is that
replaceBrowseWithRemove
is integrated into the uploader class. Before setting that option would make the uploader fire an"upload:simulateDelete"
and"uploader:simulateNewUpload"
event, which was then handled by the downloadable information tab (the only place that used this option). It really didn't make any sense, and was probably just a legacy thing from the old Flash uploader.Another legacy thing was that the uploader endpoints returned the cookie value in the response JSON. I assume the Flash uploader needed that information for making requests. Really not a great thing for those who choose to have HTTP-only cookies.
Testing
I think those are the only placed it's used.