From nobody Fri Apr 19 06:51:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543235794709416.30699340974434; Mon, 26 Nov 2018 04:36:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5007E3082E44; Mon, 26 Nov 2018 12:36:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E0F75DD89; Mon, 26 Nov 2018 12:36:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2E5B84A460; Mon, 26 Nov 2018 12:36:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAQCaVgC014229 for ; Mon, 26 Nov 2018 07:36:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 44C462D17A; Mon, 26 Nov 2018 12:36:31 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1037176B4 for ; Mon, 26 Nov 2018 12:36:26 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Mon, 26 Nov 2018 13:36:25 +0100 Message-Id: <20181126123625.5462-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] add copy to clipboard button next to search X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 26 Nov 2018 12:36:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This can be useful to copy and paste into the patchew-cli command line. Fixes issue #88. Signed-off-by: Paolo Bonzini Reviewed-by: Caio Carrara --- static/css/base.css | 11 +++++++++-- static/js/patchew.js | 23 +++++++++++++++++++++++ www/templates/base.html | 7 +++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/static/css/base.css b/static/css/base.css index 9e04f50..a8c66c0 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -65,14 +65,21 @@ h1, h2, h3, .h1, .h2, .h3 { color: #666; } =20 -.search-help { +.form-glyph-action { color: #ccc; + border: 0; + background: none; + padding: 0px 3px; } =20 -.search-help:hover { +.form-glyph-action:hover { color: #aaa; } =20 +.form-glyph-action:active { + color: #23527c; + padding: 0px 3px; + .search-form .form-group { width: 600px; } diff --git a/static/js/patchew.js b/static/js/patchew.js index a982de5..ce45abd 100644 --- a/static/js/patchew.js +++ b/static/js/patchew.js @@ -20,3 +20,26 @@ function add_fixed_scroll_events() $(window).scrollTop() + 10 >=3D pre_fixed.offset= ().top + pre_fixed.height()); }) } + +function copy_to_clipboard(input) { + if (input.value =3D=3D '') { + return; + } + + var origSelectionStart =3D input.selectionStart; + var origSelectionEnd =3D input.selectionEnd; + var origFocus =3D typeof document.activeElement.focus =3D=3D=3D "funct= ion" ? document.activeElement : null; + + // copy the selection. Note that the old selection is not restored un= less + // an error happens, to give the user feedback that the copy has happe= ned. + input.focus(); + input.setSelectionRange(0, input.value.length); + try { + document.execCommand("copy"); + } catch(e) { + input.setSelectionRange(origSelectionStart, origSelectionEnd); + if (origFocus) { + origFocus.focus(); + } + } +} diff --git a/www/templates/base.html b/www/templates/base.html index 89dabcf..850317f 100644 --- a/www/templates/base.html +++ b/www/templates/base.html @@ -63,9 +63,12 @@ crossorigin=3D"anonymous"/>
    - +
    - + +
    {% if request.user.is_authenticated %} --=20 2.19.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel