@@ -88,7 +88,8 @@ window.POG=(function() {
88
88
currentSelector += '[type=\'' + node . type + '\']' ;
89
89
}
90
90
else if ( node . getAttribute ( 'data-type' ) ) {
91
- currentSelector += '[data-type=\'' + node . getAttribute ( 'data-type' ) + '\']' ;
91
+ currentSelector += '[data-type=\'' +
92
+ node . getAttribute ( 'data-type' ) + '\']' ;
92
93
}
93
94
}
94
95
}
@@ -134,7 +135,7 @@ window.POG=(function() {
134
135
buffer . operation . documentation = input . action + suffixes . action +
135
136
suffixes . documentation ;
136
137
buffer . operation . name = getLetter ( input . action + suffixes . name ,
137
- input . letters . operation ) ;
138
+ input . letters . operation , input . action ) ;
138
139
139
140
return buffer ;
140
141
}
@@ -147,12 +148,11 @@ window.POG=(function() {
147
148
var clones = cloned . getElementsByTagName ( '*' ) ;
148
149
var originals = original . getElementsByTagName ( '*' ) ;
149
150
var hiddens = ( cloned ) ? Array . filter ( cloned . querySelectorAll (
150
- '*:not(br):not(img):not(input):not(link):not(option):not(script):not(select):not(style)' ) ,
151
- function ( item , index ) {
152
- var sourceIndex = [ ] . indexOf . call ( clones , item ) ;
153
- return originals [ sourceIndex ] . offsetHeight < 1 ||
154
- ! isElementInViewport ( item ) ;
155
- } ) : [ ] ;
151
+ '*:not(br):not(img):not(input):not(link):not(option):not(script):not(select):not(style)'
152
+ ) , function ( item , index ) {
153
+ var sourceIndex = [ ] . indexOf . call ( clones , item ) ;
154
+ return originals [ sourceIndex ] . offsetHeight < 1 || ! isElementInViewport ( item ) ;
155
+ } ) : [ ] ;
156
156
return hiddens ;
157
157
}
158
158
@@ -214,33 +214,42 @@ window.POG=(function() {
214
214
return text ;
215
215
}
216
216
217
- function getLetter ( value , type ) {
217
+ function getLetter ( value , type , action ) {
218
+ action = action || '' ;
218
219
type = type || LETTERS . CAMEL ;
219
220
type = parseInt ( type ) ;
220
221
value = value || '' ;
221
222
223
+ if ( type !== LETTERS . NATURAL ) {
224
+ // move number prefix to the end of the value
225
+ var oldValue = value . replace ( action , '' ) . trim ( ) ;
226
+ var numberPrefix = / ^ ( [ \d . ] + ) / . exec ( oldValue ) ;
227
+ if ( numberPrefix ) {
228
+ value = value . replace ( numberPrefix [ 0 ] , '' ) + ' ' + numberPrefix [ 0 ] ;
229
+ }
230
+ }
231
+
222
232
switch ( type ) {
223
233
case LETTERS . LOWER :
224
234
case LETTERS . UPPER :
225
235
value = value . replace ( / \. / g, '_' ) . replace ( / \s + | _ _ / g, '_' ) . replace ( / ^ _ | _ $ / g, '' ) ;
226
236
value = ( type === LETTERS . LOWER ) ? value . toLowerCase ( ) : value . toUpperCase ( ) ;
227
237
break ;
228
238
case LETTERS . CAMEL :
229
- case LETTERS . NATURAL :
230
239
case LETTERS . PROPER :
231
240
value = value . replace ( / \. / g, ' ' ) . trim ( ) . replace ( / \s \s + / g, ' ' ) .
232
241
replace ( / \w \S * / g, function ( word ) {
233
242
return word . charAt ( 0 ) . toUpperCase ( ) + word . substr ( 1 ) . toLowerCase ( ) ;
234
- } ) ;
235
-
236
- if ( type === LETTERS . CAMEL || type === LETTERS . PROPER ) {
237
- value = value . replace ( / \s + / g, '' ) ;
238
-
239
- if ( type === LETTERS . CAMEL ) {
240
- value = value . charAt ( 0 ) . toLowerCase ( ) + value . substr ( 1 ) ;
241
- }
243
+ } ) . replace ( / \s + / g, '' ) ;
244
+ if ( type === LETTERS . CAMEL ) {
245
+ value = value . charAt ( 0 ) . toLowerCase ( ) + value . substr ( 1 ) ;
242
246
}
243
247
break ;
248
+ case LETTERS . NATURAL :
249
+ value = value . trim ( ) . replace ( / \s \s + / g, ' ' ) . replace ( / \w \S * / g, function ( word ) {
250
+ return word . charAt ( 0 ) . toUpperCase ( ) + word . substr ( 1 ) . toLowerCase ( ) ;
251
+ } ) ;
252
+ break ;
244
253
}
245
254
246
255
return value ;
@@ -438,7 +447,9 @@ window.POG=(function() {
438
447
}
439
448
440
449
// desc
441
- sentences . sort ( function ( a , b ) { return sentences . frequencies [ b ] - sentences . frequencies [ a ] ; } ) ;
450
+ sentences . sort ( function ( a , b ) {
451
+ return sentences . frequencies [ b ] - sentences . frequencies [ a ] ;
452
+ } ) ;
442
453
443
454
return sentences ;
444
455
}
@@ -450,11 +461,12 @@ window.POG=(function() {
450
461
words . frequencies = { } ;
451
462
words . tops = [ ] ;
452
463
453
- text . toLowerCase ( ) . split ( / [ \s * \. * \, \; \+ ? \# \| : \- \/ \\ \[ \] \( \) \{ \} $ % & 0 - 9 * ] / ) . map ( function ( k , v ) {
454
- if ( k && k . length > 1 ) {
455
- words . frequencies [ k ] ++ || ( words . frequencies [ k ] = 1 ) ;
456
- }
457
- } ) ;
464
+ text . toLowerCase ( ) . split ( / [ \s * \. * \, \; \+ ? \# \| : \- \/ \\ \[ \] \( \) \{ \} $ % & 0 - 9 * ] / ) .
465
+ map ( function ( k , v ) {
466
+ if ( k && k . length > 1 ) {
467
+ words . frequencies [ k ] ++ || ( words . frequencies [ k ] = 1 ) ;
468
+ }
469
+ } ) ;
458
470
459
471
for ( var word in words . frequencies ) {
460
472
words [ ++ index ] = word ;
@@ -588,10 +600,11 @@ window.POG=(function() {
588
600
submit . label = label ;
589
601
submit . text = text ;
590
602
}
591
- else if ( submit . text === '' && text . toLowerCase ( ) . indexOf ( 'submit' ) > - 1 ) {
592
- submit . label = label ;
593
- submit . text = text ;
594
- }
603
+ else if ( submit . text === '' && text . toLowerCase ( ) .
604
+ indexOf ( 'submit' ) > - 1 ) {
605
+ submit . label = label ;
606
+ submit . text = text ;
607
+ }
595
608
}
596
609
else {
597
610
if ( inputType === 'hidden' ) {
0 commit comments