This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 0842e11 Revert "Static initializers loading hljs in TDJ."
0842e11 is described below
commit 0842e11ede8bb28cddd3c2bd7c4fa092989defe8
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Tue Jun 2 10:06:38 2020 +0300
Revert "Static initializers loading hljs in TDJ."
This reverts commit 99a8c8356573ff16b668f2d39a447355c673fee3.
---
.../ExampleAndSourceCodeTabbedSectionContent.as | 6 +-
examples/jewel/TourDeJewel/src/main/royale/hljs.as | 12 +++
.../TourDeJewel/src/main/royale/hljsFacade.as | 91 ----------------------
3 files changed, 17 insertions(+), 92 deletions(-)
diff --git
a/examples/jewel/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
b/examples/jewel/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
index 582c7ca..bafa4ab 100644
---
a/examples/jewel/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
+++
b/examples/jewel/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
@@ -136,7 +136,11 @@ package components
public function dataReadyHandler(event:Event):void
{
sourceCodeMXMLText.text = event.target.sourceCode;
- hljsFacade.highlightBlock(sourceCodeMXMLText);
+
+ COMPILE::JS
+ {
+ hljs.highlightBlock(sourceCodeMXMLText.element);
+ }
}
/**
diff --git a/examples/jewel/TourDeJewel/src/main/royale/hljs.as
b/examples/jewel/TourDeJewel/src/main/royale/hljs.as
index 7f192f0..92d4c98 100644
--- a/examples/jewel/TourDeJewel/src/main/royale/hljs.as
+++ b/examples/jewel/TourDeJewel/src/main/royale/hljs.as
@@ -24,6 +24,18 @@ package
COMPILE::JS
public class hljs
{
+ /**
+ * <inject_script>
+ * var script = document.createElement("script");
+ * script.setAttribute("src",
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js");
+ * document.head.appendChild(script);
+ * var link = document.createElement("link");
+ * link.setAttribute("rel", "stylesheet");
+ * link.setAttribute("type", "text/css");
+ * link.setAttribute("href",
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css");
+ * document.head.appendChild(link);
+ * </inject_script>
+ */
public function hljs(){}
public static function highlightBlock(block:Element):void {}
diff --git a/examples/jewel/TourDeJewel/src/main/royale/hljsFacade.as
b/examples/jewel/TourDeJewel/src/main/royale/hljsFacade.as
deleted file mode 100644
index 3724e35..0000000
--- a/examples/jewel/TourDeJewel/src/main/royale/hljsFacade.as
+++ /dev/null
@@ -1,91 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package
-{
- import org.apache.royale.utils.css.loadCSS;
- import org.apache.royale.utils.js.loadJavascript;
- import org.apache.royale.core.IRenderedObject;
- public class hljsFacade
- {
- private static var jsId:String = getJs();
- private static var cssId:String = getCss();
- private static var jsLoaded:Boolean;
- private static var cssLoaded:Boolean;
- private static var objectsToHighlight:Array;
-
- private static function getJs():String
- {
-
loadJavascript("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js",
jsLoadedHandler);
- return null;
- }
-
- private static function getCss():String
- {
- return
loadCSS("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css",
cssLoadedHandler);
- }
-
- private static function doDeferredHighLights():void
- {
- if (!objectsToHighlight)
- {
- return;
- }
- while (objectsToHighlight.length > 0)
- {
- highlightBlock(objectsToHighlight.shift() as
IRenderedObject);
- }
- }
-
- private static function jsLoadedHandler():void
- {
- jsLoaded = true;
- if (cssLoaded)
- {
- doDeferredHighLights();
- }
- }
-
- private static function cssLoadedHandler():void
- {
- cssLoaded = true;
- if (jsLoaded)
- {
- doDeferredHighLights();
- }
- }
-
- public static function
highlightBlock(renderedObject:IRenderedObject):void
- {
- if (jsLoaded && cssLoaded)
- {
- COMPILE::JS
- {
-
hljs.highlightBlock(renderedObject.element);
- }
- } else
- {
- if (!objectsToHighlight)
- {
- objectsToHighlight = [];
- }
- objectsToHighlight.push(renderedObject);
- }
- }
- }
-}