/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to includes/cropper.diff

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Files cropper.1.2/applyArrow.png and cropper/applyArrow.png differ
 
2
diff -dPNurbB cropper.1.2/cropper.css cropper/cropper.css
 
3
--- cropper.1.2/cropper.css     2006-10-30 20:58:25.000000000 +0100
 
4
+++ cropper/cropper.css 2008-01-26 17:14:11.000000000 +0100
 
5
@@ -17,17 +17,39 @@
 
6
        font-size: 0;
 
7
 }
 
8
 
 
9
+.imgCrop_apply {
 
10
+       position: absolute;
 
11
+       background: url(applyArrow.png);
 
12
+       border: green solid 1px;
 
13
+       width: 19px;
 
14
+       height: 20px;
 
15
+       margin: 5px;
 
16
+       cursor: pointer;
 
17
+}
 
18
+
 
19
 .imgCrop_overlay {
 
20
+/*
 
21
+       DS: Replacing selected part
 
22
        background-color: #000;
 
23
        opacity: 0.5;
 
24
        filter:alpha(opacity=50);
 
25
+*/
 
26
        position: absolute;
 
27
        width: 100%;
 
28
        height: 100%;
 
29
 }
 
30
 
 
31
 .imgCrop_selArea {
 
32
+/*
 
33
+       DS: Selecting
 
34
+*/
 
35
+       background-color: #FFB;
 
36
+       opacity: 0.5;
 
37
+       filter:alpha(opacity=50);
 
38
+       
 
39
+       
 
40
        position: absolute;
 
41
+       
 
42
        /* @done_in_js 
 
43
        top: 20px;
 
44
        left: 20px;
 
45
diff -dPNurbB cropper.1.2/cropper.js cropper/cropper.js
 
46
--- cropper.1.2/cropper.js      2006-10-30 20:58:25.000000000 +0100
 
47
+++ cropper/cropper.js  2008-01-26 17:09:23.000000000 +0100
 
48
@@ -262,6 +262,26 @@
 
49
                                 */
 
50
                                onEndCrop: Prototype.emptyFunction,
 
51
                                /**
 
52
+                                * @var function
 
53
+                                * The call back function to be called if crop is canceled
 
54
+                                */
 
55
+                               onCancelCrop: Prototype.emptyFunction,
 
56
+                               /**
 
57
+                                * @var function
 
58
+                                * The call back function to pass the final values to
 
59
+                                */
 
60
+                               onDblClick: Prototype.emptyFunction,
 
61
+                               /**
 
62
+                                * @var function
 
63
+                                * The call back function to pass the final values to
 
64
+                                */
 
65
+                               onApplyClick: null,
 
66
+                               /**
 
67
+                                * @var function
 
68
+                                * The call back function to handle click event
 
69
+                                */
 
70
+                               onClick: null,
 
71
+                               /**
 
72
                                 * @var boolean
 
73
                                 * Whether to capture key presses or not
 
74
                                 */
 
75
@@ -280,7 +300,38 @@
 
76
                                 * @var int
 
77
                                 * The maximum height for the select areas in pixels (if both minHeight & maxHeight set to same the height of the cropper will be fixed)
 
78
                                 */
 
79
-                               maxHeight: 0
 
80
+                               maxHeight: 0,
 
81
+                               /**
 
82
+                                * @var obj Coordinate object left, top, right, bottom
 
83
+                                * The non-selectable margins
 
84
+                                */
 
85
+                               margins: { left: 0, top: 0, right: 0, bottom: 0 },
 
86
+                               /**
 
87
+                                * @var int
 
88
+                                * If width is below this value, we are selecting whole horizontal range
 
89
+                                */
 
90
+                               allWidth: 0,
 
91
+                               /**
 
92
+                                * @var int
 
93
+                                * If height is below this value, we are selecting whole vertical range
 
94
+                                */
 
95
+                               allHeight: 0,
 
96
+                               /**
 
97
+                                * @var boolean
 
98
+                                * Whether to monitor reloading of picture
 
99
+                                */
 
100
+                               monitorImage: true,
 
101
+                               /**
 
102
+                                * @var boolean
 
103
+                                * Whether the image is already loaded
 
104
+                                */
 
105
+                               imageReady: false,
 
106
+                               /**
 
107
+                                * @var int
 
108
+                                * Maximal duration of the click event in ms (after dragging is started)
 
109
+                                */
 
110
+                               clickDuration: 200
 
111
+
 
112
                        }, 
 
