As "singleFileUpload" is used the "add" callback (which in turn calls
"addFileToUpload") will always be called with a single file. Therefore
there is no need to iterate over the files (and it is not done in the
other callbacks either, so this aligns the code with the rest of the
callbacks).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
There is no need to store the file name, as the "data" parameter given to
all the callbacks provides a "files" attribute with all the files that
the callback refers to; moreover, it will always be a single file due to
the use of "singleFileUploads" in the jQuery File Upload plugin.
This also fixes the loading icon not disappearing when several files were
uploaded at once. "singleFileUploads" causes the "add" callback to be
called once for each file to be uploaded, so "fileName" was overwritten
with the name of each new file in the upload set; when "fileName" was
later used in the "done" callback to find the file in the list whose
loading icon replace with the MIME type icon "fileName" always had the
name of the last file, and thus its icon was the only one replaced.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The "done" and "fail" callbacks both update the item for the uploaded
file using "setFileIcon". "setFileIcon" updates the contents of the
"<li>" element for the file, but the "fail" callback was giving
"setFileIcon" an element generated by the template, so the resulting
HTML contained a "<li>" element nested in another "<li>" element.
However, generating the HTML is better done through a template, so the
template now receives the icon to show in order to be used by a
successful upload and a failed one, and "setFileIcon" was changed to
"updateFileItem".
Note that the mimeTypeUrl does no longer need to be escaped, as
Handlebars templates escape the needed characters automatically.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When the "fail" callback is called, "errorThrown" is a property of the
data object instead of a parameter.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
If the estimated upload time is bigger than 4 hours it shows the text
"Uploading..." because the time then doesn't give any good hint to the
user anyways.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Pull request #5584 made cached SCSS files depend on a hash of the base
URL, so the "/css/core/server.css" file does no longer exist; as the
file can not be loaded the "Loading preview" message is never removed
and the "Saved" message is never shown.
As it now depends on the hash of the base URL the file to be reloaded
can no longer be hardcoded, so the full URL to the "server.css" file
that has to be reloaded (if any) is now got from the DataResponse
provided by the controller.
Fixes#5975
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This is a preparatory step for a following change in which
reloadStylesheets will have to be able to receive absolute URLs.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Pull request #5584 made cached SCSS files depend on a hash of the base
URL, so the "/css/core/server.css" file does no longer exist. The
"server.css" URL must be known by the Theming app in order to update the
stylesheets when previewing the changes to the theme, so the
DataResponse from the controller now provides the full URL to the
"server.css" file that has to be reloaded (if any).
The "server.css" URL provided by the response will be taken into account
by the JavaScript front-end in a following commit.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This is a preparatory step for a following commit in which the
properties present in the response will change depending on whether the
request was successful or not.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
As both elements are inline/inline-block and belong to the same line
they can be aligned vertically using "vertical-align: middle".
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When an image is being uploaded the upload icon is replaced by a loading
icon, so the loading icon and the upload icon have to share their CSS
rules, but only in that specific case; in general the loading icon is
used in a totally different way than the upload icon and thus it should
not share its CSS rules.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The removed rules were either always overriden by other rules or never
used due to not matching any element.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>