Skip to content

Commit

Permalink
Allow Tooltip to work with data-title attribute, as title would…
Browse files Browse the repository at this point in the history
… be invalid for elements like SVG.
  • Loading branch information
thednp committed Oct 5, 2017
1 parent 0bc8a95 commit 5c5fb3d
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 19 deletions.
7 changes: 3 additions & 4 deletions dist/bootstrap-native-v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
dataInterval = 'data-interval',
dataHeight = 'data-height',
dataPause = 'data-pause',
dataTitle = 'data-title',
dataOriginalTitle = 'data-original-title',
dataOriginalText = 'data-original-text',
dataDismissible = 'data-dismissible',
Expand Down Expand Up @@ -1088,9 +1089,7 @@
classString = 'class',
div = 'div',
fade = 'fade',
title = 'title',
content = 'content',
dataTitle = 'data-title',
dataContent = 'data-content',
dismissible = 'dismissible',
closeBtn = '<button type="button" class="close">×</button>',
Expand Down Expand Up @@ -1536,7 +1535,7 @@

// bind, event targets, title and constants
var self = this, timer = 0, placementSetting = this[placement], tooltip = null,
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle);
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle);

if ( !titleString || titleString == "" ) return; // invalidate

Expand All @@ -1546,7 +1545,7 @@
tooltip = null; timer = null;
},
createToolTip = function() {
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle); // read the title again
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle); // read the title again
if ( !titleString || titleString == "" ) return false; // invalidate
tooltip = document.createElement(div);
tooltip[setAttribute]('role',component);
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-native-v4.min.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions dist/bootstrap-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
dataInterval = 'data-interval',
dataHeight = 'data-height',
dataPause = 'data-pause',
dataTitle = 'data-title',
dataOriginalTitle = 'data-original-title',
dataOriginalText = 'data-original-text',
dataDismissible = 'data-dismissible',
Expand Down Expand Up @@ -1239,9 +1240,7 @@
classString = 'class',
div = 'div',
fade = 'fade',
title = 'title',
content = 'content',
dataTitle = 'data-title',
dataContent = 'data-content',
dismissible = 'dismissible',
closeBtn = '<button type="button" class="close">×</button>',
Expand Down Expand Up @@ -1681,7 +1680,7 @@

// bind, event targets, title and constants
var self = this, timer = 0, placementSetting = this[placement], tooltip = null,
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle);
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle);

if ( !titleString || titleString == "" ) return; // invalidate

Expand All @@ -1691,7 +1690,7 @@
tooltip = null; timer = null;
},
createToolTip = function() {
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle); // read the title again
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle); // read the title again
if ( !titleString || titleString == "" ) return false; // invalidate

tooltip = document.createElement(div);
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-native.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ <h4>Examples</h4>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom <span class='label label-info'>COOL</span><br> Here we add more content for testing. Perhaps adding even more content would make the job more difficult? Nope, same as if this was a very very short tooltip. Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas.">Bottom</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Tooltip on right <span class='label label-primary'>RECOMMENDED</span><br> Here we add more content for testing. Perhaps adding even more content would make the job more difficult? Nope, same as if this was a very very short tooltip. Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas.">Right</button>
<svg viewBox="0 0 80 34" width="80" height="34" xmlns="http://www.w3.org/2000/svg">
<rect data-toggle="tooltip" data-placement="top" title="Demo Title for SVG" fill="#fff" stroke="#ccc" stroke-width="1" width="100%" height="100%" rx="5"></rect>
<rect data-toggle="tooltip" data-placement="top" data-title="Demo Title for SVG" fill="#fff" stroke="#ccc" stroke-width="1" width="100%" height="100%" rx="5"></rect>
<text fill="#333" x="25" y="22" font-size="14">SVG</text>
</svg>
</p>
Expand Down
2 changes: 0 additions & 2 deletions lib/V3/popover-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ var Popover = function( element, options ) {
classString = 'class',
div = 'div',
fade = 'fade',
title = 'title',
content = 'content',
dataTitle = 'data-title',
dataContent = 'data-content',
dismissible = 'dismissible',
closeBtn = '<button type="button" class="close">×</button>',
Expand Down
4 changes: 2 additions & 2 deletions lib/V3/tooltip-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Tooltip = function( element,options ) {

// bind, event targets, title and constants
var self = this, timer = 0, placementSetting = this[placement], tooltip = null,
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle);
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle);

if ( !titleString || titleString == "" ) return; // invalidate

Expand All @@ -52,7 +52,7 @@ var Tooltip = function( element,options ) {
tooltip = null; timer = null;
},
createToolTip = function() {
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle); // read the title again
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle); // read the title again
if ( !titleString || titleString == "" ) return false; // invalidate

tooltip = document.createElement(div);
Expand Down
1 change: 1 addition & 0 deletions lib/V3/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var globalObject = typeof global !== 'undefined' ? global : this||window,
dataInterval = 'data-interval',
dataHeight = 'data-height',
dataPause = 'data-pause',
dataTitle = 'data-title',
dataOriginalTitle = 'data-original-title',
dataOriginalText = 'data-original-text',
dataDismissible = 'data-dismissible',
Expand Down
2 changes: 0 additions & 2 deletions lib/V4/popover-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ var Popover = function( element, options ) {
classString = 'class',
div = 'div',
fade = 'fade',
title = 'title',
content = 'content',
dataTitle = 'data-title',
dataContent = 'data-content',
dismissible = 'dismissible',
closeBtn = '<button type="button" class="close">×</button>',
Expand Down
4 changes: 2 additions & 2 deletions lib/V4/tooltip-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Tooltip = function( element,options ) {

// bind, event targets, title and constants
var self = this, timer = 0, placementSetting = this[placement], tooltip = null,
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle);
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle);

if ( !titleString || titleString == "" ) return; // invalidate

Expand All @@ -52,7 +52,7 @@ var Tooltip = function( element,options ) {
tooltip = null; timer = null;
},
createToolTip = function() {
titleString = element[getAttribute](title) || element[getAttribute](dataOriginalTitle); // read the title again
titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle); // read the title again
if ( !titleString || titleString == "" ) return false; // invalidate
tooltip = document.createElement(div);
tooltip[setAttribute]('role',component);
Expand Down
1 change: 1 addition & 0 deletions lib/V4/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var globalObject = typeof global !== 'undefined' ? global : this||window,
dataInterval = 'data-interval',
dataHeight = 'data-height',
dataPause = 'data-pause',
dataTitle = 'data-title',
dataOriginalTitle = 'data-original-title',
dataOriginalText = 'data-original-text',
dataDismissible = 'data-dismissible',
Expand Down

0 comments on commit 5c5fb3d

Please sign in to comment.