113
                        options || {}
 
114
                );                              
 
115
@@ -306,6 +357,16 @@
 
116
                this.resizing           = false;
 
117
                /**
 
118
                 * @var boolean
 
119
+                * Whether the selected area is present on the screen
 
120
+                */
 
121
+               this.selected           = false;
 
122
+               /**
 
123
+                * @var boolean
 
124
+                * Whether the selected area is present on the screen
 
125
+                */
 
126
+               this.altered            = false;
 
127
+               /**
 
128
+                * @var boolean
 
129
                 * Whether the user is on a webKit browser
 
130
                 */
 
131
                this.isWebKit           = /Konqueror|Safari|KHTML/.test( navigator.userAgent );
 
132
@@ -380,8 +441,10 @@
 
133
                // only load the event observers etc. once the image is loaded
 
134
                // this is done after the subInitialize() call just in case the sub class does anything
 
135
                // that will affect the result of the call to onLoad()
 
136
-               if( this.img.complete || this.isWebKit ) this.onLoad(); // for some reason Safari seems to support img.complete but returns 'undefined' on the this.img object
 
137
-               else Event.observe( this.img, 'load', this.onLoad.bindAsEventListener( this) );         
 
138
+               if( this.options.imageReady || this.img.complete || this.isWebKit ) {
 
139
+                   this.onLoad(); // for some reason Safari seems to support img.complete but returns 'undefined' on the this.img object
 
140
+                   if (this.options.monitorImage) Event.observe( this.img, 'load', this.onLoad.bindAsEventListener( this) );
 
141
+               } else Event.observe( this.img, 'load', this.onLoad.bindAsEventListener( this) );
 
142
        },
 
143
        
 
144
        /**
 
145
@@ -437,6 +500,14 @@
 
146
                 *              </div>  
 
147
                 * </div>
 
148
                 */
 
149
+
 
150
+               if (this.attached) {
 
151
+                   if (this.monitorImage) {
 
152
+                       this.setParams();
 
153
+                   }
 
154
+                   return;
 
155
+               }
 
156
+                
 
157
                var cNamePrefix = 'imgCrop_';
 
158
                
 
159
                // get the point to insert the container
 
160
@@ -447,12 +518,19 @@
 
161
                if( this.isOpera8 ) fixOperaClass = ' opera8';
 
162
                this.imgWrap = Builder.node( 'div', { 'class': cNamePrefix + 'wrap' + fixOperaClass } );
 
163
                
 
164
+               this.applyLinked = 0;
 
165
+               this.applyButton = Builder.node( 'div', { 'class': cNamePrefix + 'apply' } );
 
166
+               
 
167
                this.north              = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'north' }, [Builder.node( 'span' )] );
 
168
+               this.north_east         = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'north' }, [Builder.node( 'span' )] );
 
169
+               this.north_west         = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'north' }, [Builder.node( 'span' )] );
 
170
                this.east               = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'east' } , [Builder.node( 'span' )] );
 
171
                this.south              = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'south' }, [Builder.node( 'span' )] );
 
172
+               this.south_east         = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'south' }, [Builder.node( 'span' )] );
 
173
+               this.south_west         = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'south' }, [Builder.node( 'span' )] );
 
174
                this.west               = Builder.node( 'div', { 'class': cNamePrefix + 'overlay ' + cNamePrefix + 'west' } , [Builder.node( 'span' )] );
 
175
                
 
176
-               var overlays    = [ this.north, this.east, this.south, this.west ];
 
177
+               var overlays    = [ this.north_west, this.north, this.north_east, this.east, this.south_east, this.south, this.south_west, this.west ];
 
178
 
 
179
                this.dragArea   = Builder.node( 'div', { 'class': cNamePrefix + 'dragArea' }, overlays );
 
180
                                                
 
181
@@ -499,6 +577,14 @@
 
