Skip to content

Commit

Permalink
add clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
acemtp committed Nov 3, 2015
1 parent d928e9f commit 6eb5862
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions client/main.css
Expand Up @@ -27,3 +27,8 @@ body .well, body .jumbotron {
i {
font-size: 100% !important;
}

.clippy {
width: 13px;
cursor: pointer;
}
1 change: 1 addition & 0 deletions client/main.html
Expand Up @@ -36,6 +36,7 @@ <h1>Fastosphere</h1>
<!-- <a href="https://atmospherejs.com/{{#if authorName}}{{authorName}}{{else}}meteor{{/if}}/{{baseName}}" target="_blank">{{{_highlightResult.name.value}}}</a> -->
{{#if gitUrl}}
<a href="{{gitUrl}}" target="_blank">{{{_highlightResult.name.value}}}</a>
<img class="clippy" src="clippy.svg" alt="Copy to clipboard" data-clipboard-text="meteor add {{name}}" data-toggle="tooltip" data-trigger="hover" title="Copy to clipboard">
{{else}}
{{{_highlightResult.name.value}}}
{{/if}}
Expand Down
21 changes: 17 additions & 4 deletions client/main.js
@@ -1,6 +1,6 @@
Router.route('/', function () {
Router.route('/', function routehome() {
this.render('home', {
data: function () { return Session.get('content'); }
data() { return Session.get('content'); },
});
});

Expand All @@ -9,11 +9,11 @@ hitsPerPageInc = Meteor.isMobile ? 10 : 50;
Session.setDefault('hitsPerPage', hitsPerPageInc);
Session.setDefault('q', '');


// Setup Algolia
client = AlgoliaSearch(Meteor.settings.public.algolia_application_id, Meteor.settings.public.algolia_public_id, { dsn: true });
index = client.initIndex(Meteor.settings.public.production ? 'Packages' : 'PackagesTest');


// Do a new Algolia search if the search query changed
Tracker.autorun(function () {
var q = Session.get('q');
Expand All @@ -24,10 +24,23 @@ Tracker.autorun(function () {
});

// Init material design ripple effect
Template.searchResult.onRendered(function () {
Template.searchResults.onRendered(function () {
$.material.init();
});

// Init clipboard with event delegation (only on parent)
Template.searchResults.onRendered(function () {
this.clipboard = new Clipboard('.clippy');
this.clipboard.on('success', (e) => {
$(e.trigger).attr('data-original-title', 'Copied!').tooltip('show');
});
});

Template.searchResults.onDestroyed(function () {
this.clipboard.destroy();
});


// Focus the search bar when it's rendered
Template.searchBar.onRendered(function () {
$('#q').val(Session.get('q'));
Expand Down
2 changes: 2 additions & 0 deletions server/meteorstat.js
@@ -1,4 +1,6 @@

// XXX store the latest date we used so we don't add 2 times the totalAdds if we can the update 2 times the same day

/*
{"name":"255kb:meteor-status","version":"1.2.0","totalAdds":1,"directAdds":1}
{"name":"3stack:country-codes","version":"0.1.1","totalAdds":1,"directAdds":1}
Expand Down

0 comments on commit 6eb5862

Please sign in to comment.