Skip to content

Add click to copy functionality #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 45 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="utf-8" />
<title>Bereleydir - Easily search through the Berkeley Directory.</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="https://rawgithub.com/LeaVerou/prefixfree/gh-pages/prefixfree.js"></script>

Expand Down Expand Up @@ -107,6 +106,13 @@
position: absolute;
width: 1px;
}

.zclip {
color: #ddd;
text-decoration: underline;
cursor: pointer;
}

</style>
</head>
<body>
Expand All @@ -120,15 +126,21 @@ <h1 data-ng-class="{true: 'bd-loader'}[isloading]">
</div>
<table class="bd-table-container" ng-show="userItems.length">
<tr class="bd-table-headers">
<th>Link</th>
<th>Uid</th>
<th>Name</th>
<th>Email</th>
</tr>
<tr class="bd-table-item" ng-repeat="user in userItems = (users | limitTo:20)">
<td>
<a ng-href="https://calnet.berkeley.edu/directory/details.pl?uid={{user.id}}" ng-bind="user.id"></a>
<a ng-href="https://calnet.berkeley.edu/directory/details.pl?uid={{user.id}}">
<img src="/images/link.png"/>
</a>
</td>
<td class="zclip" data-clipboard-text="{{user.id}}" ng-bind="user.id">
</td>
<td on-finish-render class="zclip" ng-bind="user.name" data-clipboard-text="{{user.name}}">
</td>
<td ng-bind="user.name"></td>
<td>
<a data-ng-repeat="email in user.email" data-ng-href="mailto:{{email}}" data-ng-bind="email"></a>
</td>
Expand All @@ -140,6 +152,18 @@ <h1 data-ng-class="{true: 'bd-loader'}[isloading]">
</div>
<script>
var berkeleydir = angular.module("berkeleydir", []);
berkeleydir.directive('onFinishRender', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
$timeout(function () {
scope.$emit('ngRepeatFinished');
});
}
}
}
});

function PeopleController($http, $scope, $timeout) {
$scope.users = [];
Expand Down Expand Up @@ -178,6 +202,22 @@ <h1 data-ng-class="{true: 'bd-loader'}[isloading]">
}, 100);
});

ZeroClipboard.config({
moviePath: "../swf/ZeroClipboard.swf",
forceHandCursor: true
});

$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
var client = new ZeroClipboard(document.getElementsByClassName('zclip'));

client.on("load", function(client) {
client.on("complete", function(client, args) {
// Show a little message confirming that the text was copied
// alert("Copied text to clipboard: " + args.text);
});
});
});

// $scope.users = angularFireCollection(ref, function initialLoad(){
// $timeout(function() {
// $scope.isloading = false;
Expand All @@ -186,6 +226,8 @@ <h1 data-ng-class="{true: 'bd-loader'}[isloading]">
}
</script>

<script src="/js/ZeroClipboard.min.js"></script>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand Down
Loading