new patches
[webos-internals:jeffrotulls-modifications.git] / messaging / messaging-character-counter-with-text-counter.patch
1 diff --git a/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js b/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
2 index 2aca4c6..d0b973f 100644
3 --- a/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
4 +++ b/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
5 @@ -52,6 +52,10 @@ var CharacterCounter = Class.create({
6                                 containerElement: null,
7                                 valueElement: null
8                         };
9 +                       var charCounterUI = {
10 +                               containerElement: null,
11 +                               valueElement: null
12 +                       };
13                         
14                                                 
15                         // TODO: eventually we might want to implement some cleverness that counts
16 @@ -407,6 +411,20 @@ var CharacterCounter = Class.create({
17                                 }
18                         };
19                         
20 +                       var setCurrentCharCount = function(newCharCount) {
21 +                               if(charCounterUI.valueElement)
22 +                                       charCounterUI.valueElement.update(currentSegmentCount + ':' + newCharCount);
23 +                               if(charCounterUI.containerElement) {
24 +                                       if (newCharCount == 0) {
25 +                                               if (charCounterUI.containerElement.visible())
26 +                                                       charCounterUI.containerElement.hide();
27 +                                       } else {
28 +                                               if (!charCounterUI.containerElement.visible())
29 +                                                       charCounterUI.containerElement.show();
30 +                                       }
31 +                               }
32 +                       };
33 +                       
34                         return {
35                                 
36                                 init: function(controller,platform,textElement,params) {
37 @@ -514,7 +532,13 @@ var CharacterCounter = Class.create({
38                                                                 setTextFieldValueFn = params.segmentCounter.setTextFieldValueFn;
39                                                         }                                               
40                                                 }
41 -
42 +                                               if(params.charCounter) {
43 +                                                       charCounterUI.containerElement = params.charCounter.charCountContainer;
44 +                                                       charCounterUI.valueElement = params.charCounter.charCountElement;
45 +                                                       if(params.charCounter.setTextFieldValueFn) {
46 +                                                               setTextFieldValueFn = params.charCounter.setTextFieldValueFn;
47 +                                                       }                                               
48 +                                               }
49                                         }                                       
50                                 },
51                                 
52 @@ -584,7 +608,8 @@ var CharacterCounter = Class.create({
53                                         adjustedCharacterCount = messageData.adjustedCharacterCount;
54                                         if (adjustedMaxLen > 0)
55                                                 setOverLimit(messageData.isOverLimit);
56 -                                       setCurrentSegmentCount(messageData.segmentCount);                               
57 +                                       setCurrentSegmentCount(messageData.segmentCount);       
58 +                                       setCurrentCharCount(rawCharacterData.count);                                                    
59                                 },
60                                 
61                                 deferredResetCount: function() {