From be6a62a44ede5409adf071debf487a3710516cb4 Mon Sep 17 00:00:00 2001
From: Miguel Araujo Perez <miguel.araujo.perez@gmail.com>
Date: Mon, 20 Feb 2012 12:59:44 +0100
Subject: [PATCH] Title option in tooltip can be set to an attribute name

This way we can specify another attribute to read, different to title.
If the attribute doesn't exist, then the string is used as a default title.
---
 js/bootstrap-tooltip.js | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index d76e51e8c9..d4678a500a 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -199,16 +199,23 @@
     }
 
   , getTitle: function () {
-      var title
-        , $e = this.$element
-        , o = this.options
-
-      title = $e.attr('data-original-title')
-        || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
-
-      title = title.toString().replace(/(^\s*|\s*$)/, "")
+      var title, $e = this.$element, o = this.options;
+      this.fixTitle();
+
+      if (typeof o.title == 'string') {
+          var title_name = o.title == 'title' ? 'original-title' : o.title;
+          if ($e.children(title_name).length){
+              title = $e.children(title_name).html();
+          } else{
+              title = $e.attr(title_name);
+              if (typeof title == 'undefined') title = title_name
+          }
 
-      return title
+      } else if (typeof o.title == 'function') {
+          title = o.title.call($e[0]);
+      }
+      title = ('' + title).replace(/(^\s*|\s*$)/, "");
+      return title || o.fallback;
     }
 
   , tip: function () {
@@ -267,4 +274,4 @@
   , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
   }
 
-}( window.jQuery );
\ No newline at end of file
+}( window.jQuery );
-- 
GitLab