Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google_drive/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GoogleCalendarBlock(XBlock):
display_name="Public Calendar ID",
help="Google provides an ID for publicly available calendars. In the Google Calendar, open Settings and copy the ID from the Calendar Address section into this field.",
scope=Scope.settings,
default="edx.org_vme83q0j2v52mbhjncvfd5uqs8@group.calendar.google.com"
default="edx.org_lom804qe3ttspplj1bgeu1l3ak@group.calendar.google.com"
)

# 0=Week, 1=Month, 2=Agenda
Expand Down
2 changes: 1 addition & 1 deletion google_drive/google_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GoogleDocumentBlock(XBlock):
scope=Scope.settings,
default=textwrap.dedent("""
<iframe
src="https://docs.google.com/presentation/d/1B22AsMwG7jgE39vm1BuiJClir_JUz1q077cPEKJR2mI/embed?start=false&loop=false&delayms=3000"
src="https://docs.google.com/presentation/d/1x2ZuzqHsMoh1epK8VsGAlanSo7r9z55ualwQlj-ofBQ/embed?start=true&loop=true&delayms=10000"
frameborder="0"
width="960"
height="569"
Expand Down
20 changes: 12 additions & 8 deletions google_drive/public/css/google_docs.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
.google-docs-xblock-wrapper{
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
.google-docs-xblock-wrapper iframe{
max-width: 100%;
display:block;
margin: 0 auto;
}

.google-docs-xblock-wrapper iframe{
position: absolute;
.google-docs-xblock-wrapper iframe.no-width-height{
top: 0;
left: 0;
width: 100%;
height: 100%;
min-height: 450px;
}

.google-docs-xblock-wrapper img{
width: auto;
height : auto;
max-width: 100%;
}

#validation_alert{
Expand Down
37 changes: 25 additions & 12 deletions google_drive/public/js/google_calendar_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,41 @@ function GoogleCalendarEditBlock(runtime, element, defaults) {
var save_button = $('.save-button', element);
var validation_alert = $('#validation_alert', element);
var xblock_inputs_wrapper = $('#xblock-inputs', element);
var edit_calendar_id_input = $('#edit_calendar_id', element);
var edit_display_name_input = $('#edit_display_name', element);
var error_message_div = $('.xblock-editor-error-message', element);

ToggleClearDefaultName();
ToggleClearCalendarID();

$('.clear-display-name', element).bind('click', function() {
$(this).addClass('inactive');
$('#edit_display_name', element).val(defaults.defaultName);
edit_display_name_input.val(defaults.defaultName);
});

$('#edit_display_name', element).bind('keyup', function(){
edit_display_name_input.bind('keyup', function(){
ToggleClearDefaultName();
});

$('.clear-calendar-id', element).bind('click', function() {
$(this).addClass('inactive');
$('#edit_calendar_id', element).val(defaults.defaultID);
edit_calendar_id_input.val(defaults.defaultID);
save_button.unbind('click').bind('click', SaveEditing);

if (!validation_alert.hasClass('covered')) {
validation_alert.addClass('covered');
save_button.removeClass('disabled');
edit_calendar_id_input.removeClass('error');
xblock_inputs_wrapper.removeClass('alerted');

save_button.bind('click', SaveEditing);
}
});

$('#edit_calendar_id', element).bind('keyup', function(){
edit_calendar_id_input.bind('keyup', function(){
ToggleClearCalendarID();


var inputVal = $(this).val();
var calendarIDReg = /[\w-\.]+@+[\w-\.]/;
if(!calendarIDReg.test(inputVal)) {
Expand All @@ -49,7 +62,7 @@ function GoogleCalendarEditBlock(runtime, element, defaults) {
});

function ToggleClearDefaultName(){
if ($('#edit_display_name').val() == defaults.defaultName){
if (edit_display_name_input.val() == defaults.defaultName){
if (!clear_name_button.hasClass('inactive')){
clear_name_button.addClass('inactive');
}
Expand All @@ -60,7 +73,7 @@ function GoogleCalendarEditBlock(runtime, element, defaults) {
}

function ToggleClearCalendarID(){
if ($('#edit_calendar_id').val() == defaults.defaultID){
if (edit_calendar_id_input.val() == defaults.defaultID){
if (!clear_id_button.hasClass('inactive')){
clear_id_button.addClass('inactive');
}
Expand All @@ -72,20 +85,20 @@ function GoogleCalendarEditBlock(runtime, element, defaults) {

function SaveEditing(){
var data = {
'display_name': $('.edit-display-name', element).val(),
'calendar_id': $('.edit-calendar-id', element).val(),
'display_name': edit_display_name_input.val(),
'calendar_id': edit_calendar_id_input.val(),
'default_view': $('select.edit-label_type > option:selected', element).val(),
};

$('.xblock-editor-error-message', element).html();
$('.xblock-editor-error-message', element).css('display', 'none');
error_message_div.html();
error_message_div.css('display', 'none');
var handlerUrl = runtime.handlerUrl(element, 'studio_submit');
$.post(handlerUrl, JSON.stringify(data)).done(function(response) {
if (response.result === 'success') {
window.location.reload(false);
} else {
$('.xblock-editor-error-message', element).html('Error: '+response.message);
$('.xblock-editor-error-message', element).css('display', 'block');
error_message_div.html('Error: '+response.message);
error_message_div.css('display', 'block');
}
});
}
Expand Down
43 changes: 27 additions & 16 deletions google_drive/public/js/google_docs.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
/* Javascript for GoogleDocumentBlock. */
function GoogleDocumentBlock(runtime, element) {

$('iframe', element).load(function(){
var iframe_url = $(this).attr('src');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'iframe_loaded'),
data: JSON.stringify({url: iframe_url})
$(function ($) {

var iframe = $('iframe', element);
if(iframe.length > 0){
var iframe_src = iframe.attr('src');

if ((iframe_src.indexOf("document") >= 0) ||
(iframe_src.indexOf("spreadsheets") >= 0)){
/* add class to iframe containing Google document or spreadsheet*/
iframe.addClass('no-width-height');
}
}

$('iframe', element).load(function(){
var iframe_url = $(this).attr('src');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'iframe_loaded'),
data: JSON.stringify({url: iframe_url})
});
});
});

$('img', element).load(function(){
var image_url = $(this).attr('src');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'image_loaded'),
data: JSON.stringify({url: image_url})
$('img', element).load(function(){
var image_url = $(this).attr('src');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'image_loaded'),
data: JSON.stringify({url: image_url})
});
});
});

$(function ($) {
/* Here's where you'd do things on page load. */
});
}
27 changes: 14 additions & 13 deletions google_drive/public/js/google_docs_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ function GoogleDocumentEditBlock(runtime, element, defaults) {
var validation_alert = $('#validation_alert', element);
var embed_code_textbox = $('#edit_embed_code', element);
var xblock_inputs_wrapper = $('#xblock-inputs', element);
var edit_display_name_input = $('#edit_display_name', element);
var error_message_div = $('.xblock-editor-error-message', element);

ToggleClearDefaultName();

IsUrlValid();

$('.clear-display-name', element).bind('click', function() {
$(this).addClass('inactive');
$('#edit_display_name', element).val(defaults.defaultName);
edit_display_name_input.val(defaults.defaultName);
});

$('#edit_display_name', element).bind('keyup', function(){
edit_display_name_input.bind('keyup', function(){
ToggleClearDefaultName();
});

Expand All @@ -28,7 +29,7 @@ function GoogleDocumentEditBlock(runtime, element, defaults) {
});

function ToggleClearDefaultName(name, button){
if ($('#edit_display_name').val() == defaults.defaultName){
if (edit_display_name_input.val() == defaults.defaultName){
if (!clear_name_button.hasClass('inactive')){
clear_name_button.addClass('inactive');
}
Expand All @@ -40,28 +41,28 @@ function GoogleDocumentEditBlock(runtime, element, defaults) {

function SaveEditing(){
var data = {
'display_name': $('.edit-display-name', element).val(),
'embed_code': $('.edit-embed-code', element).val(),
'display_name': edit_display_name_input.val(),
'embed_code': embed_code_textbox.val(),
};

$('.xblock-editor-error-message', element).html();
$('.xblock-editor-error-message', element).css('display', 'none');
error_message_div.html();
error_message_div.css('display', 'none');
var handlerUrl = runtime.handlerUrl(element, 'studio_submit');
$.post(handlerUrl, JSON.stringify(data)).done(function(response) {
if (response.result === 'success') {
window.location.reload(false);
} else {
$('.xblock-editor-error-message', element).html('Error: '+response.message);
$('.xblock-editor-error-message', element).css('display', 'block');
error_message_div.html('Error: '+response.message);
error_message_div.css('display', 'block');
}
});
}

function IsUrlValid(){
var embed_html = $("#edit_embed_code", element).val();
var embed_html = embed_code_textbox.val();

var google_doc = $(embed_html);
$('#edit_embed_code', element).css({'cursor':'wait'});
embed_code_textbox.css({'cursor':'wait'});
save_button.addClass('disabled').unbind('click');

$.ajax({
Expand Down Expand Up @@ -89,7 +90,7 @@ function GoogleDocumentEditBlock(runtime, element, defaults) {
xblock_inputs_wrapper.addClass('alerted');
},
complete: function() {
$('#edit_embed_code', element).css({'cursor':'auto'});
embed_code_textbox.css({'cursor':'auto'});
}
});
}
Expand Down
File renamed without changes.