📄 fullpage.js
字号:
//var defaultDocTypes = 'XHTML 1.0 Transitional=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">,' + 'XHTML 1.0 Frameset=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">,' + 'XHTML 1.0 Strict=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">,' + 'XHTML 1.1=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">,' + 'HTML 4.01 Transitional=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">,' + 'HTML 4.01 Strict=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">,' + 'HTML 4.01 Frameset=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';var defaultEncodings = 'Western european (iso-8859-1)=iso-8859-1,' + 'Central European (iso-8859-2)=iso-8859-2,' + 'Unicode (UTF-8)=utf-8,' + 'Chinese traditional (Big5)=big5,' + 'Cyrillic (iso-8859-5)=iso-8859-5,' + 'Japanese (iso-2022-jp)=iso-2022-jp,' + 'Greek (iso-8859-7)=iso-8859-7,' + 'Korean (iso-2022-kr)=iso-2022-kr,' + 'ASCII (us-ascii)=us-ascii';var defaultMediaTypes = 'all=all,' + 'screen=screen,' + 'print=print,' + 'tty=tty,' + 'tv=tv,' + 'projection=projection,' + 'handheld=handheld,' + 'braille=braille,' + 'aural=aural';var defaultFontNames = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';var defaultFontSizes = '10px,11px,12px,13px,14px,15px,16px';var addMenuLayer = new MCLayer("addmenu");var lastElementType = null;var topDoc;function init() { var f = document.forms['fullpage']; var i, p, doctypes, encodings, mediaTypes, fonts; var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); // Setup doctype select box doctypes = tinyMCE.getParam("fullpage_doctypes", defaultDocTypes).split(','); for (i=0; i<doctypes.length; i++) { p = doctypes[i].split('='); if (p.length > 1) addSelectValue(f, 'doctypes', p[0], p[1]); } // Setup fonts select box fonts = tinyMCE.getParam("fullpage_fonts", defaultFontNames).split(';'); for (i=0; i<fonts.length; i++) { p = fonts[i].split('='); if (p.length > 1) addSelectValue(f, 'fontface', p[0], p[1]); } // Setup fontsize select box fonts = tinyMCE.getParam("fullpage_fontsizes", defaultFontSizes).split(','); for (i=0; i<fonts.length; i++) addSelectValue(f, 'fontsize', fonts[i], fonts[i]); // Setup mediatype select boxs mediaTypes = tinyMCE.getParam("fullpage_media_types", defaultMediaTypes).split(','); for (i=0; i<mediaTypes.length; i++) { p = mediaTypes[i].split('='); if (p.length > 1) { addSelectValue(f, 'element_style_media', p[0], p[1]); addSelectValue(f, 'element_link_media', p[0], p[1]); } } // Setup encodings select box encodings = tinyMCE.getParam("fullpage_encodings", defaultEncodings).split(','); for (i=0; i<encodings.length; i++) { p = encodings[i].split('='); if (p.length > 1) { addSelectValue(f, 'docencoding', p[0], p[1]); addSelectValue(f, 'element_script_charset', p[0], p[1]); addSelectValue(f, 'element_link_charset', p[0], p[1]); } } document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); document.getElementById('link_color_pickcontainer').innerHTML = getColorPickerHTML('link_color_pick','link_color'); //document.getElementById('hover_color_pickcontainer').innerHTML = getColorPickerHTML('hover_color_pick','hover_color'); document.getElementById('visited_color_pickcontainer').innerHTML = getColorPickerHTML('visited_color_pick','visited_color'); document.getElementById('active_color_pickcontainer').innerHTML = getColorPickerHTML('active_color_pick','active_color'); document.getElementById('textcolor_pickcontainer').innerHTML = getColorPickerHTML('textcolor_pick','textcolor'); document.getElementById('stylesheet_browsercontainer').innerHTML = getBrowserHTML('stylesheetbrowser','stylesheet','file','fullpage'); document.getElementById('link_href_pickcontainer').innerHTML = getBrowserHTML('link_href_browser','element_link_href','file','fullpage'); document.getElementById('script_src_pickcontainer').innerHTML = getBrowserHTML('script_src_browser','element_script_src','file','fullpage'); document.getElementById('bgimage_pickcontainer').innerHTML = getBrowserHTML('bgimage_browser','bgimage','image','fullpage'); // Resize some elements if (isVisible('stylesheetbrowser')) document.getElementById('stylesheet').style.width = '220px'; if (isVisible('link_href_browser')) document.getElementById('element_link_href').style.width = '230px'; if (isVisible('bgimage_browser')) document.getElementById('bgimage').style.width = '210px'; // Create iframe var iframe = document.createElement('iframe'); iframe.id = 'tempFrame'; iframe.style.display = 'none'; iframe.src = tinyMCE.baseURL + "/plugins/fullpage/blank.htm"; document.body.appendChild(iframe); tinyMCEPopup.resizeToInnerSize();}function setupIframe(doc) { var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); var hc = inst.fullpageTopContent; var f = document.forms[0]; var xmlVer, xmlEnc, docType; var nodes, i, x, name, value, tmp, l; // Keep it from not loading/executing stuff hc = hc.replace(/<script>/gi, '<script type="text/javascript">'); hc = hc.replace(/\ssrc=/gi, " mce_src="); hc = hc.replace(/\shref=/gi, " mce_href="); hc = hc.replace(/\stype=/gi, " mce_type="); hc = hc.replace(/<script/gi, '<script type="text/unknown" '); // Add end to make it DOM parseable hc += '</body></html>'; topDoc = doc; doc.open(); doc.write(hc); doc.close(); // ------- Setup options for genral tab // Parse xml and doctype xmlVer = getReItem(/<\?\s*?xml.*?version\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1); xmlEnc = getReItem(/<\?\s*?xml.*?encoding\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1); docType = getReItem(/<\!DOCTYPE.*?>/gi, hc, 0); f.langcode.value = getReItem(/lang="(.*?)"/gi, hc, 1); // Get title f.metatitle.value = tinyMCE.entityDecode(getReItem(/<title>(.*?)<\/title>/gi, hc, 1)); // Check for meta encoding nodes = doc.getElementsByTagName("meta"); for (i=0; i<nodes.length; i++) { name = tinyMCE.getAttrib(nodes[i], 'name'); value = tinyMCE.getAttrib(nodes[i], 'content'); httpEquiv = tinyMCE.getAttrib(nodes[i], 'httpEquiv'); switch (name.toLowerCase()) { case "keywords": f.metakeywords.value = value; break; case "description": f.metadescription.value = value; break; case "author": f.metaauthor.value = value; break; case "copyright": f.metacopyright.value = value; break; case "robots": selectByValue(f, 'metarobots', value, true, true); break; } switch (httpEquiv.toLowerCase()) { case "content-type": tmp = getReItem(/charset\s*=\s*(.*)\s*/gi, value, 1); // Override XML encoding if (tmp != "") xmlEnc = tmp; break; } } selectByValue(f, 'doctypes', docType, true, true); selectByValue(f, 'docencoding', xmlEnc, true, true); selectByValue(f, 'langdir', tinyMCE.getAttrib(doc.body, 'dir'), true, true); if (xmlVer != '') f.xml_pi.checked = true; // ------- Setup options for appearance tab // Get primary stylesheet nodes = doc.getElementsByTagName("link"); for (i=0; i<nodes.length; i++) { l = nodes[i]; tmp = tinyMCE.getAttrib(l, 'media'); if (tinyMCE.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(l, 'rel') == "stylesheet") { f.stylesheet.value = tinyMCE.getAttrib(l, 'mce_href'); break; } } // Get from style elements nodes = doc.getElementsByTagName("style"); for (i=0; i<nodes.length; i++) { tmp = parseStyleElement(nodes[i]); for (x=0; x<tmp.length; x++) { // if (tmp[x].rule.indexOf('a:hover') != -1 && tmp[x].data['color']) // f.hover_color.value = tmp[x].data['color']; if (tmp[x].rule.indexOf('a:visited') != -1 && tmp[x].data['color']) f.visited_color.value = tmp[x].data['color']; if (tmp[x].rule.indexOf('a:link') != -1 && tmp[x].data['color']) f.link_color.value = tmp[x].data['color']; if (tmp[x].rule.indexOf('a:active') != -1 && tmp[x].data['color']) f.active_color.value = tmp[x].data['color']; } } // Get from body attribs/* f.leftmargin.value = tinyMCE.getAttrib(doc.body, "leftmargin"); f.rightmargin.value = tinyMCE.getAttrib(doc.body, "rightmargin"); f.topmargin.value = tinyMCE.getAttrib(doc.body, "topmargin"); f.bottommargin.value = tinyMCE.getAttrib(doc.body, "bottommargin");*/ f.textcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "text")); f.active_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "alink")); f.link_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "link")); f.visited_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "vlink")); f.bgcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "bgcolor")); f.bgimage.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "background")); // Get from style info var style = tinyMCE.parseStyle(tinyMCE.getAttrib(doc.body, 'style')); if (style['font-family']) selectByValue(f, 'fontface', style['font-family'], true, true); else selectByValue(f, 'fontface', tinyMCE.getParam("fullpage_default_fontface", ""), true, true); if (style['font-size']) selectByValue(f, 'fontsize', style['font-size'], true, true); else selectByValue(f, 'fontsize', tinyMCE.getParam("fullpage_default_fontsize", ""), true, true); if (style['color']) f.textcolor.value = convertRGBToHex(style['color']); if (style['background-image']) f.bgimage.value = style['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1"); if (style['background-color']) f.bgcolor.value = convertRGBToHex(style['background-color']); if (style['margin']) { tmp = style['margin'].replace(/[^0-9 ]/g, ''); tmp = tmp.split(/ +/); f.topmargin.value = tmp.length > 0 ? tmp[0] : ''; f.rightmargin.value = tmp.length > 1 ? tmp[1] : tmp[0]; f.bottommargin.value = tmp.length > 2 ? tmp[2] : tmp[0]; f.leftmargin.value = tmp.length > 3 ? tmp[3] : tmp[0]; } if (style['margin-left']) f.leftmargin.value = style['margin-left'].replace(/[^0-9]/g, ''); if (style['margin-right']) f.rightmargin.value = style['margin-right'].replace(/[^0-9]/g, ''); if (style['margin-top'])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -