From 4a66486e1a77fa498381e5c9a8a56d47d8b9ea6e Mon Sep 17 00:00:00 2001 From: chylex <info@chylex.com> Date: Mon, 25 Apr 2016 17:01:56 +0200 Subject: [PATCH] Rename extendFunction to appendToFunction, and add prependToFunction to code.js --- Resources/code.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Resources/code.js b/Resources/code.js index fe5b4fa1..0017c4f4 100644 --- a/Resources/code.js +++ b/Resources/code.js @@ -44,10 +44,19 @@ isInitialized = true; }; + // + // Function: Prepends code at the beginning of a function. If the prepended function returns true, execution of the original function is cancelled. + // + var prependToFunction = function(func, extension){ + return function(){ + return extension.apply(this,arguments) === true ? undefined : func.apply(this,arguments); + }; + }; + // // Function: Appends code at the end of a function. // - var extendFunction = function(func, extension){ + var appendToFunction = function(func, extension){ return function(){ var res = func.apply(this,arguments); extension.apply(this,arguments); @@ -118,11 +127,11 @@ // // Block: Hook into settings object to detect when the settings change. // - TD.settings.setFontSize = extendFunction(TD.settings.setFontSize,function(name){ + TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize,function(name){ $TD.loadFontSizeClass(name); }); - TD.settings.setTheme = extendFunction(TD.settings.setTheme,function(){ + TD.settings.setTheme = appendToFunction(TD.settings.setTheme,function(){ setTimeout(function(){ $TD.loadNotificationHeadContents(getNotificationHeadContents()); },0);