Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove file button added #472

Merged
merged 8 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dist/PublicLab.Editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@
clear: left;
}

.thumbnailBtn:hover {
background-color: #efefef;
}

.thumbnailBtn:focus {
outline:none
}

.thumbnailBtn:active {
background-color: #d8d3d3;
}

.thumbnailBtn {
color: #000000b8;
background-color: white;
border-radius: 3px;
border: 1px solid black;
padding: 7px 14px;
font-weight: bold;
}

.ple-module-guide .ple-guide-minor p {
font-size: 12px;
}
Expand Down
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ <h1>Share</h1>
</div>

<p><input type="file" name="image[photo]" /></p>
<button id="removeFile" class="thumbnailBtn">Remove File</button>
<p class="ple-help">
<span class="ple-help-minor"
>Select an optional main image for your post.</span
Expand Down
42 changes: 26 additions & 16 deletions src/modules/PublicLab.MainImageModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({

init: function(_editor, options) {

var dragImageI = document.getElementById("mainImage");
var _module = this;

Expand Down Expand Up @@ -97,6 +97,7 @@ module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({

start: function(e) {

showImage = true;
_module.el.find('.progress .progress-bar')
.attr('aria-valuenow', '0')
.css('width', '0%');
Expand All @@ -109,21 +110,22 @@ module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({

done: function (e, data) {

_module.el.find('.progress .progress-bar')
.attr('aria-valuenow', '100')
.css('width', '100%');
_module.el.find('.progress').hide();
_module.dropEl.show();
_module.el.find('.progress').hide();
_module.dropEl.css('background-image', 'url("' + data.result.url + '")');

_module.value(data.result.url, data.result.id);
_module.dropEl.empty();
_editor.validate();

// primarily for testing:
if (_module.options.callback) _module.options.callback();

if (showImage) {
_module.el.find('.progress .progress-bar')
.attr('aria-valuenow', '100')
.css('width', '100%');
_module.el.find('.progress').hide();
_module.dropEl.show();
_module.el.find('.progress').hide();
_module.dropEl.css('background-image', 'url("' + data.result.url + '")');

_module.value(data.result.url, data.result.id);
_module.dropEl.empty();
_editor.validate();

// primarily for testing:
if (_module.options.callback) _module.options.callback();
}
},

// see callbacks at https://github.com/blueimp/jQuery-File-Upload/wiki/Options
Expand All @@ -146,6 +148,14 @@ module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({

});

// Remove Image button
var mainImage = document.getElementById('mainImage');
var removeFile = document.getElementById('removeFile');
removeFile.onclick = function () {
mainImage.style.background = 'white';
_module.el.find('.progress').hide();
showImage = false;
};

}

Expand Down