File "profile-settings.min.js"

Path: /StudyIB/js/user/profile-settingsminjs
File size: 5.29 KB
MIME-type: text/plain
Charset: utf-8

 
Open Back
function saveUserpic(){var url="/pages/user/userpic-management.php",data={action:"save-userpic",ticket:$("#ticket").val(),img:$("#crop-source").val(),x1:$("#crop-x1").val(),y1:$("#crop-y1").val(),w:$("#crop-w").val(),h:$("#crop-h").val()};$.post(url,data,(function(response){1==response.success?($("#modal-userpic").modal("hide"),$("img.userpic").attr("src",response.img)):(alert(response.msg),resetModalUserpic())}),"json")}function startCropper(imgURL,selectionCoords){null==selectionCoords&&(selectionCoords=[0,0,128,128]),!1===jcrop_api?$("#crop-target").Jcrop({minSize:[128,128],aspectRatio:1,bgFade:!0,bgOpacity:.2,onChange:updateCoords,onSelect:updateCoords},(function(){jcrop_api=this,this.setSelect(selectionCoords)})):jcrop_api.setImage($("#crop-target").attr("src"),(function(){jcrop_api=this;var bounds=this.getBounds();this.setSelect(selectionCoords)}))}function updateCoords(c){$("#crop-x1").val(c.x),$("#crop-y1").val(c.y),$("#crop-x2").val(c.x2),$("#crop-y2").val(c.y2),$("#crop-w").val(c.w),$("#crop-h").val(c.h)}function clearCoords(){$("#crop-coords input").val("")}function resetModalUserpic(){$("#upload-progress > label").text("Uploading..."),$("#upload-progress .progress-bar").css("width: 0"),$("#upload-progress").hide(),$("input#uploaded-file").val(""),$("#modal-userpic .stage-1").find(".reset").show(),$("#modal-userpic .stage-1").show(),$("#modal-userpic .stage-2").hide()}function resetProfileUserpic(){var url="/pages/user/userpic-management.php",data={action:"reset-userpic",ticket:$("#ticket").val()};$.post(url,data,(function(response){1==response.success&&window.location.reload()}),"json")}function loadUserpicStage2(imgURL){var maxW=540,url="/pages/user/userpic-management.php",data={action:"prepare-crop",ticket:$("#ticket").val(),img:imgURL,maxW:540};$.post(url,data,(function(response){1==response.success?($("#crop-preview-pane img.crop-preview").attr("src",response.src),$.when($("#crop-target").attr("src",response.src),$("#crop-source").val(response.src)).then(startCropper(response.src,response.selection)),$("#modal-userpic .stage-1").hide(),$("#modal-userpic .stage-2").show()):(alert(response.msg),resetModalUserpic())}),"json")}$(document).ready((function(){$("#show-modal-userpic").click((function(){resetModalUserpic()})),$("#btn-image-uploader").click((function(){$("input#fileupload").trigger("click"),$(".stage-1").find(".reset").hide(),$("#upload-progress").show()})),$("#crop-save").click((function(){saveUserpic()})),$("#reset-userpic").on("click",(function(){resetProfileUserpic()})),$("#change-email").on("click",(function(e){e.preventDefault();var button=$(this),email=$("#profile-email").val(),emailInputs=$("#profile-email, #profile-reemail, #profile-confirm-reemail");"change"==button.data("action")?(button.data("action","cancel"),button.attr("data-action","cancel"),button.text("Cancel"),emailInputs.closest(".form-group").show("fast"),$("#profile-reemail, #profile-confirm-reemail").attr("disabled",!1),$("#profile-reemail, #profile-confirm-reemail").val(""),$("#alert-school-email").closest(".form-group").show(),$('label[for="profile-email"]').text("Old email address")):(button.data("action","change"),button.attr("data-action","change"),button.html('<i class="fa fa-fw fa-pencil"></i> Change email address'),$("#profile-email").val(email),$("#profile-reemail, #profile-confirm-reemail").val(""),$("#profile-reemail, #profile-confirm-reemail").attr("disabled",!0),$("#profile-reemail, #profile-confirm-reemail").closest(".form-group").hide("fast"),$("#alert-school-email").closest(".form-group").hide(),$('label[for="profile-email"]').text("Email address"))})),$("#change-password").on("click",(function(e){e.preventDefault();var button=$(this),pwInputs=$("#profile-password, #profile-new-password, #profile-confirm-new-password");pwInputs.next("i.toggle-password").removeClass("fa-eye-slash").addClass("fa-eye"),"change"==button.data("action")?(button.data("action","cancel"),button.attr("data-action","cancel"),button.text("Cancel"),pwInputs.next("i.toggle-password").show(),pwInputs.attr("disabled",!1),pwInputs.val(""),$('label[for="profile-password"]').text("Old password"),$("#profile-new-password, #profile-confirm-new-password").closest(".form-group").show("fast")):(button.data("action","change"),button.attr("data-action","change"),button.html('<i class="fa fa-fw fa-pencil"></i> Change password'),pwInputs.next("i.toggle-password").hide(),pwInputs.attr("disabled",!0),pwInputs.val(""),$('label[for="profile-password"]').text("Password"),$("#profile-new-password, #profile-confirm-new-password").closest(".form-group").hide("fast"))})),$("#profile-exams-date-calendar").on("changeDate",(function(e){e.preventDefault(),checkDatepicker($(this))}))})),jcrop_api=!1,$((function(){"use strict";var uploadURL="/js/jq-fileupload/server/?disable-thumbs=1";$("#fileupload").fileupload({url:uploadURL,dataType:"json",maxChunkSize:15e6,done:function(e,data){$.each(data.result.files,(function(index,file){null==file.error?loadUserpicStage2(file.url):alert(file.error)})),$("#upload-progress label").text("Uploading... DONE!")},progressall:function(e,data){var progress=parseInt(data.loaded/data.total*100,10);$("#upload-progress .progress-bar").css("width",progress+"%")},processfail:function(e,data){alert("Upload failed! Please contact support")}}).prop("disabled",!$.support.fileInput).parent().addClass($.support.fileInput?void 0:"disabled")}));