@@ -12,24 +12,23 @@ $(function() {
12
12
}
13
13
} ,
14
14
supportedViews : [ F2 . Constants . Views . HOME , F2 . Constants . Views . SETTINGS , F2 . Constants . Views . REMOVE ] ,
15
- secureAppPagePath : " secure.html" // this should go on a separate domain from index.html
15
+ secureAppPagePath : ' secure.html' // this should go on a separate domain from index.html
16
16
} ) ;
17
17
18
18
// Define these prior to init
19
19
F2 . AppHandlers
20
20
. on (
21
21
containerAppHandlerToken ,
22
22
F2 . Constants . AppHandlers . APP_CREATE_ROOT ,
23
- function ( appConfig )
24
- {
23
+ function ( appConfig ) {
25
24
var hasSettings = F2 . inArray ( F2 . Constants . Views . SETTINGS , appConfig . views ) ;
26
25
var hasHelp = F2 . inArray ( F2 . Constants . Views . HELP , appConfig . views ) ;
27
26
var hasAbout = F2 . inArray ( F2 . Constants . Views . ABOUT , appConfig . views ) ;
28
27
var showDivider = hasSettings || hasHelp || hasAbout ;
29
28
var gridWidth = appConfig . minGridSize || 3 ;
30
29
31
30
appConfig . root = $ ( [
32
- '<section class="' + F2 . Constants . Css . APP + ' span' + gridWidth + '">' ,
31
+ '<section class="' + F2 . Constants . Css . APP + ' span' + gridWidth + '" data-grid-width="' + gridWidth + '" >',
33
32
'<header class="clearfix">' ,
34
33
'<h2 class="pull-left ' , F2 . Constants . Css . APP_TITLE , '">' , appConfig . name . toUpperCase ( ) , '</h2>' ,
35
34
'<div class="btn-group pull-right">' ,
@@ -52,12 +51,34 @@ $(function() {
52
51
. on (
53
52
containerAppHandlerToken ,
54
53
F2 . Constants . AppHandlers . APP_RENDER ,
55
- $ ( "body" ) . get ( 0 )
54
+ function ( appConfig , app ) {
55
+
56
+ var gridWidth = appConfig . minGridSize || 3 ;
57
+
58
+ // find a row that can fit this app
59
+ var row ;
60
+ $ ( '#mainContent div.row' ) . each ( function ( i , el ) {
61
+ var span = 0 ;
62
+ $ ( '.f2-app' , el ) . each ( function ( j , app ) {
63
+ span += Number ( $ ( app ) . data ( 'gridWidth' ) ) ;
64
+ } ) ;
65
+ if ( span <= ( 12 - gridWidth ) ) {
66
+ row = el ;
67
+ return false ;
68
+ }
69
+ } ) ;
70
+ // create a new row if one wasn't found
71
+ if ( row === undefined ) {
72
+ row = $ ( '<div class="row"></div>' ) . appendTo ( '#mainContent' ) ;
73
+ }
74
+ // append app to app root and also to row
75
+ $ ( appConfig . root ) . append ( app ) . appendTo ( row ) ;
76
+ }
56
77
)
57
78
. on (
58
79
containerAppHandlerToken ,
59
80
F2 . Constants . AppHandlers . APP_RENDER_AFTER ,
60
- function ( appConfig ) {
81
+ function ( appConfig ) {
61
82
F2 . UI . hideMask ( appConfig . instanceId , appConfig . root ) ;
62
83
}
63
84
)
@@ -68,14 +89,14 @@ $(function() {
68
89
if ( ! appInstance ) { return ; }
69
90
70
91
// call the apps destroy method, if it has one
71
- if ( appInstance . app && appInstance . app . destroy && typeof ( appInstance . app . destroy ) == " function" )
92
+ if ( appInstance . app && appInstance . app . destroy && typeof ( appInstance . app . destroy ) == ' function' )
72
93
{
73
94
appInstance . app . destroy ( ) ;
74
95
}
75
96
// warn the container developer/app developer that even though they have a destroy method it hasn't been
76
97
else if ( appInstance . app && appInstance . app . destroy )
77
98
{
78
- F2 . log ( app . config . appId + " has a Destroy property, but Destroy is not of type function and as such will not be executed." ) ;
99
+ F2 . log ( appInstance . appId + ' has a Destroy property, but Destroy is not of type function and as such will not be executed.' ) ;
79
100
}
80
101
81
102
// fade out and remove the root
@@ -89,15 +110,15 @@ $(function() {
89
110
//listen for app symbol change events and re-broadcast
90
111
F2 . Events . on (
91
112
F2 . Constants . Events . APP_SYMBOL_CHANGE ,
92
- function ( data ) {
93
- F2 . Events . emit ( F2 . Constants . Events . CONTAINER_SYMBOL_CHANGE , { symbol : data . symbol , name : data . name || "" } ) ;
113
+ function ( data ) {
114
+ F2 . Events . emit ( F2 . Constants . Events . CONTAINER_SYMBOL_CHANGE , { symbol : data . symbol , name : data . name || '' } ) ;
94
115
}
95
116
) ;
96
117
97
118
/**
98
119
* init symbol lookup in navbar
99
120
*/
100
- $ ( " #symbolLookup" )
121
+ $ ( ' #symbolLookup' )
101
122
. on ( 'keypress' , function ( event ) {
102
123
if ( event . keyCode == 13 ) {
103
124
event . preventDefault ( ) ;
@@ -112,24 +133,24 @@ $(function() {
112
133
source : function ( request , response ) {
113
134
114
135
$ . ajax ( {
115
- url : " http://dev.markitondemand.com/api/Lookup/jsonp" ,
116
- dataType : " jsonp" ,
136
+ url : ' http://dev.markitondemand.com/api/Lookup/jsonp' ,
137
+ dataType : ' jsonp' ,
117
138
data : {
118
139
input : request . term
119
140
} ,
120
141
success : function ( data ) {
121
142
response ( $ . map ( data , function ( item ) {
122
143
return {
123
- label : item . Name + " (" + item . Exchange + ")" ,
144
+ label : item . Name + ' (' + item . Exchange + ')' ,
124
145
value : item . Symbol
125
- }
146
+ } ;
126
147
} ) ) ;
127
148
} ,
128
149
open : function ( ) {
129
- $ ( this ) . removeClass ( " ui-corner-all" ) . addClass ( " ui-corner-top" ) ;
150
+ $ ( this ) . removeClass ( ' ui-corner-all' ) . addClass ( ' ui-corner-top' ) ;
130
151
} ,
131
152
close : function ( ) {
132
- $ ( this ) . removeClass ( " ui-corner-top" ) . addClass ( " ui-corner-all" ) ;
153
+ $ ( this ) . removeClass ( ' ui-corner-top' ) . addClass ( ' ui-corner-all' ) ;
133
154
}
134
155
} ) ;
135
156
}
0 commit comments