This repository has been archived by the owner on May 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now can see the pictures in the channel and when a picture clicked, the channel's picture is changed to it.
- Loading branch information
HyeonJe Jun
committed
Nov 22, 2012
1 parent
db12956
commit 26aff79
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var ShowPicturesView = Backbone.View.extend({ | ||
channel: null, | ||
handler: null, | ||
object: null, | ||
initialize: function(channel, handler) { | ||
this.channel = channel; | ||
this.handler = handler; | ||
|
||
this.render(); | ||
}, | ||
render: function() { | ||
var _this = this; | ||
this.object = $(ich.show_pictures_template()).appendTo('body'); | ||
this.object.data('view', this); | ||
this.object.click(function(e) { | ||
_this.object.remove(); | ||
e.stopPropagation(); | ||
}); | ||
|
||
$.ajax('/channel/'+this.channel+'/pictures', { | ||
type: 'GET', | ||
dataType: 'json', | ||
success: function(picture_list) { | ||
_.each(picture_list, function(pid) { | ||
var picture = $(ich.picture_thumbnail_template({pid: pid})); | ||
picture.click(function(e) { | ||
_this.handler(pid); | ||
_this.remove(); | ||
e.stopPropagation(); | ||
}); | ||
|
||
$('ul.picture-list', _this.object).append(picture); | ||
}); | ||
}, | ||
error: function(err) { | ||
console.log('Error loading pictures:'+err); | ||
_this.remove(); | ||
} | ||
}); | ||
|
||
// resize handler | ||
var resize_handler = function() { | ||
_this.object.height($(window).height() - _this.object.position().top); | ||
}; | ||
resize_handler(); | ||
$(window).bind('resize.show_pictures', resize_handler); | ||
}, | ||
remove: function() { | ||
this.object.remove(); | ||
|
||
// remove resize handler | ||
$(window).unbind('resize.show_pictures'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters