Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
55d05bf8
Commit
55d05bf8
authored
Jan 29, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lazy-load ace config so that we can ensure window.gon exists
parent
70c3b984
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
app/assets/javascripts/lib/ace/ace_config_paths.js.erb
app/assets/javascripts/lib/ace/ace_config_paths.js.erb
+17
-10
No files found.
app/assets/javascripts/lib/ace/ace_config_paths.js.erb
View file @
55d05bf8
...
...
@@ -7,21 +7,28 @@ ace_modes = Dir[ace_gem_path + '/vendor/assets/javascripts/ace/mode-*.js'].sort.
File
.
basename
(
file
,
'.js'
).
sub
(
/^mode-/
,
''
)
end
%>
// Lazy-load configuration when ace.edit is called
(function() {
window.gon = window.gon || {};
var basePath = (window.gon.relative_url_root || '').replace(/\/$/, '') + '/assets/ace';
ace.config.set('basePath', basePath);
var basePath;
var ace = window.ace;
var edit = ace.edit;
ace.edit = function() {
window.gon = window.gon || {};
basePath = (window.gon.relative_url_root || '').replace(/\/$/, '') + '/assets/ace';
ace.config.set('basePath', basePath);
// configure paths for all worker modules
// configure paths for all worker modules
<%
ace_workers
.
each
do
|
worker
|
%>
<%
filename
=
File
.
basename
(
asset_path
(
"ace/worker-
#{
worker
}
.js"
))
%>
ace.config.setModuleUrl('ace/mode/
<%=
worker
%>
_worker', basePath + '/
<%=
filename
%>
');
ace.config.setModuleUrl('ace/mode/
<%=
worker
%>
_worker', basePath + '/
<%=
File
.
basename
(
asset_path
(
"ace/worker-
#{
worker
}
.js"
))
%>
');
<%
end
%>
// configure paths for all mode modules
// configure paths for all mode modules
<%
ace_modes
.
each
do
|
mode
|
%>
<%
filename
=
File
.
basename
(
asset_path
(
"ace/mode-
#{
mode
}
.js"
))
%>
ace.config.setModuleUrl('ace/mode/
<%=
mode
%>
', basePath + '/
<%=
filename
%>
');
ace.config.setModuleUrl('ace/mode/
<%=
mode
%>
', basePath + '/
<%=
File
.
basename
(
asset_path
(
"ace/mode-
#{
mode
}
.js"
))
%>
');
<%
end
%>
// restore original method
ace.edit = edit;
return ace.edit.apply(ace, arguments);
};
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment