Commit e27df938 by TJ Keemon

added studio view to edit audio source

parent 1fbf19cc
...@@ -35,6 +35,28 @@ class AudioXBlock(XBlock): ...@@ -35,6 +35,28 @@ class AudioXBlock(XBlock):
frag.add_css(self.resource_string("static/css/audio.css")) frag.add_css(self.resource_string("static/css/audio.css"))
return frag return frag
def studio_view(self, context):
"""
The view for editing the AudioXBlock parameters inside Studio.
"""
html = self.resource_string("static/html/audio_edit.html")
frag = Fragment(html.format(src=self.src))
js = self.resource_string("static/js/src/audio_edit.js")
frag.add_javascript(js)
frag.initialize_js('AudioEditBlock')
return frag
@XBlock.json_handler
def studio_submit(self, data, suffix=''):
"""
Called when submitting the form in Studio.
"""
self.src = data.get('src')
return {'result': 'success'}
# TO-DO: change this to create the scenarios you'd like to see in the # TO-DO: change this to create the scenarios you'd like to see in the
# workbench while developing your XBlock. # workbench while developing your XBlock.
@staticmethod @staticmethod
......
<div class="wrapper-comp-settings is-active editor-with-buttons" id="settings-tab">
<ul class="list-input settings-list">
<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="audio_src">Audio Source Location</label>
<input class="input setting-input" name="audio_src" id="audio_src" value="{src}" type="text" />
</div>
</li>
</ul>
<div class="row module-actions">
<a href="#" class="save-button action-primary action">Save</a>
<a href="#" class="cancel-button action-secondary action">Cancel</a>
</div>
</div>
\ No newline at end of file
function AudioEditBlock(runtime, element) {
$(element).find('.save-button').bind('click', function() {
var handlerUrl = runtime.handlerUrl(element, 'studio_submit');
var data = {
src: $(element).find('input[name=audio_src]').val()
};
$.post(handlerUrl, JSON.stringify(data)).done(function(response) {
window.location.reload(false);
});
});
$(element).find('.cancel-button').bind('click', function() {
runtime.notify('cancel', {});
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment