author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
5 | 1 |
/* global tinymce, QTags */ |
0 | 2 |
// send html to the post editor |
3 |
||
5 | 4 |
var wpActiveEditor, send_to_editor; |
0 | 5 |
|
5 | 6 |
send_to_editor = function( html ) { |
7 |
var editor, |
|
8 |
hasTinymce = typeof tinymce !== 'undefined', |
|
9 |
hasQuicktags = typeof QTags !== 'undefined'; |
|
10 |
||
11 |
if ( ! wpActiveEditor ) { |
|
12 |
if ( hasTinymce && tinymce.activeEditor ) { |
|
13 |
editor = tinymce.activeEditor; |
|
14 |
wpActiveEditor = editor.id; |
|
15 |
} else if ( ! hasQuicktags ) { |
|
0 | 16 |
return false; |
17 |
} |
|
5 | 18 |
} else if ( hasTinymce ) { |
19 |
editor = tinymce.get( wpActiveEditor ); |
|
0 | 20 |
} |
21 |
||
5 | 22 |
if ( editor && ! editor.isHidden() ) { |
23 |
editor.execCommand( 'mceInsertContent', false, html ); |
|
24 |
} else if ( hasQuicktags ) { |
|
25 |
QTags.insertContent( html ); |
|
0 | 26 |
} else { |
5 | 27 |
document.getElementById( wpActiveEditor ).value += html; |
0 | 28 |
} |
29 |
||
5 | 30 |
// If the old thickbox remove function exists, call it |
31 |
if ( window.tb_remove ) { |
|
32 |
try { window.tb_remove(); } catch( e ) {} |
|
33 |
} |
|
34 |
}; |
|
0 | 35 |
|
36 |
// thickbox settings |
|
37 |
var tb_position; |
|
38 |
(function($) { |
|
39 |
tb_position = function() { |
|
5 | 40 |
var tbWindow = $('#TB_window'), |
41 |
width = $(window).width(), |
|
42 |
H = $(window).height(), |
|
43 |
W = ( 833 < width ) ? 833 : width, |
|
44 |
adminbar_height = 0; |
|
0 | 45 |
|
5 | 46 |
if ( $('#wpadminbar').length ) { |
47 |
adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 ); |
|
48 |
} |
|
0 | 49 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
if ( tbWindow.length ) { |
0 | 51 |
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height ); |
52 |
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height ); |
|
5 | 53 |
tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'}); |
54 |
if ( typeof document.body.style.maxWidth !== 'undefined' ) |
|
55 |
tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'}); |
|
56 |
} |
|
0 | 57 |
|
58 |
return $('a.thickbox').each( function() { |
|
59 |
var href = $(this).attr('href'); |
|
60 |
if ( ! href ) return; |
|
61 |
href = href.replace(/&width=[0-9]+/g, ''); |
|
62 |
href = href.replace(/&height=[0-9]+/g, ''); |
|
63 |
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) ); |
|
64 |
}); |
|
65 |
}; |
|
66 |
||
67 |
$(window).resize(function(){ tb_position(); }); |
|
68 |
||
69 |
})(jQuery); |