var Setup = {
windowHeight: $(window).height(),
windowWidth: $(window).width(),
sidebarWidth: 150,
dragging: false,
dragElement: false,
dragAllow: true,
draggingLine: false,
elementID: 0,
element: null,
styles: null,
mouseY: null,
mouseX: null,
targetY: null,
targetX: null,
scroll: $(window).scrollTop(),
elements: [],
blocks: [],
cords: null,
time: null,
cache: null,
css: {},
cssObject: {},
cssClasses: {},
cssCache: null,
cssCopy: [null, null],
cssModalHtml: null,
plugin: null,
wrapperTimer: null,
history: [],
currentHistory: 0,
mouse: {
x: 0,
y: 0,
element: null,
},
popupTimer: null,
lastElementPopup: 0
}
define(['Onload/editor'], function() {
Setup.contentWidth = Setup.windowWidth - Setup.sidebarWidth - 40;
$('#content').width(Setup.contentWidth);
});
define(['Time/micro'], function(get_as_float) {
var now = new Date() .getTime() / 1000;
var s = parseInt(now, 10);
return now*1000;
});
define(['Editor/setupCols'], function (col) {
row = col.parent();
cols = row.find('.drop-col');
currentIndex = cols.index(col.eq(0));
isSame = true;
lastClass = null;
colsWidth = [];
startIndex = (currentIndex == 0) ? 1 : 0;
cols.each(function(i) {
currentCol = $(this);
nowClass = Math.floor(currentCol.width() / 16);
if(i != currentIndex) {
if(i == startIndex) {
lastClass = Math.floor(currentCol.width() / 16);
nowClass = lastClass;
}
if(nowClass != lastClass) {
isSame = false;
}
lastClass = nowClass;
}
colsWidth[i] = nowClass;
});
if(isSame) {
cuurentClass = Math.floor(60/cols.length);
deltaClass = 60-cuurentClass*cols.length;
cols.each(function(i) {
if(i == currentIndex) {
nowClass = cuurentClass + deltaClass;
} else {
nowClass = cuurentClass;
}
$(this).removeClass(function (index, css) { return (css.match (/\bcol\S+/g) || []).join(' '); }).addClass('col'+nowClass);
});
} else {
leftColIndex = currentIndex - 1;
rightColIndex = currentIndex + 1;
minimumWidth = 5;
if(leftColIndex >= 0 && rightColIndex <= (colsWidth.length-1)) {
if(colsWidth[leftColIndex] < colsWidth[rightColIndex]) {
colsWidth[currentIndex] = colsWidth[leftColIndex];
} else {
colsWidth[currentIndex] = colsWidth[rightColIndex];
}
} else {
if(leftColIndex >= 0) {
colsWidth[currentIndex] = colsWidth[leftColIndex];
} else {
colsWidth[currentIndex] = colsWidth[rightColIndex];
}
}
sum = 0;
i = 0;
while(sum != 60) {
if(i % 2 == 0) {
if(colsWidth[currentIndex] > minimumWidth) {
colsWidth[currentIndex]--;
}
} else if((i-1) % 4 == 0) {
if(leftColIndex >= 0) {
if(colsWidth[leftColIndex] == (minimumWidth+1)) {
colsWidth[leftColIndex]--;
} else if(colsWidth[leftColIndex] > minimumWidth) {
colsWidth[leftColIndex]--;
}
if(colsWidth[leftColIndex] == minimumWidth) {
leftColIndex--;
}
}
} else if((i-1) % 2 == 0) {
if(rightColIndex <= colsWidth.length-1) {
if(colsWidth[rightColIndex] == (minimumWidth+1)) {
colsWidth[rightColIndex]--;
} else if(colsWidth[rightColIndex] > minimumWidth) {
colsWidth[rightColIndex]--;
}
if(colsWidth[rightColIndex] == minimumWidth) {
rightColIndex++;
}
}
}
i++;
sum = 0;
for (var j = 0; j < colsWidth.length; j++) {
sum += colsWidth[j];
};
if(i == 500) {
sum = 60;
}
// console.log(colsWidth);
// console.log(colsWidth[leftColIndex] + ' ' + colsWidth[currentIndex] + ' ' + colsWidth[rightColIndex]);
// console.log(leftColIndex + ' ' + currentIndex + ' ' + rightColIndex);
// console.log('-------');
}
// console.log(colsWidth);
cols.each(function(i) {
$(this).removeClass(function (index, css) { return (css.match (/\bcol\S+/g) || []).join(' '); }).addClass('col'+colsWidth[i]);
});
}
// console.log(isSame);
// console.log('-------');
Editor.renderLines(row);
});
define(['Editor/getID'], function() {
max = 0;
$('.drop-element, .drop-col, .drop-row, .wrapper-outside').each(function(i){
id = parseInt($(this).attr('data-id'));
if(id > max) max = id;
});
return max;
});
define(['Editor/getCssSetups'], function(type) {
switch(type) {
case "button": result = 'button'; break;
case "form": result = 'box-form'; break;
case "text": result = 'box-text'; break;
case "video": result = 'box-video'; break;
case "hr": result = 'box-hr'; break;
case "timer": result = 'part'; break;
case "image": result = 'img'; break;
default:
result = 'parent';
}
return result;
});
define(['Editor/getTemplate'], function(type, elementID, elementHTML) {
if(type == 'template') {
$.ajax({
url: '/scr/getSectionTemplate',
type: 'post',
async: false,
cache: false,
data: 'type='+Setup.cssCache.attr('data-value')+'&blank=true',
dataType: 'json',
success: function (data) {
html = data;
html.css = $.parseJSON(data.css);
html.content = $.parseJSON(data.content);
inside = $('
';
if(elementHTML == null) {
$.ajax({
url: '/scr/getBlockTemplate',
type: 'post',
async: false,
cache: false,
data: 'type='+type+'&blank=true',
dataType: 'json',
success: function (data) {
html += data.html;
Editor.elements(elementID, $.extend(true, {}, Witgets[type].content));
}
});
} else {
html += elementHTML;
}
html += '
';
}
return html;
});
define(['Editor/renderLines'], function(row) {
if(typeof row == 'undefined') row = $('.drop-row');
row.find('.move-line').remove();
row.each(function() {
var row = $(this);
rowID = row.attr('data-id');
height = row.outerHeight(true);
cols = row.find('.drop-col');
last = cols.length-1;
left = 0;
cols.each(function(j) {
colID = j;
if(j < last) {
left += $(this).outerWidth(true);
moveLine = $('').parent().html());
Witgets.css.updateElementCss(parseInt(wrapper.attr('data-id')));
elementsSettings.css('display', 'none');
wrapperAdds.css('display', 'none');
wrapper.css('background-size', '100% 100%');
html2canvas(wrapper, {
logging: true,
useCORS: true,
onrendered: save
});
console.log(elements)
function save(canvas) {
wrapper.removeAttr('style');
elementsSettings.removeAttr('style');
wrapperAdds.removeAttr('style');
data = canvas.toDataURL('image/png');
$.ajax({
url: '/scr/addSection',
type: 'post',
dataType: 'json',
data: {
image: data,
dom: dom,
css: css,
elements: elements
},
success: function (data) {
$('#sectionPreview .sections div[data-type="self"]').append('
\
\
\
')
// showSections($('#sidebar ul.menu li[data-type="self"] a')[0]);
Editor.selfSectionHelp('add');
// Editor.loading('stop');
Modal.show({
scr: 'message',
text: 'Секция успешно добавлена в «Мои секции»'
});
}
});
// console.log(data)
// html = '
'+
// '
'+
// '
' +
// '
' +
// '
' +
// '
'+
// '
'+
// '
';
// $('body').append(html);
// $('#modal').show();
// $("#modal .dimmer").animate({
// opacity: 1,
// }, 250);
}
self.event.preventDefault();
self.event.stopPropagation();
});
define(['Editor/selfSectionHelp'], function(type) {
len = $('#sidebar-content div[data-type="self"] .block-template').length;
lenMessage = $('#sidebar-content div[data-type="self"] .message').length;
if(type == 'add') {
if(lenMessage == 1) {
$('#sidebar-content div[data-type="self"] .message').remove();
}
} else {
if(len == 0) {
if($('#sidebar-content div[data-type="self"]').length == 0) {
$('#sidebar-content').append('
');
}
$('#sidebar-content div[data-type="self"]')
.html('
Сохраняйте сюда свои уникальные секции и используйте их на всех страницах
Для добавления нажмите на
сердечко у любой секции
');
}
}
});
define(['Editor/mergeWrapperTop', '.drop-merge-top', 'click'], function() {
wrapper = self.e.parent().parent().parent();
index = wrapper.index();
i = index-1;
if(i < 0) return false;
wrapperCopyFrom = $('#editor .wrapper-outside').eq(i);
if(!Editor.addWrapperToSlide(wrapper, wrapperCopyFrom)) {
return false;
}
html = wrapperCopyFrom.html();
wrapper.prepend(html);
id = wrapperCopyFrom.attr('data-id');
wrapperCopyFrom.remove();
Editor.setSectionAddButtons();
Editor.enableSave();
delete Setup.css[id];
});
define(['Editor/mergeWrapperBot', '.drop-merge-bot', 'click'], function() {
wrapper = self.e.parent().parent().parent();
index = wrapper.index();
len = $('.wrapper-outside').length - 1;
i = index+1;
if(i > len) return false;
wrapperCopyFrom = $('#editor .wrapper-outside').eq(i);
if(!Editor.addWrapperToSlide(wrapper, wrapperCopyFrom)) {
return false;
}
html = wrapperCopyFrom.html();
wrapper.append(html);
id = wrapperCopyFrom.attr('data-id');
wrapperCopyFrom.remove();
Witgets.wrapper.slide(wrapper.find('.drop-row').eq(0), 'update');
Editor.setSectionAddButtons();
Editor.enableSave();
delete Setup.css[id];
});
define(['Editor/moveWrapperBot', '.drop-move-bot', 'click'], function() {
wrapper = self.e.parent().parent().parent();
index = wrapper.index('.wrapper-outside');
len = $('.wrapper-outside').length -1;
i = ((index+1) > len) ? len : (index+1);
prev = $('#editor .wrapper-outside').eq(i);
wrapper.insertAfter(prev);
Editor.enableSave();
Editor.setSectionAddButtons();
});
define(['Editor/moveWrapperTop', '.drop-move-top', 'click'], function() {
wrapper = self.e.parent().parent().parent();
index = wrapper.index('.wrapper-outside');
i = ((index-1) < 0) ? 0 : (index-1);
prev = $('#editor .wrapper-outside').eq(i);
wrapper.insertBefore(prev);
Editor.enableSave();
Editor.setSectionAddButtons();
});
define(['Editor/showHidedMenu', '.drop-show-menu', 'mouseover'], function() {
self.e.hide();
self.e.parent().find('.hide-menu').show();
self.e.parent().addClass('absolute');
});
define(['Editor/hideShowedMenu', '.element-settings', 'mouseleave'], function() {
if(self.e.find('.drop-show-menu').hasClass('active')) {
self.e.find('.drop-show-menu').show();
self.e.find('.hide-menu').hide();
self.e.removeClass('absolute');
}
});
define(['Editor/redStyle', '.drop-red-style', 'click'], function() {
$("#drop-popup").remove();
e = self.e;
elementBlock = e.parent().parent().parent();
if(e.closest('.css-editable').length == 1) {
elementBlock = e.closest('.css-editable');
}
elementCss = elementBlock.attr('class').split(' ');
element = self.e.closest('.drop-element');
if(element.length == 1) {
type = element.attr('data-type');
styleElement = element;
styleClass = Witgets[type].styles;
$.each(elementCss, function(i, v) {
if(v == 'drop-element') {
v = 'element';
}
if(typeof styleClass[v] != 'undefined') {
styleSubtype = v;
if(styleClass[v] != 'this') {
styleClass = styleClass[v];
} else {
styleClass = v;
}
styleElement = styleElement.find('.'+styleClass).eq(0);
return false;
}
});
styleType = type;
} else {
styleElement = element = self.e.closest('.wrapper-outside');
styleClass = 'element';
styleType = 'wrapper';
styleSubtype = 'element';
}
console.log(element)
Setup.elementID = element.attr('data-id');
Setup.element = element;
Setup.styles = {
'element': styleElement,
'class': styleClass,
'type': styleType,
'subtype': styleSubtype
};
Setup.plugin = 'css';
html = Editor.modalTemplates('css');
Setup.cssModalHtml = html;
html = '
';
$('body').prepend(html);
modal_top_position = $.session.get("modal_top_position") || 50;
modal_left_position = $.session.get("modal_left_position") || ($(window).width()-570);
$('#modal-widget').css({
'left': modal_left_position+'px',
'top': modal_top_position+'px',
'width': 450,
});
$('#modal').show();
Editor.loadPlugin('css');
});
define(['Editor/redContent', '.drop-red-content', 'click'], function() {
if($('#modal').length == 1) {
return false;
}
$("#drop-popup").remove();
e = self.e.closest('.drop-element');
type = e.attr('data-type') || 'wrapper';
if(type == 'wrapper') {
e = self.e.closest('.wrapper-outside');
}
e.addClass('hover');
Setup.elementID = e.attr('data-id');
Setup.element = e;
width = $(window).width();
height = $(window).height();
offset = e.offset();
xs = offset.left;
xe = xs + e.outerWidth(true);
ys = offset.top;
ye = ys + e.outerHeight(true);
distRight = width - xe;
distLeft = xs;
bottom = false;
marginTop = ye + 30;
marginLeft = xs;
if(type == 'blank' || type == 'hr') {
self.e.remove();
e.removeClass('hover');
return false;
}
modalWidth = 400;
if(type == 'text') {
e.removeClass('hover');
modalType = 'editor-text';
bottom = false;
marginTop = ys;
marginLeft = xs;
} else {
modalType = 'editor';
bottom = true;
marginLeft = (width - modalWidth)/2;
marginTop = 150;
}
Setup.plugin = type;
html = Editor.modalTemplates(type);
html = '
';
$('body').prepend(html);
modal_top_position = $.session.get("modal_top_position") || marginTop;
modal_left_position = $.session.get("modal_left_position") || marginLeft;
if(type == 'form' && (width-modal_left_position-800) < 0) {
modal_left_position = width - 950;
}
if(type == 'text') {
$('#modal-widget').css({
'width': xe-xs,
'height': ye-ys,
'left': marginLeft+'px',
'top': marginTop+'px'
});
$('#modal .dimmer').css({
'position': 'absolute',
'top': 0,
'left': 0
})
} else {
$('#modal-widget').css({
'width': modalWidth,
'left': modal_left_position+'px',
'top': modal_top_position+'px'
});
}
$('#modal').show();
$("#modal .dimmer").animate({
opacity: 1,
}, 250);
// $('.modal').addClass('scale');
Editor.loadPlugin(type);
});
define(['Editor/changeHistory'], function(type) {
if(Setup.history.length != 1) {
$('#change-history-prev').removeClass('disabled');
$('#change-history-next').removeClass('disabled');
}
if(type == 'next') {
Setup.currentHistory++;
if(Setup.currentHistory >= (Setup.history.length-1)) {
$('#change-history-next').addClass('disabled');
}
if(Setup.currentHistory > (Setup.history.length-1)) {
Setup.currentHistory = Setup.history.length-1;
toastr.error('Нельзя вернуть предыдущее действие');
return false;
}
} else {
Setup.currentHistory--;
if(Setup.currentHistory <= 0) {
$('#change-history-prev').addClass('disabled');
}
if(Setup.currentHistory < 0) {
Setup.currentHistory = 0;
toastr.error('Нельзя возвратиться к последнему действию');
return false;
}
}
// alert(Setup.history);
// console.log('------');
historySetup = Setup.history[Setup.currentHistory];
Setup.elements = $.extend(true, {}, historySetup.elements);
Setup.blocks = $.extend(true, {}, historySetup.blocks);
Setup.css = $.extend(true, {}, historySetup.css);
$.each(Setup.css, function(i, v) {
Witgets.css.updateElementCss(i);
});
$('#editor').html(historySetup.html);
Editor.enableSave(false);
Editor.wrappersSetBlockUpdate();
if(type == 'next') {
toastr.info('Последнее действие возвращено');
} else {
toastr.info('Последнее действие отменено');
}
});
define(['Editor/enableSave'], function(historySaving) {
if(typeof historySaving == 'undefined') {
historySaving = true;
}
$('#editor-button-save').fadeIn();
if(historySaving == true) {
setTimeout(function() {
historySetup = {
elements: $.extend(true, {}, Setup.elements),
blocks: $.extend(true, {}, Setup.blocks),
css: $.extend(true, {}, Setup.css),
html: $('#editor').html()
}
Setup.history.push(historySetup);
if(Setup.history.length > 20) { // Num of history backups
Setup.history.splice(0, 1);
}
Setup.currentHistory = $.extend(true, [], [Setup.history.length - 1])[0];
// console.log(Setup.currentHistory);
$('#change-history-prev').removeClass('disabled');
$('#change-history-next').removeClass('disabled');
}, 200);
}
});
define(['Editor/disableSave'], function() {
$('#editor-button-save').fadeOut();
});
define(['Editor/save'], function() {
array = new Object();
elements = new Object();
$('.wrapper-outside').each(function(wi) {
array[wi] = new Object();
array[wi].id = $(this).attr('data-id');
array[wi].rows = Array();
elements[array[wi].id] = {
'content': Setup.elements[array[wi].id].content,
'type': 'wrapper'
}
$(this).find('.drop-row').each(function(ri) {
array[wi].rows[ri] = new Object();
array[wi].rows[ri].cols = Array();
array[wi].rows[ri].id = $(this).attr('data-id');
$(this).find('.drop-col').each(function(ci) {
array[wi].rows[ri].cols[ci] = new Object();
array[wi].rows[ri].cols[ci].class = $(this).attr('class').match(/\bcol\S+/g).join(' ');
array[wi].rows[ri].cols[ci].elements = Array();
array[wi].rows[ri].cols[ci].id = $(this).attr('data-id');
$(this).find('.drop-element').each(function(ei) {
id = $(this).attr('data-id');
type = $(this).attr('data-type');
dropBox = $(this).find('.drop-box');
dropBox = dropBox.children();
rowClass = dropBox.attr('class').match(/\brow\S+/g);
rowClass = (rowClass == null) ? null : rowClass.toString();
array[wi].rows[ri].cols[ci].elements.push(id);
elements[id] = {
'content': Setup.elements[id].content,
'type': type,
'rowClass': rowClass,
'colClass': array[wi].rows[ri].cols[ci].class
}
if(type == 'form' || type == 'button') {
name = (type == 'form') ? Setup.elements[id].content.button.name : Setup.elements[id].content.settings.name;
elements[id]['goals'] = Setup.elements[id].goals || {
name: name,
yandex: '',
google: '',
stats: true
}
}
});
});
});
});
css = JSON.stringify(Setup.css);
// elements = JSON.stringify(elements);
var id = window.location.href.split('/')[4];
console.log(array);
console.log(css);
console.log(elements);
$.ajax({
url: '/scr/saveDD',
type: 'post',
data: {
'id': id,
'dom': array,
'type': 'dom'
},
success: function (data) {
Editor.disableSave();
}
});
$.ajax({
url: '/scr/saveDD',
type: 'post',
data: {
'id': id,
'css': css,
'type': 'css'
},
success: function (data) {
Editor.disableSave();
}
});
$.ajax({
url: '/scr/saveDD',
type: 'post',
data: {
'id': id,
'elements': elements,
'type': 'elements'
},
success: function (data) {
toastr.success('Изменения сохранены');
// alert(data)
Editor.disableSave();
}
});
});
define(['Editor/widgetClick', '#sidebar-widgets .block-widget .drag', 'mousedown'], function() {
insert = $('.wrapper-outside').last();
target = self.e.parent();
type = target.attr('data-type');
$('#element_move').attr({
'data-type': type
});
if($('.drop-element').length == 0) {
Editor.setHolder($('#editor'), 'zero', 'zero');
} else {
Editor.setHolder(insert, 'wrapper', 'bot');
}
});
define(['Editor/deleteSection', '#sidebar-sections .sections .block-template .delete', 'mousedown'], function() {
var element = self.e.closest('.block-template');
$('.tipsy').remove();
$.ajax({
url: '/scr/deleteSection',
type: 'post',
data: 'id='+element.attr('data-id'),
success: function (data) {
element.addClass('animated zoomOut').slideUp(500); //.fadeOut();
setTimeout(function() {
element.remove();
Editor.selfSectionHelp('delete');
}, 600);
}
});
self.event.preventDefault();
self.event.stopPropagation();
});
var sectionTimer;
define(['Editor/wrapperMouseLeave', '#sidebar-sections', 'mouseleave'], function() {
sectionTimer = setTimeout(function() {
$('#sidebar-sections').animate({
height: 0,
opacity: 0
}, 500, function() {
$(this).remove();
Editor.setSectionAddButtons();
if($('.drop-element').length == 0) {
$('#editor').html(Editor.getBlankTemplate());
$('.drop-insert').fadeIn(100);
}
});
}, 800);
});
define(['Editor/wrapperMouseEnter', '#sidebar-sections', 'mouseenter'], function() {
clearTimeout(sectionTimer);
});
define(['Editor/sectionPreview'], function(id, type, e) {
clearTimeout(sectionTimer);
$('#sidebar-sections').remove();
sectionPreview = $('');
elementsLength = $('.drop-element').length;
if(elementsLength == 0) {
sectionPreview.css({
'height': 0,
'opacity': 0
});
$('#editor').html(sectionPreview);
} else {
element = $(e).closest('.wrapper-outside');
if(type == 'top') {
sectionPreview.css({
'height': 0,
'opacity': 0
}).insertBefore(element);
} else {
sectionPreview.css({
'height': 0,
'opacity': 0
}).insertAfter(element);
}
}
$('#sidebar-sections').animate({
height: 382,
opacity: 1
}, 400, function() {
$(this).css('height', 'auto');
});
Editor.setSectionAddButtons();
$('#sidebar-sections .sidebar-tabs li').eq(0).find('a').click();
});
define(['Editor/sectionWheel', '#sidebar-sections .sections > div', 'mousewheel'], function() {
event = self.event;
self.e[0].scrollLeft += (event.deltaY !== undefined) ? event.deltaY :
(event.detail !== undefined && event.detail !== 0) ? event.detail : -event.wheelDelta;
// tplsWidth = self.e.find('.block-template').length * 200;
// if(self.e[0].scrollLeft >= 100 && self.e[0].scrollLeft <= tplsWidth) {
// $('#sidebar-sections .sections').removeClass('shadow-right').removeClass('shadow-left').addClass('shadow');
// } else if(self.e[0].scrollLeft < 100) {
// $('#sidebar-sections .sections').removeClass('shadow').removeClass('shadow-left');
// $('#sidebar-sections .sections').addClass('shadow-right');
// } else if(self.e[0].scrollLeft > tplsWidth) {
// $('#sidebar-sections .sections').removeClass('shadow').removeClass('shadow-right');
// $('#sidebar-sections .sections').addClass('shadow-left');
// }
});
define(['Editor/sectionTabs', '#sidebar-sections .sidebar-tabs li a', 'click'], function(e) {
self.e.closest('.sidebar-tabs').find('.active').removeClass('active');
self.e.parent().addClass('active');
i = self.e.parent().index();
type = self.e.parent().attr('data-type');
sections = $('#sidebar-sections .sections');
sections.children('div').hide();
sections.find('.active').removeClass('active');
sections.find('div[data-type='+type+']').addClass('active').show();
});
define(['Editor/templateClick', '#sidebar-sections .sections .block-template .overlay', 'mousedown'], function() {
target = self.e.parent();
type = target.attr('data-type');
$('#element_move').attr({
'data-type': type
});
Setup.mouseY = self.event.pageY;
Setup.mouseX = self.event.pageX;
if($('.drop-element').length == 0) {
Editor.setHolder($('#editor'), 'zero', 'zero');
} else {
if($('#sidebar-sections').length == 1) {
var insert = $('.wrapper-outside[data-id='+$('#sidebar-sections').attr('data-id')+']');
} else {
var insert = $('.wrapper-outside').last();
}
Editor.setHolder(insert, 'wrapper', $('#sidebar-sections').attr('data-type'));
}
// Editor.prepareDragging(Setup.dragging, 'object_start');
$('#sidebar-sections').animate({
height: 0
}, 500, function() {
$(this).remove();
Setup.dragging = target;
Editor.prepareDragging(Setup.dragging, 'object_end');
Editor.setSectionAddButtons();
Setup.dragging = false;
});
// Setup.wrapperTimer = setTimeout(function() {
// $("html, body").animate({
// scrollTop: insert.offset().top - 50
// }, 1000);
// }, 500);
});
define(['Editor/textEditor'], function(type, e, callback, selection, init) {
if(type == 'init') {
e.raptor({
'autoEnable': true,
'unloadWarning': false,
"plugins": {
'cancel': false,
'classMenu': false,
'clearFormatting': false,
'cleanBlock': false,
'clickButtonToEdit': false,
'dockToElement': false,
'dockToScreen': false,
'embed': false,
'floatLeft': false,
'floatNone': false,
'floatRight': false,
'guides': false,
'historyRedo': false,
'historyUndo': false,
'hrCreate': false,
'insertFile': false,
'languageMenu': false,
'logo': false,
'save': false,
'snippetMenu': false,
'specialCharacters': false,
'statistics': false,
'tableCreate': false,
'tableDeleteColumn': false,
'tableDeleteRow': false,
'tableInsertColumn': false,
'tableInsertRow': false,
'tableMergeCells': false,
'tableSplitCells': false,
'textSizeDecrease': false,
'textSizeIncrease': false,
'textBlockQuote': false,
'viewSource': false,
'unsavedEditWarning': false,
'textSub': false,
'textSuper': false
},
bind: {
change: function() {
var element = this.getElement(),
html = this.getHtml();
if(typeof callback == 'function') {
callback(html);
}
},
selectionCustomise: function() {
if(typeof selection == 'function') {
selection(html);
}
},
enabled: function() {
target = this.target;
offset = target.offset();
width = target.outerWidth();
setTimeout(function() {
if(typeof init == 'function') {
init(target);
} else {
leftPos = offset.left;
if((offset.left + 480) > $(window).width()) {
leftPos = offset.left + width - 480;
}
$('.raptor-layout-toolbar-inner').css({
top: offset.top - 48,
left: leftPos
}).fadeIn();
$('.raptor-ui-link-remove').hide();
}
}, 100);
}
}
});
}
if(type == 'destroy') {
e.raptor('destruct');
setTimeout(function() {
e
.removeAttr('contenteditable')
.removeAttr('data-raptor-initialised')
.removeAttr('tabindex')
.removeClass('raptor-editable-block')
.removeClass('raptor-editing');
}, 100);
}
});
define(['Editor/timersUpdate'], function() {
// alert()
$(".box-timer").each(function(i){
timer = $(this);
type = $(this).attr('data-type');
time =$(this).attr('data-time');
if($(this).find('.part.hide').length == 1) type = undefined;
if(typeof type != 'undefined') {
dateNow = new Date();
hours = dateNow.getHours();
minutes = dateNow.getMinutes();
seconds = dateNow.getSeconds();
day = dateNow.getDate();
month = dateNow.getMonth();
year = dateNow.getFullYear();
date = new Date(time*1000);
hoursTime = date.getHours();
minutesTime = date.getMinutes();
secondsTime = date.getSeconds();
dayTime = date.getDate();
monthTime = date.getMonth();
yearTime = date.getFullYear();
if(type == 'everyday') {
if(hours > hoursTime || (hours == hoursTime && minutes > minutesTime)) {
timeEnds = new Date(year, month, day+1, hoursTime, minutesTime);
} else {
timeEnds = new Date(year, month, day, hoursTime, minutesTime);
}
dateString = timeEnds.getFullYear() + '/'+(timeEnds.getMonth()+1)+'/'+timeEnds.getDate()+' '+timeEnds.getHours()+':'+timeEnds.getMinutes()+':'+timeEnds.getSeconds();
} else {
// monthTime--;
timeEnds = new Date(yearTime, monthTime, dayTime, hoursTime, minutesTime);
dateString = timeEnds.getFullYear() + '/'+(timeEnds.getMonth()+1)+'/'+timeEnds.getDate()+' '+timeEnds.getHours()+':'+timeEnds.getMinutes()+':'+timeEnds.getSeconds();
}
timer.countdown(dateString, function(event) {
w = parseInt(event.strftime('%w'));
d = parseInt(event.strftime('%d'));
h = parseInt(event.strftime('%H'));
m = parseInt(event.strftime('%M'));
s = parseInt(event.strftime('%S'));
html = '';
if(w == 0 && h == 0 && m == 0 && s == 0) {
html = '
Акция закончилась!
';
} else {
if(w != 0) html += '
'+w+'
'+Text.num(w, 'Неделя', 'Недели', 'Недель')+'
';
if(d != 0) html += '
'+d+'
'+Text.num(d, 'День', 'Дня', 'Дней')+'
';
if(h != 0) html += '
'+h+'
'+Text.num(h, 'Час', 'Часа', 'Часов')+'
';
if(h != 0 || (h == 0 && m != 0)) html += '
'+m+'
'+Text.num(m, 'Минута', 'Минуты', 'Минут')+'
';
html += '
'+s+'
'+Text.num(s, 'Секунда', 'Секунды', 'Секунд')+'
';
}
$(this).html(html);
});
}
});
});
define(['Editor/showContentPanel'], function() {
$('#sidebar-content > div').hide();
$('body').css('overflow', 'hidden');
$('#sidebar-content div[data-type="header"]').show();
$('#sidebar-content').show().animate({
left: Setup.sidebarWidth,
}, 300);
});
function showSections(e) {
var li = $(e).parent();
if(timerSidebarContent == null) {
timerSidebarContent = setTimeout(function() {
$('#sidebar-content > div').hide();
$('body').css('overflow', 'hidden');
$('#sidebar-content div[data-type="'+li.attr('data-type')+'"]').show();
$('#sidebar-content').show().animate({
left: Setup.sidebarWidth,
}, 300);
}, 100);
} else {
clearTimeout(timerSidebarContent);
timerSidebarContent = setTimeout(function() {
$('#sidebar-content > div').hide();
$('body').css('overflow', 'hidden');
$('#sidebar-content div[data-type="'+li.attr('data-type')+'"]').show();
$('#sidebar-content').show().animate({
left: Setup.sidebarWidth,
}, 300);
}, 300);
}
}
var Tutorial = {};
define(['Editor/startTutorial'], function(names) {
if($('#tutorial-elements').length == 0) {
$('body').prepend('
');
}
mouse = $('#tutorial-elements .mouse');
if(typeof names != 'undefined') {
Tutorial.names = names;
}
if(typeof Tutorial.names[0] == 'undefined') {
console.log('the end');
mouse.hide();
return false;
}
name = Tutorial.names[0];
elementStart = Tutorial[name].elementStart;
elementEnd = Tutorial[name].elementEnd;
evt = Tutorial[name].evt;
var callback = Tutorial[name].callback || function() {};
mouse.hide();
Tutorial.timer = setInterval(function() {
if(elementStart == 'mouse') {
elementStartTop = Setup.mouse.y;
elementStartLeft = Setup.mouse.x;
elementStartWidth = 20;
elementStartHeight = 20;
} else {
elementStartOffset = elementStart.offset() || {top:0,left:0};
elementStartTop = elementStartOffset.top;
elementStartLeft = elementStartOffset.left;
elementStartWidth = elementStart.width();
elementStartHeight = elementStart.height();
}
elementEndOffset = elementEnd.offset() || {top:0,left:0};
elementEndTop = elementEndOffset.top;
elementEndLeft = elementEndOffset.left;
elementEndWidth = elementEnd.width();
elementEndHeight = elementEnd.height();
mouse.fadeIn(300).css({
top: elementStartTop + elementStartHeight/2,
left: elementStartLeft + elementStartWidth/2
}).animate({
top: elementEndTop + elementEndHeight/2,
left: elementEndLeft + elementEndWidth/2
}, 1500, function() {
callback();
$(this).fadeOut(300);
});
}, 2000);
elementEnd.mouseenter(function() {
clearInterval(Tutorial.timer);
Tutorial.names.shift();
Editor.startTutorial();
});
});
define(['Editor/setTutorial'], function(name, elementStart, elementEnd, evt, func) {
Tutorial[name] = {
elementStart: elementStart,
elementEnd: elementEnd,
evt: evt,
callback: func
}
});
var timerSidebarContent = null;
$(document).ready(function(event) {
toastr.options = {
'closeButton': false,
'debug': false,
'progressBar': false,
'positionClass': 'toast-top-left',
'onclick': null,
'showDuration': '300',
'hideDuration': '1000',
'timeOut': '5000',
'extendedTimeOut': '1000',
'showEasing': 'swing',
'hideEasing': 'linear',
'showMethod': 'fadeIn',
'hideMethod': 'fadeOut'
}
Editor.templatesSetup();
Editor.moveStart();
firstTime = $.cookie("first_time") || true;
if(firstTime) {
// Editor.setTutorial('sidebarSectionHover', 'mouse', $('#sidebar .menu li[data-type=header]'), 'hover');
// Editor.setTutorial('sidebarSectionChoose', 'mouse', $('#sidebar-content div[data-type=header] .block-template').eq(0), 'hover', function() {
// alert(1)
// });
// Editor.setTutorial('sidebarSectionMove', 'mouse', $(window), 'hover');
// Editor.startTutorial([
// 'sidebarSectionHover',
// 'sidebarSectionChoose',
// 'sidebarSectionMove',
// ]);
// $.cookie("first_time", false);
}
$(window).on('beforeunload', function(event) {
if($('#editor-button-save').is(':visible'))
return 'Внимание! У вас остались несохраненные изменения.';
});
$('#sidebar ul.menu li[data-type] a').hover(function() {
showSections(this);
})
$('#sidebar-content').hover(function() {
clearTimeout(timerSidebarContent);
}, function() {
timerSidebarContent = setTimeout(function() {
$('body').css('overflow', 'inherit');
$('#sidebar-content').animate({
left: -200,
}, 500, function() {
$(this).hide();
});
}, 500);
});
});