11// Copyright (C) 2009 BRAT Tech LLC
2- nglr . Binder = function ( doc , widgetFactory , urlWatcher , config ) {
2+ Binder = function ( doc , widgetFactory , urlWatcher , config ) {
33 this . doc = doc ;
44 this . urlWatcher = urlWatcher ;
55 this . anchor = { } ;
@@ -8,7 +8,7 @@ nglr.Binder = function(doc, widgetFactory, urlWatcher, config) {
88 this . updateListeners = [ ] ;
99} ;
1010
11- nglr . Binder . parseBindings = function ( string ) {
11+ Binder . parseBindings = function ( string ) {
1212 var results = [ ] ;
1313 var lastIndex = 0 ;
1414 var index ;
@@ -28,18 +28,18 @@ nglr.Binder.parseBindings = function(string) {
2828 return results . length === 0 ? [ string ] : results ;
2929} ;
3030
31- nglr . Binder . hasBinding = function ( string ) {
32- var bindings = nglr . Binder . parseBindings ( string ) ;
33- return bindings . length > 1 || nglr . Binder . binding ( bindings [ 0 ] ) !== null ;
31+ Binder . hasBinding = function ( string ) {
32+ var bindings = Binder . parseBindings ( string ) ;
33+ return bindings . length > 1 || Binder . binding ( bindings [ 0 ] ) !== null ;
3434} ;
3535
36- nglr . Binder . binding = function ( string ) {
36+ Binder . binding = function ( string ) {
3737 var binding = string . replace ( / \n / gm, ' ' ) . match ( / ^ \{ \{ ( .* ) \} \} $ / ) ;
3838 return binding ? binding [ 1 ] : null ;
3939} ;
4040
4141
42- nglr . Binder . prototype . parseQueryString = function ( query ) {
42+ Binder . prototype . parseQueryString = function ( query ) {
4343 var params = { } ;
4444 query . replace ( / (?: ^ | & ) ( [ ^ & = ] * ) = ? ( [ ^ & ] * ) / g,
4545 function ( match , left , right ) {
@@ -48,7 +48,7 @@ nglr.Binder.prototype.parseQueryString = function(query) {
4848 return params ;
4949} ;
5050
51- nglr . Binder . prototype . parseAnchor = function ( url ) {
51+ Binder . prototype . parseAnchor = function ( url ) {
5252 var self = this ;
5353 url = url || this . urlWatcher . getUrl ( ) ;
5454
@@ -65,13 +65,13 @@ nglr.Binder.prototype.parseAnchor = function(url) {
6565 } ) ;
6666} ;
6767
68- nglr . Binder . prototype . onUrlChange = function ( url ) {
68+ Binder . prototype . onUrlChange = function ( url ) {
6969 console . log ( "URL change detected" , url ) ;
7070 this . parseAnchor ( url ) ;
7171 this . updateView ( ) ;
7272} ;
7373
74- nglr . Binder . prototype . updateAnchor = function ( ) {
74+ Binder . prototype . updateAnchor = function ( ) {
7575 var url = this . urlWatcher . getUrl ( ) ;
7676 var anchorIndex = url . indexOf ( '#' ) ;
7777 if ( anchorIndex > - 1 )
@@ -93,7 +93,7 @@ nglr.Binder.prototype.updateAnchor = function() {
9393 return url ;
9494} ;
9595
96- nglr . Binder . prototype . updateView = function ( ) {
96+ Binder . prototype . updateView = function ( ) {
9797 var start = new Date ( ) . getTime ( ) ;
9898 var scope = jQuery ( this . doc ) . scope ( ) ;
9999 scope . set ( "$invalidWidgets" , [ ] ) ;
@@ -103,7 +103,7 @@ nglr.Binder.prototype.updateView = function() {
103103 _ . each ( this . updateListeners , function ( fn ) { fn ( ) ; } ) ;
104104} ;
105105
106- nglr . Binder . prototype . docFindWithSelf = function ( exp ) {
106+ Binder . prototype . docFindWithSelf = function ( exp ) {
107107 var doc = jQuery ( this . doc ) ;
108108 var selection = doc . find ( exp ) ;
109109 if ( doc . is ( exp ) ) {
@@ -112,31 +112,31 @@ nglr.Binder.prototype.docFindWithSelf = function(exp){
112112 return selection ;
113113} ;
114114
115- nglr . Binder . prototype . executeInit = function ( ) {
115+ Binder . prototype . executeInit = function ( ) {
116116 this . docFindWithSelf ( "[ng-init]" ) . each ( function ( ) {
117117 var jThis = jQuery ( this ) ;
118118 var scope = jThis . scope ( ) ;
119119 try {
120120 scope . eval ( jThis . attr ( 'ng-init' ) ) ;
121121 } catch ( e ) {
122- nglr . alert ( "EVAL ERROR:\n" + jThis . attr ( 'ng-init' ) + '\n' + nglr . toJson ( e , true ) ) ;
122+ alert ( "EVAL ERROR:\n" + jThis . attr ( 'ng-init' ) + '\n' + toJson ( e , true ) ) ;
123123 }
124124 } ) ;
125125} ;
126126
127- nglr . Binder . prototype . entity = function ( scope ) {
127+ Binder . prototype . entity = function ( scope ) {
128128 this . docFindWithSelf ( "[ng-entity]" ) . attr ( "ng-watch" , function ( ) {
129129 try {
130130 var jNode = jQuery ( this ) ;
131131 var decl = scope . entity ( jNode . attr ( "ng-entity" ) ) ;
132132 return decl + ( jNode . attr ( 'ng-watch' ) || "" ) ;
133133 } catch ( e ) {
134- nglr . alert ( e ) ;
134+ alert ( e ) ;
135135 }
136136 } ) ;
137137} ;
138138
139- nglr . Binder . prototype . compile = function ( ) {
139+ Binder . prototype . compile = function ( ) {
140140 var jNode = jQuery ( this . doc ) ;
141141 var self = this ;
142142 if ( this . config . autoSubmit ) {
@@ -153,37 +153,37 @@ nglr.Binder.prototype.compile = function() {
153153 jNode . removeClass ( "ng-exception" ) ;
154154 } catch ( e ) {
155155 jNode . addClass ( "ng-exception" ) ;
156- jNode . attr ( 'ng-error' , nglr . toJson ( e , true ) ) ;
156+ jNode . attr ( 'ng-error' , toJson ( e , true ) ) ;
157157 }
158158 self . updateView ( ) ;
159159 return false ;
160160 } ) ;
161161} ;
162162
163- nglr . Binder . prototype . translateBinding = function ( node , parentPath , factories ) {
163+ Binder . prototype . translateBinding = function ( node , parentPath , factories ) {
164164 var path = parentPath . concat ( ) ;
165165 var offset = path . pop ( ) ;
166- var parts = nglr . Binder . parseBindings ( node . nodeValue ) ;
167- if ( parts . length > 1 || nglr . Binder . binding ( parts [ 0 ] ) ) {
166+ var parts = Binder . parseBindings ( node . nodeValue ) ;
167+ if ( parts . length > 1 || Binder . binding ( parts [ 0 ] ) ) {
168168 var parent = node . parentNode ;
169- if ( nglr . isLeafNode ( parent ) ) {
169+ if ( isLeafNode ( parent ) ) {
170170 parent . setAttribute ( 'ng-bind-template' , node . nodeValue ) ;
171171 factories . push ( { path :path , fn :function ( node , scope , prefix ) {
172- return new nglr . BindUpdater ( node , node . getAttribute ( 'ng-bind-template' ) ) ;
172+ return new BindUpdater ( node , node . getAttribute ( 'ng-bind-template' ) ) ;
173173 } } ) ;
174174 } else {
175175 for ( var i = 0 ; i < parts . length ; i ++ ) {
176176 var part = parts [ i ] ;
177- var binding = nglr . Binder . binding ( part ) ;
177+ var binding = Binder . binding ( part ) ;
178178 var newNode ;
179179 if ( binding ) {
180180 newNode = document . createElement ( "span" ) ;
181181 var jNewNode = jQuery ( newNode ) ;
182182 jNewNode . attr ( "ng-bind" , binding ) ;
183183 if ( i === 0 ) {
184- factories . push ( { path :path . concat ( offset + i ) , fn :nglr . Binder . prototype . ng_bind } ) ;
184+ factories . push ( { path :path . concat ( offset + i ) , fn :Binder . prototype . ng_bind } ) ;
185185 }
186- } else if ( nglr . msie && part . charAt ( 0 ) == ' ' ) {
186+ } else if ( msie && part . charAt ( 0 ) == ' ' ) {
187187 newNode = document . createElement ( "span" ) ;
188188 newNode . innerHTML = ' ' + part . substring ( 1 ) ;
189189 } else {
@@ -196,7 +196,7 @@ nglr.Binder.prototype.translateBinding = function(node, parentPath, factories) {
196196 }
197197} ;
198198
199- nglr . Binder . prototype . precompile = function ( root ) {
199+ Binder . prototype . precompile = function ( root ) {
200200 var factories = [ ] ;
201201 this . precompileNode ( root , [ ] , factories ) ;
202202 return function ( template , scope , prefix ) {
@@ -211,13 +211,13 @@ nglr.Binder.prototype.precompile = function(root) {
211211 try {
212212 scope . addWidget ( factory . fn ( node , scope , prefix ) ) ;
213213 } catch ( e ) {
214- nglr . alert ( e ) ;
214+ alert ( e ) ;
215215 }
216216 }
217217 } ;
218218} ;
219219
220- nglr . Binder . prototype . precompileNode = function ( node , path , factories ) {
220+ Binder . prototype . precompileNode = function ( node , path , factories ) {
221221 var nodeType = node . nodeType ;
222222 if ( nodeType == Node . TEXT_NODE ) {
223223 this . translateBinding ( node , path , factories ) ;
@@ -234,19 +234,19 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
234234 if ( attributes ) {
235235 var bindings = node . getAttribute ( 'ng-bind-attr' ) ;
236236 node . removeAttribute ( 'ng-bind-attr' ) ;
237- bindings = bindings ? nglr . fromJson ( bindings ) : { } ;
237+ bindings = bindings ? fromJson ( bindings ) : { } ;
238238 var attrLen = attributes . length ;
239239 for ( var i = 0 ; i < attrLen ; i ++ ) {
240240 var attr = attributes [ i ] ;
241241 var attrName = attr . name ;
242242 // http://www.glennjones.net/Post/809/getAttributehrefbug.htm
243- var attrValue = nglr . msie && attrName == 'href' ?
243+ var attrValue = msie && attrName == 'href' ?
244244 decodeURI ( node . getAttribute ( attrName , 2 ) ) : attr . value ;
245- if ( nglr . Binder . hasBinding ( attrValue ) ) {
245+ if ( Binder . hasBinding ( attrValue ) ) {
246246 bindings [ attrName ] = attrValue ;
247247 }
248248 }
249- var json = nglr . toJson ( bindings ) ;
249+ var json = toJson ( bindings ) ;
250250 if ( json . length > 2 ) {
251251 node . setAttribute ( "ng-bind-attr" , json ) ;
252252 }
@@ -270,7 +270,7 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
270270 return clone ;
271271 } ;
272272 factories . push ( { path :path , fn :function ( node , scope , prefix ) {
273- return new nglr . RepeaterUpdater ( jQuery ( node ) , repeaterExpression , template , prefix ) ;
273+ return new RepeaterUpdater ( jQuery ( node ) , repeaterExpression , template , prefix ) ;
274274 } } ) ;
275275 return ;
276276 }
@@ -309,42 +309,42 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
309309 }
310310} ;
311311
312- nglr . Binder . prototype . ng_eval = function ( node ) {
313- return new nglr . EvalUpdater ( node , node . getAttribute ( 'ng-eval' ) ) ;
312+ Binder . prototype . ng_eval = function ( node ) {
313+ return new EvalUpdater ( node , node . getAttribute ( 'ng-eval' ) ) ;
314314} ;
315315
316- nglr . Binder . prototype . ng_bind = function ( node ) {
317- return new nglr . BindUpdater ( node , "{{" + node . getAttribute ( 'ng-bind' ) + "}}" ) ;
316+ Binder . prototype . ng_bind = function ( node ) {
317+ return new BindUpdater ( node , "{{" + node . getAttribute ( 'ng-bind' ) + "}}" ) ;
318318} ;
319319
320- nglr . Binder . prototype . ng_bind_attr = function ( node ) {
321- return new nglr . BindAttrUpdater ( node , nglr . fromJson ( node . getAttribute ( 'ng-bind-attr' ) ) ) ;
320+ Binder . prototype . ng_bind_attr = function ( node ) {
321+ return new BindAttrUpdater ( node , fromJson ( node . getAttribute ( 'ng-bind-attr' ) ) ) ;
322322} ;
323323
324- nglr . Binder . prototype . ng_hide = function ( node ) {
325- return new nglr . HideUpdater ( node , node . getAttribute ( 'ng-hide' ) ) ;
324+ Binder . prototype . ng_hide = function ( node ) {
325+ return new HideUpdater ( node , node . getAttribute ( 'ng-hide' ) ) ;
326326} ;
327327
328- nglr . Binder . prototype . ng_show = function ( node ) {
329- return new nglr . ShowUpdater ( node , node . getAttribute ( 'ng-show' ) ) ;
328+ Binder . prototype . ng_show = function ( node ) {
329+ return new ShowUpdater ( node , node . getAttribute ( 'ng-show' ) ) ;
330330} ;
331331
332- nglr . Binder . prototype . ng_class = function ( node ) {
333- return new nglr . ClassUpdater ( node , node . getAttribute ( 'ng-class' ) ) ;
332+ Binder . prototype . ng_class = function ( node ) {
333+ return new ClassUpdater ( node , node . getAttribute ( 'ng-class' ) ) ;
334334} ;
335335
336- nglr . Binder . prototype . ng_class_even = function ( node ) {
337- return new nglr . ClassEvenUpdater ( node , node . getAttribute ( 'ng-class-even' ) ) ;
336+ Binder . prototype . ng_class_even = function ( node ) {
337+ return new ClassEvenUpdater ( node , node . getAttribute ( 'ng-class-even' ) ) ;
338338} ;
339339
340- nglr . Binder . prototype . ng_class_odd = function ( node ) {
341- return new nglr . ClassOddUpdater ( node , node . getAttribute ( 'ng-class-odd' ) ) ;
340+ Binder . prototype . ng_class_odd = function ( node ) {
341+ return new ClassOddUpdater ( node , node . getAttribute ( 'ng-class-odd' ) ) ;
342342} ;
343343
344- nglr . Binder . prototype . ng_style = function ( node ) {
345- return new nglr . StyleUpdater ( node , node . getAttribute ( 'ng-style' ) ) ;
344+ Binder . prototype . ng_style = function ( node ) {
345+ return new StyleUpdater ( node , node . getAttribute ( 'ng-style' ) ) ;
346346} ;
347347
348- nglr . Binder . prototype . ng_watch = function ( node , scope ) {
348+ Binder . prototype . ng_watch = function ( node , scope ) {
349349 scope . watch ( node . getAttribute ( 'ng-watch' ) ) ;
350350} ;
0 commit comments