diff --git a/config/config.php b/config/config.php index a334f843..b810c2dc 100644 --- a/config/config.php +++ b/config/config.php @@ -499,28 +499,28 @@ $config['head']['default']['js'] = array( "___path.root.engine_lib___/external/jquery/jquery.placeholder.min.js", "___path.root.engine_lib___/external/jquery/jquery.charcount.js", "___path.root.engine_lib___/external/prettify/prettify.js", - "___path.root.engine_lib___/internal/template/js/main.js", - "___path.root.engine_lib___/internal/template/js/favourite.js", - "___path.root.engine_lib___/internal/template/js/blocks.js", - "___path.root.engine_lib___/internal/template/js/talk.js", - "___path.root.engine_lib___/internal/template/js/vote.js", - "___path.root.engine_lib___/internal/template/js/poll.js", - "___path.root.engine_lib___/internal/template/js/subscribe.js", - "___path.root.engine_lib___/internal/template/js/infobox.js", - "___path.root.engine_lib___/internal/template/js/geo.js", - "___path.root.engine_lib___/internal/template/js/wall.js", - "___path.root.engine_lib___/internal/template/js/usernote.js", - "___path.root.engine_lib___/internal/template/js/comments.js", - "___path.root.engine_lib___/internal/template/js/blog.js", - "___path.root.engine_lib___/internal/template/js/user.js", - "___path.root.engine_lib___/internal/template/js/userfeed.js", - "___path.root.engine_lib___/internal/template/js/userfield.js", - "___path.root.engine_lib___/internal/template/js/stream.js", - "___path.root.engine_lib___/internal/template/js/photoset.js", - "___path.root.engine_lib___/internal/template/js/toolbar.js", - "___path.root.engine_lib___/internal/template/js/settings.js", - "___path.root.engine_lib___/internal/template/js/topic.js", - "___path.root.engine_lib___/internal/template/js/hook.js", + "___path.root.server/templates/framework/js/main.js", + "___path.root.server/templates/framework/js/favourite.js", + "___path.root.server/templates/framework/js/blocks.js", + "___path.root.server/templates/framework/js/talk.js", + "___path.root.server/templates/framework/js/vote.js", + "___path.root.server/templates/framework/js/poll.js", + "___path.root.server/templates/framework/js/subscribe.js", + "___path.root.server/templates/framework/js/infobox.js", + "___path.root.server/templates/framework/js/geo.js", + "___path.root.server/templates/framework/js/wall.js", + "___path.root.server/templates/framework/js/usernote.js", + "___path.root.server/templates/framework/js/comments.js", + "___path.root.server/templates/framework/js/blog.js", + "___path.root.server/templates/framework/js/user.js", + "___path.root.server/templates/framework/js/userfeed.js", + "___path.root.server/templates/framework/js/userfield.js", + "___path.root.server/templates/framework/js/stream.js", + "___path.root.server/templates/framework/js/photoset.js", + "___path.root.server/templates/framework/js/toolbar.js", + "___path.root.server/templates/framework/js/settings.js", + "___path.root.server/templates/framework/js/topic.js", + "___path.root.server/templates/framework/js/hook.js", "http://yandex.st/share/share.js" => array('merge'=>false), ); $config['head']['default']['css'] = array( diff --git a/templates/framework/css/.gitignore b/templates/framework/css/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/engine/lib/internal/template/js/blocks.js b/templates/framework/js/blocks.js similarity index 100% rename from engine/lib/internal/template/js/blocks.js rename to templates/framework/js/blocks.js diff --git a/engine/lib/internal/template/js/blog.js b/templates/framework/js/blog.js similarity index 100% rename from engine/lib/internal/template/js/blog.js rename to templates/framework/js/blog.js diff --git a/engine/lib/internal/template/js/comments.js b/templates/framework/js/comments.js similarity index 96% rename from engine/lib/internal/template/js/comments.js rename to templates/framework/js/comments.js index e4c1a364..079991c9 100644 --- a/engine/lib/internal/template/js/comments.js +++ b/templates/framework/js/comments.js @@ -1,363 +1,363 @@ -var ls = ls || {}; - -/** -* Обработка комментариев -*/ -ls.comments = (function ($) { - /** - * Опции - */ - this.options = { - type: { - topic: { - url_add: aRouter.blog+'ajaxaddcomment/', - url_response: aRouter.blog+'ajaxresponsecomment/' - }, - talk: { - url_add: aRouter.talk+'ajaxaddcomment/', - url_response: aRouter.talk+'ajaxresponsecomment/' - } - }, - classes: { - form_loader: 'loader', - comment_new: 'comment-new', - comment_current: 'comment-current', - comment_deleted: 'comment-deleted', - comment_self: 'comment-self', - comment: 'comment', - comment_goto_parent: 'goto-comment-parent', - comment_goto_child: 'goto-comment-child' - }, - wysiwyg: null, - folding: true - }; - - this.iCurrentShowFormComment=0; - this.iCurrentViewComment=null; - this.aCommentNew=[]; - - // Добавляет комментарий - this.add = function(formObj, targetId, targetType) { - if (this.options.wysiwyg) { - $('#'+formObj+' textarea').val(tinyMCE.activeEditor.getContent()); - } - formObj = $('#'+formObj); - - $('#form_comment_text').addClass(this.options.classes.form_loader).attr('readonly',true); - $('#comment-button-submit').attr('disabled', 'disabled'); - - ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){ - $('#comment-button-submit').removeAttr('disabled'); - if (!result) { - this.enableFormComment(); - ls.msg.error('Error','Please try again later'); - return; - } - if (result.bStateError) { - this.enableFormComment(); - ls.msg.error(null,result.sMsg); - } else { - this.enableFormComment(); - $('#form_comment_text').val(''); - - // Load new comments - this.load(targetId, targetType, result.sCommentId, true); - ls.hook.run('ls_comments_add_after',[formObj, targetId, targetType, result]); - } - }.bind(this)); - }; - - - // Активирует форму - this.enableFormComment = function() { - $('#form_comment_text').removeClass(this.options.classes.form_loader).attr('readonly',false); - }; - - - // Показывает/скрывает форму комментирования - this.toggleCommentForm = function(idComment, bNoFocus) { - var reply=$('#reply'); - if(!reply.length){ - return; - } - $('#comment_preview_' + this.iCurrentShowFormComment).remove(); - - if (this.iCurrentShowFormComment==idComment && reply.is(':visible')) { - reply.hide(); - return; - } - if (this.options.wysiwyg) { - tinyMCE.execCommand('mceRemoveControl',true,'form_comment_text'); - } - reply.insertAfter('#comment_id_'+idComment).show(); - $('#form_comment_text').val(''); - $('#form_comment_reply').val(idComment); - - this.iCurrentShowFormComment = idComment; - if (this.options.wysiwyg) { - tinyMCE.execCommand('mceAddControl',true,'form_comment_text'); - } - if (!bNoFocus) $('#form_comment_text').focus(); - - if ($('html').hasClass('ie7')) { - var inputs = $('input.input-text, textarea'); - ls.ie.bordersizing(inputs); - } - }; - - - // Подгружает новые комментарии - this.load = function(idTarget, typeTarget, selfIdComment, bNotFlushNew) { - var idCommentLast = $("#comment_last_id").val(); - - // Удаляем подсветку у комментариев - if (!bNotFlushNew) { - $('.comment').each(function(index, item){ - $(item).removeClass(this.options.classes.comment_new+' '+this.options.classes.comment_current); - }.bind(this)); - } - - objImg = $('#update-comments'); - objImg.addClass('active'); - - var params = { idCommentLast: idCommentLast, idTarget: idTarget, typeTarget: typeTarget }; - if (selfIdComment) { - params.selfIdComment = selfIdComment; - } - if ($('#comment_use_paging').val()) { - params.bUsePaging = 1; - } - - ls.ajax(this.options.type[typeTarget].url_response, params, function(result) { - objImg.removeClass('active'); - - if (!result) { ls.msg.error('Error','Please try again later'); } - if (result.bStateError) { - ls.msg.error(null,result.sMsg); - } else { - var aCmt = result.aComments; - if (aCmt.length > 0 && result.iMaxIdComment) { - $("#comment_last_id").val(result.iMaxIdComment); - $('#count-comments').text(parseInt($('#count-comments').text())+aCmt.length); - if (ls.blocks) { - var curItemBlock=ls.blocks.getCurrentItem('stream'); - if (curItemBlock.data('type')=='comment') { - ls.blocks.load(curItemBlock, 'stream'); - } - } - } - var iCountOld=0; - if (bNotFlushNew) { - iCountOld=this.aCommentNew.length; - } else { - this.aCommentNew=[]; - } - if (selfIdComment) { - this.toggleCommentForm(this.iCurrentShowFormComment, true); - this.setCountNewComment(aCmt.length-1+iCountOld); - } else { - this.setCountNewComment(aCmt.length+iCountOld); - } - - $.each(aCmt, function(index, item) { - if (!(selfIdComment && selfIdComment==item.id)) { - this.aCommentNew.push(item.id); - } - this.inject(item.idParent, item.id, item.html); - }.bind(this)); - - if (selfIdComment && $('#comment_id_'+selfIdComment).length) { - this.scrollToComment(selfIdComment); - } - this.checkFolding(); - ls.hook.run('ls_comments_load_after',[idTarget, typeTarget, selfIdComment, bNotFlushNew, result]); - } - }.bind(this)); - }; - - - // Вставка комментария - this.inject = function(idCommentParent, idComment, sHtml) { - var newComment = $('
', {'class': 'comment-wrapper', id: 'comment_wrapper_id_'+idComment}).html(sHtml); - if (idCommentParent) { - // Уровень вложенности родителя - var iCurrentTree = $('#comment_wrapper_id_'+idCommentParent).parentsUntil('#comments').length; - if(iCurrentTree == ls.registry.get('comment_max_tree')) { - // Определяем id предыдушего родителя - var prevCommentParent = $('#comment_wrapper_id_'+idCommentParent).parent(); - idCommentParent = parseInt(prevCommentParent.attr('id').replace('comment_wrapper_id_','')); - } - $('#comment_wrapper_id_'+idCommentParent).append(newComment); - } else { - $('#comments').append(newComment); - } - ls.hook.run('ls_comment_inject_after',arguments,newComment); - }; - - - // Удалить/восстановить комментарий - this.toggle = function(obj, commentId) { - var url = aRouter['ajax']+'comment/delete/'; - var params = { idComment: commentId }; - - ls.hook.marker('toggleBefore'); - ls.ajax(url, params, function(result){ - if (!result) { - ls.msg.error('Error','Please try again later'); - } - if (result.bStateError) { - ls.msg.error(null,result.sMsg); - } else { - ls.msg.notice(null,result.sMsg); - - $('#comment_id_'+commentId).removeClass(this.options.classes.comment_self+' '+this.options.classes.comment_new+' '+this.options.classes.comment_deleted+' '+this.options.classes.comment_current); - if (result.bState) { - $('#comment_id_'+commentId).addClass(this.options.classes.comment_deleted); - } - $(obj).text(result.sTextToggle); - ls.hook.run('ls_comments_toggle_after',[obj,commentId,result]); - } - }.bind(this)); - }; - - - // Предпросмотр комментария - this.preview = function(divPreview) { - if (this.options.wysiwyg) { - $("#form_comment_text").val(tinyMCE.activeEditor.getContent()); - } - if ($("#form_comment_text").val() == '') return; - $("#comment_preview_" + this.iCurrentShowFormComment).remove(); - $('#reply').before('
'); - ls.tools.textPreview('form_comment_text', false, 'comment_preview_' + this.iCurrentShowFormComment); - }; - - - // Устанавливает число новых комментариев - this.setCountNewComment = function(count) { - if (count > 0) { - $('#new_comments_counter').show().text(count); - } else { - $('#new_comments_counter').text(0).hide(); - } - }; - - - // Вычисляет кол-во новых комментариев - this.calcNewComments = function() { - var aCommentsNew = $('.'+this.options.classes.comment+'.'+this.options.classes.comment_new); - this.setCountNewComment(aCommentsNew.length); - $.each(aCommentsNew,function(k,v){ - this.aCommentNew.push(parseInt($(v).attr('id').replace('comment_id_',''))); - }.bind(this)); - }; - - - // Переход к следующему комментарию - this.goToNextComment = function() { - if (this.aCommentNew[0]) { - if ($('#comment_id_'+this.aCommentNew[0]).length) { - this.scrollToComment(this.aCommentNew[0]); - } - this.aCommentNew.shift(); - } - this.setCountNewComment(this.aCommentNew.length); - }; - - - // Прокрутка к комментарию - this.scrollToComment = function(idComment) { - $.scrollTo('#comment_id_'+idComment, 1000, {offset: -250}); - - if (this.iCurrentViewComment) { - $('#comment_id_'+this.iCurrentViewComment).removeClass(this.options.classes.comment_current); - } - $('#comment_id_'+idComment).addClass(this.options.classes.comment_current); - this.iCurrentViewComment=idComment; - }; - - - // Прокрутка к родительскому комментарию - this.goToParentComment = function(id, pid) { - thisObj = this; - $('.'+this.options.classes.comment_goto_child).hide().find('a').unbind(); - - $("#comment_id_"+pid).find('.'+this.options.classes.comment_goto_child).show().find("a").bind("click", function(){ - $(this).parent('.'+thisObj.options.classes.comment_goto_child).hide(); - thisObj.scrollToComment(id); - return false; - }); - this.scrollToComment(pid); - return false; - }; - - - // Сворачивание комментариев - this.checkFolding = function() { - if(!this.options.folding){ - return false; - } - $(".folding").each(function(index, element){ - if ($(element).parent(".comment").next(".comment-wrapper").length == 0) { - $(element).hide(); - } else { - $(element).show(); - } - }); - return false; - }; - - this.expandComment = function(folding) { - $(folding).removeClass("folded").parent().nextAll(".comment-wrapper").show(); - }; - - this.collapseComment = function(folding) { - $(folding).addClass("folded").parent().nextAll(".comment-wrapper").hide(); - }; - - this.expandCommentAll = function() { - $.each($(".folding"),function(k,v){ - this.expandComment(v); - }.bind(this)); - }; - - this.collapseCommentAll = function() { - $.each($(".folding"),function(k,v){ - this.collapseComment(v); - }.bind(this)); - }; - - this.init = function() { - this.initEvent(); - this.calcNewComments(); - this.checkFolding(); - this.toggleCommentForm(this.iCurrentShowFormComment); - - if (typeof(this.options.wysiwyg)!='number') { - this.options.wysiwyg = Boolean(BLOG_USE_TINYMCE && tinyMCE); - } - ls.hook.run('ls_comments_init_after',[],this); - }; - - this.initEvent = function() { - $('#form_comment_text').bind('keyup', function(e) { - key = e.keyCode || e.which; - if(e.ctrlKey && (key == 13)) { - $('#comment-button-submit').click(); - return false; - } - }); - - if(this.options.folding){ - $(".folding").click(function(e){ - if ($(e.target).hasClass("folded")) { - this.expandComment(e.target); - } else { - this.collapseComment(e.target); - } - }.bind(this)); - } - }; - - return this; -}).call(ls.comments || {},jQuery); +var ls = ls || {}; + +/** +* Обработка комментариев +*/ +ls.comments = (function ($) { + /** + * Опции + */ + this.options = { + type: { + topic: { + url_add: aRouter.blog+'ajaxaddcomment/', + url_response: aRouter.blog+'ajaxresponsecomment/' + }, + talk: { + url_add: aRouter.talk+'ajaxaddcomment/', + url_response: aRouter.talk+'ajaxresponsecomment/' + } + }, + classes: { + form_loader: 'loader', + comment_new: 'comment-new', + comment_current: 'comment-current', + comment_deleted: 'comment-deleted', + comment_self: 'comment-self', + comment: 'comment', + comment_goto_parent: 'goto-comment-parent', + comment_goto_child: 'goto-comment-child' + }, + wysiwyg: null, + folding: true + }; + + this.iCurrentShowFormComment=0; + this.iCurrentViewComment=null; + this.aCommentNew=[]; + + // Добавляет комментарий + this.add = function(formObj, targetId, targetType) { + if (this.options.wysiwyg) { + $('#'+formObj+' textarea').val(tinyMCE.activeEditor.getContent()); + } + formObj = $('#'+formObj); + + $('#form_comment_text').addClass(this.options.classes.form_loader).attr('readonly',true); + $('#comment-button-submit').attr('disabled', 'disabled'); + + ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){ + $('#comment-button-submit').removeAttr('disabled'); + if (!result) { + this.enableFormComment(); + ls.msg.error('Error','Please try again later'); + return; + } + if (result.bStateError) { + this.enableFormComment(); + ls.msg.error(null,result.sMsg); + } else { + this.enableFormComment(); + $('#form_comment_text').val(''); + + // Load new comments + this.load(targetId, targetType, result.sCommentId, true); + ls.hook.run('ls_comments_add_after',[formObj, targetId, targetType, result]); + } + }.bind(this)); + }; + + + // Активирует форму + this.enableFormComment = function() { + $('#form_comment_text').removeClass(this.options.classes.form_loader).attr('readonly',false); + }; + + + // Показывает/скрывает форму комментирования + this.toggleCommentForm = function(idComment, bNoFocus) { + var reply=$('#reply'); + if(!reply.length){ + return; + } + $('#comment_preview_' + this.iCurrentShowFormComment).remove(); + + if (this.iCurrentShowFormComment==idComment && reply.is(':visible')) { + reply.hide(); + return; + } + if (this.options.wysiwyg) { + tinyMCE.execCommand('mceRemoveControl',true,'form_comment_text'); + } + reply.insertAfter('#comment_id_'+idComment).show(); + $('#form_comment_text').val(''); + $('#form_comment_reply').val(idComment); + + this.iCurrentShowFormComment = idComment; + if (this.options.wysiwyg) { + tinyMCE.execCommand('mceAddControl',true,'form_comment_text'); + } + if (!bNoFocus) $('#form_comment_text').focus(); + + if ($('html').hasClass('ie7')) { + var inputs = $('input.input-text, textarea'); + ls.ie.bordersizing(inputs); + } + }; + + + // Подгружает новые комментарии + this.load = function(idTarget, typeTarget, selfIdComment, bNotFlushNew) { + var idCommentLast = $("#comment_last_id").val(); + + // Удаляем подсветку у комментариев + if (!bNotFlushNew) { + $('.comment').each(function(index, item){ + $(item).removeClass(this.options.classes.comment_new+' '+this.options.classes.comment_current); + }.bind(this)); + } + + objImg = $('#update-comments'); + objImg.addClass('active'); + + var params = { idCommentLast: idCommentLast, idTarget: idTarget, typeTarget: typeTarget }; + if (selfIdComment) { + params.selfIdComment = selfIdComment; + } + if ($('#comment_use_paging').val()) { + params.bUsePaging = 1; + } + + ls.ajax(this.options.type[typeTarget].url_response, params, function(result) { + objImg.removeClass('active'); + + if (!result) { ls.msg.error('Error','Please try again later'); } + if (result.bStateError) { + ls.msg.error(null,result.sMsg); + } else { + var aCmt = result.aComments; + if (aCmt.length > 0 && result.iMaxIdComment) { + $("#comment_last_id").val(result.iMaxIdComment); + $('#count-comments').text(parseInt($('#count-comments').text())+aCmt.length); + if (ls.blocks) { + var curItemBlock=ls.blocks.getCurrentItem('stream'); + if (curItemBlock.data('type')=='comment') { + ls.blocks.load(curItemBlock, 'stream'); + } + } + } + var iCountOld=0; + if (bNotFlushNew) { + iCountOld=this.aCommentNew.length; + } else { + this.aCommentNew=[]; + } + if (selfIdComment) { + this.toggleCommentForm(this.iCurrentShowFormComment, true); + this.setCountNewComment(aCmt.length-1+iCountOld); + } else { + this.setCountNewComment(aCmt.length+iCountOld); + } + + $.each(aCmt, function(index, item) { + if (!(selfIdComment && selfIdComment==item.id)) { + this.aCommentNew.push(item.id); + } + this.inject(item.idParent, item.id, item.html); + }.bind(this)); + + if (selfIdComment && $('#comment_id_'+selfIdComment).length) { + this.scrollToComment(selfIdComment); + } + this.checkFolding(); + ls.hook.run('ls_comments_load_after',[idTarget, typeTarget, selfIdComment, bNotFlushNew, result]); + } + }.bind(this)); + }; + + + // Вставка комментария + this.inject = function(idCommentParent, idComment, sHtml) { + var newComment = $('
', {'class': 'comment-wrapper', id: 'comment_wrapper_id_'+idComment}).html(sHtml); + if (idCommentParent) { + // Уровень вложенности родителя + var iCurrentTree = $('#comment_wrapper_id_'+idCommentParent).parentsUntil('#comments').length; + if(iCurrentTree == ls.registry.get('comment_max_tree')) { + // Определяем id предыдушего родителя + var prevCommentParent = $('#comment_wrapper_id_'+idCommentParent).parent(); + idCommentParent = parseInt(prevCommentParent.attr('id').replace('comment_wrapper_id_','')); + } + $('#comment_wrapper_id_'+idCommentParent).append(newComment); + } else { + $('#comments').append(newComment); + } + ls.hook.run('ls_comment_inject_after',arguments,newComment); + }; + + + // Удалить/восстановить комментарий + this.toggle = function(obj, commentId) { + var url = aRouter['ajax']+'comment/delete/'; + var params = { idComment: commentId }; + + ls.hook.marker('toggleBefore'); + ls.ajax(url, params, function(result){ + if (!result) { + ls.msg.error('Error','Please try again later'); + } + if (result.bStateError) { + ls.msg.error(null,result.sMsg); + } else { + ls.msg.notice(null,result.sMsg); + + $('#comment_id_'+commentId).removeClass(this.options.classes.comment_self+' '+this.options.classes.comment_new+' '+this.options.classes.comment_deleted+' '+this.options.classes.comment_current); + if (result.bState) { + $('#comment_id_'+commentId).addClass(this.options.classes.comment_deleted); + } + $(obj).text(result.sTextToggle); + ls.hook.run('ls_comments_toggle_after',[obj,commentId,result]); + } + }.bind(this)); + }; + + + // Предпросмотр комментария + this.preview = function(divPreview) { + if (this.options.wysiwyg) { + $("#form_comment_text").val(tinyMCE.activeEditor.getContent()); + } + if ($("#form_comment_text").val() == '') return; + $("#comment_preview_" + this.iCurrentShowFormComment).remove(); + $('#reply').before('
'); + ls.tools.textPreview('form_comment_text', false, 'comment_preview_' + this.iCurrentShowFormComment); + }; + + + // Устанавливает число новых комментариев + this.setCountNewComment = function(count) { + if (count > 0) { + $('#new_comments_counter').show().text(count); + } else { + $('#new_comments_counter').text(0).hide(); + } + }; + + + // Вычисляет кол-во новых комментариев + this.calcNewComments = function() { + var aCommentsNew = $('.'+this.options.classes.comment+'.'+this.options.classes.comment_new); + this.setCountNewComment(aCommentsNew.length); + $.each(aCommentsNew,function(k,v){ + this.aCommentNew.push(parseInt($(v).attr('id').replace('comment_id_',''))); + }.bind(this)); + }; + + + // Переход к следующему комментарию + this.goToNextComment = function() { + if (this.aCommentNew[0]) { + if ($('#comment_id_'+this.aCommentNew[0]).length) { + this.scrollToComment(this.aCommentNew[0]); + } + this.aCommentNew.shift(); + } + this.setCountNewComment(this.aCommentNew.length); + }; + + + // Прокрутка к комментарию + this.scrollToComment = function(idComment) { + $.scrollTo('#comment_id_'+idComment, 1000, {offset: -250}); + + if (this.iCurrentViewComment) { + $('#comment_id_'+this.iCurrentViewComment).removeClass(this.options.classes.comment_current); + } + $('#comment_id_'+idComment).addClass(this.options.classes.comment_current); + this.iCurrentViewComment=idComment; + }; + + + // Прокрутка к родительскому комментарию + this.goToParentComment = function(id, pid) { + thisObj = this; + $('.'+this.options.classes.comment_goto_child).hide().find('a').unbind(); + + $("#comment_id_"+pid).find('.'+this.options.classes.comment_goto_child).show().find("a").bind("click", function(){ + $(this).parent('.'+thisObj.options.classes.comment_goto_child).hide(); + thisObj.scrollToComment(id); + return false; + }); + this.scrollToComment(pid); + return false; + }; + + + // Сворачивание комментариев + this.checkFolding = function() { + if(!this.options.folding){ + return false; + } + $(".folding").each(function(index, element){ + if ($(element).parent(".comment").next(".comment-wrapper").length == 0) { + $(element).hide(); + } else { + $(element).show(); + } + }); + return false; + }; + + this.expandComment = function(folding) { + $(folding).removeClass("folded").parent().nextAll(".comment-wrapper").show(); + }; + + this.collapseComment = function(folding) { + $(folding).addClass("folded").parent().nextAll(".comment-wrapper").hide(); + }; + + this.expandCommentAll = function() { + $.each($(".folding"),function(k,v){ + this.expandComment(v); + }.bind(this)); + }; + + this.collapseCommentAll = function() { + $.each($(".folding"),function(k,v){ + this.collapseComment(v); + }.bind(this)); + }; + + this.init = function() { + this.initEvent(); + this.calcNewComments(); + this.checkFolding(); + this.toggleCommentForm(this.iCurrentShowFormComment); + + if (typeof(this.options.wysiwyg)!='number') { + this.options.wysiwyg = Boolean(BLOG_USE_TINYMCE && tinyMCE); + } + ls.hook.run('ls_comments_init_after',[],this); + }; + + this.initEvent = function() { + $('#form_comment_text').bind('keyup', function(e) { + key = e.keyCode || e.which; + if(e.ctrlKey && (key == 13)) { + $('#comment-button-submit').click(); + return false; + } + }); + + if(this.options.folding){ + $(".folding").click(function(e){ + if ($(e.target).hasClass("folded")) { + this.expandComment(e.target); + } else { + this.collapseComment(e.target); + } + }.bind(this)); + } + }; + + return this; +}).call(ls.comments || {},jQuery); diff --git a/engine/lib/internal/template/js/favourite.js b/templates/framework/js/favourite.js similarity index 100% rename from engine/lib/internal/template/js/favourite.js rename to templates/framework/js/favourite.js diff --git a/engine/lib/internal/template/js/geo.js b/templates/framework/js/geo.js similarity index 100% rename from engine/lib/internal/template/js/geo.js rename to templates/framework/js/geo.js diff --git a/engine/lib/internal/template/js/hook.js b/templates/framework/js/hook.js similarity index 95% rename from engine/lib/internal/template/js/hook.js rename to templates/framework/js/hook.js index 81c93a05..f54b76c5 100644 --- a/engine/lib/internal/template/js/hook.js +++ b/templates/framework/js/hook.js @@ -1,114 +1,114 @@ -/** - * JavaScript-hooks - * - * Examples: - * - * - inject function call/code at top of function body - * ls.hook.inject([ls.lang,'get'], function(){ls.msg.notice('lang debug');})}); - * ls.hook.inject([ls,'ajax'], 'alert(url)'); - * - * - add and call hooks - * ls.hook.add('somefunc_hook1_name', function(param1, param2){ ... }); - * - * function someFunc(..params..){ - * //code - * ls.hook.run('somefunc_hook1_name', [param1,param2], thisArg); - * //code - * } - * - * @author Sergey S Yaglov - * @link http://livestreet.ru/profile/1d10t - */ -ls.hook = (function ($) { - this.hooks = {}; - - this.cloneFunc = function(func,as_text,no_def) { - var f; - if($.type(func)=='string'){ - eval('f = '+func+';'); - }else if($.type(func)=='array'){ - f = func[0][func[1]]; - }else{ - f = func; - } - if($.type(f)=='function'){ - var fbody = f.toString().replace(/^(function)([^\(]*)\(/gi, '$1 ('); - if(typeof as_text!='undefined' && as_text){ - if(typeof no_def!='undefined' && no_def){ - return fbody.replace(/^[^\{]*\{/gi, '').replace(/\}$/gi, ''); - }else{ - return fbody; - } - } - return eval('('+fbody+')'); - } - return function(){}; - }; - - /** - * @param func functionName|object[parentObject,functionName] Name of function that will be modified - * @param funcInj function|string Function or code to be injected - * @param marker string - */ - this.inject = function(func,funcInj,marker) { - var funcBody = ls.hook.cloneFunc(func, 1); - var funcDefinition = ($.type(func)=='string'?func:($.type(func)=='array'?'func[0][func[1]]':'func'))+' = '; - var replaceFrom = /\{/m; - var replaceTo = '{ '; - if($.type(marker) == 'string'){ - //replaceFrom = new RegExp('(\'\\*'+marker+'\\*\'[\r\n\t ]*;?)', 'm'); - replaceFrom = new RegExp('(ls\\.hook\\.marker\\(([\'"])'+marker+'(\\2)\\)[\\r\\n\\t ]*;?)','m'); - replaceTo = '$1'; - } - if($.type(funcInj)=='function'){ - var funcInjName = 'funcInj'+Math.floor(Math.random()*1000000); - eval('window["'+funcInjName+'"] = funcInj;'); - eval(funcDefinition + funcBody.replace(replaceFrom,replaceTo+funcInjName+'.apply(this, arguments); ')); - }else{ - eval(funcDefinition + funcBody.replace(replaceFrom,replaceTo+funcInj+'; ')); - } - }; - - this.add = function(name,callback,priority) { - var priority = priority || 0; - if(typeof ls.hook.hooks[name] == 'undefined'){ - ls.hook.hooks[name] = []; - } - ls.hook.hooks[name].push({ - 'callback': callback, - 'priority': priority - }); - }; - - this.run = function(name,params,o) { - var params = params || []; - var hooks = ls.hook.hooks; - if(typeof hooks[name] != 'undefined'){ - hooks[name].sort(function(a,b){ - return a.priority > b.priority ? - 1 - : (a.priority < b.priority ? -1 : 0) - ; - }); - $.each(hooks[name], function(i){ - var callback = hooks[name][i].callback; - if($.type(callback) == 'function'){ - callback.apply(o, params); - }else if($.type(callback) == 'array'){ - //console.log(callback); - callback[0][callback[1]].apply(o, params); - }else if($.type(callback) == 'string'){ - eval('(function(){'+callback+'}).apply(o, params);'); - }else{ - ls.debug('cant call hook "'+name+'"['+i+']'); - } - }); - } - }; - - this.marker = function(name){ - // noop - }; - - return this; +/** + * JavaScript-hooks + * + * Examples: + * + * - inject function call/code at top of function body + * ls.hook.inject([ls.lang,'get'], function(){ls.msg.notice('lang debug');})}); + * ls.hook.inject([ls,'ajax'], 'alert(url)'); + * + * - add and call hooks + * ls.hook.add('somefunc_hook1_name', function(param1, param2){ ... }); + * + * function someFunc(..params..){ + * //code + * ls.hook.run('somefunc_hook1_name', [param1,param2], thisArg); + * //code + * } + * + * @author Sergey S Yaglov + * @link http://livestreet.ru/profile/1d10t + */ +ls.hook = (function ($) { + this.hooks = {}; + + this.cloneFunc = function(func,as_text,no_def) { + var f; + if($.type(func)=='string'){ + eval('f = '+func+';'); + }else if($.type(func)=='array'){ + f = func[0][func[1]]; + }else{ + f = func; + } + if($.type(f)=='function'){ + var fbody = f.toString().replace(/^(function)([^\(]*)\(/gi, '$1 ('); + if(typeof as_text!='undefined' && as_text){ + if(typeof no_def!='undefined' && no_def){ + return fbody.replace(/^[^\{]*\{/gi, '').replace(/\}$/gi, ''); + }else{ + return fbody; + } + } + return eval('('+fbody+')'); + } + return function(){}; + }; + + /** + * @param func functionName|object[parentObject,functionName] Name of function that will be modified + * @param funcInj function|string Function or code to be injected + * @param marker string + */ + this.inject = function(func,funcInj,marker) { + var funcBody = ls.hook.cloneFunc(func, 1); + var funcDefinition = ($.type(func)=='string'?func:($.type(func)=='array'?'func[0][func[1]]':'func'))+' = '; + var replaceFrom = /\{/m; + var replaceTo = '{ '; + if($.type(marker) == 'string'){ + //replaceFrom = new RegExp('(\'\\*'+marker+'\\*\'[\r\n\t ]*;?)', 'm'); + replaceFrom = new RegExp('(ls\\.hook\\.marker\\(([\'"])'+marker+'(\\2)\\)[\\r\\n\\t ]*;?)','m'); + replaceTo = '$1'; + } + if($.type(funcInj)=='function'){ + var funcInjName = 'funcInj'+Math.floor(Math.random()*1000000); + eval('window["'+funcInjName+'"] = funcInj;'); + eval(funcDefinition + funcBody.replace(replaceFrom,replaceTo+funcInjName+'.apply(this, arguments); ')); + }else{ + eval(funcDefinition + funcBody.replace(replaceFrom,replaceTo+funcInj+'; ')); + } + }; + + this.add = function(name,callback,priority) { + var priority = priority || 0; + if(typeof ls.hook.hooks[name] == 'undefined'){ + ls.hook.hooks[name] = []; + } + ls.hook.hooks[name].push({ + 'callback': callback, + 'priority': priority + }); + }; + + this.run = function(name,params,o) { + var params = params || []; + var hooks = ls.hook.hooks; + if(typeof hooks[name] != 'undefined'){ + hooks[name].sort(function(a,b){ + return a.priority > b.priority ? + 1 + : (a.priority < b.priority ? -1 : 0) + ; + }); + $.each(hooks[name], function(i){ + var callback = hooks[name][i].callback; + if($.type(callback) == 'function'){ + callback.apply(o, params); + }else if($.type(callback) == 'array'){ + //console.log(callback); + callback[0][callback[1]].apply(o, params); + }else if($.type(callback) == 'string'){ + eval('(function(){'+callback+'}).apply(o, params);'); + }else{ + ls.debug('cant call hook "'+name+'"['+i+']'); + } + }); + } + }; + + this.marker = function(name){ + // noop + }; + + return this; }).call(ls.hook || {},jQuery); \ No newline at end of file diff --git a/engine/lib/internal/template/js/infobox.js b/templates/framework/js/infobox.js similarity index 100% rename from engine/lib/internal/template/js/infobox.js rename to templates/framework/js/infobox.js diff --git a/engine/lib/internal/template/js/main.js b/templates/framework/js/main.js similarity index 100% rename from engine/lib/internal/template/js/main.js rename to templates/framework/js/main.js diff --git a/engine/lib/internal/template/js/photoset.js b/templates/framework/js/photoset.js similarity index 100% rename from engine/lib/internal/template/js/photoset.js rename to templates/framework/js/photoset.js diff --git a/engine/lib/internal/template/js/poll.js b/templates/framework/js/poll.js similarity index 100% rename from engine/lib/internal/template/js/poll.js rename to templates/framework/js/poll.js diff --git a/engine/lib/internal/template/js/settings.js b/templates/framework/js/settings.js similarity index 100% rename from engine/lib/internal/template/js/settings.js rename to templates/framework/js/settings.js diff --git a/engine/lib/internal/template/js/stream.js b/templates/framework/js/stream.js similarity index 100% rename from engine/lib/internal/template/js/stream.js rename to templates/framework/js/stream.js diff --git a/engine/lib/internal/template/js/subscribe.js b/templates/framework/js/subscribe.js similarity index 100% rename from engine/lib/internal/template/js/subscribe.js rename to templates/framework/js/subscribe.js diff --git a/engine/lib/internal/template/js/talk.js b/templates/framework/js/talk.js similarity index 100% rename from engine/lib/internal/template/js/talk.js rename to templates/framework/js/talk.js diff --git a/engine/lib/internal/template/js/toolbar.js b/templates/framework/js/toolbar.js similarity index 100% rename from engine/lib/internal/template/js/toolbar.js rename to templates/framework/js/toolbar.js diff --git a/engine/lib/internal/template/js/topic.js b/templates/framework/js/topic.js similarity index 100% rename from engine/lib/internal/template/js/topic.js rename to templates/framework/js/topic.js diff --git a/engine/lib/internal/template/js/user.js b/templates/framework/js/user.js similarity index 100% rename from engine/lib/internal/template/js/user.js rename to templates/framework/js/user.js diff --git a/engine/lib/internal/template/js/userfeed.js b/templates/framework/js/userfeed.js similarity index 100% rename from engine/lib/internal/template/js/userfeed.js rename to templates/framework/js/userfeed.js diff --git a/engine/lib/internal/template/js/userfield.js b/templates/framework/js/userfield.js similarity index 100% rename from engine/lib/internal/template/js/userfield.js rename to templates/framework/js/userfield.js diff --git a/engine/lib/internal/template/js/usernote.js b/templates/framework/js/usernote.js similarity index 100% rename from engine/lib/internal/template/js/usernote.js rename to templates/framework/js/usernote.js diff --git a/engine/lib/internal/template/js/vote.js b/templates/framework/js/vote.js similarity index 100% rename from engine/lib/internal/template/js/vote.js rename to templates/framework/js/vote.js diff --git a/engine/lib/internal/template/js/wall.js b/templates/framework/js/wall.js similarity index 100% rename from engine/lib/internal/template/js/wall.js rename to templates/framework/js/wall.js