jQuery(document).ready(function($){

    var editor = new MediumEditor('.editable'
            );
        $(function () {
            $('.editable-0').mediumInsert({
                editor: editor,
                addons: {
                    images: {
                        uploadScript: null,
                        deleteScript: null,
                        captionPlaceholder: 'Type caption for image',
                        styles: {
                            slideshow: {
                                label: '<span class="fa fa-play"></span>',
                                added: function ($el) {
                                    $el
                                        .data('cycle-center-vert', true)
                                        .cycle({
                                            slides: 'figure'
                                        });
                                },
                                removed: function ($el) {
                                    $el.cycle('destroy');
                                }
                            }
                        },
                        actions: null
                    }
                }
            });
        });
        $(function () {
            $('.editable-1').mediumInsert({
                editor: editor,
                addons: {
                    images: {
                        uploadScript: null,
                        deleteScript: null,
                        captionPlaceholder: 'Type caption for image',
                        styles: {
                            slideshow: {
                                label: '<span class="fa fa-play"></span>',
                                added: function ($el) {
                                    $el
                                        .data('cycle-center-vert', true)
                                        .cycle({
                                            slides: 'figure'
                                        });
                                },
                                removed: function ($el) {
                                    $el.cycle('destroy');
                                }
                            }
                        },
                        actions: null
                    }
                }
            });
        });
        $(function () {
            $('.editable-2').mediumInsert({
                editor: editor,
                addons: {
                    images: {
                        uploadScript: null,
                        deleteScript: null,
                        captionPlaceholder: 'Type caption for image',
                        styles: {
                            slideshow: {
                                label: '<span class="fa fa-play"></span>',
                                added: function ($el) {
                                    $el
                                        .data('cycle-center-vert', true)
                                        .cycle({
                                            slides: 'figure'
                                        });
                                },
                                removed: function ($el) {
                                    $el.cycle('destroy');
                                }
                            }
                        },
                        actions: null
                    }
                }
            });
        });
        $(function () {
            $('.editable-3').mediumInsert({
                editor: editor,
                addons: {
                    images: {
                        uploadScript: null,
                        deleteScript: null,
                        captionPlaceholder: 'Type caption for image',
                        styles: {
                            slideshow: {
                                label: '<span class="fa fa-play"></span>',
                                added: function ($el) {
                                    $el
                                        .data('cycle-center-vert', true)
                                        .cycle({
                                            slides: 'figure'
                                        });
                                },
                                removed: function ($el) {
                                    $el.cycle('destroy');
                                }
                            }
                        },
                        actions: null
                    }
                }
            });
        });
        $(function () {
            $('.editable-4').mediumInsert({
                editor: editor,
                addons: {
                    images: {
                        uploadScript: null,
                        deleteScript: null,
                        captionPlaceholder: 'Type caption for image',
                        styles: {
                            slideshow: {
                                label: '<span class="fa fa-play"></span>',
                                added: function ($el) {
                                    $el
                                        .data('cycle-center-vert', true)
                                        .cycle({
                                            slides: 'figure'
                                        });
                                },
                                removed: function ($el) {
                                    $el.cycle('destroy');
                                }
                            }
                        },
                        actions: null
                    }
                }
            });
        });
        var editor_1 = new MediumEditor('.editable-1');
        var editor_2 = new MediumEditor('.editable-2');
        var editor_3 = new MediumEditor('.editable-3');
        var editor_4 = new MediumEditor('.editable-4');
    //
    $('.ahachat_submit_form_settings').click(function(e){
        e.preventDefault();
        var name= $('.cartback_shortcode_editor_name').html();
        var img = $('#ahachat_like_comment_image_icon_url').val();
        var please = $('.ahachat_like_comment_editor_please').html();
        var like =  $('.ahachat_like_comment_editor_like').html();
        var comment = $('.ahachat_like_comment_editor_comment').html();
        var done = $('.ahachat_like_comment_editor_done').html();
        var action_data = {
            action:'ahachat_like_comment_settings_alert',
            name:name,
            img : img,
            please:please,
            like:like,
            comment:comment,
            done:done
        };
        $.post(ajaxurl,action_data,function(result){
            if(result){
                if(result=="success"){
                    $(".msg").html('<div class="updated" style="color:green;" id="message"><p><strong> Save Changed! </strong></p></div>');
                    $('html, body').animate({scrollTop:(0)}, '200');
                        setTimeout(function() {
                            $("#message").fadeOut(1000);
                        }, 4000);
                }
            }
            else
            {
                return false;
            }
        });
    });
});