From c3ecb95a78e06aa9d42644085dd6ba07ea6a51ac Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Tue, 16 Jun 2015 11:40:00 -0500 Subject: [PATCH] add option to open flash in new window --- flash/flash.py | 8 ++++++++ flash/static/html/flash_edit.html | 11 ++++++++++ flash/static/html/flash_view.html | 34 +++++++++++++++++-------------- flash/static/js/flash_edit.js | 3 ++- flash/static/js/flash_view.js | 6 ++++++ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/flash/flash.py b/flash/flash.py index 8f601e4..065894b 100644 --- a/flash/flash.py +++ b/flash/flash.py @@ -27,6 +27,11 @@ class flashXBlock(XBlock): scope=Scope.content, help="The URL for your flash file.") + use_popup = Boolean(display_name="Open in Pop Up Window", + default=True, + scope=Scope.content, + help="Display a button to open the flash file in a separate window.") + allow_download = Boolean(display_name="Flash Download Allowed", default=True, scope=Scope.content, @@ -71,6 +76,7 @@ def student_view(self, context=None): context = { 'display_name': self.display_name, 'url': self.url, + 'use_popup': self.use_popup, 'allow_download': self.allow_download, 'source_text': self.source_text, 'source_url': self.source_url @@ -91,6 +97,7 @@ def studio_view(self, context=None): context = { 'display_name': self.display_name, 'url': self.url, + 'use_popup': self.use_popup, 'allow_download': self.allow_download, 'source_text': self.source_text, 'source_url': self.source_url @@ -109,6 +116,7 @@ def save_flash(self, data, suffix=''): """ self.display_name = data['display_name'] self.url = data['url'] + self.use_popup = True if data['use_popup'] == "True" else False # Str to Bool translation self.allow_download = True if data['allow_download'] == "True" else False # Str to Bool translation self.source_text = data['source_text'] self.source_url = data['source_url'] diff --git a/flash/static/html/flash_edit.html b/flash/static/html/flash_edit.html index 89957b5..cd5bafc 100644 --- a/flash/static/html/flash_edit.html +++ b/flash/static/html/flash_edit.html @@ -17,6 +17,17 @@ The URL for your flash file. +
  • +
    + + +
    + Display a button that will open this Flash file in a separate window. +
  • +
  • diff --git a/flash/static/html/flash_view.html b/flash/static/html/flash_view.html index 6f66485..70285c5 100644 --- a/flash/static/html/flash_view.html +++ b/flash/static/html/flash_view.html @@ -1,18 +1,22 @@
    -

    {{ display_name }}

    - - {% if allow_download or source_url != "" %} - {% endif %} -
    \ No newline at end of file +
    diff --git a/flash/static/js/flash_edit.js b/flash/static/js/flash_edit.js index 7d07466..55bada5 100644 --- a/flash/static/js/flash_edit.js +++ b/flash/static/js/flash_edit.js @@ -9,6 +9,7 @@ function flashXBlockInitEdit(runtime, element) { var data = { 'display_name': $('#flash_edit_display_name').val(), 'url': $('#flash_edit_url').val(), + 'use_popup': $('#flash_edit_use_popup').val(), 'allow_download': $('#flash_edit_allow_download').val(), 'source_text': $('#flash_edit_source_text').val(), 'source_url': $('#flash_edit_source_url').val() @@ -27,4 +28,4 @@ function flashXBlockInitEdit(runtime, element) { } }); }); -} \ No newline at end of file +} diff --git a/flash/static/js/flash_view.js b/flash/static/js/flash_view.js index 38ae06b..7c4a106 100644 --- a/flash/static/js/flash_view.js +++ b/flash/static/js/flash_view.js @@ -6,3 +6,9 @@ function flashXBlockInitView(runtime, element) { * So here I make sure element is the jQuery object */ if(element.innerHTML) element = $(element); } + +function newPopup(url) { + popupWindow = window.open( + null,'popUpWindow','left=10,top=10,width=1024,height=600,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes') + popupWindow.document.write(''); +}