From bbf7ed3827cf42d68ff978d497a48d30ed06c690 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 8 Sep 2017 12:24:20 +0200 Subject: [PATCH] refactor drive to use dialog.selectable() fix class on alertify-like boxes --- www/common/common-interface.js | 39 ++++++++++++++++++++++++++++------ www/drive/main.js | 29 +++++++++++-------------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 609317ea3..87a24df5c 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -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), ]); diff --git a/www/drive/main.js b/www/drive/main.js index b0d90b01b..90c5854f3 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -2339,9 +2339,9 @@ define([ $('
').appendTo($d); if (!ro) { $('