BUGFIX Disabling add_sheet() on jstree, as its horribly slow

This commit is contained in:
Ingo Schommer 2011-04-15 11:15:15 +12:00
parent dafb93fd77
commit 0f7175f1f7
3 changed files with 342 additions and 52 deletions

View File

@ -82,7 +82,8 @@
'theme': 'apple',
'url': 'sapphire/thirdparty/jstree/themes/apple/style.css'
},
// 'plugins': ['html_data', 'ui', 'dnd', 'crrm', 'themeroller']
// Caution: SilverStripe has disabled $.vakata.css.add_sheet() for performance reasons,
// which means you need to add any CSS manually to sapphire/admin/scss/_tree.css
'plugins': [
'html_data', 'ui', 'dnd', 'crrm', 'themes',
'checkbox' // checkboxes are hidden unless .multiple is set

View File

@ -5,7 +5,8 @@
display: block;
margin: 0 0 0 0;
padding: 0 0 0 0;
list-style-type: none; }
list-style-type: none;
}
li {
display: block;
margin: 0 0 0 0;
@ -16,14 +17,16 @@
line-height: 18px;
white-space: nowrap;
margin-left: 18px;
min-width: 18px; }
min-width: 18px;
}
ins {
display: inline-block;
text-decoration: none;
width: 18px;
height: 18px;
margin: 0 0 0 0;
padding: 0; }
padding: 0;
}
a {
display: inline-block;
line-height: 16px;
@ -34,31 +37,314 @@
padding: 1px 2px;
margin: 0;
&:focus {
outline: none; }
outline: none;
}
> {
ins {
height: 16px;
width: 16px; }
width: 16px;
}
.jstree-icon {
margin-right: 3px; } } }
margin-right: 3px;
}
}
}
li {
&.jstree-open > ul {
display: block; }
display: block;
}
&.jstree-closed > ul {
display: none; } }
display: none;
}
}
li.disabled a {
color: #aaaaaa; } }
color: #aaaaaa;
}
}
.jstree-rtl {
a > .jstree-icon {
margin-left: 3px;
margin-right: 0; }
margin-right: 0;
}
li {
margin-left: 0;
margin-right: 18px; } }
margin-right: 18px;
}
}
.jstree-rtl > ul > li {
margin-right: 0px; }
margin-right: 0px;
}
.jstree > ul > li {
margin-left: 0px; }
margin-left: 0px;
}
#vakata-dragged {
display: block;
margin: 0 0 0 0;
padding: 4px 4px 4px 24px;
position: absolute;
top: -2000px;
line-height: 16px;
z-index: 10000;
}
#vakata-contextmenu {
display: block;
visibility: hidden;
left: 0;
top: -200px;
position: absolute;
margin: 0;
padding: 0;
min-width: 180px;
background: #ebebeb;
border: 1px solid silver;
z-index: 10000; *width:180px;
}
#vakata-contextmenu ul {
min-width: 180px; *width:180px;
}
#vakata-contextmenu ul, #vakata-contextmenu li {
margin: 0;
padding: 0;
list-style-type: none;
display: block;
}
#vakata-contextmenu li {
line-height: 20px;
min-height: 20px;
position: relative;
padding: 0px;
}
#vakata-contextmenu li a {
padding: 1px 6px;
line-height: 17px;
display: block;
text-decoration: none;
margin: 1px 1px 0 1px;
}
#vakata-contextmenu li ins {
float: left;
width: 16px;
height: 16px;
text-decoration: none;
margin-right: 2px;
}
#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a {
background: gray;
color: white;
}
#vakata-contextmenu li ul {
display: none;
position: absolute;
top: -2px;
left: 100%;
background: #ebebeb;
border: 1px solid gray;
}
#vakata-contextmenu .right {
right: 100%;
left: auto;
}
#vakata-contextmenu .bottom {
bottom: -1px;
top: auto;
}
#vakata-contextmenu li.vakata-separator {
min-height: 0;
height: 1px;
line-height: 1px;
font-size: 1px;
overflow: hidden;
margin: 0 2px;
background: silver; /* border-top:1px solid #fefefe; */ padding:0;
}
.jstree ul, .jstree li {
display: block;
margin: 0 0 0 0;
padding: 0 0 0 0;
list-style-type: none;
}
.jstree li {
display: block;
min-height: 18px;
line-height: 18px;
white-space: nowrap;
margin-left: 18px;
min-width: 18px;
}
.jstree-rtl li {
margin-left: 0;
margin-right: 18px;
}
.jstree > ul > li {
margin-left: 0px;
}
.jstree-rtl > ul > li {
margin-right: 0px;
}
.jstree ins {
display: inline-block;
text-decoration: none;
width: 18px;
height: 18px;
margin: 0 0 0 0;
padding: 0;
}
.jstree a {
display: inline-block;
line-height: 16px;
height: 16px;
color: black;
white-space: nowrap;
text-decoration: none;
padding: 1px 2px;
margin: 0;
}
.jstree a:focus {
outline: none;
}
.jstree a > ins {
height: 16px;
width: 16px;
}
.jstree a > .jstree-icon {
margin-right: 3px;
}
.jstree-rtl a > .jstree-icon {
margin-left: 3px;
margin-right: 0;
}
li.jstree-open > ul {
display: block;
}
li.jstree-closed > ul {
display: none;
}
#vakata-dragged ins {
display: block;
text-decoration: none;
width: 16px;
height: 16px;
margin: 0 0 0 0;
padding: 0;
position: absolute;
top: 4px;
left: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-border-radius: 4px;
}
#vakata-dragged .jstree-ok {
background: green;
}
#vakata-dragged .jstree-invalid {
background: red;
}
#jstree-marker {
padding: 0;
margin: 0;
font-size: 12px;
overflow: hidden;
height: 12px;
width: 8px;
position: absolute;
top: -30px;
z-index: 10001;
background-repeat: no-repeat;
display: none;
background-color: transparent;
text-shadow: 1px 1px 1px white;
color: black;
line-height: 10px;
}
#jstree-marker-line {
padding: 0;
margin: 0;
line-height: 0%;
font-size: 1px;
overflow: hidden;
height: 1px;
width: 100px;
position: absolute;
top: -30px;
z-index: 10000;
background-repeat: no-repeat;
display: none;
background-color: #456c43;
cursor: pointer;
border: 1px solid #eeeeee;
border-left: 0;
-moz-box-shadow: 0px 0px 2px #666;
-webkit-box-shadow: 0px 0px 2px #666;
box-shadow: 0px 0px 2px #666;
-moz-border-radius: 1px;
border-radius: 1px;
-webkit-border-radius: 1px;
}
.jstree .jstree-real-checkbox {
display: none;
}
.jstree-themeroller .ui-icon {
overflow: visible;
}
.jstree-themeroller a {
padding: 0 2px;
}
.jstree-themeroller .jstree-no-icon {
display: none;
}
.jstree .jstree-wholerow-real {
position: relative;
z-index: 1;
}
.jstree .jstree-wholerow-real li {
cursor: pointer;
}
.jstree .jstree-wholerow-real a {
border-left-color: transparent !important;
border-right-color: transparent !important;
}
.jstree .jstree-wholerow {
position: relative;
z-index: 0;
height: 0;
}
.jstree .jstree-wholerow ul, .jstree .jstree-wholerow li {
width: 100%;
}
.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a {
margin: 0 !important;
padding: 0 !important;
}
.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li {
background: transparent !important;
}
.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input {
display: none !important;
}
.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover {
text-indent: -9999px !important;
width: 100%;
padding: 0 !important;
border-right-width: 0px !important;
border-left-width: 0px !important;
}
.jstree .jstree-wholerow-span {
position: absolute;
left: 0;
margin: 0px;
padding: 0;
height: 18px;
border-width: 0;
padding: 0;
z-index: 0;
}

View File

@ -57,44 +57,47 @@
return $.vakata.css.get_css(rule_name, true, sheet);
},
add_sheet : function(opts) {
var tmp = false, is_new = true;
if(opts.str) {
if(opts.title) { tmp = $("style[id='" + opts.title + "-stylesheet']")[0]; }
if(tmp) { is_new = false; }
else {
tmp = document.createElement("style");
tmp.setAttribute('type',"text/css");
if(opts.title) { tmp.setAttribute("id", opts.title + "-stylesheet"); }
}
if(tmp.styleSheet) {
if(is_new) {
document.getElementsByTagName("head")[0].appendChild(tmp);
tmp.styleSheet.cssText = opts.str;
}
else {
tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str;
}
}
else {
tmp.appendChild(document.createTextNode(opts.str));
document.getElementsByTagName("head")[0].appendChild(tmp);
}
return tmp.sheet || tmp.styleSheet;
}
if(opts.url) {
if(document.createStyleSheet) {
try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
}
else {
tmp = document.createElement('link');
tmp.rel = 'stylesheet';
tmp.type = 'text/css';
tmp.media = "all";
tmp.href = opts.url;
document.getElementsByTagName("head")[0].appendChild(tmp);
return tmp.styleSheet;
}
}
// MODIFIED ischommer/SilverStripe: add_sheet significantly slows down rendering,
// we're loading all required CSS directly rather than adding it inline
// var tmp = false, is_new = true;
// if(opts.str) {
// if(opts.title) { tmp = $("style[id='" + opts.title + "-stylesheet']")[0]; }
// if(tmp) { is_new = false; }
// else {
// tmp = document.createElement("style");
// tmp.setAttribute('type',"text/css");
// if(opts.title) { tmp.setAttribute("id", opts.title + "-stylesheet"); }
// }
// if(tmp.styleSheet) {
// if(is_new) {
// document.getElementsByTagName("head")[0].appendChild(tmp);
// tmp.styleSheet.cssText = opts.str;
// }
// else {
// tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str;
// }
// }
// else {
// tmp.appendChild(document.createTextNode(opts.str));
// document.getElementsByTagName("head")[0].appendChild(tmp);
// }
// return tmp.sheet || tmp.styleSheet;
// }
// if(opts.url) {
// if(document.createStyleSheet) {
// try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
// }
// else {
// tmp = document.createElement('link');
// tmp.rel = 'stylesheet';
// tmp.type = 'text/css';
// tmp.media = "all";
// tmp.href = opts.url;
// document.getElementsByTagName("head")[0].appendChild(tmp);
// return tmp.styleSheet;
// }
// }
}
};