projects
/
featherfall2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e784c72
)
Allow empty attribute syntax to mean "same command as ID".
master
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Thu, 2 Oct 2014 15:57:32 +0000
(17:57 +0200)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Mon, 6 Oct 2014 23:17:23 +0000
(
01:17
+0200)
src/yuu/director.js
patch
|
blob
|
history
diff --git
a/src/yuu/director.js
b/src/yuu/director.js
index e9996deaa49a4b5c07da23d090dd6f5dec97403a..4aad9aa70beab352a1eb9d7d28305e5462096592 100644
(file)
--- a/
src/yuu/director.js
+++ b/
src/yuu/director.js
@@
-17,6
+17,13
@@
if (!yuu.InputState) require("./input");
if (!yuu.Material) require("./gfx");
if (!yuu.InputState) require("./input");
if (!yuu.Material) require("./gfx");
+ function getCommand (element) {
+ var command = element.getAttribute('data-yuu-command');
+ if (!command || command === 'data-yuu-command')
+ element.setAttribute('data-yuu-command', command = element.id);
+ return command;
+ }
+
yuu.Director = yT({
constructor: function (commandStack, input, tickHz) {
/** Manage and update a set of Scenes
yuu.Director = yT({
constructor: function (commandStack, input, tickHz) {
/** Manage and update a set of Scenes
@@
-564,7
+571,7
@@
var elements = element.querySelectorAll("[data-yuu-command]");
yf.each(function (element) {
var elements = element.querySelectorAll("[data-yuu-command]");
yf.each(function (element) {
- var command =
element.getAttribute("data-yuu-command"
);
+ var command =
getCommand(element
);
switch (element.tagName.toLowerCase()) {
case "input":
switch (element.type.toLowerCase()) {
switch (element.tagName.toLowerCase()) {
case "input":
switch (element.type.toLowerCase()) {
@@
-632,7
+639,7
@@
function handleElement (event) {
/*jshint validthis:true */
/* `this` comes from being a DOM element event handler. */
function handleElement (event) {
/*jshint validthis:true */
/* `this` comes from being a DOM element event handler. */
- var command =
this.getAttribute("data-yuu-command"
);
+ var command =
getCommand(this
);
switch (this.tagName.toLowerCase()) {
case "input":
switch (this.type.toLowerCase()) {
switch (this.tagName.toLowerCase()) {
case "input":
switch (this.type.toLowerCase()) {