[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 8036349be340b25ad80e34de84f0722d3b1abb76
Mark Wells
mark at 420.am
Thu Oct 24 16:00:16 PDT 2013
The branch, FREESIDE_2_3_BRANCH has been updated
via 8036349be340b25ad80e34de84f0722d3b1abb76 (commit)
from d19eb8a333fd8cfc7d2a8b773496fffa3b1d69f8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8036349be340b25ad80e34de84f0722d3b1abb76
Author: Mark Wells <mark at freeside.biz>
Date: Thu Oct 24 16:00:08 2013 -0700
masked input clipboard hack, #25599
diff --git a/httemplate/elements/tr-input-mask.html b/httemplate/elements/tr-input-mask.html
index 33725b9..8a494c8 100644
--- a/httemplate/elements/tr-input-mask.html
+++ b/httemplate/elements/tr-input-mask.html
@@ -5,6 +5,7 @@
% }
<& /elements/tr-input-text.html, id => $id, @_ &>
<script type="text/javascript">
+<&| /elements/onload.js &>
MaskedInput({
elm: document.getElementById('<%$id%>'),
format: '<% $opt{format} %>',
@@ -12,7 +13,38 @@ MaskedInput({
<% $opt{typeon} ? "typeon: '$opt{typeon}'," : '' %>
});
document.getElementById('<%$id%>').value = <% $value |js_string %>;
+% if ( $clipboard_hack ) {
+var t = document.getElementById('<% $id %>');
+var container = document.getElementById('<%$id%>_clipboard');
+var KeyHandlerDown = t.onkeydown
+t.onkeydown = function(e) {
+ // intercept ctrl-c and ctrl-x
+ // and cmd-c and cmd-x on mac
+ // when text is selected
+ if ( ( e.ctrlKey || e.metaKey ) ) {
+ // do the dance
+ var separators = /[\\/:-]/g;
+ var s = t.value.substr(t.selectionStart, t.selectionEnd);
+ if ( s ) {
+ container.value = s.replace(separators, '');
+ container.previous = t;
+ container.focus();
+ container.select();
+ return true;
+ }
+ }
+ return KeyHandlerDown.call(t, e);
+};
+container.onkeyup = function(e) {
+ if ( container.previous ) {
+ setTimeout(function() {container.previous.focus();}, 10);
+ }
+ return true;
+}
+% } # clipboard hack
+</&>
</script>
+<textarea id="<%$id%>_clipboard" style="opacity:0"></textarea>
<%shared>
my $init = 0;
</%shared>
@@ -21,6 +53,8 @@ my %opt = @_;
# must have a DOM id
my $id = $opt{id} || sprintf('input%04d',int(rand(10000)));
my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value} || '';
+
+my $clipboard_hack = $FS::CurrentUser::CurrentUser->option('enable_mask_clipboard_hack');
</%init>
<%doc>
Set up a text input field with input masking.
diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html
index 84f0832..55f306a 100644
--- a/httemplate/pref/pref-process.html
+++ b/httemplate/pref/pref-process.html
@@ -52,6 +52,7 @@ unless ( $error ) { # if ($access_user) {
spreadsheet_format mobile_menu
enable_fuzzy_on_exact
disable_html_editor disable_enter_submit_onetimecharge
+ enable_mask_clipboard_hack
email_address
snom-ip snom-username snom-password
vonage-fromnumber vonage-username vonage-password
diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html
index fcd2596..e504ffc 100644
--- a/httemplate/pref/pref.html
+++ b/httemplate/pref/pref.html
@@ -134,6 +134,13 @@ Email Address
</TD>
</TR>
+ <TR>
+ <TH ALIGN="right">Don't copy MAC address delimiters to clipboard</TH>
+ <TD ALIGN="left" COLSPAN=2>
+ <INPUT TYPE="checkbox" NAME="enable_mask_clipboard_hack" VALUE="1" <% $curuser->option('enable_mask_clipboard_hack') ? 'CHECKED' : '' %>>
+ </TD>
+ </TR>
+
</TABLE>
<BR>
-----------------------------------------------------------------------
Summary of changes:
httemplate/elements/tr-input-mask.html | 34 ++++++++++++++++++++++++++++++++
httemplate/pref/pref-process.html | 1 +
httemplate/pref/pref.html | 7 ++++++
3 files changed, 42 insertions(+), 0 deletions(-)
More information about the freeside-commits
mailing list