Skip to content

Commit bcbb630

Browse files
committed
Fancy tooltips
Cleaner dependency loading
1 parent 03fdc23 commit bcbb630

File tree

9 files changed

+53
-24
lines changed

9 files changed

+53
-24
lines changed

src/app/models/scripts-lib.xqy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ declare function m:find-scripts($db-name) as json:array
4747
map:put($obj, "category", fn:string($script/@category)),
4848
map:put($obj, "path", fn:string($script/scripts:path/text())),
4949
map:put($obj, "description", fn:string($script/scripts:description/text())),
50-
map:put($obj, "content-db", fn:string($script/scripts:content-db/text())),
51-
map:put($obj, "modules-db", fn:string($script/scripts:modules-db/text()))
50+
map:put($obj, "contentDb", fn:string($script/scripts:content-db/text())),
51+
map:put($obj, "modulesDb", fn:string($script/scripts:modules-db/text()))
5252
)
5353
order by $script/@name
5454
return $obj

src/app/views/main.xqy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ xdmp:set-response-encoding("UTF-8"),
3333
</div>
3434

3535
<!-- Load our JS here -->
36-
<script src="/js/lib/jquery-1.7.1.min.js"></script>
36+
<script src="/js/lib/jquery-1.11.2.min.js"></script>
3737
<script src="/js/lib/handlebars-v1.3.0.js"></script>
3838
<script src="/js/lib/ember-1.8.1.js"></script>
3939
<script src="/js/lib/bootstrap.min.js"></script>

src/public/favicon.ico

25.5 KB
Binary file not shown.

src/public/js/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// definition of application routes
2-
define(['ember'], function(Ember) {
1+
// setup the ember application
2+
define(['ember', 'templates'], function(Ember) {
33
var EmberApp = Ember.Application.extend({rootElement: '#content'});
44

55
return EmberApp.create({

src/public/js/config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ requirejs.config({
1111
ember: {
1212
deps: ['handlebars', 'jquery'],
1313
exports: 'Ember'
14+
},
15+
bootstrap: {
16+
deps: ['jquery']
1417
}
1518
},
1619
noGlobal: true,
1720
paths:{
18-
//app:"workspace_app/app",
1921
ember: 'lib/ember-1.8.1',
2022
jquery: 'lib/jquery-1.11.2.min',
2123
handlebars: 'lib/handlebars-v1.3.0',
24+
bootstrap: 'lib/bootstrap.min',
2225
text: 'lib/text'
2326
}
2427
});
2528

26-
require(['ember', 'app', 'routes', 'controllers', 'views', 'templates'], function(Ember, App) {
29+
require(['ember', 'app', 'routes', 'controllers', 'views'], function(Ember, App) {
2730

2831
// Override didInsertElement() to trigger event to run
2932
// DOM-ready dependent code, like jQuery plugins

src/public/js/templates.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
define(['ember',
22
'text!templates/application.hbs',
3-
'text!templates/index.hbs'
3+
'text!templates/index.hbs',
4+
'text!templates/script-row-table.hbs'
45
], function(Ember,
56
applicationTemplate,
6-
indexTemplate
7+
indexTemplate,
8+
scriptRowTableTemptlate
79
){
810

911
/*
@@ -29,7 +31,7 @@ define(['ember',
2931
}
3032
*/
3133

32-
Ember.TEMPLATES['application'] = Ember.Handlebars.compile(applicationTemplate);
33-
Ember.TEMPLATES['index'] = Ember.Handlebars.compile(indexTemplate);
34-
34+
Ember.TEMPLATES['application'] = Ember.Handlebars.compile(applicationTemplate);
35+
Ember.TEMPLATES['index'] = Ember.Handlebars.compile(indexTemplate);
36+
Ember.TEMPLATES['script-row-table'] = Ember.Handlebars.compile(scriptRowTableTemptlate);
3537
});

src/public/js/templates/index.hbs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,22 @@
22
<table id="scriptTable" class="table table-bordered table-hover">
33
<tr>
44
<th>Name</th>
5+
<th>Category</th>
56
<th>Description</th>
67
<th>Path</th>
78
<th></th>
89
</tr>
910
{{#if loading}}
1011
<tr>
11-
<td class="col-wide" colspan="4">loading...</td>
12+
<td class="col-wide" colspan="5">loading...</td>
1213
</tr>
1314
{{else}}
1415
{{#each script in scripts}}
15-
<tr>
16-
<td>{{script.name}}</td>
17-
<td>{{script.description}}</td>
18-
<td>{{script.path}}</td>
19-
<td class="run-col">
20-
<button type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" title="run script" {{action 'executeScript' script}}>Run</button>
21-
</td>
22-
</tr>
16+
{{render 'scriptTableRow' script}}
2317
{{/each}}
2418
{{#unless scripts}}
2519
<tr>
26-
<td class="col-wide" colspan="4">No scripts found in selected database.</td>
20+
<td class="col-wide" colspan="5">No scripts found in selected database.</td>
2721
</tr>
2822
{{/unless}}
2923
{{/if}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<td>{{name}}</td>
2+
<td>{{category}}</td>
3+
<td>{{description}}</td>
4+
<td>{{path}}</td>
5+
<td class="run-col">
6+
<button type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" {{action 'executeScript' script}}>Run</button>
7+
</td>

src/public/js/views.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
// definition of application views
2-
require(['ember', 'app', 'jquery'], function(Ember, App, $) {
2+
require(['ember', 'app', 'jquery', 'bootstrap'], function(Ember, App, $) {
33

44
App.IndexView = Ember.View.extend({
5+
templateName: 'index',
56
afterRenderEvent: function() {
67
// active bootstrap tooltips
7-
$('[data-toggle="tooltip"]').tooltip()
8+
console.log('afterRenderEvent!!!!');
9+
$('[data-toggle="tooltip"]').tooltip();
810
}
911
});
1012

13+
App.ScriptTableRowView = Ember.View.extend({
14+
templateName: 'script-row-table',
15+
tagName: 'tr',
16+
afterRenderEvent: function() {
17+
// active bootstrap tooltips
18+
var element = this.get('element');
19+
var script = this.get('controller.model');
20+
$(element).find('[data-toggle="tooltip"]').tooltip({
21+
title: script.get('name') + '<br/>' + script.get('contentDb') + '<br/>' + script.get('modulesDb'),
22+
html: true
23+
});
24+
},
25+
willDestroyElement: function() {
26+
this._super();
27+
// tear down tooltips
28+
var element = this.get('element');
29+
$(element).find('[data-toggle="tooltip"]').tooltip('destroy');
30+
}
31+
32+
});
33+
1134
});

0 commit comments

Comments
 (0)