Skip to content

Commit bb3bce2

Browse files
authored
Merge pull request #9 from maxplanck-ie/jmv_dev
html based configuration
2 parents 0690af6 + af75a4c commit bb3bce2

File tree

7 files changed

+119
-88
lines changed

7 files changed

+119
-88
lines changed

hicbrowser/client/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ This project aims to visualize gene expression profiles in the context of mitoch
1111
3. Compile the project
1212
`grunt dist`
1313

14+
## Usage
15+
16+
```
17+
<html>
18+
<head>
19+
20+
<!-- 1. Import the app styles CSS -->
21+
<link href='css/App.css' rel='stylesheet' type='text/css'>
22+
23+
</head>
24+
25+
<body></body>
26+
27+
<!-- 2. Import javascript -->
28+
<script src="js/App.min.js"></script>
29+
30+
<script>
31+
// 3. Initialize application!
32+
App.init({
33+
browser_example: 'X:3800000-4340000',
34+
gene_example: 'mof',
35+
icon: '/static/img/fly.svg'
36+
});
37+
38+
// Alternatively use the default configuration:
39+
// App.init();
40+
</script>
41+
</html>
42+
```
43+
1444
## Built With
1545

1646
* [NPM](https://www.npmjs.com/) - Dependency Management

hicbrowser/client/html/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,15 @@
6262
<!-- build:js /static/js/App.js -->
6363
<script src="../static/js/App.js"></script>
6464
<!-- /build -->
65+
66+
<script>
67+
68+
App.init({
69+
browser_example: 'X:3800000-4340000',
70+
gene_example: 'mof',
71+
icon: '/static/img/fly.svg'
72+
});
73+
74+
</script>
75+
6576
</html>

hicbrowser/client/index.js

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,46 @@ var GeneView = require('./js/views/gene');
1212
var BrowserView = require('./js/views/browser');
1313
var Intro = require('./js/views/intro-header');
1414

15-
function initViews(){
16-
// Render initial views
17-
App.views.intro.render(App.config);
18-
App.views.search.render(App.config);
19-
}
20-
2115
App = {};
2216

23-
App.init = function(){
24-
25-
//Views
26-
App.views = {};
27-
App.views.loading = new Loading({el:'body'});
28-
App.views.search = new Search({el:'#search'});
29-
App.views.index = new Index({el:'#content'});
30-
App.views.gene = new GeneView({el:'#content'});
31-
App.views.browser = new BrowserView({el:'#content'});
32-
App.views.intro = new Intro({el:'.intro-header'});
33-
34-
// Models
35-
App.models = {};
36-
App.models.Gene = require('./js/models/gene');
37-
App.models.Browser = require('./js/models/browser');
38-
App.models.Config = require('./js/models/config');
39-
40-
// Init config with defaults
17+
//Views
18+
App.views = {};
19+
App.views.loading = new Loading({el:'body'});
20+
App.views.search = new Search({el:'#search'});
21+
App.views.index = new Index({el:'#content'});
22+
App.views.gene = new GeneView({el:'#content'});
23+
App.views.browser = new BrowserView({el:'#content'});
24+
App.views.intro = new Intro({el:'.intro-header'});
25+
26+
// Models
27+
App.models = {};
28+
App.models.Gene = require('./js/models/gene');
29+
App.models.Browser = require('./js/models/browser');
30+
App.models.Config = require('./js/models/config');
31+
32+
//Router
33+
App.router = require('./js/router');
34+
35+
// listen to ajax
36+
$(document).ajaxStart(function() {
37+
App.views.loading.show();
38+
}).ajaxStop(function() {
39+
setTimeout(App.views.loading.hide, 800);
40+
});
41+
42+
App.init = function(config){
43+
44+
// Init config
4145
App.config = new App.models.Config();
42-
43-
// See if there is a config file defined.
44-
// If not, load app with defaults
45-
App.config.fetch({
46-
success: initViews,
47-
error: initViews
48-
});
49-
50-
//Router
51-
App.router = require('./js/router');
52-
53-
// listen to ajax
54-
$(document).ajaxStart(function() {
55-
App.views.loading.show();
56-
}).ajaxStop(function() {
57-
setTimeout(App.views.loading.hide, 800);
58-
});
46+
App.config.set(config);
5947

6048
// Render loading
6149
App.views.loading.render();
6250

6351
// Select all elements with data-toggle="tooltips" in the document
6452
$('[data-toggle="tooltip"]').tooltip();
65-
};
6653

67-
App.init();
54+
// Render initial views
55+
App.views.intro.render(App.config);
56+
App.views.search.render(App.config);
57+
};

hicbrowser/static/js/App.js

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,49 @@ var GeneView = require('./js/views/gene');
1414
var BrowserView = require('./js/views/browser');
1515
var Intro = require('./js/views/intro-header');
1616

17-
function initViews(){
18-
// Render initial views
19-
App.views.intro.render(App.config);
20-
App.views.search.render(App.config);
21-
}
22-
2317
App = {};
2418

25-
App.init = function(){
26-
27-
//Views
28-
App.views = {};
29-
App.views.loading = new Loading({el:'body'});
30-
App.views.search = new Search({el:'#search'});
31-
App.views.index = new Index({el:'#content'});
32-
App.views.gene = new GeneView({el:'#content'});
33-
App.views.browser = new BrowserView({el:'#content'});
34-
App.views.intro = new Intro({el:'.intro-header'});
19+
//Views
20+
App.views = {};
21+
App.views.loading = new Loading({el:'body'});
22+
App.views.search = new Search({el:'#search'});
23+
App.views.index = new Index({el:'#content'});
24+
App.views.gene = new GeneView({el:'#content'});
25+
App.views.browser = new BrowserView({el:'#content'});
26+
App.views.intro = new Intro({el:'.intro-header'});
27+
28+
// Models
29+
App.models = {};
30+
App.models.Gene = require('./js/models/gene');
31+
App.models.Browser = require('./js/models/browser');
32+
App.models.Config = require('./js/models/config');
33+
34+
//Router
35+
App.router = require('./js/router');
36+
37+
// listen to ajax
38+
$(document).ajaxStart(function() {
39+
App.views.loading.show();
40+
}).ajaxStop(function() {
41+
setTimeout(App.views.loading.hide, 800);
42+
});
3543

36-
// Models
37-
App.models = {};
38-
App.models.Gene = require('./js/models/gene');
39-
App.models.Browser = require('./js/models/browser');
40-
App.models.Config = require('./js/models/config');
44+
App.init = function(config){
4145

42-
// Init config with defaults
46+
// Init config
4347
App.config = new App.models.Config();
44-
45-
// See if there is a config file defined.
46-
// If not, load app with defaults
47-
App.config.fetch({
48-
success: initViews,
49-
error: initViews
50-
});
51-
52-
//Router
53-
App.router = require('./js/router');
54-
55-
// listen to ajax
56-
$(document).ajaxStart(function() {
57-
App.views.loading.show();
58-
}).ajaxStop(function() {
59-
setTimeout(App.views.loading.hide, 800);
60-
});
48+
App.config.set(config);
6149

6250
// Render loading
6351
App.views.loading.render();
6452

6553
// Select all elements with data-toggle="tooltips" in the document
6654
$('[data-toggle="tooltip"]').tooltip();
67-
};
6855

69-
App.init();
56+
// Render initial views
57+
App.views.intro.render(App.config);
58+
App.views.search.render(App.config);
59+
};
7060

7161
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7262
},{"./js/models/browser":2,"./js/models/config":3,"./js/models/gene":4,"./js/router":5,"./js/views/browser":7,"./js/views/gene":8,"./js/views/index":9,"./js/views/intro-header":10,"./js/views/loading":11,"./js/views/search":12,"backbone":16,"bootstrap":18,"jquery":78}],2:[function(require,module,exports){

hicbrowser/static/js/App.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hicbrowser/static/json/config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

hicbrowser/templates/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@
5656

5757
</body>
5858
<script src="/static/js/App.js"></script>
59+
60+
<script>
61+
62+
App.init({
63+
browser_example: 'X:3800000-4340000',
64+
gene_example: 'mof',
65+
icon: '/static/img/fly.svg'
66+
});
67+
68+
</script>
69+
5970
</html>

0 commit comments

Comments
 (0)