1 /** 2 * Add toolbar item for block plugin 3 * @author Myron Turner <turnermm02@shaw.ca> 4 */ 5 6 if(toolbar){ 7 var url = encodeURI('lib/plugins/block/exe/block.php?'); 8 toolbar[toolbar.length] = {"type":"mediapopup", "title":"block utility", "key":"", 9 "icon": "../../plugins/block/images/block.png", 10 "url": url, 11 'name': 'block', 12 'options': 'width=700,height=620,left=25,top=25,scrollbars=yes,resizable=yes' 13 }; 14 } 15 16var saveSelectionObj; 17var wikiTextArea; 18var pluginDisplayDiv; 19 20function initialize(dispDivId) { 21 22 pluginDisplayDiv = dispDivId; 23 wikiTextArea = document.getElementById('wiki__text'); 24 return wikiTextArea; 25} 26 27function setIdObj(id,w) { 28 return w.document.getElementById(id); 29} 30 31function show_text_entry(el) { 32 33 if(typeof window.getSelection != 'undefined' && typeof window.getSelection.getText !='undefined') { 34 saveSelectionObj = getSelection(wikiTextArea); 35 } 36 else saveSelectionObj = DWgetSelection(wikiTextArea); 37 var text = saveSelectionObj.getText(); 38 if(text) { 39 el.innerHTML=text; 40 41 } 42 43 return saveSelectionObj; 44} 45 46function createBlock(styles) { 47 if(jQuery) { 48 insertTags('wiki__text','<block ' + styles + '>', '</block>', 'abc') ; 49 } 50 else { 51 insertTags(wikiTextArea,'<block ' + styles + '>', '</block>', 'abc') ; 52 } 53} 54 55function getfnarray() { 56 var FontNamesArray = Array( 57'Arial', 58'Arial Black', 59'Arial Narrow', 60'Arial Rounded MT Bold', 61'Baskerville', 62'Baskerville Old Face', 63'Bauhaus 93', 64'Comic Sans MS', 65'Copperplate', 66'Copperplate Gothic Bold', 67'Courier', 68'Courier New', 69'Futura', 70'Futura Md BT', 71'Georgia', 72'Garamond', 73'Helvetica', 74'Impact', 75'Sans-serif', 76'Microsoft Sans Serif', 77'Serif', 78'Palatino', 79'Palatino Linotype', 80'Papyrus', 81'Tahoma', 82'Times New Roman', 83'Trebuchet MS', 84'Verdana' 85); 86 87 return FontNamesArray; 88} 89 var Block_plugin_options; 90 var getBlockOptions = function() { 91 jQuery.ajax( 92 DOKU_BASE + 'lib/exe/ajax.php', 93 { 94 data: 95 { 96 call: 'block__opts' 97 }, 98 type: "POST", 99 async: true, 100 dataType: 'json', 101 success: function(data, textStatus, jqXHR) 102 { 103 Block_plugin_options = data; 104 }, 105 error: function(jqXHR, textStatus, errorThrown ) 106 { 107 console.log(textStatus); 108 console.log(errorThrown); 109 } 110 } 111 ); 112 }; 113 114 115jQuery(document).ready(function() { 116 117 if(JSINFO['block'] && JSINFO['act']) { 118 getBlockOptions(); 119 } 120}); 121 122function block_supports_canvas() { 123 return !!document.createElement('canvas').getContext; 124} 125function doesFontExist(fontName) { 126 // creating our in-memory Canvas element where the magic happens 127 var canvas = document.createElement("canvas"); 128 var context = canvas.getContext("2d"); 129 130 // the text whose final pixel size I want to measure 131 var text = "abcdefghijklmnopqrstuvwxyz0123456789"; 132 133 // specifying the baseline font 134 context.font = "72px monospace"; 135 136 // checking the size of the baseline text 137 var baselineSize = context.measureText(text).width; 138 139 // specifying the font whose existence we want to check 140 context.font = "72px '" + fontName + "', monospace"; 141 142 // checking the size of the font we want to check 143 var newSize = context.measureText(text).width; 144 145 // removing the Canvas element we created 146 delete canvas; 147 148 // 149 // If the size of the two text instances is the same, the font does not exist because it is being rendered 150 // using the default sans-serif font 151 // 152 if (newSize == baselineSize) { 153 return false; 154 } else { 155 return true; 156 } 157} 158 159function getJQy() { 160 return jQuery; 161}