Skip to content

Commit

Permalink
Alter image and demo file
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbotazini committed Jul 12, 2018
1 parent e1f3387 commit f48a08a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 63 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailing-spaces.trimOnSave": true
}
27 changes: 20 additions & 7 deletions floating-wpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
showPopup: false,
autoOpenTimeout: 0,
headerColor: '#128C7E',
headerTitle: '',
headerTitle: 'WhatsApp Chat',
buttonImage: '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 800 800" width="800" height="800"><defs><clipPath id="_clipPath_A3g8G5hPEGG2L0B6hFCxamU4cc8rfqzQ"><rect width="800" height="800"/></clipPath></defs><g clip-path="url(#_clipPath_A3g8G5hPEGG2L0B6hFCxamU4cc8rfqzQ)"><g><path d=" M 787.59 800 L 12.41 800 C 5.556 800 0 793.332 0 785.108 L 0 14.892 C 0 6.667 5.556 0 12.41 0 L 787.59 0 C 794.444 0 800 6.667 800 14.892 L 800 785.108 C 800 793.332 794.444 800 787.59 800 Z " fill="rgb(37,211,102)"/></g><g><path d=" M 508.558 450.429 C 502.67 447.483 473.723 433.24 468.325 431.273 C 462.929 429.308 459.003 428.328 455.078 434.22 C 451.153 440.114 439.869 453.377 436.434 457.307 C 433 461.236 429.565 461.729 423.677 458.78 C 417.79 455.834 398.818 449.617 376.328 429.556 C 358.825 413.943 347.008 394.663 343.574 388.768 C 340.139 382.873 343.207 379.687 346.155 376.752 C 348.804 374.113 352.044 369.874 354.987 366.436 C 357.931 362.999 358.912 360.541 360.875 356.614 C 362.837 352.683 361.857 349.246 360.383 346.299 C 358.912 343.352 347.136 314.369 342.231 302.579 C 337.451 291.099 332.597 292.654 328.983 292.472 C 325.552 292.301 321.622 292.265 317.698 292.265 C 313.773 292.265 307.394 293.739 301.996 299.632 C 296.6 305.527 281.389 319.772 281.389 348.752 C 281.389 377.735 302.487 405.731 305.431 409.661 C 308.376 413.592 346.949 473.062 406.015 498.566 C 420.062 504.634 431.03 508.256 439.581 510.969 C 453.685 515.451 466.521 514.818 476.666 513.302 C 487.978 511.613 511.502 499.06 516.409 485.307 C 521.315 471.55 521.315 459.762 519.842 457.307 C 518.371 454.851 514.446 453.377 508.558 450.429 Z M 401.126 597.117 L 401.047 597.117 C 365.902 597.104 331.431 587.661 301.36 569.817 L 294.208 565.572 L 220.08 585.017 L 239.866 512.743 L 235.21 505.332 C 215.604 474.149 205.248 438.108 205.264 401.1 C 205.307 293.113 293.17 205.257 401.204 205.257 C 453.518 205.275 502.693 225.674 539.673 262.696 C 576.651 299.716 597.004 348.925 596.983 401.258 C 596.939 509.254 509.078 597.117 401.126 597.117 Z M 567.816 234.565 C 523.327 190.024 464.161 165.484 401.124 165.458 C 271.24 165.458 165.529 271.161 165.477 401.085 C 165.46 442.617 176.311 483.154 196.932 518.892 L 163.502 641 L 288.421 608.232 C 322.839 627.005 361.591 636.901 401.03 636.913 L 401.126 636.913 L 401.127 636.913 C 530.998 636.913 636.717 531.2 636.77 401.274 C 636.794 338.309 612.306 279.105 567.816 234.565" fill-rule="evenodd" fill="rgb(255,255,255)"/></g></g></svg>',
}, options);

//#region jQuery Elements

var $button = $(document.createElement('div'));
var $buttonImageContainer = $(document.createElement('div'));
var $popup = $(document.createElement('div'));
Expand All @@ -36,7 +35,7 @@
openPopup();
}
else {
sendWhatsappMessage(settings);
sendWhatsappMessage();
}
});
//#endregion
Expand All @@ -55,6 +54,13 @@
$inputMessage.addClass('floating-wpp-input-message');
$btnSend.addClass('floating-wpp-btn-send');

$message.text(settings.popupMessage);
$textarea.val(settings.message);

if (!settings.message) {
$message.hide();
}

$header.append('<span>' + settings.headerTitle + '</span>', $closeBtn)
.css('background-color', settings.headerColor);

Expand All @@ -70,7 +76,7 @@
.appendTo(this);

$message.click(function() {
//sendWhatsappMessage(settings);
//sendWhatsappMessage();
});

$closeBtn.click(function() {
Expand All @@ -91,7 +97,7 @@

$btnSend.click(function () {
settings.message = $textarea.val();
sendWhatsappMessage(settings);
sendWhatsappMessage();
});

this.mouseenter(function() {
Expand All @@ -107,13 +113,20 @@
function openPopup(){
if (!$popup.hasClass('active')) {
$popup.addClass('active');
$message.text(settings.popupMessage);
$textarea.val(settings.message);
$textarea.focus();
}
}
}

function sendWhatsappMessage() {
var apilink = 'http://';

apilink += mobilecheck() ? 'api' : 'web';
apilink += '.whatsapp.com/send?phone=' + settings.phone + '&text=' + encodeURI(settings.message);

window.open(apilink);
}

if (settings.position === 'right') {
this.css({
left: 'unset',
Expand Down
21 changes: 8 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,17 @@
<meta charset="UTF-8">
<title>Teste</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="floating-wpp.min.css">
<script type="text/javascript" src="floating-wpp.min.js"></script>
<link rel="stylesheet" href="floating-wpp.css">
<script type="text/javascript" src="floating-wpp.js"></script>
<style>
body{
font-family: Arial, Helvetica, sans-serif
}
</style>
</head>
<script type="text/javascript">
$(function () {
$('.floating-wpp').floatingWhatsApp({
phone: '5531992677766',
popupMessage: 'Olá, como podemos ajudar?',
showPopup: true,
//position: 'right',
//autoOpen: false,
//autoOpenTimer: 4000,
message: 'Gostaria de informações sobre o imóvel.',
//headerColor: 'orange',
headerTitle: 'Estamos no WhatsApp!',
});
$('.floating-wpp').floatingWhatsApp();
});
</script>
<body>
Expand Down
44 changes: 1 addition & 43 deletions whatsapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f48a08a

Please sign in to comment.