Add Script To All Pages On Click Of An Image - wordpress

I created a function (myFunction88) that holds the zen desk chat widget script that is only activated on click of an image in the bottom right corner of a staging site.
http://allcal.staging.wpengine.com/
The purpose is to not load the chat script at all unless someone clicks to start a chat. Increase my site's load speed and not load the chat script on every page when most users don't use it.
It works great. Image in the corner. Click on image, loads the chat.
***My Question is how can I load the script on every page when the image is clicked so the chat will follow the user? Currently the chat only works on the page it clicked on so if you go to a new page, have to start a new chat. Is there a way to onclick of the image, load "myFunction88" output script to every page for that user so the chat is activated on all pages they visit?
JS:
function myFunction88() {
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
$.src="https://v2.zopim.com/?[My ZenDeskChatNumber]";z.t=+new Date;$.
type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
});}
In Function.php:
add_action ( 'wp_footer', 'hook_infooter' );
function hook_infooter() {
echo '<<div class="chatimagediv"><img id="chatimageid"
class="chatimage2" src="https://beachcandyswimwear.com/wp-content/uploads/2018/11/Screen-Shot-2018-11-07-at-8.18.03-AM.png" width=240
onclick="myFunction88(); toggleClick4();"></div>>';
}

Related

Wordpress Infinite scroll & facebook like,share box

I made a site http://18union.cc/, and used the infinite scroll in homepage.
When I scroll down, the facebook like&share box doesn't show up.
I have tried many methods, but it didn't work.
How could I fix this?
You will need to reinitialize the facebook script after the Ajax completes.
You can add your code between this code:
jQuery( document ).ajaxComplete(function() {
jQuery( ".log" ).text( "Add Facebook initialisation here." );
})
You should add this in your custom javaScript file.

AddThis Share : LinkedIn always open in new window

