/**
 * selectedText v0.6
 * http://squareflower.de/downloads/jquery/selectedText/
 *
 * Copyright 2010, Lukas Rydygel
 * Attribution-ShareAlike 3.0 Unported
 * http://creativecommons.org/licenses/by-sa/3.0/
 */
(function(e){e.selectedText=function(f){e(document).selectedText(f)};e.fn.selectedText=function(f){var h=function(){},a={min:0,max:0,start:h,selecting:h,stop:h},g=false,c={_setOptions:function(b){e.extend(true,a,b);e(this).data("selectedText-settings",a)},_getOptions:function(){return e(this).data("selectedText-settings")},options:function(b){return typeof b==="object"?c._setOptions.apply(this,[b]):c._getOptions.apply(this)},init:function(b){c._setOptions.apply(this,[b]);this.bind("mousedown",function(d){c._start(d)}).bind("mousemove", function(d){c._selecting(d)}).bind("mouseup",function(d){c._stop(d)})},_start:function(b){g=true;a.start(b)},_selecting:function(b){var d=c._getSelectedText();c._checkLength(d.length)&&g&&a.selecting(d,b)},_stop:function(b){var d=c._getSelectedText();c._checkLength(d.length)&&g&&a.stop(d,b);g=false},_checkLength:function(b){if(a.min<=0&&a.max<=0)return true;else if(a.min>0&&a.max==0)return b>=a.min?true:false;else if(a.min==0&&a.max>0)return b<=a.max?true:false;else if(a.min>0&&a.max>=a.min)return b>= a.min&&b<=a.max?true:false},_getSelectedText:function(){if(window.getSelection)return window.getSelection().toString();else if(document.getSelection)return document.getSelection();else if(document.selection)return document.selection.createRange().text;return null},destroy:function(){this.unbind("mousedown mousemove mouseup")}};if(c[f]){a=c._getOptions.apply(this);c[f].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof f==="object"||!f)c.init.apply(this,arguments)}})(jQuery);
