/*! jquery.textSelect - v1.0.0-alpha.1 - 2013-06-18 * https://github.com/JamesMGreene/jquery.textSelect * Copyright (c) 2013 James M. Greene; Licensed MIT */ !function(a,b){"use strict";var c=b.document,d=b.console||null,e=a(c),f=0,g={},h=".textSelect",i=h+".default";a.event.special.textSelect={add:function(b){0===f++&&e.on("mouseup"+i,function(){d&&"function"==typeof d.log&&d.log("document.mouseup [Final bubble! No additional handlers will be invoked]"),g={}});var c=h+(b.namespace?"."+b.namespace:""),j=b.selector,k=a(this);k.on("mousedown"+c,j,function(a){g[this]=a}),k.on("mouseup"+c,j,function(c){var d=a.event.special.textSelect.options;if(g[this]&&d.getSelectedText()){var e,f=g[this],h=c.type,i=c.relatedTarget,j=c.data;g={},c.type=b.origType,c.relatedTarget=f.target,e=d.getCustomEventData(c),b.data=a.extend(!0,{},j,b.data,e),a.event.dispatch.apply(this,arguments),c.type=h,c.relatedTarget=i,c.data=j}})},remove:function(b){0===--f&&e.off(i);var c=h+(b.namespace?"."+b.namespace:""),d=b.selector,g=a(this);g.off("mousedown"+c,d),g.off("mouseup"+c,d)},trigger:function(){var b=a(this);return b.trigger("mousedown"),a.event.special.textSelect.options.selectText(this),b.trigger("mouseup"),!1},options:{getSelectedText:function(){var a="";if(b.getSelection){var d,e=b.getSelection(),f=[];for(d=0;d"),i=[],j=function(){return""===a.trim(a(this).html())};for(f=0;f0&&j.removeAllRanges(),e=c.createRange(),e.setStart(h,0),e.setEnd(i,i.nodeValue.length),j.addRange(e)}else c.selection&&(c.selection.empty(),e=d.createTextRange(),e.select())},getCustomEventData:function(){var b=a.event.special.textSelect.options.getSelectedText(),c=a.event.special.textSelect.options.getSelectedHtml();return{text:b,html:c}}}}}(jQuery,this);