@@ -16,7 +16,7 @@ define([
1616 el : '.resource-list-container' ,
1717 initialize : function ( ) {
1818 var that = this ;
19-
19+
2020 } ,
2121 events : {
2222 'click a[data-resource-id]' : 'showMethodList' ,
@@ -32,27 +32,27 @@ define([
3232 } else {
3333 var el = $ ( '[data-resource-id=' + this . options . resourceId + ']' ) ;
3434 }
35- if ( el . length > 0 ) {
35+ if ( el . length > 0 ) {
3636 this . expandMethods ( $ ( el ) . parents ( 'li[data-resource-id]' ) ) ;
3737 }
38-
38+
3939 //var methodListView = new MethodsListView({username: that.options.username, api: that.options.api, version: that.options.version, resourceId: that.options.resourceId, method: that.options.method});
40- //methodListView.render();
40+ //methodListView.render();
4141 var resourcePageView = Vm . create ( this , 'resourcepageview' , ResourcePageView , that . options ) ;
42- resourcePageView . render ( ) ;
42+ resourcePageView . render ( ) ;
4343 } ,
4444 expandMethodsHandler : function ( ev ) {
4545 $ ( ev . currentTarget ) . text ( '-' ) ;
4646 $ ( ev ) . addClass ( 'expanded' ) ;
4747 var ele = $ ( ev . currentTarget ) . parents ( 'li[data-resource-id]' ) ;
4848 this . expandMethods ( ele ) ;
4949 } ,
50- expandMethods : function ( ele ) {
50+ expandMethods : function ( ele ) {
5151 var resourceId = $ ( ele ) . attr ( 'data-resource-id' ) ;
5252 var el = $ ( ele ) . next ( 'li' ) ;
5353 var methodListView = Vm . create ( this , 'methodlist' + this . options . resourceId , MethodsListView , { username : this . options . username , apiname : this . options . apiname , version : this . options . version , resourceId : resourceId , method : this . options . method , el : el } ) ;
5454 methodListView . setElement ( el ) ;
55- methodListView . render ( ) ;
55+ methodListView . render ( ) ;
5656 } ,
5757 contractMethods : function ( ev ) {
5858 $ ( ev . currentTarget ) . removeClass ( 'expanded' ) ;
@@ -67,34 +67,38 @@ define([
6767 that . $el . attr ( 'data-api-id' , that . options . apiname ) ;
6868 resources . fetch ( {
6969 success : function ( collection ) {
70+ // mark active resource in list if we're viewing one
7071 if ( that . options . resourceId ) {
71-
72- collection . get ( that . options . resourceId ) . set ( { active : 'active' } ) ;
72+ collection . get ( that . options . resourceId ) . set ( { active : 'active' } ) ;
7373 }
7474 that . $el . html ( Mustache . render ( resourceListTemplate , { _ :_ , selectedResource : that . options . resourceId , is_public : that . options . is_public , resources : collection , username : Session . get ( 'login' ) , location : that . options . location } ) ) ;
75- if ( typeof that . options . resourceId !== 'undefined' ) { //&& $('.method-list-container').attr('data-resource-id') !== that.options.resourceId) {
76- that . showMethodList ( ) ;
75+
76+ // render method list for active resource
77+ if ( typeof that . options . resourceId !== 'undefined' ) {
78+ that . showMethodList ( ) ;
7779 }
78- //that.showMethodList();
7980
81+ // read in notification counts
8082 var notificationTotals = new NTotals ( ) ;
8183 notificationTotals . options = {
8284 api : that . options . apiname ,
8385 version : that . options . version ,
8486 username : that . options . username
8587 } ;
8688 notificationTotals . fetch ( {
87- success : function ( model ) {
88- console . log ( 'I dont know what to do' , model ) ;
89- //var notifEl = $('.notification[data-resource-id='+model.options.resourceId+']');
90- // notifEl.text(model.get('resource')).show();
89+ success : function ( model ) {
90+ // set notifiactions on the top-level API
91+ if ( model . get ( 'api' ) ) {
92+ var anotifEl = $ ( 'ul.api-menu-list[data-api-id=' + that . options . apiname + '] .api-notification' ) ;
93+ anotifEl . text ( model . get ( 'api' ) ) . show ( ) ;
94+ }
95+
96+ // set notifications on each resource
9197 _ . each ( model . get ( 'resources' ) , function ( method ) {
92- console . log ( method , 'wtf is this' ) ;
9398 if ( method . count > 0 ) {
94- var anotifEl = $ ( '.resource-notification [data-resource-id=' + method . key + ']' ) ;
99+ var anotifEl = $ ( 'li [data-resource-id=' + method . key + '] .resource-notification ' ) ;
95100 anotifEl . text ( method . count ) . show ( ) ;
96101 }
97-
98102 } ) ;
99103 }
100104 } ) ;
@@ -105,7 +109,7 @@ define([
105109 }
106110 } ) ;
107111
108-
112+
109113 }
110114 } ) ;
111115 return ApisPage ;
0 commit comments