Commit 963019b3 by Martyn James

Merge pull request #10 from edx-solutions/mjevtic/SOL-135

Added title attribute to iframe/img
parents c5e6c708 7dc4e55b
...@@ -51,7 +51,7 @@ class GoogleCalendarBlock(XBlock): ...@@ -51,7 +51,7 @@ class GoogleCalendarBlock(XBlock):
view = "Week" if self.default_view==0 else "Month" if self.default_view==1 else "Agenda" view = "Week" if self.default_view==0 else "Month" if self.default_view==1 else "Agenda"
iframe = "<iframe src=\"https://www.google.com/calendar/embed?mode={}&amp;src={}&amp;showCalendars=0\"></iframe>".format(view, self.calendar_id) iframe = '<iframe src="https://www.google.com/calendar/embed?mode={}&amp;src={}&amp;showCalendars=0" title="{}"></iframe>'.format(view, self.calendar_id, self.display_name)
context.update({ context.update({
"self": self, "self": self,
......
...@@ -49,8 +49,9 @@ class GoogleDocumentBlock(XBlock): ...@@ -49,8 +49,9 @@ class GoogleDocumentBlock(XBlock):
fragment = Fragment() fragment = Fragment()
context.update({ context.update({
"self": self, "self": self
}) })
fragment.add_content(loader.render_template('/templates/html/google_docs.html', context)) fragment.add_content(loader.render_template('/templates/html/google_docs.html', context))
fragment.add_css(loader.load_unicode('public/css/google_docs.css')) fragment.add_css(loader.load_unicode('public/css/google_docs.css'))
fragment.add_javascript(loader.load_unicode('public/js/google_docs.js')) fragment.add_javascript(loader.load_unicode('public/js/google_docs.js'))
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
function GoogleDocumentBlock(runtime, element) { function GoogleDocumentBlock(runtime, element) {
var iframe = $('iframe', element); var iframe = $('iframe', element);
var image = $('img', element);
var display_name = $('.google-docs-xblock-wrapper', element).attr('data-display-name');
if(iframe.length > 0){ if(iframe.length > 0){
var iframe_src = iframe.attr('src'); var iframe_src = iframe.attr('src');
...@@ -10,6 +13,10 @@ function GoogleDocumentBlock(runtime, element) { ...@@ -10,6 +13,10 @@ function GoogleDocumentBlock(runtime, element) {
/* add class to iframe containing Google document or spreadsheet*/ /* add class to iframe containing Google document or spreadsheet*/
iframe.addClass('no-width-height'); iframe.addClass('no-width-height');
} }
iframe.attr('title', display_name);
}else if(image.length > 0){
image.attr('title', display_name);
} }
function SignalDocumentLoaded(ev, presented_within){ function SignalDocumentLoaded(ev, presented_within){
...@@ -23,7 +30,7 @@ function GoogleDocumentBlock(runtime, element) { ...@@ -23,7 +30,7 @@ function GoogleDocumentBlock(runtime, element) {
}) })
}); });
} }
$('iframe', element).load(function(e){SignalDocumentLoaded(e, 'iframe');}); iframe.load(function(e){SignalDocumentLoaded(e, 'iframe');});
$('img', element).load(function(e){SignalDocumentLoaded(e, 'img');}); image.load(function(e){SignalDocumentLoaded(e, 'img');});
} }
<div class="google-docs-xblock-wrapper"> <div class="google-docs-xblock-wrapper" data-display-name="{{self.display_name}}">
{{ self.embed_code|safe }} {{ self.embed_code|safe }}
</div> </div>
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