Class: WirisPlugin::EditorImpl
- Inherits:
-
Object
- Object
- WirisPlugin::EditorImpl
- Extended by:
- EditorInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/EditorImpl.rb
Instance Attribute Summary collapse
-
#plugin ⇒ Object
Returns the value of attribute plugin.
Instance Method Summary collapse
- #addLine(output, s) ⇒ Object
- #editor(language, provider) ⇒ Object
-
#initialize(plugin) ⇒ EditorImpl
constructor
A new instance of EditorImpl.
Methods included from EditorInterface
Constructor Details
#initialize(plugin) ⇒ EditorImpl
Returns a new instance of EditorImpl.
12 13 14 15 |
# File 'lib/com/wiris/plugin/impl/EditorImpl.rb', line 12 def initialize(plugin) super() self.plugin = plugin end |
Instance Attribute Details
#plugin ⇒ Object
Returns the value of attribute plugin.
11 12 13 |
# File 'lib/com/wiris/plugin/impl/EditorImpl.rb', line 11 def plugin @plugin end |
Instance Method Details
#addLine(output, s) ⇒ Object
82 83 84 85 |
# File 'lib/com/wiris/plugin/impl/EditorImpl.rb', line 82 def addLine(output, s) output::add(s) output::add("\r\n") end |
#editor(language, provider) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/com/wiris/plugin/impl/EditorImpl.rb', line 16 def editor(language, provider) output = StringBuf.new() if (language == nil) || (language::length() == 0) language = "en" end language = language::toLowerCase() StringTools::replace(language,"-","_") store = Storage::newResourceStorage(("lang/" + language) + "/strings.js") if !store::exists() store = Storage::newResourceStorage(("lang/" + Std::substr(language,0,2).to_s) + "/strings.js") language = Std::substr(language,0,2) if !store::exists() language = "en" end end attributes = StringBuf.new() attributes::add("") confVal = "" i = 0 config = @plugin::getConfiguration() h = ConfigurationKeys::imageConfigPropertiesInv it = h::keys() while it::hasNext() value = it::next() if config::getProperty(value,nil) != nil if i != 0 attributes::add(",") end i+=1 confVal = config::getProperty(value,nil) StringTools::replace(confVal,"-","_") StringTools::replace(confVal,"-","_") attributes::add("\'") attributes::add(ConfigurationKeys::imageConfigPropertiesInv::get(value)) attributes::add("\' : \'") attributes::add(confVal) attributes::add("\'") end end script = StringBuf.new() if i > 0 script::add("<script type=\"text/javascript\">window.wrs_attributes = {") script::add(attributes) script::add("};</script>") end editorUrl = @plugin::getImageServiceURL("editor",false) isSegure = (provider::getParameter("secure","false") == "true") if editorUrl::startsWith("http:") && isSegure editorUrl = "https:" + Std::substr(editorUrl,5).to_s end addLine(output,"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">") addLine(output,"<html><head>") addLine(output,"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>") addLine(output,script::toString()) addLine(output,((("<script type=\"text/javascript\" src=\"" + editorUrl) + "?lang=") + StringTools::urlEncode(language).to_s) + "\"></script>") addLine(output,"<script type=\"text/javascript\" src=\"../core/editor.js\"></script>") addLine(output,("<script type=\"text/javascript\" src=\"../lang/" + StringTools::urlEncode(language).to_s) + "/strings.js\"></script>") addLine(output,"<title>MathType</title>") addLine(output,"<style type=\"text/css\">/*<!--*/html, body, #container { height: 100%; } body { margin: 0; }") addLine(output,"#links { text-align: right; margin-right: 20px; } #links_rtl {text-align: left; margin-left: 20px;} #controls { float: left; } #controls_rtl {float: right;}/*-->*/</style>") addLine(output,"</head><body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">") addLine(output,"<div id=\"container\"><div id=\"editorContainer\"></div><div id=\"controls\"></div>") addLine(output,"<div id=\"links\"><a href=\"http://www.wiris.com/editor3/docs/manual/latex-support\" id=\"a_latex\" target=\"_blank\">LaTeX</a> | ") addLine(output,"<a href=\"http://www.wiris.com/editor3/docs/manual\" target=\"_blank\" id=\"a_manual\">Manual</a></div></div></body>") return output::toString() end |