We're using AddThis Social Share functionality with our Sitecore/MVC application. The problem we're facing is that the LinkedIn share always opens in new window. On Inspect, we can see the target=_blank in code, which is not being added in our code.
Any help?
Thanks,
Chandana
The behavior of each share button is as per the website to which the page is being shared. If you test each button (say Facebook, G+, Twitter, LinkedIn, etc.) you will notice that they all work differently. It's not AddThis choice. This is because each website has its own API and that's the way that website decided it would work with their system. LinkedIn happens to open a separate window... Pinterest first opens a popup within your page and then another window after you selected the image you wanted to share. G+ and Facebook open a new tab. And the popups/windows all look quite different, but the users should recognize each respective brand as a result...
I suspect that this is a problem with the AddThis Social Share functionality. To share on LinkedIn, all you need is the following URL format...
https://www.linkedin.com/sharing/share-offsite/?url={url}
Then you can setup your <a href="..."> element however you like, with target="_blank" or not.
Source: Official LinkedIn Sharing Documentation.
Can try out below JavaScript code, which will overwrite addthis functionality, and make linkedIn as popup,
setInterval make sure click event attached to dynamically generated anchor tag
$(document).ready(function () {
var clickinterval = setInterval(setclickevent, 500);
function setclickevent() {
if ($('.at-svc-linkedin').length > 0) {
$('.at-svc-linkedin').on('click', function () {
window.open('https://www.linkedin.com/sharing/share-offsite/?url=' + fixedEncodeURIComponent(window.location.href), 'popup', 'width=600,height=600');
e.preventDefault();
return false;
});
clearInterval(clickinterval);
}
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
});

How to use Meteor FlowRouter.withReplaceState

This is a different problem from a similar question about 'reload'. This use case has to use 'withReplaceState' to handle back button reloading.
I've found the FlowRouter documentation for FlowRouter.withReplaceState(fn), but I've been unable to find specific code examples and can't get it working.
My problem is with Isotope, a plugin that moves elements around when window is resized. User sometimes visits Isotope page, goes to another page, re-sizes window, then presses "back" button to return to Isotope page. Page has to reload to re-trigger the Isotope layout correctly for the new window size.
This is my route. How would I use FlowRouter.withReplaceState() to ensure that user who clicks back button is not seeing the cached page?
FlowRouter.route( '/work', {
action: function() {
BlazeLayout.render( 'body-static', {
content: 'work',
});
},
});

Meteor: How to override verify email popup dialog which appears after clicking email verification link

I want to add some fields to popup dialog which appears when user click on verification email link sent to there email. Actually i want to extend the sign up process. So when user clicked on verify link i want to show some more fields like zip code and date of birth in popup and on clicking save those fields should save to user modal.
Any help will be highly appreciated. I am new to meteor.
I am using ian:accounts-ui-bootstrap-3 for sign up process.
Some more details if needed !
With the following package, you can replace templates :
https://github.com/aldeed/meteor-template-extension
So you create your own template, then replace the default one :
Template.emailVerifiedDialog.replaces("_justVerifiedEmailDialog")
Your dialog will be shown on every pages, you have to add the behaviour to make it visible when necessary
Template.emailVerifiedDialog.helpers({
visible: function () {
return loginButtonsSession.get('justVerifiedEmail');
}
And manage click button event :
Template.emailVerifiedDialog.events({
'click #just-verified-dismiss-button': function () {
loginButtonsSession.set('justVerifiedEmail', false);
}
});
Ok, i found solution myself.
Here it is if some one else also looking for this.
We can override email popup dialog by overriding login_buttons_dialogs.html file in /meteor-accounts-ui-bootstrap-3 folder.

How to embed "Share on Facebook" button into Flex application?

I'm trying to duplicate the behaviour of the "Share on Facebook" button from Youtube. Basically, inside a Flex app I'll have a button and when I click it I want a popup that enables me to post something on the wall.
While it is possible to make a call to javascript to open the pop-up I want to be able to set the images and the text of my posting.
Do you know how I could set the images or text as a paramter to the sharer window?
Thank you!
This is fairly straightforward to do. Youtube uses the Facebook API which pops up a new window (Info on Facebook sharer API).
To do this in flex,
Create a button that onClick will call a javascript method, ExternalInterface.call("fbLink", "www.yahoo.com");
In your HTML file (most likely index.template.html) add the JavaScript method, fbLink which does the following:
function fbLink(url) {
window.popup("http://www.facebook.com/sharer.php?u=" + url, {height:440, width:620, scrollbars:true})
}
Now when a user clicks on the button they will be sharing the link "yahoo.com" with facebook account.
as I understood you asking for some help in accessing js popup in html page of facebook share button, so you should use ExternalInterface in this casa and access needed DOM node using getElementById function in your js interface.
In other case I want propose you to read another one way http://www.riaxe.com/blog/flex/publish-into-facebook-wall-from-flex/
It seems that you want to have a button on the flash application and once clicked it opens the facebook page that shares the video/image that pertains to the clicked button. What you want to do is simply create a button that on click opens a new website to facebook using their share api which has the following format:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
Where the u parameter stands for the link that you wish to share, and the t parameter stands for the title of the piece that you want to share, whether it be a picture or video.
You want to add an event listener on MouseEvent.CLICK that has as its callback function a method that handles the opening of the facebook page passing the facebookShare variable as shown above. To open another page on your browser you can use this AS3 Class called URLNavigator: http://www.danishmetal.dk/project/source/com/zorked/URLNavigator.as
To sum it up, something along these lines would do:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
facebookButton.addEventListener(MouseEvent.CLICK, this._goToUrl(facebookShare));
private function _goToUrl(link:String):Function {
var window:String = "_blank",
feats = "",
thisOverlay:Object = this; // to not lose scope when returning a func
return function (e:MouseEvent):void {
trace("Opening link to:"+link);
try { URLNavigator.ChangePage(link, window, feats); }
catch (e:Error) { trace("error launching "+link+" in "+window+" with feature set "+feats); }
}
}
I hope that helps. If you have questions regarding the code please let me know.

Resources