{"id":2770,"date":"2015-03-31T20:21:29","date_gmt":"2015-03-31T16:21:29","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2770"},"modified":"2023-05-05T13:43:48","modified_gmt":"2023-05-05T10:43:48","slug":"soft-closed-windows","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/soft-closed-windows\/","title":{"rendered":"DHTMLX Little-Known Features: &#8220;Soft-Closed&#8221; Windows"},"content":{"rendered":"<p><strong>Update: This feature was deprecated. Find the latest features <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxWindow\/\" rel=\"noopener\" target=\"_blank\">on the DHTMLX Window page<\/a>.<\/strong><\/p>\n<p>One more small DHTMLX tip with the help of which you&#8217;ll be able to close window (not collapse), but it will be still active and continue working on background.<\/p>\n<p>Why does someone need it? It&#8217;ll save you from the necessity to load the definite part of information each time, i.e. the work with your app will render faster.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dhtmlx.com\/blog\/wp-content\/uploads\/2015\/03\/soft-closed-windows.png\" alt=\"soft-closed-windows\" width=\"479\" height=\"351\" class=\"aligncenter size-full wp-image-2771\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/03\/soft-closed-windows.png 479w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/03\/soft-closed-windows-300x219.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p>So, to achieve it, we use the following algorithm:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> showWindow<span class=\"br0\">&#40;<\/span>id<span class=\"sy0\">,<\/span> text<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ step 1 - init windows on first attempt to show window<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>myWindows <span class=\"sy0\">==<\/span> <span class=\"kw2\">null<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; myWindows <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhtmlXWindows<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ step 2 - check if window already inited<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>myWindows.<span class=\"me1\">window<\/span><span class=\"br0\">&#40;<\/span>id<span class=\"br0\">&#41;<\/span> <span class=\"sy0\">==<\/span> <span class=\"kw2\">null<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ window not inited yet, init new one and configure<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">var<\/span> w1 <span class=\"sy0\">=<\/span> myWindows.<span class=\"me1\">createWindow<\/span><span class=\"br0\">&#40;<\/span>....<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ attach closing event, here we will hide<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ window instead of completely closing<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; w1.<span class=\"me1\">attachEvent<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;onClose&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>win<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win.<span class=\"me1\">hide<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">return<\/span> <span class=\"kw2\">false<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ window inited, just show it<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; myWindows.<span class=\"me1\">window<\/span><span class=\"br0\">&#40;<\/span>id<span class=\"br0\">&#41;<\/span>.<span class=\"me1\">show<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ call init code if any<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/...<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>If you have any questions regarding this tip, feel free to leave it in the comments section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: This feature was deprecated. Find the latest features on the DHTMLX Window page. One more small DHTMLX tip with the help of which you&#8217;ll be able to close &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3306,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,72,1,38],"tags":[33,43,14],"class_list":["post-2770","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts-for-codeproject-com","category-general","category-uncategorized","category-visible","tag-all-posts","tag-dhtmlx-tips","tag-tips"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=2770"}],"version-history":[{"count":3,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2770\/revisions"}],"predecessor-version":[{"id":8573,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2770\/revisions\/8573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3306"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}