mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Доработка компонентов
This commit is contained in:
parent
e0bccec00a
commit
cf71f95f6e
|
@ -242,7 +242,7 @@ class ActionContent extends Action
|
|||
/**
|
||||
* Проверяем разрешено ли постить топик по времени
|
||||
*/
|
||||
if (isPost('submit_topic_publish') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) {
|
||||
if ( ! isPost('is_draft') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('topic.add.notices.time_limit'), $this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class ActionContent extends Action
|
|||
* Публикуем или сохраняем в черновиках
|
||||
*/
|
||||
$bSendNotify = false;
|
||||
if (isset($_REQUEST['submit_topic_publish'])) {
|
||||
if ( ! isset($_REQUEST['is_draft'])) {
|
||||
$oTopic->setPublish(1);
|
||||
if ($oTopic->getPublishDraft() == 0) {
|
||||
$oTopic->setPublishDraft(1);
|
||||
|
@ -406,7 +406,7 @@ class ActionContent extends Action
|
|||
/**
|
||||
* Публикуем или сохраняем
|
||||
*/
|
||||
if (isset($_REQUEST['submit_topic_publish'])) {
|
||||
if ( ! isset($_REQUEST['is_draft'])) {
|
||||
$oTopic->setPublish(1);
|
||||
$oTopic->setPublishDraft(1);
|
||||
} else {
|
||||
|
|
|
@ -530,7 +530,9 @@ $config['head']['default']['js'] = array(
|
|||
"___path.skin.web___/components/ls-core/registry.js",
|
||||
"___path.skin.web___/components/ls-core/utils.js",
|
||||
"___path.skin.web___/components/ls-core/timer.js",
|
||||
"___path.skin.web___/components/subscribe/js/subscribe.js",
|
||||
"___path.skin.web___/components/tooltip/js/tooltip.js",
|
||||
"___path.skin.web___/components/content/js/content.js",
|
||||
"___path.skin.web___/components/notification/js/notification.js",
|
||||
"___path.skin.web___/components/autocomplete/js/autocomplete.js",
|
||||
"___path.skin.web___/components/tabs/js/tab.js",
|
||||
|
@ -582,9 +584,6 @@ $config['head']['default']['js'] = array(
|
|||
"___path.skin.web___/components/actionbar/js/actionbar-item-select.js",
|
||||
"___path.skin.web___/components/toolbar-scrollup/js/toolbar.scrollup.js",
|
||||
"___path.skin.web___/components/toolbar-scrollnav/js/toolbar.scrollnav.js",
|
||||
"___path.application.web___/frontend/common/js/subscribe.js",
|
||||
"___path.application.web___/frontend/common/js/content.js",
|
||||
"___path.application.web___/frontend/common/js/init.js",
|
||||
"//yandex.st/share/share.js" => array('merge' => false),
|
||||
);
|
||||
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* Контент
|
||||
*
|
||||
* @module ls/content
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
|
||||
ls.content = (function ($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
// Роутеры
|
||||
routers: {
|
||||
add: aRouter['content'] + 'ajax/add/',
|
||||
edit: aRouter['content'] + 'ajax/edit/'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
* @param {Object} options Опции
|
||||
*/
|
||||
this.init = function(options) {
|
||||
this.options = $.extend({}, defaults, options);
|
||||
|
||||
$('#submit-add-topic-publish').on('click',function(){
|
||||
ls.content.save('add','form-topic-add',{ 'submit_topic_publish': 1 });
|
||||
});
|
||||
|
||||
$('#submit-add-topic-save').on('click',function(){
|
||||
ls.content.save('add','form-topic-add',{ 'submit_topic_save': 1 });
|
||||
});
|
||||
|
||||
$('#submit-edit-topic-publish').on('click',function(){
|
||||
ls.content.save('edit','form-topic-add',{ 'submit_topic_publish': 1 });
|
||||
});
|
||||
|
||||
$('#submit-edit-topic-save').on('click',function(){
|
||||
ls.content.save('edit','form-topic-add',{ 'submit_topic_save': 1 });
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Создание контента
|
||||
*
|
||||
* @param {String} sFormId ID формы
|
||||
*/
|
||||
this.save = function(submitType,sFormId,params) {
|
||||
var oForm = $('#' + sFormId);
|
||||
ls.ajax.submit(this.options.routers[submitType], oForm, function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
if (result.sUrlRedirect) {
|
||||
window.location.href=result.sUrlRedirect;
|
||||
}
|
||||
}
|
||||
},{ params: params });
|
||||
return false;
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.content || {}, jQuery);
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* Основной файл инициализации
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
$('html').removeClass('no-js');
|
||||
|
||||
/**
|
||||
* Определение браузера
|
||||
*/
|
||||
if ($.browser.opera) {
|
||||
$('body').addClass('opera opera' + parseInt($.browser.version, 10));
|
||||
}
|
||||
|
||||
if ($.browser.mozilla) {
|
||||
$('body').addClass('mozilla mozilla' + parseInt($.browser.version, 10));
|
||||
}
|
||||
|
||||
if ($.browser.webkit) {
|
||||
$('body').addClass('webkit webkit' + parseInt($.browser.version, 10));
|
||||
}
|
||||
|
||||
if ($.browser.msie) {
|
||||
$('body').addClass('ie');
|
||||
if (parseInt($.browser.version, 0) > 8) {
|
||||
$('body').addClass('ie' + parseInt($.browser.version, 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Фикс бага с z-index у встроенных видео
|
||||
*/
|
||||
$("iframe").each(function(){
|
||||
var ifr_source = $(this).attr('src');
|
||||
|
||||
if(ifr_source) {
|
||||
var wmode = "wmode=opaque";
|
||||
|
||||
if (ifr_source.indexOf('?') != -1)
|
||||
$(this).attr('src',ifr_source+'&'+wmode);
|
||||
else
|
||||
$(this).attr('src',ifr_source+'?'+wmode);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Поиск по тегам
|
||||
*/
|
||||
$('.js-tag-search-form').submit(function(){
|
||||
var val=$(this).find('.js-tag-search').val();
|
||||
if (val) {
|
||||
window.location = aRouter['tag']+encodeURIComponent(val)+'/';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
|
@ -1,459 +0,0 @@
|
|||
/**
|
||||
* Работа с медиа файлами
|
||||
*
|
||||
* @module ls/media
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
|
||||
ls.media = (function ($) {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var _defaults = {
|
||||
// Селекторы
|
||||
selectors: {
|
||||
link: {
|
||||
form: '.js-media-link-form',
|
||||
url: 'input[name=url]',
|
||||
title: 'input[name=title]',
|
||||
align: 'select[name=align]',
|
||||
insertButton: '.js-media-link-insert-button',
|
||||
uploadButton: '.js-media-link-upload-button'
|
||||
},
|
||||
info: {
|
||||
self: '.js-media-info',
|
||||
remove: '.js-media-item-info-remove',
|
||||
create_preview: '.js-media-item-info-create-preview',
|
||||
remove_preview: '.js-media-item-info-remove-preview',
|
||||
sizes: 'select[name=size]',
|
||||
empty: '.js-media-info-empty'
|
||||
},
|
||||
buttons_insert: '.js-media-insert-button',
|
||||
button_insert: '.js-media-insert',
|
||||
button_insert_photoset: '.js-media-insert-photoset',
|
||||
modal: '#modal-image-upload'
|
||||
},
|
||||
// Роуты
|
||||
routers: {
|
||||
upload: aRouter['ajax'] + "media/upload/",
|
||||
remove_file: aRouter['ajax'] + "media/remove-file/",
|
||||
create_preview_file: aRouter['ajax'] + "media/create-preview-file/",
|
||||
remove_preview_file: aRouter['ajax'] + "media/remove-preview-file/",
|
||||
load_preview_items: aRouter['ajax'] + "media/load-preview-items/",
|
||||
load_gallery: aRouter['ajax'] + "media/load-gallery/",
|
||||
generate_target_tmp: aRouter['ajax'] + "media/generate-target-tmp/",
|
||||
submit_insert: aRouter['ajax'] + "media/submit-insert/",
|
||||
submit_photoset: aRouter['ajax'] + "media/submit-create-photoset/",
|
||||
save_data_file: aRouter['ajax'] + "media/save-data-file/",
|
||||
upload_link: aRouter['ajax'] + "media/upload-link/"
|
||||
}
|
||||
};
|
||||
|
||||
var _countCheckLink = 0;
|
||||
|
||||
var _blockCheckLink = -1;
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
this.init = function(options) {
|
||||
var _this = this;
|
||||
|
||||
this.options = $.extend(true, {}, _defaults, options);
|
||||
|
||||
this.elements = {
|
||||
uploader: $('#media-uploader'),
|
||||
buttonsInsert: $(this.options.selectors.buttons_insert),
|
||||
buttonInsert: $(this.options.selectors.button_insert),
|
||||
buttonInsertPhotoset: $(this.options.selectors.button_insert_photoset),
|
||||
modal: $(this.options.selectors.modal),
|
||||
link: {
|
||||
url: $(this.options.selectors.link.form).find(this.options.selectors.link.url),
|
||||
align: $(this.options.selectors.link.form).find(this.options.selectors.link.align),
|
||||
title: $(this.options.selectors.link.form).find(this.options.selectors.link.title),
|
||||
insertButton: $(this.options.selectors.link.insertButton),
|
||||
uploadButton: $(this.options.selectors.link.uploadButton)
|
||||
},
|
||||
info: {
|
||||
self: $(this.options.selectors.info.self),
|
||||
remove: $(this.options.selectors.info.remove),
|
||||
create_preview: $(this.options.selectors.info.create_preview),
|
||||
remove_preview: $(this.options.selectors.info.remove_preview),
|
||||
sizes: $(this.options.selectors.info.sizes),
|
||||
empty: $(this.options.selectors.info.empty)
|
||||
}
|
||||
};
|
||||
|
||||
this.elements.uploader.lsUploader({
|
||||
autoload: false,
|
||||
params: {
|
||||
security_ls_key: LIVESTREET_SECURITY_KEY
|
||||
},
|
||||
file_options: {
|
||||
beforeactivate: function ( event, context ) {
|
||||
_this.updateInsertSettings( context.element );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.activateInfoBlock( 'insert' );
|
||||
|
||||
// Ивенты вставки в редактор
|
||||
this.elements.buttonInsert.on('click', function () {
|
||||
var params = {
|
||||
align: $('#media-settings-mode-insert').find('select[name=align]').val(),
|
||||
size: $('#media-settings-mode-insert').find('select[name=size]').val()
|
||||
}
|
||||
|
||||
this.insert(this.options.routers.submit_insert, params);
|
||||
}.bind(this));
|
||||
|
||||
this.elements.buttonInsertPhotoset.on('click', function () {
|
||||
var params = {
|
||||
use_thumbs: $('#media-settings-mode-create-photoset').find('input[name=use_thumbs]').is(':checked'),
|
||||
show_caption: $('#media-settings-mode-create-photoset').find('input[name=show_caption]').is(':checked')
|
||||
}
|
||||
this.insert(this.options.routers.submit_photoset, params);
|
||||
}.bind(this));
|
||||
|
||||
// Перемещение галереи из одного таба в другой
|
||||
$('.js-tab-show-gallery').on('tabactivate', function(event, tab) {
|
||||
this.elements.uploader.appendTo( $( '#' + tab.options.target ).find( '.modal-content' ) );
|
||||
this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'clearSelected' );
|
||||
this.activateInfoBlock( $( event.target ).data( 'mediaMode' ) );
|
||||
}.bind(this));
|
||||
|
||||
// После добавления комментария необходимо получить новый временный идентификатор и очистить галлерею
|
||||
ls.hook.add('ls_comments_add_after',function(){
|
||||
this.elements.uploader.lsUploader( 'generateTargetTmp' ).lsUploader( 'markAsEmpty' );
|
||||
this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'empty' );
|
||||
}.bind(this));
|
||||
|
||||
// Проверка корректности урла при вставке ссылки на медиа-объект
|
||||
this.elements.link.url.on('input', function() {
|
||||
this.checkLinkUrl(this.elements.link.url.val());
|
||||
}.bind(this));
|
||||
|
||||
// Вставка медиа ссылки в текст
|
||||
this.elements.link.insertButton.on('click', function() {
|
||||
var sTitle = ls.utils.escapeHtml( this.elements.link.title.val() ),
|
||||
sTextInsert;
|
||||
|
||||
if ($('.js-media-link-settings-image').is(':visible')) {
|
||||
var sAlign = this.elements.link.align.val();
|
||||
sAlign = sAlign == 'center' ? 'class="image-center"' : 'align="' + sAlign + '"';
|
||||
sTextInsert = '<img src="' + this.elements.link.url.val() + '" title="' + sTitle + '" ' + sAlign + ' />';
|
||||
} else {
|
||||
sTextInsert = '<a href="'+this.elements.link.url.val() + '">' + sTitle + '</a>';
|
||||
}
|
||||
|
||||
this.insertTextToEditor(sTextInsert);
|
||||
this.elements.modal.lsModal('hide');
|
||||
}.bind(this));
|
||||
|
||||
// Загрузка медиа файлы по ссылке
|
||||
this.elements.link.uploadButton.on('click', function() {
|
||||
ls.ajax.submit(this.options.routers.upload_link, $('.js-media-link-form'), function (data){
|
||||
if (data.bStateError) {
|
||||
ls.msg.error(data.sMsgTitle,data.sMsg);
|
||||
} else {
|
||||
this.insertTextToEditor(data.sText);
|
||||
this.elements.modal.lsModal('hide');
|
||||
this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'load' );
|
||||
}
|
||||
}.bind(this), {
|
||||
// TODO: Fix validation
|
||||
validate: false,
|
||||
submitButton: this.elements.link.uploadButton,
|
||||
params: { target_type: this.options.target_type, target_id: this.options.target_id, target_tmp: this.options.target_tmp }
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
// Создание превью из файла
|
||||
this.elements.info.create_preview.on('click', function(e) {
|
||||
ls.media.createPreviewActiveFile();
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
// Удаление превью
|
||||
this.elements.info.remove_preview.on('click', function(e) {
|
||||
ls.media.removePreviewActiveFile();
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
// После показа модального подгружаем контент
|
||||
this.elements.modal.on('modalaftershow', function() {
|
||||
this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'load' );
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Загрузка по ссылки
|
||||
//
|
||||
|
||||
/**
|
||||
* Проверка корректности ссылки на медиа
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
this.checkLinkUrl = function(url) {
|
||||
// TODO: здесь нужно показывать спинер загрузки в инпуте
|
||||
|
||||
_countCheckLink++;
|
||||
this.checkLinkUrlImage(url, function(src, result) {
|
||||
if ( ! result) {
|
||||
// если не изображение, то проверяем на другой тип, например, видео
|
||||
|
||||
// разрешаем скрытие настроек только след итерациям после успешной проверки
|
||||
if (_blockCheckLink < _countCheckLink) {
|
||||
this.hideSettingsLinkImage();
|
||||
}
|
||||
} else {
|
||||
_blockCheckLink = _countCheckLink;
|
||||
this.showSettingsLinkImage(src);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверка на корректность ссылки на изображение
|
||||
*
|
||||
* @param url
|
||||
* @param callback
|
||||
*/
|
||||
this.checkLinkUrlImage = function(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
$('<img>', {
|
||||
src: url,
|
||||
error: function() {
|
||||
callback.call(_this, this.src, false);
|
||||
},
|
||||
load: function() {
|
||||
callback.call(_this, this.src, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставка по ссылке - Показывает настройки изображения
|
||||
*
|
||||
* @param src Ссылка на изображения
|
||||
*/
|
||||
this.showSettingsLinkImage = function(src) {
|
||||
this.elements.link.uploadButton.prop('disabled', false);
|
||||
$('.js-media-link-settings-image-preview').attr('src', src);
|
||||
$('.js-media-link-settings-image').show();
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставка по ссылке - Скрывает настройки изображения
|
||||
*/
|
||||
this.hideSettingsLinkImage = function() {
|
||||
this.elements.link.uploadButton.prop('disabled', true);
|
||||
$('.js-media-link-settings-image').hide();
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Превью
|
||||
//
|
||||
|
||||
/**
|
||||
* Создание превью из активного файла
|
||||
*/
|
||||
this.createPreviewActiveFile = function() {
|
||||
var file = this._getActiveFile();
|
||||
|
||||
return file.length ? this.createPreviewFile( file.lsUploaderFile( 'getProperty', 'id' ) ) : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Удаление превью у активного файла
|
||||
*/
|
||||
this.removePreviewActiveFile = function() {
|
||||
var file = this._getActiveFile();
|
||||
|
||||
return file.length ? this.removePreviewFile( file.lsUploaderFile( 'getProperty', 'id' ) ) : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Создание превью
|
||||
*
|
||||
* @param {Number} id
|
||||
*/
|
||||
this.createPreviewFile = function( id ) {
|
||||
ls.ajax.load(
|
||||
this.options.routers.create_preview_file,
|
||||
{
|
||||
id: id,
|
||||
target_type: this.options.target_type,
|
||||
target_id: this.options.target_id,
|
||||
target_tmp: this.options.target_tmp
|
||||
},
|
||||
function( response ) {
|
||||
if ( response.bStateError ) {
|
||||
ls.msg.error( null, response.sMsg );
|
||||
} else {
|
||||
if ( response.bUnsetOther ) {
|
||||
this.elements.uploader
|
||||
.lsUploader( 'getElement', 'list' )
|
||||
.lsUploaderFileList( 'getFiles' )
|
||||
.lsUploaderFile( 'setProperty', 'media_relation_is_preview', false );
|
||||
}
|
||||
|
||||
var file = this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'getFileById', id );
|
||||
|
||||
file.lsUploaderFileList( 'setProperty', 'media_relation_is_preview', true );
|
||||
|
||||
// Обновляем отображение информации
|
||||
this.showDetail( file );
|
||||
this.loadPreviewItems();
|
||||
}
|
||||
}.bind( this )
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Удаление превью
|
||||
*
|
||||
* @param {Number} id
|
||||
*/
|
||||
this.removePreviewFile = function( id ) {
|
||||
ls.ajax.load(
|
||||
this.options.routers.remove_preview_file,
|
||||
{
|
||||
id: id,
|
||||
target_type: this.options.target_type,
|
||||
target_id: this.options.target_id,
|
||||
target_tmp: this.options.target_tmp
|
||||
},
|
||||
function( response ) {
|
||||
if ( response.bStateError ) {
|
||||
ls.msg.error( null, response.sMsg );
|
||||
} else {
|
||||
var file = this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'getFileById', id );
|
||||
|
||||
file.lsUploaderFileList( 'setProperty', 'media_relation_is_preview', false );
|
||||
|
||||
// Обновляем отображение информации
|
||||
this.showDetail( file );
|
||||
this.loadPreviewItems();
|
||||
}
|
||||
}.bind( this ));
|
||||
};
|
||||
|
||||
/**
|
||||
* Подгрузка превьюшек
|
||||
*/
|
||||
this.loadPreviewItems = function() {
|
||||
ls.ajax.load(
|
||||
this.options.routers.load_preview_items,
|
||||
{
|
||||
target_type: this.options.target_type,
|
||||
target_id: this.options.target_id,
|
||||
target_tmp: this.options.target_tmp
|
||||
},
|
||||
function( response ) {
|
||||
this.renderPreviewItems( response.sTemplatePreview );
|
||||
}.bind( this )
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Отображение превьюшек
|
||||
*/
|
||||
this.renderPreviewItems = function( html ) {
|
||||
$( '#tab-media-preview' ).find( '.modal-content' ).html( html );
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Вставка
|
||||
//
|
||||
|
||||
/**
|
||||
* Вставка файлов в редактор
|
||||
*/
|
||||
this.insert = function( url, params ) {
|
||||
var files = this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'getSelectedFiles' );
|
||||
|
||||
if ( ! files.length ) return false;
|
||||
|
||||
/* Формируем список ID элементов */
|
||||
var ids = $.map(files, function (value, index) {
|
||||
return $(value).data('mediaId');
|
||||
});
|
||||
|
||||
ls.ajax.load( url, $.extend( true, {}, { ids: ids }, params ), function( response ) {
|
||||
if ( response.bStateError ) {
|
||||
ls.msg.error( response.sMsgTitle, response.sMsg );
|
||||
} else {
|
||||
this.insertTextToEditor( response.sTextResult );
|
||||
this.elements.modal.lsModal( 'hide' );
|
||||
}
|
||||
}.bind( this ));
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставляет текст в редактор
|
||||
* @param {String} text Текст
|
||||
*/
|
||||
this.insertTextToEditor = function( text ) {
|
||||
$.markItUp({
|
||||
replaceWith: text
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Блоки
|
||||
//
|
||||
|
||||
/**
|
||||
* Устанавливает текущий режим вставки медиа файлов
|
||||
*/
|
||||
this.activateInfoBlock = function( name ) {
|
||||
var blocks = $( '.js-media-info-block' ).hide();
|
||||
|
||||
blocks.filter( '[data-type=' + name + ']' ).show();
|
||||
};
|
||||
|
||||
/**
|
||||
* Показывает блок с информацией об активном файле
|
||||
*
|
||||
* @param {Object} item Выделенный файл
|
||||
*/
|
||||
this.updateInsertSettings = function( file ) {
|
||||
if ( file.lsUploaderFile( 'getProperty', 'type' ) === '1' ) {
|
||||
// Выставляем настройки по вставке медиа
|
||||
this.elements.info.sizes.find( 'option:not([value=original])' ).remove();
|
||||
this.elements.info.sizes.append($.map( file.data('mediaImageSizes'), function ( v, k ) {
|
||||
// Расчитываем пропорциональную высоту изображения
|
||||
var height = v.h || parseInt( v.w * file.lsUploaderFile( 'getProperty', 'height' ) / file.lsUploaderFile( 'getProperty', 'width' ) );
|
||||
|
||||
return '<option value="' + v.w + 'x' + (v.h ? v.h : '') + (v.crop ? 'crop' : '') + '">' + v.w + ' × ' + height + '</option>';
|
||||
}).join(''));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает активный файл
|
||||
*/
|
||||
this._getActiveFile = function() {
|
||||
return this.elements.uploader.lsUploader( 'getElement', 'list' ).lsUploaderFileList( 'getActiveFile' );
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.media || {},jQuery);
|
|
@ -10,6 +10,8 @@ jQuery(document).ready(function($){
|
|||
// Хук начала инициализации javascript-составляющих шаблона
|
||||
ls.hook.run('ls_template_init_start',[],window);
|
||||
|
||||
$('html').removeClass('no-js');
|
||||
|
||||
/**
|
||||
* Иниц-ия модулей ядра
|
||||
*/
|
||||
|
@ -307,8 +309,9 @@ jQuery(document).ready(function($){
|
|||
* Topic
|
||||
*/
|
||||
$( '.js-topic' ).lsTopic();
|
||||
|
||||
// Добавление/редактирование
|
||||
ls.topic.init();
|
||||
ls.content.init();
|
||||
|
||||
// Пагинация
|
||||
$('.js-pagination-topics').lsPagination({
|
||||
|
@ -318,6 +321,7 @@ jQuery(document).ready(function($){
|
|||
}
|
||||
});
|
||||
|
||||
// Комментарии
|
||||
$('.js-comments-topic').lsComments({
|
||||
urls: {
|
||||
add: aRouter['blog'] + 'ajaxaddcomment/',
|
||||
|
@ -337,6 +341,17 @@ jQuery(document).ready(function($){
|
|||
active: false
|
||||
});
|
||||
|
||||
// Поиск по тегам
|
||||
$('.js-tag-search-form').submit(function() {
|
||||
var val = $(this).find('.js-tag-search').val();
|
||||
|
||||
if ( val ) {
|
||||
window.location = aRouter['tag'] + encodeURIComponent( val ) + '/';
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Form validate
|
||||
|
@ -399,6 +414,19 @@ jQuery(document).ready(function($){
|
|||
$( this ).fotorama();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Фикс бага с z-index у встроенных видео
|
||||
*/
|
||||
$( 'iframe' ).each(function() {
|
||||
var iframe = $( this ),
|
||||
src = iframe.attr( 'src' );
|
||||
|
||||
if ( src ) {
|
||||
iframe.attr( 'src', src + ( ~ src.indexOf( '?' ) ? '?' : '&' ) + 'wmode=opaque' );
|
||||
}
|
||||
});
|
||||
|
||||
// Хук конца инициализации javascript-составляющих шаблона
|
||||
ls.hook.run('ls_template_init_end',[],window);
|
||||
});
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* Content
|
||||
*
|
||||
* @module ls/content
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.lsContent", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
// Ссылки
|
||||
urls: {
|
||||
add: null,
|
||||
edit: null
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
this.action = this.element.data( 'content-action' );
|
||||
|
||||
this.element.on( 'submit' + this.eventNamespace, this.onSubmit.bind( this ) );
|
||||
},
|
||||
|
||||
/**
|
||||
* Коллбэк вызываемый при отправке формы
|
||||
*/
|
||||
onSubmit: function( event ) {
|
||||
this.submit();
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Отправка формы
|
||||
*/
|
||||
submit: function( params ) {
|
||||
ls.ajax.submit( this.option( 'urls.' + this.action ), this.element, function( response ) {
|
||||
if ( response.bStateError ) {
|
||||
ls.msg.error( null, response.sMsg );
|
||||
} else {
|
||||
if ( response.sUrlRedirect ) {
|
||||
window.location.href = response.sUrlRedirect;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
params: params || {}
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
|
@ -36,39 +36,39 @@
|
|||
{block 'layout_head_styles'}
|
||||
{* Подключение стилей указанных в конфиге *}
|
||||
{$aHtmlHeadFiles.css}
|
||||
|
||||
<link href="{cfg name='path.skin.assets.web'}/images/favicons/favicon.ico?v1" rel="shortcut icon" />
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="{router page='search'}opensearch/" title="{cfg name='view.name'}" />
|
||||
{/block}
|
||||
|
||||
<link href="{cfg name='path.skin.assets.web'}/images/favicons/favicon.ico?v1" rel="shortcut icon" />
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="{router page='search'}opensearch/" title="{cfg name='view.name'}" />
|
||||
|
||||
<script>
|
||||
var PATH_ROOT = '{router page='/'}',
|
||||
PATH_SKIN = '{cfg name="path.skin.web"}',
|
||||
PATH_FRAMEWORK_FRONTEND = '{cfg name="path.framework.frontend.web"}',
|
||||
PATH_FRAMEWORK_LIBS_VENDOR = '{cfg name="path.framework.libs_vendor.web"}',
|
||||
/**
|
||||
* Для совместимости с прошлыми версиями. БУДУТ УДАЛЕНЫ
|
||||
*/
|
||||
DIR_WEB_ROOT = '{cfg name="path.root.web"}',
|
||||
DIR_STATIC_SKIN = '{cfg name="path.skin.web"}',
|
||||
DIR_STATIC_FRAMEWORK = '{cfg name="path.framework.frontend.web"}',
|
||||
DIR_ENGINE_LIBS = '{cfg name="path.framework.web"}/libs',
|
||||
|
||||
LIVESTREET_SECURITY_KEY = '{$LIVESTREET_SECURITY_KEY}',
|
||||
LANGUAGE = '{Config::Get('lang.current')}',
|
||||
WYSIWYG = {if Config::Get('view.wysiwyg')}true{else}false{/if};
|
||||
|
||||
var aRouter = [];
|
||||
{foreach $aRouter as $sPage => $sPath}
|
||||
aRouter['{$sPage}'] = '{$sPath}';
|
||||
{/foreach}
|
||||
</script>
|
||||
|
||||
{**
|
||||
* JavaScript файлы
|
||||
* JS файлы подключаются в конфиге шаблона (ваш_шаблон/settings/config.php)
|
||||
*}
|
||||
{block 'layout_head_scripts'}
|
||||
<script>
|
||||
var PATH_ROOT = '{router page='/'}',
|
||||
PATH_SKIN = '{cfg name="path.skin.web"}',
|
||||
PATH_FRAMEWORK_FRONTEND = '{cfg name="path.framework.frontend.web"}',
|
||||
PATH_FRAMEWORK_LIBS_VENDOR = '{cfg name="path.framework.libs_vendor.web"}',
|
||||
/**
|
||||
* Для совместимости с прошлыми версиями. БУДУТ УДАЛЕНЫ
|
||||
*/
|
||||
DIR_WEB_ROOT = '{cfg name="path.root.web"}',
|
||||
DIR_STATIC_SKIN = '{cfg name="path.skin.web"}',
|
||||
DIR_STATIC_FRAMEWORK = '{cfg name="path.framework.frontend.web"}',
|
||||
DIR_ENGINE_LIBS = '{cfg name="path.framework.web"}/libs',
|
||||
|
||||
LIVESTREET_SECURITY_KEY = '{$LIVESTREET_SECURITY_KEY}',
|
||||
LANGUAGE = '{Config::Get('lang.current')}',
|
||||
WYSIWYG = {if Config::Get('view.wysiwyg')}true{else}false{/if};
|
||||
|
||||
var aRouter = [];
|
||||
{foreach $aRouter as $sPage => $sPath}
|
||||
aRouter['{$sPage}'] = '{$sPath}';
|
||||
{/foreach}
|
||||
</script>
|
||||
|
||||
{* Подключение скриптов указанных в конфиге *}
|
||||
{$aHtmlHeadFiles.js}
|
||||
{/block}
|
||||
|
|
|
@ -36,18 +36,30 @@ ls.topic = (function ($) {
|
|||
* @param {Object} options Опции
|
||||
*/
|
||||
this.init = function(options) {
|
||||
var self = this;
|
||||
var _this = this;
|
||||
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.form = $( '#topic-add-form' );
|
||||
|
||||
this.form.lsContent({
|
||||
urls: {
|
||||
add: aRouter['content'] + 'ajax/add/',
|
||||
edit: aRouter['content'] + 'ajax/edit/'
|
||||
}
|
||||
});
|
||||
|
||||
this.form.find( '.js-topic-draft-button' ).on( 'click', function () {
|
||||
_this.form.lsContent( 'submit', { is_draft: 1 });
|
||||
});
|
||||
|
||||
// Превью текста
|
||||
$(this.options.selectors.previewTopicTextButton).on('click', function (e) {
|
||||
self.showPreviewText('form-topic-add', 'topic-text-preview');
|
||||
_this.showPreviewText('form-topic-add', 'topic-text-preview');
|
||||
});
|
||||
|
||||
// Закрытие превью текста
|
||||
$(document).on('click', this.options.selectors.previewTopicTextHideButton, function (e) {
|
||||
self.hidePreviewText();
|
||||
_this.hidePreviewText();
|
||||
});
|
||||
|
||||
// Подгрузка информации о выбранном блоге при создании топика
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{block 'add_topic_header_after'}{/block}
|
||||
|
||||
|
||||
<form action="" method="POST" enctype="multipart/form-data" id="form-topic-add" class="js-form-validate" onsubmit="return false;">
|
||||
<form action="" method="POST" enctype="multipart/form-data" id="topic-add-form" class="js-form-validate" data-content-action="{( $topic ) ? 'edit' : 'add'}">
|
||||
{hook run="form_add_topic_begin"}
|
||||
{block 'add_topic_form_begin'}{/block}
|
||||
|
||||
|
@ -143,10 +143,8 @@
|
|||
{include 'components/button/button.tpl' type='button' classes='js-topic-preview-text-button' text=$aLang.common.preview_text}
|
||||
|
||||
{* Сохранить в черновиках / Перенести в черновики *}
|
||||
{if $topic && $topic->getPublish() != 0}
|
||||
{include 'components/button/button.tpl'
|
||||
id = {( $topic ) ? 'submit-edit-topic-save' : 'submit-add-topic-save' }
|
||||
text = $aLang.topic.add.button[ ( $sEvent == 'add' ) ? 'save_as_draft' : 'mark_as_draft' ]}
|
||||
{if ! $topic || ( $topic && $topic->getPublish() != 0 )}
|
||||
{include 'components/button/button.tpl' type='button' classes='js-topic-draft-button' text=$aLang.topic.add.button[ ( $sEvent == 'add' ) ? 'save_as_draft' : 'mark_as_draft' ]}
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
|
||||
{* Основной заголовок страницы *}
|
||||
{block 'layout_page_title' hide}
|
||||
{include 'components/page-header/page-header.tpl' text={$smarty.block.child}}
|
||||
{include 'components/page-header/page-header.tpl' text="{$smarty.block.child}"}
|
||||
{/block}
|
||||
|
||||
{block 'layout_content_header'}
|
||||
|
|
Loading…
Reference in a new issue