Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
var EcommerceProductsEdit = function () {
2
 
3
    var handleImages = function() {
4
 
5
        // see http://www.plupload.com/
6
        var uploader = new plupload.Uploader({
7
            runtimes : 'html5,flash,silverlight,html4',
8
 
9
            browse_button : document.getElementById('tab_images_uploader_pickfiles'), // you can pass in id...
10
            container: document.getElementById('tab_images_uploader_container'), // ... or DOM Element itself
11
 
12
            url : "assets/plugins/plupload/examples/upload.php",
13
 
14
            filters : {
15
                max_file_size : '10mb',
16
                mime_types: [
17
                    {title : "Image files", extensions : "jpg,gif,png"},
18
                    {title : "Zip files", extensions : "zip"}
19
                ]
20
            },
21
 
22
            // Flash settings
23
            flash_swf_url : 'assets/plugins/plupload/js/Moxie.swf',
24
 
25
            // Silverlight settings
26
            silverlight_xap_url : 'assets/plugins/plupload/js/Moxie.xap',            
27
 
28
            init: {
29
                PostInit: function() {
30
                    $('#tab_images_uploader_filelist').html("");
31
 
32
                    $('#tab_images_uploader_uploadfiles').click(function() {
33
                        uploader.start();
34
                        return false;
35
                    });
36
 
37
                    $('#tab_images_uploader_filelist').on('click', '.added-files .remove', function(){
38
                        uploader.removeFile($(this).parent('.added-files').attr("id"));    
39
                        $(this).parent('.added-files').remove();                    
40
                    });
41
                },
42
 
43
                FilesAdded: function(up, files) {
44
                    plupload.each(files, function(file) {
45
                        $('#tab_images_uploader_filelist').append('<div class="alert alert-warning added-files" id="uploaded_file_' + file.id + '">' + file.name + '(' + plupload.formatSize(file.size) + ') <span class="status label label-info"></span>&nbsp;<a href="javascript:;" style="margin-top:-5px" class="remove pull-right btn btn-sm red"><i class="fa fa-times"></i> remove</a></div>');
46
                    });
47
                },
48
 
49
                UploadProgress: function(up, file) {
50
                    $('#uploaded_file_' + file.id + ' > .status').html(file.percent + '%');
51
                },
52
 
53
                FileUploaded: function(up, file, response) {
54
                    var response = $.parseJSON(response.response);
55
 
56
                    if (response.result && response.result == 'OK') {
57
                        var id = response.id; // uploaded file's unique name. Here you can collect uploaded file names and submit an jax request to your server side script to process the uploaded files and update the images tabke
58
 
59
                        $('#uploaded_file_' + file.id + ' > .status').removeClass("label-info").addClass("label-success").html('<i class="fa fa-check"></i> Done'); // set successfull upload
60
                    } else {
61
                        $('#uploaded_file_' + file.id + ' > .status').removeClass("label-info").addClass("label-danger").html('<i class="fa fa-warning"></i> Failed'); // set failed upload
62
                        Metronic.alert({type: 'danger', message: 'One of uploads failed. Please retry.', closeInSeconds: 10, icon: 'warning'});
63
                    }
64
                },
65
 
66
                Error: function(up, err) {
67
                    Metronic.alert({type: 'danger', message: err.message, closeInSeconds: 10, icon: 'warning'});
68
                }
69
            }
70
        });
71
 
72
        uploader.init();
73
 
74
    }
75
 
76
    var handleReviews = function () {
77
 
78
        var grid = new Datatable();
79
 
80
        grid.init({
81
            src: $("#datatable_reviews"),
82
            onSuccess: function (grid) {
83
                // execute some code after table records loaded
84
            },
85
            onError: function (grid) {
86
                // execute some code on network or other general error  
87
            },
88
            loadingMessage: 'Loading...',
89
            dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options 
90
 
91
                // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
92
                // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/scripts/datatable.js). 
93
                // So when dropdowns used the scrollable div should be removed. 
94
                //"dom": "<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r>t<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>>",
95
 
96
                "lengthMenu": [
97
                    [10, 20, 50, 100, 150, -1],
98
                    [10, 20, 50, 100, 150, "All"] // change per page values here
99
                ],
100
                "pageLength": 10, // default record count per page
101
                "ajax": {
102
                    "url": "demo/ecommerce_product_reviews.php", // ajax source
103
                },
104
                "columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column)
105
                    'orderable': true,
106
                    'targets': [0]
107
                }],
108
                "order": [
109
                    [0, "asc"]
110
                ] // set first column as a default sort by asc
111
            }
112
        });
113
    }
114
 
115
    var handleHistory = function () {
116
 
117
        var grid = new Datatable();
118
 
119
        grid.init({
120
            src: $("#datatable_history"),
121
            onSuccess: function (grid) {
122
                // execute some code after table records loaded
123
            },
124
            onError: function (grid) {
125
                // execute some code on network or other general error  
126
            },
127
            loadingMessage: 'Loading...',
128
            dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options 
129
                "lengthMenu": [
130
                    [10, 20, 50, 100, 150, -1],
131
                    [10, 20, 50, 100, 150, "All"] // change per page values here
132
                ],
133
                "pageLength": 10, // default record count per page
134
                "ajax": {
135
                    "url": "demo/ecommerce_product_history.php", // ajax source
136
                },
137
                "columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column)
138
                    'orderable': true,
139
                    'targets': [0]
140
                }],
141
                "order": [
142
                    [0, "asc"]
143
                ] // set first column as a default sort by asc
144
            }
145
        });
146
    }
147
 
148
    var initComponents = function () {
149
        //init datepickers
150
        $('.date-picker').datepicker({
151
            rtl: Metronic.isRTL(),
152
            autoclose: true
153
        });
154
 
155
        //init datetimepickers
156
        $(".datetime-picker").datetimepicker({
157
            isRTL: Metronic.isRTL(),
158
            autoclose: true,
159
            todayBtn: true,
160
            pickerPosition: (Metronic.isRTL() ? "bottom-right" : "bottom-left"),
161
            minuteStep: 10
162
        });
163
 
164
        //init maxlength handler
165
        $('.maxlength-handler').maxlength({
166
            limitReachedClass: "label label-danger",
167
            alwaysShow: true,
168
            threshold: 5
169
        });
170
    }
171
 
172
    return {
173
 
174
        //main function to initiate the module
175
        init: function () {
176
            initComponents();
177
 
178
            handleImages();
179
            handleReviews();
180
            handleHistory();
181
        }
182
 
183
    };
184
 
185
}();