refactor drive to use dialog.selectable()

fix class on alertify-like boxes
pull/1/head
ansuz 7 years ago
parent fe2454ba31
commit bbf7ed3827

@ -58,11 +58,28 @@ define([
var dialog = UI.dialog = {};
dialog.selectable = function (value) {
var input = h('input', {
var merge = function (a, b) {
var c = {};
if (a) {
Object.keys(a).forEach(function (k) {
c[k] = a[k];
});
}
if (b) {
Object.keys(b).forEach(function (k) {
c[k] = b[k];
});
}
return c;
};
dialog.selectable = function (value, opt) {
var attrs = merge({
type: 'text',
readonly: 'readonly',
});
}, opt);
var input = h('input', attrs);
$(input).val(value).click(function () {
input.select();
});
@ -78,7 +95,7 @@ define([
};
dialog.message = function (text) {
return h('p.message', text);
return h('p.msg', text);
};
dialog.textInput = function (opt) {
@ -191,12 +208,20 @@ define([
UI.alert = function (msg, cb, force) {
cb = cb || function () {};
if (typeof(msg) === 'string' && force !== true) {
msg = Util.fixHTML(msg);
var message;
if (typeof(msg) === 'string') {
// sanitize
if (!force) { msg = Util.fixHTML(msg); }
message = dialog.message();
message.innerHTML = msg;
} else {
message = dialog.message(msg);
}
var ok = dialog.okButton();
var frame = dialog.frame([
dialog.message(msg),
message,
dialog.nav(ok),
]);

@ -2339,9 +2339,9 @@ define([
$('<br>').appendTo($d);
if (!ro) {
$('<label>', {'for': 'propLink'}).text(Messages.editShare).appendTo($d);
$('<input>', {'id': 'propLink', 'readonly': 'readonly', 'value': base + data.href})
.click(function () { $(this).select(); })
.appendTo($d);
$d.append(Cryptpad.dialog.selectable(base + data.href, {
id: 'propLink',
}));
}
var parsed = Cryptpad.parsePadUrl(data.href);
@ -2349,9 +2349,9 @@ define([
var roLink = ro ? base + data.href : getReadOnlyUrl(el);
if (roLink) {
$('<label>', {'for': 'propROLink'}).text(Messages.viewShare).appendTo($d);
$('<input>', {'id': 'propROLink', 'readonly': 'readonly', 'value': roLink})
.click(function () { $(this).select(); })
.appendTo($d);
$d.append(Cryptpad.dialog.selectable(roLink, {
id: 'propROLink',
}));
}
}
@ -2369,20 +2369,17 @@ define([
return void cb(void 0, $d);
}
var KB = Cryptpad.bytesToKilobytes(bytes);
var formatted = Messages._getKey('formattedKB', [KB]);
$('<br>').appendTo($d);
$('<label>', {
'for': 'size'
}).text(Messages.fc_sizeInKilobytes).appendTo($d);
$('<input>', {
$d.append(Cryptpad.dialog.selectable(formatted, {
id: 'size',
readonly: 'readonly',
value: KB + 'KB',
})
.click(function () { $(this).select(); })
.appendTo($d);
}));
cb(void 0, $d);
});
} else {
@ -2438,8 +2435,7 @@ define([
var el = filesOp.find(paths[0].path);
getProperties(el, function (e, $prop) {
if (e) { return void logError(e); }
Cryptpad.alert('', undefined, true);
$('.alertify .msg').html("").append($prop);
Cryptpad.alert($prop[0], undefined, true);
});
}
module.hideMenu();
@ -2490,8 +2486,7 @@ define([
var el = filesOp.find(paths[0].path);
getProperties(el, function (e, $prop) {
if (e) { return void logError(e); }
Cryptpad.alert('', undefined, true);
$('.alertify .msg').html("").append($prop);
Cryptpad.alert($prop[0], undefined, true);
});
}
module.hideMenu();

Loading…
Cancel
Save