From d29df9b3efd5da756b547cbf705a3d8752da7749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Emonet?= Date: Fri, 28 Mar 2014 01:23:50 +0100 Subject: [PATCH 1/3] Adding a reInitSlidesArray method for extensions that generate new slides in the "beforeInit" phase --- core/deck.core.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/deck.core.js b/core/deck.core.js index a8adefe7..f0f9fd41 100644 --- a/core/deck.core.js +++ b/core/deck.core.js @@ -427,6 +427,19 @@ that use the API provided by core. }, options.initLockTimeout); }, + /* + jQuery.deck('reInitSlidesArray') + + Force a recomputation of the "slides" array. This method is meant + to be used by extensions that generate new slides in the + beforeInit phase. + */ + + reInitSlidesArray: function() { + slides = []; + initSlidesArray(options.selectors.slides); + }, + /* jQuery.deck('go', index) From f4193effa0f94f942b66c7090e90c0196435c9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Emonet?= Date: Tue, 1 Apr 2014 17:37:16 +0200 Subject: [PATCH 2/3] add an alert when reInitSlidesArray is used too late (after beforeInit) --- core/deck.core.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/deck.core.js b/core/deck.core.js index f0f9fd41..8ad3fa4b 100644 --- a/core/deck.core.js +++ b/core/deck.core.js @@ -394,6 +394,10 @@ that use the API provided by core. initSlidesArray(options.selectors.slides); // Pre init event for preprocessing hooks beforeInitEvent.done = function() { + // reInitSlidesArray is meant only for beforeInit + methods['reInitSlidesArray'] = function() { + alert('Deck.js method "reInitSlidesArray" is meant to be called in the beforeInit phase only.'); + } // re-populate the array of slides slides = []; initSlidesArray(options.selectors.slides); From 5bfb29f74c8a0e8311dfb2c84b8efa8d99b7d977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Emonet?= Date: Sat, 27 Dec 2014 21:58:00 +0100 Subject: [PATCH 3/3] [core] optionally disallowing $.deck() call without an explicit method --- core/deck.core.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/deck.core.js b/core/deck.core.js index 8ad3fa4b..b9fee5bc 100644 --- a/core/deck.core.js +++ b/core/deck.core.js @@ -618,7 +618,12 @@ that use the API provided by core. return methods[method].apply(this, args); } else { - return methods.init(method, arg); + if (window.defaultDeckCallIsAnError) { + alert("'" + method + "' not found (or meant to be a parameter-less init)"); + } + else { + return methods.init(method, arg); + } } };