Code Duplication    Length = 202-202 lines in 2 locations

public/js/tinymce/themes/inlite/theme.js 1 location

@@ 7498-7699 (lines=202) @@
7495
      });
7496
      return count;
7497
    };
7498
    var createFormatMenu = function (editor) {
7499
      var count = 0;
7500
      var newFormats = [];
7501
      var defaultStyleFormats = [
7502
        {
7503
          title: 'Headings',
7504
          items: [
7505
            {
7506
              title: 'Heading 1',
7507
              format: 'h1'
7508
            },
7509
            {
7510
              title: 'Heading 2',
7511
              format: 'h2'
7512
            },
7513
            {
7514
              title: 'Heading 3',
7515
              format: 'h3'
7516
            },
7517
            {
7518
              title: 'Heading 4',
7519
              format: 'h4'
7520
            },
7521
            {
7522
              title: 'Heading 5',
7523
              format: 'h5'
7524
            },
7525
            {
7526
              title: 'Heading 6',
7527
              format: 'h6'
7528
            }
7529
          ]
7530
        },
7531
        {
7532
          title: 'Inline',
7533
          items: [
7534
            {
7535
              title: 'Bold',
7536
              icon: 'bold',
7537
              format: 'bold'
7538
            },
7539
            {
7540
              title: 'Italic',
7541
              icon: 'italic',
7542
              format: 'italic'
7543
            },
7544
            {
7545
              title: 'Underline',
7546
              icon: 'underline',
7547
              format: 'underline'
7548
            },
7549
            {
7550
              title: 'Strikethrough',
7551
              icon: 'strikethrough',
7552
              format: 'strikethrough'
7553
            },
7554
            {
7555
              title: 'Superscript',
7556
              icon: 'superscript',
7557
              format: 'superscript'
7558
            },
7559
            {
7560
              title: 'Subscript',
7561
              icon: 'subscript',
7562
              format: 'subscript'
7563
            },
7564
            {
7565
              title: 'Code',
7566
              icon: 'code',
7567
              format: 'code'
7568
            }
7569
          ]
7570
        },
7571
        {
7572
          title: 'Blocks',
7573
          items: [
7574
            {
7575
              title: 'Paragraph',
7576
              format: 'p'
7577
            },
7578
            {
7579
              title: 'Blockquote',
7580
              format: 'blockquote'
7581
            },
7582
            {
7583
              title: 'Div',
7584
              format: 'div'
7585
            },
7586
            {
7587
              title: 'Pre',
7588
              format: 'pre'
7589
            }
7590
          ]
7591
        },
7592
        {
7593
          title: 'Alignment',
7594
          items: [
7595
            {
7596
              title: 'Left',
7597
              icon: 'alignleft',
7598
              format: 'alignleft'
7599
            },
7600
            {
7601
              title: 'Center',
7602
              icon: 'aligncenter',
7603
              format: 'aligncenter'
7604
            },
7605
            {
7606
              title: 'Right',
7607
              icon: 'alignright',
7608
              format: 'alignright'
7609
            },
7610
            {
7611
              title: 'Justify',
7612
              icon: 'alignjustify',
7613
              format: 'alignjustify'
7614
            }
7615
          ]
7616
        }
7617
      ];
7618
      var createMenu = function (formats) {
7619
        var menu = [];
7620
        if (!formats) {
7621
          return;
7622
        }
7623
        global$4.each(formats, function (format) {
7624
          var menuItem = {
7625
            text: format.title,
7626
            icon: format.icon
7627
          };
7628
          if (format.items) {
7629
            menuItem.menu = createMenu(format.items);
7630
          } else {
7631
            var formatName = format.format || 'custom' + count++;
7632
            if (!format.format) {
7633
              format.name = formatName;
7634
              newFormats.push(format);
7635
            }
7636
            menuItem.format = formatName;
7637
            menuItem.cmd = format.cmd;
7638
          }
7639
          menu.push(menuItem);
7640
        });
7641
        return menu;
7642
      };
7643
      var createStylesMenu = function () {
7644
        var menu;
7645
        if (editor.settings.style_formats_merge) {
7646
          if (editor.settings.style_formats) {
7647
            menu = createMenu(defaultStyleFormats.concat(editor.settings.style_formats));
7648
          } else {
7649
            menu = createMenu(defaultStyleFormats);
7650
          }
7651
        } else {
7652
          menu = createMenu(editor.settings.style_formats || defaultStyleFormats);
7653
        }
7654
        return menu;
7655
      };
7656
      editor.on('init', function () {
7657
        global$4.each(newFormats, function (format) {
7658
          editor.formatter.register(format.name, format);
7659
        });
7660
      });
7661
      return {
7662
        type: 'menu',
7663
        items: createStylesMenu(),
7664
        onPostRender: function (e) {
7665
          editor.fire('renderFormatsMenu', { control: e.control });
7666
        },
7667
        itemDefaults: {
7668
          preview: true,
7669
          textStyle: function () {
7670
            if (this.settings.format) {
7671
              return editor.formatter.getCssText(this.settings.format);
7672
            }
7673
          },
7674
          onPostRender: function () {
7675
            var self = this;
7676
            self.parent().on('show', function () {
7677
              var formatName, command;
7678
              formatName = self.settings.format;
7679
              if (formatName) {
7680
                self.disabled(!editor.formatter.canApply(formatName));
7681
                self.active(editor.formatter.match(formatName));
7682
              }
7683
              command = self.settings.cmd;
7684
              if (command) {
7685
                self.active(editor.queryCommandState(command));
7686
              }
7687
            });
7688
          },
7689
          onclick: function () {
7690
            if (this.settings.format) {
7691
              toggleFormat(editor, this.settings.format)();
7692
            }
7693
            if (this.settings.cmd) {
7694
              editor.execCommand(this.settings.cmd);
7695
            }
7696
          }
7697
        }
7698
      };
7699
    };
