2013-08-29 12:30:04 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализации модулей
|
|
|
|
|
*
|
|
|
|
|
* @license GNU General Public License, version 2
|
|
|
|
|
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
|
|
|
|
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2012-04-23 13:53:41 +03:00
|
|
|
|
jQuery(document).ready(function($){
|
|
|
|
|
// Хук начала инициализации javascript-составляющих шаблона
|
|
|
|
|
ls.hook.run('ls_template_init_start',[],window);
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modals
|
|
|
|
|
*/
|
|
|
|
|
$('.js-modal-default').modal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Datepicker
|
|
|
|
|
*/
|
|
|
|
|
$('.date-picker').datepicker();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dropdowns
|
|
|
|
|
*/
|
|
|
|
|
$('.js-dropdown-default').dropdown();
|
|
|
|
|
|
|
|
|
|
/* User menu */
|
|
|
|
|
$('.js-dropdown-usermenu').dropdown({
|
|
|
|
|
alignX: 'right',
|
|
|
|
|
offsetY: -1,
|
|
|
|
|
onShow: function () {
|
|
|
|
|
$('#user-menu').addClass('opened');
|
|
|
|
|
},
|
|
|
|
|
onHide: function () {
|
|
|
|
|
$('#user-menu').removeClass('opened');
|
2012-04-23 13:53:41 +03:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/* Create */
|
|
|
|
|
$('.js-dropdown-create').dropdown({
|
|
|
|
|
offsetX: -18,
|
|
|
|
|
offsetY: -41,
|
|
|
|
|
effect: 'show',
|
|
|
|
|
duration: 0,
|
|
|
|
|
onInit: function () {
|
|
|
|
|
var self = this;
|
|
|
|
|
this.$target.find('li.active').prependTo(this.$target).find('a').on('click', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
self.hide();
|
|
|
|
|
});
|
2012-04-23 13:53:41 +03:00
|
|
|
|
}
|
|
|
|
|
});
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
/**
|
2013-04-06 22:06:48 +03:00
|
|
|
|
* Popovers
|
2012-07-01 05:51:31 +03:00
|
|
|
|
*/
|
2013-04-06 22:06:48 +03:00
|
|
|
|
$(document).popover({ selector: '.js-popover-default' });
|
|
|
|
|
|
|
|
|
|
$(document).popover({
|
|
|
|
|
selector: '.js-popover-blog-info',
|
|
|
|
|
alignX: 'left',
|
|
|
|
|
alignY: 'bottom',
|
|
|
|
|
classes: 'popover-blog-info',
|
|
|
|
|
offsetX: -20,
|
2013-04-19 16:57:49 +03:00
|
|
|
|
offsetY: 10
|
2012-04-23 13:53:41 +03:00
|
|
|
|
});
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Tooltips
|
|
|
|
|
*/
|
|
|
|
|
$(document).tooltip({
|
2013-04-19 16:57:49 +03:00
|
|
|
|
selector: '.js-tooltip, .js-tooltip-vote-topic'
|
2012-04-23 13:53:41 +03:00
|
|
|
|
});
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
$('.js-title-talk').tooltip({
|
|
|
|
|
alignX: 'left',
|
|
|
|
|
alignY: 'center',
|
|
|
|
|
classes: 'tooltip-yellow'
|
|
|
|
|
});
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
$('.js-tip-help').tooltip({
|
|
|
|
|
alignX: 'right',
|
|
|
|
|
alignY: 'center'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (ls.registry.get('block_stream_show_tip')) {
|
|
|
|
|
$(document).tooltip({
|
|
|
|
|
selector: '.js-title-comment, .js-title-topic',
|
|
|
|
|
alignX: 'left',
|
|
|
|
|
alignY: 'center',
|
|
|
|
|
classes: 'tooltip-yellow',
|
|
|
|
|
delay: 1500
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Autocomplete
|
|
|
|
|
*/
|
2012-04-23 13:53:41 +03:00
|
|
|
|
ls.autocomplete.add($(".autocomplete-tags-sep"), aRouter['ajax']+'autocompleter/tag/', true);
|
|
|
|
|
ls.autocomplete.add($(".autocomplete-tags"), aRouter['ajax']+'autocompleter/tag/', false);
|
|
|
|
|
ls.autocomplete.add($(".autocomplete-users-sep"), aRouter['ajax']+'autocompleter/user/', true);
|
|
|
|
|
ls.autocomplete.add($(".autocomplete-users"), aRouter['ajax']+'autocompleter/user/', false);
|
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Scroll
|
|
|
|
|
*/
|
2012-04-23 13:53:41 +03:00
|
|
|
|
$(window)._scrollable();
|
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Toolbar
|
|
|
|
|
*/
|
2013-08-29 12:30:04 +03:00
|
|
|
|
$('.js-toolbar').toolbar({
|
|
|
|
|
target: '#wrapper',
|
2013-04-15 08:38:51 +03:00
|
|
|
|
align: 'right',
|
|
|
|
|
offsetX: 7,
|
|
|
|
|
offsetY: 0,
|
2013-08-29 12:30:04 +03:00
|
|
|
|
onReposition: function (e, data) {
|
|
|
|
|
if (data.element.find('section').length) {
|
2013-04-15 08:38:51 +03:00
|
|
|
|
var $cont = $('#container');
|
|
|
|
|
|
|
|
|
|
if ($(document).width() <= 1100) {
|
|
|
|
|
! $cont.hasClass('no-resize') && $cont.addClass('toolbar-margin');
|
|
|
|
|
} else {
|
|
|
|
|
$cont.removeClass('toolbar-margin');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
ls.toolbar.topic.init(); // Тул-бар топиков
|
|
|
|
|
ls.toolbar.up.init(); // Кнопка "UP"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Code highlight
|
|
|
|
|
*/
|
|
|
|
|
prettyPrint();
|
2012-05-27 05:27:01 +03:00
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Blocks
|
|
|
|
|
*/
|
2013-05-04 17:10:22 +03:00
|
|
|
|
ls.blocks.init();
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
|
|
|
|
|
2013-04-06 22:06:48 +03:00
|
|
|
|
/**
|
2013-05-04 17:10:22 +03:00
|
|
|
|
* Activity
|
2013-04-06 22:06:48 +03:00
|
|
|
|
*/
|
2013-05-04 17:10:22 +03:00
|
|
|
|
ls.stream.init();
|
2012-04-23 13:53:41 +03:00
|
|
|
|
|
2013-05-04 17:10:22 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Userfeed
|
|
|
|
|
*/
|
|
|
|
|
ls.userfeed.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Comments
|
|
|
|
|
*/
|
|
|
|
|
ls.comments.init();
|
2012-07-01 05:51:31 +03:00
|
|
|
|
|
2012-04-23 13:53:41 +03:00
|
|
|
|
|
2013-05-30 16:34:30 +03:00
|
|
|
|
/**
|
|
|
|
|
* User
|
|
|
|
|
*/
|
|
|
|
|
ls.user.init();
|
|
|
|
|
|
2013-07-03 07:36:17 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Captcha
|
|
|
|
|
*/
|
|
|
|
|
ls.captcha.init();
|
2013-07-08 07:42:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User Note
|
|
|
|
|
*/
|
|
|
|
|
ls.usernote.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Poll
|
|
|
|
|
*/
|
|
|
|
|
ls.poll.init({
|
|
|
|
|
sAddItemHtml: '<li class="poll-add-item js-poll-add-item">' +
|
|
|
|
|
'<input type="text" name="answer[]" class="poll-add-item-input js-poll-add-item-input">' +
|
|
|
|
|
'<i class="icon-synio-remove poll-add-item-remove js-poll-add-item-remove" title="' + ls.lang.get('delete') + '"></i>' +
|
|
|
|
|
'</li>',
|
|
|
|
|
});
|
2013-07-09 08:09:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Photoset
|
|
|
|
|
*/
|
|
|
|
|
$('.js-photoset-type-default-image').prettyPhoto({
|
|
|
|
|
social_tools: '',
|
|
|
|
|
show_title: false,
|
|
|
|
|
slideshow: false,
|
|
|
|
|
deeplinking: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Editor
|
|
|
|
|
*/
|
|
|
|
|
ls.editor.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Topic
|
|
|
|
|
*/
|
|
|
|
|
ls.topic.init();
|
2013-07-09 11:40:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Vote
|
|
|
|
|
*/
|
|
|
|
|
ls.vote.init();
|
2013-07-15 12:40:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pagination
|
|
|
|
|
*/
|
|
|
|
|
ls.pagination.init();
|
2013-08-29 12:30:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Избраноое
|
|
|
|
|
*/
|
|
|
|
|
ls.favourite.init();
|
2013-07-03 07:36:17 +03:00
|
|
|
|
|
|
|
|
|
|
2012-05-11 16:20:44 +03:00
|
|
|
|
// вступление в блог
|
|
|
|
|
ls.hook.add('ls_blog_toggle_join_after',function(idBlog,result){
|
|
|
|
|
if (!this.data('onlyText')) {
|
|
|
|
|
this.html('<i class="icon-synio-join"></i><span>'+(result.bState ? ls.lang.get('blog_leave') : ls.lang.get('blog_join'))+'</span>');
|
|
|
|
|
if (result.bState) {
|
|
|
|
|
this.addClass('active');
|
|
|
|
|
} else {
|
|
|
|
|
this.removeClass('active');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (this.data('buttonAdditional') && $('#'+this.data('buttonAdditional')).length) {
|
|
|
|
|
$('#'+this.data('buttonAdditional')).html(result.bState ? ls.lang.get('blog_leave') : ls.lang.get('blog_join'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
// лента активности
|
|
|
|
|
ls.hook.add('ls_stream_append_user_after',function(length,data){
|
|
|
|
|
if (length==0) {
|
|
|
|
|
$('#strm_u_'+data.uid).parent().find('a').before('<a href="'+data.user_web_path+'"><img src="'+data.user_avatar_48+'" alt="avatar" class="avatar" /></a> ');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// стена
|
|
|
|
|
ls.hook.add('ls_wall_loadreplynew_after',function(iPid, idMore, result){
|
|
|
|
|
if (result.iCountWall) {
|
|
|
|
|
if ($('#wall-reply-container-'+iPid).length == 0) {
|
|
|
|
|
$('#wall-item-'+iPid).find('.wall-item').after('<div class="wall-item-replies"><div id="wall-reply-container-'+iPid+'" class="wall-item-container"></div></div>');
|
|
|
|
|
$('#wall-reply-container-'+iPid).append(result.sText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
ls.hook.add('ls_wall_remove_reply_item_fade',function(iId, result){
|
|
|
|
|
var rpls = $(this).parent('.wall-item-container').parent();
|
|
|
|
|
$(this).remove();
|
|
|
|
|
if (rpls.children().find('.wall-item-reply').length == 0) {
|
|
|
|
|
rpls.remove();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
ls.hook.add('ls_wall_remove_item_fade',function(iId, result){
|
|
|
|
|
$(this).remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// регистрация
|
|
|
|
|
ls.hook.add('ls_user_validate_registration_fields_after',function(aFields, sForm, result){
|
|
|
|
|
$.each(aFields,function(i,aField){
|
|
|
|
|
if (result.aErrors && result.aErrors[aField.field][0]) {
|
|
|
|
|
sForm.find('.form-item-help-'+aField.field).removeClass('active');
|
|
|
|
|
} else {
|
|
|
|
|
sForm.find('.form-item-help-'+aField.field).addClass('active');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-16 15:41:47 +03:00
|
|
|
|
// Инициализация строчки поиска
|
|
|
|
|
(function(){
|
|
|
|
|
var search_show = $('#search-header-show');
|
|
|
|
|
if (!search_show.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var search_form = $('#search-header-form');
|
|
|
|
|
var write = $('#modal_write_show');
|
|
|
|
|
|
|
|
|
|
search_show.click(function(){
|
2013-06-02 20:02:54 +03:00
|
|
|
|
search_form.toggle().find('input[type=text]').focus();
|
2012-06-16 15:41:47 +03:00
|
|
|
|
$(this).toggle();
|
|
|
|
|
write.toggle();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(document).click(function(){
|
2013-06-02 20:02:54 +03:00
|
|
|
|
if (search_form.find('input[type=text]').val() == '') {
|
2012-06-16 15:41:47 +03:00
|
|
|
|
search_form.hide();
|
|
|
|
|
search_show.show();
|
|
|
|
|
write.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '#search-header-form', function(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
})();
|
2012-05-07 05:02:25 +03:00
|
|
|
|
|
2012-05-12 20:25:11 +03:00
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
ls.talk.toggleSearchForm = function() {
|
|
|
|
|
$('.talk-search').toggleClass('opened'); return false;
|
|
|
|
|
};
|
2012-05-13 20:22:36 +03:00
|
|
|
|
|
2012-07-01 05:51:31 +03:00
|
|
|
|
// Хук конца инициализации javascript-составляющих шаблона
|
|
|
|
|
ls.hook.run('ls_template_init_end',[],window);
|
|
|
|
|
});
|
2012-06-11 23:52:55 +03:00
|
|
|
|
|
|
|
|
|
|
2013-04-09 01:30:54 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Nav Main
|
|
|
|
|
*
|
|
|
|
|
* Группировка не влезающих пунктов в главном меню
|
|
|
|
|
*/
|
2012-07-30 15:32:21 +03:00
|
|
|
|
|
2013-04-09 01:30:54 +03:00
|
|
|
|
(function($) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
function navMainGroup() {
|
|
|
|
|
var nav = $('#nav-main'),
|
|
|
|
|
ddm = $('#dropdown-mainmenu-menu'),
|
|
|
|
|
ddi = nav.find('#nav-main-more'),
|
|
|
|
|
currentWidth = 0,
|
|
|
|
|
isOutofbox = false;
|
|
|
|
|
|
|
|
|
|
ddi.hide().find('a').dropdown('hide');
|
|
|
|
|
ddm.empty();
|
|
|
|
|
|
|
|
|
|
nav.find('li').not(ddi).show().each(function() {
|
|
|
|
|
var item = $(this);
|
|
|
|
|
|
|
|
|
|
if ( ! isOutofbox ) {
|
|
|
|
|
currentWidth += item.outerWidth(true);
|
|
|
|
|
|
|
|
|
|
if ( nav.width() - currentWidth < ddi.outerWidth(true) ) {
|
|
|
|
|
ddi.show();
|
|
|
|
|
isOutofbox = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isOutofbox) {
|
|
|
|
|
item.hide().clone().show().appendTo(ddm);
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-07-30 15:32:21 +03:00
|
|
|
|
}
|
2013-04-09 01:30:54 +03:00
|
|
|
|
|
2013-05-04 17:10:22 +03:00
|
|
|
|
// TODO: load deprecated jQuery 1.9
|
2013-04-09 01:30:54 +03:00
|
|
|
|
$(window).load(function () {
|
|
|
|
|
navMainGroup();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(window).resize(function () {
|
|
|
|
|
navMainGroup();
|
|
|
|
|
});
|
|
|
|
|
})(jQuery);
|