diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2017-01-03 19:31:15 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2017-01-03 19:31:15 -0500 |
commit | 51c14fa5dfdce1fe6261e2ee61c35afd2e2ac7d6 (patch) | |
tree | f321f9ab3768bca23c6ad7a34cacb8af7b748c3c /plugins/wp-syntax/js | |
parent | Update plugin wordpress-mobile-pack to 2.2.7 (diff) | |
download | blogs-gentoo-51c14fa5dfdce1fe6261e2ee61c35afd2e2ac7d6.tar.gz blogs-gentoo-51c14fa5dfdce1fe6261e2ee61c35afd2e2ac7d6.tar.bz2 blogs-gentoo-51c14fa5dfdce1fe6261e2ee61c35afd2e2ac7d6.zip |
Update plugin wp-syntax to 1.1
Diffstat (limited to 'plugins/wp-syntax/js')
-rw-r--r-- | plugins/wp-syntax/js/wp-syntax.js | 78 |
1 files changed, 70 insertions, 8 deletions
diff --git a/plugins/wp-syntax/js/wp-syntax.js b/plugins/wp-syntax/js/wp-syntax.js index f7f6c739..8472db3e 100644 --- a/plugins/wp-syntax/js/wp-syntax.js +++ b/plugins/wp-syntax/js/wp-syntax.js @@ -6,14 +6,14 @@ jQuery(document).ready(function($) { var w = $(this).find('table').outerWidth(); var hw = $(document).width() - $(this).offset().left - 20; - + /* * Test code. */ /*var left, top; left = $(this).offset().left; top = $(this).offset().top; - + $(this) .appendTo('body') .css({ @@ -22,13 +22,75 @@ jQuery(document).ready(function($) 'top': top + 'px' }); */ - - if(w > $(this).outerWidth()) - $(this).css({'position':'relative', 'z-index':'9999', 'box-shadow':'5px 5px 5px #888', 'width':(w > hw ? hw : w)+'px'}); + + if(w > $(this).outerWidth()) { + // $(this).css({'position':'relative', 'z-index':'9999', 'box-shadow':'5px 5px 5px #888', 'width':(w > hw ? hw : w)+'px'}); + $(this).css({'position':'relative', 'z-index':'9999', 'width':(w > hw ? hw : w)+'px'}); + } }, mouseout: function() { - //$(this).removeAttr('style'); - } + // $(this).removeAttr('style'); + $(this).css({'position':'relative', 'z-index':'', 'width':'auto'}); + }, + dblclick: function() + { + //Create text area on top of code on double click + //This can make copying of the code easier + + var jthis = $(this); + if (!jthis.data('hasTextArea')) { + var code = jthis.find(".theCode").html(); + var ta = $('<textarea spellcheck="false"/>'); + ta.html(code); + + var pre = jthis.find('.code > pre'); + + ta.css({ + 'font-family': pre.css('font-family'), + 'font-size': pre.css('font-size'), + 'line-height': pre.css('line-height'), + 'height': "100%", + 'width': "100%", + 'position': 'absolute', + 'top': 0, + 'left': 0, + 'margin': pre.css('margin'), + 'padding': pre.css('padding'), + 'border': '0px' + }); + + ta.css('resize','none'); + ta.css('outline','none'); + + ta.focusout(function(){ + ta.remove(); + jthis.data('hasTextArea',false); + }); + + //readjust position and width if using line numbers + var line_numbers = jthis.find(".line_numbers"); + if (line_numbers.length != 0) { + var w = line_numbers.outerWidth(); + ta.css('left',w+"px"); + ta.css('width', jthis.width()-w+"px"); + } + //readjust position and height if using caption + var caption = jthis.find('caption'); + if (caption.length != 0) { + var h = caption.outerHeight(); + ta.css('top',h+"px"); + ta.css('height',jthis.height()-h+"px"); + } + + ta.appendTo(jthis); + + ta.select(); + ta.focus(); + + jthis.data('hasTextArea',true); + + } + } }); -});
\ No newline at end of file +}); |