From 1014183906c3b77a13490ac4c47f716efca8ea87 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Wed, 4 Jun 2025 14:15:42 -0700 Subject: [PATCH 1/2] Fix issue introduced by #13512 Moves Sammy.Title plugin into its own file --- deps/rabbitmq_management/priv/www/index.html | 1 + .../priv/www/js/dispatcher.js | 66 ------------------- deps/rabbitmq_management/priv/www/js/title.js | 65 ++++++++++++++++++ 3 files changed, 66 insertions(+), 66 deletions(-) create mode 100644 deps/rabbitmq_management/priv/www/js/title.js diff --git a/deps/rabbitmq_management/priv/www/index.html b/deps/rabbitmq_management/priv/www/index.html index 3d22d816f8..ca48900bdf 100644 --- a/deps/rabbitmq_management/priv/www/index.html +++ b/deps/rabbitmq_management/priv/www/index.html @@ -13,6 +13,7 @@ + diff --git a/deps/rabbitmq_management/priv/www/js/dispatcher.js b/deps/rabbitmq_management/priv/www/js/dispatcher.js index 5789bc1b72..4e4f09cd4f 100644 --- a/deps/rabbitmq_management/priv/www/js/dispatcher.js +++ b/deps/rabbitmq_management/priv/www/js/dispatcher.js @@ -1,69 +1,3 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery', 'sammy'], factory); - } else { - (window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy); - } -}(function ($, Sammy) { - - // Sammy.Title is a very simple plugin to easily set the document's title. - // It supplies a helper for setting the title (`title()`) within routes, - // and an app level method for setting the global title (`setTitle()`) - Sammy.Title = function() { - - // setTitle allows setting a global title or a function that modifies the - // title for each route/page. - // - // ### Example - // - // // setting a title prefix - // $.sammy(function() { - // - // this.setTitle('My App -'); - // - // this.get('#/', function() { - // this.title('Home'); // document's title == "My App - Home" - // }); - // }); - // - // // setting a title with a function - // $.sammy(function() { - // - // this.setTitle(function(title) { - // return [title, " /// My App"].join(''); - // }); - // - // this.get('#/', function() { - // this.title('Home'); // document's title == "Home /// My App"; - // }); - // }); - // - this.setTitle = function(title) { - if (!$.isFunction(title)) { - this.title_function = function(additional_title) { - return [title, additional_title].join(' '); - } - } else { - this.title_function = title; - } - }; - - // *Helper* title() sets the document title, passing it through the function - // defined by setTitle() if set. - this.helper('title', function() { - var new_title = $.makeArray(arguments).join(' '); - if (this.app.title_function) { - new_title = this.app.title_function(new_title); - } - document.title = new_title; - }); - - }; - - return Sammy.Title; - -})); - dispatcher_add(function(sammy) { function path(p, r, t) { sammy.get(p, function() { diff --git a/deps/rabbitmq_management/priv/www/js/title.js b/deps/rabbitmq_management/priv/www/js/title.js new file mode 100644 index 0000000000..b9b806b494 --- /dev/null +++ b/deps/rabbitmq_management/priv/www/js/title.js @@ -0,0 +1,65 @@ +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', 'sammy'], factory); + } else { + (window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy); + } +}(function ($, Sammy) { + + // Sammy.Title is a very simple plugin to easily set the document's title. + // It supplies a helper for setting the title (`title()`) within routes, + // and an app level method for setting the global title (`setTitle()`) + Sammy.Title = function() { + + // setTitle allows setting a global title or a function that modifies the + // title for each route/page. + // + // ### Example + // + // // setting a title prefix + // $.sammy(function() { + // + // this.setTitle('My App -'); + // + // this.get('#/', function() { + // this.title('Home'); // document's title == "My App - Home" + // }); + // }); + // + // // setting a title with a function + // $.sammy(function() { + // + // this.setTitle(function(title) { + // return [title, " /// My App"].join(''); + // }); + // + // this.get('#/', function() { + // this.title('Home'); // document's title == "Home /// My App"; + // }); + // }); + // + this.setTitle = function(title) { + if (!$.isFunction(title)) { + this.title_function = function(additional_title) { + return [title, additional_title].join(' '); + } + } else { + this.title_function = title; + } + }; + + // *Helper* title() sets the document title, passing it through the function + // defined by setTitle() if set. + this.helper('title', function() { + var new_title = $.makeArray(arguments).join(' '); + if (this.app.title_function) { + new_title = this.app.title_function(new_title); + } + document.title = new_title; + }); + + }; + + return Sammy.Title; + +})); From ca15fa70f7db2ff329d40cf1dbaade3ba04fc2c2 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Wed, 4 Jun 2025 15:07:16 -0700 Subject: [PATCH 2/2] Run `prettier` on title.js --- deps/rabbitmq_management/priv/www/js/title.js | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/deps/rabbitmq_management/priv/www/js/title.js b/deps/rabbitmq_management/priv/www/js/title.js index b9b806b494..5ca31d90df 100644 --- a/deps/rabbitmq_management/priv/www/js/title.js +++ b/deps/rabbitmq_management/priv/www/js/title.js @@ -1,16 +1,17 @@ (function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery', 'sammy'], factory); + if (typeof define === "function" && define.amd) { + define(["jquery", "sammy"], factory); } else { - (window.Sammy = window.Sammy || {}).Title = factory(window.jQuery, window.Sammy); + (window.Sammy = window.Sammy || {}).Title = factory( + window.jQuery, + window.Sammy, + ); } -}(function ($, Sammy) { - +})(function ($, Sammy) { // Sammy.Title is a very simple plugin to easily set the document's title. // It supplies a helper for setting the title (`title()`) within routes, // and an app level method for setting the global title (`setTitle()`) - Sammy.Title = function() { - + Sammy.Title = function () { // setTitle allows setting a global title or a function that modifies the // title for each route/page. // @@ -38,11 +39,11 @@ // }); // }); // - this.setTitle = function(title) { + this.setTitle = function (title) { if (!$.isFunction(title)) { - this.title_function = function(additional_title) { - return [title, additional_title].join(' '); - } + this.title_function = function (additional_title) { + return [title, additional_title].join(" "); + }; } else { this.title_function = title; } @@ -50,16 +51,14 @@ // *Helper* title() sets the document title, passing it through the function // defined by setTitle() if set. - this.helper('title', function() { - var new_title = $.makeArray(arguments).join(' '); + this.helper("title", function () { + var new_title = $.makeArray(arguments).join(" "); if (this.app.title_function) { new_title = this.app.title_function(new_title); } document.title = new_title; }); - }; return Sammy.Title; - -})); +});