web/wp-admin/js/media-upload.dev.js
author ymh <ymh.work@gmail.com>
Mon, 22 Mar 2010 16:36:28 +0100
changeset 5 ac511f1ccc8e
parent 1 0d28b7c10758
permissions -rw-r--r--
add hgignore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
0d28b7c10758 First commit
ymh
parents:
diff changeset
     1
// send html to the post editor
0d28b7c10758 First commit
ymh
parents:
diff changeset
     2
function send_to_editor(h) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
     3
	var ed;
0d28b7c10758 First commit
ymh
parents:
diff changeset
     4
0d28b7c10758 First commit
ymh
parents:
diff changeset
     5
	if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
     6
		ed.focus();
0d28b7c10758 First commit
ymh
parents:
diff changeset
     7
		if ( tinymce.isIE )
0d28b7c10758 First commit
ymh
parents:
diff changeset
     8
			ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
0d28b7c10758 First commit
ymh
parents:
diff changeset
     9
0d28b7c10758 First commit
ymh
parents:
diff changeset
    10
		if ( h.indexOf('[caption') === 0 ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    11
			if ( ed.plugins.wpeditimage )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    12
				h = ed.plugins.wpeditimage._do_shcode(h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    13
		} else if ( h.indexOf('[gallery') === 0 ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    14
			if ( ed.plugins.wpgallery )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    15
				h = ed.plugins.wpgallery._do_gallery(h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    16
		} else if ( h.indexOf('[embed') === 0 ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    17
			if ( ed.plugins.wordpress )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    18
				h = ed.plugins.wordpress._setEmbed(h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    19
		}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    20
0d28b7c10758 First commit
ymh
parents:
diff changeset
    21
		ed.execCommand('mceInsertContent', false, h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    22
0d28b7c10758 First commit
ymh
parents:
diff changeset
    23
	} else if ( typeof edInsertContent == 'function' ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    24
		edInsertContent(edCanvas, h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    25
	} else {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    26
		jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    27
	}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    28
0d28b7c10758 First commit
ymh
parents:
diff changeset
    29
	tb_remove();
0d28b7c10758 First commit
ymh
parents:
diff changeset
    30
}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    31
0d28b7c10758 First commit
ymh
parents:
diff changeset
    32
// thickbox settings
0d28b7c10758 First commit
ymh
parents:
diff changeset
    33
var tb_position;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    34
(function($) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    35
	tb_position = function() {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    36
		var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    37
0d28b7c10758 First commit
ymh
parents:
diff changeset
    38
		if ( tbWindow.size() ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    39
			tbWindow.width( W - 50 ).height( H - 45 );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    40
			$('#TB_iframeContent').width( W - 50 ).height( H - 75 );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    41
			tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    42
			if ( typeof document.body.style.maxWidth != 'undefined' )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    43
				tbWindow.css({'top':'20px','margin-top':'0'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    44
		};
0d28b7c10758 First commit
ymh
parents:
diff changeset
    45
0d28b7c10758 First commit
ymh
parents:
diff changeset
    46
		return $('a.thickbox').each( function() {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    47
			var href = $(this).attr('href');
0d28b7c10758 First commit
ymh
parents:
diff changeset
    48
			if ( ! href ) return;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    49
			href = href.replace(/&width=[0-9]+/g, '');
0d28b7c10758 First commit
ymh
parents:
diff changeset
    50
			href = href.replace(/&height=[0-9]+/g, '');
0d28b7c10758 First commit
ymh
parents:
diff changeset
    51
			$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    52
		});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    53
	};
0d28b7c10758 First commit
ymh
parents:
diff changeset
    54
0d28b7c10758 First commit
ymh
parents:
diff changeset
    55
	$(window).resize(function(){ tb_position(); });
0d28b7c10758 First commit
ymh
parents:
diff changeset
    56
0d28b7c10758 First commit
ymh
parents:
diff changeset
    57
})(jQuery);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    58
0d28b7c10758 First commit
ymh
parents:
diff changeset
    59
jQuery(document).ready(function($){
0d28b7c10758 First commit
ymh
parents:
diff changeset
    60
	$('a.thickbox').click(function(){
0d28b7c10758 First commit
ymh
parents:
diff changeset
    61
		if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    62
			tinyMCE.get('content').focus();
0d28b7c10758 First commit
ymh
parents:
diff changeset
    63
			tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
0d28b7c10758 First commit
ymh
parents:
diff changeset
    64
		}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    65
	});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    66
});