Skip to content

Commit

Permalink
various fixed to make source compatible with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vakata committed Feb 24, 2013
1 parent ddff258 commit 4851b81
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 176 deletions.
172 changes: 88 additions & 84 deletions dist/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@
this.trigger("init");

this._data.core.original_container_html = this.element.find(" > ul > li").clone(true);
this._data.core.original_container_html.find("li").addBack().contents().filter(function() { return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue)); }).remove();
this._data.core.original_container_html
.find("li").addBack()
.contents().filter(function() {
return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
})
.remove();
this.element.html("<"+"ul><"+"li class='jstree-loading'><"+"a class='jstree-anchor' href='#'>" + this.get_string("Loading ...") + "</a></li></ul>");
this.clean_node(-1);
this._data.core.li_height = this.settings.base_height || this.get_container_ul().children("li:eq(0)").height() || 18;
Expand Down Expand Up @@ -1888,9 +1893,9 @@
w1 = oi.width() * oi.length,
w2 = ai.width() * ai.length,
t = typeof default_text === 'string' ? default_text : this.get_text(obj),
h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
h2 = obj.css("position","relative").append(
$("<input />", {
$("<"+"input />", {
"value" : t,
"class" : "jstree-rename-input",
// "size" : t.length,
Expand Down Expand Up @@ -2309,7 +2314,6 @@
/**
* ### Checkbox plugin
*/
// TODO: get undetermined from server too
(function ($) {
$.jstree.defaults.checkbox = {
three_state : true,
Expand Down Expand Up @@ -2403,7 +2407,7 @@
d = t.data('jstree'),
o = t.children('a');
if(!o.children(".jstree-checkbox").length) {
o.prepend("<i class='jstree-icon jstree-checkbox'></i>");
o.prepend("<"+"i class='jstree-icon jstree-checkbox'><"+"/i>");
}
if(d && d.undetermined) {
o.parentsUntil('.jstree', 'li').find('> .jstree-anchor > .jstree-checkbox').addClass('jstree-undetermined');
Expand Down Expand Up @@ -2705,32 +2709,32 @@
sep = false,
tmp;

if(is_callback) { str += "<ul>"; }
if(is_callback) { str += "<"+"ul>"; }
$.each(o, function (i, val) {
if(!val) { return true; }
vakata_context.items.push(val);
if(!sep && val.separator_before) {
str += "<li class='vakata-context-separator'><a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;</a></li>";
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
}
sep = false;
str += "<li class='" + (val._class || "") + (val._disabled ? " vakata-contextmenu-disabled " : "") + "'>";
str += "<a href='#' rel='" + (vakata_context.items.length - 1) + "'>";
str += "<"+"li class='" + (val._class || "") + (val._disabled ? " vakata-contextmenu-disabled " : "") + "'>";
str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "'>";
if($.vakata.context.settings.icons) {
str += "<ins ";
str += "<"+"ins ";
if(val.icon) {
if(val.icon.indexOf("/") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; }
else { str += " class='" + val.icon + "' "; }
}
str += ">&#160;</ins><span>&#160;</span>";
str += ">&#160;<"+"/ins><"+"span>&#160;<"+"/span>";
}
str += val.label + "</a>";
str += val.label + "<"+"/a>";
if(val.submenu) {
tmp = $.vakata.context._parse(val.submenu, true);
if(tmp) { str += tmp; }
}
str += "</li>";
str += "<"+"/li>";
if(val.separator_after) {
str += "<li class='vakata-context-separator'><a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;</a></li>";
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + ">&#160;<"+"/a><"+"/li>";
sep = true;
}
});
Expand Down Expand Up @@ -3078,7 +3082,7 @@
i = ref.parent().index() + 1;
break;
}
/*
/*!
// TODO: moving inside, but the node is not yet loaded?
// the check will work anyway, as when moving the node will be loaded first and checked again
if(v === 'i' && !ins.is_loaded(p)) { }
Expand Down Expand Up @@ -4423,74 +4427,74 @@
var xsl = {
'nest' : '' +
'<' + '?xml version="1.0" encoding="utf-8" ?>' +
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
'<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
'<xsl:template match="/">' +
' <xsl:call-template name="nodes">' +
' <xsl:with-param name="node" select="/root" />' +
' </xsl:call-template>' +
'</xsl:template>' +
'<xsl:template name="nodes">' +
' <xsl:param name="node" />' +
' <ul>' +
' <xsl:for-each select="$node/item">' +
' <xsl:variable name="children" select="count(./item) &gt; 0" />' +
' <li>' +
' <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute></xsl:for-each>' +
' <a>' +
' <xsl:for-each select="./content/@*"><xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute></xsl:for-each>' +
' <xsl:copy-of select="./content/child::node()" />' +
' </a>' +
' <xsl:if test="$children"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
' </li>' +
' </xsl:for-each>' +
' </ul>' +
'</xsl:template>' +
'</xsl:stylesheet>',
'<'+'xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
'<'+'xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
'<'+'xsl:template match="/">' +
' <'+'xsl:call-template name="nodes">' +
' <'+'xsl:with-param name="node" select="/root" />' +
' <'+'/xsl:call-template>' +
'<'+'/xsl:template>' +
'<'+'xsl:template name="nodes">' +
' <'+'xsl:param name="node" />' +
' <'+'ul>' +
' <'+'xsl:for-each select="$node/item">' +
' <'+'xsl:variable name="children" select="count(./item) &gt; 0" />' +
' <'+'li>' +
' <'+'xsl:for-each select="@*"><'+'xsl:attribute name="{name()}"><'+'xsl:value-of select="." /><'+'/xsl:attribute><'+'/xsl:for-each>' +
' <'+'a>' +
' <'+'xsl:for-each select="./content/@*"><'+'xsl:attribute name="{name()}"><'+'xsl:value-of select="." /><'+'/xsl:attribute><'+'/xsl:for-each>' +
' <'+'xsl:copy-of select="./content/child::node()" />' +
' <'+'/a>' +
' <'+'xsl:if test="$children"><'+'xsl:call-template name="nodes"><'+'xsl:with-param name="node" select="current()" /><'+'/xsl:call-template><'+'/xsl:if>' +
' <'+'/li>' +
' <'+'/xsl:for-each>' +
' <'+'/ul>' +
'<'+'/xsl:template>' +
'<'+'/xsl:stylesheet>',
'flat' : '' +
'<' + '?xml version="1.0" encoding="utf-8" ?>' +
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
'<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
'<xsl:template match="/">' +
' <ul>' +
' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
' <xsl:call-template name="nodes">' +
' <xsl:with-param name="node" select="." />' +
' </xsl:call-template>' +
' </xsl:for-each>' +
' </ul>' +
'</xsl:template>' +
'<xsl:template name="nodes">' +
' <xsl:param name="node" />' +
' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
' <li>' +
' <xsl:for-each select="@*">' +
' <xsl:if test="name() != \'parent_id\'">' +
' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
' </xsl:if>' +
' </xsl:for-each>' +
' <a>' +
' <xsl:for-each select="./content/@*"><xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute></xsl:for-each>' +
' <xsl:copy-of select="./content/child::node()" />' +
' </a>' +
' <xsl:if test="$children">' +
' <ul>' +
' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
' <xsl:call-template name="nodes">' +
' <xsl:with-param name="node" select="." />' +
' </xsl:call-template>' +
' </xsl:for-each>' +
' </ul>' +
' </xsl:if>' +
' </li>' +
'</xsl:template>' +
'</xsl:stylesheet>'
'<'+'xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
'<'+'xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
'<'+'xsl:template match="/">' +
' <'+'ul>' +
' <'+'xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
' <'+'xsl:call-template name="nodes">' +
' <'+'xsl:with-param name="node" select="." />' +
' <'+'/xsl:call-template>' +
' <'+'/xsl:for-each>' +
' <'+'/ul>' +
'<'+'/xsl:template>' +
'<'+'xsl:template name="nodes">' +
' <'+'xsl:param name="node" />' +
' <'+'xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
' <'+'li>' +
' <'+'xsl:for-each select="@*">' +
' <'+'xsl:if test="name() != \'parent_id\'">' +
' <'+'xsl:attribute name="{name()}"><'+'xsl:value-of select="." /><'+'/xsl:attribute>' +
' <'+'/xsl:if>' +
' <'+'/xsl:for-each>' +
' <'+'a>' +
' <'+'xsl:for-each select="./content/@*"><'+'xsl:attribute name="{name()}"><'+'xsl:value-of select="." /><'+'/xsl:attribute><'+'/xsl:for-each>' +
' <'+'xsl:copy-of select="./content/child::node()" />' +
' <'+'/a>' +
' <'+'xsl:if test="$children">' +
' <'+'ul>' +
' <'+'xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
' <'+'xsl:call-template name="nodes">' +
' <'+'xsl:with-param name="node" select="." />' +
' <'+'/xsl:call-template>' +
' <'+'/xsl:for-each>' +
' <'+'/ul>' +
' <'+'/xsl:if>' +
' <'+'/li>' +
'<'+'/xsl:template>' +
'<'+'/xsl:stylesheet>'
},
escape_xml = function(string) {
return string
.toString()
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/<'+'/g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
Expand All @@ -4516,7 +4520,7 @@
}
if(dom === -1) { dom = this.element; }
if(!dom.length) { return false; }
if(!dom.children('ul').length) { dom.append('<ul />'); }
if(!dom.children('ul').length) { dom.append('<'+'ul />'); }
dom.children('ul').empty().append(data.is('ul') ? data.children('li') : data);
return true;
};
Expand Down Expand Up @@ -4569,9 +4573,9 @@
}, this));
return '' +
'<' + '?xml version="1.0" encoding="utf-8" ?>' +
'<root>' + r + '</root>';
'<'+'root>' + r + '<'+'/root>';
}
r += '<item';
r += '<'+'item';
if(mode === 'flat' && is_callback !== true) {
r += ' parent_id="' + escape_xml(is_callback) + '"';
}
Expand All @@ -4586,19 +4590,19 @@
r += ' ' + i + '="' + escape_xml(v) + '"';
});
r += '>';
r += '<content';
r += '<'+'content';
$.each(obj.a_attr, function (i, v) {
r += ' ' + i + '="' + escape_xml(v) + '"';
});
r += '><![CDATA[' + obj.title + ']]></content>';
r += '><'+'![CDATA[' + obj.title + ']]><'+'/content>';

if(mode === 'flat') { r += '</item>'; }
if(mode === 'flat') { r += '<'+'/item>'; }
if(obj.children) {
$.each(obj.children, $.proxy(function (i, v) {
r += this.get_xml(mode, v, obj.li_attr && obj.li_attr.id ? obj.li_attr.id : true);
}, this));
}
if(mode === 'nest') { r += '</item>'; }
if(mode === 'nest') { r += '<'+'/item>'; }
return r;
};
};
Expand All @@ -4615,7 +4619,7 @@
p = new XSLTProcessor();
p.importStylesheet(xs);
r = p.transformToFragment(xm, document);
return $('<div />').append(r).html();
return $('<'+'div />').append(r).html();
}
// OLD IE
if(typeof (xm.transformNode) !== "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions dist/jstree.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4851b81

Please sign in to comment.