This is an automated email from the ASF dual-hosted git repository.
jamesyong pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new 1f9c300 Improved: Move page-specific script links to html template (OFBIZ-11799) 1f9c300 is described below commit 1f9c3000271e7a12e9c79105f0a8d6c9117fdf0e Author: James Yong <[hidden email]> AuthorDate: Sat Aug 22 21:11:20 2020 +0800 Improved: Move page-specific script links to html template (OFBIZ-11799) Use importLibrary js function to load jstree and cookie js in ContentNav.ftl and CategoryTree.ftl. Tested on /content/control/navigateContent /humanres/control/main --- .../content/template/content/ContentNav.ftl | 81 ++++++++++++---------- .../content/widget/content/ContentScreens.xml | 2 +- .../humanres/template/category/CategoryTree.ftl | 78 +++++++++++---------- 3 files changed, 87 insertions(+), 74 deletions(-) diff --git a/applications/content/template/content/ContentNav.ftl b/applications/content/template/content/ContentNav.ftl index 42e31df..d527e38 100644 --- a/applications/content/template/content/ContentNav.ftl +++ b/applications/content/template/content/ContentNav.ftl @@ -16,7 +16,6 @@ specific language governing permissions and limitations under the License. --> -<script type="application/javascript" src="<@ofbizContentUrl>/common/js/jquery/plugins/jsTree/jquery.jstree.js</@ofbizContentUrl>"></script> <script type="application/javascript"> <#-- some labels are not unescaped in the JSON object so we have to do this manuely --> @@ -65,44 +64,50 @@ jQuery(document).ready(createTree()); <#-------------------------------------------------------------------------------------create Tree--> function createTree() { jQuery(function () { - jQuery("#tree").jstree({ - "plugins" : [ "themes", "json_data", "ui", "contextmenu", "crrm"], - "json_data" : { - "data" : rawdata, - "progressive_render" : false - }, - 'contextmenu': { - 'items': { - 'ccp' : false, - 'create' : false, - 'rename' : false, - 'remove' : false, - 'create1' : { - 'label' : "New Folder", - 'action' : function(obj) { - callCreateDocumentTree(obj.attr('id')); - } - }, - 'create2' : { - 'label' : "New Content in Folder", - 'action' : function(obj) { - callCreateDocument(obj.attr('id')); - } - }, - 'rename1' : { - 'label' : "Rename Folder", - 'action' : function(obj) { - callRenameDocumentTree(obj.attr('id')); - } - }, - 'delete1' : { - 'label' : "Delete Folder", - 'action' : function(obj) { - callDeleteDocument(obj.attr('id'), obj.attr('contentId'), obj.attr('AssocType'), obj.attr('fromDate')); - } - }, + importLibrary(["/common/js/jquery/plugins/jsTree/jquery.jstree.js"], function(){ + jQuery("#tree").jstree({ + "plugins" : [ "themes", "json_data", "ui", "contextmenu", "crrm"], + "json_data" : { + "data" : rawdata, + "progressive_render" : false + }, + 'contextmenu': { + 'items': { + 'ccp' : false, + 'create' : false, + 'rename' : false, + 'remove' : false, + 'create1' : { + 'label' : "New Folder", + 'action' : function(obj) { + callCreateDocumentTree(obj.attr('id')); + } + }, + 'create2' : { + 'label' : "New Content in Folder", + 'action' : function(obj) { + callCreateDocument(obj.attr('id')); + } + }, + 'rename1' : { + 'label' : "Rename Folder", + 'action' : function(obj) { + callRenameDocumentTree(obj.attr('id')); + } + }, + 'delete1' : { + 'label' : "Delete Folder", + 'action' : function(obj) { + callDeleteDocument(obj.attr('id'), obj.attr('contentId'), obj.attr('AssocType'), obj.attr('fromDate')); + } + }, + } + }, + "themes": { + "theme":"default", + "url":"/common/js/jquery/plugins/jsTree/themes/default/style.css" } - } + }); }); }); } diff --git a/applications/content/widget/content/ContentScreens.xml b/applications/content/widget/content/ContentScreens.xml index fd032a5..85e01a2 100644 --- a/applications/content/widget/content/ContentScreens.xml +++ b/applications/content/widget/content/ContentScreens.xml @@ -133,7 +133,7 @@ under the License. <widgets> <platform-specific> <html> - <html-template location="component://content/template/content/ContentNav.ftl"/> + <html-template multi-block="true" location="component://content/template/content/ContentNav.ftl"/> </html> </platform-specific> </widgets> diff --git a/applications/humanres/template/category/CategoryTree.ftl b/applications/humanres/template/category/CategoryTree.ftl index b1b7465..27ab9ee 100644 --- a/applications/humanres/template/category/CategoryTree.ftl +++ b/applications/humanres/template/category/CategoryTree.ftl @@ -17,8 +17,6 @@ specific language governing permissions and limitations under the License. --> -<script src="/common/js/jquery/plugins/jsTree/jquery.jstree.js" type="application/javascript" data-import="head"></script> - <script type="application/javascript"> <#-- some labels are not unescaped in the JSON object so we have to do this manualy --> function unescapeHtmlText(text) { @@ -54,43 +52,53 @@ var rawdata = [ <#-- create Tree--> function createTree() { - jQuery(function () { - $.cookie('jstree_select', null); - $.cookie('jstree_open', null); - - jQuery("#tree").jstree({ - "core" : { "initially_open" : [ "${partyId}" ] }, - "plugins" : [ "themes", "json_data","ui" ,"cookies", "types", "crrm", "contextmenu"], - "json_data" : { - "data" : rawdata, - "ajax" : { "url" : "<@ofbizUrl>getHRChild</@ofbizUrl>", "type" : "POST", - "data" : function (n) { - return { - "partyId" : n.attr ? n.attr("id").replace("node_","") : 1 , - "additionParam" : "','category" , - "hrefString" : "viewprofile?partyId=" , - "onclickFunction" : "callDocument" - }; - }, - success : function(data) { - return data.hrTree; + jQuery(function () { + var libraryFiles = ["/common/js/jquery/ui/js/jquery.cookie-1.4.0.js", + "/common/js/jquery/plugins/jsTree/jquery.jstree.js"]; + importLibrary(libraryFiles, function(){ + + $.cookie('jstree_select', null); + $.cookie('jstree_open', null); + + jQuery("#tree").jstree({ + "core" : { "initially_open" : [ "${partyId}" ] }, + "plugins" : [ "themes", "json_data","ui" ,"cookies", "types", "crrm", "contextmenu"], + "json_data" : { + "data" : rawdata, + "ajax" : { "url" : "<@ofbizUrl>getHRChild</@ofbizUrl>", "type" : "POST", + "data" : function (n) { + return { + "partyId" : n.attr ? n.attr("id").replace("node_","") : 1 , + "additionParam" : "','category" , + "hrefString" : "viewprofile?partyId=" , + "onclickFunction" : "callDocument" + }; + }, + success : function(data) { + return data.hrTree; + } } - } - }, - "types" : { - "valid_children" : [ "root" ], - "types" : { - "CATEGORY" : { - "icon" : { - "image" : "/common/js/jquery/plugins/jsTree/themes/apple/d.png", - "position" : "10px40px" + }, + "types" : { + "valid_children" : [ "root" ], + "types" : { + "CATEGORY" : { + "icon" : { + "image" : "/common/js/jquery/plugins/jsTree/themes/apple/d.png", + "position" : "10px40px" + } } } - } - }, - "contextmenu": {items: customMenu} + }, + "contextmenu": {items: customMenu}, + "themes": { + "theme":"default", + "url":"/common/js/jquery/plugins/jsTree/themes/default/style.css" + } + + }); }); - }); + }); } function callDocument(id,type) { |
Free forum by Nabble | Edit this page |