From 18df11cce613d536e43748edd7a3400e59296d74 Mon Sep 17 00:00:00 2001 From: kurochan Date: Mon, 15 Apr 2013 00:03:48 +0900 Subject: [PATCH 1/2] make textillate reusable --- jquery.textillate.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jquery.textillate.js b/jquery.textillate.js index 7484c73..a18b07e 100644 --- a/jquery.textillate.js +++ b/jquery.textillate.js @@ -183,9 +183,14 @@ , data = $this.data('textillate') , options = $.extend(true, {}, $.fn.textillate.defaults, getData(this), typeof settings == 'object' && settings); - if (!data) { - $this.data('textillate', (data = new Textillate(this, options))); - } else if (typeof settings == 'string') { + if (data) { + var text = $this.find('.texts').text(); + $this.empty(); + $this.text(text); + } + $this.data('textillate', (data = new Textillate(this, options))); + + if (typeof settings == 'string') { data[settings].apply(data, [].concat(args)); } else { data.setOptions.call(data, options); From 109f20703d456086de811ce6cc72695d3f006894 Mon Sep 17 00:00:00 2001 From: kurochan Date: Mon, 15 Apr 2013 18:59:15 +0900 Subject: [PATCH 2/2] Fix bug --- jquery.textillate.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.textillate.js b/jquery.textillate.js index a18b07e..e6f1093 100644 --- a/jquery.textillate.js +++ b/jquery.textillate.js @@ -184,7 +184,10 @@ , options = $.extend(true, {}, $.fn.textillate.defaults, getData(this), typeof settings == 'object' && settings); if (data) { - var text = $this.find('.texts').text(); + var text; + if(!(text = $this.find('.texts').text())){ + text = $this.text(); + } $this.empty(); $this.text(text); } @@ -222,4 +225,4 @@ outEffects: [ 'hinge' ] }; -}(jQuery)); \ No newline at end of file +}(jQuery));