Subversion Repositories SmartDukaan

Rev

Rev 36563 | Rev 36726 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
36563 amit 1
$(function() {
2
    var selectedCatalogId = null;
3
 
4
    $(document).on('click', ".manage-flagship", function() {
5
        loadFlagship("main-content");
6
    });
7
 
8
    $(document).on('click', ".add-flagship-model", function() {
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
    $(document).on('focus', '.flagship-item-search', function() {
36598 amit 48
        getCatalogAheadOptions($(this), 70000, function(selectedItem) {
36563 amit 49
            selectedCatalogId = selectedItem.catalogId;
50
        });
51
    });
52
});
53
 
54
function loadFlagship(domId) {
55
    doGetAjaxRequestHandler(context + "/manageFlagship", function(response) {
56
        $('#' + domId).html(response);
57
    });
58
}