User:Mopsgamer/global.js

/*DivEditor by Mopsgamer*/ /*Version 1.8*/

$(function {    if (window.wgUserLanguage == "ru") { Editor = { AddInside: "#Editor", FontSize: 14, ButtonTextOpen: "Открыть", ButtonTextChange: "Сменить редактор", ButtonTextClose: "Закрыть", ButtonTextClear: "Очистить", ButtonTextCopy: "Копировать", ButtonTextSetCSS: "Применить", TextFontSize: "Размер текста", TextAreaTitle: "Код", ViewAreaTitle: "Вид", SettingStyles: "Стили", SettingText: "Текст", SettingColor: "Цвет", SettingFontFamily: "Шрифт", SettingFontSize: "Размер", SettingFontStyle: "Стиль", SettingFontWeight: "Жирность", SettingTextTransform: "Регистр", SettingTextDecoration: "Оформление", SettingWidth: "Ширина", SettingHeight: "Высота", SettingMargin: "Отступ снаружи", SettingPadding: "Отступ внутри", SettingBackground: "Фон", SettingPosition: "Позиция", SettingBorders: "Рамки", SettingBorderWidth: "Ширина", SettingBorderStyle: "Стиль", SettingBorderColor: "Цвет", SettingBorderRadius: "Радиус", SettingBoxShadow: "Тень", SettingTextShadow: "Тень текста", SettingOpacity: "Прозрачность", SettingTransform: "Трансформация", SettingOverflow: "Переполнение", SettingAttributes: "Атрибуты", SettingClasses: "Классы", SettingId: "ID" } } else { Editor = { AddInside: "#Editor", FontSize: 14, ButtonTextOpen: "Open", ButtonTextChange: "Change editor", ButtonTextClose: "Close", ButtonTextClear: "Clear", ButtonTextCopy: "Copy", ButtonTextSetCSS: "Apply", TextFontSize: "Font size", TextAreaTitle: "Code", ViewAreaTitle: "View", SettingStyles: "Styles", SettingText: "Text", SettingColor: "Color", SettingFontFamily: "Font", SettingFontSize: "Size", SettingFontStyle: "Style", SettingFontWeight: "Weight", SettingTextTransform: "Case", SettingTextDecoration: "Decor", SettingWidth: "Width", SettingHeight: "Height", SettingMargin: "Margin", SettingPadding: "Padding", SettingBackground: "Background", SettingPosition: "Position", SettingBorders: "Borders", SettingBorderWidth: "Width", SettingBorderStyle: "Style", SettingBorderColor: "Color", SettingBorderRadius: "Radius", SettingBoxShadow: "Shadow", SettingTextShadow: "Text shadow", SettingOpacity: "Opacity", SettingTransform: "Transform", SettingOverflow: "Overflow", SettingAttributes: "Attributes", SettingClasses: "Classes", SettingId: "ID" } } Area = "EditorTextArea"; AreaTitle = Editor.TextAreaTitle; $(Editor.AddInside).append(' '); $('#DivEditor').html('').css("border", "1px solid #90afcc").css("background", "#b4dbff").append(' '); $('#EditorAreas').append(' '); $('#EditorAreas').append('  '); $('#EditorAreas').append(' '); $('#EditorRightArea').append('  + -  Копировать '); $('#EditorRightArea').append(' Очистить Применить  '); $('#EditorHeader').append('Открыть Закрыть '); $('#ViewSettings').append('  : <input type="text" prop="text"></li> : <input type="text" prop="color"></li> : <input type="text" prop="font-family"></li> : <input type="text" prop="font-size"></li> : <select prop="font-style"> inherit initial  italic  normal  oblique  </li> : <select prop="font-weight"> inherit  initial  1  2  3  4  5  6  7  8  9  </li> : <select prop="text-transform"> capitalize  inherit  initial  lowercase  uppercase  </li> : <select prop="text-decoration"> overline <option val="line-through">line-through  underline  </li></ul> : <input type="text" prop="width"></li> : <input type="text" prop="height"></li> : <input type="text" prop="margin"></li> : <input type="text" prop="padding"></li> : <input type="text" prop="background"></li> :  absolute  fixed  inherit  initial <option val="relative" selected>relative  static  sticky  </li> <li> : <input type="text" prop="border-width"></li><li> : <select prop="border-style"> dashed  dotted  double  groove  hidden  inherit  initial  inset  outset  revert  ridge <option val="solid" selected>solid  unset  </li><li> : <input type="text" prop="border-color"></li><li> : <input type="text" prop="border-radius"></li></ul></li><li> : <input type="text" prop="box-shadow"></li><li> : <input type="text" prop="text-shadow"></li><li> : <input type="text" prop="opacity"></li><li> : <input type="text" prop="transform"></li><li> :  auto  hidden  inherit  initial  overlay  scroll <option val="visible" selected>visible  </li><li style="list-style-type: none;text-align: center;font-weight: bold;border-bottom: 1px solid #94a6b8;margin-bottom: 5px;"> </li><li> : <input type="text" prop="class"></li><li> : <input type="text" prop="id"></li>');

$('#ChangeEditor').text(Editor.ButtonTextOpen); $('#Close').text(Editor.ButtonTextClose); $('#Clear').text(Editor.ButtonTextClear); $('#Copy').text(Editor.ButtonTextCopy); $('#SetCSS').text(Editor.ButtonTextSetCSS); $('#TextFontSize').text(Editor.TextFontSize + ":"); $('#FontSize').text(Editor.FontSize); $('#EditorAreaTitle').text(AreaTitle); $('#SettingStyles').text(Editor.SettingStyles); $('#SettingText').text(Editor.SettingText); $('#SettingColor').text(Editor.SettingColor); $('#SettingFontFamily').text(Editor.SettingFontFamily); $('#SettingFontSize').text(Editor.SettingFontSize); $('#SettingFontStyle').text(Editor.SettingFontStyle); $('#SettingFontWeight').text(Editor.SettingFontWeight); $('#SettingTextTransform').text(Editor.SettingTextTransform); $('#SettingTextDecoration').text(Editor.SettingTextDecoration); $('#SettingWidth').text(Editor.SettingWidth); $('#SettingHeight').text(Editor.SettingHeight); $('#SettingMargin').text(Editor.SettingMargin); $('#SettingPadding').text(Editor.SettingPadding); $('#SettingBackground').text(Editor.SettingBackground); $('#SettingPosition').text(Editor.SettingPosition); $('#SettingBorders').text(Editor.SettingBorders); $('#SettingBorderWidth').text(Editor.SettingBorderWidth); $('#SettingBorderStyle').text(Editor.SettingBorderStyle); $('#SettingBorderColor').text(Editor.SettingBorderColor); $('#SettingBorderRadius').text(Editor.SettingBorderRadius); $('#SettingBoxShadow').text(Editor.SettingBoxShadow); $('#SettingTextShadow').text(Editor.SettingTextShadow); $('#SettingOpacity').text(Editor.SettingOpacity); $('#SettingTransform').text(Editor.SettingTransform); $('#SettingOverflow').text(Editor.SettingOverflow); $('#SettingAttributes').text(Editor.SettingAttributes); $('#SettingClasses').text(Editor.SettingClasses); $('#SettingId').text(Editor.SettingId); $('#EditorRightAreaText').hide; $('#EditorAreaTitle').hide; $('#EditorAreas').hide; $('#Close').hide;

$('#EditorRightArea button').css("width", "auto"); $('#ViewSettings li').css("list-style-type", "none"); $('#ViewSettings input').css("width", "110px"); $('#ViewSettings select').css("width", "118px"); $('#ViewSettings input, #ViewSettings select').css("float", "right") $('#EditorTextArea').css("font-size", Editor.FontSize.toString+"px");

var $setcss = function(prop) { $('#EditorViewArea>div') .css(prop, $('#ViewSettings input[prop=' + prop + ']').val); } var $setattr = function(attrib) { $('#EditorViewArea>div') .attr(attrib, $('#ViewSettings input[prop=' + attrib + ']').val); } var $setplhl = function(attrib) { $('#ViewSettings input[prop=' + attrib + ']') .attr("placeholder", attrib); }

$setplhl("color"); $setplhl("font-family"); $setplhl("font-size"); $setplhl("width"); $setplhl("height"); $setplhl("margin"); $setplhl("padding"); $setplhl("background"); $setplhl("position"); $setplhl("border-width"); $setplhl("border-style"); $setplhl("border-color"); $setplhl("border-radius"); $setplhl("box-shadow"); $setplhl("text-shadow"); $setplhl("opacity"); $setplhl("transform"); $setplhl("overflow"); $setplhl("class"); $setplhl("id");

$("#SetCSS").click(function{   $('#EditorViewArea>div').text($('#ViewSettings input[prop="text"]').val);    $setcss("color");    $setcss("font-family");    $setcss("font-size");    $setcss("font-style");    $setcss("font-weight");    $setcss("text-transform");    $setcss("text-decoration");    $setcss("width");    $setcss("height");    $setcss("margin");    $setcss("padding");    $setcss("background");    $setcss("position");    $setcss("border-width");    $setcss("border-style");    $setcss("border-color");    $setcss("border-radius");    $setcss("box-shadow");    $setcss("text-shadow");    $setcss("opacity");    $setcss("transform");    $setcss("overflow");    $setattr("class");    $setattr("id"); })

$('#Clear').click(function{ $('#EditorViewArea>div').attr("style", "").text(""); $('[prop="color"]').val(""); $('[prop="font-family"]').val(""); $('[prop="font-size"]').val(""); $('[prop="width"]').val(""); $('[prop="height"]').val(""); $('[prop="margin"]').val(""); $('[prop="padding"]').val(""); $('[prop="background"]').val(""); $('[prop="border-width"]').val(""); $('[prop="border-color"]').val(""); $('[prop="border-radius"]').val(""); $('[prop="box-shadow"]').val(""); $('[prop="box-shadow"]').val(""); $('[prop="opacity"]').val(""); $('[prop="transform"]').val(""); })

jQuery.fn.selectText = function { var range, selection; return this.each(function {   if (document.body.createTextRange) {      range = document.body.createTextRange;      range.moveToElementText(this);      range.select;    } else if (window.getSelection) {      selection = window.getSelection;      range = document.createRange;      range.selectNodeContents(this);      selection.removeAllRanges;      selection.addRange(range);    }  }); };

$('#Copy').click(function { $('#EditorTextArea').attr("contenteditable", "true");  $('#EditorTextArea').selectText;  document.execCommand("Copy");  document.getSelection.collapseToEnd;  $('#EditorTextArea').attr("contenteditable", "false"); });

$('#FontSizeIncrease').click(function{ if (Editor.FontSize < 30) {++Editor.FontSize; $('#EditorTextArea').css("font-size", Editor.FontSize+"px"); $('#FontSize').text(Editor.FontSize);} })

$('#FontSizeDecrease').click(function{ if (Editor.FontSize > 1) {--Editor.FontSize; $('#EditorTextArea').css("font-size", Editor.FontSize+"px"); $('#FontSize').text(Editor.FontSize);} })

$('#Close').click(function{ $('#ChangeEditor').text(Editor.ButtonTextOpen); $('#EditorAreas').hide; $('#EditorAreaTitle').hide; $('#Close').hide; $('#DivEditor').css("height", "unset").css("width", "unset").css("transition", "0.5s").unwrap; $('.refpopups-configure-page').css("z-index", "1001"); $('.avatars').css("z-index", "auto"); $('.wds-community-header').css("z-index", "5"); }) Area = "EditorTextArea"; AreaTitle = Editor.ViewAreaTitle; $('#EditorViewArea').show; $('#EditorTextArea').hide; $('#ChangeEditor').click(function{ $('#DivEditor').css("height", "500px").css("width", "950px").css("transition", "0"); $('#Close').show; $('#EditorAreas').show; $('#EditorAreaTitle').show; $('.refpopups-configure-page').css("z-index", "0"); $('.avatars').css("z-index", "0"); $('.wds-community-header').css("z-index", "3");

if( $('#ChangeEditor').text == Editor.ButtonTextOpen ){ $('#DivEditor').wrap(' '); }	if( $('#ChangeEditor').text == Editor.ButtonTextChange ){ switch (Area) { case "EditorViewArea": Area = "EditorTextArea"; AreaTitle = Editor.ViewAreaTitle; $('#EditorTextArea').hide; $('#EditorViewArea').show; $('#EditorRightAreaView').show; $('#EditorRightAreaText').hide; $('#EditorTextArea').text($('#EditorViewArea').val); break; case "EditorTextArea": Area = "EditorViewArea"; AreaTitle = Editor.TextAreaTitle; $('#EditorTextArea').show; $('#EditorViewArea').hide; $('#EditorRightAreaView').hide; $('#EditorRightAreaText').show; $('#EditorTextArea').text($('#EditorViewArea').html); }} $('#EditorAreaTitle').text(AreaTitle); $('#ChangeEditor').text(Editor.ButtonTextChange); }); });