Created
August 19, 2014 16:33
-
-
Save tillda/6e3f70d357765d9b6629 to your computer and use it in GitHub Desktop.
Glogster - dalsi upravy textu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var containerHeight = this.viewport.height; // vypocitana pixelova velikost na glogu | |
var currentFlowHeight = $(this.domHtml).height(); // velikost vyrenderovaneho textu | |
var mainFontSize = $(this.domMarkup).data("mainfontsize"); // z normalizeru | |
var scrollingForbidden = false; | |
var domLastInnerSizedElement = this.domText; // posledni element nad this.domHtml s nastavenyma velikostma n, | |
var currentBoxWidth = $(domLastInnerSizedElement).width(); | |
var currentBoxHeight = $(domLastInnerSizedElement).height(); | |
function decreaseFontSize(match, value, unit) { | |
switch (unit) { | |
case "px": | |
return (parseFloat(value, 10)-0.5) + unit; | |
} | |
return match; | |
}; | |
var reFs = /([0-9\.]+) *([^ ]*)/; | |
// Text vycuhuje | |
if ((currentFlowHeight > currentBoxHeight - mainFontSize)) { | |
$(this.domText).find("span.font-sized").each(function(i, domSpan) { | |
var fs = domSpan.style.fontSize; | |
$(domSpan).attr("data-original-font-size", fs); | |
fs = fs.replace(reFs, decreaseFontSize); | |
if (currentFlowHeight == $(that.domHtml).height()) { | |
fs = fs.replace(reFs, decreaseFontSize); | |
} | |
domSpan.style.fontSize = fs; | |
}); | |
} | |
// pridavani trid pro scrollovani - toto te uz podle me nezajima | |
$(domLastInnerSizedElement).css("width", currentBoxWidth+"px"); | |
if ((!scrollingForbidden) && (currentFlowHeight > containerHeight*1.7)) { | |
$(this.domText).removeClass("text__content_scrolling_off").addClass("text__content_scrolling_on"); | |
} | |
$(this.domMain).removeClass("text__main_progress_waiting").addClass("text__main_progress_ready"); | |
this.domHtml.style.width = currentBoxWidth+"px"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment