Skip to content

Commit

Permalink
MDL-46860 filepicker: iframe context aware
Browse files Browse the repository at this point in the history
The filepicker now checks if it's within an iframe when
creating the dialogue, if so it will set the dialogue width
to fit within the iframe and disable dragging.
  • Loading branch information
ryanwyllie committed Aug 10, 2015
1 parent 49fa660 commit c7007d2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions repository/filepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1299,17 +1299,25 @@ M.core_filepicker.init = function(Y, options) {
var client_id = this.options.client_id;
var fpid = "filepicker-"+ client_id;
var labelid = 'fp-dialog-label_'+ client_id;
var width = 873;
var draggable = true;
this.fpnode = Y.Node.createWithFilesSkin(M.core_filepicker.templates.generallayout).
set('id', 'filepicker-'+client_id).set('aria-labelledby', labelid);

if (this.in_iframe()) {
width = Math.floor(window.innerWidth * 0.95);
draggable = false;
}

this.mainui = new M.core.dialogue({
extraClasses : ['filepicker'],
draggable : true,
draggable : draggable,
bodyContent : this.fpnode,
headerContent: '<h3 id="'+ labelid +'">'+ M.util.get_string('filepicker', 'repository') +'</h3>',
centered : true,
modal : true,
visible : false,
width : '873px',
width : width+'px',
responsiveWidth : 873,
height : '558px',
zIndex : this.options.zIndex
Expand Down Expand Up @@ -1947,6 +1955,10 @@ M.core_filepicker.init = function(Y, options) {
M.util.set_user_preference('filepicker_' + name, value);
this.options.userprefs[name] = value;
}
},
in_iframe: function () {
// If we're not the top window then we're in an iFrame
return window.self !== window.top;
}
});
var loading = Y.one('#filepicker-loading-'+options.client_id);
Expand Down

0 comments on commit c7007d2

Please sign in to comment.