Skip to content

Commit

Permalink
[creating playlist] closes #23, closes #22, #17
Browse files Browse the repository at this point in the history
successful flow in creating a new playlist with youtube api and adding
a video to a playlist
  • Loading branch information
orizens committed Sep 26, 2013
1 parent 4ae90e8 commit 92066e1
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 44 deletions.
10 changes: 5 additions & 5 deletions css/modules.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions css/modules/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@
{
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
transition: all 1s ease;
transition: all .8s ease;
}

.card .face.back
.card .front
{
-webkit-transform: perspective(400px) rotateY(0deg);
transform: perspective(400px) rotateY(0deg);
-webkit-backface-visibility: visible;
backface-visibility: visible;
}

.card .front
.card .back
{
-webkit-transform: perspective(400px) rotateY(-179.9deg);
transform: perspective(400px) rotateY(-179.9deg);
Expand All @@ -76,12 +78,11 @@
-webkit-transform: perspective(400px) rotateY(0deg);
transform: perspective(400px) rotateY(0deg);
}*/
.show-description .face.back {
.show-description .face.front {
-webkit-transform: perspective(400px) rotateY(179.9deg);
transform: perspective(400px) rotateY(179.9deg);
}
.show-description .face.front {
.show-description .face.back {
-webkit-transform: perspective(400px) rotateY(0deg);
transform: perspective(400px) rotateY(0deg);
-webkit-backface-visibility: visible;
}
35 changes: 18 additions & 17 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,28 @@ iframe {
vertical-align: middle;
}
.youtube-item .description {
height: 0;
overflow: auto;
height: 235px;
overflow: hidden;
background-color: rgba(255, 255, 255, .9);
position: absolute;
bottom: 0;
top: 0px;
left:0;
margin: 0px;
padding: 0 8px;
width: 100%;
margin: 8px;
padding: 8px;
/*width: 100%;*/
box-sizing: border-box;
word-wrap:break-word;
}

.youtube-item.show-description .description {
overflow: auto;
}
.youtube-item .indicators {
height: 22px;
}
.show-description .btn.btn-mini.media-desc {
color: #efefef;
background: rgb(71, 68, 68);
}
.youtube-item .title {
height: 27px;
white-space: nowrap;
Expand Down Expand Up @@ -206,14 +215,6 @@ iframe {
}
.youtube-item .add-to-playlist {

}
.youtube-item.show-description .description {
height: 100px;
padding: 4px 8px;
margin: 0;
}
.show-description .icon-chevron-up {
-webkit-transform: rotate(180deg);
}
/* youtube player module */
.youtube-player {
Expand Down Expand Up @@ -504,7 +505,7 @@ iframe {
box-shadow: 0px 1px 2px rgba(0,0,0,.3), inset 0px 0px 0px rgba(0,0,0, .6);
font-family: "Open Sans Condensed", Arial;
text-decoration: none;
-webkit-transform: translate3d(0px, 0px, 0);
/*-webkit-transform: translate3d(0px, 0px, 0);*/
}
.wood .youtube-item .add-to-playlists ul {
font-size: 12px;
Expand Down Expand Up @@ -661,7 +662,7 @@ iframe {
@media (min-width: 1000px) {
.youtube-item:hover .media-title {
box-shadow: 0px 0px 0px rgba(0,0,0,.3), inset 0px 1px 17px rgba(0,0,0, .7);
-webkit-transform: translate3d(0px, 2px, 0);
/*-webkit-transform: translate3d(0px, 2px, 0);*/
background: rgba(0, 0, 0, 0.1);
}
/* Webkit browsers */
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ <h3>Notice - Before You Start Listening...</h3>
<div class="modal-header"></div>
<div class="modal-body">
<h3 class="sign-in-message">Please sign in to add videos to your playlists</h3>
<h5>Select a playlist to add the video to it</h5>
<ul class="unstyled"></ul>
</div>
<div class="modal-footer">
Expand Down
10 changes: 10 additions & 0 deletions js/collections/youtube_playlists_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ define([

createPlaylist: function (title, description) {
var playlist = new PlaylistsService();
playlist.on('sync', function(model){
this.resetParams();
this.fetch();
playlist.off();
}, this);
return playlist.insert(title, description);
},

resetParams: function () {
this.index = 1;
this.tempItems.length = 0;
},

getInfo: function() {
// reset startIndex for 'playlist' only, because it's a new request
if (this.hasChanged('id')) {
Expand Down
15 changes: 13 additions & 2 deletions js/views/playlists-viewer/playlist_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define([
'jquery',
'underscore',
'backbone',
'text!templates/viewer-search.html'
'text!templates/playlist-search.html'
], function($, _, Backbone, template) {

var ViewerSearch = Backbone.View.extend({
Expand All @@ -15,7 +15,7 @@ define([
},
'click button[data-action="create"]': function () {
var query = this.$('input[type=search]').val();
this.createPlaylist(query);
this.setState('loading');
this.trigger('search:add', query);
},

Expand All @@ -34,7 +34,18 @@ define([
render: function(model, video) {
video.query = this.filter;
this.$el.html(this.template(video));
setTimeout(_.bind(function(){
this.$('input').get(0).focus();
}, this), 500);
return this;
},

setState: function (state) {
this.$('.add-btn').button(state);
},

resetState: function () {
this.setState('reset');
}

});
Expand Down
8 changes: 7 additions & 1 deletion js/views/youtube/PlaylistsViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ define([
// this.listenTo(this.model.youtube().playlists, 'sync', this.renderGapiResult);
// listen to modal events
this.$el.on('hidden', _.bind(this.reset, this));
this.$el.on('show', _.bind(this.render, this));
this.header = new ViewerSearch({
el: this.$('.modal-header'),
model: this.model
Expand All @@ -40,6 +41,7 @@ define([
this.filter = "";

this.listenTo(this.header, 'search:change', this.filterPlaylist);
this.listenTo(this.header, 'search:add', this.createPlaylist);
// prerendering
this.render();
},
Expand Down Expand Up @@ -97,8 +99,12 @@ define([
},

createPlaylist: function (title) {
var playlist;
if (title.length) {
this.model.user().playlists.createPlaylist({ title: title });
playlist = this.model.user().playlists.createPlaylist(title);
this.listenTo(playlist, 'sync', function(model){
this.header.resetState();
});
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion js/views/youtube_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define([
var YoutubeItemView = Backbone.View.extend({
tagName: 'li',

className: 'youtube-item span3 nicer-ux ux-maker',
className: 'youtube-item card span3 nicer-ux ux-maker',

template: _.template(YoutubeItemTemplate),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="thumbnail">
<img src="<%= thumbnail.hqDefault %>" class="media-thumb">
</div>
<h3>Add to a playlist:</h3>
<h3>Add To A Playlist:</h3>
<div class="video-title ellipsis"><%= title %></div>
<form class="form-inline">
<input type="search" placeholder="find a playlist" value="<%= query %>">
<button class="btn btn-success add-btn" data-action="create">Create New</button>
<input type="search" placeholder="find or create a playlist">
<button class="btn btn-success add-btn" data-action="create" data-loading-text="Creating...">Create New</button>
</form>
15 changes: 8 additions & 7 deletions templates/youtube_item.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<section class="media-title">
<section class="media-title front face">

<div class="indicators clearfix">

<span class="pull-left item-is-playing playing-<%= isPlaying %>">
<i class="icon-play"></i>Now Playing
</span>

<button class="pull-right btn btn-mini item-action favorite-media is-favorite-<%= isFavorite %>">
<!-- <button class="pull-right btn btn-mini item-action favorite-media is-favorite-<%= isFavorite %>">
<i class="icon-heart-empty"></i>
<i class="icon-heart"></i>
</button>
</button> -->

<button class="pull-right btn btn-mini add-to-playlist" title="Add this video to a playlist">
<i class="icon-plus"></i> Add
Expand All @@ -29,13 +29,14 @@ <h4 class="title span11"><%- title %></h4>



<p class="description">
<span class="close"><i class="icon-remove-sign"></i></span>
<%- description %>
</p>

</section>

<div class="description back face">
<h5>"<%= title %>"</h5>
<%- description %>
</div>

<section class="item-actions">

<span class="btn btn-mini media-desc " title="more info about this video">
Expand Down
4 changes: 2 additions & 2 deletions templates/youtube_playlist_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<i class="icon-play"></i>Now Playing
</span>

<button class="pull-right btn btn-mini add-to-playlist" title="Add this video to a playlist">
<!-- <button class="pull-right btn btn-mini add-to-playlist" title="Add this video to a playlist">
<i class="icon-plus"></i> Add
</button>
</button> -->

</div>

Expand Down

0 comments on commit 92066e1

Please sign in to comment.