Created
May 11, 2017 16:12
-
-
Save agentfitz/c3b9faee776b9792558bde0c80d09fea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function($) { | |
var dom; | |
var link1Content = 'Smithfield<br><span class="dynamic-phone-number ws-dynamic-number" data-number-type="sales">844-457-1764</span>'; | |
var link2Content = 'Goldsboro<br><span class="dynamic-phone-number ws-dynamic-number" data-number-type="sales">919-736-2900</span>'; | |
var newLinkMarkup = '<a class="btn btn-success btn-block btn-lg track-click event-click ws-dynamic-number" data-action="Sales" data-adsolconv="call_initiated" data-category="Click to Call" data-label="Mobile" data-number-type="sales" data-text-prepend="Call Sales: " href="tel:888-566-7306">Clinton<br><span class="dynamic-phone-number ws-dynamic-number" data-number-type="sales">888-566-7306</span></a>'; | |
var cacheDom = function() { | |
dom = {}; | |
dom.document = $(document); | |
dom.clickToCallBtn = $('#click-to-call'); | |
dom.link1 = dom.clickToCallBtn.find('a:first-of-type'); | |
dom.link2 = dom.clickToCallBtn.find('a:nth-of-type(2)'); | |
dom.newLink = $(newLinkMarkup); | |
}; | |
var bindHandlers = function() { | |
dom.document.on('ready', onDocumentReady); | |
}; | |
var updateExistingLinks = function() { | |
dom.link1.html(link1Content); | |
dom.link2.html(link2Content); | |
}; | |
var insertNewLink = function() { | |
dom.newLink.insertBefore(dom.clickToCallBtn); | |
}; | |
var onDocumentReady = function() { | |
updateExistingLinks(); | |
insertNewLink(); | |
}; | |
var init = function() { | |
cacheDom(); | |
bindHandlers(); | |
}; | |
// kick things off | |
init(); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment