<fieldset>
<legend ng-class="{'patron-summary-alert': addr.valid() == 'f'}">
{{addr.address_type()}}
- <a href class="pad-horiz patron-summary-act-link"
- ng-click="print_address(addr)">[% l('(print)') %]</a>
+ (<a href class="patron-summary-act-link"
+ ng-click="copy_address(addr)">[%- l('copy') -%]</a><a
+ href class="patron-summary-act-link"
+ ng-click="print_address(addr)">[%- l('/print') -%]</a>)
</legend>
<div>{{addr.street1()}} {{addr.street2()}}</div>
<div>{{addr.city()}}, {{addr.state()}} {{addr.post_code()}}</div>
</fieldset>
+ <textarea id="patron-address-copy-{{addr.id()}}" rows="2"
+ style="visibility:hidden">[%- l(
+ '[_1] [_2] [_3] [_4] [_5] [_6], [_7] [_8]',
+ '{{patron().first_given_name()}}',
+ '{{patron().second_given_name()}}',
+ '{{patron().family_name()}}',
+ '{{addr.street1()}}',
+ '{{addr.street2()}}',
+ '{{addr.city()}}',
+ '{{addr.state()}}',
+ '{{addr.post_code()}}')
+ -%]</textarea>
</div>
</div>
</div>
});
}
+ $scope.copy_address = function(addr) {
+ // Alas, navigator.clipboard is not yet supported in FF and others.
+ var lNode = document.querySelector('#patron-address-copy-' + addr.id());
+
+ // Un-hide the textarea just long enough to copy its data.
+ // Using node.style instead of ng-show/ng-hide in hopes it
+ // will be quicker, so the user never sees the textarea.
+ lNode.style.visibility = 'visible';
+ lNode.focus();
+ lNode.select();
+
+ if (!document.execCommand('copy')) {
+ console.error('Copy command failed');
+ }
+
+ lNode.style.visibility = 'hidden';
+ }
+
$scope.toggle_expand_summary = function() {
if ($scope.collapsePatronSummary) {
$scope.collapsePatronSummary = false;