2
2
* @ngdoc service
3
3
* @name umbraco.services.navigationService
4
4
*
5
- * @requires $rootScope
5
+ * @requires $rootScope
6
6
* @requires $routeParams
7
7
* @requires $log
8
8
* @requires $location
9
9
* @requires dialogService
10
10
* @requires treeService
11
11
* @requires sectionResource
12
- *
12
+ *
13
13
* @description
14
14
* Service to handle the main application navigation. Responsible for invoking the tree
15
15
* Section navigation and search, and maintain their state for the entire application lifetime
@@ -41,8 +41,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
41
41
appState . setMenuState ( "showMenuDialog" , false ) ;
42
42
appState . setGlobalState ( "stickyNavigation" , false ) ;
43
43
appState . setGlobalState ( "showTray" , false ) ;
44
-
45
- //$("#search-form input").focus();
44
+
45
+ //$("#search-form input").focus();
46
46
break ;
47
47
case 'menu' :
48
48
appState . setGlobalState ( "navMode" , "menu" ) ;
@@ -94,8 +94,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
94
94
init : function ( ) {
95
95
96
96
setTreeMode ( ) ;
97
-
98
- //keep track of the current section - initially this will always be undefined so
97
+
98
+ //keep track of the current section - initially this will always be undefined so
99
99
// no point in setting it now until it changes.
100
100
$rootScope . $watch ( function ( ) {
101
101
return $routeParams . section ;
@@ -118,7 +118,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
118
118
* Shows the legacy iframe and loads in the content based on the source url
119
119
* @param {String } source The URL to load into the iframe
120
120
*/
121
- loadLegacyIFrame : function ( source ) {
121
+ loadLegacyIFrame : function ( source ) {
122
122
$location . path ( "/" + appState . getSectionState ( "currentSection" ) + "/framed/" + encodeURIComponent ( source ) ) ;
123
123
} ,
124
124
@@ -160,7 +160,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
160
160
showTree : function ( sectionAlias , syncArgs ) {
161
161
if ( sectionAlias !== appState . getSectionState ( "currentSection" ) ) {
162
162
appState . setSectionState ( "currentSection" , sectionAlias ) ;
163
-
163
+
164
164
if ( syncArgs ) {
165
165
this . syncTree ( syncArgs ) ;
166
166
}
@@ -176,7 +176,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
176
176
appState . setGlobalState ( "showTray" , false ) ;
177
177
} ,
178
178
179
- /**
179
+ /**
180
180
Called to assign the main tree event handler - this is called by the navigation controller.
181
181
TODO: Potentially another dev could call this which would kind of mung the whole app so potentially there's a better way.
182
182
*/
@@ -190,7 +190,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
190
190
191
191
//when a tree node is synced this event will fire, this allows us to set the currentNode
192
192
mainTreeEventHandler . bind ( "treeSynced" , function ( ev , args ) {
193
-
193
+
194
194
if ( args . activate === undefined || args . activate === true ) {
195
195
//set the current selected node
196
196
appState . setTreeState ( "selectedNode" , args . node ) ;
@@ -207,7 +207,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
207
207
208
208
//Set the current action node (this is not the same as the current selected node!)
209
209
appState . setMenuState ( "currentNode" , args . node ) ;
210
-
210
+
211
211
if ( args . event && args . event . altKey ) {
212
212
args . skipDefault = true ;
213
213
}
@@ -231,7 +231,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
231
231
ev . preventDefault ( ) ;
232
232
233
233
if ( n . metaData && n . metaData [ "jsClickCallback" ] && angular . isString ( n . metaData [ "jsClickCallback" ] ) && n . metaData [ "jsClickCallback" ] !== "" ) {
234
- //this is a legacy tree node!
234
+ //this is a legacy tree node!
235
235
var jsPrefix = "javascript:" ;
236
236
var js ;
237
237
if ( n . metaData [ "jsClickCallback" ] . startsWith ( jsPrefix ) ) {
@@ -254,7 +254,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
254
254
else if ( n . routePath ) {
255
255
//add action to the history service
256
256
historyService . add ( { name : n . name , link : n . routePath , icon : n . icon } ) ;
257
-
257
+
258
258
//put this node into the tree state
259
259
appState . setTreeState ( "selectedNode" , args . node ) ;
260
260
//when a node is clicked we also need to set the active menu node to this node
@@ -280,7 +280,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
280
280
* The path format is: ["itemId","itemId"], and so on
281
281
* so to sync to a specific document type node do:
282
282
* <pre>
283
- * navigationService.syncTree({tree: 'content', path: ["-1","123d"], forceReload: true});
283
+ * navigationService.syncTree({tree: 'content', path: ["-1","123d"], forceReload: true});
284
284
* </pre>
285
285
* @param {Object } args arguments passed to the function
286
286
* @param {String } args.tree the tree alias to sync to
@@ -298,7 +298,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
298
298
if ( ! args . tree ) {
299
299
throw "args.tree cannot be null" ;
300
300
}
301
-
301
+
302
302
if ( mainTreeEventHandler ) {
303
303
//returns a promise
304
304
return mainTreeEventHandler . syncTree ( args ) ;
@@ -308,8 +308,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
308
308
return angularHelper . rejectedPromise ( ) ;
309
309
} ,
310
310
311
- /**
312
- Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
311
+ /**
312
+ Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
313
313
have to set an active tree and then sync, the new API does this in one method by using syncTree
314
314
*/
315
315
_syncPath : function ( path , forceReload ) {
@@ -333,16 +333,16 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
333
333
}
334
334
} ,
335
335
336
- /**
337
- Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
336
+ /**
337
+ Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
338
338
have to set an active tree and then sync, the new API does this in one method by using syncTreePath
339
339
*/
340
340
_setActiveTreeType : function ( treeAlias , loadChildren ) {
341
341
if ( mainTreeEventHandler ) {
342
342
mainTreeEventHandler . _setActiveTreeType ( treeAlias , loadChildren ) ;
343
343
}
344
344
} ,
345
-
345
+
346
346
/**
347
347
* @ngdoc method
348
348
* @name umbraco.services.navigationService#hideTree
@@ -367,7 +367,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
367
367
* @methodOf umbraco.services.navigationService
368
368
*
369
369
* @description
370
- * Hides the tree by hiding the containing dom element.
370
+ * Hides the tree by hiding the containing dom element.
371
371
* This always returns a promise!
372
372
*
373
373
* @param {Event } event the click event triggering the method, passed from the DOM element
@@ -393,7 +393,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
393
393
394
394
//NOTE: This is assigning the current action node - this is not the same as the currently selected node!
395
395
appState . setMenuState ( "currentNode" , args . node ) ;
396
-
396
+
397
397
//ensure the current dialog is cleared before creating another!
398
398
if ( currentDialog ) {
399
399
dialogService . close ( currentDialog ) ;
@@ -411,13 +411,13 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
411
411
}
412
412
}
413
413
414
- //there is no default or we couldn't find one so just continue showing the menu
414
+ //there is no default or we couldn't find one so just continue showing the menu
415
415
416
416
setMode ( "menu" ) ;
417
417
418
418
appState . setMenuState ( "currentNode" , args . node ) ;
419
419
appState . setMenuState ( "menuActions" , data . menuItems ) ;
420
- appState . setMenuState ( "dialogTitle" , args . node . name ) ;
420
+ appState . setMenuState ( "dialogTitle" , args . node . name ) ;
421
421
422
422
//we're not opening a dialog, return null.
423
423
deferred . resolve ( null ) ;
@@ -448,7 +448,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
448
448
throw "action cannot be null" ;
449
449
}
450
450
if ( ! node ) {
451
- throw "node cannot be null" ;
451
+ throw "node cannot be null" ;
452
452
}
453
453
if ( ! section ) {
454
454
throw "section cannot be null" ;
@@ -467,9 +467,9 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
467
467
var menuAction = action . metaData [ "jsAction" ] . split ( '.' ) ;
468
468
if ( menuAction . length !== 2 ) {
469
469
470
- //if it is not two parts long then this most likely means that it's a legacy action
470
+ //if it is not two parts long then this most likely means that it's a legacy action
471
471
var js = action . metaData [ "jsAction" ] . replace ( "javascript:" , "" ) ;
472
- //there's not really a different way to acheive this except for eval
472
+ //there's not really a different way to acheive this except for eval
473
473
eval ( js ) ;
474
474
}
475
475
else {
@@ -526,8 +526,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
526
526
modalClass : "umb-modal-left" ,
527
527
show : true
528
528
} ) ;
529
-
530
-
529
+
530
+
531
531
532
532
return userDialog ;
533
533
} ,
@@ -553,7 +553,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
553
553
modalClass : "umb-modal-left" ,
554
554
show : true
555
555
} ) ;
556
-
556
+
557
557
return service . helpDialog ;
558
558
} ,
559
559
@@ -566,13 +566,13 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
566
566
* Opens a dialog, for a given action on a given tree node
567
567
* uses the dialogService to inject the selected action dialog
568
568
* into #dialog div.umb-panel-body
569
- * the path to the dialog view is determined by:
569
+ * the path to the dialog view is determined by:
570
570
* "views/" + current tree + "/" + action alias + ".html"
571
571
* The dialog controller will get passed a scope object that is created here with the properties:
572
572
* scope.currentNode = the selected tree node
573
573
* scope.currentAction = the selected menu item
574
574
* so that the dialog controllers can use these properties
575
- *
575
+ *
576
576
* @param {Object } args arguments passed to the function
577
577
* @param {Scope } args.scope current scope passed to the dialog
578
578
* @param {Object } args.action the clicked action containing `name` and `alias`
@@ -651,14 +651,14 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
651
651
}
652
652
653
653
//TODO: some action's want to launch a new window like live editing, we support this in the menu item's metadata with
654
- // a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog
655
- // if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window,
654
+ // a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog
655
+ // if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window,
656
656
// though would be v-easy, just not sure we want to ever support that?
657
657
658
658
var dialog = dialogService . open (
659
659
{
660
660
container : $ ( ".app-navigation-dialog .umb-modalcolumn-body" ) ,
661
- //The ONLY reason we're passing in scope to the dialogService (which is legacy functionality) is
661
+ //The ONLY reason we're passing in scope to the dialogService (which is legacy functionality) is
662
662
// for backwards compatibility since many dialogs require $scope.currentNode or $scope.currentAction
663
663
// to exist
664
664
scope : dialogScope ,
@@ -687,9 +687,9 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
687
687
* hides the currently open dialog
688
688
*/
689
689
hideDialog : function ( showMenu ) {
690
-
690
+
691
691
setMode ( "default" ) ;
692
-
692
+
693
693
if ( showMenu ) {
694
694
this . showMenu ( undefined , { skipDefault : true , node : appState . getMenuState ( "currentNode" ) } ) ;
695
695
}
0 commit comments