Skip to content

Instantly share code, notes, and snippets.

@roothybrid7
Created March 9, 2013 06:26
Show Gist options
  • Select an option

  • Save roothybrid7/5123108 to your computer and use it in GitHub Desktop.

Select an option

Save roothybrid7/5123108 to your computer and use it in GitHub Desktop.
即時関数のスコープでハマったこと ref: http://qiita.com/items/f66d0e57f1d5f8ed847f
;(function(global, $, undefined) {
'use strict';
// globalはwindowだということを期待している
global.App = global.App || {};
var App = global.App;
// […]
}(this, jQuery));
<script>
// […]
;(function(global, $, undefined) {
'use strict';
var App = global.App,
document = global.document;
$(document).on('open.menu close.menu', function(e) {
if (e.type == 'open') {
// Menu 表示時
$('#mainContent').hide();
$('#menu').fadeIn();
} else {
$('#menu').fadeOut(function() {
$(global).scrollTop(0);
$('#mainContent').show();
});
}
});
}(window, jQuery));
// […]
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment