From 0a7222b1230c200a3fdd4ff7f76a90a5aa65f0bc Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Wed, 22 May 2013 15:04:30 -0400 Subject: [PATCH] Allow an AJAX call to specify that it should not notify on error Because there are some cases where it's OK to fail, and it's not the user's fault --- cms/static/coffee/src/main.coffee | 2 ++ .../js/src/video/display/video_caption.coffee | 19 +++++++++++-------- .../videoalpha/display/video_caption.coffee | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/cms/static/coffee/src/main.coffee b/cms/static/coffee/src/main.coffee index 083a005c71..efcd869113 100644 --- a/cms/static/coffee/src/main.coffee +++ b/cms/static/coffee/src/main.coffee @@ -16,6 +16,8 @@ $ -> dataType: 'json' $(document).ajaxError (event, jqXHR, ajaxSettings, thrownError) -> + if ajaxSettings.notifyOnError is false + return msg = new CMS.Models.ErrorMessage( "title": gettext("Studio's having trouble saving your work") "message": jqXHR.responseText || gettext("This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.") diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee index e840cd2a77..bf3ec1e102 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee @@ -27,16 +27,19 @@ class @VideoCaption extends Subview @fetchCaption() fetchCaption: -> - $.getWithPrefix @captionURL(), (captions) => - @captions = captions.text - @start = captions.start + $.ajaxWithPrefix + url: @captionURL() + notifyOnError: false + success: (captions) => + @captions = captions.text + @start = captions.start - @loaded = true + @loaded = true - if onTouchBasedDevice() - $('.subtitles li').html "Caption will be displayed when you start playing the video." - else - @renderCaption() + if onTouchBasedDevice() + $('.subtitles li').html "Caption will be displayed when you start playing the video." + else + @renderCaption() renderCaption: -> container = $('
    ') diff --git a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_caption.coffee b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_caption.coffee index 9ecdaca474..b0adfbfd81 100644 --- a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_caption.coffee +++ b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_caption.coffee @@ -27,16 +27,19 @@ class @VideoCaptionAlpha extends SubviewAlpha @fetchCaption() fetchCaption: -> - $.getWithPrefix @captionURL(), (captions) => - @captions = captions.text - @start = captions.start + $.ajaxWithPrefix + url: @captionURL() + notifyOnError: false + success: (captions) => + @captions = captions.text + @start = captions.start - @loaded = true + @loaded = true - if onTouchBasedDevice() - $('.subtitles li').html "Caption will be displayed when you start playing the video." - else - @renderCaption() + if onTouchBasedDevice() + $('.subtitles li').html "Caption will be displayed when you start playing the video." + else + @renderCaption() renderCaption: -> container = $('
      ')