Subversion Repositories SmartDukaan

Rev

Rev 28270 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {
        $(document).on('click', ".url-generation", function() {
                loadUrlGenration("main-content");
        });



        $(document).on('click', "#submitImage", function() {

                if (confirm("Are you sure?")) {
                        var mediaPojo = {};

                        var title = $('#imageTitle').val();
                        if (title === "") {
                                alert("Title is required!");
                                return false;
                        }
                        //title = title.replace(/\s+/g, "-");
                        mediaPojo.title = title;

                        mediaPojo.imageData = $('#imgPreview').attr("src");

                        console.log(mediaPojo)

                        doPostAjaxRequestWithJsonHandler(context + "/image/media/upload", JSON.stringify(mediaPojo), function(response) {
                                bootbox.alert("Images uploaded successfully");

                                $('#searchImage').click();

                        });

                }


        });


        $(document).on('click', "#searchImage", function() {


                var title = $('#imageTitle').val();
                if (title === "") {
                        alert("Title is required!");
                        return false;
                }
                title = title.replace(/\s+/g, "-");

                doGetAjaxRequestHandler(context + "/search/image/media?title=" + title, function(response) {
                        $('#image-url-container').html(response);

                })

        });



});

function loadUrlGenration(domId) {

        doGetAjaxRequestHandler(context + "/urlGeneration", function(response) {
                $('#' + domId).html(response);
        });
}