/**
 * jQuery Library for Multilingual Press
 *
 * @version        2014.03.24
 * @package		mlp
 *
 * @todo		Doc
 */

jQuery.noConflict();
( function( $ ) {

	/**
	 * Class Holder
	 */
	var multilingual_press = {

		/**
		 * Initial Function
		 */
		init : function () {
			// this.do_blog_checkup();
			this.set_toggle();
			this.copy_post();
		},

		/**
		 * Retrieves all responses from the blog checkup
		 *
		 * @since	0.8
		 */
		do_blog_checkup : function() {
			if ( ! '#multilingual_press_checkup' )
				return;

			$( '#multilingual_press_checkup_link' ).live( 'click', function() {
				var data = {
					action: 'checkup_blogs'
				};

				$.ajax( {
    				url: ajaxurl,
    				data: data,
    				async: true,
    				success: function ( response ) {
    					$( '#multilingual_press_checkup' ).append( response ).delay( 250 ).animate( {
    						backgroundColor: 'lightYellow',
						    borderBottomColor: '#E6DB55',
						    borderLeftColor: '#E6DB55',
    						borderRightColor: '#E6DB55',
    						borderTopColor: '#E6DB55'
    					}, 500 ).delay( 3500 ).slideUp();
    				}
    			} );
			} );
		},

		/**
		 * Toggle handler, show/hide elements with the class 'mlp_toggler'.
		 */
		set_toggle: function () {

			$(document).on("click", ".mlp_toggler", function (event) {

				var toggle_container = $($(this).data('toggle_selector'));

				// buttons and links
				if ('submit' == this.type || 'A' == this.tagName) {
					event.stopPropagation();
					event.preventDefault();
					toggle_container.toggle();
					return false;
				}

				// labels, needs improvements
				if ('LABEL' == this.tagName) {
					var target = $('#' + $(this).attr('for'));

					/* probably not necessary or useful
					 if ( 'radio' != target.attr( 'type' ) )
					 return true;*/

					event.stopPropagation();

					$('input[name="' + target.attr('name') + '"]').change(function () {
						toggle_container.toggle(target.val() == $(this).val());
						return true;
					});

					return true;
				}

				toggle_container.toggle();

				return false;
			});
		},

		/**
		 * Copy post buttons next to media buttons.
		 */
		copy_post: function () {

			$( document ).on( "click", ".mlp_copy_button", function ( event ) {
				event.stopPropagation();
				event.preventDefault();

				// @formatter:off
				var blog_id = $( this ).data( "blog_id" ),
					title   = $( "#title" ).val(),
					content = $( "#content" ).val(),
					prefix  = "mlp_translation_data_" + blog_id,
					mce     = tinyMCE.get( prefix + "_content" );

				if ( title )
					$( "#" + prefix + "_title" ).val( title );

				if ( content ) {
					$( "#" + prefix + "_content" ).val( content );

					if ( mce )
						mce.setContent( content );
				}
				// @formatter:on
			});
		}
	};

	$( document ).ready( function( $ ) {
		multilingual_press.init();
	} );

} )( jQuery );
@@ -31,17 +31,16 @@
 ilingual
- 
 Press%0A *
@@ -2224,37 +2224,8 @@
 ) %7B%0A
-%09%09%09%09event.stopPropagation();%0A
 %09%09%09%09
@@ -2286,17 +2286,18 @@
  blog_id
- 
+%09%09
 = $( thi
@@ -2323,82 +2323,8 @@
  ),%0A
-%09%09%09%09%09title   = $( %22#title%22 ).val(),%0A%09%09%09%09%09content = $( %22#content%22 ).val(),%0A
 %09%09%09%09
@@ -2330,18 +2330,18 @@
 %09%09prefix
-  
+%09%09
 = %22mlp_t
@@ -2378,20 +2378,18 @@
 %09%09%09%09mce 
-    
+%09%09
 = tinyMC
@@ -2416,16 +2416,128 @@
 ntent%22 )
+,%0A%09%09%09%09%09content%09%09= $( '#content' ).val(), // plain content for %22text%22-view%0A%09%09%09%09%09title%09%09= $( %22#title%22 ).val()%0A%09%09%09%09
 ;%0A%0A%09%09%09%09i
@@ -2674,26 +2674,8 @@
  );%0A
-%0A%09%09%09%09%09if ( mce )%0A%09
 %09%09%09%09

update js