|
1 | 1 | (function (factory) { |
2 | | - if (typeof define === 'function' && define.amd) { |
3 | | - define(['jquery', 'sammy'], factory); |
| 2 | + if (typeof define === "function" && define.amd) { |
| 3 | + define(["jquery", "sammy"], factory); |
4 | 4 | } else { |
5 | | - (window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy); |
| 5 | + (window.Sammy = window.Sammy || {}).Title = factory( |
| 6 | + window.jQuery, |
| 7 | + window.Sammy, |
| 8 | + ); |
6 | 9 | } |
7 | | -}(function ($, Sammy) { |
8 | | - |
| 10 | +})(function ($, Sammy) { |
9 | 11 | // Sammy.Title is a very simple plugin to easily set the document's title. |
10 | 12 | // It supplies a helper for setting the title (`title()`) within routes, |
11 | 13 | // and an app level method for setting the global title (`setTitle()`) |
12 | | - Sammy.Title = function() { |
13 | | - |
| 14 | + Sammy.Title = function () { |
14 | 15 | // setTitle allows setting a global title or a function that modifies the |
15 | 16 | // title for each route/page. |
16 | 17 | // |
|
38 | 39 | // }); |
39 | 40 | // }); |
40 | 41 | // |
41 | | - this.setTitle = function(title) { |
| 42 | + this.setTitle = function (title) { |
42 | 43 | if (!$.isFunction(title)) { |
43 | | - this.title_function = function(additional_title) { |
44 | | - return [title, additional_title].join(' '); |
45 | | - } |
| 44 | + this.title_function = function (additional_title) { |
| 45 | + return [title, additional_title].join(" "); |
| 46 | + }; |
46 | 47 | } else { |
47 | 48 | this.title_function = title; |
48 | 49 | } |
49 | 50 | }; |
50 | 51 |
|
51 | 52 | // *Helper* title() sets the document title, passing it through the function |
52 | 53 | // defined by setTitle() if set. |
53 | | - this.helper('title', function() { |
54 | | - var new_title = $.makeArray(arguments).join(' '); |
| 54 | + this.helper("title", function () { |
| 55 | + var new_title = $.makeArray(arguments).join(" "); |
55 | 56 | if (this.app.title_function) { |
56 | 57 | new_title = this.app.title_function(new_title); |
57 | 58 | } |
58 | 59 | document.title = new_title; |
59 | 60 | }); |
60 | | - |
61 | 61 | }; |
62 | 62 |
|
63 | 63 | return Sammy.Title; |
64 | | - |
65 | | -})); |
| 64 | +}); |
0 commit comments