Skip to content

Commit 621c197

Browse files
Adding Joe's extensions
1 parent 27d41f9 commit 621c197

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Background Image Swapper
2+
3+
![Screenshot](https://github.com/optimizely/extension-library/blob/master/Extensions/Editor%20Extensions/Background%20Image%20Swapper/screenshot.png)
4+
5+
## Description
6+
7+
Extension to replace a background image as soon as Optimizely loads so as to prevent any chance of flickering using CSS important tags.
8+
9+
## Fields
10+
11+
* Image Selector
12+
* Image SRC
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"plugin_type": "widget",
3+
"name": "Background Image Swapper",
4+
"edit_page_url": "https://www.optimizely.com/homepage/",
5+
"form_schema": [
6+
{
7+
"default_value": ".js-hero",
8+
"field_type": "selector",
9+
"name": "imageSelector",
10+
"label": "Image Selector",
11+
"options": null
12+
},
13+
{
14+
"default_value": "https://res.cloudinary.com/dy8i0qezub/image/upload/f_auto,q_65/p13n-homepage/Optimizely-Home.jpg",
15+
"field_type": "image",
16+
"name": "src",
17+
"label": "Image SRC",
18+
"options": null
19+
}
20+
],
21+
"description": "Swaps a background image on the page when Optimizely initially loads to prevent flicker.",
22+
"options": {
23+
"html": "",
24+
"css": "",
25+
"apply_js": "function imageSwap() {\n var selector = extension.imageSelector;\n\tvar rawCSS = \"{background-image: url(\" + extension.src + \" ) !important}\";\n applyCSS(selector, rawCSS, \"optimizely-extension-\");\n}\n\nfunction applyCSS(selector, rawCSS) {\n var css = selector + \" \" + rawCSS;\n var style = document.createElement('style');\n style.type = 'text/css';\n style.className = \"optimizely-extension-\" + extension.$instance;\n if (style.styleSheet){\n style.styleSheet.cssText = css; \n } else {\n style.appendChild(document.createTextNode(css));\n }\n document.head.appendChild(style);\n}\n\nimageSwap();",
26+
"undo_js": "// document.querySelector('.optimizely-extension-' + extension.$instance).remove();"
27+
}
28+
}
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Text Swapper
2+
3+
![Screenshot](https://github.com/optimizely/extension-library/blob/master/Extensions/Editor%20Extensions/Text%20Swapper/screenshot.png)
4+
5+
## Description
6+
7+
Extension to replace a text element as soon as Optimizely loads so as to prevent any chance of flicker. This is especially useful for testing above the fold on sites that load quickly where an element may be displayed before Optimizely is able to detect it.
8+
9+
## Fields
10+
11+
* CSS Path
12+
* Text
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"plugin_type": "widget",
3+
"name": "Text Swapper",
4+
"edit_page_url": "https://www.optimizely.com/",
5+
"form_schema": [
6+
{
7+
"default_value": ".optly-header-one",
8+
"field_type": "selector",
9+
"name": "cssPath",
10+
"label": "CSS Path",
11+
"options": null
12+
},
13+
{
14+
"default_value": "Hello World",
15+
"field_type": "text",
16+
"name": "text",
17+
"label": "Text",
18+
"options": null
19+
}
20+
],
21+
"description": "Hides and swaps text while mitigating any risk of page flashing",
22+
"options": {
23+
"html": "",
24+
"css": "",
25+
"apply_js": "function init() {\n tempHide();\n swapText(extension.cssPath, extension.text);\n showContent();\n}\n\nfunction swapText(cssPath, text) {\n var selector = document.querySelector(cssPath);\n if (selector && text) {\n \tselector.innerHTML = text;\n }\n}\n\nfunction tempHide(item) {\n\tvar selector = item || \"body\";\n\tvar css = selector + \" {visibility:hidden !important}\";\n\tvar style = document.createElement('style');\n\tstyle.type = 'text/css';\n\tstyle.className = \"optly-hide-\" + extension.$instance;\n\tif (style.styleSheet) {\n\t\tstyle.styleSheet.cssText = css;\n\t} else {\n\t\tstyle.appendChild(document.createTextNode(css));\n\t}\n\tdocument.head.appendChild(style);\n}\n\nfunction showContent() {\n\tvar styleSheet = document.querySelector(\"style.optly-hide-\" + extension.$instance);\n if (styleSheet) {\n\t\tstyleSheet.remove();\n }\n}\n\ninit();",
26+
"undo_js": "//document.querySelector('#optimizely-extension-' + extension.$instance).remove();"
27+
}
28+
}
Loading

0 commit comments

Comments
 (0)