openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

trumbowyg.fontfamily.js (2702B)


      1 (function ($) {
      2     'use strict';
      3 
      4     $.extend(true, $.trumbowyg, {
      5         langs: {
      6             // jshint camelcase:false
      7             en: {
      8                 fontFamily: 'Font'
      9             },
     10             fr: {
     11                 fontFamily: 'Police'
     12             },
     13             nl: {
     14                 fontFamily: 'Lettertype'
     15             },
     16             tr: {
     17                 fontFamily: 'Yazı Tipi'
     18             }
     19         }
     20     });
     21     // jshint camelcase:true
     22 
     23     var defaultOptions = {
     24         fontList: [
     25             {name: 'Arial', family: 'Arial, Helvetica, sans-serif'},
     26             {name: 'Arial Black', family: '\'Arial Black\', Gadget, sans-serif'},
     27             {name: 'Comic Sans', family: '\'Comic Sans MS\', Textile, cursive, sans-serif'},
     28             {name: 'Courier New', family: '\'Courier New\', Courier, monospace'},
     29             {name: 'Georgia', family: 'Georgia, serif'},
     30             {name: 'Impact', family: 'Impact, Charcoal, sans-serif'},
     31             {name: 'Lucida Console', family: '\'Lucida Console\', Monaco, monospace'},
     32             {name: 'Lucida Sans', family: '\'Lucida Sans Uncide\', \'Lucida Grande\', sans-serif'},
     33             {name: 'Palatino', family: '\'Palatino Linotype\', \'Book Antiqua\', Palatino, serif'},
     34             {name: 'Tahoma', family: 'Tahoma, Geneva, sans-serif'},
     35             {name: 'Times New Roman', family: '\'Times New Roman\', Times, serif'},
     36             {name: 'Trebuchet', family: '\'Trebuchet MS\', Helvetica, sans-serif'},
     37             {name: 'Verdana', family: 'Verdana, Geneva, sans-serif'}
     38         ]
     39     };
     40 
     41     // Add dropdown with web safe fonts
     42     $.extend(true, $.trumbowyg, {
     43         plugins: {
     44             fontfamily: {
     45                 init: function (trumbowyg) {
     46                     trumbowyg.o.plugins.fontfamily = trumbowyg.o.plugins.fontfamily || defaultOptions;
     47                     trumbowyg.addBtnDef('fontfamily', {
     48                         dropdown: buildDropdown(trumbowyg),
     49                         hasIcon: false,
     50                         text: trumbowyg.lang.fontFamily
     51                     });
     52                 }
     53             }
     54         }
     55     });
     56 
     57     function buildDropdown(trumbowyg) {
     58         var dropdown = [];
     59 
     60         $.each(trumbowyg.o.plugins.fontfamily.fontList, function (index, font) {
     61             trumbowyg.addBtnDef('fontfamily_' + index, {
     62                 title: '<span style="font-family: ' + font.family + ';">' + font.name + '</span>',
     63                 hasIcon: false,
     64                 fn: function () {
     65                     trumbowyg.execCmd('fontName', font.family, true);
     66                 }
     67             });
     68             dropdown.push('fontfamily_' + index);
     69         });
     70 
     71         return dropdown;
     72     }
     73 })(jQuery);