diff --git a/templates/skin/developer-jquery/js/blocks.js b/templates/skin/developer-jquery/js/blocks.js
index 4166ff93..1884b50d 100644
--- a/templates/skin/developer-jquery/js/blocks.js
+++ b/templates/skin/developer-jquery/js/blocks.js
@@ -1,63 +1,87 @@
-var blocks = {
- //==================
- // Опции
- //==================
-
- options: {
- active: 'active',
- url: {
- block_stream_item_comment: aRouter['ajax']+'stream/comment/',
- block_stream_item_topic: aRouter['ajax']+'stream/topic/',
- block_blogs_item_top: aRouter['ajax']+'blogs/top/',
- block_blogs_item_join: aRouter['ajax']+'blogs/join/',
- block_blogs_item_self: aRouter['ajax']+'blogs/self/'
- }
- },
-
+var ls = ls || {};
- //==================
- // Функции
- //==================
-
- load: function(obj, block_id){
- thisObj = this;
- objId = $(obj).attr('id');
- content = $('#'+block_id+'_content');
-
- content.html($('
').css('text-align','center').append($('
', {src: IMG_PATH_LOADER})));
-
- $('[id^="'+block_id+'_item"]').removeClass(this.options.active);
- $(obj).addClass(this.options.active);
-
- $.getJSON(this.options.url[objId], {security_ls_key: LIVESTREET_SECURITY_KEY}, function(result){
- content.empty();
-
- if (result.bStateError) {
- $.notifier.error(null, result.sMsg);
- } else {
- content.html(result.sText);
+/**
+* Динамическая подгрузка блоков
+*/
+ls.blocks = (function ($) {
+ /**
+ * Опции
+ */
+ this.options = {
+ active: 'active',
+ loader: DIR_STATIC_SKIN + '/images/loader.gif',
+ type: {
+ block_stream_item_comment: {
+ url: aRouter['ajax']+'stream/comment/'
+ },
+ block_stream_item_topic: {
+ url: aRouter['ajax']+'stream/topic/'
+ },
+ block_blogs_item_top: {
+ url: aRouter['ajax']+'blogs/top/'
+ },
+ block_blogs_item_join: {
+ url: aRouter['ajax']+'blogs/join/'
+ },
+ block_blogs_item_self: {
+ url: aRouter['ajax']+'blogs/self/'
}
- });
- }
-}
+ }
+ };
+ /**
+ * Метод загрузки содержимого блока
+ */
+ this.load = function(obj, block, params){
+ var id = $(obj).attr('id');
+ params=$.extend(true,{},this.options.type[id].params || {},params || {});
+ params.security_ls_key=LIVESTREET_SECURITY_KEY;
+ var content = $('#'+block+'_content');
+ this.showProgress(content);
-$(document).ready(function(){
+ $('[id^="'+block+'_item"]').removeClass(this.options.active);
+ $(obj).addClass(this.options.active);
+
+ $.getJSON(this.options.type[id].url, params, function(result){
+ this.onLoad(content,id,result);
+ }.bind(this));
+ };
+
+ /**
+ * Отображение процесса загрузки
+ */
+ this.showProgress = function(content) {
+ content.html($('').css('text-align','center').append($('
', {src: this.options.loader})));
+ };
+
+ /**
+ * Обработка результатов загрузки
+ */
+ this.onLoad = function(content,id,result) {
+ $(this).trigger('load',[content,id,result]);
+ content.empty();
+ if (result.bStateError) {
+ $.notifier.error(null, result.sMsg);
+ } else {
+ content.html(result.sText);
+ }
+ };
+
+ return this;
+}).call(ls.blocks || {},jQuery);
+
+/**
+* Подключаем действующие блоки
+*/
+jQuery(document).ready(function($){
$('[id^="block_stream_item"]').click(function(){
- blocks.load(this, 'block_stream');
+ ls.blocks.load(this, 'block_stream');
return false;
});
-
+
$('[id^="block_blogs_item"]').click(function(){
- blocks.load(this, 'block_blogs');
+ ls.blocks.load(this, 'block_blogs');
return false;
});
-});
-
-
-
-
-
-
-
+});
\ No newline at end of file
diff --git a/templates/skin/developer-jquery/js/main.js b/templates/skin/developer-jquery/js/main.js
index 08097275..a7f495a4 100644
--- a/templates/skin/developer-jquery/js/main.js
+++ b/templates/skin/developer-jquery/js/main.js
@@ -1,3 +1,10 @@
+Function.prototype.bind = function(context) {
+ var fn = this;
+ return function() {
+ return fn.apply(context, arguments);
+ };
+};
+
$(document).ready(function(){
// Всплывающие окна
$('#login_form').jqm({trigger: '#login_form_show'});
diff --git a/templates/skin/developer-jquery/settings/config/config.php b/templates/skin/developer-jquery/settings/config/config.php
index 612ef96a..dd190805 100644
--- a/templates/skin/developer-jquery/settings/config/config.php
+++ b/templates/skin/developer-jquery/settings/config/config.php
@@ -10,6 +10,7 @@ $config['head']['default']['js'] = array(
"___path.static.skin___/js/libs/jquery.rich-array.min.js",
"___path.static.skin___/js/libs/markitup/jquery.markitup.js",
"___path.static.skin___/js/libs/markitup/sets/default/set.js",
+ "___path.static.skin___/js/main.js",
"___path.static.skin___/js/autocomplete.js",
"___path.static.skin___/js/favourite.js",
"___path.static.skin___/js/blocks.js",
@@ -19,7 +20,6 @@ $config['head']['default']['js'] = array(
"___path.static.skin___/js/comments.js",
"___path.static.skin___/js/blog.js",
"___path.static.skin___/js/friend.js",
- "___path.static.skin___/js/main.js",
);
$config['head']['default']['css'] = array(
"___path.static.skin___/css/reset.css",