Sha256: 38e9738fd275f3fd41b977fcf18f2db02200fcd8a1d4e732dfd57c4d8f3295f2

Contents?: true

Size: 1.92 KB

Versions: 10

Compression:

Stored size: 1.92 KB

Contents

/* jQuery plugin textselect
 * version: 0.9
 * author: Josef Moravec, josef.moravec@gmail.com
 * updated: Imperavi 
 * 
 */
(function($){$.event.special.textselect={setup:function(data,namespaces)
{$(this).data("textselected",false);$(this).data("ttt",data);$(this).bind('mouseup',$.event.special.textselect.handler);},teardown:function(data)
{$(this).unbind('mouseup',$.event.special.textselect.handler);},handler:function(event)
{var data=$(this).data("ttt");var text=$.event.special.textselect.getSelectedText(data).toString();if(text!='')
{$(this).data("textselected",true);event.type="textselect";event.text=text;$.event.handle.apply(this,arguments);}},getSelectedText:function(data)
{var text='';var frame=$('#imp_redactor_frame_'+data).get(0);if(frame.contentWindow.getSelection)text=frame.contentWindow.getSelection();else if(frame.contentWindow.document.getSelection) text=frame.contentWindow.document.getSelection();else if(frame.contentWindow.document.selection)text=frame.contentWindow.document.selection.createRange().text;return text;}}
$.event.special.textunselect={setup:function(data,namespaces){$(this).data("rttt",data);$(this).data("textselected",false);$(this).bind('mouseup',$.event.special.textunselect.handler);$(this).bind('keyup',$.event.special.textunselect.handlerKey)},teardown:function(data){$(this).unbind('mouseup',$.event.special.textunselect.handler);},handler:function(event){if($(this).data("textselected")){var data=$(this).data("rttt");var text=$.event.special.textselect.getSelectedText(data).toString();if(text==''){$(this).data("textselected",false);event.type="textunselect";$.event.handle.apply(this,arguments);}}},handlerKey:function(event){if($(this).data("textselected")){var data=$(this).data("rttt");var text=$.event.special.textselect.getSelectedText(data).toString();if((event.keyCode=27)&&(text=='')){$(this).data("textselected",false);event.type="textunselect";$.event.handle.apply(this,arguments);}}}}})(jQuery);

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
imperavi-rails-0.0.12.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.11.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.10.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.9.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.8.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.7.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.6.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.5.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.4.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js
imperavi-rails-0.0.3.beta app/assets/javascripts/imperavi-rails/imperavi/textselect.js