/*
Alessandro Minoccheri
V 0.1.0
17-05-2014
*/

(function ($) {
    $.fn.extend({      
        highlightTwitter: function (argumentOptions) {
            var defaults = {
				image: "img/twitter.png",
			}
			var options = $.extend(defaults, argumentOptions);
			
			return this.each(function () {
                var o = options;
				var obj = $(this);
				var textSend = '';

				getSelectedText = function(){
		    		if (window.getSelection) {
			            return window.getSelection().toString();
			        } else if (document.selection) {
			            return document.selection.createRange().text;
			        }
			        return '';
		    	}

				obj.mouseup(function(e) {
					if(($(event.target).closest('#img-share-twitter').length) && (textSend.toString() !== '')){
						var textTotal = textSend + window.location.href;
						if(textTotal.length > 140){
							textCut = 140 - window.location.href.length;
							textSend = textSend.substring(0, textCut);
						}

						window.open(
						  "http://twitter.com/share?text=" + textSend + "&url=" + window.location.href,
						  '_blank'
						);
					}
					else{
						var text = getSelectedText();
						if (text != ''){
							textSend = text;
							if($(event.target).closest('#img-share-twitter').length){
								window.location.href = "http://twitter.com/share?text=" + text + "&url=" + window.location.href;
							}
							else{
								var offset = obj.offset();
								mouseX = Math.min(e.pageX - offset.left - 30);
								mouseY = Math.min(e.pageY - offset.top - 58);

								$(document).find('#img-share-twitter').remove();

								var img= '<img id="img-share-twitter" src="' + o.image + '" alt="share on twitter" title="Share on Twitter" style="position:absolute; top: ' + mouseY + 'px;  left: ' + mouseX + 'px;">';
								
								if(obj.parent().css('position') == 'relative')
									obj.append(img);
								else
									obj.wrap('<div style="position:relative;"></div>').append(img);
							    
							}
						}
						else
							$(document).find('#img-share-twitter').remove();
					}
				});

				$(document).click(function(event) { 
				    if((!$(event.target).closest(obj).length) && (!$(event.target).closest('#img-share-twitter').length)){
				        $(document).find('#img-share-twitter').remove();
				    }        
				});
            });
        }
    });     
})(jQuery);
@@ -57,20 +57,17 @@
 n ($) %7B%0A
-    
+%09
 $.fn.ext
@@ -78,24 +78,18 @@
 %7B      %0A
-        
+%09%09
 highligh
@@ -127,28 +127,19 @@
 ions) %7B%0A
-            
+%09%09%09
 var defa
@@ -278,24 +278,12 @@
 ) %7B%0A
-                
+%09%09%09%09
 var 
@@ -378,20 +378,17 @@
 on()%7B%0A%09%09
-    
+%09
 %09%09if (wi
@@ -407,36 +407,27 @@
 ction) %7B%0A%09%09%09
-            
+%09%09%09
 return windo
@@ -458,24 +458,18 @@
 g();%0A%09%09%09
-        
+%09%09
 %7D else i
@@ -496,28 +496,19 @@
 n) %7B%0A%09%09%09
-            
+%09%09%09
 return d
@@ -552,29 +552,17 @@
 %0A%09%09%09
-        %7D%0A%09%09%09        
+%09%09%7D%0A%09%09%09%09%09
 retu
@@ -570,20 +570,17 @@
 n '';%0A%09%09
-    
+%09
 %09%7D%0A%0A%09%09%09%09
@@ -1906,20 +1906,17 @@
 %0A%09%09%09%09%09%09%09
-    
+%09
 %0A%09%09%09%09%09%09%09
@@ -2053,20 +2053,17 @@
  %7B %0A%09%09%09%09
-    
+%09
 if((!$(e
@@ -2161,24 +2161,18 @@
 ))%7B%0A%09%09%09%09
-        
+%09%09
 $(docume
@@ -2216,20 +2216,17 @@
 ();%0A%09%09%09%09
-    
+%09
 %7D       
@@ -2239,38 +2239,20 @@
 %7D);%0A
-            %7D);%0A        %7D%0A    
+%09%09%09%7D);%0A%09%09%7D%0A%09
 %7D); 

convert tabs to space