182
                
 
183
                this.endCropBind        = this.endCrop.bindAsEventListener( this );
 
184
                Event.observe( document, 'mouseup', this.endCropBind );
 
185
+//             Event.observe( this.imgWrap, 'mouseup', this.endCropBind );
 
186
+               
 
187
+               this.dblClickBind       = this.dblClick.bindAsEventListener( this );
 
188
+               Event.observe( this.selArea, 'dblclick', this.dblClickBind );
 
189
+               
 
190
+               this.applyClickBind     = this.applyClick.bindAsEventListener( this );
 
191
+               Event.observe( this.applyButton, 'mousedown', this.applyClickBind );
 
192
+//             Event.observe( this.applyButton, 'click', this.applyClickBind );
 
193
                
 
194
                this.resizeBind         = this.startResize.bindAsEventListener( this );
 
195
                this.handles = [ this.handleN, this.handleNE, this.handleE, this.handleSE, this.handleS, this.handleSW, this.handleW, this.handleNW ];
 
196
@@ -570,8 +656,12 @@
 
197
                this.imgH = this.img.height;                    
 
198
 
 
199
                $( this.north ).setStyle( { height: 0 } );
 
200
+               $( this.north_east ).setStyle( { height: 0 } );
 
201
+               $( this.north_west ).setStyle( { height: 0 } );
 
202
                $( this.east ).setStyle( { width: 0, height: 0 } );
 
203
                $( this.south ).setStyle( { height: 0 } );
 
204
+               $( this.south_east ).setStyle( { height: 0 } );
 
205
+               $( this.south_west ).setStyle( { height: 0 } );
 
206
                $( this.west ).setStyle( { width: 0, height: 0 } );
 
207
                
 
208
                // resize the container to fit the image
 
209
@@ -580,8 +670,17 @@
 
210
                // hide the select area
 
211
                $( this.selArea ).hide();
 
212
                                                
 
213
+               // hide apply button
 
214
+               if (this.applyLinked) {
 
215
+                   this.dragArea.removeChild(this.applyButton);
 
216
+                   this.applyLinked = false;
 
217
+               }
 
218
+               
 
219
+               this.selected = false;
 
220
+               this.altered = false;
 
221
+                                               
 
222
                // setup the starting position of the select area
 
223
-               var startCoords = { x1: 0, y1: 0, x2: 0, y2: 0 };
 
224
+               var startCoords = { x1: this.options.margins.left, y1: this.options.margins.top, x2: this.options.margins.left, y2: this.options.margins.top };
 
225
                var validCoordsSet = false;
 
226
                
 
227
                // display the select area 
 
228
@@ -627,6 +726,10 @@
 
229
                        Event.stopObserving( this.dragArea, 'mousedown', this.startDragBind );
 
230
                        Event.stopObserving( document, 'mousemove', this.onDragBind );          
 
231
                        Event.stopObserving( document, 'mouseup', this.endCropBind );
 
232
+//                     Event.stopObserving( this.imgWrap, 'mouseup', this.endCropBind );
 
233
+                       Event.stopObserving( this.selArea, 'dblclick', this.dblClickBind );
 
234
+                       Event.stopObserving( this.applyButton, 'mousedown', this.applyClickBind );
 
235
+                       
 
236
                        this.registerHandles( false );
 
237
                        if( this.options.captureKeys ) Event.stopObserving( document, 'keypress', this.keysBind );
 
238
                }
 
239
@@ -645,6 +748,39 @@
 
240
        },
 
241
        
 
242
        /**
 
243
+        * Resets the cropper selection
 
244
+        * 
 
245
+        * @access public
 
246
+        * @return void
 
247
+        */
 
248
+       clear: function() {
 
249
+               $( this.north ).setStyle( { height: 0 } );
 
250
+               $( this.north_east ).setStyle( { height: 0 } );
 
251
+               $( this.north_west ).setStyle( { height: 0 } );
 
252
+               $( this.east ).setStyle( { width: 0, height: 0 } );
 
253
+               $( this.south ).setStyle( { height: 0 } );
 
254
+               $( this.south_east ).setStyle( { height: 0 } );
 
255
+               $( this.south_west ).setStyle( { height: 0 } );
 
256
+               $( this.west ).setStyle( { width: 0, height: 0 } );
 
257
+
 
258
+               // hide the select area
 
259
+               $( this.selArea ).hide();
 
260
+               
 
261
+               // hide apply button
 
262
+               if (this.applyLinked) {
 
263
+                   this.dragArea.removeChild(this.applyButton);
 
264
+                   this.applyLinked = false;
 
265
+               }
 
266
+               
 
267
+               //
 
268
+               this.selected = false;
 
269
+               this.altered = false;
 
270
+               
 
271
+               this.setAreaCoords( { x1: this.options.margins.left, y1: this.options.margins.top, x2: this.options.margins.left, y2: this.options.margins.top }, false, false, null );
 
272
+               this.drawArea();
 
273
+       },
 
274
+       
 
275
+       /**
 
276
         * Handles the key functionality, currently just using arrow keys to move, if the user
 
277
         * presses shift then the area will move by 10 pixels
 
278
         */
 
279
@@ -710,6 +846,7 @@
 
280
         */
 
