Skip to content

Commit ab8a541

Browse files
committed
calling the shortener view from the share button
1 parent 25323c9 commit ab8a541

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

myimgat/apps/wall/static/wall/js/crop-popin.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@
66
initialize: function(){
77
this.parent.apply(this, arguments);
88
this.bindEvents();
9+
this.createRequest();
10+
},
11+
12+
createRequest: function(){
13+
this.request = new Request.JSON({
14+
url: settings.urls.shorten
15+
});
916
},
1017

1118
bindEvents: function() {
1219
this.shareButton = this.element.getElement('.share-button');
20+
this.token = this.element.getElement('[name="csrfmiddlewaretoken"]');
1321
this.shareButton.addEvent('click', this.share.bind(this));
1422
},
1523

1624
share: function(e) {
1725
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);
2231
},
2332

2433
show: function(tab) {

myimgat/apps/wall/static/wall/js/init.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,18 @@
1414
var photo = new Element('img', {
1515
events: {
1616
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, {
2518
min: {width: 50, height: 50},
2619
maskColor: '#ddd',
2720
maskOpacity: 0.2,
2821
constrainRatio: false,
2922
handleColor: '#ccc',
3023
cropBorder: 'dashed 1px #000',
31-
onComplete: function(){
32-
24+
onComplete: function(a, info){
25+
cropPopin.shareButton.store('crop-info', info);
3326
}
3427
});
28+
cropPopin.shareButton.store('crop-info', moocrop.getCropInfo());
3529
}
3630
}
3731
});

myimgat/apps/wall/templates/wall/popin.html

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<h2>image title</h2>
1515
<div class="photo"></div>
1616
<a class="share-button" href="#">share photo</a>
17+
{% csrf_token %}
1718
</div>
1819
<div class="share">
1920
</div>

0 commit comments

Comments
 (0)