/** * @author Kirill Burkhanov */ var originalSerializeArray = $.fn.serializeArray; $.fn.extend({ serializeArray: function () { var brokenSerialization = originalSerializeArray.apply(this); var checkboxValues = $(this).find('input[type=checkbox]').map(function () { return { 'name': this.name, 'value': (this.checked) ? this.value : 0 }; }).get(); var checkboxKeys = $.map(checkboxValues, function (element) { return element.name; }); var withoutCheckboxes = $.grep(brokenSerialization, function (element) { return $.inArray(element.name, checkboxKeys) == -1; }); return $.merge(withoutCheckboxes, checkboxValues); } }); define = function(data, func) { var controller = data[0].split('/'); if(typeof window[controller[0]] == 'undefined') { window[controller[0]] = new Object(); } if(typeof controller[1] != 'undefined') { window[controller[0]][controller[1]] = func; if(typeof data[1] != 'undefined') { $(document).on(data[2], data[1], function(event) { try { self = {} self.e = $(this); self.data = [data[1], data[2]]; self.controller = controller; self.event = event; self.get = function(type) { switch(type[0]) { case ":": var result = window['Data'][type.substring(1)](); returnBack = { 0: result, query: function() { return Data.query(result); }, callback: function() { contr = result['callback'].split('/'); window[contr[0]][contr[1]](); } } break; } return returnBack; }; if(typeof window[self.controller[0]]['index'] != 'undefined') { allow = window[self.controller[0]]['index'](); if(allow) { window[self.controller[0]][self.controller[1]](); } } else { window[self.controller[0]][self.controller[1]](); } event.preventDefault(); return self; } catch(e) { console.log(e); alert('Ошибка! Пожалуйста обратитесь в Тех Поддержку \n Линия:' + e.line + ' Ошибка: ' + e.message); return false; } }); } } } define(['Data/url'], function() { var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = decodeURIComponent(pair[1]); } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; } else { query_string[pair[0]].push(decodeURIComponent(pair[1])); } } return query_string; }); // Data-[....] + inputs define(['Data/any'], function() { e = self.e; a = Data.form(); b = Data.attr(); $.extend(a, b); return a; }); // inputs define(['Data/form'], function() { e = self.e; var attrs = new Object(); url = self.e.serialize(); url = url.split('&'); $.each(url, function(i, v) { v = v.split('='); attrs[v[0]] = v[1]; }); return attrs; }); // data-[..] define(['Data/attr'], function(element) { if(typeof element == 'undefined') element = self.e[0]; attributes = element.attributes; var attrs = new Object(); for (var i = 0; i < attributes.length; i++) { name = attributes[i].name.toLowerCase(); val = attributes[i].value; if(name.substring(0, 4) == 'data') { name = name.substring(5); attrs[name] = val; } }; return attrs; }); // to query define(['Data/query'], function(obj) { var data = '', i = 0; for(var index in obj) { if(index != 'callback') { if(i == 0) { data += index+'='+obj[index]; } else { data += '&'+index+'='+obj[index]; } i++; } } return data; }); var requreQueue = []; define(['Data/setRequire'], function(file, path) { if(typeof path == 'undefined') { path = 'require'; } if(path == 'editor') { href = window.location.href.split('/')[3] if(href != 'content') { return false; } } requreQueue.push('/view/javascript/'+path+'/'+file+'.js'); }); define(['Data/require'], function(i) { $.getScript(requreQueue[i], function() { if(typeof requreQueue[i+1] != 'undefined') { Data.require(i+1); } }); }); // STATIC GO GO GO ----->>> var YandexID if(typeof yaCounter22792237 == 'undefined') { YandexID = { reachGoal: function() { return true; } } } else { YandexID = yaCounter22792237; } define(['Spinner/set'], function(name, element) { var opts = { lines: 11, // The number of lines to draw length: 0, // The length of each line width: 16, // The line thickness radius: 60, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 14, // The rotation offset direction: 1, // 1: clockwise, -1: counterclockwise color: '#999', // #rgb or #rrggbb or array of colors speed: 1.2, // Rounds per second trail: 88, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; spinner = new Spinner(opts).spin(element[0]); return true; }); define(['Spinner/remove'], function(name, element) { }); /** * Modals */ define(['Modal/hideEditor', '._modal-hide-editor', 'click'], function() { Modal.hide(); }); define(['Modal/hideOnClick', '._modal-hide', 'click'], function() { Modal.hide(); }); define(['Modal/hide'], function() { $('.drop-element.hover').removeClass('hover'); $('.modal').addClass('end'); $("#modal .dimmer").animate({ opacity: 0, }, 250, function() { $('#modal').remove(); }); $('body').css('overflow', 'auto'); }); define(['Modal/show'], function(data) { if(typeof data.size == 'undefined') { data.size = 'normal'; } if(typeof data.position == 'undefined') { data.position = ''; } if(typeof data.color == 'undefined') { data.color = ''; } $.ajax({ url: '/modal/'+data.scr, type: 'post', data: data, success: function (html) { switch(data.size) { case "normal": w = 600; break; case "big": w = 900; break; } if(typeof data.width != 'undefined') { w = data.width; } html = '
'; $('body').prepend(html).css('overflow', 'hidden'); if(data.position == '') { winWidth= $(window).width(); winMargin = (winWidth - w) / 2; if(winWidth < 800) { w = winWidth - 150; winMargin = 60; } $('.modal').css({ 'left': winMargin+'px', 'width': w }) } $('#modal').show(); $("#modal .dimmer").animate({ opacity: 1, }, 250); $('.modal').addClass('scale'); if(typeof data.callback != 'undefined') { data.callback(); } } }); }); define(['Modal/showOnClick', '._modal', 'click'], function() { data = self.get(':any')[0]; Modal.show(data); }); define(['Dimmer/show'], function(data) { html = '