Skip to content

Commit fab3c58

Browse files
author
Angelo Dini
committed
Merge pull request django-cms#2270 from jonprindiville/jstree-rel-marker-gif
Fixes jsTree's relative URL construction for theme components
2 parents f64bd67 + d1ecf1a commit fab3c58

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

cms/static/cms/js/plugins/cms.changelist.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ $(document).ready(function () {
5454
return this.after(o).remove().end();
5555
};
5656

57+
// For passing in to jsTree's settings.ui.theme_path in order to enable
58+
// it to construct a proper relative URL for its assets. If theme_path
59+
// remains false, jsTree will construct a path using the contents of the
60+
// location bar. In the case that static files (including jsTree's
61+
// javascript) are served from a location other than that of the HTML
62+
// files, the URLs constructed will be incorrect.
63+
function script_url_path() {
64+
// Find the URL that loaded this script (not sure if we can
65+
// programatically determine the name of the current script, so it is
66+
// hardcoded here)
67+
full_url = $('script[src*="/cms.changelist.js"]').attr('src');
68+
// Return everything but the filename
69+
return full_url.slice(0,full_url.lastIndexOf('/'));
70+
}
71+
72+
5773
var tree;
5874
// global initTree function
5975
initTree = function(){
@@ -77,7 +93,7 @@ $(document).ready(function () {
7793
rtl: false,
7894
animation: 0,
7995
hover_mode: true,
80-
theme_path: false,
96+
theme_path: script_url_path() + "/../jstree/themes/",
8197
theme_name: "default",
8298
a_class: "title"
8399
},
@@ -537,4 +553,4 @@ $(document).ready(function () {
537553
}
538554

539555
});
540-
})(CMS.$);
556+
})(CMS.$);

0 commit comments

Comments
 (0)