Commit d29b5a19 authored by Curtis Adam's avatar Curtis Adam

Refactor the card modals

parent 5524bc20
......@@ -88,103 +88,6 @@
</div>
</template>
<template name="copyCard">
<div class="modal fade" id="showCopyCardModal" role="dialog">
<div class="modal-dialog" aria-labelledby="showHintTitle">
<div class="modal-content">
<div class="modal-header">
<h4 id="showHintTitle" class="modal-title">{{_ "copyCardTitle"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-12">
{{_ "copyCardText"}}
<br>
<br>
<table class="table table-hover table-bordered cardListSubject">
<thead>
<tr>
<th>
<span>{{_ "navbar-collapse.carddecks"}}</span>
</th>
</tr>
</thead>
<tbody>
{{#each cardsetList}}
<tr>
<td class="copyCardset" data-id="{{this._id}}">
<a href="#" data-id="{{this._id}}">
{{this.name}}
</a>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<template name="cancelEditForm">
<div class="modal fade" id="cancelEditModal" tabindex="-1" role="dialog"
aria-labelledby="deleteCardsTitle">
<div class="modal-dialog">
<div class="modal-content modal-content-for-buttons">
<div class="modal-header">
<h4 id="cancelEditTitle" class="modal-title">{{_ "modal-dialog.cancelEditCardTitle"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
{{_ "modal-dialog.cancelEditCard"}}
<button id="cancelEditConfirm" class="btn btn-raised btn-danger btn-block col-xs-12 col-sm-3">{{_
"modal-dialog.cancelEditCardTitle"}}</button>
<button id="cancelEditDismiss" class="btn btn-raised btn-default btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</template>
<template name="deleteCardForm">
<div class="modal fade" id="deleteCardModal" tabindex="-1" role="dialog"
aria-labelledby="deleteCardTitle">
<div class="modal-dialog">
<div class="modal-content modal-content-for-buttons">
<div class="modal-header">
<h4 id="deleteCardTitle" class="modal-title">{{_ "deletecard"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
{{_ "modal-dialog.deleteCard"}}
<button id="deleteCardConfirm" class="btn btn-raised btn-danger btn-block col-xs-12 col-sm-3">{{_
"deletecard"}}</button>
<button id="deleteCardDismiss" class="btn btn-raised btn-default btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</template>
<template name="cardSubject">
{{#if gotLearningUnit}}<a class="cardHeaderLink"
href="/cardset/{{getLearningIndex}}/card/{{getLearningUnit}}"
......
......@@ -21,6 +21,8 @@ import './navigation/navigation.js';
import './modal/settings.js';
import "./modal/beolingusTranslation.js";
import "./modal/deeplTranslation.js";
import "./modal/deleteCard.js";
import "./modal/copyCard.js";
import "./card.html";
/*
......@@ -180,24 +182,6 @@ Template.flashcardsEnd.onRendered(function () {
$('.carousel-inner').css('min-height', 0);
});
/*
* ############################################################################
* copyCard
* ############################################################################
*/
Template.copyCard.helpers({
cardsetList: function () {
return Cardsets.find({
owner: Meteor.userId(),
shuffled: false,
_id: {$nin: [Router.current().params._id]}
}, {
fields: {name: 1},
sort: {name: 1}
});
}
});
Template.copyCard.events({
"click .copyCardset": function (evt) {
......@@ -212,53 +196,6 @@ Template.copyCard.events({
}
});
/*
* ############################################################################
* cancelEditForm
* ############################################################################
*/
Template.cancelEditForm.events({
'click #cancelEditConfirm': function () {
$('#cancelEditModal').on('hidden.bs.modal', function () {
Session.set('activeCard', Router.current().params.card_id);
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}).modal('hide');
}
});
/*
* ############################################################################
* deleteCardForm
* ############################################################################
*/
Template.deleteCardForm.events({
'click #deleteCardConfirm': function () {
Meteor.call("deleteCard", Session.get('activeCard'), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('deletecardSuccess'), "success", 'growl-top-left');
$('#deleteCardModal').modal('hide');
$('.modal-backdrop').css('display', 'none');
Session.set('activeCard', undefined);
$('#deleteCardModal').on('hidden.bs.modal', function () {
$('.deleteCard').removeClass("pressed");
if (Route.isEditMode()) {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
} else {
CardVisuals.resizeFlashcard();
CardNavigation.selectButton();
}
});
}
});
}
});
/*
* ############################################################################
* cardSubject
......
......@@ -7,6 +7,7 @@ import {CardVisuals} from "../../../api/cardVisuals";
import ResizeSensor from "../../../../client/thirdParty/resizeSensor/ResizeSensor";
import {Cards} from "../../../api/cards";
import "../card.js";
import "./modal/cancelEdit.js";
import "./modal/learningUnit.js";
import "./item/buttonCancel.js";
import "./item/buttonSave.js";
......
<template name="cancelEditForm">
<div class="modal fade" id="cancelEditModal" tabindex="-1" role="dialog"
aria-labelledby="deleteCardsTitle">
<div class="modal-dialog">
<div class="modal-content modal-content-for-buttons">
<div class="modal-header">
<h4 id="cancelEditTitle" class="modal-title">{{_ "modal-dialog.cancelEditCardTitle"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
{{_ "modal-dialog.cancelEditCard"}}
<button id="cancelEditConfirm" class="btn btn-raised btn-danger btn-block col-xs-12 col-sm-3">{{_
"modal-dialog.cancelEditCardTitle"}}</button>
<button id="cancelEditDismiss" class="btn btn-raised btn-default btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</template>
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import "./cancelEdit.html";
/*
* ############################################################################
* cancelEditForm
* ############################################################################
*/
Template.cancelEditForm.events({
'click #cancelEditConfirm': function () {
$('#cancelEditModal').on('hidden.bs.modal', function () {
Session.set('activeCard', Router.current().params.card_id);
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}).modal('hide');
}
});
<template name="copyCard">
<div class="modal fade" id="showCopyCardModal" role="dialog">
<div class="modal-dialog" aria-labelledby="showHintTitle">
<div class="modal-content">
<div class="modal-header">
<h4 id="showHintTitle" class="modal-title">{{_ "copyCardTitle"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-12">
{{_ "copyCardText"}}
<br>
<br>
<table class="table table-hover table-bordered cardListSubject">
<thead>
<tr>
<th>
<span>{{_ "navbar-collapse.carddecks"}}</span>
</th>
</tr>
</thead>
<tbody>
{{#each cardsetList}}
<tr>
<td class="copyCardset" data-id="{{this._id}}">
<a href="#" data-id="{{this._id}}">
{{this.name}}
</a>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
import {Template} from "meteor/templating";
import {Cardsets} from "../../../api/cardsets";
import {Meteor} from "meteor/meteor";
import "./copyCard.html";
/*
* ############################################################################
* copyCard
* ############################################################################
*/
Template.copyCard.helpers({
cardsetList: function () {
return Cardsets.find({
owner: Meteor.userId(),
shuffled: false,
_id: {$nin: [Router.current().params._id]}
}, {
fields: {name: 1},
sort: {name: 1}
});
}
});
<template name="deleteCardForm">
<div class="modal fade" id="deleteCardModal" tabindex="-1" role="dialog"
aria-labelledby="deleteCardTitle">
<div class="modal-dialog">
<div class="modal-content modal-content-for-buttons">
<div class="modal-header">
<h4 id="deleteCardTitle" class="modal-title">{{_ "deletecard"}}
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</h4>
</div>
<div class="modal-body">
{{_ "modal-dialog.deleteCard"}}
<button id="deleteCardConfirm" class="btn btn-raised btn-danger btn-block col-xs-12 col-sm-3">{{_
"deletecard"}}</button>
<button id="deleteCardDismiss" class="btn btn-raised btn-default btn-block col-xs-12 col-sm-3"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</template>
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {BertAlertVisuals} from "../../../api/bertAlertVisuals";
import {Route} from "../../../api/route";
import {CardVisuals} from "../../../api/cardVisuals";
import {CardNavigation} from "../../../api/cardNavigation";
import "./deleteCard.html";
/*
* ############################################################################
* deleteCardForm
* ############################################################################
*/
Template.deleteCardForm.events({
'click #deleteCardConfirm': function () {
Meteor.call("deleteCard", Session.get('activeCard'), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('deletecardSuccess'), "success", 'growl-top-left');
$('#deleteCardModal').modal('hide');
$('.modal-backdrop').css('display', 'none');
Session.set('activeCard', undefined);
$('#deleteCardModal').on('hidden.bs.modal', function () {
$('.deleteCard').removeClass("pressed");
if (Route.isEditMode()) {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
} else {
CardVisuals.resizeFlashcard();
CardNavigation.selectButton();
}
});
}
});
}
});
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