Project

General

Profile

chrome_style_issue_1.txt

Sergey Ivanovskiy, 12/15/2015 02:56 PM

Download (8.73 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.js'
2
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.js	2015-10-22 23:14:19 +0000
3
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.js	2015-12-15 19:48:22 +0000
4
@@ -19,6 +19,8 @@
5
 **                  common clipboard logic.  Added p2j.fonts.
6
 ** 007 SBI 20150901 Modifications to initialization order.
7
 ** 008 SBI 20151020 Increased logging buffer size.
8
+** 009 SBI 20151215 Fixed to take into an account that for Chrome an element style object has only
9
+**                  the "getter" access function. 
10
 */
11
 
12
 "use strict";
13
@@ -135,9 +137,16 @@
14
          {
15
             if (typeof source[prop] == "object")
16
             {
17
-               target[prop] = {};
18
-               
19
-               setOwnPropertiesTo(target[prop], source[prop]);
20
+               if (prop === "style" && target.setAttribute !== undefined
21
+                  && typeof target.setAttribute === "function")
22
+               {
23
+                  setStyleForElement(target, source[prop]);
24
+               }
25
+               else
26
+               {
27
+                  target[prop] = {};
28
+                  setOwnPropertiesTo(target[prop], source[prop]);
29
+               }
30
             }
31
             else
32
             {
33
@@ -148,6 +157,68 @@
34
    }
35
    
36
    /**
37
+    * Returns the string representation of all own object's properties in the following format:
38
+    * [key1 : value1[; key2 : value2] ...]
39
+    * 
40
+    * @param    {Object} styleObj
41
+    *           The custom object that holds the target style properties.
42
+    *
43
+    * @return   The object's properties as a "key1 : value1; key2 : value2 ..." string.
44
+    */
45
+   function toProperties(styleObj)
46
+   {
47
+      var clsDef = "";
48
+      if (!styleObj)
49
+      {
50
+         return clsDef;
51
+      }
52
+      
53
+      for (var prop in styleObj)
54
+      {
55
+         if (styleObj.hasOwnProperty(prop))
56
+         {
57
+            if (typeof styleObj[prop] !== "object")
58
+            {
59
+               clsDef += (prop + ":" + styleObj[prop] + ";");
60
+            }
61
+         }
62
+      }
63
+      
64
+      return clsDef;
65
+   }
66
+   
67
+   /**
68
+    * Sets the provided style properties for the given html element.
69
+    * 
70
+    * @param    {HtmlElement} element
71
+    *           The DOM element which will be the parent for the new canvas. If not provided, the
72
+    *           default container element will be used.
73
+    * @param    {Object} styleObj
74
+    *           The custom object that holds the target style properties.
75
+    */
76
+   function setStyleForElement(element, styleObj)
77
+   {
78
+      if (element["styleObj"] === undefined)
79
+      {
80
+         element["styleObj"] = styleObj;
81
+      }
82
+      else
83
+      {
84
+         // override common properties
85
+         for (var prop in styleObj)
86
+         {
87
+            if (styleObj.hasOwnProperty(prop))
88
+            {
89
+               element["styleObj"][prop] = styleObj[prop];
90
+            }
91
+         }
92
+      }
93
+      element.setAttribute("style", toProperties(element["styleObj"]));
94
+   }
95
+   
96
+   me.setStyleForElement = setStyleForElement;
97
+   
98
+   /**
99
     * Helper function to crate a new canvas as a child of the given element and with
100
     * caller-defined optional settings.
101
     *
102

    
103
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js'
104
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js	2015-10-22 23:14:19 +0000
105
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js	2015-12-15 19:46:52 +0000
106
@@ -11,6 +11,8 @@
107
 ** -#- -I- --Date-- ------------------------------Description----------------------------------
108
 ** 001 SBI 20150906 The virtual desktop to create task bar and drop zones.
109
 ** 002 SBI 20151020 Fix for disabling old task icons.
110
+** 003 SBI 20151215 Fixed to take into an account that for Chrome an element style object has only
111
+**                  the "getter" access function. 
112
 */
113
 
114
 "use strict";
115
@@ -77,9 +79,7 @@
116
    /** the parent element for the virtual desktop */
117
    var desktop = document.createElement("div");
118
    
119
-   desktop.style["position"] = "fixed";
120
-   desktop.style["top"]  = "0px";
121
-   desktop.style["left"] = "0px";
122
+   p2j.setStyleForElement(desktop, {position : "fixed", top : "0px", left : "0px"});
123
    
124
    var body = document.body;
125
    body.appendChild(desktop);
126
@@ -109,14 +109,15 @@
127
       var bottom = document.createElement("div");
128
       bottom.className = dockClassName;
129
       
130
-      bottom.style["position"] = "fixed";
131
-      
132
-      bottom.style["bottom"]  = "0px";
133
-      
134
-      bottom.style["height"] = height + "px";
135
-      bottom.style["width"]  = "100%";
136
-
137
-      bottom.style.zIndex = MAX_Z_INDEX;
138
+      p2j.setStyleForElement(bottom,
139
+                               {
140
+                                  position : "fixed",
141
+                                  left     : "0px",
142
+                                  bottom   : "0px",
143
+                                  height   : height + "px",
144
+                                  width    : "100%",
145
+                                  "z-index"  : MAX_Z_INDEX
146
+                               });
147
       return bottom;
148
    };
149
    
150
@@ -135,15 +136,15 @@
151
    {
152
       var right = document.createElement("div");
153
       right.className = dockClassName;
154
-      right.style["position"] = "fixed";
155
-      
156
-      right.style["right"] = "0px";
157
-      right.style["top"]   = "0px";
158
-      
159
-      right.style["height"] = "100%";
160
-      right.style["width"]  = width + "px";
161
-
162
-      right.style.zIndex = MIN_Z_INDEX;
163
+      p2j.setStyleForElement(right,
164
+                              {
165
+                                 position : "fixed",
166
+                                 right    : "0px",
167
+                                 top      : "0px",
168
+                                 height   : "100%",
169
+                                 width    : width + "px",
170
+                                 "z-index"  : MIN_Z_INDEX
171
+                              });
172
       return right;
173
    };
174
    
175
@@ -161,13 +162,13 @@
176
       var peer = document.createElement("div");
177
       peer.id = id;
178
       peer.tabIndex = 1;
179
-      peer.style["position"] = "relative";
180
-      
181
-      peer.style["height"] = "100%";
182
-      peer.style["width"]  = "100%";
183
-      
184
-      peer.style.zIndex = MAX_Z_INDEX;
185
-      
186
+      p2j.setStyleForElement(peer,
187
+            {
188
+               position : "relative",
189
+               height   : "100%",
190
+               width    : "100%",
191
+               "z-index"  : MAX_Z_INDEX
192
+            });
193
       peer.draggable = true;
194
       return peer;
195
    };
