Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.
Open
Changes from all commits
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
26 changes: 18 additions & 8 deletions jquery.watermark.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
elems.each(function () {
var $elem, attr_name, label_text, watermark_container, watermark_label;
var e_margin_left, e_margin_top, pos, e_top = 0, height, line_height;
var e_boxSizing; //LG: Added

$elem = $(this);
if ($elem.attr('data-jq-watermark') == 'processed')
Expand Down Expand Up @@ -85,24 +86,32 @@

$elem.wrap(watermark_container).attr('data-jq-watermark', 'processed');

e_boxSizing = $elem.css('box-sizing'); //LG: Added
if (this.nodeName.toLowerCase() == 'textarea') {
e_height = $elem.css('line-height');
e_height = e_height === 'normal' ? parseInt($elem.css('font-size')) : e_height;
e_top = ($elem.css('padding-top') != 'auto' ? parseInt($elem.css('padding-top')) : 0);
} else {
e_height = $elem.outerHeight();
if (e_height <= 0) {
e_height = ($elem.css('padding-top') != 'auto' ? parseInt($elem.css('padding-top')) : 0);
e_height += ($elem.css('padding-bottom') != 'auto' ? parseInt($elem.css('padding-bottom')) : 0);
e_height += ($elem.css('height') != 'auto' ? parseInt($elem.css('height')) : 0);
}
if (e_boxSizing != null && e_boxSizing.toLowerCase() == "border-box") { //LG: Added
e_height = $elem.height(); //LG: Added
} //LG: Added
else { //LG: Added
e_height = $elem.outerHeight();

if (e_height <= 0) {
e_height = ($elem.css('padding-top') != 'auto' ? parseInt($elem.css('padding-top')) : 0);
e_height += ($elem.css('padding-bottom') != 'auto' ? parseInt($elem.css('padding-bottom')) : 0);
e_height += ($elem.css('height') != 'auto' ? parseInt($elem.css('height')) : 0);
}
} //LG: Added
}

e_top += ($elem.css('margin-top') != 'auto' ? parseInt($elem.css('margin-top')) : 0);

e_margin_left = $elem.css('margin-left') != 'auto' ? parseInt($elem.css('margin-left')) : 0;
e_margin_left += $elem.css('padding-left') != 'auto' ? parseInt($elem.css('padding-left')) : 0;


watermark_label.css({
position: 'absolute',
display: 'block',
Expand All @@ -114,7 +123,8 @@
height: e_height,
lineHeight: e_height + 'px',
textAlign: 'left',
pointerEvents: 'none'
pointerEvents: 'none',
"box-sizing": e_boxSizing //LG: added
}).data('jq_watermark_element', $elem);

$.watermarker.checkVal($elem.val(), watermark_label);
Expand Down Expand Up @@ -147,4 +157,4 @@
$(function () {
$('.jq_watermark').watermark();
})
})(jQuery);
})(jQuery);