Patch updates 8-22-2010
[webos-internals:modifications.git] / messaging / messaging-character-counter-with-text-counter.patch
1 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
2 index 484cd45..049c8eb 100644
3 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
5 @@ -196,6 +196,11 @@ var ChatviewAssistant = Class.create({
6                                 segmentCountContainer: this.controller.get('segmentCounterContainer'),
7                                 segmentCountElement: this.controller.get('segmentCounter'),
8                                 setTextFieldValueFn: this.setTextFieldValue.bind(this)
9 +                       },
10 +                       charCounter: {
11 +                               charCountContainer: this.controller.get('charCounterContainer'),
12 +                               charCountElement: this.controller.get('charCounter'),
13 +                               setTextFieldValueFn: this.setTextFieldValue.bind(this)
14                         }
15                 };
16  
17 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
18 index 3183de4..718dc2c 100644
19 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
20 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
21 @@ -161,6 +161,11 @@ var ComposeAssistant = Class.create({
22                         segmentCountContainer: this.controller.get('segmentCounterContainer'),
23                         segmentCountElement: this.controller.get('segmentCounter'),
24                         setTextFieldValueFn: this.setTextFieldValue.bind(this)
25 +               },
26 +               charCounter: {
27 +                       charCountContainer: this.controller.get('charCounterContainer'),
28 +                       charCountElement: this.controller.get('charCounter'),
29 +                       setTextFieldValueFn: this.setTextFieldValue.bind(this)
30                 }
31         };
32  
33 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
34 index 2aca4c6..213c69f 100644
35 --- a/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
36 +++ b/usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
37 @@ -52,6 +52,10 @@ var CharacterCounter = Class.create({
38                                 containerElement: null,
39                                 valueElement: null
40                         };
41 +                       var charCounterUI = {
42 +                               containerElement: null,
43 +                               valueElement: null
44 +                       };
45                         
46                                                 
47                         // TODO: eventually we might want to implement some cleverness that counts
48 @@ -407,6 +411,20 @@ var CharacterCounter = Class.create({
49                                 }
50                         };
51                         
52 +                       var setCurrentCharCount = function(newCharCount) {
53 +                               if(charCounterUI.valueElement)
54 +                                       charCounterUI.valueElement.update(currentSegmentCount + '.' + newCharCount);
55 +                               if(charCounterUI.containerElement) {
56 +                                       if (newCharCount == 0) {
57 +                                               if (charCounterUI.containerElement.visible())
58 +                                                       charCounterUI.containerElement.hide();
59 +                                       } else {
60 +                                               if (!charCounterUI.containerElement.visible())
61 +                                                       charCounterUI.containerElement.show();
62 +                                       }
63 +                               }
64 +                       };
65 +                       
66                         return {
67                                 
68                                 init: function(controller,platform,textElement,params) {
69 @@ -514,7 +532,13 @@ var CharacterCounter = Class.create({
70                                                                 setTextFieldValueFn = params.segmentCounter.setTextFieldValueFn;
71                                                         }                                               
72                                                 }
73 -
74 +                                               if(params.charCounter) {
75 +                                                       charCounterUI.containerElement = params.charCounter.charCountContainer;
76 +                                                       charCounterUI.valueElement = params.charCounter.charCountElement;
77 +                                                       if(params.charCounter.setTextFieldValueFn) {
78 +                                                               setTextFieldValueFn = params.charCounter.setTextFieldValueFn;
79 +                                                       }                                               
80 +                                               }
81                                         }                                       
82                                 },
83                                 
84 @@ -584,7 +608,8 @@ var CharacterCounter = Class.create({
85                                         adjustedCharacterCount = messageData.adjustedCharacterCount;
86                                         if (adjustedMaxLen > 0)
87                                                 setOverLimit(messageData.isOverLimit);
88 -                                       setCurrentSegmentCount(messageData.segmentCount);                               
89 +                                       setCurrentSegmentCount(messageData.segmentCount);       
90 +                                       setCurrentCharCount(rawCharacterData.count);                                                    
91                                 },
92                                 
93                                 deferredResetCount: function() {
94 diff --git a/usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html b/usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html
95 index d0d8745..fbc1f82 100644
96 --- a/usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html
97 +++ b/usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html
98 @@ -22,6 +22,10 @@
99                         <div id="messageContainer" class='palm-row'>
100                                 <div class="palm-row-wrapper textfield-group focused">
101                                         <div class="title">
102 +                                               <div id="charCounterContainer" style="display: none;">
103 +                                                       <div id="charCounter">
104 +                                                       </div>
105 +                                               </div>
106                                                 <div id="attachmentContainer" style="display: none;">
107                                                         <div id="cancelAttachment">
108                                                         </div>
109 diff --git a/usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html b/usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html
110 index 30daa88..aa9c440 100644
111 --- a/usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html
112 +++ b/usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html
113 @@ -6,6 +6,10 @@
114                 <div id="messageContainer" class='palm-row'>
115                         <div class="palm-row-wrapper textfield-group focused">
116                                 <div class="title">
117 +                                       <div id="charCounterContainer" style="display: none;">
118 +                                               <div id="charCounter">
119 +                                               </div>
120 +                                       </div>
121                                         <div id="attachmentContainer" style="display: none;">
122                                                 <div id="cancelAttachment">
123                                                 </div>
124 diff --git a/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css b/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
125 index 019deb5..94eb766 100644
126 --- a/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
127 +++ b/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
128 @@ -1017,6 +1017,24 @@ img.avatar-overlay {
129                 height: 61px;
130  }
131  
132 +#messageContainer #charCounterContainer {
133 +       line-height: 20px;
134 +       display:block;
135 +       height: 20px;
136 +       border-width: 0px 10px 0px 9px;
137 +       -webkit-border-image: url(../images/message-segment-badge.png) 0 10 0 9 stretch stretch;
138 +       position: absolute;
139 +       z-index: 3;
140 +       top: 2px;
141 +       left: 2px;
142 +}
143 +#messageContainer #charCounterContainer #charCounter {
144 +       font-size: 12px;
145 +       font-weight: bold;
146 +       color: #679BC2;
147 +       margin: 0px -4px 3px -3px;
148 +}
149 +
150  #messageContainer #attachmentContainer {
151                 position: relative;
152                 margin-top: 10px;