1function Share(id) { 2 //Class for share button in shared/_button_share.php 3 this.selectors = null, 4 this.shareServices = null, 5 this.shareObject = null, 6 this.id = id, 7 this.translation = {}, 8 9 // Methods 10 11 this.escapeString = function(string) { 12 return string.replace(/'/g, "'").replace(/"/g, """); 13 } 14 15 this.populateShareServices = function() { 16 //Setting default values for shareObject 17 if(!this.shareObject.title) { 18 throw new Error("Share() requires an object with atleast a title property. url and content are optional parameters") 19 } 20 21 this.shareObject.url = this.shareObject.url || window.location.href; 22 this.shareObject.content = this.shareObject.content || ''; 23 24 25 this.shareServices = [ 26 { 27 name: "Whatsapp", 28 url: "https://wa.me/?text=*" + this.shareObject.title + ":*%0A" + this.shareObject.url, 29 image: BASE_URL + "/img/share/whats.jpg" 30 }, 31 { 32 name: "Facebook", 33 url: "https://www.facebook.com/sharer/sharer.php?u=" + this.shareObject.url, 34 image: BASE_URL + "/img/share/facebook.jpg" 35 }, 36 { 37 name: "Twitter", 38 url: "https://twitter.com/intent/tweet?text=" + this.shareObject.title + ":%0A&url=" + encodeURI(this.shareObject.url), 39 image: BASE_URL + "/img/share/twitter.jpg" 40 }, 41 { 42 name: "E-mail", 43 url: "mailto:?subject=" + this.shareObject.title + "&body="+this.translation.defaultContent+": " + this.shareObject.url + "%0A%0A" + this.escapeString(this.shareObject.content), 44 image: BASE_URL + "/img/share/email.jpg" 45 } 46 ]; 47 }; 48 49 this.getSelectors = function() { 50 this.selectors = { 51 shareTriggers: $('.share.share-' + this.id), 52 shareModal: $('.share-modal.share-'+this.id), 53 shareBackdrop: $('.share-modal.share-'+this.id+' .backdrop') 54 } 55 }; 56 57 this.renderShareOptions = function() { 58 this.populateShareServices(); 59 60 var shareList = this.shareServices.map(function(item) { 61 return '<li>\ 62 <a href="'+ item.url +'" target="_blank">\ 63 <img src="'+item.image+'"/>\ 64 <h6 class="name">'+item.name+'</h6>\ 65 </a>\ 66 </li>' 67 }); 68 69 return shareList.join(""); 70 }; 71 72 this.renderShareModal = function() { 73 // shareServices must be an array of objects: [{url,image,name},{url,image,name}...] 74 75 var self = this; 76 77 var shareModal ='\ 78 <div class="share-modal share-' +this.id +'">\ 79 <div class="backdrop"></div>\ 80 <div class="share-card">\ 81 <h2>' + this.translation.share + '</h2>\ 82 <div class="share-options">\ 83 <ul>\ 84 '+this.renderShareOptions(this.shareServices) +'\ 85 </ul>\ 86 </div>\ 87 <button class="close-share">\ 88 <span class="glyphicon glyphicon-remove"></span>\ 89 </button>\ 90 </div>\ 91 </div>'; 92 93 $("body").append(shareModal); 94 95 $(".share-modal.share-"+this.id+" .close-share").click(function() { 96 self.toggleModal(); 97 }); 98 }; 99 100 this.shareClick = function() { 101 var self = this; 102
103 this.getSelectors(); 104 105 this.selectors.shareTriggers.click(function() { 106 self.handleSharing(); 107 }); 108 109 this.selectors.shareBackdrop.click(function(e) { 110 self.handleSharing(); 111 }); 112 }; 113 114 this.handleSharing = function() { 115 var self = this; 116 117 if(navigator.share) { 118 navigator.share({ 119 text: this.shareObject.title, 120 url: this.shareObject.url 121 }) 122 .catch(function(err) { 123 this.renderShareModal() 124 }) 125 } else { 126 this.toggleModal(); 127 } 128 }; 129 130 this.toggleModal = function() { 131 this.selectors.shareModal.toggleClass("active"); 132 }; 133 134 this.init = function(shareObject, translation) { 135 this.shareObject = shareObject; 136 this.translation = translation 137 138 this.getSelectors(); 139 this.renderShareModal(); 140 this.shareClick(); 141 } 142}; 143 144/** 145 * Normaliza CPF/CNPJ para uso em formulários (maiúsculas, apenas A-Z e 0-9). 146 */ 147function normalizeDocumentInput(value) { 148 return (value || '').toUpperCase().replace(/[^A-Z0-9]/g, ''); 149}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.