Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Resalat Haque
- * @link http://www.w3bees.com
- */
- $(document).ready(function() {
- /* variables */
- var preview = $('img');
- var status = $('.status');
- var percent = $('.percent');
- var bar = $('.bar');
- /* only for image preview */
- $("#image").change(function(){
- //preview.fadeOut();
- /* html FileRender Api */
- var oFReader = new FileReader();
- oFReader.readAsDataURL(document.getElementById("image").files[0]);
- oFReader.onload = function (oFREvent) {
- //preview.attr('src', oFREvent.target.result).fadeIn();
- };
- });
- /* submit form with ajax request */
- $('form').ajaxForm({
- /* set data type json */
- dataType: 'json',
- /* reset before submitting */
- beforeSend: function() {
- status.fadeOut();
- bar.width('0%');
- percent.html('0%');
- },
- /* progress bar call back*/
- uploadProgress: function(event, position, total, percentComplete) {
- var pVel = percentComplete + '%';
- bar.width(pVel);
- percent.html(pVel);
- },
- /* complete call back */
- complete: function(data) {
- bar.width('100%');
- percent.html('100%');
- //Response Text mit übergebenen Werten holen
- var meldung = data.responseText,
- oJSONResponse = $.parseJSON(meldung),
- statusmeldung = oJSONResponse.status,
- isValid = oJSONResponse.valid;
- pfad = oJSONResponse.optimized_path;
- if($('#profiuploadvalue').html() == "false")
- {
- //Die Statusmeldung unter den Upload posten
- status.html(statusmeldung).fadeIn();
- if(isValid) {
- var imagewidth = oJSONResponse.imagewidth,
- imageheight = oJSONResponse.imageheight,
- //pfad = oJSONResponse.path;
- pfad = oJSONResponse.optimized_path;
- $("#bildhoehe").html(imageheight);
- $("#bildbreite").html(imagewidth);
- $("#bildpfad").html(pfad);
- //DPI des hochgeladenen Bildes über ein Script bestimmen
- var oData = {
- pfad: "../" + pfad
- };
- $.post('js/getdpi.php', oData,
- function(returnedData) {
- $('#getdpi').html(returnedData);
- });
- var constFaktor = 500;
- //Faktor berechnen
- var faktorWidth = imagewidth / constFaktor;
- var faktorHeight = imageheight / constFaktor;
- var imagewidthNew = 0;
- var imageheightNew = 0;
- //Größere Seite rausfinden
- if(imageheight < imagewidth)
- {
- imagewidthNew = imagewidth / faktorWidth;
- imageheightNew = imageheight / faktorWidth;
- }
- else
- {
- imagewidthNew = imagewidth / faktorHeight;
- imageheightNew = imageheight / faktorHeight;
- }
- $('#faktorWidth').html(faktorWidth);
- $('#faktorHeigth').html(faktorHeight);
- $('.standardview').fadeOut();
- $('#crop_container2').fadeIn();
- //Cropcontainer der Größe anpassen
- cropzoom = $('#crop_container2').cropzoom({
- bgColor: '#dadada',
- enableRotation:false,
- enableZoom:false,
- rotationSteps:4,
- selector:{
- centered:true,
- aspectRatio: true,
- startWithOverlay:true,
- borderColor:'#aed73f',
- borderColorHover:'#000000',
- hideOverlayOnDragAndResize: true,
- showPositionsOnDrag: false,
- showDimetionsOnDrag: false,
- w: 100,
- h: 30,
- onSelectorResizeStop: resizeStopped
- },
- image:{
- source: pfad,
- width: imagewidth,
- height: imageheight,
- startZoom:0,
- useStartZoomAsMinZoom:true,
- snapToContainer:false
- }
- });
- //Größe anpassen
- $('#crop_container2').height(imageheightNew);
- $('#crop_container2').width(imagewidthNew);
- //$('#weiterbutton').fadeIn();
- $("#weiterbutton").prop('disabled', false);
- $("#abbrechenbutton").prop('disabled', true);
- $("#uploadbutton").prop('disabled', false);
- //Buttons wieder enablen
- $("#buttonmengeminus").prop('disabled', false);
- $("#buttonmengeplus").prop('disabled', false);
- $("#textbox_menge").prop('disabled', false);
- $("#eigenesformat").prop('disabled', false);
- $(".formatselectQuer").prop('disabled', false);
- $(".formatselectHoch").prop('disabled', false);
- $(".formatselectQuadrat").prop('disabled', false);
- $("#eigenesformatwidth").prop('disabled', false);
- $("#eigenesformatheight").prop('disabled', false);
- $('#indenwarenkorbbutton_profi').fadeOut();
- //Imagequalitywrapper einfaden
- $("#imagequalityWrapper").fadeIn();
- $('#rotate_button_left').fadeIn();
- $('#rotate_button_right').fadeIn();
- $('#change_image').fadeIn();
- $('#zurueckbutton').fadeIn();
- //Hinweis ausblenden
- //$("#hinweisFormat").fadeOut();
- $('#crop_container2').css('border', '1px solid #cccccc');
- //Automatisch weitergehen nach Upload
- $('#weiterbutton').trigger("click");
- }
- } // end else check profiupload
- else //Hier wird der Profiupload gestartet
- {
- //Filter ausblenden
- $('.filter').fadeOut();
- $("#restorebutton").prop('disabled', true);
- //Abbrechen Button ausgrauen
- $("#abbrechenbutton2").prop('disabled', true);
- //Weiterbutton2 enablen
- $("#weiterbutton2").prop('disabled', false);
- //Standardview ausblenden
- $('.standardview').fadeOut();
- $('.profiview').fadeIn();
- //Warenkorbbutton einfaden
- $('#indenwarenkorbbutton_profi').fadeIn();
- //Warenkorbbutton disablen
- $("#indenwarenkorbbutton_profi").prop('disabled', true);
- $('#change_image_profi').fadeIn();
- $('#zurueckbutton').fadeIn();
- $("#bildpfad").html(pfad);
- //Weiter button ausfaden
- $('#cropbutton').fadeOut();
- //Qualität des Bildes ausblenden
- $('#imagequalityWrapper').fadeOut();
- //Automatisch weitergehen nach Upload
- $('#weiterbutton2').trigger("click");
- }
- //} //end else megapixel check
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement