Commit 9a11d059 authored by Marius Trautrims's avatar Marius Trautrims

Merge branch 'master' of git.thm.de:arsnova/flashcards

parents b88905d4 9962863d
......@@ -192,21 +192,21 @@
<thead>
<tr>
<th>
<span>{{_ "foreside"}}</span>
<a href="#"></a>
<a href="#"></a>
<span>{{_ "frontside"}}</span>
<a class="frontdown" role="button"></a>
<a class="frontup" role="button"></a>
</th>
<th>
<span>{{_ "backside"}}</span>
<a href="#"></a>
<a href="#"></a>
<a class="backdown" role="button"></a>
<a class="backup" role="button"></a>
</th>
<th>{{_ "options"}}</th>
</tr>
</thead>
<tbody>
{{#if countCards this._id}}
{{#each getCards}}
{{#each cardList}}
<tr class="listitem">
{{cardlistMarkdown this.front this.back @index}}
<td class="front{{@index}}"></td>
......
......@@ -4,6 +4,8 @@ Meteor.subscribe('ratings', function onReady() {
Session.set('ratingsLoaded', true);
});
Session.setDefault('cardSort', {front: 1});
/**
* ############################################################################
* cardset
......@@ -12,21 +14,21 @@ Meteor.subscribe('ratings', function onReady() {
Template.cardset.helpers({
'onEditmodalClose': function(id) {
Session.set('previousName', Cardsets.findOne(id).name);
Session.set('previousDescription', Cardsets.findOne(id).description);
Session.set('previousCategory', Cardsets.findOne(id).category);
Session.set('previousVisible', Cardsets.findOne(id).visible);
Session.set('previousRatings', Cardsets.findOne(id).ratings);
Session.set('previousName', Cardsets.findOne(id).name);
Session.set('previousDescription', Cardsets.findOne(id).description);
Session.set('previousCategory', Cardsets.findOne(id).category);
Session.set('previousVisible', Cardsets.findOne(id).visible);
Session.set('previousRatings', Cardsets.findOne(id).ratings);
var previousCategory = Cardsets.findOne(id).category;
var categoryId = previousCategory.toString();
var previousCategory = Cardsets.findOne(id).category;
var categoryId = previousCategory.toString();
if (categoryId.length == 1) categoryId = "0" + categoryId;
if (categoryId.length == 1) categoryId = "0" + categoryId;
var category = Categories.findOne(categoryId);
if (category !== undefined) {
Session.set('previousCategoryName', category.name);
}
var category = Categories.findOne(categoryId);
if (category !== undefined) {
Session.set('previousCategoryName', category.name);
}
}
});
......@@ -100,40 +102,33 @@ Template.cardsetForm.onRendered(function() {
var previousVisible = Session.get('previousVisible');
var previousRatings = Session.get('previousRatings');
if (previousName != $('#editSetName').val())
{
if (previousName != $('#editSetName').val()) {
$('#editSetName').val(previousName);
$('#editSetNameLabel').css('color', '');
$('#editSetName').css('border-color', '');
}
if (previousDescription != $('#editSetDescription').val())
{
if (previousDescription != $('#editSetDescription').val()) {
$('#editSetDescription').val(previousDescription);
$('#editSetDescriptionLabel').css('color', '');
$('#editSetDescription').css('border-color', '');
}
if (previousCategoryName != $('#editSetCategory').html())
{
if (previousCategoryName != $('#editSetCategory').html()) {
$('#editSetCategory').html(previousCategoryName);
}
if (previousVisible != $('#editCardSetVisibility > .active > input').val())
{
if(previousVisible) {
if (previousVisible != $('#editCardSetVisibility > .active > input').val()) {
if (previousVisible) {
$('#visibilityoption1').removeClass('active');
$('#visibilityoption2').addClass('active');
}
else {
} else {
$('#visibilityoption2').removeClass('active');
$('#visibilityoption1').addClass('active');
}
}
if (previousRatings != $('#editCardSetRating > .active > input').val())
{
if(previousRatings) {
if (previousRatings != $('#editCardSetRating > .active > input').val()) {
if (previousRatings) {
$('#ratingoption2').removeClass('active');
$('#ratingoption1').addClass('active');
}
else {
} else {
$('#ratingoption1').removeClass('active');
$('#ratingoption2').addClass('active');
}
......@@ -176,6 +171,13 @@ Template.cardsetList.helpers({
var alt = $('.listitem img').attr('alt');
$('.listitem img').replaceWith($('<a class="card-back btn-showPictureModal" data-toggle="modal" data-target="#pictureModal" href="#" data-val="' + src + '" data-alt="' + alt + '"><i class="glyphicon glyphicon-picture"></i></a>'));
});
},
cardList: function() {
return Cards.find({
cardset_id: this._id
}, {
sort: Session.get("cardSort")
});
}
});
......@@ -189,9 +191,26 @@ Template.cardsetList.events({
'click .deleteCardList': function() {
var id = this._id;
Meteor.call("deleteCard", id);
},
'click #set-details-region .frontdown': function() {
Session.set('cardSort', {front: 1});
},
'click #set-details-region .frontup': function() {
Session.set('cardSort', {front: -1});
},
'click #set-details-region .backdown': function() {
Session.set('cardSort', {back: 1});
},
'click #set-details-region .backup': function() {
Session.set('cardSort', {back: -1});
}
});
Template.cardsetList.onDestroyed(function() {
Session.set('cardSort', {front: 1});
});
/**
* ############################################################################
* cardsetDetails
......@@ -332,8 +351,10 @@ Template.sidebarCardset.events({
Meteor.call("addRating", cardset_id, rating);
}
},
'click #usr-profile2': function () {
Router.go('profile', {_id: Meteor.userId()});
'click #usr-profile2': function() {
Router.go('profile', {
_id: Meteor.userId()
});
}
});
......
......@@ -52,18 +52,16 @@
<tr>
<th>
<span>{{_ "set-list.name"}}</span>
<a class="namedown" href="#"></a>
<a class="nameup" href="#"></a>
<a class="namedown" role="button"></a>
<a class="nameup" role="button"></a>
</th>
<th>
<span>{{_ "set-list.category"}}</span>
<a class="categorydown" href="#"></a>
<a class="categoryup" href="#"></a>
<a class="categorydown" role="button"></a>
<a class="categoryup" role="button"></a>
</th>
<th>
<span>{{_ "set-list.description"}}</span>
<a class="descriptiondown" href="#"></a>
<a class="descriptionup" href="#"></a>
</th>
</tr>
</thead>
......@@ -106,24 +104,22 @@
<template name="learned">
<div id="set-list-region" class="col-md-9">
<div id="learned-list-region" class="col-md-9">
<table class="table table-bordered table-striped table-hover">
<thead class="set-list">
<tr>
<th>
<span>{{_ "set-list.name"}}</span>
<a onclick="Cards.Set.Controller.showListLayout('name', 'down');" href=""></a>
<a onclick="Cards.Set.Controller.showListLayout('name', 'up');" href=""></a>
<a class="namedown" role="button"></a>
<a class="nameup" role="button"></a>
</th>
<th width="25%">
<th>
<span>{{_ "set-list.category"}}</span>
<a onclick="Cards.Set.Controller.showListLayout('category', 'down');" href=""></a>
<a onclick="Cards.Set.Controller.showListLayout('category', 'up');" href=""></a>
<a class="categorydown" role="button"></a>
<a class="categoryup" role="button"></a>
</th>
<th width="40%">
<th>
<span>{{_ "set-list.description"}}</span>
<a onclick="Cards.Set.Controller.showListLayout('description', 'down');" href=""></a>
<a onclick="Cards.Set.Controller.showListLayout('description', 'up');" href=""></a>
</th>
</tr>
</thead>
......
Meteor.subscribe("cardsets");
Meteor.subscribe("cards");
Session.setDefault('cardsetSort', {
name: 1
});
Session.setDefault('cardsetSortCreated', {name: 1});
Session.setDefault('cardsetSortLearned', {name: 1});
/**
* ############################################################################
* created
......@@ -16,11 +14,30 @@ Template.created.helpers({
return Cardsets.find({
owner: Meteor.userId()
}, {
sort: Session.get('cardsetSort')
sort: Session.get('cardsetSortCreated')
});
}
});
Template.created.events({
'click #set-list-region .namedown': function() {
Session.set('cardsetSortCreated', {name: 1});
},
'click #set-list-region .nameup': function() {
Session.set('cardsetSortCreated', {name: -1});
},
'click #set-list-region .categorydown': function() {
Session.set('cardsetSortCreated', {category: 1});
},
'click #set-list-region .categoryup': function() {
Session.set('cardsetSortCreated', {category: -1});
}
});
Template.created.onDestroyed(function() {
Session.set('cardsetSortCreated', {name: 1});
});
/**
* ############################################################################
* learned
......@@ -43,10 +60,31 @@ Template.learned.helpers({
_id: {
$in: learnedCardsets
}
}, {
sort: Session.get('cardsetSortLearned')
});
}
});
Template.learned.events({
'click #learned-list-region .namedown': function() {
Session.set('cardsetSortLearned', {name: 1});
},
'click #learned-list-region .nameup': function() {
Session.set('cardsetSortLearned', {name: -1});
},
'click #learned-list-region .categorydown': function() {
Session.set('cardsetSortLearned', {category: 1});
},
'click #learned-list-region .categoryup': function() {
Session.set('cardsetSortLearned', {category: -1});
}
});
Template.created.onDestroyed(function() {
Session.set('cardsetSortLearned', {name: 1});
});
/**
* ############################################################################
* cardsets
......
......@@ -17,9 +17,19 @@
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><span>{{_ "pool.name"}}</span></th>
<th><span>{{_ "pool.description"}}</span></th>
<th><span>{{_ "pool.created"}}</span></th>
<th>
<span>{{_ "pool.name"}}</span>
<a class="namedown" role="button"></a>
<a class="nameup" role="button"></a>
</th>
<th>
<span>{{_ "pool.description"}}</span>
</th>
<th>
<span>{{_ "pool.created"}}</span>
<a class="createddown" role="button"></a>
<a class="createdup" role="button"></a>
</th>
</tr>
</thead>
<tbody id="cardSetsPool">
......
Meteor.subscribe("categories");
Meteor.subscribe("cardsets");
Session.setDefault('poolSort', {name: 1});
/**
* ############################################################################
* category
......@@ -13,10 +15,31 @@ Template.category.helpers({
return Cardsets.find({
category: id,
visible: true
}, {
sort: Session.get('poolSort')
});
}
});
Template.category.events({
'click #pool-category-region .namedown': function() {
Session.set('poolSort', {name: 1});
},
'click #pool-category-region .nameup': function() {
Session.set('poolSort', {name: -1});
},
'click #pool-category-region .createddown': function() {
Session.set('poolSort', {username: 1});
},
'click #pool-category-region .createdup': function() {
Session.set('poolSort', {username: -1});
}
});
Template.category.onDestroyed(function() {
Session.set('poolSort', {name: 1});
});
/**
* ############################################################################
* helpers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment