From 75658806488f491a61f408e2d1beca1b1afd018e Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Tue, 7 Jan 2014 19:12:20 +0530 Subject: [PATCH] [ADD]: automatically generate a menu from h1 and h2 tag in the content bzr revid: aja@tinyerp.com-20140107134220-nhff7fw6bpz8jhjb --- .../data/website_quotation_demo.xml | 5 +- .../static/src/css/website_quotation.css | 3 + .../static/src/js/website_quotation.js | 29 +- .../views/website_quotation.xml | 282 +++++++++--------- 4 files changed, 172 insertions(+), 147 deletions(-) create mode 100644 addons/website_quotation/static/src/css/website_quotation.css diff --git a/addons/website_quotation/data/website_quotation_demo.xml b/addons/website_quotation/data/website_quotation_demo.xml index de7d6bb4e07..84b6aec79f1 100644 --- a/addons/website_quotation/data/website_quotation_demo.xml +++ b/addons/website_quotation/data/website_quotation_demo.xml @@ -297,7 +297,7 @@ 12950.00
-

Online Training + Certification

+

Online Training + Certification

@@ -339,6 +339,9 @@ 1 00.00 +
+

Technical Training

+
diff --git a/addons/website_quotation/static/src/css/website_quotation.css b/addons/website_quotation/static/src/css/website_quotation.css new file mode 100644 index 00000000000..f44cf367e97 --- /dev/null +++ b/addons/website_quotation/static/src/css/website_quotation.css @@ -0,0 +1,3 @@ +.affix { + width : 260px; +} diff --git a/addons/website_quotation/static/src/js/website_quotation.js b/addons/website_quotation/static/src/js/website_quotation.js index 29bdcbc1f31..2fcf5d7c832 100644 --- a/addons/website_quotation/static/src/js/website_quotation.js +++ b/addons/website_quotation/static/src/js/website_quotation.js @@ -22,5 +22,32 @@ $(document).ready(function () { }); return false; }); -}); + + // automatically generate a menu from h1 and h1 tag in content + var ul = null; + var sub_li = null; + var sub_ul = null; + + $("section h1, section h2").each(function() { + switch (this.tagName.toLowerCase()) { + case "h1": + if (!ul) { + ul = $('[data-id="quote_sidebar"]'); + } + sub_li = $("
  • ").html('').appendTo(ul); + sub_ul = null; + break; + case "h2": + id = _.uniqueId('quote_') + if (sub_li) { + if (!sub_ul) { + sub_ul = $("