1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-11-23 19:36:53 +00:00
This commit is contained in:
exane 2015-07-03 18:48:37 +02:00
parent 4b26af7db1
commit 1e85167c6f
3 changed files with 32 additions and 8 deletions

View File

@ -398,9 +398,9 @@ let BattleView = Backbone.View.extend({
}, },
onMouseover: function(e){ onMouseover: function(e){
let target = $(e.target).closest(".card"); let target = $(e.target).closest(".card");
//this.user.set("showPreview", target.find("img").attr("src")); var hasPreviewB = target.parent().hasClass("preview-b");
//this.user.set("showPreview", target.data().key);
this.user.set("showPreview", new Preview({key: target.data().key})); this.user.set("showPreview", new Preview({key: target.data().key, previewB: hasPreviewB}));
}, },
onMouseleave: function(e){ onMouseleave: function(e){
this.user.get("showPreview").remove(); this.user.get("showPreview").remove();
@ -837,6 +837,24 @@ let User = Backbone.Model.extend({
this.get("app").send("response:chooseWhichSideBegins", { this.get("app").send("response:chooseWhichSideBegins", {
side: roomSide side: roomSide
}) })
},
getCardData: function(card) {
if(!card || !card.ability) return;
var abilities;
if(Array.isArray(card.ability)){
abilities = card.ability.slice();
}
else {
abilities = [];
abilities.push(card.ability);
}
abilities = abilities.map((ability) => {
return abilityData[ability].description;
})
return abilities;
} }
}); });
@ -905,6 +923,10 @@ let Preview = Backbone.View.extend({
template: require("../templates/preview.handlebars"), template: require("../templates/preview.handlebars"),
initialize: function(opt){ initialize: function(opt){
this.card = cardData[opt.key]; this.card = cardData[opt.key];
this.size = opt.size || "lg";
this.previewB = opt.previewB || false;
this.$el.addClass(this.previewB ? "preview-b" : "");
if(!this.card || !this.card.ability) return; if(!this.card || !this.card.ability) return;
@ -916,7 +938,7 @@ let Preview = Backbone.View.extend({
this.abilities.push(this.card.ability); this.abilities.push(this.card.ability);
} }
this.abilities = this.abilities.map((ability) =>{ this.abilities = this.abilities.map((ability) => {
return abilityData[ability].description; return abilityData[ability].description;
}) })
@ -925,7 +947,9 @@ let Preview = Backbone.View.extend({
render: function(){ render: function(){
let html = this.template({ let html = this.template({
card: this.card, card: this.card,
abilities: this.abilities abilities: this.abilities,
size: this.size,
previewB: this.previewB
}) })
this.$el.html(html); this.$el.html(html);
return this; return this;

View File

@ -2,7 +2,7 @@
<h3 class="bbm-modal__title">Choose up to 2 cards you wish to redraw!</h3> <h3 class="bbm-modal__title">Choose up to 2 cards you wish to redraw!</h3>
<span class="btn-sub bbm-close">CLOSE</span> <span class="btn-sub bbm-close">CLOSE</span>
</div> </div>
<div class="bbm-modal__section"> <div class="bbm-modal__section preview-b">
{{#each handCards as |val key|}} {{#each handCards as |val key|}}
{{>card val}} {{>card val}}
{{/each}} {{/each}}

View File

@ -1,5 +1,5 @@
<i class="card-lg-{{card.faction}} card-lg-{{card.faction}}-{{card.img}}"></i> <i class="card-{{this.size}}-{{card.faction}} card-{{this.size}}-{{card.faction}}-{{card.img}}"></i>
<div class="preview-description"> <div class="preview-description {{#if previewB}}preview-b{{/if}}">
<p>{{card.name}}</p> <p>{{card.name}}</p>
{{#each abilities as |val key|}} {{#each abilities as |val key|}}
<p>{{val}}</p> <p>{{val}}</p>