1jQuery( function ( $ ) { 2 'use strict'; 3 4 var $body = $( 'body' ), 5 clickEvent = 'ontouchstart' in window ? 'touchstart' : 'click', 6 $popupLogin = $( '#edupro-popup-login' ), 7 $loginContainer = $popupLogin.find( '.edupro-login-container' ), 8 $popupRegister = $( '#edupro-popup-register' ), 9 $registerContainer = $popupRegister.find( '.edupro-login-container' ); 10 11 /** 12 * Action of login Popup 13 */ 14 function loginPopup() { 15 var login = '#edupro_login', 16 pass = '#edupro_pass'; 17 18 $( login ).attr( 'placeholder', EduPro.login ); 19 $( pass ).attr( 'placeholder', EduPro.password ); 20 21 // Replace img with icon 22 $( '.mo-openid-app-icons a img' ).each( function () { 23 var $this = $( this ), 24 alt = $this.attr( 'alt' ), 25 icon; 26 27 if ( 'Facebook' === alt ) { 28 icon = 'facebook'; 29 } 30 else if ( 'Google' === alt ) { 31 icon = 'google-plus'; 32 } 33 else if ( 'Twitter' === alt ) { 34 icon = 'twitter'; 35 } 36 else if ( 'LinkedIn' === alt ) { 37 icon = 'linkedin'; 38 } 39 else if ( 'Instagram' === alt ) { 40 icon = 'instagram'; 41 } 42 else if ( 'Amazon' === alt ) { 43 icon = 'amazon'; 44 } 45 else if ( 'Salesforce' === alt ) { 46 icon = 'cloud'; 47 } 48 else if ( 'Windowslive' === alt ) { 49 icon = 'windows'; 50 } 51 else if ( 'Vkontakte' === alt ) { 52 icon = 'vk'; 53 } 54 55 $this.after( '<i class="fa fa-' + icon + '"></i>' ).remove(); 56 } ); 57 58 $body.on( 'click', '#edupro-popup-login .close-popup', function ( e ) { 59 e.preventDefault(); 60 $body.removeClass( 'edupro-popup-active' ); 61 $popupLogin.removeClass( 'active' ); 62 } ); 63 64 $body.on( 'click', '.topbar .login-popup', function ( e ) { 65 if ( $( window ).width() > 0 ) { 66 e.preventDefault(); 67 $( 'body' ).addClass( 'edupro-popup-active' ); 68 $popupLogin.addClass( 'active' ); 69 70 if ( $loginContainer.length ) { 71 72 var el_H = $loginContainer.outerHeight(), 73 win_H = $( window ).height(); 74 75 if ( win_H > el_H ) { 76 $loginContainer.css( 'top', parseInt( ( 77 win_H - el_H 78 ) / 2 ) ); 79 } 80 } 81 } 82 } ); 83 84 $body.on( 'click', '#edupro-popup-login .register a', function ( e ) { 85 e.preventDefault(); 86 $popupRegister.addClass( 'active' ); 87 $popupLogin.removeClass( 'active' ); 88 89 if ( $registerContainer.length ) { 90 91 var el_H = $registerContainer.outerHeight(), 92 win_H = $( window ).height(); 93 94 if ( win_H > el_H ) { 95 $registerContainer.css( 'top', parseInt( ( 96 win_H - el_H 97 ) / 2 ) ); 98 } 99 } 100 101 return false; 102 } ); 103 104 $body.on( 'click', '#edupro-popup-login', function ( e ) { 105 if ( $( e.target ).attr( 'id' ) == 'edupro-popup-login' ) { 106 $body.removeClass( 'edupro-popup-active' ); 107 $popupLogin.removeClass( 'active' ); 108 } 109 } ); 110 111 $( '#edupro_login,#edupro_pass' ).on( 'focus', function () { 112 $( this ).removeClass( 'invalid' ); 113 } ); 114 115 $( '#edupro-popup-login #loginform' ).submit( function ( e ) { 116 117 var $this = $( this ), 118 inputUsername = $this.find( '#edupro_login' ), 119 inputPass = $this.find( '#edupro_pass' ), 120 valUsername = inputUsername.val(), 121 valPass = inputPass.val(); 122 123 if ( inputUsername.length > 0 && valUsername == '' ) { 124 inputUsername.addClass( 'invalid' ); 125 event.preventDefault(); 126 } 127 128 if ( inputPass.length > 0 && valPass == '' ) { 129 inputPass.addClass( 'invalid' ); 130 event.preventDefault(); 131 } 132 133 if ( valUsername == '' || valPass == '' ) { 134 return false; 135 } 136 137 $loginContainer.append( '<div class="edupro-loading-container"><div class="edupro-loading"></div></div>' ); 138 $loginContainer.find( '.message' ).slideDown().remove(); 139 140 var data = { 141 action: 'edupro_login_ajax', 142 username: valUsername, 143 password: valPass, 144 remember: $loginContainer.find( '#rememberme' ).val() 145 }; 146 147 $.post( EduPro.ajaxUrl, data, function ( response ) { 148 149 $loginContainer.find( '.edupro-login' ).append( response.data ); 150 $loginContainer.find( '.edupro-loading-container' ).remove(); 151 152 if ( ! response.success ) { 153 return; 154 } 155 156 window.location = window.location; 157 } ); 158 159 event.preventDefault(); 160 return false;
161 } ); 162 } 163 164 /** 165 * Register popup 166 * 167 * @constructor 168 */ 169 function registerPopup() { 170 171 if ( $registerContainer.length ) { 172 173 var el_H = $registerContainer.outerHeight(), 174 win_H = $( window ).height(); 175 176 if ( win_H > el_H ) { 177 $registerContainer.css( 'top', ( win_H - el_H ) / 2 ); 178 } 179 } 180 181 $body.on( 'click', '#edupro-popup-register .close-popup', function ( e ) { 182 e.preventDefault(); 183 $body.removeClass( 'edupro-popup-active' ); 184 $popupRegister.removeClass( 'active' ); 185 } ); 186 187 $body.on( 'click', '.topbar .register-popup', function ( e ) { 188 if ( $( window ).width() > 0 ) { 189 e.preventDefault(); 190 $( 'body' ).addClass( 'edupro-popup-active' ); 191 $popupRegister.addClass( 'active' ); 192 } 193 } ); 194 195 $body.on( 'click', '#registration .login a', function ( e ) { 196 e.preventDefault(); 197 $popupRegister.removeClass( 'active' ); 198 $popupLogin.addClass( 'active' ); 199 200 if ( $loginContainer.length ) { 201 202 var el_H = $loginContainer.outerHeight(), 203 win_H = $( window ).height(); 204 205 if ( win_H > el_H ) { 206 $loginContainer.css( 'top', parseInt( ( win_H - el_H ) / 2 ) ); 207 } 208 } 209 210 return false; 211 } ); 212 213 $body.on( 'click', '#edupro-popup-register', function ( e ) { 214 if ( $( e.target ).attr( 'id' ) == 'edupro-popup-register' ) { 215 $body.removeClass( 'edupro-popup-active' ); 216 $popupRegister.removeClass( 'active' ); 217 } 218 } ); 219 220 221 var $allInput = $( '.edupro_user_name,.edupro_user_name,.edupro_user_email,.edupro_user_pass,.edupro_user_pass_confirm' ); 222 223 $allInput.on( 'focus', function () { 224 $( this ).removeClass( 'invalid' ); 225 } ); 226 227 228 $( '#edupro-popup-register #registration, .edupro-register #registration' ).submit( function ( e ) { 229 230 var $this = $( this ), 231 $registerContainer = $( '#edupro-popup-register .edupro-login-container, .edupro-register .edupro-login-container' ), 232 inputUsername = $this.find( '.edupro_user_name' ), 233 inputEmail = $this.find( '.edupro_user_email' ), 234 $inputPass = $this.find( '.edupro_user_pass' ), 235 $inputPassConfirm = $this.find( '.edupro_user_pass_confirm' ), 236 valUsername = inputUsername.val(), 237 valEmail = inputEmail.val(), 238 valPass = $inputPass.val(), 239 valPassConfirm = $inputPassConfirm.val(); 240 241 $allInput.removeClass( 'invalid' ); 242 243 if ( inputUsername.length > 0 && valUsername == '' ) { 244 inputUsername.addClass( 'invalid' ); 245 event.preventDefault(); 246 } 247 248 249 250 if ( inputEmail.length > 0 && valEmail == '' ) { 251 inputEmail.addClass( 'invalid' ); 252 event.preventDefault(); 253 } 254 255 256 if ( $inputPass.length > 0 && valPass == '' ) { 257 $inputPass.addClass( 'invalid' ); 258 event.preventDefault(); 259 } 260 261 if ( $inputPassConfirm.length > 0 && valPassConfirm == '' ) { 262 $inputPassConfirm.addClass( 'invalid' ); 263 event.preventDefault(); 264 } 265 if ( valUsername == '' || valEmail == '' || valPass == '' || valPassConfirm == '' ) { 266 return false; 267 } 268 269 // Password does not match the confirm password 270 if ( valPassConfirm !== valPass ) { 271 $inputPass.addClass( 'invalid' ); 272 $inputPassConfirm.addClass( 'invalid' ); 273 $registerContainer.find( '.edupro-login' ).append( EduPro.errorPass ); 274 event.preventDefault(); 275 276 return false; 277 } 278 $registerContainer.append( '<div class="edupro-loading-container"><div class="edupro-loading"></div></div>' ); 279 $registerContainer.find( '.message' ).slideDown().remove(); 280 281 var data = { 282 action: 'edupro_register_ajax', 283 fistName: $this.find( '.edupro_first_name' ).val(), 284 lastName: $this.find( '.edupro_last_name' ).val(), 285 username: valUsername, 286 password: valPass, 287 confirmPass: valPassConfirm, 288 email: valEmail 289 }; 290 291 $.post( EduPro.ajaxUrl, data, function ( response ) { 292 293 $registerContainer.find( '.edupro-login' ).append( response.data ); 294 $registerContainer.find( '.edupro-loading-container' ).remove(); 295 296 if ( ! response.success ) { 297 return; 298 } 299 300 window.location = window.location; 301 302 } ); 303 304 event.preventDefault(); 305 return false; 306 } ); 307 308 } 309 310 /** 311 * Show search popup 312 */ 313 function searchPopup() { 314 $( '.header__search .search-toggle' ).on( 'click', function ( e ) { 315 e.stopPropagation(); 316 var parent = jQuery( this ).parent(); 317 $body.addClass( 'edupro-search-active' ); 318 setTimeout( function () { 319 parent.find( '.search-field' ).focus(); 320 }, 500 ); 321 322 return false;
323 324 } ); 325 jQuery( '.search-popup-bg' ).on( 'click', function () { 326 var parent = jQuery( this ).parent(); 327 parent.find( '.search-field' ).val( '' ); 328 $body.removeClass( 'edupro-search-active' ); 329 330 return false; 331 } ); 332 } 333 334 loginPopup(); 335 registerPopup(); 336 searchPopup(); 337})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.