Load the codemirror as package in the require.js, which will allow us to

load the codemirror addons without any modification.
This commit is contained in:
Ashesh Vashi 2016-04-14 12:34:14 +05:30
parent af1e38a97a
commit 30d189f499
6 changed files with 18 additions and 18 deletions

View File

@ -61,10 +61,18 @@ class PgAdmin(Flask):
@property @property
def javascripts(self): def javascripts(self):
stylesheets = [] scripts = []
scripts_names = []
# Remove duplicate javascripts from the list
for module in self.submodules: for module in self.submodules:
stylesheets.extend(getattr(module, "javascripts", [])) module_scripts = getattr(module, "javascripts", [])
return stylesheets for s in module_scripts:
if s['name'] not in scripts_names:
scripts.append(s)
scripts_names.append(s['name'])
return scripts
@property @property
def panels(self): def panels(self):

View File

@ -62,19 +62,6 @@ class BrowserModule(PgAdminModule):
'exports': 'alertify', 'exports': 'alertify',
'preloaded': True 'preloaded': True
}) })
scripts.append({
'name': 'codemirror',
'path': url_for('static', filename='js/codemirror/codemirror'),
'exports': 'CodeMirror',
'preloaded': True
})
scripts.append({
'name': 'codemirror.sql',
'path': url_for('static', filename='js/codemirror/mode/sql'),
'deps': ['codemirror'],
'exports': 'CodeMirror.modes.sql',
'preloaded': True
})
scripts.append({ scripts.append({
'name': 'jqueryui.position', 'name': 'jqueryui.position',
'path': url_for( 'path': url_for(

View File

@ -1,6 +1,6 @@
define('pgadmin.browser', define('pgadmin.browser',
['require', 'jquery', 'underscore', 'underscore.string', 'bootstrap', ['require', 'jquery', 'underscore', 'underscore.string', 'bootstrap',
'pgadmin', 'alertify', 'codemirror', 'codemirror.sql', 'wcdocker', 'pgadmin', 'alertify', 'codemirror', 'codemirror/mode/sql', 'wcdocker',
'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree', 'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree',
'pgadmin.alertifyjs', 'pgadmin.browser.messages', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin.browser.menu', 'pgadmin.browser.panel',

View File

@ -4,7 +4,7 @@
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define([ define([
'underscore', 'underscore.string', 'jquery', 'backbone', 'backform', 'underscore', 'underscore.string', 'jquery', 'backbone', 'backform',
'backgrid', 'codemirror', 'pgadmin.backgrid', 'codemirror.sql', 'backgrid', 'codemirror', 'pgadmin.backgrid', 'codemirror/mode/sql',
'select2' 'select2'
], ],
function(_, S, $, Backbone, Backform, Backgrid, CodeMirror) { function(_, S, $, Backbone, Backform, Backgrid, CodeMirror) {

View File

@ -43,6 +43,11 @@
require.config({ require.config({
baseUrl: '', baseUrl: '',
waitSeconds: 0, waitSeconds: 0,
packages: [{
name: 'codemirror',
location: '{{ url_for('static', filename='js/codemirror')}}',
main: 'lib/codemirror'
}],
shim: { shim: {
"backbone": { "backbone": {
"deps": ['underscore', 'jquery'], "deps": ['underscore', 'jquery'],