Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
acid-block
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
acid-block
Commits
5bbb4a22
Commit
5bbb4a22
authored
Nov 25, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make acid_parent use js subclassing
and get it to work.
parent
2921b892
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
30 deletions
+40
-30
acid/static/js/acid.js
+13
-6
acid/static/js/acid_parent.js
+27
-24
No files found.
acid/static/js/acid.js
View file @
5bbb4a22
/* Javascript for the Acid XBlock. */
function
AcidBlock
(
runtime
,
element
)
{
function
AcidBlock
(
runtime
,
element
,
fields
)
{
this
.
runtime
=
runtime
;
this
.
element
=
element
;
if
(
fields
&&
fields
.
acid_data_ele
)
{
this
.
acid_data_ele
=
fields
.
acid_data_ele
;
}
else
{
this
.
acid_data_ele
=
$
(
this
.
element
).
children
(
'div[data-error-class]'
)[
0
];
}
this
.
type
=
$
(
element
).
data
(
'block-type'
)
this
.
mark
(
'success'
,
'.js-init-run'
,
$
(
element
));
this
.
resourceTests
();
...
...
@@ -10,7 +17,7 @@ function AcidBlock(runtime, element) {
AcidBlock
.
prototype
=
{
acidData
:
function
(
key
)
{
return
$
(
'.acid-block, .aside-block'
,
this
.
element
).
data
(
key
);
return
$
(
this
.
acid_data_ele
).
data
(
key
);
},
mark
:
function
(
result
,
selector
,
subelem
,
msg
)
{
...
...
@@ -35,7 +42,7 @@ AcidBlock.prototype = {
scopeTests
:
function
()
{
var
that
=
this
;
$
(
'.scope-storage-test'
,
this
.
element
).
each
(
function
()
{
$
(
'.scope-storage-test'
,
this
.
acid_data_ele
).
each
(
function
()
{
var
$this
=
$
(
this
);
$
.
ajaxq
(
"acid-queue"
,
{
type
:
"POST"
,
...
...
@@ -71,6 +78,7 @@ AcidBlock.prototype = {
}
};
function
AcidAsideBlock
(
runtime
,
element
,
block_element
,
init_args
)
{
AcidBlock
.
call
(
this
,
runtime
,
element
);
this
.
block_element
=
block_element
;
...
...
@@ -81,14 +89,13 @@ function AcidAsideBlock(runtime, element, block_element, init_args) {
)
this
.
runTests
();
}
AcidAsideBlock
.
prototype
=
Object
.
create
(
AcidBlock
.
prototype
)
AcidAsideBlock
.
prototype
=
Object
.
create
(
AcidBlock
.
prototype
)
;
AcidAsideBlock
.
prototype
.
runTests
=
function
()
{
if
(
this
.
test_aside
)
{
if
(
this
.
block_element
.
data
(
'block-type'
)
===
'acid'
)
{
this
.
mark
(
'success'
,
'.acid-dom'
,
$
(
this
.
element
));
// AcidBlock.prototype.mark.call(this, 'success', '.acid-dom', $(element));
}
else
{
AcidBlock
.
prototype
.
mark
.
call
(
this
,
'failure'
,
'.acid-dom'
,
$
(
this
.
element
));
this
.
mark
(
'failure'
,
'.acid-dom'
,
$
(
this
.
element
));
}
}
}
acid/static/js/acid_parent.js
View file @
5bbb4a22
/* Javascript for the Acid XBlock. */
function
AcidParentBlock
(
runtime
,
element
)
{
// this looks like but isn't really a subclass of AcidBlock
this
.
runtime
=
runtime
;
this
.
element
=
element
;
this
.
type
=
$
(
element
).
data
(
'block-type'
);
function
acidData
(
key
)
{
return
$
(
'.acid-parent-block'
,
element
).
data
(
key
);
}
var
acid_frag_dom
=
$
(
"> div > .acid-block"
,
element
);
this
.
acid_frag
=
new
AcidBlock
(
runtime
,
element
,
{
acid_data_ele
:
acid_frag_dom
});
this
.
childTests
();
}
function
mark
(
result
,
selector
,
subelem
,
msg
)
{
acid_update_status
(
selector
,
subelem
,
element
,
msg
,
acidData
(
result
+
'-class'
),
acidData
(
'error-class'
)
);
}
AcidParentBlock
.
prototype
=
{
acidData
:
function
(
key
)
{
return
$
(
this
.
element
).
children
(
'div[data-'
+
key
+
']'
).
data
(
key
);
}
,
function
childTests
()
{
var
acidChildCount
=
runtime
.
children
(
element
).
filter
(
function
(
child
)
{
return
child
.
type
==
"acid"
;
mark
:
function
(
result
,
selector
,
subelem
,
msg
)
{
acid_update_status
(
selector
,
subelem
,
this
.
element
,
msg
,
this
.
acidData
(
result
+
'-class'
),
this
.
acidData
(
'error-class'
));
},
childTests
:
function
(){
var
acidChildCount
=
this
.
runtime
.
children
(
this
.
element
).
filter
(
function
(
child
)
{
return
child
.
type
===
"acid"
;
}).
length
;
if
(
acidData
(
'acid-child-count'
)
==
acidChildCount
)
{
mark
(
'success'
,
'.child-counts-match'
);
}
var
childValues
=
JSON
.
parse
(
$
(
'.acid-child-values'
,
element
).
html
());
this
.
mark
((
this
.
acidData
(
'acid-child-count'
)
==
acidChildCount
)
?
'success'
:
'failure'
,
'.child-counts-match'
);
var
childValues
=
JSON
.
parse
(
$
(
'.acid-child-values'
,
this
.
element
).
html
());
var
that
=
this
;
$
.
each
(
childValues
,
function
(
name
,
value
)
{
var
child_value
=
runtime
.
childMap
(
element
,
name
).
parentValue
;
var
child_value
=
that
.
runtime
.
childMap
(
that
.
element
,
name
).
parentValue
;
if
(
child_value
!==
value
)
{
mark
(
'failure'
,
'.child-values-match'
,
element
,
that
.
mark
(
'failure'
,
'.child-values-match'
,
that
.
element
,
'Child '
+
name
+
' had value '
+
child_value
+
' but expected '
+
value
);
return
;
}
});
mark
(
'success'
,
'.child-values-match'
);
this
.
mark
(
'success'
,
'.child-values-match'
);
}
AcidBlock
(
runtime
,
element
);
childTests
();
return
{
parentValue
:
acidData
(
'parent-value'
)};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment