deblan.tv/src/Deblan/Bundle/BlogBundle/Resources/public/js/main.js
2015-11-25 18:35:09 +01:00

151 lines
4.2 KiB
JavaScript

$('.pop').popover();
$('.error_list').each(function() {
if ($(this).prev().length && $(this).prev().hasClass('form-control')) {
$(this).prev().addClass('has-error');
}
});
$(document).one(
'mousemove',
function() {
$('form[data-secured]').each(function() {
$(this).attr('action', $(this).data('target'));
});
}
);
$('.answer').click(function() {
$('#answer_inprogress').removeClass('hide');
document.location.href = '#form';
$('#comment_ParentCommentId').attr('value', $(this).data('comment'));
});
$('#cancel_answer').click(function() {
$('#answer_inprogress').addClass('hide');
$('#comment_ParentCommentId').attr('value', '');
});
$('*[data-dimensions="destroy"]').removeAttr('width').removeAttr('height');
$('.show-code').click(function() {
$(this).next().toggle();
});
function SyntaxHighlighterAutoloaderPath() {
var args = arguments,
result = [];
for (var i = 0; i < args.length; i++) {
result.push(args[i].replace('@', '/bundles/deblanblog/syntaxhighlighter/scripts/'));
}
return result
};
$('code').each(function() {
var clasName = $(this).attr('class');
if (!clasName) {
return;
}
clasName = clasName
.replace('console', 'shell')
.replace('sh', 'shell')
.replace('texte', 'text')
.replace('apache', 'html');
var $pre = $(this).parent();
$pre
.attr('class', 'brush: ' + clasName + '; gutter: false')
.html($(this).html());
$('<div>')
.addClass('code-container')
.insertAfter($pre)
.append($pre.clone());
$pre.remove();
});
SyntaxHighlighter.autoloader.apply(null, SyntaxHighlighterAutoloaderPath(
'applescript @shBrushAppleScript.js',
'actionscript3 as3 @shBrushAS3.js',
'bash shell console @shBrushBash.js',
'coldfusion cf @shBrushColdFusion.js',
'cpp c @shBrushCpp.js',
'c# c-sharp csharp @shBrushCSharp.js',
'css @shBrushCss.js',
'delphi pascal @shBrushDelphi.js',
'diff patch pas @shBrushDiff.js',
'erl erlang @shBrushErlang.js',
'groovy @shBrushGroovy.js',
'java @shBrushJava.js',
'jfx javafx @shBrushJavaFX.js',
'js jscript javascript @shBrushJScript.js',
'perl pl @shBrushPerl.js',
'php @shBrushPhp.js',
'text plain @shBrushPlain.js',
'py python @shBrushPython.js',
'ruby rails ror rb @shBrushRuby.js',
'sass scss @shBrushSass.js',
'scala @shBrushScala.js',
'sql @shBrushSql.js',
'vb vbnet @shBrushVb.js',
'xml xhtml xslt html @shBrushXml.js'
));
SyntaxHighlighter.all();
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.deblan.org//";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', 1]);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.defer = true;
g.async = true;
g.src = u + 'piwik.js';
s.parentNode.insertBefore(g, s);
})();
var createCookie = function(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
}
var readCookie = function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
if (!readCookie('private_life')) {
createCookie('private_life', '1', 365);
$('#cookie').removeClass('hide').css({
bottom: 0,
position: 'fixed',
width: '100%'
});
}