mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-05 07:54:24 +03:00
developer-jquery, совместиость с xtext
This commit is contained in:
parent
17eab63cd1
commit
1930b193b2
|
@ -5,4 +5,8 @@
|
|||
.note { font-size: 12px; color: #aaa; }
|
||||
.checkbox { position: relative; top: 2px; margin: 0 4px 0 1px; }
|
||||
.question-list { margin-bottom: 15px; }
|
||||
.question-list li { margin-bottom: 3px; }
|
||||
.question-list li { margin-bottom: 3px; }
|
||||
|
||||
.markItUp { width: 100%; }
|
||||
.markItUpEditor { width: 100%; -moz-box-sizing: border-box; box-sizing: border-box; }
|
||||
.markItUpHeader { width: 100%; -moz-box-sizing: border-box; box-sizing: border-box; height: 28px; }
|
|
@ -34,6 +34,10 @@ ls.blocks = (function ($) {
|
|||
*/
|
||||
this.load = function(obj, block, params){
|
||||
var id = $(obj).attr('id');
|
||||
/*loadBefore*/ //-loadBefore
|
||||
|
||||
if(!id) return;
|
||||
|
||||
params=$.extend(true,{},this.options.type[id].params || {},params || {});
|
||||
|
||||
var content = $('#'+block+'_content');
|
||||
|
@ -64,6 +68,7 @@ ls.blocks = (function ($) {
|
|||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
content.html(result.sText);
|
||||
ls.hook.run('ls_block_onload_html_after',[content,id,result],this);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -73,7 +78,7 @@ ls.blocks = (function ($) {
|
|||
/**
|
||||
* Подключаем действующие блоки
|
||||
*/
|
||||
jQuery(document).ready(function($){
|
||||
jQuery(function($){
|
||||
$('[id^="block_stream_item"]').click(function(){
|
||||
ls.blocks.load(this, 'block_stream');
|
||||
return false;
|
||||
|
|
|
@ -128,8 +128,8 @@ ls.comments = (function ($) {
|
|||
if (aCmt.length > 0 && result.iMaxIdComment) {
|
||||
$("#comment_last_id").val(result.iMaxIdComment);
|
||||
$('#count-comments').text(parseInt($('#count-comments').text())+aCmt.length);
|
||||
if ($('#block_stream_item_comment').length && ls.blocks) {
|
||||
ls.blocks.load($('#block_stream_item_comment'), 'block_stream');
|
||||
if (ls.blocks) {
|
||||
ls.blocks.load('#block_stream_item_comment', 'block_stream');
|
||||
}
|
||||
}
|
||||
var iCountOld=0;
|
||||
|
@ -169,6 +169,7 @@ ls.comments = (function ($) {
|
|||
} else {
|
||||
$('#comments').append(newComment);
|
||||
}
|
||||
ls.hook.run('ls_comment_inject_after',arguments,newComment);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,14 +24,14 @@ ls.hook = (function ($) {
|
|||
|
||||
this.cloneFunc = function(func,as_text,no_def) {
|
||||
var f;
|
||||
if(typeof func=='string'){
|
||||
if($.type(func)=='string'){
|
||||
eval('f = '+func+';');
|
||||
}else if(typeof func=='object'){
|
||||
}else if($.type(func)=='array'){
|
||||
f = func[0][func[1]];
|
||||
}else{
|
||||
f = func;
|
||||
}
|
||||
if(typeof f=='function'){
|
||||
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){
|
||||
|
@ -52,14 +52,14 @@ ls.hook = (function ($) {
|
|||
*/
|
||||
this.inject = function(func,funcInj,marker) {
|
||||
var funcBody = ls.hook.cloneFunc(func, 1);
|
||||
var funcDefinition = (typeof func=='string'?func:(typeof func=='object'?'func[0][func[1]]':'func'))+' = ';
|
||||
var funcDefinition = ($.type(func)=='string'?func:($.type(func)=='array'?'func[0][func[1]]':'func'))+' = ';
|
||||
var replaceFrom = /\{/m;
|
||||
var replaceTo = '{ ';
|
||||
if(typeof marker == 'string'){
|
||||
if($.type(marker) == 'string'){
|
||||
replaceFrom = new RegExp('(/\\*'+marker+'\\*/)', 'm');
|
||||
replaceTo = '$1';
|
||||
}
|
||||
if(typeof funcInj=='function'){
|
||||
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); '));
|
||||
|
@ -91,12 +91,15 @@ ls.hook = (function ($) {
|
|||
});
|
||||
for(var i in hooks[name]){
|
||||
var callback = hooks[name][i].callback;
|
||||
if(typeof callback == 'function'){
|
||||
if($.type(callback) == 'function'){
|
||||
callback.apply(o, params);
|
||||
}else if(typeof callback == 'object'){
|
||||
}else if($.type(callback) == 'array'){
|
||||
//console.log(callback);
|
||||
callback[0][callback[1]].apply(o, params);
|
||||
}else{
|
||||
}else if($.type(callback) == 'string'){
|
||||
eval('(function(){'+callback+'}).apply(o, params);');
|
||||
}else{
|
||||
ls.debug('cant call hook "'+name+'"['+i+']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,22 @@ Function.prototype.bind = function(context) {
|
|||
return fn.apply(context, arguments);
|
||||
};
|
||||
};
|
||||
String.prototype.tr = function(a,p) {
|
||||
var k;
|
||||
var p = typeof(p)=='string' ? p : '';
|
||||
var s = this;
|
||||
for(k in a){
|
||||
var tk = p?p.split('/'):[];
|
||||
tk[tk.length] = k;
|
||||
var tp = tk.join('/');
|
||||
if(typeof(a[k])=='object'){
|
||||
s = s.tr(a[k],tp);
|
||||
}else{
|
||||
s = s.replace((new RegExp('%%'+tp+'%%', 'g')), a[k]);
|
||||
};
|
||||
};
|
||||
return s;
|
||||
};
|
||||
|
||||
|
||||
var ls = ls || {};
|
||||
|
@ -61,9 +77,7 @@ ls.lang = (function ($) {
|
|||
if (this.msgs[name]) {
|
||||
var value=this.msgs[name];
|
||||
if (replace) {
|
||||
$.each(replace,function(k,v){
|
||||
value=value.replace(new RegExp('%%'+k+'%%','g'),v);
|
||||
});
|
||||
value = value.tr(replace);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -90,7 +104,7 @@ ls.swfupload = (function ($) {
|
|||
post_params: {'SSID':SESSION_ID, 'security_ls_key': LIVESTREET_SECURITY_KEY},
|
||||
|
||||
// File Upload Settings
|
||||
file_types : "*.jpg; *.JPG;*.png;*.gif",
|
||||
file_types : "*.jpg;*.jpe;*.jpeg;*.png;*.gif;*.JPG;*.JPE;*.JPEG;*.PNG;*.GIF",
|
||||
file_types_description : "Images",
|
||||
file_upload_limit : "0",
|
||||
|
||||
|
@ -126,14 +140,19 @@ ls.swfupload = (function ($) {
|
|||
}
|
||||
|
||||
this.loadSwf = function() {
|
||||
$.getScript(DIR_ROOT_ENGINE_LIB+'/external/swfupload/swfupload.swfobject.js',function(){
|
||||
if(!window.SWFUpload){
|
||||
$.getScript(DIR_ROOT_ENGINE_LIB+'/external/swfupload/swfupload.swfobject.js',function(){
|
||||
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
$.getScript(DIR_ROOT_ENGINE_LIB+'/external/swfupload/swfupload.js',function(){
|
||||
$.getScript(DIR_ROOT_ENGINE_LIB+'/external/swfupload/swfupload.js',function(){
|
||||
this.initOptions();
|
||||
$(this).trigger('load');
|
||||
}.bind(this));
|
||||
}else{
|
||||
this.initOptions();
|
||||
$(this).trigger('load');
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
this.init = function(opt) {
|
||||
|
@ -210,23 +229,47 @@ ls.tools = (function ($) {
|
|||
* Предпросмотр
|
||||
*/
|
||||
this.textPreview = function(textId, save, divPreview) {
|
||||
var text =(BLOG_USE_TINYMCE) ? tinyMCE.activeEditor.getContent() : $('#'+textId).val();
|
||||
ls.ajax(aRouter['ajax']+'preview/text/', {text: text, save: save}, function(result){
|
||||
var text =(BLOG_USE_TINYMCE) ? tinyMCE.activeEditor.getContent() : $('#'+textId).val();
|
||||
var ajaxUrl = aRouter['ajax']+'preview/text/';
|
||||
var ajaxOptions = {text: text, save: save};
|
||||
/*textPreviewAjaxBefore*/ //-textPreviewAjaxBefore
|
||||
ls.ajax(ajaxUrl, ajaxOptions, function(result){
|
||||
if (!result) {
|
||||
ls.msg.error('Error','Please try again later');
|
||||
}
|
||||
if (result.bStateError) {
|
||||
ls.msg.error('Error','Please try again later');
|
||||
ls.msg.error(result.sMsgTitle||'Error',result.sMsg||'Please try again later');
|
||||
} else {
|
||||
if (!divPreview) {
|
||||
divPreview = 'text_preview';
|
||||
}
|
||||
/*textPreviewDisplayBefore*/ //-textPreviewDisplayBefore
|
||||
if ($('#'+divPreview).length) {
|
||||
$('#'+divPreview).html(result.sText);
|
||||
/*textPreviewDisplayAfter*/ //-textPreviewDisplayAfter
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает выделенный текст на странице
|
||||
*/
|
||||
this.getSelectedText = function(){
|
||||
var text = '';
|
||||
if(window.getSelection){
|
||||
text = window.getSelection().toString();
|
||||
} else if(window.document.selection){
|
||||
var sel = window.document.selection.createRange();
|
||||
text = sel.text || sel;
|
||||
if(text.toString) {
|
||||
text = text.toString();
|
||||
} else {
|
||||
text = '';
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
return this;
|
||||
}).call(ls.tools || {},jQuery);
|
||||
|
@ -260,7 +303,7 @@ ls = (function ($) {
|
|||
url=aRouter['ajax']+url+'/';
|
||||
}
|
||||
|
||||
return $.ajax({
|
||||
var ajaxOptions = {
|
||||
type: more.type || "POST",
|
||||
url: url,
|
||||
data: params,
|
||||
|
@ -277,7 +320,11 @@ ls = (function ($) {
|
|||
ls.debug("base complete: ");
|
||||
ls.debug(msg);
|
||||
}.bind(this)
|
||||
});
|
||||
};
|
||||
|
||||
ls.hook.run('ls_ajax_before', [ajaxOptions], this);
|
||||
|
||||
return $.ajax(ajaxOptions);
|
||||
|
||||
};
|
||||
|
||||
|
@ -309,6 +356,8 @@ ls = (function ($) {
|
|||
|
||||
}
|
||||
|
||||
ls.hook.run('ls_ajaxsubmit_before', [options], this);
|
||||
|
||||
form.ajaxSubmit(options);
|
||||
}
|
||||
|
||||
|
@ -316,6 +365,7 @@ ls = (function ($) {
|
|||
* Загрузка изображения
|
||||
*/
|
||||
this.ajaxUploadImg = function(form, sToLoad) {
|
||||
/*ajaxUploadImgBefore*/ //-ajaxUploadImgBefore
|
||||
ls.ajaxSubmit('upload/image/',form,function(data){
|
||||
if (data.bStateError) {
|
||||
ls.msg.error(data.sMsgTitle,data.sMsg);
|
||||
|
@ -323,6 +373,7 @@ ls = (function ($) {
|
|||
$.markItUp({ replaceWith: data.sText} );
|
||||
$('#form_upload_img').find('input[type="text"], input[type="file"]').val('');
|
||||
$('#form_upload_img').jqmHide();
|
||||
/*ajaxUploadImgAfter*/ //-ajaxUploadImgAfter
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -330,18 +381,18 @@ ls = (function ($) {
|
|||
/**
|
||||
* Дебаг сообщений
|
||||
*/
|
||||
this.debug = function(msg) {
|
||||
this.debug = function() {
|
||||
if (this.options.debug) {
|
||||
this.log(msg);
|
||||
this.log.apply(this,arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Лог сообщений
|
||||
*/
|
||||
this.log = function(msg) {
|
||||
this.log = function() {
|
||||
if (window.console && window.console.log) {
|
||||
console.log(msg);
|
||||
Function.prototype.bind.call(console.log, console).apply(console, arguments);
|
||||
} else {
|
||||
//alert(msg);
|
||||
}
|
||||
|
@ -420,6 +471,9 @@ ls.autocomplete = (function ($) {
|
|||
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
// Хук начала инициализации javascript-составляющих шаблона
|
||||
ls.hook.run('ls_template_init_start',[],window);
|
||||
|
||||
// Всплывающие окна
|
||||
$('#login_form').jqm({trigger: '#login_form_show'});
|
||||
$('#blog_delete_form').jqm({trigger: '#blog_delete_show'});
|
||||
|
@ -428,6 +482,9 @@ jQuery(document).ready(function($){
|
|||
$('#userfield_form').jqm();
|
||||
|
||||
// Datepicker
|
||||
/**
|
||||
* TODO: навесить языки на datepicker
|
||||
*/
|
||||
$('.date-picker').datepicker({
|
||||
dateFormat: 'dd.mm.yy',
|
||||
dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
|
||||
|
@ -438,7 +495,7 @@ jQuery(document).ready(function($){
|
|||
|
||||
// Поиск по тегам
|
||||
$('#tag_search_form').submit(function(){
|
||||
window.location = aRouter['tag']+$('#tag_search').val()+'/';
|
||||
window.location = aRouter['tag']+encodeURIComponent($('#tag_search').val())+'/';
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -452,4 +509,7 @@ jQuery(document).ready(function($){
|
|||
|
||||
// Скролл
|
||||
$(window)._scrollable();
|
||||
|
||||
// Хук конца инициализации javascript-составляющих шаблона
|
||||
ls.hook.run('ls_template_init_end',[],window);
|
||||
});
|
Loading…
Reference in a new issue