281
        moveArea: function( point ) {
 
282
                // dump( 'moveArea        : ' + point[0] + ',' + point[1] + ',' + ( point[0] + ( this.areaCoords.x2 - this.areaCoords.x1 ) ) + ',' + ( point[1] + ( this.areaCoords.y2 - this.areaCoords.y1 ) ) + '\n' );
 
283
+               this.altered = true;
 
284
                this.setAreaCoords( 
 
285
                        {
 
286
                                x1: point[0], 
 
287
@@ -754,28 +891,28 @@
 
288
                        var targH = coords.y2 - coords.y1;
 
289
                        
 
290
                        // ensure we're within the bounds
 
291
-                       if( coords.x1 < 0 ) {
 
292
-                               coords.x1 = 0;
 
293
-                               coords.x2 = targW;
 
294
+                       if( coords.x1 < this.options.margins.left ) {
 
295
+                               coords.x1 = this.options.margins.left;
 
296
+                               coords.x2 = this.options.margins.left + targW;
 
297
                        }
 
298
-                       if( coords.y1 < 0 ) {
 
299
-                               coords.y1 = 0;
 
300
-                               coords.y2 = targH;
 
301
+                       if( coords.y1 < this.options.margins.top ) {
 
302
+                               coords.y1 = this.options.margins.top;
 
303
+                               coords.y2 = this.options.margins.top + targH;
 
304
                        }
 
305
-                       if( coords.x2 > this.imgW ) {
 
306
-                               coords.x2 = this.imgW;
 
307
-                               coords.x1 = this.imgW - targW;
 
308
+                       if( coords.x2 > (this.imgW - this.options.margins.right) ) {
 
309
+                               coords.x2 = this.imgW - this.options.margins.right;
 
310
+                               coords.x1 = coords.x2 - targW;
 
311
                        }
 
312
-                       if( coords.y2 > this.imgH ) {
 
313
-                               coords.y2 = this.imgH;
 
314
-                               coords.y1 = this.imgH - targH;
 
315
+                       if( coords.y2 > (this.imgH - this.options.margins.bottom) ) {
 
316
+                               coords.y2 = this.imgH - this.options.margins.bottom;
 
317
+                               coords.y1 = coords.y2 - targH;
 
318
                        }                       
 
319
                } else {
 
320
                        // ensure we're within the bounds
 
321
-                       if( coords.x1 < 0 ) coords.x1 = 0;
 
322
-                       if( coords.y1 < 0 ) coords.y1 = 0;
 
323
-                       if( coords.x2 > this.imgW ) coords.x2 = this.imgW;
 
324
-                       if( coords.y2 > this.imgH ) coords.y2 = this.imgH;
 
325
+                       if( coords.x1 < this.options.margins.left ) coords.x1 = this.options.margins.left;
 
326
+                       if( coords.y1 < this.options.margins.top ) coords.y1 = this.options.margins.top;
 
327
+                       if( coords.x2 > (this.imgW - this.options.margins.right) ) coords.x2 = this.imgW - this.options.margins.right;
 
328
+                       if( coords.y2 > (this.imgH - this.options.margins.bottom) ) coords.y2 = this.imgH - this.options.margins.bottom;
 
329
                        
 
330
                        // This is passed as null in onload
 
331
                        if( direction != null ) {
 
332
@@ -819,7 +956,7 @@
 
333
                        }
 
334
                }
 
335
                
 
336
-               // dump( 'setAreaCoords (out) : ' + coords.x1 + ',' + coords.y1 + ',' + coords.x2 + ',' + coords.y2 + '\n' );
 
337
+//             dump( 'setAreaCoords (out) : ' + coords.x1 + ',' + coords.y1 + ',' + coords.x2 + ',' + coords.y2 + '\n' );
 
338
                this.areaCoords = coords;
 
339
        },
 
340
        
 
341
@@ -1000,8 +1137,58 @@
 
342
                this.handleS.style.left         = horizHandlePos;
 
343
                this.handleW.style.top          = vertHandlePos;
 
344
                
 
345
+               if ((areaWidth < this.options.allWidth)&&(areaHeight<this.options.allHeight)) {
 
346
+                   if (this.applyLinked) {
 
347
+                       this.dragArea.removeChild(this.applyButton);
 
348
+                       this.applyLinked = false;
 
349
+                   }
 
350
+                   this.east.className = "imgCrop_overlay";
 
351
+                   this.west.className = "imgCrop_overlay";
 
352
+                   this.north.className = "imgCrop_overlay";
 
353
+                   this.south.className = "imgCrop_overlay";
 
354
+               } else if (areaWidth < this.options.allWidth) {
 
355
+                   if ((this.options.onApplyClick)&&(!this.applyLinked)) {
 
356
+                       this.dragArea.appendChild(this.applyButton);
 
357
+                       this.applyLinked = true;
 
358
+                   }
 
359
+                   this.east.className = "imgCrop_selArea";
 
360
+                   this.west.className = "imgCrop_selArea";
 
361
+                   this.north.className = "imgCrop_overlay";
 
362
+                   this.south.className = "imgCrop_overlay";
 
363
+               } else if (areaHeight < this.options.allHeight) {
 
364
+                   if ((this.options.onApplyClick)&&(!this.applyLinked)) {
 
365
+                       this.dragArea.appendChild(this.applyButton);
 
366
+                       this.applyLinked = true;
 
367
+                   }
 
368
+                   this.east.className = "imgCrop_overlay";
 
369
+                   this.west.className = "imgCrop_overlay";
 
370
+                   this.north.className = "imgCrop_selArea";
 
371
+                   this.south.className = "imgCrop_selArea";
 
372
+               } else {
 
373
+                   if ((this.options.onApplyClick)&&(!this.applyLinked)) {
 
374
+                       this.dragArea.appendChild(this.applyButton);
 
375
+                       this.applyLinked = true;
 
376
+                   }
 
377
+                   this.east.className = "imgCrop_overlay";
 
378
+                   this.west.className = "imgCrop_overlay";
 
379
+                   this.north.className = "imgCrop_overlay";
 
380
+                   this.south.className = "imgCrop_overlay";
 
381
+               }
 
382
+               
 
383
                // draw the four overlays
 
384
-               this.north.style.height         = params[1];
 
385
+               var northStyle                  = this.north.style;
 
386
+               northStyle.height               = params[1];
 
387
+               northStyle.left                 = params[0];
 
388
+               northStyle.width                = params[2];
 
389
+               
 
390
+               var neStyle                     = this.north_east.style;
 
391
+               neStyle.height                  = params[1];
 
392
+               neStyle.width                   = params[0];
 
393
+
 
394
+               var nwStyle                     = this.north_west.style;
 
395
+               nwStyle.height                  = params[1];
 
396
+               nwStyle.left                    = params[4];
 
397
+               nwStyle.width                   = params[6];
 
398
                
 
399
                var eastStyle                           = this.east.style;
 
400
                eastStyle.top                           = params[1];
 
401
@@ -1012,12 +1199,33 @@
 
402
                var southStyle                          = this.south.style;
 
403
                southStyle.top                          = params[5];
 
404
                southStyle.height                       = params[7];
 
405
+               southStyle.left                 = params[0];
 
406
+               southStyle.width                = params[2];
 
407
+
 
408
+               var seStyle                     = this.south_east.style;
 
409
+               seStyle.top                     = params[5];
 
410
+               seStyle.height                  = params[7];
 
411
+               seStyle.width                   = params[0];
 
412
+
 
413
+               var swStyle                     = this.south_west.style;
 
414
+               swStyle.top                     = params[5];
 
415
+               swStyle.height                  = params[7];
 
416
+               swStyle.left                    = params[4];
 
417
+               swStyle.width                   = params[6];
 
418
           
 
419
            var westStyle                       = this.west.style;
 
420
            westStyle.top                               = params[1];
 
421
            westStyle.height                    = params[3];
 
422
                westStyle.width                         = params[0];
 
423
                
 
424
+               
 
425
+               if (this.applyButton.parentNode) {
 
426
+                   var applyStyle = this.applyButton.style;
 
427
+                   applyStyle.left = params[4];
 
428
+                   applyStyle.top = params[5];
 
429
+               }
 
430
+               
 
431
+
 
432
                // call the draw method on sub classes
 
433
                this.subDrawArea();
 
434
                
 
435
@@ -1067,7 +1275,9 @@
 
436
        startResize: function( e ) {
 
437
                this.startCoords = this.cloneCoords( this.areaCoords );
 
438
                
 
439
+               this.altered = true;
 
440
                this.resizing = true;
 
441
+
 
442
                this.resizeHandle = Event.element( e ).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/, '');
 
443
                // dump( 'this.resizeHandle : ' + this.resizeHandle + '\n' );
 
444
                Event.stop( e );
 
445
@@ -1081,12 +1291,22 @@
 
446
         * @return void
 
447
         */
 
448
        startDrag: function( e ) {      
 
449
+           if (!this.dragging) {
 
450
+               var curtime = new Date();
 
451
+               this.start_time = curtime.getTime();
 
452
+           }
 
453
+               
 
454
                this.selArea.show();
 
455
                this.clickCoords = this.getCurPos( e );
 
456
        
 
457
        this.setAreaCoords( { x1: this.clickCoords.x, y1: this.clickCoords.y, x2: this.clickCoords.x, y2: this.clickCoords.y }, false, false, null );
 
458
        
 
459
+           this.altered = true;
 
460
        this.dragging = true;
 
461
+
 
462
+           if (this.options.onClick)
 
463
+               this.dragged = false;
 
464
+           else
 
465
        this.onDrag( e ); // incase the user just clicks once after already making a selection
 
466
        Event.stop( e );
 
467
        },
 
468
@@ -1101,12 +1321,15 @@
 
469
        getCurPos: function( e ) {
 
470
                // get the offsets for the wrapper within the document
 
471
                var el = this.imgWrap, wrapOffsets = Position.cumulativeOffset( el );
 
472
+               
 
473
                // remove any scrolling that is applied to the wrapper (this may be buggy) - don't count the scroll on the body as that won't affect us
 
474
+/* DS: Causes problems in Opera9 (IE, Seamonkey are OK)
 
475
                while( el.nodeName != 'BODY' ) {
 
476
                        wrapOffsets[1] -= el.scrollTop  || 0;
 
477
                        wrapOffsets[0] -= el.scrollLeft || 0;
 
478
                        el = el.parentNode;
 
479
            }           
 
480
+*/
 
481
                return curPos = { 
 
482
                        x: Event.pointerX(e) - wrapOffsets[0],
 
483
                        y: Event.pointerY(e) - wrapOffsets[1]
 
484
@@ -1122,6 +1345,7 @@
 
485
         */
 
486
        onDrag: function( e ) {
 
487
                if( this.dragging || this.resizing ) {  
 
488
+                       this.dragged = true;
 
489
                
 
490
                        var resizeHandle = null;
 
491
                        var curPos = this.getCurPos( e );                       
 
492
@@ -1191,17 +1415,108 @@
 
493
         * @access private
 
494
         * @return void
 
495
         */
 
496
-       endCrop : function() {
 
497
+       endCrop : function(e) {
 
498
+               var click = false;
 
499
+               var w, h;
 
500
+               
 
501
+               if ((this.dragging)&&(this.start_time)) {
 
502
+                   var curtime = new Date();
 
503
+                   var duration = curtime.getTime() - this.start_time;
 
504
+                   
 
505
+                   if (duration < this.options.clickDuration) click = true;
 
506
+               } 
 
507
+
 
508
+               
 
509
                this.dragging = false;
 
510
                this.resizing = false;
 
511
                
 
512
+               w = this.calcW();
 
513
+               h = this.calcH();
 
514
+               
 
515
+               if (click) {
 
516
+                   if ((w>this.options.allWidth)||(h>this.options.allHeight)) click = false;
 
517
+               }
 
518
+               
 
519
+               if (click) {
 
520
+                   var x = this.areaCoords.x1;
 
521
+                   var y = this.areaCoords.y1;
 
522
+
 
523
+                   if (this.selected) {
 
524
+                       this.options.onCancelCrop();
 
525
+                       this.clear();
 
526
+                   } else if (this.options.onClick) {
 
527
+                       this.options.onClick(e,
 
528
+                           {
 
529
+                               x: x,
 
530
+                               y: y
 
531
+                           }
 
532
+                       );
 
533
+                       this.clear();
 
534
+                   }
 
535
+               } else if ((w>this.options.allWidth)||(h>this.options.allHeight)) {
 
536
+                   if (!this.dragged)  this.onDrag( e );
 
537
+                   
 
538
+                   if (this.altered) {
 
539
                this.options.onEndCrop(
 
540
                        this.areaCoords,
 
541
                        {
 
542
+                               width: w, 
 
543
+                               height: h 
 
544
+                           }
 
545
+                       );
 
546
+                       this.altered = false;
 
547
+                   }
 
548
+                   this.selected = true;
 
549
+               } else {
 
550
+                   this.clear();
 
551
+               }
 
552
+       },
 
553
+       
 
554
+       /**
 
555
+        * Passes the values of the select area on to the appropriate 
 
556
+        * callback function on double click in cropping area
 
557
+        * 
 
558
+        * @access private
 
559
+        * @return void
 
560
+        */
 
561
+       dblClick : function() {
 
562
+               this.dragging = false;
 
563
+               this.resizing = false;
 
564
+               
 
565
+               var w = this.calcW();
 
566
+               var h = this.calcH();
 
567
+               
 
568
+               if ((w > this.options.allWidth)&&(h > this.options.allHeight)) {
 
569
+                   this.options.onDblClick(
 
570
+                       this.areaCoords,
 
571
+                       {
 
572
+                               width: w, 
 
573
+                               height: h 
 
574
+                       }
 
575
+                   );
 
576
+               }
 
577
+       },
 
578
+
 
579
+       /**
 
580
+        * Passes the values of the select area on to the appropriate 
 
581
+        * callback function on a click on apply button
 
582
+        * 
 
583
+        * @access private
 
584
+        * @return void
 
585
+        */
 
586
+       applyClick : function(ev) {
 
587
+               this.dragging = false;
 
588
+               this.resizing = false;
 
589
+               
 
590
+               this.options.onApplyClick(
 
591
+                       this.areaCoords,
 
592
+                       {
 
593
                                width: this.calcW(), 
 
594
                                height: this.calcH() 
 
595
                        }
 
596
                );
 
597
+               //ev.cancelBubble = true;
 
598
+               Event.stop( ev );
 
599
        },
 
600
        
 
601
        /**
 
602
diff -dPNurbB cropper.1.2/licence.txt cropper/licence.txt
 
603
--- cropper.1.2/licence.txt     2006-10-30 20:58:25.000000000 +0100
 
604
+++ cropper/licence.txt 1970-01-01 01:00:00.000000000 +0100
 
605
@@ -1,12 +0,0 @@
 
606
-Copyright (c) 2006, David Spurr (www.defusion.org.uk)
 
607
-All rights reserved.
 
608
-
 
609
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
610
-
 
611
-    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 
612
-    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 
613
-    * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 
614
-
 
615
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
616
-
 
617
-http://www.opensource.org/licenses/bsd-license.php
 
618
\ No newline at end of file