File tree 3 files changed +18
-14
lines changed
3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 6
6
initialize : function ( ) {
7
7
this . parent . apply ( this , arguments ) ;
8
8
this . bindEvents ( ) ;
9
+ this . createRequest ( ) ;
10
+ } ,
11
+
12
+ createRequest : function ( ) {
13
+ this . request = new Request . JSON ( {
14
+ url : settings . urls . shorten
15
+ } ) ;
9
16
} ,
10
17
11
18
bindEvents : function ( ) {
12
19
this . shareButton = this . element . getElement ( '.share-button' ) ;
20
+ this . token = this . element . getElement ( '[name="csrfmiddlewaretoken"]' ) ;
13
21
this . shareButton . addEvent ( 'click' , this . share . bind ( this ) ) ;
14
22
} ,
15
23
16
24
share : function ( e ) {
17
25
e . preventDefault ( ) ;
18
- new Request . JSON ( {
19
- url : settings . urls . shorten
20
- } ) ;
21
- //this.shareButton.
26
+ var data = Object . clone ( this . shareButton . retrieve ( 'crop-info' ) ) ;
27
+ data [ this . token . get ( 'name' ) ] = this . token . get ( 'value' ) ;
28
+ this . request . addEvent ( 'success' , function ( ) {
29
+ console . log ( 'sucesso' ) ;
30
+ } ) . post ( data ) ;
22
31
} ,
23
32
24
33
show : function ( tab ) {
Original file line number Diff line number Diff line change 14
14
var photo = new Element ( 'img' , {
15
15
events : {
16
16
load : function ( ) {
17
- var size = this . getSize ( ) ;
18
- new MooCrop ( this , {
19
- initialCrop : {
20
- top : 0 ,
21
- left : 0 ,
22
- width : size . x - 2 ,
23
- height : size . y - 2
24
- } ,
17
+ var moocrop = new MooCrop ( this , {
25
18
min : { width : 50 , height : 50 } ,
26
19
maskColor : '#ddd' ,
27
20
maskOpacity : 0.2 ,
28
21
constrainRatio : false ,
29
22
handleColor : '#ccc' ,
30
23
cropBorder : 'dashed 1px #000' ,
31
- onComplete : function ( ) {
32
-
24
+ onComplete : function ( a , info ) {
25
+ cropPopin . shareButton . store ( 'crop-info' , info ) ;
33
26
}
34
27
} ) ;
28
+ cropPopin . shareButton . store ( 'crop-info' , moocrop . getCropInfo ( ) ) ;
35
29
}
36
30
}
37
31
} ) ;
Original file line number Diff line number Diff line change 14
14
< h2 > image title</ h2 >
15
15
< div class ="photo "> </ div >
16
16
< a class ="share-button " href ="# "> share photo</ a >
17
+ {% csrf_token %}
17
18
</ div >
18
19
< div class ="share ">
19
20
</ div >
You can’t perform that action at this time.
0 commit comments