Ported to 1.2.0 by HattCzech
[webos-internals:adamrmcd-modifications.git] / messaging / charcounter.patch
1 diff -ur /usr/palm/app-original/com.palm.app.messaging/app/controllers/chatview-assistant.js /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
2 --- /usr/palm/app-original/com.palm.app.messaging/app/controllers/chatview-assistant.js 2009-09-13 23:09:56.000000000 -0500
3 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js 2009-09-28 15:29:40.000000000 -0500
4 @@ -187,6 +187,11 @@
5                                 segmentCountContainer: this.controller.get('segmentCounterContainer'),
6                                 segmentCountElement: this.controller.get('segmentCounter'),
7                                 setTextFieldValueFn: this.setTextFieldValue.bind(this)
8 +                       },
9 +                       charCounter: {
10 +                               charCountContainer: this.controller.get('charCounterContainer'),
11 +                               charCountElement: this.controller.get('charCounter'),
12 +                               setTextFieldValueFn: this.setTextFieldValue.bind(this)
13                         }
14                 };
15  
16 diff -ur /usr/palm/app-original/com.palm.app.messaging/app/controllers/compose-assistant.js /usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
17 --- /usr/palm/app-original/com.palm.app.messaging/app/controllers/compose-assistant.js  2009-09-13 23:09:56.000000000 -0500
18 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js  2009-09-28 15:30:36.000000000 -0500
19 @@ -140,6 +140,11 @@
20                         segmentCountContainer: this.controller.get('segmentCounterContainer'),
21                         segmentCountElement: this.controller.get('segmentCounter'),
22                         setTextFieldValueFn: this.setTextFieldValue.bind(this)
23 +               },
24 +               charCounter: {
25 +                       charCountContainer: this.controller.get('charCounterContainer'),
26 +                       charCountElement: this.controller.get('charCounter'),
27 +                       setTextFieldValueFn: this.setTextFieldValue.bind(this)
28                 }
29         };
30  
31 diff -ur /usr/palm/app-original/com.palm.app.messaging/app/utilities/CharacterCounter.js /usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js
32 --- /usr/palm/app-original/com.palm.app.messaging/app/utilities/CharacterCounter.js     2009-09-13 23:09:56.000000000 -0500
33 +++ /usr/palm/applications/com.palm.app.messaging/app/utilities/CharacterCounter.js     2009-09-28 15:34:44.000000000 -0500
34 @@ -58,6 +58,10 @@
35                                 containerElement: null,
36                                 valueElement: null
37                         };
38 +                       var charCounterUI = {
39 +                               containerElement: null,
40 +                               valueElement: null
41 +                       };
42                         
43                                                 
44                         // TODO: eventually we might want to implement some cleverness that counts
45 @@ -291,6 +295,20 @@
46                                 }
47                         };
48                         
49 +                       var setCurrentCharCount = function(newCharCount) {
50 +                               if(charCounterUI.valueElement)
51 +                                       charCounterUI.valueElement.update(newCharCount);
52 +                               if(charCounterUI.containerElement) {
53 +                                       if (newCharCount == 0) {
54 +                                               if (charCounterUI.containerElement.visible())
55 +                                                       charCounterUI.containerElement.hide();
56 +                                       } else {
57 +                                               if (!charCounterUI.containerElement.visible())
58 +                                                       charCounterUI.containerElement.show();
59 +                                       }
60 +                               }
61 +                       };
62 +                       
63                         return {
64                                 
65                                 init: function(controller,platform,textElement,params) {
66 @@ -451,7 +469,13 @@
67                                                                 setTextFieldValueFn = params.segmentCounter.setTextFieldValueFn;
68                                                         }                                               
69                                                 }
70 -
71 +                                               if(params.charCounter) {
72 +                                                       charCounterUI.containerElement = params.charCounter.charCountContainer;
73 +                                                       charCounterUI.valueElement = params.charCounter.charCountElement;
74 +                                                       if(params.charCounter.setTextFieldValueFn) {
75 +                                                               setTextFieldValueFn = params.charCounter.setTextFieldValueFn;
76 +                                                       }                                               
77 +                                               }
78                                         }                                       
79                                 },
80                                 
81 @@ -517,6 +541,7 @@
82                                         
83                                         var messageData = parseMessage(rawCharacterData.message,rawCharacterData.count,true);
84                                         adjustedCharacterCount = messageData.adjustedCharacterCount;
85 +                                       setCurrentCharCount(rawCharacterData.count);
86                                         if (adjustedMaxLen > 0)
87                                                 setOverLimit(messageData.isOverLimit);
88                                         setCurrentSegmentCount(messageData.segmentCount);                               
89 diff -ur /usr/palm/app-original/com.palm.app.messaging/app/views/chatview/chatview-scene.html /usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html
90 --- /usr/palm/app-original/com.palm.app.messaging/app/views/chatview/chatview-scene.html        2009-09-13 23:09:57.000000000 -0500
91 +++ /usr/palm/applications/com.palm.app.messaging/app/views/chatview/chatview-scene.html        2009-09-28 15:35:16.000000000 -0500
92 @@ -22,6 +22,10 @@
93                         <div id="messageContainer" class='palm-row'>
94                                 <div class="palm-row-wrapper textfield-group focused">
95                                         <div class="title">
96 +                                               <div id="charCounterContainer" style="display: none;">
97 +                                                       <div id="charCounter">
98 +                                                       </div>
99 +                                               </div>
100                                                 <div id="attachmentContainer" style="display: none;">
101                                                         <div id="cancelAttachment">
102                                                         </div>
103 diff -ur /usr/palm/app-original/com.palm.app.messaging/app/views/compose/compose-scene.html /usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html
104 --- /usr/palm/app-original/com.palm.app.messaging/app/views/compose/compose-scene.html  2009-09-13 23:09:57.000000000 -0500
105 +++ /usr/palm/applications/com.palm.app.messaging/app/views/compose/compose-scene.html  2009-09-28 15:36:15.000000000 -0500
106 @@ -6,6 +6,10 @@
107                 <div id="messageContainer" class='palm-row'>
108                         <div class="palm-row-wrapper textfield-group focused">
109                                 <div class="title">
110 +                                       <div id="charCounterContainer" style="display: none;">
111 +                                               <div id="charCounter">
112 +                                               </div>
113 +                                       </div>
114                                         <div id="attachmentContainer" style="display: none;">
115                                                 <div id="cancelAttachment">
116                                                 </div>
117 diff -ur /usr/palm/app-original/com.palm.app.messaging/stylesheets/messaging.css /usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
118 --- /usr/palm/app-original/com.palm.app.messaging/stylesheets/messaging.css     2009-09-13 23:10:04.000000000 -0500
119 +++ /usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css     2009-09-28 15:37:25.000000000 -0500
120 @@ -837,6 +837,23 @@
121  #messageContainer.palm-row .icon.right {
122         height: 61px;
123  }
124 +#messageContainer #charCounterContainer {
125 +       line-height: 20px;
126 +       display:block;
127 +       height: 20px;
128 +       border-width: 0px 10px 0px 9px;
129 +       -webkit-border-image: url(../images/message-segment-badge.png) 0 10 0 9 stretch stretch;
130 +       position: absolute;
131 +       z-index: 3;
132 +       top: 2px;
133 +       left: 2px;
134 +}
135 +#messageContainer #charCounterContainer #charCounter {
136 +       font-size: 12px;
137 +       font-weight: bold;
138 +       color: #679BC2;
139 +       margin: 0px -4px 3px -3px;
140 +}
141  #messageContainer #attachmentContainer {
142         position: relative;
143         margin-top:10px;