Skip to content

Commit 1014183

Browse files
committed
Fix issue introduced by #13512
Moves Sammy.Title plugin into its own file
1 parent 71adabc commit 1014183

File tree

3 files changed

+66
-66
lines changed

3 files changed

+66
-66
lines changed

deps/rabbitmq_management/priv/www/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<script src="js/base64.js" type="text/javascript"></script>
1414
<script src="js/global.js" type="text/javascript"></script>
1515
<script src="js/main.js" type="text/javascript"></script>
16+
<script src="js/title.js" type="text/javascript"></script>
1617
<script src="js/prefs.js" type="text/javascript"></script>
1718
<script src="js/formatters.js" type="text/javascript"></script>
1819
<script src="js/charts.js" type="text/javascript"></script>

deps/rabbitmq_management/priv/www/js/dispatcher.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,3 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
define(['jquery', 'sammy'], factory);
4-
} else {
5-
(window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy);
6-
}
7-
}(function ($, Sammy) {
8-
9-
// Sammy.Title is a very simple plugin to easily set the document's title.
10-
// It supplies a helper for setting the title (`title()`) within routes,
11-
// and an app level method for setting the global title (`setTitle()`)
12-
Sammy.Title = function() {
13-
14-
// setTitle allows setting a global title or a function that modifies the
15-
// title for each route/page.
16-
//
17-
// ### Example
18-
//
19-
// // setting a title prefix
20-
// $.sammy(function() {
21-
//
22-
// this.setTitle('My App -');
23-
//
24-
// this.get('#/', function() {
25-
// this.title('Home'); // document's title == "My App - Home"
26-
// });
27-
// });
28-
//
29-
// // setting a title with a function
30-
// $.sammy(function() {
31-
//
32-
// this.setTitle(function(title) {
33-
// return [title, " /// My App"].join('');
34-
// });
35-
//
36-
// this.get('#/', function() {
37-
// this.title('Home'); // document's title == "Home /// My App";
38-
// });
39-
// });
40-
//
41-
this.setTitle = function(title) {
42-
if (!$.isFunction(title)) {
43-
this.title_function = function(additional_title) {
44-
return [title, additional_title].join(' ');
45-
}
46-
} else {
47-
this.title_function = title;
48-
}
49-
};
50-
51-
// *Helper* title() sets the document title, passing it through the function
52-
// defined by setTitle() if set.
53-
this.helper('title', function() {
54-
var new_title = $.makeArray(arguments).join(' ');
55-
if (this.app.title_function) {
56-
new_title = this.app.title_function(new_title);
57-
}
58-
document.title = new_title;
59-
});
60-
61-
};
62-
63-
return Sammy.Title;
64-
65-
}));
66-
671
dispatcher_add(function(sammy) {
682
function path(p, r, t) {
693
sammy.get(p, function() {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
(function (factory) {
2+
if (typeof define === 'function' && define.amd) {
3+
define(['jquery', 'sammy'], factory);
4+
} else {
5+
(window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy);
6+
}
7+
}(function ($, Sammy) {
8+
9+
// Sammy.Title is a very simple plugin to easily set the document's title.
10+
// It supplies a helper for setting the title (`title()`) within routes,
11+
// and an app level method for setting the global title (`setTitle()`)
12+
Sammy.Title = function() {
13+
14+
// setTitle allows setting a global title or a function that modifies the
15+
// title for each route/page.
16+
//
17+
// ### Example
18+
//
19+
// // setting a title prefix
20+
// $.sammy(function() {
21+
//
22+
// this.setTitle('My App -');
23+
//
24+
// this.get('#/', function() {
25+
// this.title('Home'); // document's title == "My App - Home"
26+
// });
27+
// });
28+
//
29+
// // setting a title with a function
30+
// $.sammy(function() {
31+
//
32+
// this.setTitle(function(title) {
33+
// return [title, " /// My App"].join('');
34+
// });
35+
//
36+
// this.get('#/', function() {
37+
// this.title('Home'); // document's title == "Home /// My App";
38+
// });
39+
// });
40+
//
41+
this.setTitle = function(title) {
42+
if (!$.isFunction(title)) {
43+
this.title_function = function(additional_title) {
44+
return [title, additional_title].join(' ');
45+
}
46+
} else {
47+
this.title_function = title;
48+
}
49+
};
50+
51+
// *Helper* title() sets the document title, passing it through the function
52+
// defined by setTitle() if set.
53+
this.helper('title', function() {
54+
var new_title = $.makeArray(arguments).join(' ');
55+
if (this.app.title_function) {
56+
new_title = this.app.title_function(new_title);
57+
}
58+
document.title = new_title;
59+
});
60+
61+
};
62+
63+
return Sammy.Title;
64+
65+
}));

0 commit comments

Comments
 (0)