Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Форма новости
- *
- *
- */
- Ext.app.ThemeView = function(styleId, form) {
- Ext.get('actualTehemeHeader').setStyle('display', 'none');
- Ext.get('quoteTehemeHeader').setStyle('display', 'none');
- return(
- Ext.app.actualThemeView((styleId === 104), form)
- || Ext.app.quoteThemeView((styleId === 200), form)
- );
- }
- Ext.app.actualThemeView = function(hide, form) {
- // лишние элементы формы
- var hide_form_item = ['body', 'source_block', 'pickers_tags', 'pickers_themes', 'photoauthor', 'alt'];
- var fi = form.items;
- var fic = fi.getCount();
- for (i = 0; i < fic; i++) {
- var item = fi.itemAt(i);
- if (hide_form_item.indexOf(item.name) !== -1) {
- if (hide) {
- item.hide();
- } else {
- item.show();
- }
- }
- }
- // лишние блоки формы
- var id_blocks = [
- 'id_block_bigtitle',
- 'id_block_source',
- 'id_block_checkboxes',
- 'id_block_regional_news',
- 'id_block_wide_news',
- 'id_block_digest'
- ];
- Ext.each(id_blocks, function(id){
- Ext.get(id).setStyle('display', (hide) ? 'none' : 'block');
- });
- Ext.get('actualTehemeHeader').setStyle('display', (hide) ? 'block' : 'none');
- return hide;
- }
- // вид админки цитат
- Ext.app.quoteThemeView = function(hide, form) {
- // лишние элементы формы
- var hide_form_item = ['body', 'descript', 'isauthor', 'source_name', 'pickers_tags', 'pickers_themes',
- 'photoauthor', 'alt'];
- var fi = form.items;
- var fic = fi.getCount();
- for (i = 0; i < fic; i++) {
- var item = fi.itemAt(i);
- if (item.name == 'title') {
- // убрать|вернуть ограничение на кол-во символов
- item.maxLength = (hide) ? 255 : 70;
- item.validate();
- }
- if (hide_form_item.indexOf(item.name) !== -1) {
- if (hide) {
- item.hide();
- } else {
- item.show();
- }
- }
- }
- // лишние блоки формы
- var id_blocks = [
- 'id_block_bigtitle',
- 'id_block_checkboxes',
- 'id_block_regional_news',
- 'id_block_wide_news',
- 'id_block_digest'
- ];
- Ext.each(id_blocks, function(id) {
- Ext.get(id).setStyle('display', hide ? 'none' : 'block');
- });
- Ext.get('quoteTehemeHeader').setStyle('display', hide ? 'block' : 'none');
- return hide;
- }
- Ext.form.PickersFormPanel = Ext.extend(Ext.form.FormPanel, {
- // применяем конфигурацию
- initComponent: function() {
- var _this = this;
- var secStore = new Ext.data.JsonStore({
- fields: ['name', 'value', 'firststyle'],
- proxy: new Ext.data.DirectProxy({
- directFn:pickerstree.readSections
- }),
- root: 'data',
- autoLoad: true
- });
- var tagsStore = new Ext.data.JsonStore({
- fields: ['name', 'value'],
- proxy: new Ext.data.DirectProxy({
- directFn:tagstree.readSections
- }),
- root: 'data',
- autoLoad: true
- });
- var themesStore = new Ext.data.JsonStore({
- fields: ['name', 'value'],
- baseParams: {
- extAction: 'themestree',
- extMethod: 'readSections'
- },
- proxy: new Ext.data.DirectProxy({
- directFn: themestree.readSections
- }),
- root: 'data',
- remoteSort: true,
- autoLoad: true
- });
- var config = {
- labelAlign: 'left',
- trackResetOnLoad: true,
- submitAllvalues: true,
- buttonAlign: 'left',
- frame: true,
- link: '/?id=',
- defaults: {
- width:800,
- enableKeyEvents: true,
- allowBlank: true,
- submitValue: false,
- bubbleEvents: ['focus', 'blur', 'change', 'htmlchange'] // всплытие событий фокуса и потери фокуса \
- // для отключения перехватчика событий грида (нужно только если эта форма вложена в поле грида), \
- // обработчики на эти события подключаются извне, для формы html редактора вызывается \\
- // отдельный обработчик
- },
- reader: new Ext.data.JsonReader(),
- items: [{
- xtype: 'hidden',
- name: 'id',
- ref: 'idfield',
- id: 'articleId'
- }, {
- xtype: 'hidden',
- name: 'sort',
- ref: 'sort'
- }, {
- xtype: 'hidden',
- name: 'is_diggest',
- ref: 'is_diggest'
- }, {
- xtype: 'hidden',
- name: 'is_widecart',
- ref: 'is_widecart'
- }, {
- xtype: 'hidden',
- name: 'big_fp',
- ref: 'big_fp'
- }, {
- xtype: 'hidden',
- name: 'small_fp',
- ref: 'small_fp'
- }, {
- xtype: 'hidden',
- name: 'vsmall_fp',
- ref: 'vsmall_fp'
- }, {
- xtype: 'hidden',
- name: 'source_fp',
- ref: 'source_fp'
- }, {
- xtype: 'hidden',
- name: 'wide_fp',
- ref: 'wide_fp'
- }, {
- xtype: 'hidden',
- name: 'source_fp_orig',
- ref: 'source_fp_orig'
- }, {
- xtype: 'hidden',
- name: 'img_url',
- ref: 'img_url'
- }, {
- xtype: 'hidden',
- name: 'img_author',
- ref: 'img_author'
- }, {
- xtype: 'hidden',
- name: 'img_cc',
- ref: 'img_cc'
- }, {
- xtype: 'hidden',
- name: 'img_cc_url',
- ref: 'img_cc_url'
- }, {
- xtype: 'hidden',
- name: 'img_alt',
- ref: 'img_alt'
- }, {
- xtype: 'hidden',
- name: 'img_title',
- ref: 'img_title'
- }, {
- xtype: 'hidden',
- name: 'del',
- ref: 'del'
- }, {
- xtype: 'hidden',
- name: 'news_agre',
- ref: 'news_agre',
- id: 'news_agre'
- }, {
- layout: 'column',
- width: 1518,
- items: [{
- columnWidth: 0.47,
- layout: 'form',
- defaults: {
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype:'textfield',
- maxLength:70,
- fieldLabel: 'Title SEO',
- submitValue: false,
- name: 'title_seo',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }]
- }]
- },{
- layout: 'column',
- width: 1518,
- items: [{
- columnWidth: 0.47,
- layout: 'form',
- defaults: {
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype:'textfield',
- maxLength:70,
- fieldLabel: 'Заголовок',
- submitValue: false,
- name: 'title',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }]
- }, {
- columnWidth:0.11,
- layout: 'form',
- defaults:{
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype: 'datefield',
- fieldLabel: 'дата',
- hideLabel: true,
- labelAlign: 'right',
- ref: '../../lastmod',
- submitValue: false,
- format: 'd.m.Y H:i:s',
- name: 'lastmod'
- }]
- }, {
- columnWidth: 0.42,
- id: 'id_block_bigtitle',
- layout: 'form',
- defaults:{
- anchor: '100%',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'textfield',
- maxLength: 70,
- fieldLabel:' Шпигель',
- submitValue: false,
- name: 'bigtitle',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keydown: Ext.app.QuotesChristmasTrees
- }
- }]
- }]
- }, {
- layout: 'column',
- items: [{
- layout: 'form',
- defaults:{
- hideLabel: true,
- submitValue: false,
- bubbleEvents: ['change']
- }
- }, {
- layout: 'form',
- defaults: {
- width: 608,
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'textarea',
- fieldLabel: 'Анонс',
- grow: true,
- growMin: 20,
- name: 'descript',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }]
- }]
- }, {
- width: 915,
- id: 'id_block_source',
- layout: 'column',
- items: [{
- columnWidth: 0.5,
- layout: 'form',
- defaults: {
- anchor: '96%',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- fieldLabel: '',
- xtype: 'combo',
- mode: 'local',
- triggerAction: 'all',
- forceSelection: true,
- editable: false,
- name: 'isauthor',
- displayField: 'name',
- valueField: 'value',
- value: '0',
- store: new Ext.data.JsonStore({
- fields: ['name', 'value'],
- data: [
- {name: 'Источник (если не задан, то будет info.sibnet.ru)', value: '0'},
- {name: 'Автор', value: '1'}
- ]
- }),
- listeners: {
- show: function (event) {
- if (this.value == 0) { // Источник
- Ext.getCmp('source_name').setHideTrigger(true);
- } else if (this.value == 1) { // Автор
- Ext.getCmp('source_name').setHideTrigger(false);
- }
- },
- select: function (event) {
- if (this.value == 0) { // Источник
- Ext.getCmp('source_name').setHideTrigger(true);
- } else if (this.value == 1) { // Автор
- Ext.getCmp('source_name').setHideTrigger(false);
- }
- }
- }
- }, {
- id: 'source_name',
- fieldLabel: 'Источник',
- xtype: 'combo',
- mode: 'local',
- triggerAction: 'all',
- forceSelection: false,
- editable: true,
- name: 'source_name',
- displayField: 'name',
- valueField: 'name',
- hideTrigger: true,
- value: '',
- store: new Ext.data.JsonStore({
- fields: ['name', 'url'],
- data: [
- {name: 'Олег Чернов, Sibnet.ru', url: '385'},
- {name: 'Вячеслав Корзун, Sibnet.ru', url: '384'},
- {name: 'Полина Разуваева, Sibnet.ru', url: '389'},
- {name: 'Елена Кондратенко, Sibnet.ru', url: '387'},
- {name: 'Светлана Дрягилева, Sibnet.ru', url: '388'},
- {name: 'Ольга Диянова, Sibnet.ru', url: '383'},
- {name: 'Елена Медведева, Sibnet.ru', url: '390'},
- {name: 'Елизавета Разумникова, Sibnet.ru', url: '386'},
- {name: 'Олег Девятилов', url: '392'},
- {name: 'Елена Козлова', url: '393'},
- {name: 'Очистить', url: '0'}
- ]
- }),
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees,
- select: function (event) {
- if(this.value == 'Очистить') {
- Ext.getCmp('source_link').setValue("")
- this.setValue("")
- } else {
- var items = this.store.data.items
- for (var i = 0; i < items.length; i++) {
- if(this.value == items[i].data.name) {
- Ext.getCmp('source_link').setValue("https://info.sibnet.ru/articles/" + items[i].data.url)
- }
- }
- }
- }
- }
- }]
- }, {
- columnWidth: 0.5,
- layout: 'form',
- defaults: {
- anchor: '100%',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [
- {
- xtype: 'checkbox',
- name: 'goto_source',
- fieldLabel: 'Всех на ист.'
- }, {
- id: 'source_link',
- xtype: 'textfield',
- fieldLabel: 'url на Источник',
- name: 'source_link'
- }
- ]
- }]
- }, {
- xtype: 'superboxselect',
- anchor:'100%',
- name: 'altsection',
- ref: 'altsection',
- mode: 'remote',
- fieldLabel: 'Рубрики',
- allowBlank: false,
- emptyText: 'Не выбрано',
- submitValue:false,
- store: secStore,
- triggerAction: 'all',
- displayField: 'name',
- valueField: 'value',
- checkChangeBuffer: 500,
- listeners: {
- 'valid': function(e) {
- // специальное оформление для "Актуальные темы" и "Цитаты"
- var record = e.usedRecords;
- var firststyle = (record.getCount()) ? parseInt(record.itemAt(0).data.firststyle) : false;
- var form = this.ownerCt.getForm();
- if (Ext.app.ThemeView(firststyle, form)) {
- this.hide();
- } else {
- this.show();
- }
- }
- }
- }, {
- xtype: 'superboxselect',
- anchor:'100%',
- name: 'pickers_tags',
- ref: 'pickers_tags',
- mode: 'remote',
- fieldLabel: 'Теги',
- allowBlank: true,
- emptyText: 'none',
- submitValue:false,
- store: tagsStore,
- triggerAction: 'all',
- displayField: 'name',
- valueField: 'value',
- checkChangeBuffer: 500
- }, {
- xtype: 'superboxselect',
- anchor: '100%',
- name: 'pickers_themes',
- ref: 'pickers_themes',
- mode: 'remote',
- fieldLabel: 'Темы',
- allowBlank: true,
- emptyText: 'none',
- submitValue: false,
- store: themesStore,
- triggerAction: 'all',
- displayField: 'name',
- valueField: 'value',
- checkChangeBuffer: 500
- }, {
- anchor:'100%',
- layout: 'column',
- id: 'id_block_checkboxes',
- items:[{
- layout: 'form',
- defaults:{
- labelStyle: 'text-align:right;',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype:'checkbox',
- fieldLabel: 'Выделенная',
- name: 'isbigtitle',
- itemId: 'isbigtitle',
- ref: '../../isbigtitle'
- }]
- }, {
- layout: 'form',
- defaults: {
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'checkbox',
- fieldLabel: 'Заблокировано',
- name: 'blocked'
- }]
- }, {
- layout: 'form',
- defaults:{
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype:'checkbox',
- fieldLabel: 'Без коммент.',
- name: 'nocomments'
- }]
- }, {
- layout: 'form',
- id: 'agre_buttonset',
- xtype: 'splitbutton',
- text: 'Агрегаторы', // button_set - несколько значений одной цифрой
- tooltip: 'Передать в новостные агрегаторы: news.yandex.ru, news.google ...',
- iconCls: 'app-ico-checkbox-unchecked',
- bubbleEvents:['change'],
- style: 'margin-left:23px;margin-right:7px;',
- my_iconCls0: 'app-ico-checkbox-unchecked',
- my_iconCls1: 'app-ico-checkbox-mix-checked',
- my_iconCls2: 'app-ico-checkbox-full-checked',
- my_fn_check: function(setValue) {
- var powcount_sum = 0; // число всех чекбоксов
- var powcount_checked = 0; // число всех выбранных чекбоксов
- this.menu.items.each(function(menuItem) {
- // проверяем прочеканность
- var value = menuItem.value | false;
- if (value == false) {
- return true;
- }
- //alert(value);
- var pow2 = 1 << (value - 1); // id элем. меню в степени 2
- if (typeof(setValue) !== 'undefined') {
- var state = (setValue & pow2) ? true : false;
- menuItem.setChecked(state, true);
- menuItem.checked = state;
- }
- if (menuItem.checked) {
- powcount_checked += pow2;
- }
- powcount_sum += pow2;
- });
- // ставим иконку кнопке.
- var iconCls = powcount_checked != 0
- ? (powcount_checked != powcount_sum ? this.my_iconCls1 : this.my_iconCls2)
- : this.my_iconCls0; // по умолчанию unchecked
- this.setIconClass(iconCls);
- this.value = powcount_checked; // реальная цифра почеканных чекбоксов
- this.maxValue = powcount_sum; // цифра - если бы все были прочеканны
- //alert(powcount_sum);
- Ext.getCmp('news_agre').setValue(powcount_checked); // запись в скрытое поле для отправки на сервер
- },
- handler: function() {
- // check|unchek при клике на кнопку
- var setValue = this.value == this.maxValue ? 0 : -1;
- this.my_fn_check(setValue);
- },
- menu: {
- defaults: {
- xtype: 'menucheckitem',
- hideOnClick: false, // не закрывать меню при выборе чекбоксов
- submitValue: false,
- listeners: {
- checkchange: function(menuItem, checked) {
- // обрабатываем чеки
- var root = this.findParentByType('button');
- root.my_fn_check();
- }
- }
- },
- items: [
- // value - bit analog mysql set 63max
- { value: 1, text: 'news.yandex.ru' },
- { value: 2, text: 'news.google.com' },
- { value: 3, text: 'news.mail.ru' },
- { value: 4, text: 'news.rambler.ru' },
- { value: 5, text: 'news.liveinternet.ru' },
- { xtype: 'menuseparator' },
- {
- text: 'все',
- xtype: '',
- onClick: function() {
- var root = this.findParentByType('button');
- var setValue = (root.value == root.maxValue) ? 0 : -1;
- root.my_fn_check(setValue);
- }
- }
- ] // items
- } // menu
- }, { // Агрегаторы
- layout: 'form',
- id: 'zen_yandex',
- defaults: {
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'checkbox',
- fieldLabel: 'Zen.sport.ya',
- name: 'zen_yandex',
- listeners: {
- change: {
- fn: function (event) {
- // Порядковый номер Агрегатора
- var value = 6;
- var pow2 = 1 << (value - 1);
- var agre_buttonset = Ext.getCmp('agre_buttonset');
- //alert(agre_buttonset.value);
- alert(this.checked);
- if(this.checked) {
- agre_buttonset.value += pow2;
- } else {
- agre_buttonset.value -= pow2;
- }
- alert(agre_buttonset.value);
- }
- }
- },
- }]
- },{
- layout: 'form',
- defaults:{
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype:'checkbox',
- fieldLabel: 'В информер',
- name: 'informer'
- }]
- }, {
- layout: 'form',
- defaults: {
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'checkbox',
- fieldLabel: 'в ленте sibnet',
- name: 'export_flag',
- checked: true
- }]
- }, {
- layout: 'form',
- defaults:{
- labelStyle: 'text-align:right',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- xtype: 'checkbox',
- fieldLabel: 'Реклама',
- name: 'ad'
- }]
- }, {
- defaults: {
- labelStyle: 'display: none; width: 0',
- submitValue: false,
- bubbleEvents: ['change']
- },
- items: [{
- fieldLabel: '',
- width: 120,
- xtype: 'combo',
- mode: 'local',
- triggerAction: 'all',
- forceSelection: true,
- editable: false,
- name: 'flags',
- displayField: 'name',
- valueField: 'value',
- value: '0',
- store: new Ext.data.JsonStore({
- fields: ['name', 'value'],
- data: [
- { name: 'нет фото/видео', value: '0' },
- { name: 'есть фото' , value: '1' },
- { name: 'есть видео' , value: '2' },
- { name: 'есть ф. и в.' , value: '3' },
- { name: 'инфографика' , value: '8' },
- { name: 'online' , value: '16' },
- { name: 'без фото' , value: '4' }
- ]
- })
- }]
- }]
- }, {
- xtype: 'container',
- layout: {
- type: 'table',
- columns: 2
- },
- defaults: {
- anchor: '100%',
- labelWidth: 72
- },
- items: [
- {
- xtype: 'container',
- margin: 4,
- padding: 1,
- layout: {
- type: 'table',
- columns: 2
- },
- style: { border: '1px solid #ccc' },
- width: 230,
- height: 82,
- padding: 2,
- items: [
- {
- xtype: 'image',
- ref: '../../small_fp_source',
- resetImageSize: false,
- style: {
- width: '110px',
- height: '82px'
- }
- }, {
- xtype: 'image',
- ref: '../../small_wide_fp',
- resetImageSize: false,
- style: {
- marginLeft: '5px',
- width: '110px',
- height: '73px'
- }
- }
- ]
- }, {
- xtype: 'container',
- width: 800,
- layout: {
- type: 'form',
- columns: 4
- },
- style: { marginLeft: '5px' },
- defaults: {
- anchor: '100%',
- decimalSeparator: '.',
- submitValue: false,
- width: '100%',
- style: { marginBottom: '5px' }
- },
- items: [
- {
- xtype: 'displayfield',
- id: 'actualTehemeHeader',
- value: '<div>^ Заголовок и описание темы</div><div>< фото темы</div>',
- style: 'font-size: 16px;'
- }, {
- xtype: 'displayfield',
- id: 'quoteTehemeHeader',
- value: '<div>^ Ссылка с цитаты (если ввели ссылку, поставьте галочку "всех на источник")</div><div>< фото цитаты</div>',
- style: 'font-size: 16px;'
- }, {
- xtype:'textfield',
- fieldLabel: 'Авт. фото в теле новости ',
- name: 'photoauthor',
- value: '© ',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }, {
- xtype:'textfield',
- fieldLabel: 'Заголовок изображения',
- name: 'title_img',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }, {
- xtype:'textfield',
- fieldLabel: 'Подпись к фото',
- name: 'alt',
- enableKeyEvents: true,
- listeners: {
- keyup: Ext.app.QuotesChristmasTrees,
- keypress: Ext.app.QuotesChristmasTrees
- }
- }
- ]
- }
- ]
- }, {
- xtype: 'container',
- layout: {
- type: 'table',
- columns: 4
- },
- defaults: { margin: '0 8 0 0' },
- padding: '0 0 0 12',
- items: [{
- xtype: 'button',
- text: 'Редактировать',
- iconCls: 'x-htmleditor-imageupload-cropbutton',
- itemId: 'cropButton',
- ref: '../imgEditButton',
- scope: this,
- tooltip: 'Редактировать изображение',
- style: {
- margin: '-28px 0 0 4px',
- position: 'absolute'
- },
- handler: this._editImageHandler
- }]
- }, {
- layout: 'column',
- width: 920,
- items: [{
- columnWidth: 0.37,
- layout: 'form',
- defaults: {
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype: 'button',
- text: 'Редактировать фотослайдер',
- iconCls: 'x-htmleditor-imageupload-cropbutton',
- itemId: 'photoSliderButton',
- ref: '../photoSliderEditButton',
- scope: this,
- tooltip: 'Редактировать фотослайдер',
- handler: this.onPhotoSliderOpen
- }]
- }, {
- columnWidth: 0.37,
- layout: 'form',
- defaults: {
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype: 'button',
- text: 'Редактировать фотоленту',
- iconCls: 'x-htmleditor-imageupload-cropbutton',
- itemId: 'photoBlogButton',
- ref: '../photoBlogEditButton',
- scope: this,
- tooltip: 'Редактировать фотоленту',
- style: {
- margin: '0px 0px 0px 30px'
- },
- handler: this.onPhotoBlogOpen
- }]
- }, {
- columnWidth: 0.2,
- layout: 'form',
- defaults: {
- anchor:'100%',
- submitValue: false,
- bubbleEvents:['change']
- },
- items: [{
- xtype: 'button',
- text: 'Отправить в Яндекс',
- iconCls: '',
- itemId: 'Ybutton',
- style: {
- margin: '0px 0px 0px 30px'
- },
- listeners: {
- click: {
- fn: function (event) {
- _this.sendYandex();
- }
- }
- },
- scope: this
- }]
- }]
- }, {
- xtype: 'advhtmleditor',
- hideLabel: true,
- fieldLabel: 'Содержание',
- name: 'body',
- width: 960,
- height: 600,
- style: 'font-family:Verdana, Helvetica, sans-serif;',
- // костыль - добавляем кнопку вставки картинки в тело новости
- listeners: {
- PickersFormPanel: (PickersFormPanel = this),
- init: function() {
- PickersFormPanel._injectCss(cmp, '/isr_features.css' + Ext.app.cssSuffix);
- },
- render: function(cmp) {
- cmp.getToolbar().add({
- iconCls: 'x-htmleditor-imageupload',
- tooltip: 'Вставить фото',
- cmp: cmp,
- handler: function() {
- PickersFormPanel._bodyImageHandler(this.cmp);
- }
- });
- }
- }
- }],
- buttons: [{
- text: 'Опубликовать!',
- iconCls: 'icon-form-yes',
- itemId:'PublicButton',
- handler: this.onPublic,
- scope: this
- }, {
- xtype: 'tbspacer',
- width: 50
- }, {
- text: 'Региональные новости',
- id: 'id_block_regional_news',
- iconCls: '',
- itemId: 'Rbutton',
- handler: function() {
- var id = this.idfield.getValue();
- if (id && this.del.getValue() == 0)
- window.open('/admin_main_news/?id=' + id);
- else
- alert('Новость должна быть сохранена и опубликована!');
- },
- scope: this
- }, {
- text: 'Слайдер на главной',
- id: 'id_block_wide_news',
- iconCls: '',
- itemId: 'Wbutton',
- handler: this.onWideChange,
- scope: this
- }, {
- text: 'Дайджест дня',
- id: 'id_block_digest',
- iconCls: '',
- itemId: 'Dbutton',
- handler: this.onDiggestChange,
- scope: this
- }, {
- text: 'Приоритетная',
- iconCls: '',
- itemId: 'Pbutton',
- handler: this.onPriorityChange,
- scope: this
- }, {
- xtype: 'tbspacer',
- width: 50
- }, {
- itemId:'win',
- text: 'Просмотр',
- iconCls: '',
- disabled:true,
- scope: this,
- handler: function() {
- if (this.link && this.idfield.value)
- window.open(this.link + this.idfield.value);
- }
- }, {
- xtype: 'tbspacer',
- width: 50
- }, {
- text: 'Сохранить',
- iconCls: 'icon-save',
- listeners: {
- click: {
- buffer: 500,
- fn: function (event) {
- _this.onUpdate(this, event);
- }
- }
- },
- scope: this
- }]
- };
- Ext.apply(this, config);
- Ext.apply(this.initialConfig, config);
- Ext.form.PickersFormPanel.superclass.initComponent.apply(this, arguments);
- this.altsection.store.on('load', function() {
- if (this.dontreset) {
- this.dontreset = false;
- } else {
- this.originalValue = this.getValue();
- }
- }, this.altsection);
- this.pickers_tags.store.on('load', function() {
- if (this.dontreset) {
- this.dontreset = false;
- } else
- this.originalValue = this.getValue();
- }, this.pickers_tags);
- this.pickers_themes.store.on('load', function() {
- if (this.dontreset) {
- this.dontreset = false;
- } else
- this.originalValue = this.getValue();
- }, this.pickers_themes);
- this.getForm().on('actioncomplete', function(form, action) {
- // action - данные детальной формы
- if (action.type == 'load') {
- // <Костыль> для news_agre - Агрегаторы
- var agre_buttonset = Ext.getCmp('agre_buttonset');
- if (agre_buttonset.rendered) {
- //alert(action.result.data.news_agre);
- agre_buttonset.my_fn_check(action.result.data.news_agre);
- }
- var zen_yandex = Ext.getCmp('zen_yandex');
- if(zen_yandex.rendered) {
- // Порядковый номер Агрегатора
- zen_yandex.items.each(function(i){
- var pow2 = 1 << (6 - 1);
- var agre = action.result.data.news_agre;
- if (typeof(agre) !== 'undefined') {
- var state = (agre & pow2) ? true : false;
- i.setValue(state);
- }
- })
- }
- // </Костыль>
- var img = action.reader.jsonData.records.small_fp;
- this.small_fp_source.setSrc(img ? '/' + img : Ext.BLANK_IMAGE_URL);
- var wide_img = action.reader.jsonData.records.wide_fp;
- this.small_wide_fp.setSrc(wide_img ? '/' + wide_img : Ext.BLANK_IMAGE_URL);
- this.PublicChange();
- this.PriorityChange();
- this.DiggestChange();
- this.WideChange();
- this.YandexChange();
- }
- }, this);
- this.on('afterrender', function(form) {
- if (!form.drTarget)
- form.drTarget = new Ext.dd.DropTarget(form.body.dom, {
- ddGroup: 'pickers',
- notifyEnter: function(ddSource, e, data) {
- this.el.stopFx();
- this.el.highlight();
- },
- notifyDrop: function(ddSource, e, data) {
- if (data.node.ownerTree.id == 'tags-tree') {
- var oldval = form.pickers_tags.getValue();
- form.pickers_tags.setValue(oldval + ',' + data.node.id);
- form.pickers_tags.dontreset = true;
- } else if (data.node.ownerTree.id == 'themes-tree') {
- var oldval = form.pickers_themes.getValue();
- form.pickers_themes.setValue(oldval + ',' + data.node.id);
- form.pickers_themes.dontreset = true;
- } else if (data.node.ownerTree.id == 'feed-tree') {
- var oldval = form.altsection.getValue();
- form.altsection.setValue(oldval + ',' + data.node.id);
- form.altsection.dontreset = true;
- }
- }
- });
- }, this);
- },
- onUpdate: function(btn, ev) {
- this.fireEvent('clickonsave', btn, ev);
- },
- onPublic: function(btn, ev) {
- var id = this.idfield.getValue();
- if (id) {
- var d = this.del.getValue();
- var me = this;
- Ext.Ajax.request({
- url: this.url,
- params: {
- extAction: 'pickers',
- extMethod: 'setPublic',
- id: id,
- del: d
- },
- success: function(response) {
- var obj = Ext.ux.errorhandler.jsonajax(response);
- if (obj && obj.success) {
- if (d>0)
- me.del.setValue(0);
- else
- me.del.setValue(1);
- me.PublicChange();
- }
- },
- failure: Ext.ux.errorhandler.failuremessage
- });
- }
- },
- // Отправка текста в Яндекс Оригинальные тексты
- sendYandex: function() {
- frm = this.getForm();
- frm.items.each(function(f) {
- if (f.xtype == 'advhtmleditor') {
- var text = f.getValue();
- text = text.replace(/<[^>]*>/g, ' ');
- text = text.replace(/ /g, ' ');
- text = text.replace(/>/g, '>');
- text = text.replace(/</g, '<');
- text = text.replace(/\n+/g, ' ');
- text = text.replace(/ +/g, ' ');
- if (text.length < 500) {
- alert('Текст меньше 500 знаков!');
- } else if (text.length > 32000) {
- alert('Текст больше 32000 знаков!');
- } else {
- Ext.Ajax.request({
- url: Ext.app.REMOTING_API.url,
- params: {
- extAction: 'pickers',
- extMethod: 'sendYandex',
- text: text
- },
- success: function(response) {
- var data = Ext.decode(response.responseText);
- if (data) {
- if (data.success) {
- alert(data.msg);
- this.YandexChange();
- } else {
- alert(data.msg);
- }
- }
- },
- failure: Ext.ux.errorhandler.failuremessage
- });
- }
- }
- })
- },
- // выборка только измененных значений
- getModifiedFieldsValues: function() {
- frm = this.getForm();
- var o = false,
- n,
- key,
- val;
- frm.items.each(function(f) {
- if (this.create_fix && f.xtype == 'superboxselect')
- f.originalValue = '';
- if (!f.disabled && f.isDirty()) {
- n = f.getName();
- key = o[n];
- val = f.getValue();
- if (val != f.originalValue) {
- o = o ? o : {};
- if (Ext.isDefined(key)) {
- if (Ext.isArray(key)) {
- o[n].push(val);
- } else {
- o[n] = [key, val];
- }
- } else {
- o[n] = val;
- }
- }
- }
- }, this);
- if (o.altsection) {
- o.del = this.del.getValue();
- }
- return o;
- },
- setModifiedFieldsValues: function(values, response_values) {
- if (this.create_fix)
- this.create_fix = false;
- var resp_records = response_values.records;
- var me = this;
- frm = this.getForm();
- frm.items.each(function(f) {
- n = f.getName();
- if (values[n]) {
- f.originalValue = values[n];
- }
- if (resp_records[n]) {
- if (n == 'title') {
- me.setTitle(resp_records[n]);
- }
- f.setValue(resp_records[n]);
- f.originalValue = f.getValue();
- if (n == 'del') {
- me.PublicChange();
- me.PriorityChange();
- }
- }
- });
- },
- _editImageHandler: function() {
- var bigimage = '';
- if ((img_src = this.source_fp.getValue())) {
- var http = new RegExp('^https?:');
- bigimage = Ext.DomHelper.createDom({
- tag: 'img',
- src: (http.test(img_src) ? '' : '/') + img_src
- });
- }
- this.uploadDialog = new Sibnet.adminjs.NewsImageDialog({
- submitUrl: this.url,
- managerUrl: this.url,
- baseParams: {extAction: 'ImageNewsMapper'},
- imageToEdit: bigimage,
- width: 830,
- pageSize: 120,
- disableServerSideEdit: false,
- disableStyling: false,
- disableDelete: true,
- inline: false
- });
- this.uploadDialog.img_url.setValue(this.img_url.getValue());
- this.uploadDialog.img_author.setValue(img_src ? this.img_author.getValue() : '© ');
- this.uploadDialog.img_cc.setValue(this.img_cc.getValue());
- this.uploadDialog.img_cc_url.setValue(this.img_cc_url.getValue());
- this.uploadDialog.img_alt.setValue(this.img_alt.getValue());
- this.uploadDialog.img_title.setValue(this.img_title.getValue());
- this.uploadDialog.isbigtitle.setValue(this.isbigtitle.getValue());
- Ext.FREE_CROP = false;
- var me = this;
- this.uploadDialog.on('mainArticleImageEdited', function () {
- var newimg = this.imageUploadForm.vistaPrevia.src;
- if (newimg) {
- newimg = newimg.replace(new RegExp('https://' + document.domain + '(:[0-9]+)?/', 'g'), '');
- var old_img = me.source_fp.getValue();
- var sm_newimg = '';
- var sm = newimg.split('.');
- if (sm.length == 2 && (sm[1] == 'jpg' || sm[1] == 'jpeg' || sm[1] == 'gif' || sm[1] == 'png')) {
- sm_newimg = sm[0] + 's.' + (sm[1] == 'jpeg' ? 'jpg' : sm[1]);
- }
- if (sm_newimg && /^ni_source\/tmp\//.test(sm_newimg))
- me.small_fp_source.setSrc('/' + sm_newimg + '?' + Math.floor(Math.random() * 111111));
- if (old_img != newimg)
- me.source_fp.setValue(newimg);
- }
- var newimg_3x2 = this.imageUploadForm.imagePreview_3_2.src;
- if (newimg_3x2) {
- newimg_3x2 = newimg_3x2.replace(new RegExp('https://' + document.domain + '(:[0-9]+)?/', 'g'), '');
- var old_img_3x2 = me.wide_fp.getValue();
- var sm_newimg = '';
- var sm = newimg_3x2.split('.');
- if (sm.length == 2 && (sm[1] == 'jpg' || sm[1] == 'jpeg' || sm[1] == 'gif' || sm[1] == 'png')) {
- sm_newimg = sm[0] + 's.' + (sm[1] == 'jpeg' ? 'jpg' : sm[1]);
- }
- if (sm_newimg && /^ni_source\/tmp\//.test(sm_newimg)) {
- me.small_wide_fp.setSrc('/' + sm_newimg + '?' + Math.floor(Math.random() * 111111));
- }
- if (old_img_3x2 != newimg_3x2)
- me.wide_fp.setValue(newimg_3x2);
- }
- // задать source_fp_orig при сохр стр. (если там не пусто - то менялся исходник фото)
- var source_fp_orig = this.source_fp_orig.getValue();
- source_fp_orig = source_fp_orig.replace(new RegExp('https://' + document.domain + '/', 'g'), '');
- me.source_fp_orig.setValue(source_fp_orig);
- var isbigtitle = this.isbigtitle.getValue(); // коммерческая
- me.isbigtitle.setValue(isbigtitle);
- me.img_url.setValue(this.img_url.getValue());
- me.img_author.setValue(this.img_author.getValue());
- me.img_cc.setValue(this.img_cc.getValue());
- me.img_cc_url.setValue(this.img_cc_url.getValue());
- me.img_alt.setValue(this.img_alt.getValue());
- me.img_title.setValue(this.img_title.getValue());
- this.close();
- });
- this.uploadDialog.show();
- },
- // private
- // instead of overriding the htmleditor header method we just append another css file to it's iframe head
- _injectCss: function (cmp, cssFile) {
- var frameName = cmp.iframe.name;
- var iframe;
- iframe = document.frames ? document.frames[frameName] : window.frames[frameName];
- // we have to add our custom css file to the iframe
- var ss = iframe.document.createElement('link');
- ss.type = 'text/css';
- ss.rel = 'stylesheet';
- ss.href = cssFile;
- if (document.all) {
- iframe.document.createStyleSheet(ss.href);
- } else {
- iframe.document.getElementsByTagName('head')[0].appendChild(ss);
- }
- },
- // вставка фото в тело редактора
- _bodyImageHandler: function(cmp) {
- var bigimage = '';
- var img_src = '';
- this.uploadDialog = new Sibnet.adminjs.NewsImageDialog({
- submitUrl: this.url,
- managerUrl: this.url,
- width: 830,
- baseParams: { extAction:'ImageNewsMapper' },
- imageToEdit: bigimage,
- pageSize: 120,
- disableServerSideEdit: false,
- disableStyling: false,
- disableDelete: true,
- inline: true
- });
- // предзаполнить значения
- this.uploadDialog.img_url.setValue('');
- this.uploadDialog.img_author.setValue('© ');
- this.uploadDialog.img_cc.setValue('');
- this.uploadDialog.img_cc_url.setValue('');
- this.uploadDialog.img_alt.setValue('');
- this.uploadDialog.img_title.setValue('');
- Ext.FREE_CROP = true;
- // после нажатия ОК при вставке изображения в текст новости
- this.uploadDialog.on('inlineArticleImageEdited', function () {
- var newimg_src = (/sibnet\.ru\/ni/g.test(this.imageUploadForm.vistaPrevia.src)) ? this.imageUploadForm.vistaPrevia.src : this.imageUploadForm.src.el.getValue();
- if (!newimg_src) {
- this.close();
- return false;
- }
- var newimg_0w1h = this.imageUploadForm.realSize.getValue().split('x');
- var img_url = this.img_url.getValue();
- var img_author = this.img_author.getValue();
- var img_cc = this.img_cc.getValue();
- var img_cc_url = this.img_cc_url.getValue();
- var isbigtitle = this.isbigtitle.getValue(); // коммерческая
- var img_alt = this.img_alt.getValue();
- var img_title = this.img_title.getValue();
- var html = '\n<div class="isr_bi_c' + (newimg_0w1h[0] <= 480 ? ' inline_block' : '' ) + '">'
- html += '<div class="isr_bi_ic">';
- html += (newimg_0w1h[0]>480)
- ? '<img src="' + newimg_src + '" alt="' + img_alt + '" width="100%" class="isr_imgover480" title="' + img_title + '">'
- : '<img src="' + newimg_src + '" alt="' + img_alt + '" width="' + newimg_0w1h[0]
- + '" height="' + newimg_0w1h[1] + '" title="' + img_title + '">';
- html += '</div>';
- var sale_photo_html = '<div class="isr_bi_caption"><span class="isr_sale_photo">Купить иллюстрацию</span></div>';
- if (img_author.length && img_author != '© ') {
- html += '<div class="isr_bi_caption">';
- html += (img_url.length && !(/fotobank\.sibnet\.ru/.test(img_url)))
- ? '<a href="' + img_url + '" target="_blank" rel="nofollow">Фото</a><span>: </span>'
- : '<span>Фото: </span>';
- html += '<span>' + img_author + '</span>';
- html += img_cc_url.length
- ? '<span> / </span><a href="' + img_cc_url + '" target="_blank" rel="nofollow">'
- + img_cc + '</a>'
- : '';
- html += isbigtitle ? ' <span>|</span> ' + sale_photo_html : '';
- html+='</div>';
- } else {
- if (isbigtitle) {
- html += sale_photo_html;
- }
- }
- html += '</div></br>\n</br>\n';
- cmp.insertAtCursor(html);
- Ext.FREE_CROP = false;
- this.close();
- });
- this.uploadDialog.show();
- },
- PublicChange: function() {
- var p_btn = this.getFooterToolbar().getComponent('PublicButton');
- p_btn.enable();
- if (this.del.getValue() > 0) {
- p_btn.setIconClass('icon-form-yes');
- p_btn.setText('Опубликовать');
- } else {
- p_btn.setIconClass('sib-elist0');
- p_btn.setText('Скрыть');
- }
- },
- PriorityChange: function() {
- p_btn = this.getFooterToolbar().getComponent('Pbutton');
- p_btn.enable();
- if (this.sort.getValue() > 0)
- p_btn.setIconClass('icon-form-yes');
- else p_btn.setIconClass('');
- },
- DiggestChange: function() {
- p_btn = this.getFooterToolbar().getComponent('Dbutton');
- if (this.is_diggest.getValue() > 0)
- p_btn.setIconClass('icon-form-yes');
- else
- p_btn.setIconClass('');
- },
- YandexChange: function() {
- // p_btn = this.getFooterToolbar().getComponent('Ybutton');
- // if (this.is_diggest.getValue() > 0)
- // p_btn.setIconClass('icon-form-yes');
- // else
- // p_btn.setIconClass('');
- p_btn.setIconClass('');
- },
- onDiggestChange: function() {
- var fff_val = this.idfield.getValue();
- var win = new Ext.ux.ItemSelectWindow({
- title: 'Установка дайджеста дня',
- url: this.url,
- baseParams: {extAction:'pickers', extMethod: 'saveDiggest'},
- baseParams1: {
- sort: 'is_diggest',
- filter: [{
- type: 'list',
- value: 1,
- field: 'is_diggest'
- }]
- },
- baseParams2: {
- filter: [{
- type: 'list',
- value: 0,
- field: 'is_diggest'
- }, {
- type: 'numeric',
- comparison: 'eq',
- value: fff_val,
- field: 'id'
- }]
- },
- directLoad: pickers.read
- });
- win.show();
- win.m_form.getForm().on('actioncomplete' , function(form, action) {
- if (action.result.success) {
- var rec = form.findField('itemselector').multiselects[1].store.getById(fff_val);
- if (typeof rec != 'undefined') {
- this.is_diggest.setValue(1);
- this.is_diggest.originalValue = 1;
- } else {
- this.is_diggest.setValue(0);
- this.is_diggest.originalValue = 0;
- }
- this.DiggestChange();
- }
- }, this);
- },
- WideChange: function() {
- p_btn = this.getFooterToolbar().getComponent('Wbutton');
- if (this.is_widecart.getValue() > 0)
- p_btn.setIconClass('icon-form-yes');
- else
- p_btn.setIconClass('');
- },
- onWideChange: function() {
- var fff_val = this.idfield.getValue();
- var win = new Ext.ux.ItemSelectWindow({
- title: 'Слайдер на главной',
- url: this.url,
- baseParams: {
- extAction: 'pickers',
- extMethod: 'saveWideCart'
- },
- baseParams1: {
- sort:'is_widecart',
- filter: [
- { type: 'list', value: 1, field: 'is_widecart' }
- ]
- },
- baseParams2: {
- filter: [
- { type: 'list', value: 0, field: 'is_widecart' },
- { type: 'numeric', comparison: 'eq', value: fff_val, field: 'id'}
- ]
- },
- directLoad: pickers.read
- }); win.show();
- win.m_form.getForm().on('actioncomplete' , function(form, action) {
- if (action.result.success) {
- var rec = form.findField('itemselector').multiselects[1].store.getById(fff_val);
- if (typeof rec != 'undefined') {
- this.is_widecart.setValue(1);
- this.is_widecart.originalValue = 1;
- } else {
- this.is_widecart.setValue(0);
- this.is_widecart.originalValue = 0;
- }
- this.WideChange();
- }
- }, this);
- },
- onPriorityChange: function() {
- var fff_val = this.idfield.getValue();
- var sects = this.altsection.getValue();
- if (sects && fff_val) {
- var sect = sects.split(',')[0];
- var win = new Ext.ux.ItemPriorityWindow({
- title: 'Установка приоритетных новостей',
- url: this.url,
- baseParams: {
- extAction: 'pickers',
- extMethod: 'savePriority',
- section: sect,
- target:
- fff_val
- },
- baseParams1: {
- section: sect,
- sort: 'sort',
- dir: 'DESC',
- filter: [{
- type:'numeric',
- comparison:'gt',
- value:1,
- field:'sort'
- }]
- },
- baseParams2: {
- section: sect,
- filter: [{
- type: 'numeric',
- comparison: 'eq',
- value: fff_val,
- field: 'id'
- }, {
- type: 'numeric',
- comparison: 'eq',
- value: 0,
- field: 'sort'
- }]
- },
- directLoad: pickers.read,
- sectionLoad: pickerstree.readSections,
- baseParams3: {
- query:sects,
- valuesqry:true
- }
- });
- win.show();
- win.m_form.getForm().on('actioncomplete' , function(form, action) {
- if (action.result.success) {
- var rec = form.findField('itemselector').multiselects[1].store.getById(fff_val);
- if (typeof rec != 'undefined') {
- this.sort.setValue(1);
- this.sort.originalValue = 1;
- } else {
- this.sort.setValue(0);
- this.sort.originalValue = 0;
- }
- this.PriorityChange();
- }
- }, this);
- }
- },
- onPhotoBlogOpen: function() {
- var hiddenArticleId = Ext.getCmp('articleId');
- var articleId = hiddenArticleId.getValue();
- window.open(
- '/gtw/media/image/' + articleId + '/',
- '',
- 'width=1300,height=800,location=no,resizable=yes,scrollbars=yes,top=' + ((screen.height - 800) / 2)
- + ',left=' + ((screen.width - 1300) / 2)
- )
- },
- onPhotoSliderOpen: function() {
- var hiddenArticleId = Ext.getCmp('articleId');
- var articleId = hiddenArticleId.getValue();
- window.open(
- '/gtw/media/image/' + articleId + '/?in_slider=1',
- '',
- 'width=1300,height=800,location=no,resizable=yes,scrollbars=yes,top=' + ((screen.height - 800) / 2)
- + ',left=' + ((screen.width - 1300) / 2)
- )
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement