2011-04-09 22:38:11 +03:00
|
|
|
var ls = ls || {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Динамическая подгрузка блоков
|
|
|
|
*/
|
|
|
|
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/'
|
|
|
|
}
|
2011-04-01 10:49:36 +03:00
|
|
|
}
|
2011-04-09 22:38:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Метод загрузки содержимого блока
|
|
|
|
*/
|
|
|
|
this.load = function(obj, block, params){
|
|
|
|
var id = $(obj).attr('id');
|
2012-01-17 21:15:52 +02:00
|
|
|
'*loadBefore*'; '*/loadBefore*';
|
2012-01-15 02:47:20 +02:00
|
|
|
|
|
|
|
if(!id) return;
|
|
|
|
|
2011-04-09 22:38:11 +03:00
|
|
|
params=$.extend(true,{},this.options.type[id].params || {},params || {});
|
2011-05-03 00:28:36 +03:00
|
|
|
|
2011-04-09 22:38:11 +03:00
|
|
|
var content = $('#'+block+'_content');
|
|
|
|
this.showProgress(content);
|
|
|
|
|
|
|
|
$('[id^="'+block+'_item"]').removeClass(this.options.active);
|
2011-04-01 10:49:36 +03:00
|
|
|
$(obj).addClass(this.options.active);
|
|
|
|
|
2011-05-03 00:28:36 +03:00
|
|
|
ls.ajax(this.options.type[id].url, params, function(result){
|
2011-04-09 22:38:11 +03:00
|
|
|
this.onLoad(content,id,result);
|
|
|
|
}.bind(this));
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Отображение процесса загрузки
|
|
|
|
*/
|
|
|
|
this.showProgress = function(content) {
|
|
|
|
content.html($('<div />').css('text-align','center').append($('<img>', {src: this.options.loader})));
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Обработка результатов загрузки
|
|
|
|
*/
|
|
|
|
this.onLoad = function(content,id,result) {
|
2011-11-05 08:40:09 +02:00
|
|
|
$(this).trigger('loadSuccessful',[content,id,result]);
|
2011-04-09 22:38:11 +03:00
|
|
|
content.empty();
|
|
|
|
if (result.bStateError) {
|
2011-05-03 00:28:36 +03:00
|
|
|
ls.msg.error(null, result.sMsg);
|
2011-04-09 22:38:11 +03:00
|
|
|
} else {
|
|
|
|
content.html(result.sText);
|
2012-01-15 02:47:20 +02:00
|
|
|
ls.hook.run('ls_block_onload_html_after',[content,id,result],this);
|
2011-04-09 22:38:11 +03:00
|
|
|
}
|
|
|
|
};
|
2011-04-01 10:49:36 +03:00
|
|
|
|
2011-04-09 22:38:11 +03:00
|
|
|
return this;
|
|
|
|
}).call(ls.blocks || {},jQuery);
|
2011-04-01 10:49:36 +03:00
|
|
|
|
2011-04-09 22:38:11 +03:00
|
|
|
/**
|
|
|
|
* Подключаем действующие блоки
|
|
|
|
*/
|
2012-01-15 02:47:20 +02:00
|
|
|
jQuery(function($){
|
2011-04-01 10:49:36 +03:00
|
|
|
$('[id^="block_stream_item"]').click(function(){
|
2011-04-09 22:38:11 +03:00
|
|
|
ls.blocks.load(this, 'block_stream');
|
2011-04-01 10:49:36 +03:00
|
|
|
return false;
|
|
|
|
});
|
2011-04-09 22:38:11 +03:00
|
|
|
|
2011-04-01 10:49:36 +03:00
|
|
|
$('[id^="block_blogs_item"]').click(function(){
|
2011-04-09 22:38:11 +03:00
|
|
|
ls.blocks.load(this, 'block_blogs');
|
2011-04-01 10:49:36 +03:00
|
|
|
return false;
|
|
|
|
});
|
2011-04-09 22:38:11 +03:00
|
|
|
});
|