Re-use code for ignore toggle

This commit is contained in:
Ruud
2013-06-14 23:21:41 +02:00
parent 187f5a8a93
commit 6dcd74d116
2 changed files with 74 additions and 81 deletions
@@ -136,7 +136,7 @@ MA.Release = new Class({
}
// Create release
new Element('div', {
var item = new Element('div', {
'class': 'item '+status.identifier,
'id': 'release_'+release.id
}).adopt(
@@ -165,22 +165,12 @@ MA.Release = new Class({
'click': function(e){
(e).preventDefault();
self.ignore(release);
if(this.getParent('.item').hasClass('failed')){
this.getParent('.item').toggleClass('failed');
this.parentNode.getElementsByTagName('span')[1].innerHTML = 'available';
}
else if(this.getParent('.item').hasClass('ignored')){
this.getParent('.item').toggleClass('ignored');
this.parentNode.getElementsByTagName('span')[1].innerHTML = 'available';
}
else {
this.getParent('.item').toggleClass('ignored');
this.parentNode.getElementsByTagName('span')[1].innerHTML = 'ignored';
}
}
}
})
).inject(self.release_container)
).inject(self.release_container);
release['el'] = item;
if(status.identifier == 'ignored' || status.identifier == 'failed' || status.identifier == 'snatched'){
if(!self.last_release || (self.last_release && self.last_release.status.identifier != 'snatched' && status.identifier == 'snatched'))
@@ -329,6 +319,17 @@ MA.Release = new Class({
Api.request('release.ignore', {
'data': {
'id': release.id
},
'onComplete': function(){
var el = release.el;
if(el.hasClass('failed') || el.hasClass('ignored')){
el.removeClass('failed').removeClass('ignored');
el.getElement('.release_status').set('text', 'available');
}
else {
el.addClass('ignored');
el.getElement('.release_status').set('text', 'ignored');
}
}
})
+59 -67
View File
@@ -8,7 +8,7 @@
.movies > div {
clear: both;
}
.movies > div .message {
display: block;
padding: 20px;
@@ -20,11 +20,11 @@
padding: 20px;
display: block;
}
.movies.thumbs_list > div:not(.description) {
margin-right: -4px;
}
.movies .loading {
display: block;
padding: 20px 0 0 0;
@@ -43,26 +43,26 @@
margin-top: -20px;
overflow: hidden;
}
.movies .loading .spinner {
display: inline-block;
}
.movies .loading .message {
margin: 0 20px;
}
.movies h2 {
margin-bottom: 20px;
margin-bottom: 20px;
}
@media all and (max-width: 480px) {
.movies h2 {
font-size: 25px;
margin-bottom: 10px;
margin-bottom: 10px;
}
}
.movies > .description {
position: absolute;
top: 30px;
@@ -73,17 +73,17 @@
.movies:hover > .description {
opacity: 1;
}
@media all and (max-width: 860px) {
.movies > .description {
display: none;
}
}
.movies.thumbs_list {
padding: 20px 0 20px;
}
.home .movies {
padding-top: 6px;
}
@@ -99,27 +99,27 @@
transition-property: width, height;
background: rgba(0,0,0,.2);
}
.movies.mass_edit_list .movie {
padding-left: 22px;
background: none;
}
.movies.details_list .movie {
padding-left: 120px;
}
.movies.list_list .movie:not(.details_view),
.movies.mass_edit_list .movie {
height: 30px;
border-bottom: 1px solid rgba(255,255,255,.15);
}
.movies.list_list .movie:last-child,
.movies.mass_edit_list .movie:last-child {
border: none;
}
.movies.thumbs_list .movie {
width: 16.66667%;
height: auto;
@@ -128,7 +128,7 @@
padding: 0;
vertical-align: top;
}
@media all and (max-width: 800px) {
.movies.thumbs_list .movie {
width: 25%;
@@ -165,7 +165,7 @@
.movies.mass_edit_list .movie .data {
padding-left: 8px;
}
.movies.thumbs_list .data {
position: absolute;
left: 0;
@@ -176,7 +176,7 @@
background: none;
transition: none;
}
.movies.thumbs_list .movie:hover .data {
background: rgba(0,0,0,0.9);
}
@@ -218,7 +218,7 @@
.movies.mass_edit_list .poster {
display: none;
}
.movies.thumbs_list .poster {
width: 100%;
height: 100%;
@@ -243,7 +243,7 @@
bottom: 0;
opacity: 0;
}
.movies .info {
position: relative;
height: 100%;
@@ -272,7 +272,7 @@
display: inline-block;
padding-right: 55px;
}
.movies .info .title span {
display: inline-block;
text-overflow: ellipsis;
@@ -282,14 +282,14 @@
height: 100%;
line-height: 30px;
}
.movies.thumbs_list .info .title span {
white-space: normal;
overflow: auto;
height: auto;
text-align: left;
}
@media all and (max-width: 480px) {
.movies.thumbs_list .movie .info .title span,
.movies.thumbs_list .movie .info .year {
@@ -298,21 +298,21 @@
overflow: hidden;
}
}
.movies.list_list .movie:not(.details_view) .info .title,
.movies.mass_edit_list .info .title {
font-size: 16px;
font-weight: normal;
width: auto;
}
.movies.thumbs_list .movie:not(.no_thumbnail) .info {
display: none;
}
.movies.thumbs_list .movie:hover .info {
display: block;
}
.movies.thumbs_list .info .title {
font-size: 21px;
word-wrap: break-word;
@@ -334,7 +334,7 @@
font-size: 1.25em;
right: 10px;
}
.movies.thumbs_list .info .year {
font-size: 23px;
margin: 0;
@@ -344,7 +344,7 @@
right: auto;
color: #FFF;
}
.touch_enabled .movies.list_list .movie .info .year {
font-size: 1em;
}
@@ -371,24 +371,24 @@
display: block;
min-height: 20px;
}
.movies.list_list .movie:hover .data .quality {
display: none;
}
.touch_enabled .movies.list_list .movie .data .quality {
position: relative;
display: inline-block;
margin: 0;
top: -4px;
}
@media all and (max-width: 480px) {
.movies .data .quality {
display: none;
}
}
.movies .status_suggest .data .quality,
.movies.thumbs_list .data .quality {
display: none;
@@ -417,13 +417,13 @@
z-index: 1;
top: 5px;
}
.movies .data .quality .available,
.movies .data .quality .snatched {
opacity: 1;
cursor: pointer;
}
.movies .data .quality .available { background-color: #578bc3; }
.movies .data .quality .snatched { background-color: #369545; }
.movies .data .quality .done {
@@ -454,18 +454,18 @@
display: none !important;
}
}
.movies .movie:hover .data .actions,
.touch_enabled .movies .movie .data .actions {
opacity: 1;
display: inline-block;
}
.movies.details_list .data .actions {
top: auto;
bottom: 18px;
}
.movies .movie:hover .actions {
opacity: 1;
display: inline-block;
@@ -475,7 +475,7 @@
right: 10px;
top: auto;
}
.movies .movie:hover .action { opacity: 0.6; }
.movies .movie:hover .action:hover { opacity: 1; }
@@ -497,7 +497,7 @@
.movies .data .action.delete { color: #e9b0b0; }
.movies .data .action.directory { color: #ffed92; }
.movies .data .action.readd { color: #c2fac5; }
.movies.mass_edit_list .movie .data .actions {
display: none;
}
@@ -558,23 +558,15 @@
.movies .options .table .item {
border-bottom: 1px solid rgba(255,255,255,0.1);
}
.movies .options .table .item.ignored span {
text-decoration: line-through;
color: rgba(255,255,255,0.4);
}
.movies .options .table .item.ignored .delete:before {
display: inline-block;
content: "\e04b";
transform: scale(-1, 1);
}
.movies .options .table .item.ignored span,
.movies .options .table .item.failed span {
text-decoration: line-through;
color: rgba(255,255,255,0.4);
}
.movies .options .table .item.ignored .delete:before,
.movies .options .table .item.failed .delete:before {
display: inline-block;
content: "\e04b";
display: inline-block;
content: "\e04b";
transform: scale(-1, 1);
}
@@ -626,7 +618,7 @@
.movies .options .table a:hover { opacity: 1; }
.movies .options .table a.download { color: #a7fbaf; }
.movies .options .table a.delete { color: #fda3a3; }
.movies .options .table .ignored a.delete { color: #b5fda3; }
.movies .options .table .ignored a.delete,
.movies .options .table .failed a.delete { color: #b5fda3; }
.movies .options .table .head > * {
@@ -706,7 +698,7 @@
.touch_enabled .movies .movie .trynext {
display: none;
}
@media all and (max-width: 480px) {
.movies .movie .trynext {
display: none;
@@ -720,14 +712,14 @@
.touch_enabled .movies.details_list .movie .trynext {
opacity: 1;
}
.movies.details_list .movie .trynext {
background: #47515f;
padding: 0;
right: 0;
height: 25px;
}
.movies .movie .trynext a {
background-position: 5px center;
padding: 0 5px 0 25px;
@@ -772,7 +764,7 @@
display: none;
}
}
.movies .alph_nav .menus {
display: inline-block;
float: right;
@@ -796,7 +788,7 @@
border-right: 1px solid rgba(255,255,255,.07);
}
.movies .alph_nav .numbers li,
.movies .alph_nav .numbers li,
.movies .alph_nav .actions li {
display: inline-block;
vertical-align: top;
@@ -806,7 +798,7 @@
border: 1px solid transparent;
transition: all 0.1s ease-in-out;
}
.movies .alph_nav .numbers li {
width: 30px;
height: 30px;
@@ -815,14 +807,14 @@
.movies .alph_nav .numbers li.letter_all {
width: 60px;
}
.movies .alph_nav li.available {
font-weight: bold;
cursor: pointer;
opacity: 1;
}
.movies .alph_nav li.active.available,
.movies .alph_nav li.active.available,
.movies .alph_nav li.available:hover {
background: rgba(0,0,0,.1);
}
@@ -843,12 +835,12 @@
.movies .alph_nav .search input:focus {
background: rgba(0,0,0,.08);
}
.movies .alph_nav .search input::-webkit-input-placeholder {
color: #444;
opacity: .6;
}
.movies .alph_nav .search:before {
font-family: 'Elusive-Icons';
content: "\e03e";
@@ -971,10 +963,10 @@
text-align: center;
display: block;
}
.movies .alph_nav .more_menu.filter {
}
.movies .alph_nav .more_menu.filter > a:before {
content: "\e0e8";
font-family: 'Elusive-Icons';
@@ -982,7 +974,7 @@
display: block;
text-align: center;
}
.movies .alph_nav .more_menu.filter .wrapper {
right: 88px;
width: 300px;