7700
    var registerMenuItems = function (editor, formatMenu) {
7701
      editor.addMenuItem('formats', {
7702
        text: 'Formats',

public/js/tinymce/themes/modern/theme.js 1 location

@@ 7340-7541 (lines=202) @@
7337
      });
7338
      return count;
7339
    };
7340
    var createFormatMenu = function (editor) {
7341
      var count = 0;
7342
      var newFormats = [];
7343
      var defaultStyleFormats = [
7344
        {
7345
          title: 'Headings',
7346
          items: [
7347
            {
7348
              title: 'Heading 1',
7349
              format: 'h1'
7350
            },
7351
            {
7352
              title: 'Heading 2',
7353
              format: 'h2'
7354
            },
7355
            {
7356
              title: 'Heading 3',
7357
              format: 'h3'
7358
            },
7359
            {
7360
              title: 'Heading 4',
7361
              format: 'h4'
7362
            },
7363
            {
7364
              title: 'Heading 5',
7365
              format: 'h5'
7366
            },
7367
            {
7368
              title: 'Heading 6',
7369
              format: 'h6'
7370
            }
7371
          ]
7372
        },
7373
        {
7374
          title: 'Inline',
7375
          items: [
7376
            {
7377
              title: 'Bold',
7378
              icon: 'bold',
7379
              format: 'bold'
7380
            },
7381
            {
7382
              title: 'Italic',
7383
              icon: 'italic',
7384
              format: 'italic'
7385
            },
7386
            {
7387
              title: 'Underline',
7388
              icon: 'underline',
7389
              format: 'underline'
7390
            },
7391
            {
7392
              title: 'Strikethrough',
7393
              icon: 'strikethrough',
7394
              format: 'strikethrough'
7395
            },
7396
            {
7397
              title: 'Superscript',
7398
              icon: 'superscript',
7399
              format: 'superscript'
7400
            },
7401
            {
7402
              title: 'Subscript',
7403
              icon: 'subscript',
7404
              format: 'subscript'
7405
            },
7406
            {
7407
              title: 'Code',
7408
              icon: 'code',
7409
              format: 'code'
7410
            }
7411
          ]
7412
        },
7413
        {
7414
          title: 'Blocks',
7415
          items: [
7416
            {
7417
              title: 'Paragraph',
7418
              format: 'p'
7419
            },
7420
            {
7421
              title: 'Blockquote',
7422
              format: 'blockquote'
7423
            },
7424
            {
7425
              title: 'Div',
7426
              format: 'div'
7427
            },
7428
            {
7429
              title: 'Pre',
7430
              format: 'pre'
7431
            }
7432
          ]
7433
        },
7434
        {
7435
          title: 'Alignment',
7436
          items: [
7437
            {
7438
              title: 'Left',
7439
              icon: 'alignleft',
7440
              format: 'alignleft'
7441
            },
7442
            {
7443
              title: 'Center',
7444
              icon: 'aligncenter',
7445
              format: 'aligncenter'
7446
            },
7447
            {
7448
              title: 'Right',
7449
              icon: 'alignright',
7450
              format: 'alignright'
7451
            },
7452
            {
7453
              title: 'Justify',
7454
              icon: 'alignjustify',
7455
              format: 'alignjustify'
7456
            }
7457
          ]
7458
        }
7459
      ];
7460
      var createMenu = function (formats) {
7461
        var menu = [];
7462
        if (!formats) {
7463
          return;
7464
        }
7465
        global$2.each(formats, function (format) {
7466
          var menuItem = {
7467
            text: format.title,
7468
            icon: format.icon
7469
          };
7470
          if (format.items) {
7471
            menuItem.menu = createMenu(format.items);
7472
          } else {
7473
            var formatName = format.format || 'custom' + count++;
7474
            if (!format.format) {
7475
              format.name = formatName;
7476
              newFormats.push(format);
7477
            }
7478
            menuItem.format = formatName;
7479
            menuItem.cmd = format.cmd;
7480
          }
7481
          menu.push(menuItem);
7482
        });
7483
        return menu;
7484
      };
7485
      var createStylesMenu = function () {
7486
        var menu;
7487
        if (editor.settings.style_formats_merge) {
7488
          if (editor.settings.style_formats) {
7489
            menu = createMenu(defaultStyleFormats.concat(editor.settings.style_formats));
7490
          } else {
7491
            menu = createMenu(defaultStyleFormats);
7492
          }
7493
        } else {
7494
          menu = createMenu(editor.settings.style_formats || defaultStyleFormats);
7495
        }
7496
        return menu;
7497
      };
7498
      editor.on('init', function () {
7499
        global$2.each(newFormats, function (format) {
7500
          editor.formatter.register(format.name, format);
7501
        });
7502
      });
7503
      return {
7504
        type: 'menu',
7505
        items: createStylesMenu(),
7506
        onPostRender: function (e) {
7507
          editor.fire('renderFormatsMenu', { control: e.control });
7508
        },
7509
        itemDefaults: {
7510
          preview: true,
7511
          textStyle: function () {
7512
            if (this.settings.format) {
7513
              return editor.formatter.getCssText(this.settings.format);
7514
            }
7515
          },
7516
          onPostRender: function () {
7517
            var self = this;
7518
            self.parent().on('show', function () {
7519
              var formatName, command;
7520
              formatName = self.settings.format;
7521
              if (formatName) {
7522
                self.disabled(!editor.formatter.canApply(formatName));
7523
                self.active(editor.formatter.match(formatName));
7524
              }
7525
              command = self.settings.cmd;
7526
              if (command) {
7527
                self.active(editor.queryCommandState(command));
7528
              }
7529
            });
7530
          },
7531
          onclick: function () {
7532
            if (this.settings.format) {
7533
              toggleFormat(editor, this.settings.format)();
7534
            }
7535
            if (this.settings.cmd) {
7536
              editor.execCommand(this.settings.cmd);
7537
            }
7538
          }
7539
        }
7540
      };
7541
    };
7542
    var registerMenuItems = function (editor, formatMenu) {
7543
      editor.addMenuItem('formats', {
7544
        text: 'Formats',