@@ -49,51 +49,101 @@ define(function(require) {
4949 }
5050
5151 var fr = new FileReader ( ) ;
52- fr . readAsArrayBuffer ( this . files [ 0 ] ) ;
53- fr . onload = function ( ) {
54- var blob = _this . getStrippedBlob ( this . result ) ;
55- var urlCreator = window . URL || window . webkitURL ;
56- var imageUrl = urlCreator . createObjectURL ( blob ) ;
57- var image = new Image ( ) ;
58-
59- image . src = imageUrl ;
60- image . onload = function ( ) {
61- var image = this ;
62- var isValid = _this . validImage ( this ) ;
63- var $errorMsg = _this . $uploadButton . parent ( ) . siblings ( ".error" ) ;
64-
65- if ( isValid ) {
66- // Remove any previously added error message.
67- if ( $errorMsg . length ) {
68- $errorMsg . remove ( ) ;
52+
53+ if ( window . navigator . userAgent . match ( / i P a d / i) || window . navigator . userAgent . match ( / i P h o n e / i) ) {
54+ fr . readAsArrayBuffer ( this . files [ 0 ] ) ;
55+ fr . onload = function ( ) {
56+ var blob = _this . getStrippedBlob ( this . result ) ;
57+ var urlCreator = window . URL || window . webkitURL ;
58+ var imageUrl = urlCreator . createObjectURL ( blob ) ;
59+ var image = new Image ( ) ;
60+
61+ image . src = imageUrl ;
62+ image . onload = function ( ) {
63+ var image = this ;
64+ var isValid = _this . validImage ( this ) ;
65+ var $errorMsg = _this . $uploadButton . parent ( ) . siblings ( ".error" ) ;
66+
67+ if ( isValid ) {
68+ // Remove any previously added error message.
69+ if ( $errorMsg . length ) {
70+ $errorMsg . remove ( ) ;
71+ }
72+
73+ // Open the modal.
74+ _this . openModal ( ) ;
75+
76+ // Add the preview image to the modal
77+ _this . previewImage ( image , _this . $imagePreview ) ;
78+
79+ //Unbind before rebind so it doesnt fire twice.
80+ _this . $cropButton . off ( "click" ) ;
81+
82+ // When the user submits the modal form, send crop values to the form.
83+ _this . $cropButton . on ( 'click' , function ( event ) {
84+ event . preventDefault ( ) ;
85+
86+ // Validate the caption field and make sure we are good to proceed.
87+ _this . validateCaption ( _this . engageImageCrop , image ) ;
88+ } ) ;
89+ }
90+ // Show user an error if they upload an image that is too small.
91+ else {
92+ if ( ! $errorMsg . length ) {
93+ var $error = $ ( "<div class='messages error'>Please upload a larger photo. Min. size is 480px by 480px.</div>" ) ;
94+ $error . insertAfter ( _this . $uploadButton . parent ( ) ) ;
95+ }
6996 }
97+ } ;
98+ } ;
99+ }
100+ else {
101+ $ ( "reportback__submissions form-wrapper" ) . prepend ( "<p>" + Modernizr . exiforientation + "</p>" ) ;
102+ fr . readAsDataURL ( files [ 0 ] ) ;
103+
104+ fr . onloadend = function ( ) {
105+ var result = this . result ;
106+ var image = new Image ( ) ;
107+ image . src = result ;
70108
71- // Open the modal.
72- _this . openModal ( ) ;
109+ image . onload = function ( ) {
110+ var image = this ;
111+ var isValid = _this . validImage ( this ) ;
112+ var $errorMsg = _this . $uploadButton . parent ( ) . siblings ( ".error" ) ;
73113
74- // Add the preview image to the modal
75- _this . previewImage ( image , _this . $imagePreview ) ;
114+ if ( isValid ) {
115+ // Remove any previously added error message.
116+ if ( $errorMsg . length ) {
117+ $errorMsg . remove ( ) ;
118+ }
76119
77- //Unbind before rebind so it doesnt fire twice .
78- _this . $cropButton . off ( "click" ) ;
120+ // Open the modal .
121+ _this . openModal ( ) ;
79122
80- // When the user submits the modal form, send crop values to the form.
81- _this . $cropButton . on ( 'click' , function ( event ) {
82- event . preventDefault ( ) ;
123+ // Add the preview image to the modal
124+ _this . previewImage ( image , _this . $imagePreview ) ;
83125
84- // Validate the caption field and make sure we are good to proceed.
85- _this . validateCaption ( _this . engageImageCrop , image ) ;
86- } ) ;
87- }
88- // Show user an error if they upload an image that is too small.
89- else {
90- if ( ! $errorMsg . length ) {
91- var $error = $ ( "<div class='messages error'>Please upload a larger photo. Min. size is 480px by 480px.</div>" ) ;
92- $error . insertAfter ( _this . $uploadButton . parent ( ) ) ;
126+ //Unbind before rebind so it doesnt fire twice.
127+ _this . $cropButton . off ( "click" ) ;
128+
129+ // When the user submits the modal form, send crop values to the form.
130+ _this . $cropButton . on ( 'click' , function ( event ) {
131+ event . preventDefault ( ) ;
132+
133+ // Validate the caption field and make sure we are good to proceed.
134+ _this . validateCaption ( _this . engageImageCrop , image ) ;
135+ } ) ;
136+ }
137+ // Show user an error if they upload an image that is too small.
138+ else {
139+ if ( ! $errorMsg . length ) {
140+ var $error = $ ( "<div class='messages error'>Please upload a larger photo. Min. size is 480px by 480px.</div>" ) ;
141+ $error . insertAfter ( _this . $uploadButton . parent ( ) ) ;
142+ }
93143 }
94- }
144+ } ;
95145 } ;
96- } ;
146+ }
97147 } ) ;
98148
99149 // Close the modal when a user wants to change their photo.
@@ -359,7 +409,6 @@ define(function(require) {
359409 else {
360410 generatedBlob = new Blob ( [ dataView ] , { type : 'image/png' } ) ;
361411 }
362-
363412 return generatedBlob ;
364413 } ;
365414
0 commit comments