Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.23 KB | None | 0 0
  1. /**
  2. * @author Resalat Haque
  3. * @link http://www.w3bees.com
  4. */
  5.  
  6.  
  7. $(document).ready(function() {
  8.     /* variables */
  9.     var preview = $('img');
  10.     var status = $('.status');
  11.     var percent = $('.percent');
  12.     var bar = $('.bar');
  13.    
  14.  
  15.     /* only for image preview */
  16.     $("#image").change(function(){
  17.             //preview.fadeOut();
  18.  
  19.         /* html FileRender Api */
  20.         var oFReader = new FileReader();
  21.         oFReader.readAsDataURL(document.getElementById("image").files[0]);
  22.  
  23.         oFReader.onload = function (oFREvent) {
  24.             //preview.attr('src', oFREvent.target.result).fadeIn();
  25.         };
  26.     });
  27.  
  28.     /* submit form with ajax request */
  29.     $('form').ajaxForm({
  30.  
  31.         /* set data type json */
  32.         dataType:  'json',
  33.  
  34.         /* reset before submitting */
  35.         beforeSend: function() {
  36.             status.fadeOut();
  37.             bar.width('0%');
  38.             percent.html('0%');
  39.         },
  40.  
  41.         /* progress bar call back*/
  42.         uploadProgress: function(event, position, total, percentComplete) {
  43.             var pVel = percentComplete + '%';
  44.             bar.width(pVel);
  45.             percent.html(pVel);
  46.         },
  47.  
  48.         /* complete call back */
  49.         complete: function(data) {
  50.        
  51.             bar.width('100%');
  52.             percent.html('100%');
  53.  
  54.             //Response Text mit übergebenen Werten holen
  55.             var meldung = data.responseText,
  56.                 oJSONResponse = $.parseJSON(meldung),
  57.                 statusmeldung = oJSONResponse.status,
  58.                 isValid = oJSONResponse.valid;
  59.                 pfad = oJSONResponse.optimized_path;
  60.            
  61.             if($('#profiuploadvalue').html() == "false")
  62.             {
  63.                 //Die Statusmeldung unter den Upload posten
  64.                 status.html(statusmeldung).fadeIn();
  65.                 if(isValid) {
  66.                     var imagewidth = oJSONResponse.imagewidth,
  67.                         imageheight = oJSONResponse.imageheight,
  68.                         //pfad = oJSONResponse.path;
  69.                         pfad = oJSONResponse.optimized_path;
  70.  
  71.                     $("#bildhoehe").html(imageheight);
  72.                     $("#bildbreite").html(imagewidth);
  73.                     $("#bildpfad").html(pfad);
  74.  
  75.                
  76.                     //DPI des hochgeladenen Bildes über ein Script bestimmen
  77.                     var oData = {
  78.                         pfad: "../" + pfad
  79.                     };
  80.  
  81.                     $.post('js/getdpi.php', oData,
  82.                     function(returnedData) {
  83.                         $('#getdpi').html(returnedData);
  84.  
  85.                     });
  86.  
  87.  
  88.  
  89.                     var constFaktor = 500;
  90.                     //Faktor berechnen
  91.                     var faktorWidth = imagewidth / constFaktor;
  92.                     var faktorHeight = imageheight / constFaktor;
  93.                     var imagewidthNew = 0;
  94.                     var imageheightNew = 0;
  95.  
  96.  
  97.                     //Größere Seite rausfinden
  98.                     if(imageheight < imagewidth)
  99.                     {
  100.                         imagewidthNew =  imagewidth / faktorWidth;
  101.                         imageheightNew = imageheight / faktorWidth;
  102.                     }
  103.                     else
  104.                     {
  105.                         imagewidthNew =  imagewidth / faktorHeight;
  106.                         imageheightNew = imageheight / faktorHeight;
  107.                     }
  108.  
  109.  
  110.                     $('#faktorWidth').html(faktorWidth);
  111.                     $('#faktorHeigth').html(faktorHeight);
  112.  
  113.  
  114.                     $('.standardview').fadeOut();
  115.                     $('#crop_container2').fadeIn();
  116.  
  117.  
  118.  
  119.                     //Cropcontainer der Größe anpassen
  120.                     cropzoom = $('#crop_container2').cropzoom({
  121.                         bgColor: '#dadada',
  122.                         enableRotation:false,
  123.                         enableZoom:false,
  124.                         rotationSteps:4,
  125.                         selector:{
  126.                             centered:true,
  127.                             aspectRatio: true,
  128.                             startWithOverlay:true,
  129.                             borderColor:'#aed73f',
  130.                             borderColorHover:'#000000',
  131.                             hideOverlayOnDragAndResize: true,
  132.                             showPositionsOnDrag: false,
  133.                             showDimetionsOnDrag: false,
  134.                             w: 100,
  135.                             h: 30,
  136.                             onSelectorResizeStop: resizeStopped
  137.                         },
  138.                         image:{
  139.                             source: pfad,
  140.                             width: imagewidth,
  141.                             height: imageheight,
  142.                             startZoom:0,
  143.                             useStartZoomAsMinZoom:true,
  144.                             snapToContainer:false
  145.                         }
  146.                     });
  147.  
  148.                     //Größe anpassen
  149.                     $('#crop_container2').height(imageheightNew);
  150.                     $('#crop_container2').width(imagewidthNew);
  151.  
  152.  
  153.                     //$('#weiterbutton').fadeIn();
  154.                     $("#weiterbutton").prop('disabled', false);
  155.                     $("#abbrechenbutton").prop('disabled', true);
  156.  
  157.                     $("#uploadbutton").prop('disabled', false);
  158.  
  159.  
  160.  
  161.                     //Buttons wieder enablen
  162.                     $("#buttonmengeminus").prop('disabled', false);
  163.                     $("#buttonmengeplus").prop('disabled', false);
  164.                     $("#textbox_menge").prop('disabled', false);
  165.  
  166.  
  167.                     $("#eigenesformat").prop('disabled', false);
  168.                     $(".formatselectQuer").prop('disabled', false);
  169.                     $(".formatselectHoch").prop('disabled', false);
  170.                     $(".formatselectQuadrat").prop('disabled', false);
  171.  
  172.                     $("#eigenesformatwidth").prop('disabled', false);
  173.                     $("#eigenesformatheight").prop('disabled', false);
  174.  
  175.                     $('#indenwarenkorbbutton_profi').fadeOut();
  176.  
  177.  
  178.                     //Imagequalitywrapper einfaden
  179.                     $("#imagequalityWrapper").fadeIn();
  180.                    
  181.                    
  182.                     $('#rotate_button_left').fadeIn();
  183.                     $('#rotate_button_right').fadeIn();
  184.                     $('#change_image').fadeIn();
  185.                     $('#zurueckbutton').fadeIn();
  186.                    
  187.                    
  188.                                        
  189.  
  190.                     //Hinweis ausblenden
  191.                     //$("#hinweisFormat").fadeOut();
  192.  
  193.                     $('#crop_container2').css('border', '1px solid #cccccc');
  194.                    
  195.                     //Automatisch weitergehen nach Upload
  196.                     $('#weiterbutton').trigger("click");
  197.                    
  198.                    
  199.                 }
  200.             } // end else check profiupload
  201.             else //Hier wird der Profiupload gestartet
  202.             {
  203.            
  204.               //Filter ausblenden
  205.               $('.filter').fadeOut();
  206.                  
  207.               $("#restorebutton").prop('disabled', true);
  208.              
  209.            
  210.               //Abbrechen Button ausgrauen
  211.               $("#abbrechenbutton2").prop('disabled', true);
  212.              
  213.               //Weiterbutton2 enablen
  214.               $("#weiterbutton2").prop('disabled', false);
  215.              
  216.               //Standardview ausblenden
  217.               $('.standardview').fadeOut();
  218.               $('.profiview').fadeIn();
  219.                          
  220.              
  221.               //Warenkorbbutton einfaden
  222.               $('#indenwarenkorbbutton_profi').fadeIn();
  223.              
  224.               //Warenkorbbutton disablen
  225.               $("#indenwarenkorbbutton_profi").prop('disabled', true);
  226.              
  227.               $('#change_image_profi').fadeIn();
  228.               $('#zurueckbutton').fadeIn();
  229.  
  230.               $("#bildpfad").html(pfad);
  231.  
  232.              
  233.               //Weiter button ausfaden
  234.               $('#cropbutton').fadeOut();
  235.               //Qualität des Bildes ausblenden
  236.              $('#imagequalityWrapper').fadeOut();
  237.              
  238.              
  239.              //Automatisch weitergehen nach Upload
  240.              $('#weiterbutton2').trigger("click");
  241.              
  242.              
  243.           }
  244.            //} //end else megapixel check
  245.    
  246.         }
  247.  
  248.     });
  249. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement