Skip to content

Commit 6a2ef25

Browse files
authored
Merge pull request #160 from themeum/harun
icon size changed and tooltip position changed & profile photo upload translatable
2 parents b6d5cc8 + c1d20c3 commit 6a2ef25

File tree

2 files changed

+83
-72
lines changed

2 files changed

+83
-72
lines changed

assets/react/front/dashboard/settings/profile.js

Lines changed: 81 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,84 @@ const validURL = (str) => {
77
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
88
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
99
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
10-
'(\\#[-a-z\\d_]*)?$',
10+
'(\\#[-a-z\\d_]*)?$',
1111
'i',
1212
); // fragment locator
1313
return !!pattern.test(str);
1414
};
1515

16-
const getResizedFromUploaded=(file, dimension, callback)=> {
17-
// Read image as data url
18-
let reader = new FileReader();
19-
reader.addEventListener('load', ()=> {
16+
const getResizedFromUploaded = (file, dimension, callback) => {
17+
// Read image as data url
18+
let reader = new FileReader();
19+
reader.addEventListener('load', () => {
2020

21-
// Read as image to retrieve dimension
22-
let image = new Image();
23-
image.addEventListener('load', ()=>{
24-
let {width, height}=image;
21+
// Read as image to retrieve dimension
22+
let image = new Image();
23+
image.addEventListener('load', () => {
24+
let { width, height } = image;
2525

26-
let left = 0;
27-
let top = 0;
28-
let w = width;
29-
let h = height;
26+
let left = 0;
27+
let top = 0;
28+
let w = width;
29+
let h = height;
3030

31-
if(dimension.width==dimension.height) {
32-
left = width>height ? (width-height)/2 : 0;
33-
top = height>width ? (height-width)/2 : 0;
31+
if (dimension.width == dimension.height) {
32+
left = width > height ? (width - height) / 2 : 0;
33+
top = height > width ? (height - width) / 2 : 0;
3434

35-
w = width>height ? height : width;
36-
h = height>width ? width : height;
37-
}
35+
w = width > height ? height : width;
36+
h = height > width ? width : height;
37+
}
3838

39-
dimension.height = dimension.height || (height/width)*dimension.width;
39+
dimension.height = dimension.height || (height / width) * dimension.width;
4040

41-
let dm_width = dimension.width>width ? width : dimension.width;
42-
let dm_height = dimension.width>width ? height : dimension.height;
41+
let dm_width = dimension.width > width ? width : dimension.width;
42+
let dm_height = dimension.width > width ? height : dimension.height;
4343

44-
// Create the destination canvas
45-
let canvas = document.createElement('canvas');
46-
canvas.width = dm_width;
47-
canvas.height = dm_height;
48-
let context = canvas.getContext('2d');
44+
// Create the destination canvas
45+
let canvas = document.createElement('canvas');
46+
canvas.width = dm_width;
47+
canvas.height = dm_height;
48+
let context = canvas.getContext('2d');
4949

50-
context.drawImage(image, left, top, w, h, 0, 0, canvas.width, canvas.height);
50+
context.drawImage(image, left, top, w, h, 0, 0, canvas.width, canvas.height);
5151

52-
canvas.toBlob(blob=> {
53-
blob.name = file.name;
54-
blob.lastModified = file.lastModified;
55-
56-
let reader2 = new FileReader();
57-
reader2.addEventListener('load', ()=> {
58-
callback(blob, reader2.result);
59-
})
60-
reader2.readAsDataURL(blob);
52+
canvas.toBlob(blob => {
53+
blob.name = file.name;
54+
blob.lastModified = file.lastModified;
6155

62-
}, 'image/jpeg');
63-
});
56+
let reader2 = new FileReader();
57+
reader2.addEventListener('load', () => {
58+
callback(blob, reader2.result);
59+
})
60+
reader2.readAsDataURL(blob);
6461

65-
image.src = reader.result;
66-
});
62+
}, 'image/jpeg');
63+
});
6764

68-
reader.readAsDataURL(file);
65+
image.src = reader.result;
66+
});
67+
68+
reader.readAsDataURL(file);
6969
}
7070

7171
window.jQuery(document).ready(($) => {
72+
const { __ } = wp.i18n;
7273
/**
7374
* Profile Photo and Cover Photo editor
7475
*
7576
* @since v.1.7.5
7677
*/
77-
var PhotoEditor = function(photo_editor) {
78+
var PhotoEditor = function (photo_editor) {
7879
this.dialogue_box = photo_editor.find('#tutor_photo_dialogue_box');
7980

80-
this.open_dialogue_box = function(name) {
81+
this.open_dialogue_box = function (name) {
8182
this.dialogue_box.attr('name', name);
8283
this.dialogue_box.trigger('click');
8384
};
8485

85-
this.upload_selected_image = function(name, file) {
86-
86+
this.upload_selected_image = function (name, file) {
87+
8788
var nonce = tutor_get_nonce_data(true);
8889

8990
var context = this;
@@ -95,7 +96,7 @@ window.jQuery(document).ready(($) => {
9596
form_data.append('photo_type', name);
9697
form_data.append('photo_file', file, file.name);
9798
form_data.append(nonce.key, nonce.value);
98-
99+
99100
// Upload the image to server
100101
const _this = this;
101102
$.ajax({
@@ -105,36 +106,46 @@ window.jQuery(document).ready(($) => {
105106
processData: false,
106107
contentType: false,
107108
error: context.error_alert,
108-
success: function() {
109+
success: function () {
109110
let photoType = _this.title_capitalize(name.replace('_', ' '));
110-
tutor_toast('Success', photoType + ' Changed successfully!', 'success');
111+
let title = __('Success', 'tutor');
112+
let msg = photoType + ' Changed Successfully!';
113+
114+
if ('Profile Photo' === photoType) {
115+
msg = __('Profile Photo Changed Successfully!', 'tutor');
116+
}
117+
if ('Cover Photo' === photoType) {
118+
msg = __('Cover Photo Changed Successfully!', 'tutor');
119+
}
120+
121+
tutor_toast(title, msg, 'success');
111122
},
112-
complete: function() {
123+
complete: function () {
113124
context.toggle_loader(name, false);
114125
},
115126
});
116127
};
117128

118-
this.title_capitalize = function(string) {
129+
this.title_capitalize = function (string) {
119130
const arr = string.split(' ');
120131
for (var i = 0; i < arr.length; i++) {
121132
arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].slice(1);
122133
}
123134
return arr.join(' ');
124135
};
125-
this.accept_upload_image = function(context, e) {
136+
this.accept_upload_image = function (context, e) {
126137
var file = e.currentTarget.files[0] || null;
127138
context.update_preview(e.currentTarget.name, file);
128139

129140
// Resize
130-
getResizedFromUploaded(file, {width: 1200}, blob=>{
141+
getResizedFromUploaded(file, { width: 1200 }, blob => {
131142
context.upload_selected_image(e.currentTarget.name, blob);
132143
});
133-
144+
134145
$(e.currentTarget).val('');
135146
};
136147

137-
this.delete_image = function(name) {
148+
this.delete_image = function (name) {
138149
var context = this;
139150
context.toggle_loader(name, true);
140151

@@ -143,13 +154,13 @@ window.jQuery(document).ready(($) => {
143154
data: { action: 'tutor_user_photo_remove', photo_type: name },
144155
type: 'POST',
145156
error: context.error_alert,
146-
complete: function() {
157+
complete: function () {
147158
context.toggle_loader(name, false);
148159
},
149160
});
150161
};
151162

152-
this.update_preview = function(name, file) {
163+
this.update_preview = function (name, file) {
153164
var renderer = photo_editor.find(name == 'cover_photo' ? '#tutor_cover_area' : '#tutor_profile_area');
154165

155166
if (!file) {
@@ -159,52 +170,52 @@ window.jQuery(document).ready(($) => {
159170
}
160171

161172
var reader = new FileReader();
162-
163-
reader.onload = function(e) {
173+
174+
reader.onload = function (e) {
164175
renderer.css('background-image', 'url(' + e.target.result + ')');
165176
};
166177

167178
reader.readAsDataURL(file);
168179
};
169180

170-
this.toggle_profile_pic_action = function(show) {
181+
this.toggle_profile_pic_action = function (show) {
171182
var method = show === undefined ? 'toggleClass' : show ? 'addClass' : 'removeClass';
172183
photo_editor[method]('pop-up-opened');
173184
};
174185

175-
this.error_alert = function() {
186+
this.error_alert = function () {
176187
tutor_toast('Error', 'Maximum file size exceeded!', 'error');
177188
// alert('Something Went Wrong.');
178189
};
179190

180-
this.toggle_loader = function(name, show) {
191+
this.toggle_loader = function (name, show) {
181192
photo_editor.find('#tutor_photo_meta_area .loader-area').css('display', show ? 'block' : 'none');
182193
};
183194

184-
this.initialize = function() {
195+
this.initialize = function () {
185196
var context = this;
186197

187-
this.dialogue_box.change(function(e) {
198+
this.dialogue_box.change(function (e) {
188199
context.accept_upload_image(context, e);
189200
});
190201

191-
photo_editor.find('#tutor_profile_area .tutor_overlay, #tutor_pp_option>div:last-child').click(function() {
202+
photo_editor.find('#tutor_profile_area .tutor_overlay, #tutor_pp_option>div:last-child').click(function () {
192203
context.toggle_profile_pic_action();
193204
});
194205

195206
// Upload new
196-
photo_editor.find('.tutor_cover_uploader').click(function() {
207+
photo_editor.find('.tutor_cover_uploader').click(function () {
197208
context.open_dialogue_box('cover_photo');
198209
});
199-
photo_editor.find('.tutor_pp_uploader').click(function() {
210+
photo_editor.find('.tutor_pp_uploader').click(function () {
200211
context.open_dialogue_box('profile_photo');
201212
});
202213

203214
// Delete existing
204-
photo_editor.find('.tutor_cover_deleter').click(function() {
215+
photo_editor.find('.tutor_cover_deleter').click(function () {
205216
context.update_preview('cover_photo', null);
206217
});
207-
photo_editor.find('.tutor_pp_deleter').click(function() {
218+
photo_editor.find('.tutor_pp_deleter').click(function () {
208219
context.update_preview('profile_photo', null);
209220
});
210221
};
@@ -214,7 +225,7 @@ window.jQuery(document).ready(($) => {
214225
photo_editor.length > 0 ? new PhotoEditor(photo_editor).initialize() : 0;
215226

216227
// Save profile settings with ajax
217-
$('.tutor-profile-settings-save').click(function(e) {
228+
$('.tutor-profile-settings-save').click(function (e) {
218229
e.preventDefault();
219230

220231
var btn = $(this);

views/quiz/attempt-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
esc_html_e( get_the_title( $attempt->quiz_id ) );
100100
?>
101101
<div class="tooltip-wrap tooltip-icon-custom" >
102-
<i class="tutor-icon-circle-info-o tutor-color-muted"></i>
103-
<span class="tooltip-txt tooltip-top">
102+
<i class="tutor-icon-circle-info-o tutor-color-muted tutor-ml-4 tutor-fs-7"></i>
103+
<span class="tooltip-txt tooltip-right">
104104
<?php esc_html_e( get_the_title( $attempt->course_id ) ) ?>
105105
</span>
106106
</div>

0 commit comments

Comments
 (0)