summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-01-16 18:37:43 -0800
committerIvan Kohler <ivan@freeside.biz>2015-01-16 18:37:43 -0800
commitb7cf1606a66cca95e3540f803ffa66d223f23a40 (patch)
treec31be9b2b863007e19c8d1299ec4a5b3a5fceb22 /httemplate/elements
parentedb6acc2180c1a00262ef3572560a0a05862c8d1 (diff)
parentd8eb6e54c5bee38f48ee3f7e22210e1b1f373efd (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/mac_addr.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/httemplate/elements/mac_addr.html b/httemplate/elements/mac_addr.html
new file mode 100644
index 000000000..1d867f504
--- /dev/null
+++ b/httemplate/elements/mac_addr.html
@@ -0,0 +1,53 @@
+% if (!$init) {
+% if ($clipboard_hack) {
+<& init_overlib.html &>
+<script>
+<&| /elements/onload.js &>
+ var transform_text = function(str) {
+ var regexp = new RegExp('.*(..):(..):(..):(..):(..):(..).*');
+ return str.replace(regexp, '$1$2$3$4$5$6');
+ }
+ var span_onclick = function() {
+ var input = document.createElement('INPUT');
+ // IE8 doesn't support textContent
+ var str = this.textContent || this.innerText || '';
+ input.value = transform_text(str);
+ input.style.position = 'absolute';
+ input.style.top = '0px';
+ input.style.left = '0px';
+ input.onblur = function() { input.parentNode.removeChild(input) }
+ this.appendChild(input);
+ input.select();
+ }
+ // set this on any ".mac_addr" object in the doc
+
+ // IE8 doesn't support getElementsByClassName
+ var els = document.getElementsByTagName('span');
+ for (var i = 0; i < els.length; i++) {
+ if (els[i].className = 'mac_addr') {
+ els[i].id = 'span_mac_addr' + i;
+ els[i].onclick = span_onclick;
+ }
+ }
+</&>
+</SCRIPT>
+<style type="text/css">
+.mac_addr {
+ border-bottom: 1px dotted blue;
+ color: blue;
+ position: relative;
+}
+</style>
+% } # if $clipboard_hack
+% $init++;
+% }
+%# the only part to be included in every instance
+<SPAN CLASS="mac_addr"><% $value |h %></SPAN>
+<%shared>
+my $init = 0;
+</%shared>
+<%init>
+my $clipboard_hack =
+ $FS::CurrentUser::CurrentUser->option('enable_mask_clipboard_hack');
+my $value = shift; # no other params
+</%init>