Advertisement
Guest User

Untitled

a guest
May 1st, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     /**
  3.      * TMD Changed
  4.      */
  5.     {
  6.         $.tmdBBCodes = function (o) {
  7.             if (o && o.lang) message.lang = o.lang;
  8.             var smiliesURL = 'pic/smilies/';
  9.             var temp = [],
  10.                 i = 0,
  11.                 p = 0;
  12.             temp[i] = '';
  13.             var allTextAreas = "#posttext, form[action*='editpost'] textarea, form[action*='edit'] textarea, textarea[name='test'], textarea[name='msg'], textarea[name='body'], textarea[name='descr'], textarea.message";
  14.  
  15.             function init() {
  16.                 var fontsDropMenu = [],
  17.                     fonts = ['Arial', 'Comic Sans MS', 'Courier New', 'Lucida Console', 'Tahoma', 'Times New Roman', 'Verdana', 'Symbol'];
  18.                 for (var i = 0; i < fonts.length; i++) {
  19.                     fontsDropMenu.push({
  20.                         name: fonts[i],
  21.                         openWith: '[font=' + fonts[i] + ']',
  22.                         closeWith: '[/font]'
  23.                     })
  24.                 }
  25.                 tmdBbCodes = {
  26.                     markupSet: [
  27.                         {
  28.                             name: 'Bold',
  29.                             key: 'B',
  30.                             className: 'bold',
  31.                             openWith: '[b]',
  32.                             closeWith: '[/b]'
  33.                         },
  34.                         {
  35.                             name: 'Italic',
  36.                             key: 'I',
  37.                             className: 'italic',
  38.                             openWith: '[i]',
  39.                             closeWith: '[/i]'
  40.                         },
  41.                         {
  42.                             name: 'Underline',
  43.                             key: 'U',
  44.                             className: 'underline',
  45.                             openWith: '[u]',
  46.                             closeWith: '[/u]'
  47.                         },
  48.                         {
  49.                             name: 'Stroke',
  50.                             className: 'stroke',
  51.                             openWith: '[s]',
  52.                             closeWith: '[/s]'
  53.                         },
  54.                         {
  55.                             name: 'Font',
  56.                             className: 'font',
  57.                             openWith: '[font=[![Font]!]]',
  58.                             closeWith: '[/font]',
  59.                             dropMenu: fontsDropMenu
  60.                         },
  61.                         {
  62.                             separator: ' '
  63.                         },
  64.                         {
  65.                             name: 'Center Alignment',
  66.                             className: 'center',
  67.                             openWith: '[center]',
  68.                             closeWith: '[/center]'
  69.                         },
  70.                         {
  71.                             name: 'Right Alignment',
  72.                             className: 'right',
  73.                             openWith: '[right]',
  74.                             closeWith: '[/right]'
  75.                         },
  76.                         {
  77.                             name: 'Preformed text',
  78.                             className: 'pre',
  79.                             openWith: '[pre]',
  80.                             closeWith: '[/pre]'
  81.                         },
  82.                         {
  83.                             separator: ' '
  84.                         },
  85.                         {
  86.                             name: 'Size',
  87.                             key: 'S',
  88.                             className: 'fonts',
  89.                             openWith: '[size=[![' + message('size') + ']!]]',
  90.                             closeWith: '[/size]',
  91.                             dropMenu: [
  92.                                 {
  93.                                     name: 'Size 1',
  94.                                     openWith: '[size=1]',
  95.                                     closeWith: '[/size]'
  96.                                 },
  97.                                 {
  98.                                     name: 'Size 2',
  99.                                     openWith: '[size=2]',
  100.                                     closeWith: '[/size]'
  101.                                 },
  102.                                 {
  103.                                     name: 'Size 3',
  104.                                     openWith: '[size=3]',
  105.                                     closeWith: '[/size]'
  106.                                 },
  107.                                 {
  108.                                     name: 'Size 4',
  109.                                     openWith: '[size=4]',
  110.                                     closeWith: '[/size]'
  111.                                 },
  112.                                 {
  113.                                     name: 'Size 5',
  114.                                     openWith: '[size=5]',
  115.                                     closeWith: '[/size]'
  116.                                 },
  117.                                 {
  118.                                     name: 'Size 6',
  119.                                     openWith: '[size=6]',
  120.                                     closeWith: '[/size]'
  121.                                 },
  122.                                 {
  123.                                     name: 'Size 7',
  124.                                     openWith: '[size=7]',
  125.                                     closeWith: '[/size]'
  126.                                 }
  127.                             ]
  128.                         },
  129.                         {
  130.                             name: 'Colors',
  131.                             key: 'K',
  132.                             className: 'colors',
  133.                             openWith: '[color=[![Color]!]]',
  134.                             closeWith: '[/color]',
  135.                             dropMenu: [
  136.                                 {
  137.                                     openWith: '[color=#FFFFFF]',
  138.                                     closeWith: '[/color]',
  139.                                     className: "col1-1"
  140.                                 },
  141.                                 {
  142.                                     openWith: '[color=#CCCCCC]',
  143.                                     closeWith: '[/color]',
  144.                                     className: "col1-2"
  145.                                 },
  146.                                 {
  147.                                     openWith: '[color=#999999]',
  148.                                     closeWith: '[/color]',
  149.                                     className: "col1-3"
  150.                                 },
  151.                                 {
  152.                                     openWith: '[color=#666666]',
  153.                                     closeWith: '[/color]',
  154.                                     className: "col1-4"
  155.                                 },
  156.                                 {
  157.                                     openWith: '[color=#333333]',
  158.                                     closeWith: '[/color]',
  159.                                     className: "col1-5"
  160.                                 },
  161.                                 {
  162.                                     openWith: '[color=#000000]',
  163.                                     closeWith: '[/color]',
  164.                                     className: "col1-6"
  165.                                 },
  166.                                 {
  167.                                     openWith: '[color=#FF3333]',
  168.                                     closeWith: '[/color]',
  169.                                     className: "col2-1"
  170.                                 },
  171.                                 {
  172.                                     openWith: '[color=#FF0000]',
  173.                                     closeWith: '[/color]',
  174.                                     className: "col2-2"
  175.                                 },
  176.                                 {
  177.                                     openWith: '[color=#CC0000]',
  178.                                     closeWith: '[/color]',
  179.                                     className: "col2-3"
  180.                                 },
  181.                                 {
  182.                                     openWith: '[color=#990000]',
  183.                                     closeWith: '[/color]',
  184.                                     className: "col2-4"
  185.                                 },
  186.                                 {
  187.                                     openWith: '[color=#660000]',
  188.                                     closeWith: '[/color]',
  189.                                     className: "col2-5"
  190.                                 },
  191.                                 {
  192.                                     openWith: '[color=#330000]',
  193.                                     closeWith: '[/color]',
  194.                                     className: "col2-6"
  195.                                 },
  196.                                 {
  197.                                     openWith: '[color=#FFFF99]',
  198.                                     closeWith: '[/color]',
  199.                                     className: "col3-1"
  200.                                 },
  201.                                 {
  202.                                     openWith: '[color=#FFFF66]',
  203.                                     closeWith: '[/color]',
  204.                                     className: "col3-2"
  205.                                 },
  206.                                 {
  207.                                     openWith: '[color=#FFCC33]',
  208.                                     closeWith: '[/color]',
  209.                                     className: "col3-3"
  210.                                 },
  211.                                 {
  212.                                     openWith: '[color=#CC9933]',
  213.                                     closeWith: '[/color]',
  214.                                     className: "col3-4"
  215.                                 },
  216.                                 {
  217.                                     openWith: '[color=#996633]',
  218.                                     closeWith: '[/color]',
  219.                                     className: "col3-5"
  220.                                 },
  221.                                 {
  222.                                     openWith: '[color=#663333]',
  223.                                     closeWith: '[/color]',
  224.                                     className: "col3-6"
  225.                                 },
  226.                                 {
  227.                                     openWith: '[color=#66FF66]',
  228.                                     closeWith: '[/color]',
  229.                                     className: "col4-1"
  230.                                 },
  231.                                 {
  232.                                     openWith: '[color=#00FF00]',
  233.                                     closeWith: '[/color]',
  234.                                     className: "col4-2"
  235.                                 },
  236.                                 {
  237.                                     openWith: '[color=#00CC00]',
  238.                                     closeWith: '[/color]',
  239.                                     className: "col4-3"
  240.                                 },
  241.                                 {
  242.                                     openWith: '[color=#009900]',
  243.                                     closeWith: '[/color]',
  244.                                     className: "col4-4"
  245.                                 },
  246.                                 {
  247.                                     openWith: '[color=#006600]',
  248.                                     closeWith: '[/color]',
  249.                                     className: "col4-5"
  250.                                 },
  251.                                 {
  252.                                     openWith: '[color=#003300]',
  253.                                     closeWith: '[/color]',
  254.                                     className: "col4-6"
  255.                                 },
  256.                                 {
  257.                                     openWith: '[color=#6666FF]',
  258.                                     closeWith: '[/color]',
  259.                                     className: "col5-1"
  260.                                 },
  261.                                 {
  262.                                     openWith: '[color=#0000FF]',
  263.                                     closeWith: '[/color]',
  264.                                     className: "col5-2"
  265.                                 },
  266.                                 {
  267.                                     openWith: '[color=#0000CC]',
  268.                                     closeWith: '[/color]',
  269.                                     className: "col5-3"
  270.                                 },
  271.                                 {
  272.                                     openWith: '[color=#000099]',
  273.                                     closeWith: '[/color]',
  274.                                     className: "col5-4"
  275.                                 },
  276.                                 {
  277.                                     openWith: '[color=#000066]',
  278.                                     closeWith: '[/color]',
  279.                                     className: "col5-5"
  280.                                 },
  281.                                 {
  282.                                     openWith: '[color=#000033]',
  283.                                     closeWith: '[/color]',
  284.                                     className: "col5-6"
  285.                                 },
  286.                                 {
  287.                                     openWith: '[color=#FF66FF]',
  288.                                     closeWith: '[/color]',
  289.                                     className: "col6-1"
  290.                                 },
  291.                                 {
  292.                                     openWith: '[color=#FF33FF]',
  293.                                     closeWith: '[/color]',
  294.                                     className: "col6-2"
  295.                                 },
  296.                                 {
  297.                                     openWith: '[color=#CC33CC]',
  298.                                     closeWith: '[/color]',
  299.                                     className: "col6-3"
  300.                                 },
  301.                                 {
  302.                                     openWith: '[color=#993399]',
  303.                                     closeWith: '[/color]',
  304.                                     className: "col6-4"
  305.                                 },
  306.                                 {
  307.                                     openWith: '[color=#663366]',
  308.                                     closeWith: '[/color]',
  309.                                     className: "col6-5"
  310.                                 },
  311.                                 {
  312.                                     openWith: '[color=#330033]',
  313.                                     closeWith: '[/color]',
  314.                                     className: "col6-6"
  315.                                 }
  316.                             ]
  317.                         },
  318.                         {
  319.                             name: 'List item',
  320.                             className: 'list',
  321.                             openWith: '[*] ',
  322.                             multilineSupport: true
  323.                         },
  324.                         {
  325.                             name: 'Smiles',
  326.                             className: 'smiles',
  327.                             openWith: function (h) {
  328.                                 h.textarea.id = h.textarea.id || h.textarea.name;
  329.                                 BBsmiles(h.textarea.id)
  330.                             },
  331.                             closeWith: '',
  332.                             dropMenu: [
  333.                                 {
  334.                                     name: 'smile',
  335.                                     openWith: ':)'
  336.                                 },
  337.                                 {
  338.                                     name: 'cry',
  339.                                     openWith: ":'-("
  340.                                 },
  341.                                 {
  342.                                     name: 'sad',
  343.                                     openWith: ':('
  344.                                 },
  345.                                 {
  346.                                     name: 'grin',
  347.                                     openWith: ':D'
  348.                                 },
  349.                                 {
  350.                                     name: 'confused',
  351.                                     openWith: ':-/'
  352.                                 },
  353.                                 {
  354.                                     name: 'w00t',
  355.                                     openWith: ':w00t:'
  356.                                 },
  357.                                 {
  358.                                     name: 'noexpression',
  359.                                     openWith: ":|"
  360.                                 },
  361.                                 {
  362.                                     name: 'acute',
  363.                                     openWith: ':acute:'
  364.                                 },
  365.                                 {
  366.                                     name: 'annoyed',
  367.                                     openWith: ':annoyed:'
  368.                                 },
  369.                                 {
  370.                                     name: 'look',
  371.                                     openWith: ':look:'
  372.                                 },
  373.                                 {
  374.                                     name: 'airkiss',
  375.                                     openWith: ':airkiss:'
  376.                                 },
  377.                                 {
  378.                                     name: 'alien',
  379.                                     openWith: ":alien:"
  380.                                 },
  381.                                 {
  382.                                     name: 'angel',
  383.                                     openWith: ':angel:'
  384.                                 },
  385.                                 {
  386.                                     name: 'beee',
  387.                                     openWith: ':beee:'
  388.                                 },
  389.                                 {
  390.                                     name: 'ras',
  391.                                     openWith: ':ras:'
  392.                                 },
  393.                                 {
  394.                                     name: 'blink',
  395.                                     openWith: ':blink:'
  396.                                 },
  397.                                 {
  398.                                     name: 'blush',
  399.                                     openWith: ":blush:"
  400.                                 },
  401.                                 {
  402.                                     name: 'boxing',
  403.                                     openWith: ':boxing:'
  404.                                 },
  405.                                 {
  406.                                     name: 'bye',
  407.                                     openWith: ':bye:'
  408.                                 },
  409.                                 {
  410.                                     name: 'down',
  411.                                     openWith: ':down:'
  412.                                 },
  413.                                 {
  414.                                     name: 'fie',
  415.                                     openWith: ':fie:'
  416.                                 },
  417.                                 {
  418.                                     name: 'fist',
  419.                                     openWith: ":fist:"
  420.                                 },
  421.                                 {
  422.                                     name: 'fun',
  423.                                     openWith: ':fun:'
  424.                                 },
  425.                                 {
  426.                                     name: 'geek',
  427.                                     openWith: ':geek:'
  428.                                 },
  429.                                 {
  430.                                     name: 'giveheart2',
  431.                                     openWith: ':giveheart2:'
  432.                                 },
  433.                                 {
  434.                                     name: 'heartbeat',
  435.                                     openWith: ':heartbeat:'
  436.                                 },
  437.                                 {
  438.                                     name: 'hmm',
  439.                                     openWith: ":hmm:"
  440.                                 },
  441.                                 {
  442.                                     name: 'hmmm',
  443.                                     openWith: ':hmmm:'
  444.                                 },
  445.                                 {
  446.                                     name: 'huh',
  447.                                     openWith: ':huh:'
  448.                                 },
  449.                                 {
  450.                                     name: 'ike',
  451.                                     openWith: ':ike:'
  452.                                 }
  453.                             ]
  454.                         },
  455.                         {
  456.                             separator: ' '
  457.                         },
  458.                         {
  459.                             name: 'Picture',
  460.                             replaceWith: function (h) {
  461.                                 makeStaticMdPopup(h.textarea);
  462.                                 return '';
  463.                             },
  464.                             className: "picture", dropMenu: [
  465.                             {
  466.                                 name: 'Upload',
  467.                                 replaceWith: function (h) {
  468.                                     makeStaticMdPopup(h.textarea);
  469.                                     return '';
  470.                                 },
  471.                                 className: "picture-upload"
  472.                             },
  473.                             {
  474.                                 name: 'Url',
  475.                                 key: 'P',
  476.                                 replaceWith: '[img][![Url]!][/img]',
  477.                                 className: "picture-url"
  478.                             }
  479.                         ]},
  480.                         {
  481.                             name: 'Iurl',
  482.                             className: 'iurl',
  483.                             openWith: '[iurl=[![Url]!]]{}',
  484.                             closeWith: '[/iurl]',
  485.                             placeHolder: 'TEXT'
  486.                         },
  487.                         {
  488.                             name: 'Link',
  489.                             key: 'L',
  490.                             className: 'link',
  491.                             openWith: '[url=[![Url]!]]',
  492.                             closeWith: '[/url]',
  493.                             placeHolder: message('link')
  494.                         },
  495.                         {
  496.                             name: 'Anchor',
  497.                             className: 'anchor',
  498.                             openWith: '[anchor][![' + message('anchor') + ':]!][/anchor]'
  499.                         },
  500.                         {
  501.                             name: 'Anchor Link',
  502.                             className: 'anchor_lnk',
  503.                             openWith: '[url=#[![' + message('anchor') + ':]!]]',
  504.                             closeWith: '[/url]',
  505.                             placeHolder: 'Numele linkului'
  506.                         },
  507.                         {
  508.                             name: 'Youtube',
  509.                             className: 'youtube',
  510.                             openWith: '[yt][![Youtube link:]!]',
  511.                             closeWith: '[/yt]'
  512.                         },
  513.                         {
  514.                             separator: ' '
  515.                         },
  516.                         {
  517.                             name: 'Quotes',
  518.                             openWith: '[quote]',
  519.                             className: 'quote',
  520.                             closeWith: '[/quote]'
  521.                         },
  522.                         {
  523.                             name: 'Code',
  524.                             openWith: '[code]',
  525.                             className: 'code',
  526.                             closeWith: '[/code]'
  527.                         },
  528.                         {
  529.                             name: 'Spoiler',
  530.                             openWith: '[spoiler=[![Spoiler name:]!]]',
  531.                             className: 'spoiler',
  532.                             closeWith: '[/spoiler]',
  533.                             placeHolder: message('spoiler')
  534.                         },
  535.                         {
  536.                             separator: ' '
  537.                         },
  538.                         {
  539.                             name: 'Clean',
  540.                             className: "clean",
  541.                             replaceWith: function (markitup) {
  542.                                 return markitup.selection.replace(/\[(.*?)\]/g, "")
  543.                             }
  544.                         },
  545.                         {
  546.                             name: 'Undo',
  547.                             key: 'Z',
  548.                             className: "undo",
  549.                             replaceWith: function (h) {
  550.                                 h.textarea.value = wLogBack(h.textarea.value)
  551.                             }
  552.                         },
  553.                         {
  554.                             name: 'Redo',
  555.                             key: 'Y',
  556.                             className: "redo",
  557.                             replaceWith: function (h) {
  558.                                 h.textarea.value = wLogNext(h.textarea.value)
  559.                             }
  560.                         },
  561.                         {
  562.                             name: 'Preview',
  563.                             className: "preview"
  564.                         }
  565.                     ]
  566.                 };
  567.  
  568.                 $(allTextAreas).livequery(function () {
  569.                     var $this = $(this);
  570.  
  571.                     // Distruge markItUp initiliazat anterior
  572.                     if ($this.closest('.markItUp').length) {
  573.                         $this.removeClass('markItUpEditor');
  574.                         $this.closest('.markItUp').replaceWith($this);
  575.                     }
  576.  
  577.                     $this.not('.markItUpEditor').markItUp(tmdBbCodes).show(1, function(){
  578.                         markItUpStart();
  579.                     });
  580.                 });
  581.             }
  582.  
  583.             function myPreview(v, e) {
  584.                 var $t = $('textarea.markItUpEditor');
  585.                 if ($('#prv').length > 0 || $t.val().replace(/\[(.*?)\]/g, "").length < 1) return;
  586.                 var $dInfo, $ldngDiv;
  587.                 var t = $t.map(function () {
  588.                     return {
  589.                         w: $(this).width(),
  590.                         h: $(this).height(),
  591.                         c: $(this).offset()
  592.                     }
  593.                 }).get(0);
  594.                 $(v).hide();
  595.                 $ldngDiv = $('<img/>', {
  596.                     'src': 'pic/loading2.gif'
  597.                 }).css({
  598.                         'margin-top': '3px'
  599.                     }).insertAfter($(v));
  600.                 var val = $t.val();
  601.                 $.post("tags.php", {
  602.                     'test': val
  603.                 }).then(function (data) {
  604.                         var html = data.replace(/\n/g, '').replace(/.*<p><hr>/g, '').replace(new RegExp("<hr></p>.*", "g"), '');
  605.                         html = '<td style="border: 0px; width: ' + t.w + 'px;">' + html + '</td>';
  606.                         $prv = $('<div>', {
  607.                             'id': 'prv'
  608.                         }).css({
  609.                                 'width': t.w,
  610.                                 'height': t.h,
  611.                                 'left': t.c.left,
  612.                                 'top': t.c.top,
  613.                                 'text-align': 'left',
  614.                                 'position': 'absolute',
  615.                                 'z-index': '88',
  616.                                 'background-color': '#ece9d8',
  617.                                 'border': 'solid #A79F72 1px',
  618.                                 'display': 'none',
  619.                                 'padding': '5px',
  620.                                 'overflow-y': 'auto'
  621.                             }).insertBefore($t.parents('div.markItUp')).fadeIn(300).html(html);
  622.                         $ldngDiv.fadeOut(300, function () {
  623.                             $dInfo = $('<div/>').html('<b>&nbsp;&nbsp;&nbsp;' + message('infopreview') + '</b>').hide();
  624.                             $pUl = $(this).parents('ul').fadeOut(290).after($dInfo);
  625.                             $dInfo.delay(300).fadeIn(600).delay(5000).fadeOut(300, hideHeader)
  626.                         });
  627.                         $prv.append('<script>initSpoilers(); initIurl(); </script>');
  628.                         var hideHeader = function hideHeader() {
  629.                             $ldngDiv.remove();
  630.                             $dInfo.remove();
  631.                             $pUl.fadeIn(300)
  632.                         };
  633.                         var hideAll = function hideAll() {
  634.                             $prv.remove();
  635.                             hideHeader();
  636.                             $(v).show()
  637.                         };
  638.                         var hidePrv = function () {
  639.                             $(document).one("click", function (e) {
  640.                                 if ($(e.target).parents('#prv').length > 0) {
  641.                                     hidePrv()
  642.                                 } else {
  643.                                     $prv.fadeOut(300, hideAll)
  644.                                 }
  645.                             });
  646.                             $(document).one("contextmenu", function (e) {
  647.                                 $prv.fadeOut(300, hideAll);
  648.                                 e.preventDefault()
  649.                             })
  650.                         };
  651.                         hidePrv()
  652.                     })
  653.             }
  654.  
  655.             function BBsmiles(here) {
  656.                 $smilies = $('#smilies');
  657.                 if ($smilies.length) {
  658.                     $smilies.show();
  659.                     $(document).one('click', function () {
  660.                         $smilies.hide()
  661.                     });
  662.                     return
  663.                 }
  664.                 var h = $('textarea.markItUpEditor').height();
  665.                 $iframe = $('<iframe>', {
  666.                     'frameborder': '0',
  667.                     'width': '180',
  668.                     'height': (h + 11),
  669.                     'src': './smilies_popup.php?text=&container=bbIframeSmilies&lang=ro'
  670.                 });
  671.                 $smilies = $('<div>', {
  672.                     'id': 'smilies',
  673.                     'style': 'position: absolute; z-index: 10001;top: 22px; right: -12px;'
  674.                 }).insertAfter($('.markItUpHeader')).append($iframe);
  675.                 $iframe.load(function () {
  676.                     $iframe.contents().find("div, br, table tr:eq(0)").remove();
  677.                     $iframe.contents().find("a").each(function () {
  678.                         $img = $('img', this);
  679.                         $img.attr('width', ($img.attr('width') > 40) ? 40 : $img.attr('width'));
  680.                         $img.attr('height', ($img.attr('height') > 40) ? 40 : $img.attr('height'))
  681.                     }).click(function (e) {
  682.                             $.markItUp({
  683.                                 replaceWith: $(this).attr('href').replace(/.+IT\(\"/, '').replace(/\"\);/, '')
  684.                             });
  685.                             e.preventDefault();
  686.                             $smilies.hide()
  687.                         });
  688.                     $(document).one('click', function () {
  689.                         $smilies.hide()
  690.                     })
  691.                 })
  692.             }
  693.  
  694.             function wLogAdd(h) {
  695.                 if (temp[i] != h && h != "") {
  696.                     i = i + 1;
  697.                     p = i;
  698.                     temp[i] = h
  699.                 }
  700.             }
  701.  
  702.             function wLogBack(h) {
  703.                 if (p > 0) {
  704.                     if (p == i) {
  705.                         wLogAdd(h)
  706.                     }
  707.                     p = p - 1;
  708.                     return temp[p]
  709.                 }
  710.                 if (p == 0) return temp[p];
  711.                 return ''
  712.             }
  713.  
  714.             function wLogNext(h) {
  715.                 if (p + 1 <= i) {
  716.                     p = p + 1;
  717.                     return temp[p]
  718.                 }
  719.                 return h
  720.             }
  721.  
  722.             function markItUpStart() {
  723.                 $(".markItUpEditor").keypress(function (e) {
  724.                     wLogAdd(this.value)
  725.                 }).keydown(function (e) {
  726.                         if (e.keyCode == 8 || e.keyCode == 46) {
  727.                             wLogAdd(this.value)
  728.                         }
  729.                         if ((e.ctrlKey) && (e.keyCode == 86)) {
  730.                             wLogAdd(this.value)
  731.                         }
  732.                     });
  733.                 $(".markItUpContainer ul li.preview a").click(function (e) {
  734.                     myPreview($(this), e)
  735.                 });
  736.                 $(".markItUpContainer ul li.smiles ul li a").each(function () {
  737.                     var sName = $(this).attr('title');
  738.                     $(this).attr("style", 'background:url(' + smiliesURL + sName + '.gif)  no-repeat center center !important; padding: 0px;').text('').attr('title', '')
  739.                 });
  740.                 $('.markItUpContainer li.font ul li a').each(function (i, v) {
  741.                     $(v).css('font-family', $(v).attr('title'))
  742.                 })
  743.             }
  744.  
  745.             init();
  746.         };
  747.  
  748.         $.tmdBBCodes();
  749.     }
  750.  
  751.     /**
  752.      * Static.md
  753.      */
  754.     {
  755.         // Include required scripts
  756.         if ($.draggable === undefined || window.StaticMdPopup === undefined) {
  757.             (function(){
  758.                 var head    = document.getElementsByTagName('head')[0];
  759.                 var scripts = [
  760.                     '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>', // acum pe tmd e 1.8.0 si nu puteam sa o fac sa mearga pentru ca dadea erori la drag
  761.                     '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js"></script>',
  762.                     '<script type="text/javascript" src="http://popup.minecraft.md/popup.min.js"></script>'
  763.                 ];
  764.                 $(head).append(scripts.join(''));
  765.             })();
  766.         }
  767.  
  768.         // Add css
  769.         if (!$('#static-md-css').length) {
  770.             $(document.body).append("<style type=\"text/css\">.container{text-align:center}.static-md-popup{position:fixed;z-index:5000;-webkit-box-shadow:0 0 7px 3px #666;box-shadow:0 0 7px 3px #666}.static-md-popup .handle{padding:20px;background-color:#fff;cursor:move;position:relative}.static-md-popup .handle .handle-cover{position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(255,255,255,0.2)}.static-md-popup .handle .close{display:block;position:absolute;right:2px;top:2px;height:16px;width:16px;background:url('http://static.md/b47afd340c463c6d09e574d7421f21ca.gif') no-repeat 0 0}.static-md-popup .static-md-popup-iframe{height:110px;width:350px} .markItUpButton .picture-upload a, .markItUpButton .picture-url a {background-image: none;}</style>")
  771.         }
  772.  
  773.         // Instantele popup-urilor
  774.         var staticMdPopups = {};
  775.  
  776.         function makeStaticMdPopup(textareaElement) {
  777.             $textarea = $(textareaElement);
  778.  
  779.             var id = $textarea.attr('id');
  780.             if (!id) { // genereaza unul nou daca textarea nu are id
  781.                 id = 'static-md-'+ parseInt((new Date()).getTime());
  782.                 $textarea.attr('id', id);
  783.             }
  784.  
  785.             var proxyUrl    = 'http://torrentsmd.com/popup/proxy/'; // html5 functioneaza fara asta, pentru IE trebuie
  786.             var defaultTop  = 25;
  787.             var popupHeight = 150;
  788.             var popupWidth  = 390;
  789.  
  790.             var getPopupTop = function(){
  791.                 var topExtra = $textarea.offset().top - $(window).scrollTop() + popupHeight;
  792.                 if (topExtra > 0 && topExtra < $(window).height() && topExtra > popupHeight) {
  793.                     return defaultTop + topExtra - popupHeight;
  794.                 }
  795.                 return defaultTop;
  796.             };
  797.  
  798.             if (staticMdPopups[id]) {
  799.                 staticMdPopups[id].getPopupElement().css({
  800.                     top: getPopupTop()+'px',
  801.                     left: parseInt($(window).width() / 2 - popupWidth / 2)+'px'
  802.                 })
  803.             } else {
  804.                 staticMdPopups[id] = new StaticMdPopup({
  805.                     textareaElement: $textarea,
  806.                     proxyUrl: proxyUrl,
  807.                     callbacks: {
  808.                         changePopupHtml: function(html) {
  809.                             var left = parseInt($(window).width() / 2 - popupWidth / 2);
  810.  
  811.                             html =
  812.                                 '<div class="static-md-popup" style="top: '+ defaultTop +'px; left: '+ left +'px;">\
  813.                                    <div class="handle" title="Mișcă popup-ul">\
  814.                                        <a href="#" class="close" title="Închide" onclick="return false;"></a>\
  815.                                        <div class="handle-cover" style="display: none;"></div>\
  816.                                        <div class="static-md-popup-iframe">{iframe}</div>\
  817.                                    </div>\
  818.                                </div>';
  819.                             return html;
  820.                         },
  821.                         openPopup: function(instance) {
  822.                             var el = instance.getPopupElement();
  823.  
  824.                             // prepare close button
  825.                             $('.close:first', el).on('click', function(e){
  826.                                 e.preventDefault();
  827.                                 instance.close();
  828.                             });
  829.                             // fix top position
  830.                             el.css('top', getPopupTop()+'px');
  831.  
  832.                             $(document.body).prepend(el);
  833.  
  834.                             el.draggable({
  835.                                 start: function(event, ui) {
  836.                                     $('.handle-cover', ui.helper).show();
  837.                                 },
  838.                                 stop: function(event, ui) {
  839.                                     $('.handle-cover', ui.helper).hide();
  840.                                 }
  841.                             });
  842.                         },
  843.                         closePopup: function(instance) {
  844.                             instance.getPopupElement().remove();
  845.                             try {
  846.                                 delete staticMdPopups[id];
  847.                             } catch (e) {};
  848.                             staticMdPopups[id] = undefined;
  849.                         },
  850.                         changeImageLink: function(link) {
  851.                             return '[img]{link}[/img]'.split('{link}').join(link);
  852.                         }
  853.                     }
  854.                 });
  855.                 staticMdPopups[id].open();
  856.             }
  857.         }
  858.     }
  859. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement