Skip to content

Commit

Permalink
Титл страницы теперь зависит от содержимого редактора
Browse files Browse the repository at this point in the history
  • Loading branch information
anru committed Nov 13, 2011
1 parent 4d57e27 commit 9229b49
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions static/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ function setPreviewHtml(html) {
doc.open();
doc.writeln(html);
doc.close();

var body = doc.body;

var titleText = null;
var headElem = $('h1', body)[0] || $('h2', body)[0] || $('h3', body)[0] || $('h4', body)[0] || $('h5', body)[0] || $('p', body)[0];
if (headElem) {
titleText = headElem.innerText || headElem.textContent;
}
if (titleText) {
$('head title').html(titleText.substr(0, 55) + ' - ' + window.baseTitle);
} else {
$('head title').html(window.baseTitle);
}
}

var activeXhr = null;
Expand Down Expand Up @@ -85,6 +96,8 @@ function adjustBrowse() {

$(function() {
//$('<button>Conver!</button>').click(genPreview).appendTo($('body'));

window.baseTitle = $('head title').text();

$('textarea#editor').bind('change', genPreview).markItUp(mySettings);
timerId = window.setInterval(genPreview, 900);
Expand Down Expand Up @@ -138,24 +151,6 @@ $(function() {
return false;
});

//cache nav
var nav = $("#navigation");

//add indicator and hovers to submenu parents
nav.find("li").each(function() {
if ($(this).find("ul").length > 0) {
//show subnav on hover
$(this).mouseenter(function() {
$(this).find("ul").css('display', '');
});

//hide submenus on exit
$(this).mouseleave(function() {
$(this).find("ul").css('display', 'none');
});
}
});

adjustBrowse();

$(window).bind('resize', adjustBrowse);
Expand Down

0 comments on commit 9229b49

Please sign in to comment.