Subversion Repositories SmartDukaan

Rev

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

$(function() {

        $(document).on('click', ".feature", function() {
                loadFeaturePanel("main-content");
        });
        
        $(".content").on('click', function() {
                loadContentPanel("main-content");
        });

        /*
         * $(document).on('click', "#feature-paginated .next", function() {
         * loadPaginatedNextItems('/getPaginatedfeature', null, 'feature-paginated',
         * 'feature-table', 'feature-container');
         * 
         * $(this).blur(); });
         * 
         * $(document).on('click', "#feature-paginated .previous", function() {
         * 
         * loadPaginatedPreviousItems('/getPaginatedfeature', null,
         * 'feature-paginated', 'feature-table', 'feature-container');
         * 
         * $(this).blur(); });
         */

        $(document).on('click', "#submitFeature",
                        function() {
                                var editorData = CKEDITOR.instances['featureEditor'].getData();
                                console.log(editorData)
                                var catalogItemid = $('#catalogItemid').val();
                                var rankPoints = $('#rankPoints').val();
                                var featureData = {};
                                if (catalogItemid === "" && rankPoints === ""
                                                && editorData === "") {
                                        alert("Field can't be empty");
                                        return;
                                }
                                if (catalogItemid === "") {
                                        alert("Catalog Item Id is required");
                                        return;
                                }
                                if (rankPoints === "") {
                                        alert("Rank Point is required");
                                        return;
                                }

                                featureData['feature'] = editorData;
                                featureData['catalogItemId'] = $('#catalogItemid').val();
                                featureData['rankPoints'] = $('#rankPoints').val();
                                console.log(featureData)
                                console.log(JSON.stringify(featureData))
                                if (confirm("Are you sure you want add item feature") == true) {
                                        doPostAjaxRequestWithJsonHandler(context + "/itemfeature",
                                                        JSON.stringify(featureData), function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully add feature");
                                                                        loadFeaturePanel("main-content");
                                                                }
                                                        });

                                        return false;
                                }
                        });

        $(document).on('click', ".editfeature", function() {
                rank = $(this).data('rank');
                catalogItemId = $(this).data('requestid');
                $('#catalogItemid').attr('readonly', true);
                feature = $(this).data('feature');
                $('#catalogItemid').val(catalogItemId);
                $('#rankPoints').val(rank);
                CKEDITOR.instances['featureEditor'].setData(feature);
                console.log(rank);
                console.log(catalogItemId);
                console.log(feature);

        });

        $(document).on('click', ".deleteCatalogranking",
                                        function() {
                                                if (confirm("Are you sure you want to Remove the Entry") == true) {
                                                        tagid = $(this).data('tagid');
                                                        console.log(tagid);
                                                        doDeleteAjaxRequestHandler(context
                                                                        + "/removeFeature?id="
                                                                        + tagid, function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully Removed");
                                                                        loadFeaturePanel("main-content");
                                                                }

                                                        });
                                                }

                                        });
});

function loadFeaturePanel(domId) {
        doGetAjaxRequestHandler(context + "/featurePanel", function(response) {
                $('#' + domId).html(response);
                //CKEDITOR.replace("featureEditor");
        });
}
function loadContentPanel(domId) {
        doGetAjaxRequestHandler(context + "/content/index", function(response) {
                $('#' + domId).html(response);
        });
}