Subversion Repositories SmartDukaan

Rev

Rev 36751 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
36563 amit 1
$(function() {
2
 
3
    $(document).on('click', ".manage-flagship", function() {
4
        loadFlagship("main-content");
5
    });
6
 
7
    $(document).on('click', ".add-flagship-model", function() {
36751 amit 8
        var selectedCatalogId = $('.flagship-item-search').data('catalogId');
36563 amit 9
        var startDate = $('#flagship-start-date').val();
10
        var endDate = $('#flagship-end-date').val();
11
 
12
        if (!selectedCatalogId) {
13
            alert("Please select a catalog item");
14
            return false;
15
        }
16
        if (!startDate) {
17
            alert("Start date is required");
18
            return false;
19
        }
20
 
21
        if (confirm("Add this model as Flagship?") == true) {
22
            doPostAjaxRequestHandler(context + "/addFlagship?catalogItemId=" + selectedCatalogId
23
                + "&startDate=" + startDate
24
                + "&endDate=" + (endDate || ""),
25
                function(response) {
26
                    if (response == 'true') {
27
                        alert("Flagship model added successfully");
28
                        loadFlagship("main-content");
29
                    }
30
                });
31
        }
32
    });
33
 
34
    $(document).on('click', ".remove-flagship", function() {
35
        var id = $(this).data('requestid');
36
        if (confirm("Are you sure you want to remove this flagship model?") == true) {
37
            doPostAjaxRequestHandler(context + "/flagship/remove?id=" + id,
38
                function(response) {
39
                    if (response == 'true') {
40
                        alert("Flagship model removed successfully");
41
                        loadFlagship("main-content");
42
                    }
43
                });
44
        }
45
    });
46
 
47
});
48
 
49
function loadFlagship(domId) {
50
    doGetAjaxRequestHandler(context + "/manageFlagship", function(response) {
51
        $('#' + domId).html(response);
36756 amit 52
        getCatalogAheadOptions($('#' + domId).find('.flagship-item-search'), 40000, function(selectedItem) {
36751 amit 53
            $('#' + domId).find('.flagship-item-search').data('catalogId', selectedItem.catalogId);
36726 amit 54
        });
36563 amit 55
    });
56
}