refactor drive to use dialog.selectable()
fix class on alertify-like boxes
This commit is contained in:
parent
fe2454ba31
commit
bbf7ed3827
@ -58,11 +58,28 @@ define([
|
|||||||
|
|
||||||
var dialog = UI.dialog = {};
|
var dialog = UI.dialog = {};
|
||||||
|
|
||||||
dialog.selectable = function (value) {
|
var merge = function (a, b) {
|
||||||
var input = h('input', {
|
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',
|
type: 'text',
|
||||||
readonly: 'readonly',
|
readonly: 'readonly',
|
||||||
});
|
}, opt);
|
||||||
|
|
||||||
|
var input = h('input', attrs);
|
||||||
$(input).val(value).click(function () {
|
$(input).val(value).click(function () {
|
||||||
input.select();
|
input.select();
|
||||||
});
|
});
|
||||||
@ -78,7 +95,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
dialog.message = function (text) {
|
dialog.message = function (text) {
|
||||||
return h('p.message', text);
|
return h('p.msg', text);
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog.textInput = function (opt) {
|
dialog.textInput = function (opt) {
|
||||||
@ -191,12 +208,20 @@ define([
|
|||||||
|
|
||||||
UI.alert = function (msg, cb, force) {
|
UI.alert = function (msg, cb, force) {
|
||||||
cb = cb || function () {};
|
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 ok = dialog.okButton();
|
||||||
var frame = dialog.frame([
|
var frame = dialog.frame([
|
||||||
dialog.message(msg),
|
message,
|
||||||
dialog.nav(ok),
|
dialog.nav(ok),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -2339,9 +2339,9 @@ define([
|
|||||||
$('<br>').appendTo($d);
|
$('<br>').appendTo($d);
|
||||||
if (!ro) {
|
if (!ro) {
|
||||||
$('<label>', {'for': 'propLink'}).text(Messages.editShare).appendTo($d);
|
$('<label>', {'for': 'propLink'}).text(Messages.editShare).appendTo($d);
|
||||||
$('<input>', {'id': 'propLink', 'readonly': 'readonly', 'value': base + data.href})
|
$d.append(Cryptpad.dialog.selectable(base + data.href, {
|
||||||
.click(function () { $(this).select(); })
|
id: 'propLink',
|
||||||
.appendTo($d);
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsed = Cryptpad.parsePadUrl(data.href);
|
var parsed = Cryptpad.parsePadUrl(data.href);
|
||||||
@ -2349,9 +2349,9 @@ define([
|
|||||||
var roLink = ro ? base + data.href : getReadOnlyUrl(el);
|
var roLink = ro ? base + data.href : getReadOnlyUrl(el);
|
||||||
if (roLink) {
|
if (roLink) {
|
||||||
$('<label>', {'for': 'propROLink'}).text(Messages.viewShare).appendTo($d);
|
$('<label>', {'for': 'propROLink'}).text(Messages.viewShare).appendTo($d);
|
||||||
$('<input>', {'id': 'propROLink', 'readonly': 'readonly', 'value': roLink})
|
$d.append(Cryptpad.dialog.selectable(roLink, {
|
||||||
.click(function () { $(this).select(); })
|
id: 'propROLink',
|
||||||
.appendTo($d);
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2369,20 +2369,17 @@ define([
|
|||||||
return void cb(void 0, $d);
|
return void cb(void 0, $d);
|
||||||
}
|
}
|
||||||
var KB = Cryptpad.bytesToKilobytes(bytes);
|
var KB = Cryptpad.bytesToKilobytes(bytes);
|
||||||
|
|
||||||
|
var formatted = Messages._getKey('formattedKB', [KB]);
|
||||||
$('<br>').appendTo($d);
|
$('<br>').appendTo($d);
|
||||||
|
|
||||||
$('<label>', {
|
$('<label>', {
|
||||||
'for': 'size'
|
'for': 'size'
|
||||||
}).text(Messages.fc_sizeInKilobytes).appendTo($d);
|
}).text(Messages.fc_sizeInKilobytes).appendTo($d);
|
||||||
|
|
||||||
$('<input>', {
|
$d.append(Cryptpad.dialog.selectable(formatted, {
|
||||||
id: 'size',
|
id: 'size',
|
||||||
readonly: 'readonly',
|
}));
|
||||||
value: KB + 'KB',
|
|
||||||
})
|
|
||||||
.click(function () { $(this).select(); })
|
|
||||||
.appendTo($d);
|
|
||||||
|
|
||||||
cb(void 0, $d);
|
cb(void 0, $d);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -2438,8 +2435,7 @@ define([
|
|||||||
var el = filesOp.find(paths[0].path);
|
var el = filesOp.find(paths[0].path);
|
||||||
getProperties(el, function (e, $prop) {
|
getProperties(el, function (e, $prop) {
|
||||||
if (e) { return void logError(e); }
|
if (e) { return void logError(e); }
|
||||||
Cryptpad.alert('', undefined, true);
|
Cryptpad.alert($prop[0], undefined, true);
|
||||||
$('.alertify .msg').html("").append($prop);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
module.hideMenu();
|
module.hideMenu();
|
||||||
@ -2490,8 +2486,7 @@ define([
|
|||||||
var el = filesOp.find(paths[0].path);
|
var el = filesOp.find(paths[0].path);
|
||||||
getProperties(el, function (e, $prop) {
|
getProperties(el, function (e, $prop) {
|
||||||
if (e) { return void logError(e); }
|
if (e) { return void logError(e); }
|
||||||
Cryptpad.alert('', undefined, true);
|
Cryptpad.alert($prop[0], undefined, true);
|
||||||
$('.alertify .msg').html("").append($prop);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
module.hideMenu();
|
module.hideMenu();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user