I'm working on feeds, which have textfields holding the url.

I have separated each URL for each store into own textfields (since some has wondered what the URL's are for each when they don't display), and wants to have a simple copy function for them.

T.ex. for multi select of checkboxes we can add links like:
<a on-click="$(this).parent().find(':checkbox').prop('checked', true);"><?php echo $text_select_all; ?></a>
/ <a on-click="$(this).parent().find(':checkbox').prop('checked', false);"><?php echo $text_unselect_all; ?></a>


Is there a similar easy way to add a copy link for textfields, or do we need to add a JS for each feed view?

At the moment I have a button, but if it can be improved and made a link it would be better.

Button Code:
<button type="button" class="btn btn-default badge" on-click="copyToClipboard('#input-data-feed-<?php echo $store['store_id']; ?>')"><?php echo $text_copy; ?></a>

JS Code:
function copyToClipboard(element) {
var $temp = $("");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}


PS! When I'm done with my feeds, I'll make PR for the core feeds. Adding multi store support etc.
Sunday, August 28 2016, 05:32 PM
Share this post:
Responses (0)
  • There are no replies here yet.
Your Reply