196
@@ -239,9 +240,12 @@
197
       
198
       var canvas = document.createElement('canvas');
199
       canvas.className="canvas";
200
-      canvas.style["height"] = "100%";
201
-      canvas.style["width"]  = "100%";
202
-      canvas.style.zIndex = MAX_Z_INDEX;
203
+      p2j.setStyleForElement(canvas,
204
+            {
205
+               height   : "100%",
206
+               width    : "100%",
207
+               "z-index"  : MAX_Z_INDEX
208
+            });
209
       
210
       peer.appendChild(canvas);
211
       var ctx = canvas.getContext('2d', {alpha : true});
212
@@ -958,7 +962,10 @@
213
          var cls = event.target.className;
214
           if ( cls.indexOf(DOCK_CLASS_NAME) >= 0)
215
           {
216
-             event.target.style["background"] = getTransparentColor(background, 0.5);
217
+             p2j.setStyleForElement(event.target,
218
+                   {
219
+                      background : getTransparentColor(background, 0.5)
220
+                   });
221
           }
222
       }, false);
223
       
224
@@ -971,7 +978,10 @@
225
          
226
          if ( cls.indexOf(DOCK_CLASS_NAME) >= 0 )
227
          {
228
-            event.target.style["background"] = getTransparentColor(background, 0.0);
229
+            p2j.setStyleForElement(event.target,
230
+                  {
231
+                     background : getTransparentColor(background, 0.0)
232
+                  });
233
          }
234
       }, false);
235
 
236
@@ -988,14 +998,23 @@
237
             try
238
             {
239
                event.target.appendChild(dragged);
240
-               event.target.style.zIndex = MAX_Z_INDEX;
241
-               parent.style["background"] = getTransparentColor(background, 0.0);
242
-               parent.style.zIndex = MIN_Z_INDEX;
243
+               p2j.setStyleForElement(event.target,
244
+                     {
245
+                        "z-index" : MAX_Z_INDEX
246
+                     });
247
+               p2j.setStyleForElement(parent,
248
+                     {
249
+                        background : getTransparentColor(background, 0.0),
250
+                        "z-index"    : MIN_Z_INDEX
251
+                     });
252
             }
253
             catch(e)
254
             {
255
                parent.addChild(dragged);
256
-               parent.style.zIndex = MAX_Z_INDEX;
257
+               p2j.setStyleForElement(parent,
258
+                     {
259
+                        "z-index"    : MAX_Z_INDEX
260
+                     });
261
             }
262
             draw();
263
          }
264