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
0c8ac082
Commit
0c8ac082
authored
Nov 24, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Making acid and aside real js objects
and changing test code for aside to check type of block dom
parent
f8faad69
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
29 deletions
+53
-29
acid/acid.py
+1
-1
acid/static/html/aside.html.mako
+1
-0
acid/static/js/acid.js
+51
-28
No files found.
acid/acid.py
View file @
0c8ac082
...
...
@@ -285,7 +285,7 @@ class AcidAside(XBlockAside, AcidSharedMixin):
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid.js'
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/acid.css"
))
frag
.
add_css_url
(
'//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'
)
frag
.
initialize_js
(
'Acid
Block'
)
frag
.
initialize_js
(
'Acid
AsideBlock'
,
{
'test_aside'
:
isinstance
(
block
,
AcidBlock
)}
)
return
frag
...
...
acid/static/html/aside.html.mako
View file @
0c8ac082
...
...
@@ -56,4 +56,5 @@
</tr>
% endfor
</table>
<p>Sees Acid DOM: <span class="acid-dom"><i class="${unknown_class}"></i></span></p>
</div>
acid/static/js/acid.js
View file @
0c8ac082
/* Javascript for the Acid XBlock. */
function
AcidBlock
(
runtime
,
element
)
{
this
.
runtime
=
runtime
;
this
.
element
=
element
;
function
acidData
(
key
)
{
return
$
(
'.acid-block, .aside-block'
,
element
).
data
(
key
);
}
this
.
mark
(
'success'
,
'.js-init-run'
,
$
(
element
));
this
.
resourceTests
();
this
.
scopeTests
();
}
function
mark
(
result
,
selector
,
subelem
,
msg
)
{
acid_update_status
(
selector
,
subelem
,
element
,
msg
,
acidData
(
result
+
'-class'
),
acidData
(
'error-class'
)
);
}
AcidBlock
.
prototype
=
{
acidData
:
function
(
key
)
{
return
$
(
'.acid-block, .aside-block'
,
this
.
element
).
data
(
key
);
}
,
function
resourceTests
()
{
$
.
get
(
acidData
(
'local-resource-url'
))
mark
:
function
(
result
,
selector
,
subelem
,
msg
)
{
acid_update_status
(
selector
,
subelem
,
this
.
element
,
msg
,
this
.
acidData
(
result
+
'-class'
),
this
.
acidData
(
'error-class'
));
},
resourceTests
:
function
()
{
var
that
=
this
;
$
.
get
(
this
.
acidData
(
'local-resource-url'
))
.
fail
(
function
()
{
mark
(
'failure'
,
'.local-resource-test'
,
element
,
'Unable to load local resource'
);
that
.
mark
(
'failure'
,
'.local-resource-test'
,
that
.
element
,
'Unable to load local resource'
);
})
.
done
(
function
(
data
)
{
if
(
data
.
test_data
===
'success'
)
{
mark
(
'success'
,
'.local-resource-test'
);
that
.
mark
(
'success'
,
'.local-resource-test'
,
$
(
that
.
element
)
);
}
else
{
mark
(
'failure'
,
'.local-resource-test'
,
element
,
'Data mismatch'
);
that
.
mark
(
'failure'
,
'.local-resource-test'
,
that
.
element
,
'Data mismatch'
);
}
});
}
}
,
function
scopeTests
()
{
$
(
'.scope-storage-test'
,
element
).
each
(
function
()
{
scopeTests
:
function
()
{
var
that
=
this
;
$
(
'.scope-storage-test'
,
this
.
element
).
each
(
function
()
{
var
$this
=
$
(
this
);
$
.
ajaxq
(
"acid-queue"
,
{
type
:
"POST"
,
data
:
{
"VALUE"
:
$this
.
data
(
'value'
)},
url
:
$this
.
data
(
'handler-url'
),
context
:
that
,
success
:
function
(
ret
)
{
mark
(
'success'
,
'.server-storage-test-returned'
,
$this
);
this
.
mark
(
'success'
,
'.server-storage-test-returned'
,
$this
);
if
(
ret
.
status
===
"ok"
)
{
mark
(
'success'
,
'.server-storage-test-succeeded'
,
$this
);
this
.
mark
(
'success'
,
'.server-storage-test-succeeded'
,
$this
);
$
.
ajaxq
(
"acid-queue"
,
{
type
:
"POST"
,
data
:
{
"VALUE"
:
ret
.
value
},
url
:
runtime
.
handlerUrl
(
element
,
"check_storage"
,
ret
.
suffix
,
ret
.
query
),
url
:
this
.
runtime
.
handlerUrl
(
this
.
element
,
"check_storage"
,
ret
.
suffix
,
ret
.
query
),
context
:
this
,
success
:
function
(
ret
)
{
mark
(
'success'
,
'.client-storage-test-returned'
,
$this
);
this
.
mark
(
'success'
,
'.client-storage-test-returned'
,
$this
);
if
(
ret
.
status
===
"ok"
)
{
mark
(
'success'
,
'.client-storage-test-succeeded'
,
$this
);
this
.
mark
(
'success'
,
'.client-storage-test-succeeded'
,
$this
);
}
else
{
mark
(
'failure'
,
'.client-storage-test-succeeded'
,
$this
,
ret
.
message
);
this
.
mark
(
'failure'
,
'.client-storage-test-succeeded'
,
$this
,
ret
.
message
);
}
}
});
}
else
{
mark
(
'failure'
,
'.server-storage-test-succeeded'
,
$this
,
ret
.
message
);
this
.
mark
(
'failure'
,
'.server-storage-test-succeeded'
,
$this
,
ret
.
message
);
}
}
});
});
}
};
mark
(
'success'
,
'.js-init-run'
);
resourceTests
();
scopeTests
();
return
{
parentValue
:
acidData
(
'parent-value'
)};
function
AcidAsideBlock
(
runtime
,
element
,
block_element
,
init_args
)
{
AcidBlock
.
call
(
this
,
runtime
,
element
);
this
.
block_element
=
block_element
;
this
.
test_aside
=
init_args
[
'test_aside'
]
this
.
runTests
();
}
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
));
}
}
}
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