次のような機能を含む私の部分がありますmain.js
:
function isTrue(x){...}
function resizeEditors() {...}
function updateLayout() {...}
function prettify() {...}
function setTheme(theme) {...}
function themedLayout(isDark){...}
function enablePanel(panel) {...}
function disablePanel(panel) {...}
function enableDefaultPanels() {...}
function toggleFullscreen() {...}
function toggleEditorFullscreen(selected) {...}
これらの関数をmain.js
ファイルの依存関係で利用できるようにする方法はありますか?
たとえば、editors.js
私は関数を使用していますが、editors.jsモジュールはファイル内にあるため、isTrue
現在見つけることができませんisTrue
main.js
editors.setShowPrintMargin( isTrue( settings.showPrintMargin ) );
編集:
プロジェクトはどのように見えるか:
main.js
:
require(['jquery', 'appSession', 'editors'], function ($, appSession, editors) {
function isTrue(x){...}
function resizeEditors() {...}
function updateLayout() {...}
function prettify() {...}
function setTheme(theme) {...}
function themedLayout(isDark){...}
function enablePanel(panel) {...}
function disablePanel(panel) {...}
function enableDefaultPanels() {...}
function toggleFullscreen() {...}
function toggleEditorFullscreen(selected) {...}
});
editors.js
:
define(['jquery', 'appSession'], function($, appSession){
...
editors.setShowPrintMargin( isTrue( settings.showPrintMargin ) );
...
return editors;
});