Просмотр исходного кода

修复转word时的loadpage事件执行顺序问题

huqi 4 лет назад
Родитель
Сommit
9df51bc27f

+ 16 - 0
o2web/source/o2_core/o2.js

@@ -2487,8 +2487,24 @@ o2.core = true;
             h += (this.getStyle("padding-left").toFloat() || 0)+ (this.getStyle("padding-right").toFloat() || 0);
             if (!notMargin) h += (this.getStyle("margin-left").toFloat() || 0)+ (this.getStyle("margin-right").toFloat() || 0);
             return h;
+        },
+        "getSize": function(){
+            if ((/^(?:body|html)$/i).test(this.tagName)) return this.getWindow().getSize();
+            if (!window.getComputedStyle) return {x: this.offsetWidth, y: this.offsetHeight};
+            if (this.get('tag') == 'svg') return svgCalculateSize(this);
+            try {
+                if (!layout.scale || layout.scale==1){
+                    var bounds = this.getBoundingClientRect();
+                    return {x: bounds.width, y: bounds.height};
+                }else{
+                    return {"x": this.offsetWidth.toFloat(), "y": this.offsetHeight.toFloat()};
+                }
+            } catch (e){
+                return {x: 0, y: 0};
+            }
         }
     });
+
     Object.copy = function(from, to){
         Object.each(from, function(value, key){
             switch (typeOf(value)){

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/blue/layout-pc.html

@@ -8,7 +8,7 @@
                 <div class="layout_menu_lnk_area" data-o2-element="lnkAreaNode"></div>
             </div>
             <div class="layout_menu_setting deepColor_bg">
-                <div class="layout_menu_setting_button icon_setting" data-o2-element="settingNode"></div>
+                <div class="layout_menu_setting_button icon_setting" data-o2-element="settingNode" data-o2-events="click:scale"></div>
             </div>
         </div>
     </div>

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/blue/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/cyan/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/darkgreen/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/gray/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/green/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/navy/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/orange/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/purple/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/red/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 1 - 1
o2web/source/o2_core/o2/xDesktop/$Default/tan/style-pc.css

@@ -487,7 +487,7 @@
 .layout_start_item_icon {
     width: 40px;
     height: 40px;
-    background-size: cover;
+    background-size: contain;
     background-repeat: no-repeat;
     background-position: center;
 }

+ 93 - 0
o2web/source/o2_core/o2/xDesktop/Default.js

@@ -11,6 +11,99 @@ o2.xDesktop.Default = new Class({
         "style": "blue",
         "index": "Homepage"
     },
+    scale: function(){
+        debugger;
+        //document.body.setStyle("zoom", "80%");
+        if (!layout.scale) layout.scale = 1;
+        layout.scale = layout.scale-0.1;
+        if (layout.scale<0.4) layout.scale = 0.4;
+        //
+        //layout.scale = 0.8;
+        var s = (1/layout.scale)*100;
+        var p = s+"%";
+        //
+        document.body.setStyles({
+            "transform": "scale("+layout.scale+")",
+            "transform-origin": "0 0",
+            "width": p,
+            "height":p
+        });
+        this.fireEvent("resize");
+        //
+        // // if (!this.resizeScaleEvent){
+        // //     this.addEvent("resize", this.resizeScale.bind(this));
+        // // }
+        //this.resizeScale();
+    },
+    resizeScale: function(){
+        if (layout.scale!==1){
+            var node = document.body.getFirst();
+            while (node){
+                this.resizeScaleNode(node);
+                node = node.getNext();
+            }
+        }
+    },
+    setStyleValue: function(v, node, key){
+        if (node.hasClass("layout_menu_lnk_item")){
+            debugger;
+        }
+        if (v && v.indexOf("%")==-1){
+            var u = v.substr(v.length-2, v.length);
+            var o = v.substr(0, v.length-2);
+            if (o!=0){
+                o = o.toFloat()*(1/layout.scale);
+                node.setStyle(key, o+u);
+            }
+        }
+    },
+    resizeScaleNode: function(node){
+        //var style = node.getStyles("width", "height", "min-width", "min-height");
+        //this.setStyleValue(node.getStyle("width"), node, "width");
+        this.setStyleValue(node.getStyle("height"), node, "height");
+        //this.setStyleValue(node.getStyle("min-width"), node, "min-width");
+        this.setStyleValue(node.getStyle("min-height"), node, "min-height");
+
+        //this.setStyleValue(node.getStyle("padding-left"), node, "padding-left");
+        //this.setStyleValue(node.getStyle("padding-top"), node, "padding-top");
+        //this.setStyleValue(node.getStyle("padding-right"), node, "padding-right");
+        //this.setStyleValue(node.getStyle("padding-bottom"), node, "padding-bottom");
+
+        // this.setStyleValue(node.style.paddingLeft, node, "padding-left");
+        // this.setStyleValue(node.style.paddingTop, node, "padding-top");
+        // this.setStyleValue(node.style.paddingRight, node, "padding-right");
+        // this.setStyleValue(node.style.paddingBottom, node, "padding-bottom");
+
+        // if (v && v.indexOf("%")==-1)
+        //
+        // Object.keys(style).each(function(key){
+        //     var v = style[key];
+        //     if (v.indexOf("%")==-1){
+        //         debugger;
+        //         var u = v.substr(v.length-2, v.length);
+        //         var o = v.substr(0, v.length-2);
+        //         o = o.toFloat()*(1/layout.scale);
+        //         node.setStyle(key, o+u);
+        //     }
+        //     // var v = *(1/layout.scale);
+        //     // node.setStyle(key, v)
+        // }.bind(this));
+
+        // if (style.height.indexOf("%")!=-1){
+        //     alert(style.height);
+        // }
+
+        var sub = node.getFirst();
+        if (sub) this.resizeScaleNode(sub);
+
+        // while (sub) {
+        //     this.resizeScaleNode(sub);
+        //     var sub = sub.getFirst();
+        // }
+        var next = node.getNext();
+        if (next) this.resizeScaleNode(next);
+    },
+
     initialize: function(node, options){
         this.setOptions(options);
         this.type = "layout";