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
 <template id="rpg-card">
3
 <template id="rpg-card">
4
     <style type='text/css'>
4
     <style type='text/css'>
5
         :host {
5
         :host {
6
-            /* Fill the whole area of the shadow root */
7
-            width: 100%;
8
-            height: 100%;
9
             /* Border */
6
             /* Border */
10
             padding: 6px;
7
             padding: 6px;
11
             border-radius: 4px;
8
             border-radius: 4px;
33
     <style type='text/css' id="color-style">
30
     <style type='text/css' id="color-style">
34
     </style>
31
     </style>
35
 
32
 
33
+    <style type='text/css' id="card-size">
34
+        :host{width: 2.5in;height: 3.5in;}
35
+    </style>
36
+
36
     <content></content>
37
     <content></content>
37
 
38
 
38
 </template>
39
 </template>
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
         proto.createdCallback = function () {
94
         proto.createdCallback = function () {
76
             var template = importDoc.getElementById(elemName);
95
             var template = importDoc.getElementById(elemName);
77
             var clone = mainDoc.importNode(template.content, true);
96
             var clone = mainDoc.importNode(template.content, true);
79
             root.appendChild(clone);
98
             root.appendChild(clone);
80
 
99
 
81
             this.color = this.getAttribute('color') || "black";
100
             this.color = this.getAttribute('color') || "black";
101
+            this.size = this.getAttribute('size') || "25x35";
82
         }
102
         }
83
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
103
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
84
             switch (name) {
104
             switch (name) {
85
                 case "color": this.color = newValue; break;
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
     result += ' int="' + (parseInt(params[3], 10) || "") + '"';
153
     result += ' int="' + (parseInt(params[3], 10) || "") + '"';
154
     result += ' wis="' + (parseInt(params[4], 10) || "") + '"';
154
     result += ' wis="' + (parseInt(params[4], 10) || "") + '"';
155
     result += ' cha="' + (parseInt(params[5], 10) || "") + '"';
155
     result += ' cha="' + (parseInt(params[5], 10) || "") + '"';
156
-    result += '><card-dndstats>';
156
+    result += '></card-dndstats>';
157
     return result;
157
     return result;
158
 }
158
 }
159
 
159
 
230
     var color = card_data_color_front(data, options);
230
     var color = card_data_color_front(data, options);
231
 
231
 
232
     var result = "";
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
     result += card_element_title(data, options);
234
     result += card_element_title(data, options);
235
     result += card_generate_contents(data.contents, data, options);
235
     result += card_generate_contents(data.contents, data, options);
236
     result += '</rpg-card>';
236
     result += '</rpg-card>';
242
     var icon = card_data_icon_back(data, options) + ".svg";
242
     var icon = card_data_icon_back(data, options) + ".svg";
243
 
243
 
244
     var result = "";
244
     var result = "";
245
-    result += '<rpg-card color="' + color + '">';
245
+    result += '<rpg-card color="' + color + '" size="' + options.card_size + '">';
246
     result += '   <card-back>';
246
     result += '   <card-back>';
247
     result += '       <card-icon src="/icons/' + icon + '"></card-icon>';
247
     result += '       <card-icon src="/icons/' + icon + '"></card-icon>';
248
     result += '   </card-back>';
248
     result += '   </card-back>';
254
     var style_color = card_generate_color_style("white");
254
     var style_color = card_generate_color_style("white");
255
 
255
 
256
     var result = "";
256
     var result = "";
257
-    result += '<rpg-card color="' + color + '">';
257
+    result += '<rpg-card color="' + color + '" size="' + options.card_size + '">';
258
     result += '</rpg-card>';
258
     result += '</rpg-card>';
259
     return card_repeat(result, count);
259
     return card_repeat(result, count);
260
 }
260
 }

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

6
     <script type="text/javascript" src="js/output.js"></script>
6
     <script type="text/javascript" src="js/output.js"></script>
7
     <!-- CSS -->
7
     <!-- CSS -->
8
     <link rel=" stylesheet" type="text/css" href="css/output.css">
8
     <link rel=" stylesheet" type="text/css" href="css/output.css">
9
-    <link rel="stylesheet" type="text/css" href="css/cards.css">
10
     <link rel="stylesheet" type="text/css" href="css/card-size.css">
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
 </head>
12
 </head>
17
 <body class="page-background">
13
 <body class="page-background">
18
 </body>
14
 </body>

正在加载...
取消
保存