Skip to content

Commit

Permalink
calling the shortener view from the share button
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomcosta committed Jul 31, 2011
1 parent 25323c9 commit ab8a541
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
17 changes: 13 additions & 4 deletions myimgat/apps/wall/static/wall/js/crop-popin.js
Expand Up @@ -6,19 +6,28 @@
initialize: function(){
this.parent.apply(this, arguments);
this.bindEvents();
this.createRequest();
},

createRequest: function(){
this.request = new Request.JSON({
url: settings.urls.shorten
});
},

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

share: function(e) {
e.preventDefault();
new Request.JSON({
url: settings.urls.shorten
});
//this.shareButton.
var data = Object.clone(this.shareButton.retrieve('crop-info'));
data[this.token.get('name')] = this.token.get('value');
this.request.addEvent('success', function() {
console.log('sucesso');
}).post(data);
},

show: function(tab) {
Expand Down
14 changes: 4 additions & 10 deletions myimgat/apps/wall/static/wall/js/init.js
Expand Up @@ -14,24 +14,18 @@
var photo = new Element('img', {
events: {
load: function(){
var size = this.getSize();
new MooCrop(this, {
initialCrop: {
top: 0,
left: 0,
width: size.x - 2,
height: size.y - 2
},
var moocrop = new MooCrop(this, {
min: {width: 50, height: 50},
maskColor: '#ddd',
maskOpacity: 0.2,
constrainRatio: false,
handleColor: '#ccc',
cropBorder: 'dashed 1px #000',
onComplete: function(){

onComplete: function(a, info){
cropPopin.shareButton.store('crop-info', info);
}
});
cropPopin.shareButton.store('crop-info', moocrop.getCropInfo());
}
}
});
Expand Down
1 change: 1 addition & 0 deletions myimgat/apps/wall/templates/wall/popin.html
Expand Up @@ -14,6 +14,7 @@
<h2>image title</h2>
<div class="photo"></div>
<a class="share-button" href="#">share photo</a>
{% csrf_token %}
</div>
<div class="share">
</div>
Expand Down

0 comments on commit ab8a541

Please sign in to comment.