From dd6fddad01cb3ea0cfe6655d78b1f57456add9d0 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 16 Oct 2012 21:42:36 +0100 Subject: [PATCH] Added support for the empty message to the list macro --- core/modules/macros/list.js | 55 ++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/core/modules/macros/list.js b/core/modules/macros/list.js index 17d507e3f..aec685b8f 100644 --- a/core/modules/macros/list.js +++ b/core/modules/macros/list.js @@ -45,9 +45,15 @@ exports.executeMacro = function() { $tw.utils.pushTop(attributes["class"],this.classes); } this.listFrame = $tw.Tree.Element(this.isBlock ? "div" : "span",attributes,[]); - // Create each list element - for(var t=0; t=0; t--) { + this.removeListElement(t); + } + // Insert the empty message + this.listFrame.children = [this.getEmptyMessage()]; + this.listFrame.children[0].renderInDom(this.listFrame.domNode,this.listFrame.domNode.childNodes[0]); + return; + } + } else { + // If it is not empty now, but was empty previously, then remove the empty message + if(prevListLength === 0) { + this.removeListElement(0); + } + } // Step through the list and adjust our child list elements appropriately for(t=0; t t) { for(var n=index-1; n>=t; n--) { - this.removelistElement(n); + this.removeListElement(n); } } // Refresh the node we're reusing @@ -180,7 +221,7 @@ exports.refreshInDom = function(changes) { // Remove any left over elements if(this.listFrame.children.length > this.list.length) { for(t=this.listFrame.children.length-1; t>=this.list.length; t--) { - this.removeStoryElement(t); + this.removeListElement(t); } } };