diff --git a/themes/default/templates/partial/myfiles.js.ep b/themes/default/templates/partial/myfiles.js.ep
index db8254b..6a81f61 100644
--- a/themes/default/templates/partial/myfiles.js.ep
+++ b/themes/default/templates/partial/myfiles.js.ep
@@ -66,6 +66,57 @@ function onCheck(e) {
rmFromRandomHash(short);
}
}
+function delView(del_at_view) {
+ return (del_at_view) ? '
' : '
';
+}
+function editImage(e) {
+ e.preventDefault();
+ var url = $(this).data('modlink');
+ var short = $(this).data('modshort');
+ var name = $(this).data('modname');
+ var delay = $(this).data('moddelay');
+ var firstview = $(this).data('modfirstview');
+ var created_at = $(this).data('modcreated_at');
+
+ $('#mod-name').html(name);
+ $('#mod-delete-day').val(delay);
+ $('#mod-first-view').prop('checked', firstview);
+ $('#mod-delay').data('modlink', url),
+ $('#mod-delay').data('modshort', short);
+ $('#mod-delay').data('modcreated_at', created_at);
+
+ $('#modModal').modal('show');
+}
+function modifyDelay() {
+ var limit = $('#mod-delete-day').val();
+ var del_at_view = ($('#mod-first-view').prop('checked')) ? 1 : 0;
+ var short = $('#mod-delay').data('modshort');
+ var created_at = $('#mod-delay').data('modcreated_at');
+ $.ajax({
+ url : $('#mod-delay').data('modlink'),
+ type : 'POST',
+ data : {
+ 'format' : 'json',
+ 'delete-day' : limit,
+ 'first-view' : del_at_view
+ },
+ success: function(data) {
+ updateItem(short, parseInt(limit), del_at_view);
+ var newLimit = (parseInt(limit, 10) === 0) ? '<%= l('No limit') %>' : moment.unix(limit * 86400 + created_at).locale(window.navigator.language).format('LLLL');
+ $('#limit-'+short).html(newLimit);
+ $('#del_at_view-'+short).html(delView(del_at_view));
+ $('#edit-'+short).data('moddelay', limit);
+ $('#edit-'+short).data('modfirstview', del_at_view);
+ goodToast(data.msg);
+ },
+ error: function() {
+ badToast('<%= l('Error while trying to modify the image.') %>');
+ },
+ complete: function() {
+ $('#modModal').modal('hide');
+ }
+ });
+}
function populateFilesTable() {
var localImages = localStorage.getItem('images');
if (localImages === null) {
@@ -77,7 +128,6 @@ function populateFilesTable() {
files.forEach(function(element, index, array) {
var real_short = element.real_short;
var vlink = link(element.short+'.'+element.ext, '');
- var del_view = (element.del_at_view) ? '
' : '
';
var dlink = link(real_short, 'dl', element.token, false, true);
var limit = (element.limit === 0) ? '<%= l('No limit') %>' : moment.unix(element.limit * 86400 + element.created_at).locale(window.navigator.language).format('LLLL');
var created_at = moment.unix(element.created_at).locale(window.navigator.language).format('LLLL');
@@ -85,21 +135,27 @@ function populateFilesTable() {
var name = element.filename.replace(//g, '>');
var tr = [
'
',
- ' ',
+ ' ',
'', name, ' ',
'',
' ',
' ',
' ',
' ',
- '', del_view, ' ',
+ '', delView(element.del_at_view), ' ',
'', created_at, ' ',
- '', limit, ' ',
+ '',
+ '', limit, ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
' ',
' '
].join('');
$('#myfiles').append(tr);
$('#del-'+real_short).on('click', delImage);
+ $('#edit-'+real_short).on('click', editImage);
$.ajax({
url : '<%== url_for('counter') %>',
@@ -125,6 +181,6 @@ function populateFilesTable() {
}
});
});
- $('input[type="checkbox"]').on('change', onCheck);
+ $('input.ckbx[type="checkbox"]').on('change', onCheck);
$('.copy-to-clipboard').on('click', copyLink);
}
diff --git a/utilities/bootstrap-config.json b/utilities/bootstrap-config.json
index 5e77d7f..fe5f0d5 100644
--- a/utilities/bootstrap-config.json
+++ b/utilities/bootstrap-config.json
@@ -397,11 +397,13 @@
"progress-bars.less",
"close.less",
"component-animations.less",
- "dropdowns.less"
+ "dropdowns.less",
+ "modals.less"
],
"js": [
"alert.js",
"dropdown.js",
+ "modal.js",
"collapse.js",
"transition.js"
],
diff --git a/utilities/fontello-config.json b/utilities/fontello-config.json
index 5fc3f63..82dd719 100644
--- a/utilities/fontello-config.json
+++ b/utilities/fontello-config.json
@@ -95,6 +95,12 @@
"css": "shuffle",
"code": 59402,
"src": "entypo"
+ },
+ {
+ "uid": "41087bc74d4b20b55059c60a33bf4008",
+ "css": "edit",
+ "code": 59407,
+ "src": "fontawesome"
}
]
}
\ No newline at end of file