summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wp-syntax/js/wp-syntax.js')
-rw-r--r--plugins/wp-syntax/js/wp-syntax.js78
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
+});