-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from refugeetech/feature/issue75
Add share button. Closes issue#75
- Loading branch information
Showing
6 changed files
with
108 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,56 @@ | ||
if (Meteor.isClient) { | ||
|
||
Meteor.startup(function() { | ||
// Runs when the DOM is ready | ||
Session.set('willShowAutoSuggestion',false); | ||
|
||
const NAVBAR_HEIGHT = 75; // original navbar height in px | ||
|
||
var $window = $(window), | ||
$document = $(document), | ||
$searchbar = $('#searchbar'); | ||
|
||
$window.on('scroll', function(e) { | ||
// The scroll event is not supported yet by Meteor https://github.com/meteor/meteor/issues/3298, | ||
// so we use a jquery instead. | ||
// This block runs whenever the page is scrolled | ||
toggleNavbarClass(); | ||
}); | ||
|
||
var toggleNavbarClass = function() { | ||
// Toggles a css class when the page is scrolled past NAVBAR_HEIGHT. | ||
// The behaviour is controlled from the .shrinked class in navbar.css | ||
let $topNav = $('#top-nav'); | ||
if ($document.scrollTop() > NAVBAR_HEIGHT) { | ||
$topNav.addClass('shrinked'); | ||
$searchbar.addClass('navbar-is-shrinked'); | ||
} | ||
else { | ||
$topNav.removeClass('shrinked'); | ||
$searchbar.removeClass('navbar-is-shrinked'); | ||
} | ||
}; | ||
}); // end Meteor.startup | ||
|
||
Template.mainNavbar.events({ | ||
'click .activate-searchbar': function(event) { | ||
event.preventDefault(); | ||
if(!$('#searchbar').hasClass('active')) { | ||
Template.mainNavbar.rendered = function () { | ||
// Get reference to template instance | ||
let instance = this; | ||
|
||
const NAVBAR_HEIGHT = 75; // original navbar height in px | ||
|
||
var $window = $(window), | ||
$document = $(document), | ||
$searchbar = $('#searchbar'); | ||
|
||
|
||
$window.on('scroll', function(e) { | ||
// The scroll event is not supported yet by Meteor https://github.com/meteor/meteor/issues/3298, | ||
// so we use a jquery instead. | ||
// This block runs whenever the page is scrolled | ||
toggleNavbarClass(); | ||
}); | ||
|
||
var toggleNavbarClass = function() { | ||
// Toggles a css class when the page is scrolled past NAVBAR_HEIGHT. | ||
// The behaviour is controlled from the .shrinked class in navbar.css | ||
let $topNav = $('#top-nav'); | ||
if ($document.scrollTop() > NAVBAR_HEIGHT) { | ||
$topNav.addClass('shrinked'); | ||
$searchbar.addClass('navbar-is-shrinked'); | ||
} | ||
else { | ||
$topNav.removeClass('shrinked'); | ||
$searchbar.removeClass('navbar-is-shrinked'); | ||
} | ||
}; | ||
|
||
//adding share-button | ||
let config = { | ||
ui: { | ||
flyout: "bottom center", | ||
button_font: false, | ||
icon_font:false | ||
} | ||
}; | ||
|
||
new ShareButton(config); | ||
}; | ||
|
||
Template.mainNavbar.events({ | ||
'click .activate-searchbar': function(event) { | ||
event.preventDefault(); | ||
if(!$('#searchbar').hasClass('active')) { | ||
// Focus on the input of the searchbar only if it is already hidden | ||
$('#searchbar input').focus(); | ||
//show autosuggestions only if input has focus | ||
Session.set('willShowAutoSuggestion',true); | ||
} | ||
$('#searchbar').toggleClass('active'); // Toggle the searchbar | ||
} | ||
}); | ||
} | ||
$('#searchbar').toggleClass('active'); // Toggle the searchbar | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
if(Meteor.isClient) { | ||
Template.searchbar.events({ | ||
'keyup #searchbar [type=text]': function(event, template) { | ||
// Mimic a search | ||
$('#spinner').removeClass('hidden'); // Show the spinner icon | ||
|
||
Template.searchbar.events({ | ||
'keyup #searchbar [type=text]': function(event, template) { | ||
// Mimic a search | ||
$('#spinner').removeClass('hidden'); // Show the spinner icon | ||
|
||
window.setTimeout(function() { // Remove spinner icon after a while | ||
$('#spinner').addClass('hidden') | ||
}, 1500); | ||
}, | ||
'blur input':function(event,template) { | ||
$('#searchbar').removeClass('active'); //hide the searchbar when input blurs | ||
} | ||
}); | ||
|
||
} | ||
window.setTimeout(function() { // Remove spinner icon after a while | ||
$('#spinner').addClass('hidden') | ||
}, 1500); | ||
}, | ||
'blur input':function(event,template) { | ||
$('#searchbar').removeClass('active'); //hide the searchbar when input blurs | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
share-button { | ||
background: #fff; | ||
color: #1d2660; | ||
} | ||
|
||
#top-nav .navbar-nav.navbar-right #share-button-container { | ||
margin-right: calc(20/16 * 1em); | ||
padding: calc(28/16 * 1em - 0.2em) calc(4/16 * 1em) calc(26/16 * 1em - 5px); | ||
} | ||
#top-nav.shrinked .navbar-right #share-button-container { | ||
padding: 1em calc(4/16 * 1em) calc(1em - 5px); | ||
} | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.