crobi 10 年之前
父節點
當前提交
00190e586a
共有 3 個文件被更改,包括 30 次插入13 次删除
  1. 24
    3
      generator/components/rpg-card.html
  2. 4
    4
      generator/js/cards.js
  3. 2
    6
      generator/output.html

+ 24
- 3
generator/components/rpg-card.html 查看文件

@@ -3,9 +3,6 @@
3 3
 <template id="rpg-card">
4 4
     <style type='text/css'>
5 5
         :host {
6
-            /* Fill the whole area of the shadow root */
7
-            width: 100%;
8
-            height: 100%;
9 6
             /* Border */
10 7
             padding: 6px;
11 8
             border-radius: 4px;
@@ -33,6 +30,10 @@
33 30
     <style type='text/css' id="color-style">
34 31
     </style>
35 32
 
33
+    <style type='text/css' id="card-size">
34
+        :host{width: 2.5in;height: 3.5in;}
35
+    </style>
36
+
36 37
     <content></content>
37 38
 
38 39
 </template>
@@ -72,6 +73,24 @@
72 73
                 ";
73 74
             }
74 75
         });
76
+        Object.defineProperty(proto, "size", {
77
+            get: function () {
78
+                return "";
79
+            },
80
+            set: function (value) {
81
+                var root = this.shadowRoot;
82
+                var style = root.getElementById("card-size");
83
+                switch (value) {
84
+                    case "full": style.innerHTML = ":host{width:100%;height:100%;}"; break;
85
+                    case "25x35": style.innerHTML = ":host{width: 2.5in;height: 3.5in;}"; break;
86
+                    case "225x35": style.innerHTML = ":host{width: 2.25in;height: 3.5in;}"; break;
87
+                    case "25x50": style.innerHTML = ":host{width: 2.5in;height: 5.0in;}"; break;
88
+                    case "35x50": style.innerHTML = ":host{width: 3.5in;height: 5.0in;}"; break;
89
+                    case "75x50": style.innerHTML = ":host{width: 7.5in;height: 5.0in;}"; break;
90
+                }
91
+                
92
+            }
93
+        });
75 94
         proto.createdCallback = function () {
76 95
             var template = importDoc.getElementById(elemName);
77 96
             var clone = mainDoc.importNode(template.content, true);
@@ -79,10 +98,12 @@
79 98
             root.appendChild(clone);
80 99
 
81 100
             this.color = this.getAttribute('color') || "black";
101
+            this.size = this.getAttribute('size') || "25x35";
82 102
         }
83 103
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
84 104
             switch (name) {
85 105
                 case "color": this.color = newValue; break;
106
+                case "size": this.size = newValue; break;
86 107
             }
87 108
         }
88 109
 

+ 4
- 4
generator/js/cards.js 查看文件

@@ -153,7 +153,7 @@ function card_element_dndstats(params, card_data, options) {
153 153
     result += ' int="' + (parseInt(params[3], 10) || "") + '"';
154 154
     result += ' wis="' + (parseInt(params[4], 10) || "") + '"';
155 155
     result += ' cha="' + (parseInt(params[5], 10) || "") + '"';
156
-    result += '><card-dndstats>';
156
+    result += '></card-dndstats>';
157 157
     return result;
158 158
 }
159 159
 
@@ -230,7 +230,7 @@ function card_generate_front(data, options) {
230 230
     var color = card_data_color_front(data, options);
231 231
 
232 232
     var result = "";
233
-    result += '<rpg-card color="' + color + '" class="card-size-' + options.card_size + '">';
233
+    result += '<rpg-card color="' + color + '" size="' + options.card_size + '">';
234 234
     result += card_element_title(data, options);
235 235
     result += card_generate_contents(data.contents, data, options);
236 236
     result += '</rpg-card>';
@@ -242,7 +242,7 @@ function card_generate_back(data, options) {
242 242
     var icon = card_data_icon_back(data, options) + ".svg";
243 243
 
244 244
     var result = "";
245
-    result += '<rpg-card color="' + color + '">';
245
+    result += '<rpg-card color="' + color + '" size="' + options.card_size + '">';
246 246
     result += '   <card-back>';
247 247
     result += '       <card-icon src="/icons/' + icon + '"></card-icon>';
248 248
     result += '   </card-back>';
@@ -254,7 +254,7 @@ function card_generate_empty(count, options) {
254 254
     var style_color = card_generate_color_style("white");
255 255
 
256 256
     var result = "";
257
-    result += '<rpg-card color="' + color + '">';
257
+    result += '<rpg-card color="' + color + '" size="' + options.card_size + '">';
258 258
     result += '</rpg-card>';
259 259
     return card_repeat(result, count);
260 260
 }

+ 2
- 6
generator/output.html 查看文件

@@ -6,13 +6,9 @@
6 6
     <script type="text/javascript" src="js/output.js"></script>
7 7
     <!-- CSS -->
8 8
     <link rel=" stylesheet" type="text/css" href="css/output.css">
9
-    <link rel="stylesheet" type="text/css" href="css/cards.css">
10 9
     <link rel="stylesheet" type="text/css" href="css/card-size.css">
11
-    <link rel="stylesheet" type="text/css" href="css/icons.css">
12
-    <link rel="stylesheet" type="text/css" href="css/custom-icons.css">
13
-    <!-- Fonts -->
14
-    <link href='https://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
15
-    <link href='https://fonts.googleapis.com/css?family=Lora:700' rel='stylesheet' type='text/css'>
10
+    <!-- Components -->
11
+    <link rel="import" href="components/card.html">
16 12
 </head>
17 13
 <body class="page-background">
18 14
 </body>

Loading…
取消
儲存