Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add data-trunk8-* support #44

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions trunk8.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
width = settings.width,
side = settings.side,
fill = settings.fill,
parseHTML = settings.parseHTML,
parseHTML = settings.parseHTML && settings.parseHTML !== 'false',
line_height = utils.getLineHeight(this) * settings.lines,
str = data.original_text,
length = str.length,
Expand Down Expand Up @@ -197,7 +197,7 @@
/* Display the biggest bite. */
this.html(max_bite);

if (settings.tooltip) {
if (settings.tooltip && settings.tooltip !== 'false') {
this.attr('title', text);
}
}
Expand All @@ -208,7 +208,7 @@

this.html(bite);

if (settings.tooltip) {
if (settings.tooltip && settings.tooltip !== 'false') {
this.attr('title', str);
}
}
Expand All @@ -226,8 +226,18 @@
if (!data) {
$this.data('trunk8', (data = new trunk8(this)));
}

// add data-trunk8-* support
var elAttr = {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer verbose name "elementAttributes"

var attributes = $this[0].attributes;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why $this[0]? This is inside of a "this.each" function.

if(attributes) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before (

$.each(attributes,function(index,atr){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before function, atr, and {.

Rename "atr" to "attribute".

if(atr.name.indexOf('data-trunk8-') == 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after "if".

Save "data-trunk8-" to a variable, "trunk8DataAttributeName".

elAttr[atr.name.substring(12)] = atr.value;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elementAttributes[trunk8DataAttributeName.length] = attribute.value;

}
});
}
data.updateSettings(options);
data.updateSettings(elAttr);

truncate.call($this);
});
Expand Down