Define _matchMedia wrapper earlier

The unit test stub didn't work because the _matchMedia wrapper
was defined too late.

This fix defines it earlier.
This commit is contained in:
Vincent Petry 2014-03-18 16:02:13 +01:00
parent cc6c152984
commit 67b8cfedf9
1 changed files with 13 additions and 4 deletions

View File

@ -516,6 +516,19 @@ var OC={
}
$toggle.off('click.menu').removeClass('menutoggle');
$menuEl.removeClass('menu');
},
/**
* Wrapper for matchMedia
*
* This is makes it possible for unit tests to
* stub matchMedia (which doesn't work in PhantomJS)
*/
_matchMedia: function(media) {
if (window.matchMedia) {
return window.matchMedia(media);
}
return false;
}
};
OC.search.customResults={};
@ -1033,10 +1046,6 @@ function initCore() {
}
if (window.matchMedia) {
// wrapper needed for unit tests due to PhantomJS bugs
OC._matchMedia = function(media) {
return window.matchMedia(media);
}
setupMainMenu();
}
}