From 4e3571b4b76180f4a7011d24fe341a2c8ce40705 Mon Sep 17 00:00:00 2001 From: Mohammad Farouk Date: Mon, 17 Jun 2024 00:35:49 +0300 Subject: [PATCH] g --- amd/build/referral.min.js | 2 +- amd/build/referral.min.js.map | 2 +- amd/src/referral.js | 4 ++-- styles.css | 3 +-- templates/referral.mustache | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/amd/build/referral.min.js b/amd/build/referral.min.js index 68155f68..1c2a64f7 100644 --- a/amd/build/referral.min.js +++ b/amd/build/referral.min.js @@ -5,6 +5,6 @@ define("enrol_wallet/referral",["exports","jquery","core/str","core/prefetch"],( * @module enrol_wallet/referral * @copyright 2024 YOUR NAME * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */let copyTooltip,copiedTooltip,shareUrl,copyButtonCode,copyButtonUrl,uniqueId;function copyText(target,element){let input=(0,_jquery.default)("#"+target+"_"+uniqueId);navigator.clipboard.writeText(input[0].value),element.setAttribute("tooltip",copiedTooltip)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=_interopRequireDefault(_jquery),(_prefetch=_interopRequireDefault(_prefetch)).default.prefetchStrings("enrol_wallet",["referral_copy_to_clipboard","referral_copied"]);const resetTooltip=element=>{element.setAttribute("tooltip",copyTooltip)};function addListeners(){copyButtonUrl.addEventListener("click",(()=>{copyText("url",copyButtonUrl)})),copyButtonUrl.addEventListener("mouseleave",(()=>{resetTooltip(copyButtonUrl)})),copyButtonCode.addEventListener("click",(()=>{copyText("code",copyButtonCode)})),copyButtonCode.addEventListener("mouseleave",(()=>{resetTooltip(copyButtonCode)})),(0,_jquery.default)('a[href="#shareOnFacebook"]').on("click",(()=>{window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(shareUrl),"facebook-share-dialog","width=800,height=600")})),(0,_jquery.default)('a[href="#shareOnTelegram"]').on("click",(()=>{window.open("https://t.me/share/url?url="+encodeURIComponent(shareUrl))})),(0,_jquery.default)('a[href="#shareOnWhatsApp"]').on("click",(()=>{window.open("https://wa.me/?text="+encodeURIComponent(shareUrl))}))}_exports.init=(url,id)=>{(0,_str.get_strings)([{key:"referral_copy_to_clipboard",component:"enrol_wallet"},{key:"referral_copied",component:"enrol_wallet"}]).then((function(results){return copyTooltip=results[0],copiedTooltip=results[1],!0})).fail((()=>!1)),shareUrl=url,uniqueId=id,copyButtonUrl=document.getElementById("copy_url_"+id),copyButtonCode=document.getElementById("copy_code_"+id),addListeners()}})); + */let copyTooltip,copiedTooltip,shareUrl,copyButtonCode,copyButtonUrl,uniqueId;function copyText(target,element){let input=(0,_jquery.default)("#"+target+"_"+uniqueId);navigator.clipboard.writeText(input[0].value),element.setAttribute("title",copiedTooltip)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=_interopRequireDefault(_jquery),(_prefetch=_interopRequireDefault(_prefetch)).default.prefetchStrings("enrol_wallet",["referral_copy_to_clipboard","referral_copied"]);const resetTooltip=element=>{element.setAttribute("title",copyTooltip)};function addListeners(){copyButtonUrl.addEventListener("click",(()=>{copyText("url",copyButtonUrl)})),copyButtonUrl.addEventListener("mouseleave",(()=>{resetTooltip(copyButtonUrl)})),copyButtonCode.addEventListener("click",(()=>{copyText("code",copyButtonCode)})),copyButtonCode.addEventListener("mouseleave",(()=>{resetTooltip(copyButtonCode)})),(0,_jquery.default)('a[href="#shareOnFacebook"]').on("click",(()=>{window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(shareUrl),"facebook-share-dialog","width=800,height=600")})),(0,_jquery.default)('a[href="#shareOnTelegram"]').on("click",(()=>{window.open("https://t.me/share/url?url="+encodeURIComponent(shareUrl))})),(0,_jquery.default)('a[href="#shareOnWhatsApp"]').on("click",(()=>{window.open("https://wa.me/?text="+encodeURIComponent(shareUrl))}))}_exports.init=(url,id)=>{(0,_str.get_strings)([{key:"referral_copy_to_clipboard",component:"enrol_wallet"},{key:"referral_copied",component:"enrol_wallet"}]).then((function(results){return copyTooltip=results[0],copiedTooltip=results[1],!0})).fail((()=>!1)),shareUrl=url,uniqueId=id,copyButtonUrl=document.getElementById("copy_url_"+id),copyButtonCode=document.getElementById("copy_code_"+id),addListeners()}})); //# sourceMappingURL=referral.min.js.map \ No newline at end of file diff --git a/amd/build/referral.min.js.map b/amd/build/referral.min.js.map index bd1b53f5..0deee573 100644 --- a/amd/build/referral.min.js.map +++ b/amd/build/referral.min.js.map @@ -1 +1 @@ -{"version":3,"file":"referral.min.js","sources":["../src/referral.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * TODO describe module referral\n *\n * @module enrol_wallet/referral\n * @copyright 2024 YOUR NAME \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n// eslint-disable-next-line camelcase\nimport {get_strings} from 'core/str';\nimport Prefetch from 'core/prefetch';\n\n// Prefetch required string while the page loading.\nPrefetch.prefetchStrings('enrol_wallet', ['referral_copy_to_clipboard', 'referral_copied']);\n\nlet copyTooltip;\nlet copiedTooltip;\nlet shareUrl;\nlet copyButtonCode;\nlet copyButtonUrl;\nlet uniqueId;\n/**\n *\n */\nfunction shareOnFacebook() {\n let fbBase = 'https://www.facebook.com/sharer/sharer.php?u=';\n window.open(fbBase + encodeURIComponent(shareUrl), 'facebook-share-dialog', 'width=800,height=600');\n}\n\n/**\n *\n */\nfunction shareOnWhatsApp() {\n window.open('https://wa.me/?text=' + encodeURIComponent(shareUrl));\n}\n\n/**\n *\n */\nfunction shareOnTelegram() {\n window.open('https://t.me/share/url?url=' + encodeURIComponent(shareUrl));\n}\n\n/**\n * Copy the text in the input value.\n * @param {string} target\n * @param {DOMElement} element\n */\nfunction copyText(target, element) {\n let input = $('#' + target + '_' + uniqueId);\n\n navigator.clipboard.writeText(input[0].value);\n\n element.setAttribute('tooltip', copiedTooltip);\n}\n\nconst resetTooltip = (element) => {\n element.setAttribute('tooltip', copyTooltip);\n};\n\n/**\n * Add listeners to copy and sharing buttons.\n */\nfunction addListeners() {\n copyButtonUrl.addEventListener('click', () => {\n copyText('url', copyButtonUrl);\n });\n copyButtonUrl.addEventListener('mouseleave', () => {\n resetTooltip(copyButtonUrl);\n });\n copyButtonCode.addEventListener('click', () => {\n copyText('code', copyButtonCode);\n });\n copyButtonCode.addEventListener('mouseleave', () => {\n resetTooltip(copyButtonCode);\n });\n\n $('a[href=\"#shareOnFacebook\"]').on(\"click\", () => {\n shareOnFacebook();\n });\n $('a[href=\"#shareOnTelegram\"]').on(\"click\", () => {\n shareOnTelegram();\n });\n $('a[href=\"#shareOnWhatsApp\"]').on(\"click\", () => {\n shareOnWhatsApp();\n });\n}\n\n/**\n * Initiate the module.\n *\n * @param {string} url the referral url\n * @param {string} id the unique id of the template\n */\nexport const init = (url, id) => {\n var strings = [\n {\n key: 'referral_copy_to_clipboard',\n component: 'enrol_wallet'\n },\n {\n key: 'referral_copied',\n component: 'enrol_wallet',\n }\n ];\n get_strings(strings).then(function(results) {\n copyTooltip = results[0];\n copiedTooltip = results[1];\n return true;\n }).fail(() => {\n return false;\n });\n shareUrl = url;\n uniqueId = id;\n copyButtonUrl = document.getElementById('copy_url_' + id);\n copyButtonCode = document.getElementById('copy_code_' + id);\n\n addListeners();\n};"],"names":["copyTooltip","copiedTooltip","shareUrl","copyButtonCode","copyButtonUrl","uniqueId","copyText","target","element","input","navigator","clipboard","writeText","value","setAttribute","prefetchStrings","resetTooltip","addListeners","addEventListener","on","window","open","encodeURIComponent","url","id","key","component","then","results","fail","document","getElementById"],"mappings":";;;;;;;SA+BIA,YACAC,cACAC,SACAC,eACAC,cACAC,kBA4BKC,SAASC,OAAQC,aAClBC,OAAQ,mBAAE,IAAMF,OAAS,IAAMF,UAEnCK,UAAUC,UAAUC,UAAUH,MAAM,GAAGI,OAEvCL,QAAQM,aAAa,UAAWb,0LAxC3Bc,gBAAgB,eAAgB,CAAC,6BAA8B,0BA2ClEC,aAAgBR,UAClBA,QAAQM,aAAa,UAAWd,uBAM3BiB,eACLb,cAAcc,iBAAiB,SAAS,KACpCZ,SAAS,MAAOF,kBAEpBA,cAAcc,iBAAiB,cAAc,KACzCF,aAAaZ,kBAEjBD,eAAee,iBAAiB,SAAS,KACrCZ,SAAS,OAAQH,mBAErBA,eAAee,iBAAiB,cAAc,KAC1CF,aAAab,uCAGf,8BAA8BgB,GAAG,SAAS,KAnD5CC,OAAOC,KADM,gDACQC,mBAAmBpB,UAAW,wBAAyB,+CAsD1E,8BAA8BiB,GAAG,SAAS,KAxC5CC,OAAOC,KAAK,8BAAgCC,mBAAmBpB,kCA2C7D,8BAA8BiB,GAAG,SAAS,KAlD5CC,OAAOC,KAAK,uBAAyBC,mBAAmBpB,4BA6DxC,CAACqB,IAAKC,2BACR,CACV,CACIC,IAAK,6BACLC,UAAW,gBAEf,CACID,IAAK,kBACLC,UAAW,kBAGEC,MAAK,SAASC,gBAC/B5B,YAAc4B,QAAQ,GACtB3B,cAAgB2B,QAAQ,IACjB,KACRC,MAAK,KACG,IAEX3B,SAAWqB,IACXlB,SAAWmB,GACXpB,cAAgB0B,SAASC,eAAe,YAAcP,IACtDrB,eAAiB2B,SAASC,eAAe,aAAeP,IAExDP"} \ No newline at end of file +{"version":3,"file":"referral.min.js","sources":["../src/referral.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * TODO describe module referral\n *\n * @module enrol_wallet/referral\n * @copyright 2024 YOUR NAME \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n// eslint-disable-next-line camelcase\nimport {get_strings} from 'core/str';\nimport Prefetch from 'core/prefetch';\n\n// Prefetch required string while the page loading.\nPrefetch.prefetchStrings('enrol_wallet', ['referral_copy_to_clipboard', 'referral_copied']);\n\nlet copyTooltip;\nlet copiedTooltip;\nlet shareUrl;\nlet copyButtonCode;\nlet copyButtonUrl;\nlet uniqueId;\n/**\n *\n */\nfunction shareOnFacebook() {\n let fbBase = 'https://www.facebook.com/sharer/sharer.php?u=';\n window.open(fbBase + encodeURIComponent(shareUrl), 'facebook-share-dialog', 'width=800,height=600');\n}\n\n/**\n *\n */\nfunction shareOnWhatsApp() {\n window.open('https://wa.me/?text=' + encodeURIComponent(shareUrl));\n}\n\n/**\n *\n */\nfunction shareOnTelegram() {\n window.open('https://t.me/share/url?url=' + encodeURIComponent(shareUrl));\n}\n\n/**\n * Copy the text in the input value.\n * @param {string} target\n * @param {DOMElement} element\n */\nfunction copyText(target, element) {\n let input = $('#' + target + '_' + uniqueId);\n\n navigator.clipboard.writeText(input[0].value);\n\n element.setAttribute('title', copiedTooltip);\n}\n\nconst resetTooltip = (element) => {\n element.setAttribute('title', copyTooltip);\n};\n\n/**\n * Add listeners to copy and sharing buttons.\n */\nfunction addListeners() {\n copyButtonUrl.addEventListener('click', () => {\n copyText('url', copyButtonUrl);\n });\n copyButtonUrl.addEventListener('mouseleave', () => {\n resetTooltip(copyButtonUrl);\n });\n copyButtonCode.addEventListener('click', () => {\n copyText('code', copyButtonCode);\n });\n copyButtonCode.addEventListener('mouseleave', () => {\n resetTooltip(copyButtonCode);\n });\n\n $('a[href=\"#shareOnFacebook\"]').on(\"click\", () => {\n shareOnFacebook();\n });\n $('a[href=\"#shareOnTelegram\"]').on(\"click\", () => {\n shareOnTelegram();\n });\n $('a[href=\"#shareOnWhatsApp\"]').on(\"click\", () => {\n shareOnWhatsApp();\n });\n}\n\n/**\n * Initiate the module.\n *\n * @param {string} url the referral url\n * @param {string} id the unique id of the template\n */\nexport const init = (url, id) => {\n var strings = [\n {\n key: 'referral_copy_to_clipboard',\n component: 'enrol_wallet'\n },\n {\n key: 'referral_copied',\n component: 'enrol_wallet',\n }\n ];\n get_strings(strings).then(function(results) {\n copyTooltip = results[0];\n copiedTooltip = results[1];\n return true;\n }).fail(() => {\n return false;\n });\n shareUrl = url;\n uniqueId = id;\n copyButtonUrl = document.getElementById('copy_url_' + id);\n copyButtonCode = document.getElementById('copy_code_' + id);\n\n addListeners();\n};"],"names":["copyTooltip","copiedTooltip","shareUrl","copyButtonCode","copyButtonUrl","uniqueId","copyText","target","element","input","navigator","clipboard","writeText","value","setAttribute","prefetchStrings","resetTooltip","addListeners","addEventListener","on","window","open","encodeURIComponent","url","id","key","component","then","results","fail","document","getElementById"],"mappings":";;;;;;;SA+BIA,YACAC,cACAC,SACAC,eACAC,cACAC,kBA4BKC,SAASC,OAAQC,aAClBC,OAAQ,mBAAE,IAAMF,OAAS,IAAMF,UAEnCK,UAAUC,UAAUC,UAAUH,MAAM,GAAGI,OAEvCL,QAAQM,aAAa,QAASb,0LAxCzBc,gBAAgB,eAAgB,CAAC,6BAA8B,0BA2ClEC,aAAgBR,UAClBA,QAAQM,aAAa,QAASd,uBAMzBiB,eACLb,cAAcc,iBAAiB,SAAS,KACpCZ,SAAS,MAAOF,kBAEpBA,cAAcc,iBAAiB,cAAc,KACzCF,aAAaZ,kBAEjBD,eAAee,iBAAiB,SAAS,KACrCZ,SAAS,OAAQH,mBAErBA,eAAee,iBAAiB,cAAc,KAC1CF,aAAab,uCAGf,8BAA8BgB,GAAG,SAAS,KAnD5CC,OAAOC,KADM,gDACQC,mBAAmBpB,UAAW,wBAAyB,+CAsD1E,8BAA8BiB,GAAG,SAAS,KAxC5CC,OAAOC,KAAK,8BAAgCC,mBAAmBpB,kCA2C7D,8BAA8BiB,GAAG,SAAS,KAlD5CC,OAAOC,KAAK,uBAAyBC,mBAAmBpB,4BA6DxC,CAACqB,IAAKC,2BACR,CACV,CACIC,IAAK,6BACLC,UAAW,gBAEf,CACID,IAAK,kBACLC,UAAW,kBAGEC,MAAK,SAASC,gBAC/B5B,YAAc4B,QAAQ,GACtB3B,cAAgB2B,QAAQ,IACjB,KACRC,MAAK,KACG,IAEX3B,SAAWqB,IACXlB,SAAWmB,GACXpB,cAAgB0B,SAASC,eAAe,YAAcP,IACtDrB,eAAiB2B,SAASC,eAAe,aAAeP,IAExDP"} \ No newline at end of file diff --git a/amd/src/referral.js b/amd/src/referral.js index 05cae0ae..51830861 100644 --- a/amd/src/referral.js +++ b/amd/src/referral.js @@ -67,11 +67,11 @@ function copyText(target, element) { navigator.clipboard.writeText(input[0].value); - element.setAttribute('tooltip', copiedTooltip); + element.setAttribute('title', copiedTooltip); } const resetTooltip = (element) => { - element.setAttribute('tooltip', copyTooltip); + element.setAttribute('title', copyTooltip); }; /** diff --git a/styles.css b/styles.css index 7c239b43..3d7721d5 100644 --- a/styles.css +++ b/styles.css @@ -347,7 +347,7 @@ transform: translateY(0) translateX(-50%); } #page-enrol-wallet-extra-referral .shareLink .permalink .copyLink:after { - content: attr(tooltip); + content: attr(title); width: 140px; bottom: -40px; left: 50%; @@ -355,7 +355,6 @@ border-radius: 4px; font-size: 0.8rem; opacity: 0; - z-index: 3; pointer-events: none; position: absolute; background-color: #000; diff --git a/templates/referral.mustache b/templates/referral.mustache index ede78f1f..2874a6c6 100644 --- a/templates/referral.mustache +++ b/templates/referral.mustache @@ -38,7 +38,7 @@