Skip to content

Commit

Permalink
FIX: Updating attire when anything changes
Browse files Browse the repository at this point in the history
  • Loading branch information
afska committed Feb 8, 2017
1 parent b8575ca commit 711306e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
21 changes: 10 additions & 11 deletions dist/components/gs-cell.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@
rowIndex: Number,
cell: Object,
table: Array,
attire: {
type: Object,
notify: "_updateStyles"
},
attire: Object,
boom: Boolean,
backgroundUrl: String,
header: {
Expand All @@ -110,10 +107,9 @@
listeners: {
click: "_leftClick"
},
observers: ['_updateStyles(attire.enabled)'],
observers: ['_updateStyles(table.*, attire.*, rowIndex, cellIndex, boom)'],
ready: function() {
this._validateData();
return this._updateStyles();
return this._validateData();
},
cssClass: function(header) {
var theHeaderIsHere;
Expand Down Expand Up @@ -162,10 +158,13 @@
throw new Error("The coordinates are required");
}
},
_updateStyles: function() {
var url;
url = this.$.dresser.getImage(this.cell, this.attire);
this.customStyle["--stones-visibility"] = (url != null) || this.boom ? "hidden" : "visible";
_updateStyles: function(_arg, _arg1, rowIndex, cellIndex, boom) {
var attire, cell, table, url;
table = _arg.base;
attire = _arg1.base;
cell = table[rowIndex][cellIndex];
url = this.$.dresser.getImage(cell, attire);
this.customStyle["--stones-visibility"] = (url != null) || boom ? "hidden" : "visible";
if (url != null) {
this.customStyle["--background-url"] = "url(" + url + ")";
} else {
Expand Down
2 changes: 1 addition & 1 deletion dist/gs-board.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gs-board",
"version": "1.2.0",
"version": "1.2.1",
"dependencies": {},
"devDependencies": {
"connect-livereload": "^0.4.0",
Expand Down
14 changes: 6 additions & 8 deletions src/components/gs-cell/script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ Polymer
rowIndex: Number
cell: Object
table: Array
attire:
type: Object
notify: "_updateStyles"
attire: Object
boom: Boolean
backgroundUrl: String
header:
Expand All @@ -20,12 +18,11 @@ Polymer
click: "_leftClick"

observers: [
'_updateStyles(attire.enabled)'
'_updateStyles(table.*, attire.*, rowIndex, cellIndex, boom)'
]

ready: ->
@_validateData()
@_updateStyles()

cssClass: (header) ->
return "" if not header?
Expand All @@ -51,10 +48,11 @@ Polymer
throw new Error("The cell is required") if not @cell?
throw new Error("The coordinates are required") if not @cellIndex? or not @rowIndex?

_updateStyles: ->
url = @$.dresser.getImage @cell, @attire
_updateStyles: ({ base: table }, { base: attire }, rowIndex, cellIndex, boom) ->
cell = table[rowIndex][cellIndex]
url = @$.dresser.getImage cell, attire

@customStyle["--stones-visibility"] = if url? or @boom then "hidden" else "visible"
@customStyle["--stones-visibility"] = if url? or boom then "hidden" else "visible"
if url? then @customStyle["--background-url"] = "url(#{url})"
else delete @customStyle["--background-url"]

Expand Down

0 comments on commit 711306e

Please sign in to comment.