1- /*! searchNavMenu.js v2.0 | ABAKUS PLUS d.o.o. | Andrej Grlica | andrej.grlica@abakus.si */
2-
1+ /*! searchNavMenu.js v2.1 | ABAKUS PLUS d.o.o. | Andrej Grlica | andrej.grlica@abakus.si */
32/* ==========================================================================
43
54 Description:
@@ -24,6 +23,8 @@ var SNMOptions =
2423"SaveSS" : true ,
2524"ShortcutSaveSS" : false ,
2625"ShrtCaseSensitive" : true ,
26+ "OnSearchShowChildren" : true ,
27+ "UseFocus" :true ,
2728"Shortcuts" : [ ]
2829} ;
2930
@@ -39,39 +40,56 @@ function openModalSNMHelp() {
3940openModalSNM ( "SNM_Help" , getHelpSNM ( ) ) ;
4041}
4142
43+ function openSNMChildrenIfExists ( ) {
44+ if ( SNMOptions . OnSearchShowChildren )
45+ $ ( 'li[id^="t_TreeNav"].is-expandable[style="display: block;"]' ) . children ( "ul" ) . children ( "li" ) . each ( function ( ) {
46+ if ( $ ( this ) . has ( "strong" ) . length || ( $ ( this ) . has ( "ul" ) . length == false && $ ( this ) . has ( "strong" ) . length == false ) )
47+ $ ( this ) . css ( "display" , "block" ) ;
48+ } ) ;
49+ $ ( 'li[id^="t_TreeNav"].is-collapsible[style="display: block;"]' ) . children ( "ul" ) . children ( "li" ) . each ( function ( ) {
50+ if ( $ ( this ) . has ( "strong" ) . length || ( $ ( this ) . has ( "ul" ) . length == false && $ ( this ) . has ( "strong" ) . length == false ) )
51+ $ ( this ) . css ( "display" , "block" ) ;
52+ } ) ;
53+ }
54+
4255function LoadSearchNavMenu ( item_id , menuOptions , ajaxIdentifier , l_skey , elmVal ) {
4356if ( menuOptions )
4457SNMOptions = menuOptions ;
4558
46- SNMOptions . ajaxId = ajaxIdentifier ;
47- SNMOptions . ItemId = item_id ;
59+ SNMOptions . ajaxId = ajaxIdentifier ;
60+ SNMOptions . ItemId = item_id ;
4861if ( SNMOptions . MenuClickOpenClose )
4962$ ( "#t_Body_nav #t_TreeNav" ) . on ( "click" , "ul li.a-TreeView-node div.a-TreeView-content:not(:has(a))" , function ( ) {
5063$ ( this ) . prev ( "span.a-TreeView-toggle" ) . click ( ) ;
51- } ) ;
64+ } ) ;
5265
5366if ( SNMOptions . SaveSS )
54- $ ( "input.srch_input" ) . val ( elmVal ) ;
67+ $ ( "input.srch_input" ) . val ( elmVal ) ;
5568
56- // Add events on items
69+ //Add events on items
5770 //----- KeyDOWN
5871 $ ( "input.srch_input" ) . keydown ( function ( e ) {
5972keyDownSearchNav ( $ ( this ) , e ) ;
60- // Display children under parent node. This can be removed.
61- $ ( 'li[id^="t_TreeNav"].is-expandable[style="display: block;"]' ) . children ( "ul" ) . children ( "li" ) . each ( function ( ) { $ ( this ) . css ( "display" , "block" ) ; } ) ;
73+ //openSNMChildrenIfExists();
6274 } ) ;
6375
6476//----- KeyUP
6577 $ ( "input.srch_input" ) . keyup ( function ( e , pageEvent ) {
6678keyUpSearchNav ( $ ( this ) , e , pageEvent ) ;
67- // Display children under parent node. This can be removed.
68- $ ( 'li[id^="t_TreeNav"].is-expandable[style="display: block;"]' ) . children ( "ul" ) . children ( "li" ) . each ( function ( ) { $ ( this ) . css ( "display" , "block" ) ; } ) ;
69- } ) ;
79+ } ) ;
7080
81+
82+ //----- Clear field IE problem, it's not on KEYUP
83+ $ ( "input.srch_input" ) . bind ( 'input propertychange' , function ( e , pageEvent ) {
84+ if ( this . value == "" ) {
85+ setCurrentNav ( item_id ) ;
86+ if ( ! pageEvent )
87+ saveSesSateNav ( "" ) ;
88+ }
89+ } ) ;
90+
7191 //----- Click on input bar, prevent default "Chrome problem".
72- $ ( "input.srch_input" ) . on ( "click" , function ( e ) {
73- e . preventDefault ( ) ; return false ;
74- } ) ;
92+ $ ( "input.srch_input" ) . on ( "click" , function ( e ) { e . preventDefault ( ) ; return false ; } ) ;
7593
7694 apex . jQuery ( window ) . on ( "apexwindowresized" , function ( e ) {
7795 onResizeWinSearchNav ( ) ;
@@ -84,7 +102,7 @@ function LoadSearchNavMenu(item_id, menuOptions, ajaxIdentifier, l_skey, elmVal)
84102shortCutSearchNav ( e , l_skey ) ;
85103 } ) ;
86104
87- addModalSNM ( "SNM_Help" , "Search Navigation Menu Help " ) ;
105+ addModalSNM ( "SNM_Help" , "Search Navigation Menu HELP " ) ;
88106
89107//---- On document ready
90108$ ( function ( ) {
@@ -93,14 +111,14 @@ function LoadSearchNavMenu(item_id, menuOptions, ajaxIdentifier, l_skey, elmVal)
93111SNMClosed = true ;
94112openAllNavSubmenus ( ) ;
95113$ ( 'li[id^="t_TreeNav"].is-collapsible' ) . find ( 'span.a-TreeView-toggle' ) . click ( ) ;
96- //Because all list were open and last one closed, we need to open current list
114+ //Because all list were open and last one closed we need to open current list
97115setCurrentNav ( item_id ) ;
98-
116+
99117if ( SNMOptions . MenuOpen )
100118showAllSublistsSearchNav ( ) ;
101-
102- currItem . focus ( ) ;
103-
119+
120+ if ( SNMOptions . UseFocus )
121+ currItem . focus ( ) ;
104122} ) ;
105123}
106124
@@ -116,13 +134,16 @@ function openAllNavSubmenus(elm) {
116134
117135function setCurrentNav ( item_id ) {
118136$ ( 'li[id^="t_TreeNav"]' ) . each ( function ( ) {
119- if ( $ ( this ) . find ( "div.a-TreeView-content" ) . hasClass ( "is-current" ) ) {
120- $ ( this ) . find ( "div.a-TreeView-row" ) . addClass ( "is-selected" ) ;
137+ if ( $ ( this ) . find ( "div.a-TreeView-content:first " ) . hasClass ( "is-current" ) ) {
138+ $ ( this ) . find ( "div.a-TreeView-row:first " ) . addClass ( "is-selected" ) ;
121139 if ( $ ( this ) . hasClass ( "is-expandable" ) )
122- $ ( this ) . find ( "span.a-TreeView-toggle" ) . click ( ) ;
140+ $ ( this ) . find ( "span.a-TreeView-toggle:first " ) . click ( ) ;
123141 }
142+ else if ( $ ( this ) . find ( "div.a-TreeView-content:first" ) . hasClass ( "is-current--top" ) ) {
143+ $ ( this ) . find ( "span.a-TreeView-toggle:first" ) . click ( ) ;
144+ }
124145 else
125- $ ( this ) . find ( "div.a-TreeView-row" ) . removeClass ( "is-selected" ) ;
146+ $ ( this ) . find ( "div.a-TreeView-row:first " ) . removeClass ( "is-selected" ) ;
126147 } ) ;
127148if ( SNMClosed )
128149$ ( '#t_Button_navControl' ) . click ( ) ;
@@ -144,7 +165,7 @@ function isNavTreeOpen() {
144165function redirectUrlSNM ( redirectURL , pNewWindow ) {
145166if ( redirectURL && ! pNewWindow ) {
146167window . location . href = redirectURL ;
147- if ( ! SNMOptions . ShortcutSaveSS && redirectURL . toLowerCase ( ) . startsWith ( ' javascript:' ) ) {
168+ if ( ! SNMOptions . ShortcutSaveSS && redirectURL . toLowerCase ( ) . indexOf ( " javascript:" ) == 0 ) {
148169$ ( "input.srch_input" ) . val ( "" ) ;
149170setCurrentNav ( SNMOptions . ItemId ) ;
150171}
@@ -170,7 +191,7 @@ function saveSesSateNav(newVal, redirectURL, pNewWindow) {
170191redirectUrlSNM ( redirectURL , pNewWindow ) ;
171192}
172193else
173- apex . debug . error ( "Saving the session state for Search Navigation failed: " + JSON . stringify ( pData ) ) ;
194+ apex . debug . error ( "Saving the session state for Search Navigation failed: " + JSON . stringify ( pData ) ) ;
174195 } ,
175196 error : function ( pData ) {
176197 apex . debug . error ( "Saving the session state for Search Navigation failed: " + JSON . stringify ( pData ) ) ;
@@ -255,7 +276,7 @@ function parseSNMShortcut(obj, elmVal) {
255276l_clearCache = l_page_id ;
256277
257278if ( obj . action . toLowerCase ( ) == "page" && ! elmVal )
258- retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + "::NO :" + l_clearCache + "::"
279+ retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + ":::" + l_clearCache + "::"
259280else if ( obj . action . toLowerCase ( ) == "url" && ! elmVal ) {
260281if ( obj . url )
261282retURL = obj . url ;
@@ -285,19 +306,19 @@ function parseSNMShortcut(obj, elmVal) {
285306l_clearCache = obj . IR_clearCache ;
286307}
287308if ( elmVal )
288- retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + "::NO :" + l_clearCache + ":" + ir_link + ":" + elmVal ;
309+ retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + ":::" + l_clearCache + ":" + ir_link + ":" + elmVal ;
289310else
290311if ( "IR_value" in obj )
291- retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + "::NO :" + l_clearCache + ":" + ir_link + ":" + obj . IR_value ;
312+ retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + ":::" + l_clearCache + ":" + ir_link + ":" + obj . IR_value ;
292313}
293314else if ( obj . action . toLowerCase ( ) == "item" ) {
294315if ( elmVal ) {
295316if ( "item_name" in obj )
296- retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + "::NO :" + l_clearCache + ":" + obj . item_name + ":" + elmVal ;
317+ retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + ":::" + l_clearCache + ":" + obj . item_name + ":" + elmVal ;
297318}
298319else
299320if ( "item_name" in obj && "item_value" in obj )
300- retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + "::NO :" + l_clearCache + ":" + obj . item_name + ":" + obj . item_value ;
321+ retURL = "f?p=" + $v ( "pFlowId" ) + ":" + l_page_id + ":" + $v ( "pInstance" ) + ":::" + l_clearCache + ":" + obj . item_name + ":" + obj . item_value ;
301322}
302323}
303324if ( retURL )
@@ -341,8 +362,8 @@ function checkAndRedirectSNM(elm) {
341362if ( ( SNMOptions . Shortcuts [ i ] . name == elmVal && caseSensitive ) || ( SNMOptions . Shortcuts [ i ] . name . toLowerCase ( ) == elmVal . toLowerCase ( ) && ! caseSensitive ) ) {
342363find_shortcut = redirectSNM ( SNMOptions . Shortcuts [ i ] ) ;
343364}
344- else if ( ( elmVal . startsWith ( SNMOptions . Shortcuts [ i ] . name + ":" ) && caseSensitive ) ||
345- ( elmVal . toLowerCase ( ) . startsWith ( SNMOptions . Shortcuts [ i ] . name . toLowerCase ( ) + ":" ) && ! caseSensitive ) ) {
365+ else if ( ( elmVal . indexOf ( SNMOptions . Shortcuts [ i ] . name + ":" ) == 0 && caseSensitive ) ||
366+ ( elmVal . toLowerCase ( ) . indexOf ( SNMOptions . Shortcuts [ i ] . name . toLowerCase ( ) + ":" ) == 0 && ! caseSensitive ) ) {
346367find_shortcut = redirectSNM ( SNMOptions . Shortcuts [ i ] , true , elmVal ) ;
347368}
348369if ( find_shortcut ) { break ; }
@@ -352,22 +373,21 @@ function checkAndRedirectSNM(elm) {
352373find_shortcut = redirectSNM ( ) ;
353374}
354375
355- /* EVENTS */
376+ /* EVENTS........ */
356377
357378function addModalSNM ( name , title ) {
358379$ ( 'body' ) . append ( '<div id="' + name + '" />' )
359380
360381$ ( "#" + name ) . dialog (
361- {
362- "modal" : true ,
363- "title" : title ,
364- "autoOpen" :false ,
365- "resizable" :true ,
366- "dialogClass" : "no-close srch_modal" ,
367- "width" : '500px' ,
368- "closeOnEscape" : true ,
369- buttons : {
370- "Close" : function ( ) {
382+ { "modal" :true
383+ , "title" :title
384+ , "autoOpen" :false
385+ , "resizable" :true
386+ , "dialogClass" :"no-close srch_modal"
387+ , "width" :'500px'
388+ , "closeOnEscape" :true
389+ , buttons : {
390+ "Close" : function ( ) {
371391$ ( this ) . dialog ( "close" ) ;
372392}
373393}
@@ -385,11 +405,11 @@ function openModalSNM(name, p_msg) {
385405function getHelpSNM ( ) {
386406var l_return = "<h3>Shortcuts :</h3>" ;
387407l_return += "<table>" ;
388- l_return += "<tr><td class=\"td_right\"><strong>CTRL+" + SNMOptions . skey + " :</strong></td><td colspan=\"4\">Focus on Search Box </td></tr>" ;
389- l_return += "<tr><td class=\"td_right\"><strong>F1:</strong></td><td colspan=\"4\">Opens the Search Navigation Menu help. </td></tr>" ;
408+ l_return += "<tr><td class=\"td_right\"><strong>CTRL+" + SNMOptions . skey + " :</strong></td><td colspan=\"4\">Focus on search box item </td></tr>" ;
409+ l_return += "<tr><td class=\"td_right\"><strong>F1 :</strong></td><td colspan=\"4\">Opens search navigation menu help page </td></tr>" ;
390410
391411if ( ! jQuery . isEmptyObject ( SNMOptions . Shortcuts ) ) {
392- l_return += "<tr class=\"tr_bg\"><td>Shortcut Label </td><td>Type</td><td>Condition</td><td>Example (type in)</td></tr>" ;
412+ l_return += "<tr class=\"tr_bg\"><td>Shortcut label </td><td>Type</td><td>Condition</td><td>Example (type in)</td></tr>" ;
393413for ( var i = 0 ; i < SNMOptions . Shortcuts . length ; i ++ ) {
394414l_return += "<tr><td><strong>" + SNMOptions . Shortcuts [ i ] . name + "</strong></td><td>" + SNMOptions . Shortcuts [ i ] . action + "</td>" ;
395415l_return += "<td>" ;
@@ -505,7 +525,10 @@ function keyUpSearchNav(elm, e, pageEvent) {
505525if ( ! pageEvent )
506526saveSesSateNav ( elmVal ) ;
507527hoverSearchNav ( ) ;
508- $f_First_field ( ) ;
528+ openSNMChildrenIfExists ( ) ;
529+ if ( SNMOptions . UseFocus )
530+ $f_First_field ( ) ;
531+
509532}
510533}
511534
@@ -527,4 +550,4 @@ function onResizeWinSearchNav() {
527550if ( ! isNavTreeOpen ( ) )
528551hideAllSublistsSearchNav ( ) ;
529552}
530- }
553+ }
0 commit comments