1
1
$ ( function ( ) {
2
2
$ ( 'body' ) . on ( "change" , "#my-profile-file-selector" , function ( ) {
3
3
checkProfileSize ( {
4
- size : 200 ,
5
- width : 1280 ,
4
+ // size: 200,
5
+ // width: 1280,
6
6
// height: null
7
7
} ) ;
8
8
} )
@@ -71,6 +71,78 @@ function checkProfileSize(arg){
71
71
}
72
72
}
73
73
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
+
74
146
// Copy to Clipboard
75
147
function copyToClipboard ( element ) {
76
148
var $temp = $ ( "<input>" ) ;
@@ -103,6 +175,20 @@ $(function(){
103
175
trigger : 'click' ,
104
176
placement : 'top'
105
177
} ) ;
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
+
106
192
$ ( '.html-copy' ) . on ( 'click' , function ( ) {
107
193
copyToClipboard ( '#html-code' ) ;
108
194
setTooltip ( $ ( this ) , 'Copied!' ) ;
@@ -118,4 +204,22 @@ $(function(){
118
204
setTooltip ( $ ( this ) , 'Copied!' ) ;
119
205
hideTooltip ( $ ( this ) ) ;
120
206
} ) ;
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
+
121
225
} ) ;
0 commit comments