Created
January 31, 2017 19:14
-
-
Save WilCF/f889252c2a0acbd06be16d23bf93a319 to your computer and use it in GitHub Desktop.
Link Widget (Convert Comma - Delimited URLs into distinct buttons)
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
<div class="url-list-wrapper-js"> | |
<div class="hidden target_parent_urls-output-js"> | |
{{urls}} | |
</div> | |
<div class="link-list-js"> | |
</div> | |
</div> |
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
.et-click-me { | |
box-shadow: 0 0 3px 3px #f05921; | |
} | |
.et-clicked { | |
box-shadow: 0 0 3px 3px #8cc63e; | |
} |
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
require(['jquery-noconflict'], function(jQuery) { | |
//Ensure MooTools is where it must be | |
Window.implement('$', function(el, nc){ | |
return document.id(el, nc, this.document); | |
}); | |
var $ = window.jQuery; | |
// Use `$` in here. | |
$('.target_parent_urls-output-js').each(function(){ | |
var urls = $(this).text().trim(); | |
if (urls != "No data available") | |
{ | |
var urlbtns = '' | |
urls = urls.split(",") | |
urls.each(function(el, i){ | |
urlbtns += '<a target="_blank" class="btn et-click-me" href="http://www.'+el.trim()+'"><i class="icon-search"></i> Parent Website '+(i+1)+'</a><br><br>' | |
}); | |
console.log(urlbtns); | |
$(this).closest('.url-list-wrapper-js').find('.link-list-js').html(urlbtns); | |
} | |
}); | |
$(document).ready(function(){ | |
setTimeout(function(){ | |
$('.cml-table-row-title').each(function(){ | |
var h = $(this).parent('.cml-table-row').height(); | |
$(this).height(h); | |
}); | |
}, 200); | |
}); | |
$(".et-click-me").click(function(){ | |
$(this).removeClass('et-click-me').addClass('et-clicked'); | |
// console.log(a); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These bits of js, css, and cml will take a comma-delimited list of URLs and turn them into distinct and nice-looking buttons. This can also be modified to work with new-line-delimited lists by editing this line of the js:
urls = urls.split(",")
the script is set up to read from a source data column header titled "urls" right now, you can either modify your source data or the javascript to your preferences.