Advertisement
dulieuquocgia

tinymce_358.php

Nov 19th, 2020
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.18 KB | None | 0 0
  1. <script type="text/javascript" src="template/plugins/tinymce/tinymce.min.js"></script>
  2. <script src="template/plugins/fancybox/js/jquery.fancybox.js"></script>
  3. <script src="template/plugins/switchery/switchery.min.js"></script>
  4.     <script type="text/javascript">
  5.         Switchery.init($(".js-switch"), {
  6.           color:"#64bd63",
  7.           secondaryColor:"#dfdfdf",
  8.           jackColor:"#fff",
  9.           size:"small"
  10.         });
  11.        
  12.     </script>
  13.  
  14. <script type="text/javascript">
  15. function ChangeToSlug()
  16.         {
  17.             var title, slug;
  18.          
  19.             //Lấy text từ thẻ input title
  20.             title = document.getElementById("txtTitle").value;
  21.          
  22.             //Đổi chữ hoa thành chữ thường
  23.             slug = title.toLowerCase();
  24.          
  25.             //Đổi ký tự có dấu thành không dấu
  26.             slug = slug.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, 'a');
  27.             slug = slug.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, 'e');
  28.             slug = slug.replace(/i|í|ì|ỉ|ĩ|ị/gi, 'i');
  29.             slug = slug.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, 'o');
  30.             slug = slug.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, 'u');
  31.             slug = slug.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, 'y');
  32.             slug = slug.replace(/đ/gi, 'd');
  33.             //Xóa các ký tự đặt biệt
  34.             slug = slug.replace(/\`|\~|\!|\@|\#|\||\$|\%|\^|\&|\*|\(|\)|\+|\=|\,|\.|\/|\?|\>|\<|\'|\"|\:|\;|_/gi, '');
  35.             //Đổi khoảng trắng thành ký tự gạch ngang
  36.             slug = slug.replace(/ /gi, "-");
  37.             slug = slug.replace(/  /gi, "-");
  38.             slug = slug.replace(/   /gi, "-");
  39.             slug = slug.replace(/    /gi, "-");
  40.             slug = slug.replace(/     /gi, "-");
  41.             slug = slug.replace(/      /gi, "-");
  42.             slug = slug.replace(/       /gi, "-");
  43.             slug = slug.replace(/        /gi, "-");
  44.             slug = slug.replace(/         /gi, "-");
  45.             slug = slug.replace(/          /gi, "-");
  46.             //Đổi nhiều ký tự gạch ngang liên tiếp thành 1 ký tự gạch ngang
  47.             //Phòng trường hợp người nhập vào quá nhiều ký tự trắng
  48.             slug = slug.replace(/\-\-\-\-\-/gi, '-');
  49.             slug = slug.replace(/\-\-\-\-/gi, '-');
  50.             slug = slug.replace(/\-\-\-/gi, '-');
  51.             slug = slug.replace(/\-\-/gi, '-');
  52.             //Xóa các ký tự gạch ngang ở đầu và cuối
  53.             slug = '@' + slug + '@';
  54.             slug = slug.replace(/\@\-|\-\@|\@/gi, '');
  55.             //In slug ra textbox có id “slug”
  56.             document.getElementById('txtSlug').value = slug;
  57.         }
  58. tinymce.init({
  59.     mode : "textareas",
  60.     editor_selector : "wysiwygEditor", // Sử dụng với class
  61.     entity_encoding : "raw", // Thay Ch&agrave;o c&aacute;c bạn = Chào các bạn
  62.     verify_html: false,
  63.     editor_deselector: "simple",
  64.     forced_root_block : "",
  65.     force_br_newlines : false,
  66.     force_p_newlines : true,
  67.     theme: "modern",
  68.     skin: "bootmce",
  69.     elementpath: false,
  70.     height: 300,
  71.     width:800,
  72.     relative_urls : false,
  73.     remove_script_host: false,
  74.     language : 'vi_VN',
  75.     plugins: [
  76.          "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
  77.          "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
  78.          "save table contextmenu directionality emoticons template paste textcolor responsivefilemanager mfnsc",
  79.    ],
  80.    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons | fullscreen code | fontselect",
  81.     external_plugins: { "filemanager" : "<?=CMS_URL?>template/plugins/filemanager/plugin.min.js"},
  82.  
  83.    style_formats: [
  84.       {title: "Headers", items: [
  85.           {title: "Header 1", format: "h1"},
  86.           {title: "Header 2", format: "h2"},
  87.           {title: "Header 3", format: "h3"},
  88.           {title: "Header 4", format: "h4"},
  89.           {title: "Header 5", format: "h5"},
  90.           {title: "Header 6", format: "h6"}
  91.       ]},
  92.       {title: "Inline", items: [
  93.           {title: "Bold", icon: "bold", format: "bold"},
  94.           {title: "Italic", icon: "italic", format: "italic"},
  95.           {title: "Underline", icon: "underline", format: "underline"},
  96.           {title: "Strikethrough", icon: "strikethrough", format: "strikethrough"},
  97.           {title: "Superscript", icon: "superscript", format: "superscript"},
  98.           {title: "Subscript", icon: "subscript", format: "subscript"},
  99.           {title: "Code", icon: "code", format: "code"}
  100.       ]},
  101.       {title: "Blocks", items: [
  102.           {title: "Paragraph", format: "p"},
  103.           {title: "Blockquote", format: "blockquote"},
  104.           {title: "Div", format: "div"},
  105.           {title: "Pre", format: "pre"}
  106.       ]},
  107.       {title: "Alignment", items: [
  108.           {title: "Left", icon: "alignleft", format: "alignleft"},
  109.           {title: "Center", icon: "aligncenter", format: "aligncenter"},
  110.           {title: "Right", icon: "alignright", format: "alignright"},
  111.           {title: "Justify", icon: "alignjustify", format: "alignjustify"}
  112.       ]}
  113.     ],
  114.     external_filemanager_path:"<?=CMS_URL?>template/plugins/filemanager/",
  115.     filemanager_title:"Quản lý tài nguyên - Hãy sắp xếp hình ảnh và tập tin một cách khoa học"
  116.  });
  117. tinymce.init({
  118.     mode : "textareas",
  119.     editor_selector : "description", // Sử dụng với class
  120.     entity_encoding : "raw", // Thay Ch&agrave;o c&aacute;c bạn = Chào các bạn
  121.     verify_html: false,
  122.     editor_deselector: "simple",
  123.     forced_root_block : "",
  124.     force_br_newlines : true,
  125.     force_p_newlines : false,
  126.     theme: "modern",
  127.     skin: "bootmce",
  128.     menubar: false,
  129.     elementpath: false,
  130.     height: 150,
  131.     width:800,
  132.     relative_urls : false,
  133.     remove_script_host: false,
  134.     language : 'vi_VN',
  135.     plugins: [
  136.          "wordcount,charactercount",
  137.          
  138.    ],
  139.    toolbar: "",
  140.    
  141.  
  142.    style_formats: [
  143.       {title: "Headers", items: [
  144.           {title: "Header 1", format: "h1"},
  145.           {title: "Header 2", format: "h2"},
  146.           {title: "Header 3", format: "h3"},
  147.           {title: "Header 4", format: "h4"},
  148.           {title: "Header 5", format: "h5"},
  149.           {title: "Header 6", format: "h6"}
  150.       ]},
  151.       {title: "Inline", items: [
  152.           {title: "Bold", icon: "bold", format: "bold"},
  153.           {title: "Italic", icon: "italic", format: "italic"},
  154.           {title: "Underline", icon: "underline", format: "underline"},
  155.           {title: "Strikethrough", icon: "strikethrough", format: "strikethrough"},
  156.           {title: "Superscript", icon: "superscript", format: "superscript"},
  157.           {title: "Subscript", icon: "subscript", format: "subscript"},
  158.           {title: "Code", icon: "code", format: "code"}
  159.       ]},
  160.       {title: "Blocks", items: [
  161.           {title: "Paragraph", format: "p"},
  162.           {title: "Blockquote", format: "blockquote"},
  163.           {title: "Div", format: "div"},
  164.           {title: "Pre", format: "pre"}
  165.       ]},
  166.       {title: "Alignment", items: [
  167.           {title: "Left", icon: "alignleft", format: "alignleft"},
  168.           {title: "Center", icon: "aligncenter", format: "aligncenter"},
  169.           {title: "Right", icon: "alignright", format: "alignright"},
  170.           {title: "Justify", icon: "alignjustify", format: "alignjustify"}
  171.       ]}
  172.     ],
  173.     external_filemanager_path:"<?=CMS_URL?>template/plugins/filemanager/",
  174.     filemanager_title:"Quản lý tài nguyên - Hãy sắp xếp hình ảnh và tập tin một cách khoa học"
  175.  });
  176. tinymce.PluginManager.add('charactercount', function (editor) {
  177.   var self = this;
  178.  
  179.   function update() {
  180.     editor.theme.panel.find('#charactercount').text(['SỐ KÝ TỰ: {0} ', self.getCount()]);
  181.   }
  182.  
  183.   editor.on('init', function () {
  184.     var statusbar = editor.theme.panel && editor.theme.panel.find('#statusbar')[0];
  185.  
  186.     if (statusbar) {
  187.       window.setTimeout(function () {
  188.         statusbar.insert({
  189.           type: 'label',
  190.           name: 'charactercount',
  191.           text: ['SỐ KÝ TỰ: {0}', self.getCount()],
  192.           classes: 'charactercount',
  193.           disabled: editor.settings.readonly
  194.         }, 0);
  195.  
  196.         editor.on('setcontent beforeaddundo', update);
  197.  
  198.         editor.on('keyup', function (e) {
  199.             update();
  200.         });
  201.       }, 0);
  202.     }
  203.   });
  204.  
  205.   self.getCount = function () {
  206.     var tx = editor.getContent({ format: 'raw' });
  207.     var decoded = decodeHtml(tx);
  208.     var decodedStripped = decoded.replace(/(<([^>]+)>)/ig, "").trim();
  209.     var tc = decodedStripped.length;
  210.     return tc;
  211.   };
  212.  
  213.   function decodeHtml(html) {
  214.     var txt = document.createElement("textarea");
  215.     txt.innerHTML = html;
  216.     return txt.value;
  217.   }
  218. });
  219. function openKCFinder(field_name, url, type, win) {
  220.     tinyMCE.activeEditor.windowManager.open({
  221.         file: 'template/plugins/kcfinder_2.51/browse.php?opener=tinymce&lang=vi&type=' + type,
  222.         title: 'KCFinder',
  223.         width: 700,
  224.         height: 500,
  225.         resizable: "yes",
  226.         inline: true,
  227.         close_previous: "no",
  228.         popup_css: false
  229.     }, {
  230.         window: win,
  231.         input: field_name
  232.     });
  233.     return false;
  234. }
  235. function browseKCFinder(field, type) {
  236.   $('#'+field).next('input').css('display','none');
  237.   $('#'+field).after('<a style="margin-left:10px;" href="template/plugins/filemanager/dialog.php?type=1&field_id='+field+'" class="button btn btn-success iframe-btn" data-toggle="tooltip" data-title="select_image" type="button"><i class="fa fa-folder-open"></i></a>');
  238.  
  239.    
  240.  
  241.     // window.open('template/plugins/filemanager/dialog.php?type=1&field_id='+field);
  242.     // window.KCFinder = {
  243.     //     callBack: function(url) {
  244.     //         document.getElementById(field).value = url;
  245.     //         window.KCFinder = null;
  246.     //     }
  247.     // };
  248.     // window.open('template/plugins/kcfinder_2.51/browse.php?type='+type+'&lang=vi', 'kcfinder_textbox',
  249.     //     'status=0, toolbar=0, location=0, menubar=0, directories=0, ' +
  250.     //     'resizable=1, scrollbars=0, width=800, height=600'
  251.     // );
  252. }
  253. </script>
  254.  
  255. <script>
  256. var text_max = 0;
  257. //$('#count_message3').html(text_max + ' ký tự - [TIP] Description nên để <180 ký tự ');
  258.  
  259. $('#txtMetaDescription').keyup(function() {
  260. var text_length = $('#txtMetaDescription').val().length;
  261. var text_remaining = text_length;
  262.  
  263. $('#count_message3').html(text_remaining + ' ký tự - [TIP] Description nên để <180 ký tự ');
  264. });
  265. </script>
  266. <script>
  267. var text_max = 0;
  268. //$('#count_message2').html(text_max + ' ký tự - [TIP] Title nên để  <70 ký tự ');
  269.  
  270. $('#txtMetaTitle').keyup(function() {
  271. var text_length = $('#txtMetaTitle').val().length;
  272. var text_remaining = text_length;
  273.  
  274. $('#count_message2').html(text_remaining + ' ký tự - [TIP] Title nên để  <70 ký tự ');
  275. });
  276. </script>
  277. <script>
  278. var text_max = 0;
  279. //$('#count_message').html('[TIP] Bạn đã viết ' +text_max + ' ký tự - Tiêu đề nên để <70 ký tự sẽ SEO tốt hơn');
  280.  
  281. $('#txtTitle').keyup(function() {
  282.   var text_length = $('#txtTitle').val().length;
  283.   var text_remaining = text_length;
  284.  
  285.   $('#count_message').html('[TIP] Bạn đã viết ' +text_remaining + ' ký tự - Tiêu đề nên để <70 ký tự sẽ SEO tốt hơn');
  286. });
  287. </script>
  288. <script type="text/javascript">
  289.   $('.iframe-btn').fancybox({
  290.     'width'     : 900,
  291.     'height'    : 900,
  292.     'type'      : 'iframe',
  293.     'autoScale' : true
  294.   });
  295.  
  296.     $('input.iframe-btn').each(function() {
  297.       if($(this).val()) {
  298.         var id = $(this).attr('id');
  299.         $('#' + id + '_preview').css('display', 'block');
  300.         $('#' + id + '_preview img').attr('src', $(this).val());
  301.       }
  302.     });        
  303.  
  304.     $('.delete_media').click(function(e) {
  305.       e.preventDefault();
  306.       var id = $(this).attr('id');
  307.       if($('input#' + id).val()) {  
  308.         var result = confirm("Bạn muốn gỡ bỏ ảnh đại diện này?");
  309.         if (result) {
  310.           $('input#' + id).val('');
  311.           $('#' + id + '_preview img').attr('src', '');
  312.           $('#' + id + '_preview').css('display', 'none');
  313.         }
  314.       }
  315.     });
  316.  
  317.  
  318.   function close_window() {
  319.     parent.$.fancybox.close();
  320.   };
  321.  
  322.   function responsive_filemanager_callback(field_id) {
  323.     var url = $('#' + field_id).val();
  324.     $('#' + field_id + '_preview').css('display', 'block');
  325.     $('#' + field_id + '_preview img').attr('src', url);
  326.   };
  327.   var markup = document.getElementById('cms-form').innerHTML;
  328.   var n = markup.indexOf("Chọn ảnh");
  329.   if(n>0){
  330.     $('#txtImage').next('input').css('display','none');
  331.     $('#txtImage').after('<a style="margin-left:10px;" href="template/plugins/filemanager/dialog.php?type=1&field_id=txtImage" class="button btn btn-success iframe-btn" data-toggle="tooltip" data-title="select_image" type="button"><i class="fa fa-folder-open"></i></a>');
  332.   }
  333. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement