Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 17552ab

Browse files
New function and code added for working with demo2 of upload plugin.
1 parent bc0b680 commit 17552ab

File tree

1 file changed

+106
-2
lines changed

1 file changed

+106
-2
lines changed

‎js/uploader.js‎

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
$(function(){
22
$('body').on("change", "#my-profile-file-selector", function(){
33
checkProfileSize({
4-
size: 200,
5-
width: 1280,
4+
// size: 200,
5+
// width: 1280,
66
// height: null
77
});
88
})
@@ -71,6 +71,78 @@ function checkProfileSize(arg){
7171
}
7272
}
7373

74+
$(function(){
75+
$('body').on("change", "#my-profile-file-selector-1", function(){
76+
checkProfileSize1({
77+
size: 200
78+
});
79+
})
80+
$('#remove-profile-btn-1').on('click', function(event) {
81+
event.preventDefault();
82+
// make image view empty
83+
$('#upload-profile-image-1').attr('src', '');
84+
// make file name empty
85+
$('#upload-profile-file-info-1').html('');
86+
// make input file value empty
87+
$('input#my-profile-file-selector-1[type=file]').val('')
88+
// remove hide button
89+
$('#remove-profile-btn-1').hide();
90+
// show upload button again
91+
$('label.profile-1').show();
92+
});
93+
});
94+
function checkProfileSize1(arg){
95+
$('#upload-profile-image-1').attr('src', '');
96+
$('#upload-profile-file-info-1').html('');
97+
$('#upload-profile-error-1').html('');
98+
var fileInput = $('form').find("input#my-profile-file-selector-1[type=file]")[0],
99+
file = fileInput.files && fileInput.files[0];
100+
var sizeKB = file.size / 1024;
101+
var tmppath = URL.createObjectURL(fileInput.files[0]);
102+
var maxSize = arg.size || sizeKB;
103+
var imgHeight, imgWidth;
104+
console.log("maxSize "+maxSize);
105+
if( file ) {
106+
var img = new Image();
107+
img.src = window.URL.createObjectURL( file );
108+
img.onload = function() {
109+
var width = img.naturalWidth, height = img.naturalHeight;
110+
window.URL.revokeObjectURL( img.src );
111+
imgWidth = arg.width || width;
112+
console.log("imgWidth "+imgWidth);
113+
imgHeight = arg.height || height;
114+
if( sizeKB <= maxSize) {
115+
if( width == imgWidth && height == imgHeight){
116+
var fileName = $('input#my-profile-file-selector-1[type=file]').val();
117+
fileName = fileName.substr(fileName.lastIndexOf("\\")+1);
118+
$('#upload-profile-image-1').attr('src', tmppath);
119+
$('#upload-profile-file-info-1').html(fileName);
120+
$('label.profile-1').hide();
121+
$('#remove-profile-btn-1').show();
122+
}
123+
else{
124+
imgWidth = arg.width || "any";
125+
imgHeight = arg.height || "any";
126+
$('#upload-profile-error-1')
127+
.html('Uploaded Picture Width should be '+
128+
imgWidth+' and Height should be '+imgHeight);
129+
var fileName = $('input#my-profile-file-selector-1[type=file]').val();
130+
console.log(fileName);
131+
}
132+
}
133+
else {
134+
$('#upload-profile-error-1').html('Uploaded Profile picture size should be less than '+maxSize+'KB');
135+
var fileName = $('input#my-profile-file-selector-1[type=file]').val();
136+
console.log(fileName);
137+
}
138+
};
139+
}
140+
else { //No file was input or browser doesn't support client side reading
141+
console.log('No file selected');
142+
}
143+
}
144+
145+
74146
// Copy to Clipboard
75147
function copyToClipboard(element) {
76148
var $temp = $("<input>");
@@ -103,6 +175,20 @@ $(function(){
103175
trigger: 'click',
104176
placement: 'top'
105177
});
178+
179+
$('.html-copy-1').tooltip({
180+
trigger: 'click',
181+
placement: 'top'
182+
});
183+
$('.css-copy-1').tooltip({
184+
trigger: 'click',
185+
placement: 'top'
186+
});
187+
$('.js-copy-1').tooltip({
188+
trigger: 'click',
189+
placement: 'top'
190+
});
191+
106192
$('.html-copy').on('click',function(){
107193
copyToClipboard('#html-code');
108194
setTooltip($(this),'Copied!');
@@ -118,4 +204,22 @@ $(function(){
118204
setTooltip($(this),'Copied!');
119205
hideTooltip($(this));
120206
});
207+
208+
$('.html-copy-1').on('click',function(){
209+
copyToClipboard('#html-code-1');
210+
setTooltip($(this),'Copied!');
211+
hideTooltip($(this));
212+
});
213+
$('.css-copy-1').on('click',function(){
214+
copyToClipboard('#css-code-1');
215+
setTooltip($(this),'Copied!');
216+
hideTooltip($(this));
217+
});
218+
$('.js-copy-1').on('click',function(){
219+
copyToClipboard('#js-code-1');
220+
setTooltip($(this),'Copied!');
221+
hideTooltip($(this));
222+
});
223+
224+
121225
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /