Skip to content

Commit

Permalink
Baby registry is now dyanmic with dynamic shareable links: #133
Browse files Browse the repository at this point in the history
  • Loading branch information
khalidsaadat committed Apr 4, 2022
1 parent 16000a8 commit 49725f2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 9 additions & 6 deletions app/views/baby_registry/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
if($baby_reg_token == true) {
// show the existing token
echo "
<div style='cursor: pointer;' data-toggle='collapse' href='#collapseExample-$collapse_counter' role='button' aria-expanded='false' aria-controls='collapseExample'>
<div style='cursor: pointer;' data-toggle='collapse' href='#collapseExample-$baby_reg_id' role='button' aria-expanded='false' aria-controls='collapseExample'>
<img src='/assets/icons/link.png' height='14' style='vertical-align:middle;'>
<span style='font-size: 11px;'>SHARE</span>
</div>
Expand All @@ -152,7 +152,7 @@
else {
// generate a new one and display it
echo "
<button type='submit' style='background: none; border: none;' data-toggle='collapse' href='#collapseExample-$collapse_counter' role='button' aria-expanded='false' aria-controls='collapseExample'>
<button type='submit' style='background: none; border: none;' data-toggle='collapse' href='#collapseExample-$baby_reg_id' role='button' aria-expanded='false' aria-controls='collapseExample'>
<img src='/assets/icons/link.png' height='14' style='vertical-align:middle; padding-right: 5px;'>
<span style='font-size: 11px;'>SHARE</span>
</button>
Expand All @@ -167,17 +167,20 @@
</div>

<!-- Shareable link collapse -->
<div class="collapse" id="collapseExample-$collapse_counter">
<div class="collapse" id="collapseExample-<?php echo $baby_reg_id; ?>">
<div class="card card-body">
<div class="row">
<div id="my_links" class="row">
<div class="col-lg-7">
<input type="hidden" value="<?php echo $url; ?>" id="shareable_url">
<input type="hidden" style="width: 700px;" id="<?php echo $url; ?>" value="<?php echo $baby_reg_id; ?>">
<a href="<?php echo $url; ?>" id="shareable_link_url" style="color: blue;"><?php echo $url; ?></a>
</div>
<div class="col-lg-4">
<img src="/assets/icons/copy.png" height="14" onclick="copyText()" onmousemove="changeTooltip()" data-toggle="tooltip" data-placement="top" data-original-title="Copy link" style="vertical-align:middle; padding-right: 5px; cursor: pointer;">
<!-- <img src="/assets/icons/copy.png" height="14" onclick="copyText()" onmousemove="changeTooltip()" data-toggle="tooltip" data-placement="top" data-original-title="Copy link" style="vertical-align:middle; padding-right: 5px; cursor: pointer;"> -->
<img id="<?php echo $url; ?>" src="/assets/icons/copy.png" onmousemove="changeTooltip()" height="14" data-toggle="tooltip" data-placement="top" data-original-title="Copy link" style="vertical-align:middle; padding-right: 5px; cursor: pointer;">
</div>
</div>

<div id="log"></div>
</div>
</div>

Expand Down
29 changes: 27 additions & 2 deletions app/views/include/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ function shownTabsHandler(e) {
$("#shareable_link_url").html("");
$("#shareable_link_url").append("/babyregistry/shareable/" + response.token);
location.reload();
generate_flag = 0;
}
});
Expand All @@ -239,10 +241,33 @@ function shownTabsHandler(e) {
<!-- Copy a text -->
<script>
$(document).ready(function () {
var baby_reg_id = null;
$( "#my_links img" ).on( "click", function( event ) {
event.preventDefault();
console.log( $( this ).attr('id') );
baby_reg_id = $( this ).attr('id');
copyToClipboard(baby_reg_id);
// changeTooltip();
});
$( "#"+baby_reg_id ).mousemove(function( event ) {
var msg = "Handler for .mousemove() called at ";
msg += event.pageX + ", " + event.pageY;
$( "#log" ).append( "<div>" + msg + "</div>" );
});
});
function copyText() {
var copyText = document.getElementById("shareable_url");
copyToClipboard(copyText.value);
var baby_reg_id = document.getElementById("baby_registry_id");
console.log(baby_reg_id);
// var copyText = document.getElementById("shareable_url");
// copyToClipboard(copyText.value);
Expand Down

0 comments on commit 49725f2

Please sign in to comment.