web/app/plugins/wck-custom-fields-and-custom-post-types-creator/wordpress-creation-kit-api/wordpress-creation-kit.js
/* reorder elements through drag and drop */
reorder elements through drag and drop
reorder elements through drag and drop
function mb_sortable_elements() {				
		jQuery( ".mb-table-container tbody" ).not( jQuery( ".mb-table-container.single tbody, .mb-table-container.not-sortable tbody" ) ).sortable({
			start: function(event, ui){
				jQuery( ui.placeholder ).height(jQuery( ui.item ).height());
			},
			update: function(event, ui){
				var value = jQuery(this).parent().siblings('.wck-add-form').attr('id');				
				var id = jQuery(this).parent().attr('post');
				var result = jQuery(this).sortable('toArray');
				var values = {};
				for(var i in result)
				{
					values[i] = result[i].replace('element_','');
				}
				jQuery('#'+value).parent().css({'opacity':'0.4', 'position':'relative'}).append('<div id="mb-ajax-loading"></div>');
				meta = value;
				if( value.indexOf("-wcknested-") != -1 ){
					metaDetails = value.split("-wcknested-");
					meta = metaDetails[0];
				}
				jQuery.post( wckAjaxurl ,  { action:"wck_reorder_meta"+meta, meta:value, id:id, values:values}, function(response) {
					jQuery('#container_'+value).replaceWith(response.entry_list);
					jQuery('.mb-table-container tbody td').css('width', function(){ return jQuery(this).width() });
					mb_sortable_elements();
					jQuery('#'+value).parent().css('opacity','1');
					jQuery('#mb-ajax-loading').remove();
				});
			},
            items: "> tr",
			placeholder: "wck-ui-state-highlight"
		});
		jQuery( "#sortable:not(select)" ).disableSelection();
		jQuery('.mb-table-container ul').mousedown( function(e){		
			e.stopPropagation();
		});	
}
function mb_sortable_elements ( ) { jQuery ( ".mb-table-container tbody" ) . not ( jQuery ( ".mb-table-container.single tbody, .mb-table-container.not-sortable tbody" ) ) . sortable ( { start : function ( event , ui ) { jQuery ( ui . placeholder ) . height ( jQuery ( ui . item ) . height ( ) ) ; } , update : function ( event , ui ) { var value = jQuery ( this ) . parent ( ) . siblings ( '.wck-add-form' ) . attr ( 'id' ) ; var id = jQuery ( this ) . parent ( ) . attr ( 'post' ) ; var result = jQuery ( this ) . sortable ( 'toArray' ) ; var values = { } ; for ( var i in result ) { values [ i ] = result [ i ] . replace ( 'element_' , '' ) ; } jQuery ( '#' + value ) . parent ( ) . css ( { 'opacity' : '0.4' , 'position' : 'relative' } ) . append ( '<div id="mb-ajax-loading"></div>' ) ; meta = value ; if ( value . indexOf ( "-wcknested-" ) != - 1 ) { metaDetails = value . split ( "-wcknested-" ) ; meta = metaDetails [ 0 ] ; } jQuery . post ( wckAjaxurl , { action : "wck_reorder_meta" + meta , meta : value , id : id , values : values } , function ( response ) { jQuery ( '#container_' + value ) . replaceWith ( response . entry_list ) ; jQuery ( '.mb-table-container tbody td' ) . css ( 'width' , function ( ) { return jQuery ( this ) . width ( ) } ) ; mb_sortable_elements ( ) ; jQuery ( '#' + value ) . parent ( ) . css ( 'opacity' , '1' ) ; jQuery ( '#mb-ajax-loading' ) . remove ( ) ; } ) ; } , items : "> tr" , placeholder : "wck-ui-state-highlight" } ) ; jQuery ( "#sortable:not(select)" ) . disableSelection ( ) ; jQuery ( '.mb-table-container ul' ) . mousedown ( function ( e ) { e . stopPropagation ( ) ; } ) ; }
reorder elements through drag and drop
reorder elements through drag and drop
/*I don't know if this is necessary. Remove when I have more time for tests */