Changeset 1043092
- Timestamp:
- 12/11/2014 11:19:44 PM (11 years ago)
- File:
-
- 1 edited
-
verbatim/trunk/js/verbatim.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
verbatim/trunk/js/verbatim.js
r1042882 r1043092 13 13 var withTwitter = false, 14 14 twitterScriptAdded = false; 15 var longURL, textURL; 15 16 16 17 var isFirefox = /Firefox/.test(navigator.userAgent); … … 66 67 } 67 68 68 if (settings.defaultStyling){69 $('.' + settings.highlightedClass).css({70 "background-color": settings.highlightColor71 });72 }69 // if (settings.defaultStyling){ 70 // $('.' + settings.highlightedClass).css({ 71 // "background-color": settings.highlightColor 72 // }); 73 // } 73 74 } 74 75 … … 146 147 $('.verbatim-text-area').remove(); 147 148 148 var textURL = selectedText; 149 var longURL = window.location.origin + window.location.pathname + '#' + encodeURIComponent(textURL); 150 var twitterURL = window.location.origin + window.location.pathname + '#' + textURL; 151 149 textURL = selectedText; 150 longURL = window.location.origin + window.location.pathname + '#' + encodeURIComponent(textURL); 151 152 if (settings.bitlyToken){ 153 $.getJSON( 154 "https://api-ssl.bitly.com/v3/shorten?", 155 { 156 "access_token": settings.bitlyToken, 157 "longUrl": longURL 158 }, 159 function(response) 160 { 161 if (response.status_code == 200){ 162 longURL = response.data.url; 163 self.generateLink(); 164 } 165 } 166 ); 167 } else { 168 longURL = window.location.origin + window.location.pathname + '#' + encodeURIComponent(textURL); 169 self.generateLink(); 170 } 171 } 172 173 $.fn.generateLink = function(){ 152 174 if (withTwitter){ 175 if (textURL.length > 112){ 176 textURL = textURL.substring(0, 112) + '...'; 177 } 178 179 textURL = "\"" + textURL + "\""; 153 180 var twitterLink = document.createElement('a'); 154 181 twitterLink.href='https://twitter.com/intent/tweet?url=' + encodeURIComponent(longURL) + '&text=' + encodeURIComponent(textURL); … … 159 186 160 187 textArea.setAttribute("class", "verbatim-text-area"); 161 162 if (settings.defaultStyling){ 163 textArea.setAttribute("wrap", "off"); 164 } 188 textArea.setAttribute("wrap", "off"); 189 165 190 $('.' + settings.buttonClass).append(textArea); 166 191 167 if (settings.bitlyToken){ 168 $.getJSON( 169 "https://api-ssl.bitly.com/v3/shorten?", 170 { 171 "access_token": settings.bitlyToken, 172 "longUrl": longURL 173 }, 174 function(response) 175 { 176 if (response.status_code == 200){ 177 longURL = response.data.url; 178 $('.verbatim-text-area').val(longURL); 179 textArea.select(); 180 } 181 } 182 ); 183 } else{ 184 $('.verbatim-text-area').val(longURL); 185 textArea.select(); 186 } 192 $('.verbatim-text-area').val(longURL); 193 textArea.select(); 187 194 } 188 195 }
Note: See TracChangeset
for help on using the changeset viewer.