wirispluginengine 3.62.0.1322 → 7.14.0.1422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +34 -34
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
- data/app/controllers/wirispluginengine/application_controller.rb +84 -75
- data/app/helpers/wirispluginengine/application_helper.rb +4 -4
- data/config/routes.rb +4 -4
- data/lib/com/wiris/common/WInteger.rb +52 -51
- data/lib/com/wiris/plugin/api/Cas.rb +5 -5
- data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
- data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
- data/lib/com/wiris/plugin/api/Editor.rb +5 -5
- data/lib/com/wiris/plugin/api/Filter.rb +5 -5
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
- data/lib/com/wiris/plugin/api/Render.rb +5 -5
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
- data/lib/com/wiris/plugin/api/Test.rb +5 -5
- data/lib/com/wiris/plugin/api/TextService.rb +5 -5
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
- data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
- data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
- data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
- data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
- data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
- data/lib/com/wiris/util/json/JSon.rb +505 -493
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
- data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
- data/lib/com/wiris/util/json/StringParser.rb +57 -56
- data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Cache.rb +8 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
- data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
- data/lib/com/wiris/util/sys/IniFile.rb +132 -131
- data/lib/com/wiris/util/sys/Lock.rb +8 -0
- data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Store.rb +126 -101
- data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
- data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
- data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
- data/lib/com/wiris/util/type/Arrays.rb +275 -0
- data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
- data/lib/com/wiris/util/type/Comparator.rb +8 -0
- data/lib/com/wiris/util/type/DataUtils.rb +24 -0
- data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
- data/lib/com/wiris/util/type/HashCache.rb +43 -0
- data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
- data/lib/com/wiris/util/type/Queue.rb +31 -0
- data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
- data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
- data/lib/com/wiris/util/type/SortedHash.rb +45 -0
- data/lib/com/wiris/util/type/Stack.rb +31 -0
- data/lib/com/wiris/util/type/StringUtils.rb +56 -0
- data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
- data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
- data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
- data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
- data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
- data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
- data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
- data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
- data/lib/com/wiris/util/xml/WEntities.rb +11 -9
- data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
- data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
- data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
- data/lib/loader.rb +15 -12
- data/lib/src-generic/Array.rb +22 -22
- data/lib/src-generic/ArrayInt.rb +31 -31
- data/lib/src-generic/Base64.rb +14 -14
- data/lib/src-generic/BaseCode.rb +93 -93
- data/lib/src-generic/Boolean.rb +27 -0
- data/lib/src-generic/Bytes.rb +50 -50
- data/lib/src-generic/BytesInput.rb +37 -37
- data/lib/src-generic/EReg.rb +55 -55
- data/lib/src-generic/File.rb +35 -35
- data/lib/src-generic/FileLock.rb +26 -26
- data/lib/src-generic/FileSystem.rb +37 -37
- data/lib/src-generic/Hash.rb +42 -42
- data/lib/src-generic/Http.rb +111 -107
- data/lib/src-generic/HttpRequest.rb +25 -25
- data/lib/src-generic/HttpResponse.rb +70 -70
- data/lib/src-generic/Iterator.rb +20 -19
- data/lib/src-generic/Math.rb +14 -14
- data/lib/src-generic/Md5.rb +8 -8
- data/lib/src-generic/Md5Tools.rb +11 -11
- data/lib/src-generic/PropertiesTools.rb +32 -32
- data/lib/src-generic/Reflect.rb +16 -16
- data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
- data/lib/src-generic/Serializer.rb +84 -84
- data/lib/src-generic/Std.rb +74 -74
- data/lib/src-generic/Storage.rb +152 -152
- data/lib/src-generic/StringBuf.rb +40 -40
- data/lib/src-generic/StringTools.rb +44 -46
- data/lib/src-generic/Timer.rb +6 -6
- data/lib/src-generic/Type.rb +18 -18
- data/lib/src-generic/TypeTools.rb +31 -31
- data/lib/src-generic/Unserializer.rb +72 -72
- data/lib/src-generic/Utf8.rb +26 -26
- data/lib/src-generic/Xml.rb +199 -198
- data/lib/src-generic/extended/Integer.rb +5 -5
- data/lib/src-generic/extended/Math.rb +6 -6
- data/lib/src-generic/extended/Properties.rb +11 -11
- data/lib/src-generic/extended/String.rb +38 -38
- data/lib/src-generic/settings/PlatformSettings.rb +18 -18
- data/lib/src-generic/system/HttpProxy.rb +23 -0
- data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
- data/lib/wirispluginengine.rb +5 -5
- data/lib/wirispluginengine/engine.rb +5 -5
- data/lib/wirispluginengine/integration/cleancache.rb +8 -8
- data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
- data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
- data/lib/wirispluginengine/integration/createimage.rb +7 -7
- data/lib/wirispluginengine/integration/getmathml.rb +18 -18
- data/lib/wirispluginengine/integration/resource.rb +8 -8
- data/lib/wirispluginengine/integration/service.rb +5 -5
- data/lib/wirispluginengine/integration/showimage.rb +28 -21
- data/lib/wirispluginengine/integration/test.rb +5 -5
- data/lib/wirispluginengine/integration/testfilter.rb +10 -0
- data/lib/wirispluginengine/version.rb +2 -2
- data/resources/VERSION +1 -1
- data/resources/WEB-INF/web.xml +25 -0
- data/resources/WIRISplugins.js +3809 -0
- data/resources/default-configuration.ini +47 -45
- data/resources/tech.txt +1 -1
- data/resources/wirisplugin.css +43 -42
- metadata +40 -4
- data/configuration.ini.dist +0 -104
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de311c541c2c4e60fa7c3d4ac695092abb4c382b
|
4
|
+
data.tar.gz: c5c66b752c2d7d09590e8af29fef5b36ff0ce46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e584e64ed64600143396edadd72d59ab63826f0f3f00f4773c493b32ce909d7df3f3ad47f6af83a976739d181e733be306e3234c225d03129f4d16752610f7a
|
7
|
+
data.tar.gz: 920e9f90663378cd6184942d5091c799d7d457f1724b7d6a635e6557e45b84cfb1d502c97433ed12b7e99d8e6ded96f5f745b019f3d7727dc28f2739fddba031
|
data/Rakefile
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/setup'
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'Wirispluginengine'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
-
load 'rails/tasks/engine.rake'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Bundler::GemHelper.install_tasks
|
23
|
-
|
24
|
-
require 'rake/testtask'
|
25
|
-
|
26
|
-
Rake::TestTask.new(:test) do |t|
|
27
|
-
t.libs << 'lib'
|
28
|
-
t.libs << 'test'
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = false
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
task default: :test
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Wirispluginengine'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -759,6 +759,7 @@ com.wiris.js.JsOSData.prototype = {
|
|
759
759
|
}
|
760
760
|
com.wiris.js.JsBrowser = $hxClasses["com.wiris.js.JsBrowser"] = function() {
|
761
761
|
this.dataBrowser = new Array();
|
762
|
+
this.addBrowser("navigator.userAgent",null,"Edge",null,"Edge");
|
762
763
|
this.addBrowser("navigator.userAgent",null,"Chrome",null,"Chrome");
|
763
764
|
this.addBrowser("navigator.userAgent",null,"OmniWeb",null,"OmniWeb");
|
764
765
|
this.addBrowser("navigator.vendor",null,"Apple","Version","Safari");
|
@@ -769,6 +770,7 @@ com.wiris.js.JsBrowser = $hxClasses["com.wiris.js.JsBrowser"] = function() {
|
|
769
770
|
this.addBrowser("navigator.vendor",null,"Camino",null,"Camino");
|
770
771
|
this.addBrowser("navigator.userAgent",null,"Netscape",null,"Netscape");
|
771
772
|
this.addBrowser("navigator.userAgent",null,"MSIE","MSIE","Explorer");
|
773
|
+
this.addBrowser("navigator.userAgent",null,"Trident","rv","Explorer");
|
772
774
|
this.addBrowser("navigator.userAgent",null,"Gecko","rv","Mozilla");
|
773
775
|
this.addBrowser("navigator.userAgent",null,"Mozilla","Mozilla","Netscape");
|
774
776
|
this.dataOS = new Array();
|
@@ -780,21 +782,34 @@ com.wiris.js.JsBrowser = $hxClasses["com.wiris.js.JsBrowser"] = function() {
|
|
780
782
|
this.addOS("navigator.platform","Linux","Linux");
|
781
783
|
this.setBrowser();
|
782
784
|
this.setOS();
|
785
|
+
this.setTouchable();
|
783
786
|
};
|
784
787
|
com.wiris.js.JsBrowser.__name__ = ["com","wiris","js","JsBrowser"];
|
785
788
|
com.wiris.js.JsBrowser.prototype = {
|
786
|
-
|
789
|
+
isTouchable: function() {
|
790
|
+
return this.touchable;
|
791
|
+
}
|
792
|
+
,isAndroid: function() {
|
787
793
|
return this.os == "Android";
|
788
794
|
}
|
795
|
+
,isMac: function() {
|
796
|
+
return this.os == "Mac";
|
797
|
+
}
|
789
798
|
,isIOS: function() {
|
790
799
|
return this.os == "iOS";
|
791
800
|
}
|
792
801
|
,isFF: function() {
|
793
802
|
return this.browser == "Firefox";
|
794
803
|
}
|
804
|
+
,isSafari: function() {
|
805
|
+
return this.browser == "Safari";
|
806
|
+
}
|
795
807
|
,isChrome: function() {
|
796
808
|
return this.browser == "Chrome";
|
797
809
|
}
|
810
|
+
,isEdge: function() {
|
811
|
+
return this.browser == "Edge";
|
812
|
+
}
|
798
813
|
,isIE: function() {
|
799
814
|
return this.browser == "Explorer";
|
800
815
|
}
|
@@ -813,6 +828,13 @@ com.wiris.js.JsBrowser.prototype = {
|
|
813
828
|
if(index == -1) return null;
|
814
829
|
return "" + Std.parseFloat(HxOverrides.substr(str,index + search.length + 1,null));
|
815
830
|
}
|
831
|
+
,setTouchable: function() {
|
832
|
+
if(this.isIOS() || this.isAndroid()) {
|
833
|
+
this.touchable = true;
|
834
|
+
return;
|
835
|
+
}
|
836
|
+
this.touchable = false;
|
837
|
+
}
|
816
838
|
,setOS: function() {
|
817
839
|
var i = HxOverrides.iter(this.dataOS);
|
818
840
|
while(i.hasNext()) {
|
@@ -858,6 +880,7 @@ com.wiris.js.JsBrowser.prototype = {
|
|
858
880
|
b.identity = identity;
|
859
881
|
this.dataBrowser.push(b);
|
860
882
|
}
|
883
|
+
,touchable: null
|
861
884
|
,os: null
|
862
885
|
,ver: null
|
863
886
|
,browser: null
|
@@ -865,6 +888,13 @@ com.wiris.js.JsBrowser.prototype = {
|
|
865
888
|
,dataBrowser: null
|
866
889
|
,__class__: com.wiris.js.JsBrowser
|
867
890
|
}
|
891
|
+
com.wiris.js.JsPluginListener = $hxClasses["com.wiris.js.JsPluginListener"] = function() { }
|
892
|
+
com.wiris.js.JsPluginListener.__name__ = ["com","wiris","js","JsPluginListener"];
|
893
|
+
com.wiris.js.JsPluginListener.prototype = {
|
894
|
+
afterParseLatex: null
|
895
|
+
,afterParse: null
|
896
|
+
,__class__: com.wiris.js.JsPluginListener
|
897
|
+
}
|
868
898
|
com.wiris.js.JsPluginTools = $hxClasses["com.wiris.js.JsPluginTools"] = function() {
|
869
899
|
this.tryReady();
|
870
900
|
};
|
@@ -908,7 +938,11 @@ com.wiris.js.JsPluginTools.prototype = {
|
|
908
938
|
com.wiris.js.JsPluginViewer = $hxClasses["com.wiris.js.JsPluginViewer"] = function() {
|
909
939
|
this._wrs_conf_imageFormat = null;
|
910
940
|
this.javaServicePath = "/pluginwiris_engine/app";
|
941
|
+
this.wiriseditormathmlattribute = null;
|
911
942
|
this.performanceenabled = null;
|
943
|
+
this.eventListenersArray = [];
|
944
|
+
this.callsShowImageNumber = 0;
|
945
|
+
this.callsLatexToMathml = 0;
|
912
946
|
this.params = new Hash();
|
913
947
|
this.mode = com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE;
|
914
948
|
this.zoom = 1;
|
@@ -940,7 +974,14 @@ com.wiris.js.JsPluginViewer.bypassEncapsulation = function() {
|
|
940
974
|
if(window.com.wiris.js.JsPluginViewer == null) window.com.wiris.js.JsPluginViewer = com.wiris.js.JsPluginViewer.getInstance();
|
941
975
|
}
|
942
976
|
com.wiris.js.JsPluginViewer.prototype = {
|
943
|
-
|
977
|
+
removeViewerListener: function(listener) {
|
978
|
+
while(HxOverrides.remove(this.eventListenersArray,listener)) {
|
979
|
+
}
|
980
|
+
}
|
981
|
+
,addViewerListener: function(listener) {
|
982
|
+
this.eventListenersArray.push(listener);
|
983
|
+
}
|
984
|
+
,getBaseURL: function() {
|
944
985
|
return this.baseURL;
|
945
986
|
}
|
946
987
|
,queryToParams: function(query) {
|
@@ -986,14 +1027,59 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
986
1027
|
data += "&metrics=true¢erbaseline=false&mml=" + StringTools.urlEncode(mml);
|
987
1028
|
data += "&lang=" + this.lang;
|
988
1029
|
if(this.zoom != 1) data += "&zoom=" + this.zoom;
|
989
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber :
|
990
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("POST:" + data,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1030
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber : 842, className : "com.wiris.js.JsPluginViewer", methodName : "callService"});
|
1031
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("POST:" + data,{ fileName : "JsPluginViewer.hx", lineNumber : 844, className : "com.wiris.js.JsPluginViewer", methodName : "callService"});
|
991
1032
|
con.open("POST",url,false);
|
992
1033
|
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
993
1034
|
con.send(data);
|
994
1035
|
return con.responseText;
|
995
1036
|
}
|
996
|
-
,
|
1037
|
+
,latexToMathml: function(latex,nodeAfter,asynchronously,callbackFunc) {
|
1038
|
+
var _g = this;
|
1039
|
+
var con = new js.XMLHttpRequest();
|
1040
|
+
var url = (this.absoluteURL.length > 0?this.absoluteURL:this.baseURL + this.localpath) + "/service" + this.extension;
|
1041
|
+
var data = "service=latex2mathml";
|
1042
|
+
data += "&latex=" + StringTools.urlEncode(latex);
|
1043
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber : 776, className : "com.wiris.js.JsPluginViewer", methodName : "latexToMathml"});
|
1044
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("POST:" + data,{ fileName : "JsPluginViewer.hx", lineNumber : 778, className : "com.wiris.js.JsPluginViewer", methodName : "latexToMathml"});
|
1045
|
+
var onloadFunc = function(e) {
|
1046
|
+
try {
|
1047
|
+
var mathml = haxe.Json.parse(con.responseText).result.text;
|
1048
|
+
var newMathml = js.Lib.document.createElement("math");
|
1049
|
+
var mathmlSpan = js.Lib.document.createElement("span");
|
1050
|
+
mathmlSpan.appendChild(newMathml);
|
1051
|
+
e.target.wiris.nodeAfter.parentElement.insertBefore(mathmlSpan,e.target.wiris.nodeAfter.nextSibling);
|
1052
|
+
newMathml.outerHTML = mathml;
|
1053
|
+
if(--_g.callsLatexToMathml == 0) {
|
1054
|
+
var _g2 = 0, _g1 = _g.eventListenersArray.length;
|
1055
|
+
while(_g2 < _g1) {
|
1056
|
+
var i = _g2++;
|
1057
|
+
try {
|
1058
|
+
_g.eventListenersArray[i].afterParseLatex();
|
1059
|
+
} catch( e1 ) {
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
e.target.wiris.callbackFunc(mathmlSpan);
|
1064
|
+
_g.parseElement(mathmlSpan,asynchronously);
|
1065
|
+
} catch( e1 ) {
|
1066
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("LatexToMathml call failed!",{ fileName : "JsPluginViewer.hx", lineNumber : 804, className : "com.wiris.js.JsPluginViewer", methodName : "latexToMathml"});
|
1067
|
+
}
|
1068
|
+
};
|
1069
|
+
con.open("POST",url,asynchronously);
|
1070
|
+
var newDynamic = { };
|
1071
|
+
con.wiris = newDynamic;
|
1072
|
+
con.wiris.nodeAfter = nodeAfter;
|
1073
|
+
con.wiris.callbackFunc = callbackFunc;
|
1074
|
+
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
1075
|
+
con.onload = onloadFunc;
|
1076
|
+
con.onerror = function(e) {
|
1077
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("LatexToMathml call failed!",{ fileName : "JsPluginViewer.hx", lineNumber : 817, className : "com.wiris.js.JsPluginViewer", methodName : "latexToMathml"});
|
1078
|
+
};
|
1079
|
+
con.send(data);
|
1080
|
+
}
|
1081
|
+
,callShowimage: function(container,mml,img,asynchronously,callbackFunc) {
|
1082
|
+
var _g = this;
|
997
1083
|
var con;
|
998
1084
|
var height = 0;
|
999
1085
|
var width = 0;
|
@@ -1004,8 +1090,8 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1004
1090
|
con = new js.XMLHttpRequest();
|
1005
1091
|
var mmlEntities;
|
1006
1092
|
mmlEntities = "";
|
1007
|
-
var _g1 = 0,
|
1008
|
-
while(_g1 <
|
1093
|
+
var _g1 = 0, _g2 = mml.length;
|
1094
|
+
while(_g1 < _g2) {
|
1009
1095
|
var i = _g1++;
|
1010
1096
|
var character;
|
1011
1097
|
character = mml.charAt(i);
|
@@ -1013,36 +1099,90 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1013
1099
|
}
|
1014
1100
|
var md5 = haxe.Md5.encode("centerbaseline=false\nmml=" + mmlEntities + "\n");
|
1015
1101
|
url = (this.absoluteURL.length > 0?this.absoluteURL:this.baseURL + this.localpath) + "/showimage" + this.extension;
|
1016
|
-
data = "?formula=" + md5 + "&lang=" + this.lang;
|
1017
|
-
|
1018
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("
|
1019
|
-
|
1102
|
+
if(new com.wiris.js.JsBrowser().isIE()) data = "?formula=" + md5 + "&lang=" + this.lang + "&useragent=IE"; else data = "?formula=" + md5 + "&lang=" + this.lang;
|
1103
|
+
data += "&version=" + com.wiris.js.JsPluginViewer.VERSION;
|
1104
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber : 654, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1105
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("GET:" + data,{ fileName : "JsPluginViewer.hx", lineNumber : 656, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1106
|
+
con.open("GET",url + data,asynchronously);
|
1020
1107
|
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
1108
|
+
var onloadFunc = function(e) {
|
1109
|
+
var getResultFunc = function(e1) {
|
1110
|
+
var result = { };
|
1111
|
+
try {
|
1112
|
+
result = haxe.Json.parse(con.responseText).result;
|
1113
|
+
} catch( e2 ) {
|
1114
|
+
console.warn("Formula is malformed and it can't be rendered");
|
1115
|
+
return;
|
1116
|
+
}
|
1117
|
+
e1.target.wiris.img.src = result.format == "svg"?"data:image/svg+xml;charset=utf8,":"data:image/png;base64,";
|
1118
|
+
e1.target.wiris.img.src = e1.target.wiris.img.src + StringTools.urlEncode(result.content);
|
1119
|
+
var dpi = result.dpi == null?96:result.dpi;
|
1120
|
+
var scaleDpi = _g.zoom * (96 / dpi);
|
1121
|
+
var scaledHeight = result.height * scaleDpi | 0;
|
1122
|
+
var scaledWitdh = result.width * scaleDpi | 0;
|
1123
|
+
var scaledBaseLine = result.baseline * scaleDpi | 0;
|
1124
|
+
if(result.height > 0) {
|
1125
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(_g.calculateAlignment(height,baseline),{ fileName : "JsPluginViewer.hx", lineNumber : 680, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1126
|
+
e1.target.wiris.img.style.verticalAlign = "-" + _g.calculateAlignment(scaledHeight,scaledBaseLine) + "px";
|
1127
|
+
e1.target.wiris.img.style.height = "" + scaledHeight + "px";
|
1128
|
+
e1.target.wiris.img.style.width = "" + scaledWitdh + "px";
|
1129
|
+
}
|
1130
|
+
if(_g.wiriseditormathmlattribute == null) {
|
1131
|
+
var wirisEditorMathmlAttributeCall = haxe.Json.parse(_g.callGetVariableKeys("wiriseditormathmlattribute"));
|
1132
|
+
if(wirisEditorMathmlAttributeCall.status != "ok") _g.wiriseditormathmlattribute = "data-mathml"; else _g.wiriseditormathmlattribute = wirisEditorMathmlAttributeCall.result.wiriseditormathmlattribute;
|
1133
|
+
}
|
1134
|
+
e1.target.wiris.img.setAttribute(_g.wiriseditormathmlattribute,e1.target.wiris.mml);
|
1135
|
+
e1.target.wiris.img.setAttribute("class","Wirisformula");
|
1136
|
+
e1.target.wiris.img.setAttribute("role","math");
|
1137
|
+
if(result.alt != null) e1.target.wiris.img.alt = result.alt; else {
|
1138
|
+
var accessibilityResponse = _g.callService(e1.target.wiris.mml,"mathml2accessible");
|
1139
|
+
if(haxe.Json.parse(accessibilityResponse).status != "error") e1.target.wiris.img.alt = haxe.Json.parse(accessibilityResponse).result.text;
|
1140
|
+
}
|
1141
|
+
if(--_g.callsShowImageNumber == 0) {
|
1142
|
+
var _g2 = 0, _g1 = _g.eventListenersArray.length;
|
1143
|
+
while(_g2 < _g1) {
|
1144
|
+
var i = _g2++;
|
1145
|
+
try {
|
1146
|
+
_g.eventListenersArray[i].afterParse();
|
1147
|
+
} catch( e2 ) {
|
1148
|
+
}
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
callbackFunc();
|
1152
|
+
};
|
1153
|
+
if(haxe.Json.parse(con.responseText).status == "warning") {
|
1154
|
+
con.open("POST",url,e.target.wiris.asynchronously);
|
1155
|
+
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
1156
|
+
var onloadFunc1 = function(e1) {
|
1157
|
+
getResultFunc(e1);
|
1158
|
+
};
|
1159
|
+
if(new com.wiris.js.JsBrowser().isIE()) data = "centerbaseline=false&mml=" + StringTools.urlEncode(e.target.wiris.mml) + "&useragent=IE"; else data = "centerbaseline=false&mml=" + StringTools.urlEncode(e.target.wiris.mml);
|
1160
|
+
var newDynamic = { };
|
1161
|
+
con.wiris = newDynamic;
|
1162
|
+
con.wiris.callbackFunc = callbackFunc;
|
1163
|
+
con.wiris.getResultFunc = getResultFunc;
|
1164
|
+
con.wiris.mml = mml;
|
1165
|
+
con.wiris.img = img;
|
1166
|
+
con.wiris.container = container;
|
1167
|
+
con.onload = onloadFunc1;
|
1168
|
+
con.onerror = function(e1) {
|
1169
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("ShowImage call failed!",{ fileName : "JsPluginViewer.hx", lineNumber : 744, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1170
|
+
};
|
1171
|
+
con.send(data);
|
1172
|
+
} else getResultFunc(e);
|
1173
|
+
};
|
1174
|
+
var newDynamic = { };
|
1175
|
+
con.wiris = newDynamic;
|
1176
|
+
con.wiris.callbackFunc = callbackFunc;
|
1177
|
+
con.wiris.mml = mml;
|
1178
|
+
con.wiris.img = img;
|
1179
|
+
con.wiris.container = container;
|
1180
|
+
con.wiris.asynchronously = asynchronously;
|
1181
|
+
con.onload = onloadFunc;
|
1182
|
+
con.onerror = function(e) {
|
1183
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("ShowImage call failed!",{ fileName : "JsPluginViewer.hx", lineNumber : 764, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1184
|
+
};
|
1021
1185
|
con.send(null);
|
1022
|
-
var s = con.responseText;
|
1023
|
-
if(haxe.Json.parse(con.responseText).status == "warning") {
|
1024
|
-
con.open("POST",url,false);
|
1025
|
-
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
1026
|
-
data = "centerbaseline=false&mml=" + StringTools.urlEncode(mml);
|
1027
|
-
con.send(data);
|
1028
|
-
s = con.responseText;
|
1029
|
-
}
|
1030
|
-
var result = haxe.Json.parse(con.responseText).result;
|
1031
|
-
img.src = result.format == "svg"?"data:image/svg+xml;base64,":"data:image/png;base64,";
|
1032
|
-
img.src = img.src + Std.string(result.base64);
|
1033
|
-
if(result.height > 0) {
|
1034
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(this.calculateAlignment(height,baseline),{ fileName : "JsPluginViewer.hx", lineNumber : 498, className : "com.wiris.js.JsPluginViewer", methodName : "callShowimage"});
|
1035
|
-
img.style.verticalAlign = "-" + this.calculateAlignment(result.height,result.baseline) + "px";
|
1036
|
-
img.style.height = "" + Std.string(result.height) + "px";
|
1037
|
-
img.style.width = "" + Std.string(result.width) + "px";
|
1038
|
-
}
|
1039
|
-
img.setAttribute("data-mathml",mml);
|
1040
|
-
img.setAttribute("class","Wirisformula");
|
1041
|
-
img.setAttribute("role","math");
|
1042
|
-
if(result.alt != null) img.alt = result.alt; else {
|
1043
|
-
var accessibility = this.callService(mml,"mathml2accessible");
|
1044
|
-
if(accessibility != null) img.alt = accessibility;
|
1045
|
-
}
|
1046
1186
|
}
|
1047
1187
|
,callCreateImage: function(mml,img) {
|
1048
1188
|
var con;
|
@@ -1057,8 +1197,8 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1057
1197
|
data = "metrics=true¢erbaseline=false&mml=" + StringTools.urlEncode(mml);
|
1058
1198
|
data += "&lang=" + this.lang;
|
1059
1199
|
if(this.zoom != 1) data += "&zoom=" + this.zoom;
|
1060
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1061
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("POST:" + data,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1200
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Calling: " + url,{ fileName : "JsPluginViewer.hx", lineNumber : 583, className : "com.wiris.js.JsPluginViewer", methodName : "callCreateImage"});
|
1201
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("POST:" + data,{ fileName : "JsPluginViewer.hx", lineNumber : 585, className : "com.wiris.js.JsPluginViewer", methodName : "callCreateImage"});
|
1062
1202
|
con.open("POST",url,false);
|
1063
1203
|
con.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8");
|
1064
1204
|
con.send(data);
|
@@ -1067,7 +1207,7 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1067
1207
|
if(i >= 0) {
|
1068
1208
|
var scaleDpi = 1;
|
1069
1209
|
var h = this.queryToParams(HxOverrides.substr(s,i + 1,null));
|
1070
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(h.get("formula"),{ fileName : "JsPluginViewer.hx", lineNumber :
|
1210
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(h.get("formula"),{ fileName : "JsPluginViewer.hx", lineNumber : 595, className : "com.wiris.js.JsPluginViewer", methodName : "callCreateImage"});
|
1071
1211
|
if(h.exists("dpi")) scaleDpi = this.zoom * (Std.parseInt(h.get("dpi")) / 96);
|
1072
1212
|
baseline = Std.parseInt(h.get("cb")) / scaleDpi | 0;
|
1073
1213
|
height = Std.parseInt(h.get("ch")) / scaleDpi | 0;
|
@@ -1076,7 +1216,7 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1076
1216
|
}
|
1077
1217
|
img.src = con.responseText;
|
1078
1218
|
if(height > 0) {
|
1079
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(this.calculateAlignment(height,baseline),{ fileName : "JsPluginViewer.hx", lineNumber :
|
1219
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(this.calculateAlignment(height,baseline),{ fileName : "JsPluginViewer.hx", lineNumber : 606, className : "com.wiris.js.JsPluginViewer", methodName : "callCreateImage"});
|
1080
1220
|
img.style.verticalAlign = "-" + this.calculateAlignment(height,baseline) + "px";
|
1081
1221
|
img.style.height = "" + height + "px";
|
1082
1222
|
img.style.width = "" + width + "px";
|
@@ -1085,14 +1225,12 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1085
1225
|
img.setAttribute("class","Wirisformula");
|
1086
1226
|
img.setAttribute("role","math");
|
1087
1227
|
var accessibility = this.callService(mml,"mathml2accessible");
|
1088
|
-
if(accessibility != null) img.alt = accessibility;
|
1228
|
+
if(accessibility != null) img.alt = haxe.Json.parse(accessibility).result.text;
|
1089
1229
|
}
|
1090
1230
|
,calculateAlignment: function(height,baseline) {
|
1091
1231
|
var result;
|
1092
1232
|
result = 0;
|
1093
|
-
|
1094
|
-
if(this._wrs_conf_imageFormat == null) this._wrs_conf_imageFormat = haxe.Json.parse(this.callGetVariableKeys("wirisimageformat")).result.wirisimageformat;
|
1095
|
-
if(this._wrs_conf_imageFormat == "svg") result = height - baseline - ALIGN_CONSTANT; else result = height - baseline;
|
1233
|
+
result = height - baseline;
|
1096
1234
|
return result;
|
1097
1235
|
}
|
1098
1236
|
,getTechnology: function() {
|
@@ -1105,13 +1243,13 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1105
1243
|
return StringTools.trim(s.split("#")[0]);
|
1106
1244
|
} else return com.wiris.js.JsPluginViewer.TECH;
|
1107
1245
|
}
|
1108
|
-
,processMathML: function(mml,container) {
|
1109
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(mml,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1246
|
+
,processMathML: function(mml,container,asynchronously,callbackFunc) {
|
1247
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(mml,{ fileName : "JsPluginViewer.hx", lineNumber : 528, className : "com.wiris.js.JsPluginViewer", methodName : "processMathML"});
|
1110
1248
|
var img = js.Lib.document.createElement("img");
|
1111
1249
|
if(this.performanceenabled == null) this.performanceenabled = this.isPerformanceEnabled();
|
1112
|
-
if(this.mode == com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE && this.performanceenabled) this.callShowimage(mml,img); else if(this.mode == com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE && !this.performanceenabled) this.callCreateImage(mml,img); else img.src = this.baseURL + this.localpath + "/showimage" + this.extension + "?mml=" + StringTools.urlEncode(mml);
|
1250
|
+
if(this.mode == com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE && this.performanceenabled) this.callShowimage(container,mml,img,asynchronously,callbackFunc); else if(this.mode == com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE && !this.performanceenabled) this.callCreateImage(mml,img); else img.src = this.baseURL + this.localpath + "/showimage" + this.extension + "?mml=" + StringTools.urlEncode(mml);
|
1113
1251
|
container.appendChild(img);
|
1114
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(img.src,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1252
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(img.src,{ fileName : "JsPluginViewer.hx", lineNumber : 542, className : "com.wiris.js.JsPluginViewer", methodName : "processMathML"});
|
1115
1253
|
}
|
1116
1254
|
,getMathML_IE7: function(mathNode0) {
|
1117
1255
|
var mathml = "";
|
@@ -1147,17 +1285,29 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1147
1285
|
mathml += "</math>";
|
1148
1286
|
return mathml;
|
1149
1287
|
}
|
1150
|
-
,
|
1288
|
+
,removeSemanticsMathml: function(mathml) {
|
1289
|
+
var mathTagEnd = "</math>";
|
1290
|
+
var openSemantics = "<semantics>";
|
1291
|
+
var openAnnotation = "<annotation";
|
1292
|
+
var mathmlWithoutSemantics = mathml;
|
1293
|
+
var startSemantics = mathml.indexOf(openSemantics);
|
1294
|
+
if(startSemantics != -1) {
|
1295
|
+
var startAnnotation = mathml.indexOf(openAnnotation,startSemantics + openSemantics.length);
|
1296
|
+
if(startAnnotation != -1) mathmlWithoutSemantics = mathml.substring(0,startSemantics) + mathml.substring(startSemantics + openSemantics.length,startAnnotation) + mathTagEnd;
|
1297
|
+
}
|
1298
|
+
return mathmlWithoutSemantics;
|
1299
|
+
}
|
1300
|
+
,replaceNodes: function(mathNodes,n,asynchronously,callbackFunc) {
|
1151
1301
|
if(n >= mathNodes.length) return;
|
1152
1302
|
var mathNode = mathNodes[n];
|
1153
1303
|
var mathml = null;
|
1154
1304
|
var browser = new com.wiris.js.JsBrowser();
|
1155
1305
|
if(browser.getBrowser() == "Explorer" && (browser.getVersion() == "6" || browser.getVersion() == "7") && navigator.appVersion.indexOf("Trident") == -1) {
|
1156
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Is ie7",{ fileName : "JsPluginViewer.hx", lineNumber :
|
1306
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Is ie7",{ fileName : "JsPluginViewer.hx", lineNumber : 397, className : "com.wiris.js.JsPluginViewer", methodName : "replaceNodes"});
|
1157
1307
|
mathml = this.getMathML_IE7(mathNode);
|
1158
1308
|
}
|
1159
1309
|
var container = js.Lib.document.createElement("span");
|
1160
|
-
mathNode.parentNode.replaceChild(container,mathNode);
|
1310
|
+
if(mathNode.parentNode != null) mathNode.parentNode.replaceChild(container,mathNode);
|
1161
1311
|
if(mathml == null) {
|
1162
1312
|
container.appendChild(mathNode);
|
1163
1313
|
mathml = container.innerHTML;
|
@@ -1165,11 +1315,100 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1165
1315
|
}
|
1166
1316
|
var index = mathml.indexOf("<math");
|
1167
1317
|
mathml = HxOverrides.substr(mathml,index,mathml.length - index);
|
1168
|
-
|
1318
|
+
var containerMath = js.Lib.document.createElement("span");
|
1319
|
+
var containerMathElement = js.Lib.document.createElement("math");
|
1320
|
+
containerMath.appendChild(containerMathElement);
|
1321
|
+
containerMathElement.outerHTML = mathml;
|
1322
|
+
mathml = new XMLSerializer().serializeToString(containerMath.children[0]);
|
1323
|
+
this.processMathML(mathml,container,asynchronously,callbackFunc);
|
1169
1324
|
var self = this;
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1325
|
+
self.replaceNodes(mathNodes,n + 1,asynchronously,callbackFunc);
|
1326
|
+
}
|
1327
|
+
,replaceLatexInTextNode: function(pos,node,asynchronously,callbackFunc) {
|
1328
|
+
var textContent;
|
1329
|
+
textContent = node.textContent;
|
1330
|
+
if(pos < textContent.length) {
|
1331
|
+
var nextLatexPosistion = this.getNextLatexPos(pos,textContent);
|
1332
|
+
if(nextLatexPosistion != null) {
|
1333
|
+
var leftText = textContent.substring(pos,nextLatexPosistion.start);
|
1334
|
+
var leftTextNode = js.Lib.document.createTextNode(leftText);
|
1335
|
+
node.parentNode.insertBefore(leftTextNode,node);
|
1336
|
+
var latex = textContent.substring(nextLatexPosistion.start + "$$".length,nextLatexPosistion.end);
|
1337
|
+
this.latexToMathml(latex,leftTextNode,asynchronously,callbackFunc);
|
1338
|
+
this.replaceLatexInTextNode(nextLatexPosistion.end + "$$".length,node,asynchronously,callbackFunc);
|
1339
|
+
} else {
|
1340
|
+
var text = textContent.substring(pos);
|
1341
|
+
var textNode = js.Lib.document.createTextNode(text);
|
1342
|
+
node.parentNode.insertBefore(textNode,node);
|
1343
|
+
node.parentNode.removeChild(node);
|
1344
|
+
}
|
1345
|
+
} else node.parentNode.removeChild(node);
|
1346
|
+
}
|
1347
|
+
,getNextLatexPos: function(pos,text) {
|
1348
|
+
var firstLatexTags = text.indexOf("$$",pos);
|
1349
|
+
var secondLatexTags = firstLatexTags == -1?-1:text.indexOf("$$",firstLatexTags + "$$".length);
|
1350
|
+
return firstLatexTags != -1 && secondLatexTags != -1?{ start : firstLatexTags, end : secondLatexTags}:null;
|
1351
|
+
}
|
1352
|
+
,findLatex: function(node) {
|
1353
|
+
var foundLatex = false;
|
1354
|
+
var dollarIndex = node.nodeValue.indexOf("$$");
|
1355
|
+
if(dollarIndex != -1) {
|
1356
|
+
dollarIndex = node.nodeValue.indexOf("$$",dollarIndex + 2);
|
1357
|
+
if(dollarIndex != -1) foundLatex = true;
|
1358
|
+
}
|
1359
|
+
return foundLatex;
|
1360
|
+
}
|
1361
|
+
,parseLatexDocument: function(asynchronously,callbackFunc) {
|
1362
|
+
this.parseLatexElement(js.Lib.document,asynchronously,callbackFunc);
|
1363
|
+
}
|
1364
|
+
,parseLatexElement: function(element,asynchronously,callbackFunc) {
|
1365
|
+
if(callbackFunc == null) callbackFunc = function() {
|
1366
|
+
};
|
1367
|
+
if(asynchronously == null) {
|
1368
|
+
if(this.asyncParam) asynchronously = this.asyncParam;
|
1369
|
+
}
|
1370
|
+
var domTextNodes = this.findTextNodes(element);
|
1371
|
+
var latexToProcess = [];
|
1372
|
+
var i = 0;
|
1373
|
+
while(i < domTextNodes.length) {
|
1374
|
+
var node = domTextNodes[i];
|
1375
|
+
if(this.findLatex(node)) latexToProcess.push(node);
|
1376
|
+
i++;
|
1377
|
+
}
|
1378
|
+
if(latexToProcess.length == 0) {
|
1379
|
+
var _g1 = 0, _g = this.eventListenersArray.length;
|
1380
|
+
while(_g1 < _g) {
|
1381
|
+
var i1 = _g1++;
|
1382
|
+
try {
|
1383
|
+
this.eventListenersArray[i1].afterParseLatex();
|
1384
|
+
} catch( e ) {
|
1385
|
+
}
|
1386
|
+
}
|
1387
|
+
} else {
|
1388
|
+
this.callsLatexToMathml = latexToProcess.length;
|
1389
|
+
var _g1 = 0, _g = latexToProcess.length;
|
1390
|
+
while(_g1 < _g) {
|
1391
|
+
var i1 = _g1++;
|
1392
|
+
var node = latexToProcess[i1];
|
1393
|
+
this.replaceLatexInTextNode(0,node,asynchronously,callbackFunc);
|
1394
|
+
}
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
,findTextNodes: function(el) {
|
1398
|
+
var textNodes = [];
|
1399
|
+
var walk = document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false);
|
1400
|
+
var node;
|
1401
|
+
while(node = walk.nextNode()) if(!this.thereIsParentTextArea(node)) textNodes.push(node);
|
1402
|
+
return textNodes;
|
1403
|
+
}
|
1404
|
+
,thereIsParentTextArea: function(el) {
|
1405
|
+
var thereIs = false;
|
1406
|
+
var parentNode = el.parentNode;
|
1407
|
+
while(!thereIs && parentNode != null) {
|
1408
|
+
if(parentNode.nodeName == "TEXTAREA") thereIs = true;
|
1409
|
+
parentNode = parentNode.parentNode;
|
1410
|
+
}
|
1411
|
+
return thereIs;
|
1173
1412
|
}
|
1174
1413
|
,isEditable: function(element) {
|
1175
1414
|
while(element != null) {
|
@@ -1178,8 +1417,13 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1178
1417
|
}
|
1179
1418
|
return false;
|
1180
1419
|
}
|
1181
|
-
,parseElement: function(element) {
|
1420
|
+
,parseElement: function(element,asynchronously,callbackFunc) {
|
1182
1421
|
if(!this.ready) throw "Document is not loaded.";
|
1422
|
+
if(callbackFunc == null) callbackFunc = function() {
|
1423
|
+
};
|
1424
|
+
if(asynchronously == null) {
|
1425
|
+
if(this.asyncParam) asynchronously = this.asyncParam;
|
1426
|
+
}
|
1183
1427
|
var mathNodes = element.getElementsByTagName("math");
|
1184
1428
|
var arr = new Array();
|
1185
1429
|
var _g1 = 0, _g = mathNodes.length;
|
@@ -1187,13 +1431,24 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1187
1431
|
var x = _g1++;
|
1188
1432
|
if(!this.isEditable(mathNodes[x])) arr.push(mathNodes[x]);
|
1189
1433
|
}
|
1190
|
-
this.
|
1434
|
+
this.callsShowImageNumber = arr.length;
|
1435
|
+
if(this.callsShowImageNumber == 0) {
|
1436
|
+
var _g1 = 0, _g = this.eventListenersArray.length;
|
1437
|
+
while(_g1 < _g) {
|
1438
|
+
var i = _g1++;
|
1439
|
+
try {
|
1440
|
+
this.eventListenersArray[i].afterParse();
|
1441
|
+
} catch( e ) {
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
this.replaceNodes(arr,0,asynchronously,callbackFunc);
|
1191
1446
|
}
|
1192
|
-
,parseDocument: function() {
|
1193
|
-
this.parseElement(js.Lib.document);
|
1447
|
+
,parseDocument: function(asynchronously,callbackFunc) {
|
1448
|
+
this.parseElement(js.Lib.document,asynchronously,callbackFunc);
|
1194
1449
|
}
|
1195
1450
|
,doLoad: function() {
|
1196
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("doLoad",{ fileName : "JsPluginViewer.hx", lineNumber :
|
1451
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("doLoad",{ fileName : "JsPluginViewer.hx", lineNumber : 118, className : "com.wiris.js.JsPluginViewer", methodName : "doLoad"});
|
1197
1452
|
this.scriptName = "WIRISplugins.js";
|
1198
1453
|
var col;
|
1199
1454
|
col = js.Lib.document.getElementsByTagName("script");
|
@@ -1212,7 +1467,7 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1212
1467
|
var query = HxOverrides.substr(src,k + 1,null);
|
1213
1468
|
this.params = this.queryToParams(query);
|
1214
1469
|
}
|
1215
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(this.baseURL,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1470
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace(this.baseURL,{ fileName : "JsPluginViewer.hx", lineNumber : 137, className : "com.wiris.js.JsPluginViewer", methodName : "doLoad"});
|
1216
1471
|
}
|
1217
1472
|
}
|
1218
1473
|
this.tech = this.getTechnology();
|
@@ -1241,14 +1496,18 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1241
1496
|
this.absoluteURL = "/wirispluginengine/integration";
|
1242
1497
|
}
|
1243
1498
|
this.ready = true;
|
1244
|
-
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Tech:" + this.tech,{ fileName : "JsPluginViewer.hx", lineNumber :
|
1499
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Tech:" + this.tech,{ fileName : "JsPluginViewer.hx", lineNumber : 168, className : "com.wiris.js.JsPluginViewer", methodName : "doLoad"});
|
1245
1500
|
if(this.params.exists("viewer")) this.viewer = this.params.get("viewer");
|
1501
|
+
this.asyncParam = this.params.exists("async") && this.params.get("async") == "true"?true:false;
|
1246
1502
|
if(this.params.exists("zoom")) this.zoom = Std.parseFloat(this.params.get("zoom"));
|
1247
1503
|
if(this.params.exists("dpi")) this.zoom *= Std.parseFloat(this.params.get("dpi")) / 96;
|
1248
1504
|
if(this.params.exists("lang")) this.lang = this.params.get("lang"); else this.lang = "en";
|
1249
1505
|
if(this.lang == "inherit") this.lang = js.Lib.document.getElementsByTagName("html")[0].lang;
|
1250
|
-
if(this.viewer == "image") this.parseDocument();
|
1251
|
-
|
1506
|
+
if(this.viewer == "image") this.parseDocument(); else if(this.viewer == "latex") this.parseLatexDocument(this.asyncParam); else if(this.viewer == "all") {
|
1507
|
+
this.parseLatexDocument(this.asyncParam);
|
1508
|
+
this.parseDocument(this.asyncParam);
|
1509
|
+
}
|
1510
|
+
if(com.wiris.js.JsPluginViewer.DEBUG) haxe.Log.trace("Language:" + this.lang,{ fileName : "JsPluginViewer.hx", lineNumber : 198, className : "com.wiris.js.JsPluginViewer", methodName : "doLoad"});
|
1252
1511
|
com.wiris.js.JsPluginViewer.instance = this;
|
1253
1512
|
com.wiris.js.JsPluginViewer.bypassEncapsulation();
|
1254
1513
|
}
|
@@ -1260,12 +1519,17 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1260
1519
|
}
|
1261
1520
|
if(!this.ready) haxe.Timer.delay($bind(this,this.tryReady),100);
|
1262
1521
|
}
|
1522
|
+
,eventListenersArray: null
|
1523
|
+
,callsLatexToMathml: null
|
1524
|
+
,callsShowImageNumber: null
|
1263
1525
|
,_wrs_conf_imageFormat: null
|
1264
1526
|
,ready: null
|
1265
1527
|
,javaServicePath: null
|
1266
1528
|
,tech: null
|
1267
1529
|
,lang: null
|
1530
|
+
,wiriseditormathmlattribute: null
|
1268
1531
|
,performanceenabled: null
|
1532
|
+
,asyncParam: null
|
1269
1533
|
,viewer: null
|
1270
1534
|
,zoom: null
|
1271
1535
|
,absoluteURL: null
|
@@ -1277,6 +1541,710 @@ com.wiris.js.JsPluginViewer.prototype = {
|
|
1277
1541
|
,baseURL: null
|
1278
1542
|
,__class__: com.wiris.js.JsPluginViewer
|
1279
1543
|
}
|
1544
|
+
if(!com.wiris.system) com.wiris.system = {}
|
1545
|
+
com.wiris.system.JsBrowserData = $hxClasses["com.wiris.system.JsBrowserData"] = function() {
|
1546
|
+
};
|
1547
|
+
com.wiris.system.JsBrowserData.__name__ = ["com","wiris","system","JsBrowserData"];
|
1548
|
+
com.wiris.system.JsBrowserData.prototype = {
|
1549
|
+
identity: null
|
1550
|
+
,versionSearch: null
|
1551
|
+
,subString: null
|
1552
|
+
,prop: null
|
1553
|
+
,string: null
|
1554
|
+
,__class__: com.wiris.system.JsBrowserData
|
1555
|
+
}
|
1556
|
+
com.wiris.system.JsOSData = $hxClasses["com.wiris.system.JsOSData"] = function() {
|
1557
|
+
};
|
1558
|
+
com.wiris.system.JsOSData.__name__ = ["com","wiris","system","JsOSData"];
|
1559
|
+
com.wiris.system.JsOSData.prototype = {
|
1560
|
+
identity: null
|
1561
|
+
,subString: null
|
1562
|
+
,string: null
|
1563
|
+
,__class__: com.wiris.system.JsOSData
|
1564
|
+
}
|
1565
|
+
com.wiris.system.JsBrowser = $hxClasses["com.wiris.system.JsBrowser"] = function() {
|
1566
|
+
this.dataBrowser = new Array();
|
1567
|
+
this.addBrowser("navigator.userAgent",null,"Edge",null,"Edge");
|
1568
|
+
this.addBrowser("navigator.userAgent",null,"Chrome",null,"Chrome");
|
1569
|
+
this.addBrowser("navigator.userAgent",null,"OmniWeb",null,"OmniWeb");
|
1570
|
+
this.addBrowser("navigator.vendor",null,"Apple","Version","Safari");
|
1571
|
+
this.addBrowser(null,"window.opera",null,"Version","Opera");
|
1572
|
+
this.addBrowser("navigator.vendor",null,"iCab",null,"iCab");
|
1573
|
+
this.addBrowser("navigator.vendor",null,"KDE",null,"Konkeror");
|
1574
|
+
this.addBrowser("navigator.userAgent",null,"Firefox",null,"Firefox");
|
1575
|
+
this.addBrowser("navigator.vendor",null,"Camino",null,"Camino");
|
1576
|
+
this.addBrowser("navigator.userAgent",null,"Netscape",null,"Netscape");
|
1577
|
+
this.addBrowser("navigator.userAgent",null,"MSIE","MSIE","Explorer");
|
1578
|
+
this.addBrowser("navigator.userAgent",null,"Trident","rv","Explorer");
|
1579
|
+
this.addBrowser("navigator.userAgent",null,"Gecko","rv","Mozilla");
|
1580
|
+
this.addBrowser("navigator.userAgent",null,"Mozilla","Mozilla","Netscape");
|
1581
|
+
this.dataOS = new Array();
|
1582
|
+
this.addOS("navigator.platform","Win","Windows");
|
1583
|
+
this.addOS("navigator.platform","Mac","Mac");
|
1584
|
+
this.addOS("navigator.userAgent","iPhone","iOS");
|
1585
|
+
this.addOS("navigator.userAgent","iPad","iOS");
|
1586
|
+
this.addOS("navigator.userAgent","Android","Android");
|
1587
|
+
this.addOS("navigator.platform","Linux","Linux");
|
1588
|
+
this.setBrowser();
|
1589
|
+
this.setOS();
|
1590
|
+
this.setTouchable();
|
1591
|
+
};
|
1592
|
+
com.wiris.system.JsBrowser.__name__ = ["com","wiris","system","JsBrowser"];
|
1593
|
+
com.wiris.system.JsBrowser.prototype = {
|
1594
|
+
isTouchable: function() {
|
1595
|
+
return this.touchable;
|
1596
|
+
}
|
1597
|
+
,isAndroid: function() {
|
1598
|
+
return this.os == "Android";
|
1599
|
+
}
|
1600
|
+
,isMac: function() {
|
1601
|
+
return this.os == "Mac";
|
1602
|
+
}
|
1603
|
+
,isIOS: function() {
|
1604
|
+
return this.os == "iOS";
|
1605
|
+
}
|
1606
|
+
,isFF: function() {
|
1607
|
+
return this.browser == "Firefox";
|
1608
|
+
}
|
1609
|
+
,isSafari: function() {
|
1610
|
+
return this.browser == "Safari";
|
1611
|
+
}
|
1612
|
+
,isChrome: function() {
|
1613
|
+
return this.browser == "Chrome";
|
1614
|
+
}
|
1615
|
+
,isEdge: function() {
|
1616
|
+
return this.browser == "Edge";
|
1617
|
+
}
|
1618
|
+
,isIE: function() {
|
1619
|
+
return this.browser == "Explorer";
|
1620
|
+
}
|
1621
|
+
,getVersion: function() {
|
1622
|
+
return this.ver;
|
1623
|
+
}
|
1624
|
+
,getOS: function() {
|
1625
|
+
return this.os;
|
1626
|
+
}
|
1627
|
+
,getBrowser: function() {
|
1628
|
+
return this.browser;
|
1629
|
+
}
|
1630
|
+
,searchVersion: function(prop,search) {
|
1631
|
+
var str = js.Boot.__cast(eval(prop) , String);
|
1632
|
+
var index = str.indexOf(search);
|
1633
|
+
if(index == -1) return null;
|
1634
|
+
return "" + Std.parseFloat(HxOverrides.substr(str,index + search.length + 1,null));
|
1635
|
+
}
|
1636
|
+
,setTouchable: function() {
|
1637
|
+
if(this.isIOS() || this.isAndroid()) {
|
1638
|
+
this.touchable = true;
|
1639
|
+
return;
|
1640
|
+
}
|
1641
|
+
this.touchable = false;
|
1642
|
+
}
|
1643
|
+
,setOS: function() {
|
1644
|
+
var i = HxOverrides.iter(this.dataOS);
|
1645
|
+
while(i.hasNext()) {
|
1646
|
+
var s = i.next();
|
1647
|
+
var str = js.Boot.__cast(eval(s.string) , String);
|
1648
|
+
if(str.indexOf(s.subString) != -1) {
|
1649
|
+
this.os = s.identity;
|
1650
|
+
return;
|
1651
|
+
}
|
1652
|
+
}
|
1653
|
+
}
|
1654
|
+
,setBrowser: function() {
|
1655
|
+
var i = HxOverrides.iter(this.dataBrowser);
|
1656
|
+
while(i.hasNext()) {
|
1657
|
+
var b = i.next();
|
1658
|
+
if(b.string != null) {
|
1659
|
+
var obj = eval(b.string);
|
1660
|
+
if(obj != null) {
|
1661
|
+
var str = js.Boot.__cast(obj , String);
|
1662
|
+
if(str.indexOf(b.subString) != -1) {
|
1663
|
+
this.browser = b.identity;
|
1664
|
+
this.ver = this.searchVersion("navigator.userAgent",b.versionSearch);
|
1665
|
+
if(this.ver == null) this.ver = this.searchVersion("navigator.appVersion",b.versionSearch);
|
1666
|
+
return;
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
}
|
1670
|
+
}
|
1671
|
+
}
|
1672
|
+
,addOS: function(string,subString,identity) {
|
1673
|
+
var s = new com.wiris.system.JsOSData();
|
1674
|
+
s.string = string;
|
1675
|
+
s.subString = subString;
|
1676
|
+
s.identity = identity;
|
1677
|
+
this.dataOS.push(s);
|
1678
|
+
}
|
1679
|
+
,addBrowser: function(string,prop,subString,versionSearch,identity) {
|
1680
|
+
var b = new com.wiris.system.JsBrowserData();
|
1681
|
+
b.string = string;
|
1682
|
+
b.prop = prop;
|
1683
|
+
b.subString = subString;
|
1684
|
+
b.versionSearch = versionSearch != null?versionSearch:identity;
|
1685
|
+
b.identity = identity;
|
1686
|
+
this.dataBrowser.push(b);
|
1687
|
+
}
|
1688
|
+
,touchable: null
|
1689
|
+
,os: null
|
1690
|
+
,ver: null
|
1691
|
+
,browser: null
|
1692
|
+
,dataOS: null
|
1693
|
+
,dataBrowser: null
|
1694
|
+
,__class__: com.wiris.system.JsBrowser
|
1695
|
+
}
|
1696
|
+
com.wiris.system.JsDOMUtils = $hxClasses["com.wiris.system.JsDOMUtils"] = function() { }
|
1697
|
+
com.wiris.system.JsDOMUtils.__name__ = ["com","wiris","system","JsDOMUtils"];
|
1698
|
+
com.wiris.system.JsDOMUtils.ieTouchEvents = null;
|
1699
|
+
com.wiris.system.JsDOMUtils.init = function() {
|
1700
|
+
if(com.wiris.system.JsDOMUtils.initialized) return;
|
1701
|
+
com.wiris.system.JsDOMUtils.ieTouchEvents = new Hash();
|
1702
|
+
com.wiris.system.JsDOMUtils.ieTouchEvents.set("touchstart","MSPointerDown");
|
1703
|
+
com.wiris.system.JsDOMUtils.ieTouchEvents.set("touchmove","MSPointerMove");
|
1704
|
+
com.wiris.system.JsDOMUtils.ieTouchEvents.set("touchend","MSPointerUp");
|
1705
|
+
com.wiris.system.JsDOMUtils.initialized = true;
|
1706
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"MSPointerDown",function(e) {
|
1707
|
+
com.wiris.system.JsDOMUtils.internetExplorerPointers.set("" + e.pointerId,e);
|
1708
|
+
});
|
1709
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"MSPointerUp",function(e) {
|
1710
|
+
com.wiris.system.JsDOMUtils.internetExplorerPointers = new Hash();
|
1711
|
+
});
|
1712
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"scroll",function(e) {
|
1713
|
+
com.wiris.system.JsDOMUtils.internetExplorerPointers = new Hash();
|
1714
|
+
});
|
1715
|
+
var touched = false;
|
1716
|
+
var triggerEvents = function(listeners) {
|
1717
|
+
var i = HxOverrides.iter(listeners);
|
1718
|
+
while(i.hasNext()) {
|
1719
|
+
var callbackFunction = i.next();
|
1720
|
+
callbackFunction();
|
1721
|
+
}
|
1722
|
+
};
|
1723
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"touchstart",function(e) {
|
1724
|
+
if(!com.wiris.system.JsDOMUtils.browser.touchable) {
|
1725
|
+
com.wiris.system.JsDOMUtils.browser.touchable = true;
|
1726
|
+
triggerEvents(com.wiris.system.JsDOMUtils.touchDeviceListeners);
|
1727
|
+
}
|
1728
|
+
touched = true;
|
1729
|
+
});
|
1730
|
+
var onTouchEnd = function(e) {
|
1731
|
+
if(!com.wiris.system.JsDOMUtils.browser.touchable) {
|
1732
|
+
com.wiris.system.JsDOMUtils.browser.touchable = true;
|
1733
|
+
triggerEvents(com.wiris.system.JsDOMUtils.touchDeviceListeners);
|
1734
|
+
}
|
1735
|
+
touched = true;
|
1736
|
+
setTimeout(function() {
|
1737
|
+
touched = false;
|
1738
|
+
},500);
|
1739
|
+
};
|
1740
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"touchend",onTouchEnd);
|
1741
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"touchleave",onTouchEnd);
|
1742
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"touchcancel",onTouchEnd);
|
1743
|
+
com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"mousemove",function(e) {
|
1744
|
+
if(!touched) {
|
1745
|
+
if(com.wiris.system.JsDOMUtils.browser.touchable) {
|
1746
|
+
com.wiris.system.JsDOMUtils.browser.touchable = false;
|
1747
|
+
triggerEvents(com.wiris.system.JsDOMUtils.mouseDeviceListeners);
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
});
|
1751
|
+
}
|
1752
|
+
com.wiris.system.JsDOMUtils.addEventListener = function(element,eventName,handler) {
|
1753
|
+
return com.wiris.system.JsDOMUtils.addEventListenerImpl(element,eventName,handler,false);
|
1754
|
+
}
|
1755
|
+
com.wiris.system.JsDOMUtils.addEventListenerImpl = function(element,eventName,handler,useCapture) {
|
1756
|
+
if(navigator.msPointerEnabled && com.wiris.system.JsDOMUtils.ieTouchEvents.exists(eventName)) {
|
1757
|
+
eventName = com.wiris.system.JsDOMUtils.ieTouchEvents.get(eventName);
|
1758
|
+
return com.wiris.system.JsDOMUtils.addEventListenerImpl(element,eventName,function(e) {
|
1759
|
+
if(e.pointerType == "touch") {
|
1760
|
+
if(eventName == "MSPointerUp") com.wiris.system.JsDOMUtils.internetExplorerPointers.remove("" + e.pointerId); else com.wiris.system.JsDOMUtils.internetExplorerPointers.set("" + e.pointerId,e);
|
1761
|
+
e.touches = new Array();
|
1762
|
+
var i = com.wiris.system.JsDOMUtils.internetExplorerPointers.iterator();
|
1763
|
+
while(i.hasNext()) e.touches.push(i.next());
|
1764
|
+
handler(e);
|
1765
|
+
}
|
1766
|
+
},useCapture);
|
1767
|
+
}
|
1768
|
+
if(eventName == "touchhold" && com.wiris.system.JsDOMUtils.browser.isTouchable()) {
|
1769
|
+
var timeout = null;
|
1770
|
+
var startX = -1;
|
1771
|
+
var startY = -1;
|
1772
|
+
var descriptor = com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchstart",function(e) {
|
1773
|
+
touching = true;
|
1774
|
+
startX = e.touches[0].clientX;
|
1775
|
+
startY = e.touches[0].clientY;
|
1776
|
+
timeout = setTimeout(function() {
|
1777
|
+
timeout = null;
|
1778
|
+
handler(e);
|
1779
|
+
},500);
|
1780
|
+
},useCapture);
|
1781
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchmove",function(e) {
|
1782
|
+
if(timeout != null) {
|
1783
|
+
if(Math.abs(e.touches[0].clientX - startX) > com.wiris.system.JsDOMUtils.TOUCHHOLD_MOVE_MARGIN || Math.abs(e.touches[0].clientY - startY) > com.wiris.system.JsDOMUtils.TOUCHHOLD_MOVE_MARGIN) {
|
1784
|
+
clearTimeout(timeout);
|
1785
|
+
timeout = null;
|
1786
|
+
} else com.wiris.system.JsDOMUtils.cancelEvent(e);
|
1787
|
+
}
|
1788
|
+
},useCapture));
|
1789
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchend",function(e) {
|
1790
|
+
if(timeout != null) {
|
1791
|
+
clearTimeout(timeout);
|
1792
|
+
timeout = null;
|
1793
|
+
}
|
1794
|
+
},useCapture));
|
1795
|
+
return descriptor;
|
1796
|
+
}
|
1797
|
+
var descriptor = { };
|
1798
|
+
descriptor.element = element;
|
1799
|
+
descriptor.eventName = eventName;
|
1800
|
+
descriptor.handler = handler;
|
1801
|
+
descriptor.useCapture = useCapture;
|
1802
|
+
descriptor.subDescriptors = new Array();
|
1803
|
+
if(eventName == "dblclick") {
|
1804
|
+
var event = null;
|
1805
|
+
var touching = false;
|
1806
|
+
var firstClickTimestamp = null;
|
1807
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchstart",function(e) {
|
1808
|
+
touching = true;
|
1809
|
+
event = e;
|
1810
|
+
},useCapture));
|
1811
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchmove",function(e) {
|
1812
|
+
touching = false;
|
1813
|
+
},useCapture));
|
1814
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListenerImpl(element,"touchend",function(e) {
|
1815
|
+
if(touching) {
|
1816
|
+
touching = false;
|
1817
|
+
var currentTimestamp = new Date().getTime();
|
1818
|
+
if(firstClickTimestamp == null || currentTimestamp > firstClickTimestamp + 500) firstClickTimestamp = currentTimestamp; else {
|
1819
|
+
event._wrs_dealAsTouch = true;
|
1820
|
+
handler(e);
|
1821
|
+
}
|
1822
|
+
}
|
1823
|
+
},useCapture));
|
1824
|
+
}
|
1825
|
+
if(element.attachEvent) element.attachEvent("on" + eventName,function() {
|
1826
|
+
handler(window.event);
|
1827
|
+
}); else element.addEventListener(eventName,handler,useCapture);
|
1828
|
+
return descriptor;
|
1829
|
+
}
|
1830
|
+
com.wiris.system.JsDOMUtils.removeEventListener = function(descriptor) {
|
1831
|
+
if(com.wiris.system.JsDOMUtils.browser.isIE() && descriptor.element.detachEvent) descriptor.element.detachEvent("on" + Std.string(descriptor.eventName),descriptor.handler); else descriptor.element.removeEventListener(descriptor.eventName,descriptor.handler,descriptor.useCapture);
|
1832
|
+
var i = $iterator(descriptor.subDescriptors)();
|
1833
|
+
while(i.hasNext()) com.wiris.system.JsDOMUtils.removeEventListener(i.next());
|
1834
|
+
}
|
1835
|
+
com.wiris.system.JsDOMUtils.cancelEvent = function(e) {
|
1836
|
+
if(e.preventDefault) e.preventDefault(); else e.returnValue = false;
|
1837
|
+
}
|
1838
|
+
com.wiris.system.JsDOMUtils.fireEvent = function(element,eventName) {
|
1839
|
+
var event;
|
1840
|
+
if(document.createEvent) {
|
1841
|
+
event = document.createEvent("HTMLEvents");
|
1842
|
+
event.initEvent(eventName,true,true);
|
1843
|
+
event.eventName = eventName;
|
1844
|
+
element.dispatchEvent(event);
|
1845
|
+
} else {
|
1846
|
+
event = document.createEventObject();
|
1847
|
+
event.eventType = eventName;
|
1848
|
+
event.eventName = eventName;
|
1849
|
+
element.fireEvent("on" + eventName,event);
|
1850
|
+
}
|
1851
|
+
}
|
1852
|
+
com.wiris.system.JsDOMUtils.getComputedStyle = function(element) {
|
1853
|
+
if(element.currentStyle) return element.currentStyle;
|
1854
|
+
return document.defaultView.getComputedStyle(element,null);
|
1855
|
+
}
|
1856
|
+
com.wiris.system.JsDOMUtils.getComputedStyleProperty = function(element,name) {
|
1857
|
+
var value;
|
1858
|
+
if(document.defaultView && document.defaultView.getComputedStyle) {
|
1859
|
+
var computedStyle = document.defaultView.getComputedStyle(element,null);
|
1860
|
+
value = computedStyle == null?null:computedStyle.getPropertyValue(name);
|
1861
|
+
} else if(com.wiris.system.JsDOMUtils.browser.isIE() && element.currentStyle) {
|
1862
|
+
var camelName = com.wiris.system.JsDOMUtils.camelize(name);
|
1863
|
+
value = element.currentStyle[camelName];
|
1864
|
+
if(value != null && value.length > 0 && camelName != "zoom") {
|
1865
|
+
var firstChar = HxOverrides.cca(value,0);
|
1866
|
+
if(firstChar >= 48 && firstChar <= 57 && !StringTools.endsWith(value,"px")) {
|
1867
|
+
var originalLeft = element.style.left;
|
1868
|
+
var originalRuntimeLeft = element.runtimeStyle?element.runtimeStyle.left:null;
|
1869
|
+
if(originalRuntimeLeft != null) element.runtimeStyle.left = element.currentStyle.left;
|
1870
|
+
element.style.left = camelName == "fontSize"?"1em":value;
|
1871
|
+
value = element.style.pixelLeft + "px";
|
1872
|
+
element.style.left = originalLeft;
|
1873
|
+
if(originalRuntimeLeft != null) element.runtimeStyle.left = originalRuntimeLeft;
|
1874
|
+
}
|
1875
|
+
}
|
1876
|
+
} else value = element.style[com.wiris.system.JsDOMUtils.camelize(name)];
|
1877
|
+
return value;
|
1878
|
+
}
|
1879
|
+
com.wiris.system.JsDOMUtils.getPixelRatio = function() {
|
1880
|
+
var context = document.createElement("canvas").getContext("2d");
|
1881
|
+
var dpr = window.devicePixelRatio || 1;
|
1882
|
+
var bsr = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
|
1883
|
+
return dpr / bsr;
|
1884
|
+
}
|
1885
|
+
com.wiris.system.JsDOMUtils.camelize = function(str) {
|
1886
|
+
var start = 0;
|
1887
|
+
var pos;
|
1888
|
+
var sb = new StringBuf();
|
1889
|
+
while((pos = str.indexOf("-",start)) != -1) {
|
1890
|
+
sb.b += Std.string(HxOverrides.substr(str,start,pos - start));
|
1891
|
+
sb.b += Std.string(str.charAt(pos + 1).toUpperCase());
|
1892
|
+
start = pos + 2;
|
1893
|
+
}
|
1894
|
+
sb.b += Std.string(HxOverrides.substr(str,start,null));
|
1895
|
+
return sb.b;
|
1896
|
+
}
|
1897
|
+
com.wiris.system.JsDOMUtils.getElementsByClassName = function(parent,className,recursive) {
|
1898
|
+
var returnValue = new Array();
|
1899
|
+
var _g1 = 0, _g = parent.childNodes.length;
|
1900
|
+
while(_g1 < _g) {
|
1901
|
+
var i = _g1++;
|
1902
|
+
if(com.wiris.system.JsDOMUtils.hasClass(parent.childNodes[i],className)) returnValue.push(parent.childNodes[i]);
|
1903
|
+
if(recursive) returnValue = returnValue.concat(com.wiris.system.JsDOMUtils.getElementsByClassName(parent.childNodes[i],className,true));
|
1904
|
+
}
|
1905
|
+
return returnValue;
|
1906
|
+
}
|
1907
|
+
com.wiris.system.JsDOMUtils.getEventTarget = function(event) {
|
1908
|
+
if(event.srcElement) return event.srcElement;
|
1909
|
+
return event.target;
|
1910
|
+
}
|
1911
|
+
com.wiris.system.JsDOMUtils.getLeft = function(element) {
|
1912
|
+
return element.getBoundingClientRect().left;
|
1913
|
+
}
|
1914
|
+
com.wiris.system.JsDOMUtils.getRelativeLeft = function(element,parent) {
|
1915
|
+
if(parent == null) return com.wiris.system.JsDOMUtils.getLeft(element);
|
1916
|
+
return com.wiris.system.JsDOMUtils.getLeft(element) - com.wiris.system.JsDOMUtils.getLeft(parent);
|
1917
|
+
}
|
1918
|
+
com.wiris.system.JsDOMUtils.getTop = function(element) {
|
1919
|
+
return element.getBoundingClientRect().top;
|
1920
|
+
}
|
1921
|
+
com.wiris.system.JsDOMUtils.getRelativeTop = function(element,parent) {
|
1922
|
+
if(parent == null) return com.wiris.system.JsDOMUtils.getTop(element);
|
1923
|
+
return com.wiris.system.JsDOMUtils.getTop(element) - com.wiris.system.JsDOMUtils.getTop(parent);
|
1924
|
+
}
|
1925
|
+
com.wiris.system.JsDOMUtils.getWindowScroll = function() {
|
1926
|
+
var scroll = new Array();
|
1927
|
+
if(js.Lib.window.pageYOffset == undefined) {
|
1928
|
+
scroll[0] = js.Lib.document.documentElement.scrollLeft;
|
1929
|
+
scroll[1] = js.Lib.document.documentElement.scrollTop;
|
1930
|
+
} else {
|
1931
|
+
scroll[0] = js.Lib.window.pageXOffset;
|
1932
|
+
scroll[1] = js.Lib.window.pageYOffset;
|
1933
|
+
}
|
1934
|
+
return scroll;
|
1935
|
+
}
|
1936
|
+
com.wiris.system.JsDOMUtils.setWindowScroll = function(scroll) {
|
1937
|
+
var x = scroll[0] | 0;
|
1938
|
+
var y = scroll[1] | 0;
|
1939
|
+
js.Lib.window.scrollTo(x,y);
|
1940
|
+
}
|
1941
|
+
com.wiris.system.JsDOMUtils.isLeftBidiAware = function(keyCode,rtl) {
|
1942
|
+
return keyCode == 37 && !rtl || keyCode == 39 && rtl;
|
1943
|
+
}
|
1944
|
+
com.wiris.system.JsDOMUtils.getFirstDisplayedChild = function(parent) {
|
1945
|
+
var child = parent != null?parent.firstChild:parent;
|
1946
|
+
while(child != null) {
|
1947
|
+
if(com.wiris.system.JsDOMUtils.getComputedStyleProperty(child,"display") != "none") return child;
|
1948
|
+
child = child.nextSibling;
|
1949
|
+
}
|
1950
|
+
return null;
|
1951
|
+
}
|
1952
|
+
com.wiris.system.JsDOMUtils.isDescendant = function(parent,possibleDescendant) {
|
1953
|
+
if(parent == null || possibleDescendant == null) return false;
|
1954
|
+
while(possibleDescendant.parentNode != null) {
|
1955
|
+
if(possibleDescendant.parentNode == parent) return true;
|
1956
|
+
possibleDescendant = possibleDescendant.parentNode;
|
1957
|
+
}
|
1958
|
+
return false;
|
1959
|
+
}
|
1960
|
+
com.wiris.system.JsDOMUtils.parseDimension = function(x) {
|
1961
|
+
return x < 0 || x == null?0:x;
|
1962
|
+
}
|
1963
|
+
com.wiris.system.JsDOMUtils.removeChildren = function(element) {
|
1964
|
+
while(element.firstChild != null) element.removeChild(element.firstChild);
|
1965
|
+
}
|
1966
|
+
com.wiris.system.JsDOMUtils.hasClass = function(element,className) {
|
1967
|
+
if(element == null || element.className == null || !(element.className.split)) return false;
|
1968
|
+
var classes = element.className.split(" ");
|
1969
|
+
var i = HxOverrides.iter(classes);
|
1970
|
+
while(i.hasNext()) if(i.next() == className) return true;
|
1971
|
+
return false;
|
1972
|
+
}
|
1973
|
+
com.wiris.system.JsDOMUtils.addClass = function(element,className) {
|
1974
|
+
if(element == null) return;
|
1975
|
+
if(element.className == "") element.className = className; else if(!com.wiris.system.JsDOMUtils.hasClass(element,className)) element.className += " " + className;
|
1976
|
+
}
|
1977
|
+
com.wiris.system.JsDOMUtils.removeClass = function(element,className) {
|
1978
|
+
if(element == null || element.className == null || !(element.className.split)) return;
|
1979
|
+
var classes = element.className.split(" ");
|
1980
|
+
HxOverrides.remove(classes,className);
|
1981
|
+
element.className = classes.join(" ");
|
1982
|
+
}
|
1983
|
+
com.wiris.system.JsDOMUtils.toggleClass = function(element,className) {
|
1984
|
+
if(com.wiris.system.JsDOMUtils.hasClass(element,className)) com.wiris.system.JsDOMUtils.removeClass(element,className); else com.wiris.system.JsDOMUtils.addClass(element,className);
|
1985
|
+
}
|
1986
|
+
com.wiris.system.JsDOMUtils.activateClass = function(element,className) {
|
1987
|
+
if(!com.wiris.system.JsDOMUtils.hasClass(element,className)) com.wiris.system.JsDOMUtils.addClass(element,className);
|
1988
|
+
}
|
1989
|
+
com.wiris.system.JsDOMUtils.setCaretPosition = function(element,position,end) {
|
1990
|
+
if(element.setSelectionRange) element.setSelectionRange(position,end); else if(element.createTextRange) {
|
1991
|
+
var range = element.createTextRange();
|
1992
|
+
range.collapse(true);
|
1993
|
+
range.moveStart("character",position);
|
1994
|
+
range.moveEnd("character",end);
|
1995
|
+
range.select();
|
1996
|
+
}
|
1997
|
+
}
|
1998
|
+
com.wiris.system.JsDOMUtils.getSelectionBounds = function(element) {
|
1999
|
+
var bounds = new Array();
|
2000
|
+
if(element.selectionStart != null) {
|
2001
|
+
bounds[0] = element.selectionStart;
|
2002
|
+
bounds[1] = element.selectionEnd;
|
2003
|
+
return bounds;
|
2004
|
+
}
|
2005
|
+
var range = document.selection.createRange();
|
2006
|
+
if(range && range.parentElement() == element) {
|
2007
|
+
var length = element.value.length;
|
2008
|
+
var normalizedValue = element.value.split("\r\n").join("\n");
|
2009
|
+
var textInputRange = element.createTextRange();
|
2010
|
+
textInputRange.moveToBookmark(range.getBookmark());
|
2011
|
+
var endRange = element.createTextRange();
|
2012
|
+
endRange.collapse(false);
|
2013
|
+
if(textInputRange.compareEndPoints("StartToEnd",endRange) > -1) bounds[0] = bounds[1] = length; else {
|
2014
|
+
bounds[0] = -textInputRange.moveStart("character",-length);
|
2015
|
+
bounds[0] += normalizedValue.slice(0,bounds[0]).split("\n").length - 1;
|
2016
|
+
if(textInputRange.compareEndPoints("EndToEnd",endRange) > -1) bounds[1] = length; else {
|
2017
|
+
bounds[1] = -textInputRange.moveEnd("character",-length);
|
2018
|
+
bounds[1] += normalizedValue.slice(0,bounds[1]).split("\n").length - 1;
|
2019
|
+
}
|
2020
|
+
}
|
2021
|
+
return bounds;
|
2022
|
+
}
|
2023
|
+
return null;
|
2024
|
+
}
|
2025
|
+
com.wiris.system.JsDOMUtils.getMousePosition = function(target,e) {
|
2026
|
+
if(e._wrs_dealAsTouch) return com.wiris.system.JsDOMUtils.getTouchPosition(target,e.touches[0]);
|
2027
|
+
var elementScroll = new Array();
|
2028
|
+
elementScroll[0] = target.scrollLeft;
|
2029
|
+
elementScroll[1] = target.scrollTop;
|
2030
|
+
return com.wiris.system.JsDOMUtils.getMousePositionImpl(target,e,elementScroll,0);
|
2031
|
+
}
|
2032
|
+
com.wiris.system.JsDOMUtils.getMousePositionImpl = function(target,e,elementScroll,border) {
|
2033
|
+
var position = new Array();
|
2034
|
+
position[0] = e.clientX - com.wiris.system.JsDOMUtils.getLeft(target) - border + elementScroll[0];
|
2035
|
+
position[1] = e.clientY - com.wiris.system.JsDOMUtils.getTop(target) - border + elementScroll[1];
|
2036
|
+
return position;
|
2037
|
+
}
|
2038
|
+
com.wiris.system.JsDOMUtils.inFixedParent = function(element) {
|
2039
|
+
while(element != null) {
|
2040
|
+
if(com.wiris.system.JsDOMUtils.getComputedStyleProperty(element,"position") == "fixed") return true;
|
2041
|
+
element = element.offsetParent;
|
2042
|
+
}
|
2043
|
+
return false;
|
2044
|
+
}
|
2045
|
+
com.wiris.system.JsDOMUtils.getTouchPosition = function(target,touch) {
|
2046
|
+
var elementScroll = new Array();
|
2047
|
+
elementScroll[0] = target.scrollLeft;
|
2048
|
+
elementScroll[1] = target.scrollTop;
|
2049
|
+
return com.wiris.system.JsDOMUtils.getTouchPositionImpl(target,touch,elementScroll,0);
|
2050
|
+
}
|
2051
|
+
com.wiris.system.JsDOMUtils.getTouchPositionImpl = function(target,touch,elementScroll,border) {
|
2052
|
+
var position = new Array();
|
2053
|
+
position[0] = touch.clientX - com.wiris.system.JsDOMUtils.getLeft(target) - border + elementScroll[0];
|
2054
|
+
position[1] = touch.clientY - com.wiris.system.JsDOMUtils.getTop(target) - border + elementScroll[1];
|
2055
|
+
return position;
|
2056
|
+
}
|
2057
|
+
com.wiris.system.JsDOMUtils.getStandardButton = function(e) {
|
2058
|
+
if(e.touches) return 1;
|
2059
|
+
if("button" in e) return e.button + 1;
|
2060
|
+
return 0;
|
2061
|
+
}
|
2062
|
+
com.wiris.system.JsDOMUtils.vibrate = function(milliseconds) {
|
2063
|
+
if(navigator.vibrate) navigator.vibrate(milliseconds);
|
2064
|
+
}
|
2065
|
+
com.wiris.system.JsDOMUtils.onTouchDeviceDetected = function(callbackFunction) {
|
2066
|
+
com.wiris.system.JsDOMUtils.init();
|
2067
|
+
com.wiris.system.JsDOMUtils.touchDeviceListeners.push(callbackFunction);
|
2068
|
+
}
|
2069
|
+
com.wiris.system.JsDOMUtils.onMouseDeviceDetected = function(callbackFunction) {
|
2070
|
+
com.wiris.system.JsDOMUtils.init();
|
2071
|
+
com.wiris.system.JsDOMUtils.mouseDeviceListeners.push(callbackFunction);
|
2072
|
+
}
|
2073
|
+
com.wiris.system.JsDOMUtils.findScriptElement = function(reg) {
|
2074
|
+
var scripts = js.Lib.document.getElementsByTagName("script");
|
2075
|
+
var n = scripts.length;
|
2076
|
+
var i = 0;
|
2077
|
+
while(i < n) {
|
2078
|
+
var src = scripts[i].getAttribute("src");
|
2079
|
+
if(reg.match(src)) return scripts[i];
|
2080
|
+
++i;
|
2081
|
+
}
|
2082
|
+
return null;
|
2083
|
+
}
|
2084
|
+
com.wiris.system.JsDOMUtils.rewriteDefaultPaths = function(contextPath) {
|
2085
|
+
if(window.com.wiris.js.defaultServicePath != null && StringTools.startsWith(window.com.wiris.js.defaultServicePath,"http://")) {
|
2086
|
+
var protocol = js.Lib.window.location.protocol;
|
2087
|
+
var defaultServicePathWithoutProtocol = window.com.wiris.js.defaultServicePath.substr("http:".length);
|
2088
|
+
var reg = new EReg("(http:|https:)" + defaultServicePathWithoutProtocol + "/" + contextPath,"");
|
2089
|
+
if(com.wiris.system.JsDOMUtils.findScriptElement(reg) != null) protocol = reg.matched(1);
|
2090
|
+
if(protocol == "https:") {
|
2091
|
+
window.com.wiris.js.defaultServicePath = "https:" + defaultServicePathWithoutProtocol;
|
2092
|
+
if(window.com.wiris.js.defaultBasePath != null) window.com.wiris.js.defaultBasePath = "https:" + window.com.wiris.js.defaultBasePath.substr("http:".length);
|
2093
|
+
}
|
2094
|
+
}
|
2095
|
+
}
|
2096
|
+
com.wiris.system.JsDOMUtils.createCSSRules = function(selector,rules) {
|
2097
|
+
var style = js.Lib.document.createElement("style");
|
2098
|
+
style.type = "text/css";
|
2099
|
+
js.Lib.document.getElementsByTagName("head")[0].appendChild(style);
|
2100
|
+
if(style.sheet != null && style.sheet.insertRule != null) style.sheet.insertRule(selector + "{" + rules + "}",0); else if(style.styleSheet != null) style.styleSheet.addRule(selector,rules); else if(style.sheet != null) style.sheet.addRule(selector,rules);
|
2101
|
+
}
|
2102
|
+
com.wiris.system.JsDOMUtils.execCommand = function(command) {
|
2103
|
+
return document.execCommand(command);
|
2104
|
+
}
|
2105
|
+
com.wiris.system.JsDOMUtils.findServicePath = function(scriptName) {
|
2106
|
+
var scriptTags = js.Lib.document.getElementsByTagName("script");
|
2107
|
+
var servicePath = null;
|
2108
|
+
var _g1 = 0, _g = scriptTags.length;
|
2109
|
+
while(_g1 < _g) {
|
2110
|
+
var i = _g1++;
|
2111
|
+
var src = scriptTags[i].src;
|
2112
|
+
var j = src.lastIndexOf("/" + scriptName);
|
2113
|
+
if(j >= 0) servicePath = HxOverrides.substr(src,0,j); else if(src == scriptName) servicePath = "";
|
2114
|
+
}
|
2115
|
+
if(servicePath != null && StringTools.startsWith(servicePath,"http://") && js.Lib.window.location.protocol == "https:") servicePath = "https://" + HxOverrides.substr(servicePath,"http://".length,null);
|
2116
|
+
return servicePath;
|
2117
|
+
}
|
2118
|
+
com.wiris.system.JsDOMUtils.loadTextFile = function(elem,func) {
|
2119
|
+
var w = js.Lib.window;
|
2120
|
+
if(w.File && w.FileReader && w.FileList && w.Blob) {
|
2121
|
+
var d = elem.ownerDocument;
|
2122
|
+
var fileInput = d.createElement("input");
|
2123
|
+
fileInput.setAttribute("name","data");
|
2124
|
+
fileInput.setAttribute("type","file");
|
2125
|
+
elem.appendChild(fileInput);
|
2126
|
+
com.wiris.system.JsDOMUtils.init();
|
2127
|
+
com.wiris.system.JsDOMUtils.addEventListener(fileInput,"change",function(e) {
|
2128
|
+
if(fileInput.files.length) {
|
2129
|
+
var file = fileInput.files[0];
|
2130
|
+
var reader = new FileReader();
|
2131
|
+
reader.onload = function(le) {
|
2132
|
+
func(le.target.result);
|
2133
|
+
};
|
2134
|
+
reader.readAsText(file);
|
2135
|
+
}
|
2136
|
+
elem.removeChild(fileInput);
|
2137
|
+
});
|
2138
|
+
fileInput.click();
|
2139
|
+
} else throw "Browser incompatible with JavaScript File API.";
|
2140
|
+
}
|
2141
|
+
com.wiris.system.JsDOMUtils.saveTextFile = function(elem,filename,filetype,contents) {
|
2142
|
+
var d = elem.ownerDocument;
|
2143
|
+
var w = js.Lib.window;
|
2144
|
+
if(w.Blob) {
|
2145
|
+
var blob = new Blob([contents], {'type': filetype});
|
2146
|
+
var a = d.createElement("a");
|
2147
|
+
if('download' in a && w.URL) {
|
2148
|
+
a.href = w.URL.createObjectURL(blob);
|
2149
|
+
a.download = filename;
|
2150
|
+
elem.appendChild(a);
|
2151
|
+
a.click();
|
2152
|
+
elem.removeChild(a);
|
2153
|
+
return;
|
2154
|
+
}
|
2155
|
+
}
|
2156
|
+
throw "Browser incompatible with HTML object download anchors.";
|
2157
|
+
}
|
2158
|
+
com.wiris.system.JsDOMUtils.trapFocus = function(disabledFocusContainer,focusableContainer) {
|
2159
|
+
var lastScroll = com.wiris.system.JsDOMUtils.getWindowScroll();
|
2160
|
+
var previousFocused = focusableContainer;
|
2161
|
+
var descriptor = com.wiris.system.JsDOMUtils.addEventListener(js.Lib.document,"focusin",function(e) {
|
2162
|
+
previousFocused = com.wiris.system.JsDOMUtils.getEventTarget(e);
|
2163
|
+
});
|
2164
|
+
descriptor.subDescriptors.push(com.wiris.system.JsDOMUtils.addEventListener(disabledFocusContainer,"focusin",function(e) {
|
2165
|
+
var focusedElement = com.wiris.system.JsDOMUtils.getEventTarget(e);
|
2166
|
+
if(!com.wiris.system.JsDOMUtils.isDescendant(focusableContainer,focusedElement)) {
|
2167
|
+
com.wiris.system.JsDOMUtils.setWindowScroll(lastScroll);
|
2168
|
+
var focusableElements = com.wiris.system.JsDOMUtils.getFocusableElements(js.Lib.document.body);
|
2169
|
+
var focusedElementIndex = 0;
|
2170
|
+
while(focusedElementIndex < focusableElements.length) {
|
2171
|
+
if(focusableElements[focusedElementIndex] == focusedElement) break;
|
2172
|
+
++focusedElementIndex;
|
2173
|
+
}
|
2174
|
+
var direction = previousFocused == focusedElement || com.wiris.system.JsDOMUtils.elementIsBefore(previousFocused,focusedElement)?1:-1;
|
2175
|
+
var alternative = com.wiris.system.JsDOMUtils.findFocusableAlternative(focusableElements,disabledFocusContainer,focusableContainer,focusedElementIndex,direction);
|
2176
|
+
if(alternative != null) alternative.focus();
|
2177
|
+
e.stopPropagation();
|
2178
|
+
} else lastScroll = com.wiris.system.JsDOMUtils.getWindowScroll();
|
2179
|
+
}));
|
2180
|
+
var focusedElement = js.Lib.document.activeElement;
|
2181
|
+
if(!com.wiris.system.JsDOMUtils.isDescendant(focusableContainer,focusedElement)) {
|
2182
|
+
com.wiris.system.JsDOMUtils.setWindowScroll(lastScroll);
|
2183
|
+
var focusableElements = com.wiris.system.JsDOMUtils.getFocusableElements(js.Lib.document.body);
|
2184
|
+
var focusedElementIndex = 0;
|
2185
|
+
while(focusedElementIndex < focusableElements.length) {
|
2186
|
+
if(focusableElements[focusedElementIndex] == focusedElement) break;
|
2187
|
+
++focusedElementIndex;
|
2188
|
+
}
|
2189
|
+
var alternative = com.wiris.system.JsDOMUtils.findFocusableAlternative(focusableElements,disabledFocusContainer,focusableContainer,focusedElementIndex,1);
|
2190
|
+
if(alternative != null) alternative.focus();
|
2191
|
+
}
|
2192
|
+
return descriptor;
|
2193
|
+
}
|
2194
|
+
com.wiris.system.JsDOMUtils.findFocusableAlternative = function(focusableElements,disabledFocusContainer,focusableContainer,focusedElementIndex,direction,stopOnIndex) {
|
2195
|
+
if(stopOnIndex == null) stopOnIndex = -100;
|
2196
|
+
var originalFocusedElementIndex = focusedElementIndex;
|
2197
|
+
focusedElementIndex += direction;
|
2198
|
+
while(focusedElementIndex >= 0 && focusedElementIndex < focusableElements.length && com.wiris.system.JsDOMUtils.isDescendant(disabledFocusContainer,focusableElements[focusedElementIndex]) && !com.wiris.system.JsDOMUtils.isDescendant(focusableContainer,focusableElements[focusedElementIndex])) {
|
2199
|
+
focusedElementIndex += direction;
|
2200
|
+
if(focusedElementIndex == stopOnIndex) return null;
|
2201
|
+
}
|
2202
|
+
if(focusedElementIndex < 0) return com.wiris.system.JsDOMUtils.findFocusableAlternative(focusableElements,disabledFocusContainer,focusableContainer,focusableElements.length - 1,-1,originalFocusedElementIndex);
|
2203
|
+
if(focusedElementIndex >= focusableElements.length) return com.wiris.system.JsDOMUtils.findFocusableAlternative(focusableElements,disabledFocusContainer,focusableContainer,0,1,originalFocusedElementIndex);
|
2204
|
+
return focusableElements[focusedElementIndex];
|
2205
|
+
}
|
2206
|
+
com.wiris.system.JsDOMUtils.untrapFocus = function(descriptor) {
|
2207
|
+
com.wiris.system.JsDOMUtils.removeEventListener(descriptor);
|
2208
|
+
}
|
2209
|
+
com.wiris.system.JsDOMUtils.getFocusableElements = function(container) {
|
2210
|
+
var elements = container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
|
2211
|
+
var focusableElements = new Array();
|
2212
|
+
var i = 0;
|
2213
|
+
while(i < elements.length) {
|
2214
|
+
if(com.wiris.system.JsDOMUtils.getComputedStyleProperty(elements[i],"display") != "none" && com.wiris.system.JsDOMUtils.getComputedStyleProperty(elements[i],"visibility") != "hidden") focusableElements.push(elements[i]);
|
2215
|
+
++i;
|
2216
|
+
}
|
2217
|
+
return focusableElements;
|
2218
|
+
}
|
2219
|
+
com.wiris.system.JsDOMUtils.elementIsBefore = function(elementA,elementB) {
|
2220
|
+
if(elementA == elementB) throw "Trying to compare the same element.";
|
2221
|
+
var pathA = com.wiris.system.JsDOMUtils.getElementPath(elementA);
|
2222
|
+
var pathB = com.wiris.system.JsDOMUtils.getElementPath(elementB);
|
2223
|
+
var i = 1;
|
2224
|
+
var n = Math.min(pathA.length,pathB.length) | 0;
|
2225
|
+
while(i < n) {
|
2226
|
+
if(pathA[i] != pathB[i]) return com.wiris.system.JsDOMUtils.getElementChildIndex(pathA[i]) < com.wiris.system.JsDOMUtils.getElementChildIndex(pathB[i]);
|
2227
|
+
++i;
|
2228
|
+
}
|
2229
|
+
return false;
|
2230
|
+
}
|
2231
|
+
com.wiris.system.JsDOMUtils.getElementPath = function(element) {
|
2232
|
+
var path = new Array();
|
2233
|
+
while(element != null) {
|
2234
|
+
path.splice(0,0,element);
|
2235
|
+
element = element.parentNode;
|
2236
|
+
}
|
2237
|
+
return path;
|
2238
|
+
}
|
2239
|
+
com.wiris.system.JsDOMUtils.getElementChildIndex = function(element) {
|
2240
|
+
if(element.parentNode == null) return -1;
|
2241
|
+
var i = 0;
|
2242
|
+
while(i < element.parentNode.childNodes.length) {
|
2243
|
+
if(element.parentNode.childNodes[i] == element) return i;
|
2244
|
+
++i;
|
2245
|
+
}
|
2246
|
+
return -1;
|
2247
|
+
}
|
1280
2248
|
var haxe = haxe || {}
|
1281
2249
|
haxe.Http = $hxClasses["haxe.Http"] = function(url) {
|
1282
2250
|
this.url = url;
|
@@ -2759,6 +3727,7 @@ js.Lib.eval = function(code) {
|
|
2759
3727
|
js.Lib.setErrorHandler = function(f) {
|
2760
3728
|
js.Lib.onerror = f;
|
2761
3729
|
}
|
3730
|
+
function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; };
|
2762
3731
|
var $_;
|
2763
3732
|
function $bind(o,m) { var f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; return f; };
|
2764
3733
|
if(Array.prototype.indexOf) HxOverrides.remove = function(a,o) {
|
@@ -2820,7 +3789,14 @@ js.XMLHttpRequest = window.XMLHttpRequest?XMLHttpRequest:window.ActiveXObject?fu
|
|
2820
3789
|
}(this));
|
2821
3790
|
com.wiris.js.JsPluginViewer.USE_CREATE_IMAGE = 1;
|
2822
3791
|
com.wiris.js.JsPluginViewer.DEBUG = false;
|
2823
|
-
com.wiris.js.JsPluginViewer.TECH = "
|
3792
|
+
com.wiris.js.JsPluginViewer.TECH = "@param.js.tech.discover@";
|
3793
|
+
com.wiris.js.JsPluginViewer.VERSION = "7.14.0.1422";
|
3794
|
+
com.wiris.system.JsDOMUtils.TOUCHHOLD_MOVE_MARGIN = 10;
|
3795
|
+
com.wiris.system.JsDOMUtils.browser = new com.wiris.system.JsBrowser();
|
3796
|
+
com.wiris.system.JsDOMUtils.initialized = false;
|
3797
|
+
com.wiris.system.JsDOMUtils.touchDeviceListeners = new Array();
|
3798
|
+
com.wiris.system.JsDOMUtils.mouseDeviceListeners = new Array();
|
3799
|
+
com.wiris.system.JsDOMUtils.internetExplorerPointers = new Hash();
|
2824
3800
|
haxe.Serializer.USE_CACHE = false;
|
2825
3801
|
haxe.Serializer.USE_ENUM_INDEX = false;
|
2826
3802
|
haxe.Serializer.BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:";
|