Skip to content

Commit

Permalink
Editor sec fix, toolbar reponsiveness tracking fix, responsive
Browse files Browse the repository at this point in the history
contextmenu. v4.9.10
  • Loading branch information
pphod committed Sep 18, 2021
1 parent 8213c82 commit fe1d3cc
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 30 deletions.
34 changes: 34 additions & 0 deletions dist/jsuites.basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,40 @@
pointer-events: auto;
}

@media only screen and (max-width: 420px) {
.jcontextmenu {
top: initial !important;
left: 0px !important;
bottom: 0px !important;
width: 100vw;
height: 260px;
overflow: scroll;
animation: slide-bottom-in 0.4s forwards;
}
.jcontextmenu div {
width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
padding: 15px;
}
.jcontextmenu > div::before {
display: none;
}
.jcontextmenu a {
font-size: 1.4em;
text-transform: uppercase;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu hr {
display: none;
}
}

.jdropdown {
cursor:pointer;
-webkit-touch-callout: none;
Expand Down
29 changes: 19 additions & 10 deletions dist/jsuites.basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

var jSuites = function(options) {
var obj = {}
var version = '4.9.9';
var version = '4.4.0';

var find = function(DOMElement, component) {
if (DOMElement[component.type] && DOMElement[component.type] == component) {
Expand Down Expand Up @@ -5271,7 +5271,7 @@ jSuites.editor = (function(el, options) {
}

// Elements to be removed
var remove = [HTMLUnknownElement];
var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];

// Valid CSS attributes
var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
Expand All @@ -5296,9 +5296,9 @@ jSuites.editor = (function(el, options) {
}
}
// Process image
if (element.tagName == 'IMG') {
if (element.tagName.toUpperCase() == 'IMG') {
if (! obj.options.acceptImages) {
element.remove();
element.parentNode.removeChild(element);
} else {
// Check if is data
element.setAttribute('tabindex', '900');
Expand Down Expand Up @@ -5334,9 +5334,11 @@ jSuites.editor = (function(el, options) {
if (data) {
data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
}
var parser = new DOMParser();
var d = parser.parseFromString(data, "text/html");
parse(d);
var span = document.createElement('span');
span.innerHTML = data;
parse(span);
span.innerHTML = d.firstChild.innerHTML;
return span;
}

Expand Down Expand Up @@ -9114,7 +9116,8 @@ jSuites.tabs = (function(el, options) {
});

jSuites.toolbar = (function(el, options) {
var obj = {};
// New instance
var obj = { type:'toolbar' };
obj.options = {};

// Default configuration
Expand All @@ -9124,6 +9127,7 @@ jSuites.toolbar = (function(el, options) {
badge: false,
title: false,
responsive: false,
maxWidth: null,
items: [],
}

Expand Down Expand Up @@ -9322,16 +9326,21 @@ jSuites.toolbar = (function(el, options) {

obj.refresh = function() {
if (obj.options.responsive == true) {
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
if (! obj.options.maxWidth) {
obj.options.maxWidth = rect.width;
}
// Max width
var width = parseInt(obj.options.maxWidth);
// Remove arrow
toolbarArrow.remove();
// Move all items to the toolbar
while (toolbarFloating.firstChild) {
toolbarContent.appendChild(toolbarFloating.firstChild);
}
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
// Available parent space
var available = rect.width;
var available = obj.options.maxWidth;
// Toolbar is larger than the parent, move elements to the floating element
if (available < toolbarContent.offsetWidth) {
// Give space to the floating element
Expand Down
34 changes: 34 additions & 0 deletions dist/jsuites.css
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,40 @@
pointer-events: auto;
}

@media only screen and (max-width: 420px) {
.jcontextmenu {
top: initial !important;
left: 0px !important;
bottom: 0px !important;
width: 100vw;
height: 260px;
overflow: scroll;
animation: slide-bottom-in 0.4s forwards;
}
.jcontextmenu div {
width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
padding: 15px;
}
.jcontextmenu > div::before {
display: none;
}
.jcontextmenu a {
font-size: 1.4em;
text-transform: uppercase;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu hr {
display: none;
}
}

.jdropdown {
cursor:pointer;
-webkit-touch-callout: none;
Expand Down
29 changes: 19 additions & 10 deletions dist/jsuites.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

var jSuites = function(options) {
var obj = {}
var version = '4.9.9';
var version = '4.4.0';

var find = function(DOMElement, component) {
if (DOMElement[component.type] && DOMElement[component.type] == component) {
Expand Down Expand Up @@ -5282,7 +5282,7 @@ jSuites.editor = (function(el, options) {
}

// Elements to be removed
var remove = [HTMLUnknownElement];
var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];

// Valid CSS attributes
var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
Expand All @@ -5307,9 +5307,9 @@ jSuites.editor = (function(el, options) {
}
}
// Process image
if (element.tagName == 'IMG') {
if (element.tagName.toUpperCase() == 'IMG') {
if (! obj.options.acceptImages) {
element.remove();
element.parentNode.removeChild(element);
} else {
// Check if is data
element.setAttribute('tabindex', '900');
Expand Down Expand Up @@ -5345,9 +5345,11 @@ jSuites.editor = (function(el, options) {
if (data) {
data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
}
var parser = new DOMParser();
var d = parser.parseFromString(data, "text/html");
parse(d);
var span = document.createElement('span');
span.innerHTML = data;
parse(span);
span.innerHTML = d.firstChild.innerHTML;
return span;
}

Expand Down Expand Up @@ -11019,7 +11021,8 @@ jSuites.tags = (function(el, options) {
});

jSuites.toolbar = (function(el, options) {
var obj = {};
// New instance
var obj = { type:'toolbar' };
obj.options = {};

// Default configuration
Expand All @@ -11029,6 +11032,7 @@ jSuites.toolbar = (function(el, options) {
badge: false,
title: false,
responsive: false,
maxWidth: null,
items: [],
}

Expand Down Expand Up @@ -11227,16 +11231,21 @@ jSuites.toolbar = (function(el, options) {

obj.refresh = function() {
if (obj.options.responsive == true) {
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
if (! obj.options.maxWidth) {
obj.options.maxWidth = rect.width;
}
// Max width
var width = parseInt(obj.options.maxWidth);
// Remove arrow
toolbarArrow.remove();
// Move all items to the toolbar
while (toolbarFloating.firstChild) {
toolbarContent.appendChild(toolbarFloating.firstChild);
}
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
// Available parent space
var available = rect.width;
var available = obj.options.maxWidth;
// Toolbar is larger than the parent, move elements to the floating element
if (available < toolbarContent.offsetWidth) {
// Give space to the floating element
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"javascript plugins"
],
"main": "dist/jsuites.js",
"version": "4.9.9",
"version": "4.9.10",
"bugs": "https://github.com/jsuites/jsuites/issues",
"homepage": "https://github.com/jsuites/jsuites",
"docs": "https://jsuites.net",
Expand Down
34 changes: 34 additions & 0 deletions src/contextmenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,38 @@
-webkit-transform: translate(0, 0) scale(1);
transform: translate(0, 0) scale(1);
pointer-events: auto;
}

@media only screen and (max-width: 420px) {
.jcontextmenu {
top: initial !important;
left: 0px !important;
bottom: 0px !important;
width: 100vw;
height: 260px;
overflow: scroll;
animation: slide-bottom-in 0.4s forwards;
}
.jcontextmenu div {
width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
padding: 15px;
}
.jcontextmenu > div::before {
display: none;
}
.jcontextmenu a {
font-size: 1.4em;
text-transform: uppercase;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu span {
display: none;
}
.jcontextmenu hr {
display: none;
}
}
12 changes: 7 additions & 5 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ jSuites.editor = (function(el, options) {
}

// Elements to be removed
var remove = [HTMLUnknownElement];
var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];

// Valid CSS attributes
var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
Expand All @@ -749,9 +749,9 @@ jSuites.editor = (function(el, options) {
}
}
// Process image
if (element.tagName == 'IMG') {
if (element.tagName.toUpperCase() == 'IMG') {
if (! obj.options.acceptImages) {
element.remove();
element.parentNode.removeChild(element);
} else {
// Check if is data
element.setAttribute('tabindex', '900');
Expand Down Expand Up @@ -787,9 +787,11 @@ jSuites.editor = (function(el, options) {
if (data) {
data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
}
var parser = new DOMParser();
var d = parser.parseFromString(data, "text/html");
parse(d);
var span = document.createElement('span');
span.innerHTML = data;
parse(span);
span.innerHTML = d.firstChild.innerHTML;
return span;
}

Expand Down
15 changes: 11 additions & 4 deletions src/toolbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jSuites.toolbar = (function(el, options) {
var obj = {};
// New instance
var obj = { type:'toolbar' };
obj.options = {};

// Default configuration
Expand All @@ -9,6 +10,7 @@ jSuites.toolbar = (function(el, options) {
badge: false,
title: false,
responsive: false,
maxWidth: null,
items: [],
}

Expand Down Expand Up @@ -207,16 +209,21 @@ jSuites.toolbar = (function(el, options) {

obj.refresh = function() {
if (obj.options.responsive == true) {
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
if (! obj.options.maxWidth) {
obj.options.maxWidth = rect.width;
}
// Max width
var width = parseInt(obj.options.maxWidth);
// Remove arrow
toolbarArrow.remove();
// Move all items to the toolbar
while (toolbarFloating.firstChild) {
toolbarContent.appendChild(toolbarFloating.firstChild);
}
// Width of the c
var rect = el.parentNode.getBoundingClientRect();
// Available parent space
var available = rect.width;
var available = obj.options.maxWidth;
// Toolbar is larger than the parent, move elements to the floating element
if (available < toolbarContent.offsetWidth) {
// Give space to the floating element
Expand Down

0 comments on commit fe1d3cc

Please sign in to comment.