1 | (function($){
|
---|
2 | $.fn.setCursorToTextEnd = function() {
|
---|
3 | $initialVal = this.val();
|
---|
4 | this.val($initialVal + ' ');
|
---|
5 | this.val($initialVal);
|
---|
6 | };
|
---|
7 | })(jQuery);
|
---|
8 | $(document).on('change', '.upload', function() {
|
---|
9 | var path = this.value;
|
---|
10 | var filename = path.replace(/^.*\\/, "");
|
---|
11 | $("#input-upload").val(filename);
|
---|
12 | });
|
---|
13 |
|
---|
14 | $(document).ready(function(){
|
---|
15 |
|
---|
16 | $('#btn-submit').click(function(){
|
---|
17 | $("#charging").css('display', 'block');
|
---|
18 | $("#result").html("");
|
---|
19 | var data = new FormData($("#frm-upload")[0]);
|
---|
20 | //console.log(data);
|
---|
21 | $.ajax({
|
---|
22 | url: '/collaborator/user/upload',
|
---|
23 | type: 'POST',
|
---|
24 | data: data,
|
---|
25 | dataType: 'json',
|
---|
26 | mimeType: "multipart/form-data",
|
---|
27 | contentType: false,
|
---|
28 | processData: false,
|
---|
29 | cache: false,
|
---|
30 | success: function(data){
|
---|
31 | console.log(data)
|
---|
32 | $("#charging").css('display', 'none');
|
---|
33 | $("#result").html(data);
|
---|
34 | },
|
---|
35 | error: function(data){
|
---|
36 | console.log(data);
|
---|
37 | }
|
---|
38 | });
|
---|
39 | return false;
|
---|
40 | });
|
---|
41 |
|
---|
42 | });
|
---|
43 |
|
---|
44 | function updateInfo() {
|
---|
45 | $.ajax({
|
---|
46 | url: '/collaborator/collaborator/updateCollaborator/',
|
---|
47 | type: 'POST',
|
---|
48 | data: $("#frm-update-info").serialize(),
|
---|
49 | success: function (data, textStatus, jqXHR)
|
---|
50 | {
|
---|
51 | result = jQuery.parseJSON(data);
|
---|
52 | if (result.success == "1")
|
---|
53 | {
|
---|
54 | $("#updateInfoSuccess").modal('show');
|
---|
55 | $("#close").click(function(){
|
---|
56 | window.location.reload(true);
|
---|
57 | });
|
---|
58 |
|
---|
59 | }
|
---|
60 | else
|
---|
61 | {
|
---|
62 | //console.log(result.errors);
|
---|
63 | for (var key in result.errors)
|
---|
64 | {
|
---|
65 | console.log(result.errors[key]['field']);
|
---|
66 | $('#' + result.errors[key]['field']).html(result.errors[key]['content']);
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 | });
|
---|
71 | }
|
---|
72 |
|
---|
73 | function changePassword(collaborator_id)
|
---|
74 | {
|
---|
75 | $('#passwd_old_err').html("");
|
---|
76 | $('#passwd_new_err').html("");
|
---|
77 | $('#confirm_passwd_new_err').html("");
|
---|
78 | $.ajax({
|
---|
79 | url: '/collaborator/collaborator/change_password/' + collaborator_id,
|
---|
80 | type: 'POST',
|
---|
81 | data: $("#frm-change-password").serialize(),
|
---|
82 | success: function (data, textStatus, jqXHR)
|
---|
83 | {
|
---|
84 | console.log(data);
|
---|
85 | result = jQuery.parseJSON(data);
|
---|
86 | if (result.success == "1")
|
---|
87 | {
|
---|
88 | $("#changePassSuccess").modal('show');
|
---|
89 | }
|
---|
90 | else
|
---|
91 | {
|
---|
92 | for (var key in result.errors)
|
---|
93 | {
|
---|
94 | $('#'+key).html(result.errors[key]);
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | });
|
---|
99 | }
|
---|