Browse Source

修复sonar扫描问题

guohh 4 years ago
parent
commit
6e94c63cd8

+ 2 - 2
ipu-server/web/res/js/mobile/expand-mobile.js

@ -136,13 +136,13 @@ define(["require"],function(require) {
136 136
			},appendFile:function(content,fileName,type,isSdcard,err){
137 137
				execute("appendFile",[content,fileName,type,isSdcard],err);
138 138
			},readFile:function(callback,fileName,type,isSdcard,isEscape,err){
139
				storageCallback("readFile",callback,isEscape);
139
				storageCallback("readFile",callback);
140 140
				execute("readFile",[fileName,type,isSdcard,isEscape],err);
141 141
			},openFile:function(filename,type,isSdcard,err){
142 142
				execute("openFile", [filename,type,isSdcard],err);
143 143
			},deleteFile:function(filename,type,isSdcard,err){
144 144
				execute("deleteFile", [filename,type,isSdcard],err);
145
			},getAllFile:function(callback,filename,type,isSdcard,err){
145
			},getAllFile:function(callback,filename,type,isSdcard,err){
146 146
				storageCallback("getAllFile", callback);
147 147
				execute("getAllFile", [filename,type,isSdcard],err);
148 148
			},getRelativePath:function(callback,filename,type,err){

+ 185 - 182
ipu-server/web/res/js/ui/wm-animate.js

@ -3,192 +3,195 @@
3 3
 * Only supports x/y now and is used by the scroller library
4 4
 */
5 5
define(["jcl"],function($){
6
	/**
7
	  * @license MIT - https://github.com/darius/requestAnimationFrame/commit/4f27a5a21902a883330da4663bea953b2f96cb15#diff-9879d6db96fd29134fc802214163b95a
8

9
	    http://paulirish.com/2011/requestanimationframe-for-smart-animating/
10
	    http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
11
	    requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
12
	    MIT license
13

14
	    Adapted from https://gist.github.com/paulirish/1579671 which derived from 
15
	    http://paulirish.com/2011/requestanimationframe-for-smart-animating/
16
	    http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
17

18
	    requestAnimationFrame polyfill by Erik Möller.
19
	    Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon
20
	*/
21

22
	if (!Date.now)
23
	    Date.now = function() {
24
	        return new Date().getTime();
25
	    };
26

27
	(function() {
28
	    var vendors = ["webkit", "moz","ms"];
29
	    for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
30
	        var vp = vendors[i];
31
	        window.requestAnimationFrame = window[vp+"RequestAnimationFrame"];
32
	        window.cancelAnimationFrame = (window[vp+"CancelAnimationFrame"] || window[vp+"CancelRequestAnimationFrame"]);
33
	    }
34
	    if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
35
	        var lastTime = 0;
36
	        window.requestAnimationFrame = function(callback) {
37
	            var now = Date.now();
38
	            var nextTime = Math.max(lastTime + 16, now);
39
	            return setTimeout(function() { callback(lastTime = nextTime); },
40
	                              nextTime - now);
41
	        };
42
	        window.cancelAnimationFrame = clearTimeout;
43
	    }
44
	}());
45
	
46
	/*-------------------------------------------------------*/
47
    var cache = [];
48
    var objId = function(obj) {
49
        if (!obj.wmAnimateId) obj.wmAnimateId = $.uuid();
50
        return obj.wmAnimateId;
51
    };
52
    var getEl = function(elID) {
53
        if (typeof elID === "string" || elID instanceof String) {
54
            return document.getElementById(elID);
55
        } else if ($.is$(elID)) {
56
            return elID[0];
57
        } else {
58
            return elID;
59
        }
60
    };
61
    var getAnimate = function(obj, options) {
62
        var tmp, id, el = getEl(obj);
63
        //first one
64
        id = objId(el);
65
        if (cache[id]) {
66
            if(options)
67
                cache[id].animate(options);
68
            tmp = cache[id];
69
        } else {
70
            tmp = Animate(el, options);
71
            cache[id] = tmp;
72
        }
73
        return tmp;
74
    };
75
    $.fn.animate = function(opts) {
76
        var tmp = getAnimate(this[0], opts);
77
        return tmp;
78
    };
79

6
  /**
7
   * @license MIT - https://github.com/darius/requestAnimationFrame/commit/4f27a5a21902a883330da4663bea953b2f96cb15#diff-9879d6db96fd29134fc802214163b95a
80 8

9
   http://paulirish.com/2011/requestanimationframe-for-smart-animating/
10
   http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
11
   requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
12
   MIT license
81 13

82
    var Animate = function(elID, options) {
83
        if (!(this instanceof Animate)) return new Animate(elID, options);
14
   Adapted from https://gist.github.com/paulirish/1579671 which derived from
15
   http://paulirish.com/2011/requestanimationframe-for-smart-animating/
16
   http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
84 17

85
        this.el=elID;
86
        //start doing stuff
87
        if (!this.el) return;
18
   requestAnimationFrame polyfill by Erik Möller.
19
   Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon
20
   */
88 21

89
        if(options)
90
            this.animate(options);
91

92
        var that = this;
93
        $(this.el).bind("destroy", function() {
94
            var id = that.el.wmAnimateId;
95
            if (cache[id]) delete cache[id];
96
        });
97
    };
98
    Animate.prototype = {
99
        animationTimer:null,
100
        isAnimating:false,
101
        startX:0,
102
        startY:0,
103
        runTime:0,
104
        endX:0,
105
        endY:0,
106
        currX:0,
107
        currY:0,
108
        animationStartTime:0,
109
        pauseTime:0,
110
        completeCB:null,
111
        easingFn:"linear",
112
        animateOpts:{},
113
        updateCb:null,
114
        animate: function(options) {
115
            var that=this;
116
            if(that.isAnimating) return;
117
            that.isAnimating=true;
118
            window.cancelAnimationFrame(that.animationTimer);
119
            if (!options) {
120
                options={
121
                    x:0,
122
                    y:0,
123
                    duration:0
124
                };
125
            }
126
            this.easingFn=options.easing||"linear";
127

128
            this.completeCB=options.complete||null;
129
            this.updateCB=options.update||null;
130
            this.runTime=numOnly(options.duration);
131
            options.complete&&(delete options.complete);
132
            this.animateOpts=options;
133
            this.startTime=Date.now();
134
            this.startMatrix=$.getCssMatrix(this.el);
135

136
            if(this.runTime===0)
137
                this.doAnimate();
138
        },
139
        start:function(){
140
            this.doAnimate();
141
        },
142
        doAnimate:function(){
143
            var now = Date.now(), nextX, nextY,easeStep,that=this;
144

145
            if (this.runTime===0||(now >= this.startTime + this.runTime)) {
146
                that.setPosition(this.animateOpts.x,this.animateOpts.y);
147
                that.isAnimating = false;
148
                if(this.updateCB)
149
                    this.updateCB({x:this.animateOpts.x,y:this.animateOpts.y});
150
                if(this.completeCB)
151
                    this.completeCB();
152
                return;
153
            }
154

155
            now = (now - this.startTime) / this.runTime;
156
            now=now>1?1:now;
157
            easeStep = tweens[this.easingFn](now);
158
            nextX = (this.animateOpts.x - this.startMatrix.e) * easeStep + this.startMatrix.e;
159
            nextY = (this.animateOpts.y - this.startMatrix.f) * easeStep + this.startMatrix.f;
160
            this.setPosition(nextX,nextY);
161
            if(this.updateCB)
162
                this.updateCB({x:nextX,y:nextY});
163

164
            if (this.isAnimating)
165
                this.animationTimer = window.requestAnimationFrame(function(){that.doAnimate();});
166
        },
167
        setPosition:function(x,y){
168
            this.el.style[$.feat.cssPrefix+"Transform"]="matrix3d( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+x+", "+y+", 0, 1 )";
169
            this.currX=x;
170
            this.currY=y;
171
        },
172
        stop:function(){
173
            this.isAnimating=false;
174
            window.cancelAnimationFrame(this.animationTimer);
175
            this.pauseTime=Date.now()-this.startTime;
176
        },
177
        resume:function(){
178
            this.isAnimating=true;
179
            this.startTime=Date.now()-this.pauseTime;
180
            this.doAnimate();
181
        }
22
  if (!Date.now)
23
    Date.now = function() {
24
      return new Date().getTime();
182 25
    };
183 26

184

185
    var tweens = {
186
        linear:function (k) {
187
            return k;
188
        },
189
        easeOutSine:function (k) {
190
            return Math.sin(k * Math.PI / 2 );
191
        }
192
    };
193
    return $;
27
  (function() {
28
    var vendors = ["webkit", "moz","ms"];
29
    for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
30
      var vp = vendors[i];
31
      window.requestAnimationFrame = window[vp+"RequestAnimationFrame"];
32
      window.cancelAnimationFrame = (window[vp+"CancelAnimationFrame"] || window[vp+"CancelRequestAnimationFrame"]);
33
    }
34
    if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
35
      var lastTime = 0;
36
      window.requestAnimationFrame = function(callback) {
37
        var now = Date.now();
38
        var nextTime = Math.max(lastTime + 16, now);
39
        return setTimeout(function() { callback(lastTime = nextTime); },
40
          nextTime - now);
41
      };
42
      window.cancelAnimationFrame = clearTimeout;
43
    }
44
  }());
45

46
  /*-------------------------------------------------------*/
47
  var cache = [];
48
  var objId = function(obj) {
49
    if (!obj.wmAnimateId) obj.wmAnimateId = $.uuid();
50
    return obj.wmAnimateId;
51
  };
52
  var getEl = function(elID) {
53
    if (typeof elID === "string" || elID instanceof String) {
54
      return document.getElementById(elID);
55
    } else if ($.is$(elID)) {
56
      return elID[0];
57
    } else {
58
      return elID;
59
    }
60
  };
61
  var getAnimate = function(obj, options) {
62
    var tmp, id, el = getEl(obj);
63
    //first one
64
    id = objId(el);
65
    if (cache[id]) {
66
      if(options)
67
        cache[id].animate(options);
68
      tmp = cache[id];
69
    } else {
70
      tmp = Animate(el, options);
71
      cache[id] = tmp;
72
    }
73
    return tmp;
74
  };
75
  $.fn.animate = function(opts) {
76
    var tmp = getAnimate(this[0], opts);
77
    return tmp;
78
  };
79

80

81

82
  var Animate = function(elID, options) {
83
    if (!(this instanceof Animate)) return new Animate(elID, options);
84

85
    this.el=elID;
86
    //start doing stuff
87
    if (!this.el) return;
88

89
    if(options)
90
      this.animate(options);
91

92
    var that = this;
93
    $(this.el).bind("destroy", function() {
94
      var id = that.el.wmAnimateId;
95

96
      if (cache[id]) {
97
        cache[id] = null;
98
      }
99
    });
100
  };
101
  Animate.prototype = {
102
    animationTimer:null,
103
    isAnimating:false,
104
    startX:0,
105
    startY:0,
106
    runTime:0,
107
    endX:0,
108
    endY:0,
109
    currX:0,
110
    currY:0,
111
    animationStartTime:0,
112
    pauseTime:0,
113
    completeCB:null,
114
    easingFn:"linear",
115
    animateOpts:{},
116
    updateCb:null,
117
    animate: function(options) {
118
      var that=this;
119
      if(that.isAnimating) return;
120
      that.isAnimating=true;
121
      window.cancelAnimationFrame(that.animationTimer);
122
      if (!options) {
123
        options={
124
          x:0,
125
          y:0,
126
          duration:0
127
        };
128
      }
129
      this.easingFn=options.easing||"linear";
130

131
      this.completeCB=options.complete||null;
132
      this.updateCB=options.update||null;
133
      this.runTime=numOnly(options.duration);
134
      options.complete&&(delete options.complete);
135
      this.animateOpts=options;
136
      this.startTime=Date.now();
137
      this.startMatrix=$.getCssMatrix(this.el);
138

139
      if(this.runTime===0)
140
        this.doAnimate();
141
    },
142
    start:function(){
143
      this.doAnimate();
144
    },
145
    doAnimate:function(){
146
      var now = Date.now(), nextX, nextY,easeStep,that=this;
147

148
      if (this.runTime===0||(now >= this.startTime + this.runTime)) {
149
        that.setPosition(this.animateOpts.x,this.animateOpts.y);
150
        that.isAnimating = false;
151
        if(this.updateCB)
152
          this.updateCB({x:this.animateOpts.x,y:this.animateOpts.y});
153
        if(this.completeCB)
154
          this.completeCB();
155
        return;
156
      }
157

158
      now = (now - this.startTime) / this.runTime;
159
      now=now>1?1:now;
160
      easeStep = tweens[this.easingFn](now);
161
      nextX = (this.animateOpts.x - this.startMatrix.e) * easeStep + this.startMatrix.e;
162
      nextY = (this.animateOpts.y - this.startMatrix.f) * easeStep + this.startMatrix.f;
163
      this.setPosition(nextX,nextY);
164
      if(this.updateCB)
165
        this.updateCB({x:nextX,y:nextY});
166

167
      if (this.isAnimating)
168
        this.animationTimer = window.requestAnimationFrame(function(){that.doAnimate();});
169
    },
170
    setPosition:function(x,y){
171
      this.el.style[$.feat.cssPrefix+"Transform"]="matrix3d( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+x+", "+y+", 0, 1 )";
172
      this.currX=x;
173
      this.currY=y;
174
    },
175
    stop:function(){
176
      this.isAnimating=false;
177
      window.cancelAnimationFrame(this.animationTimer);
178
      this.pauseTime=Date.now()-this.startTime;
179
    },
180
    resume:function(){
181
      this.isAnimating=true;
182
      this.startTime=Date.now()-this.pauseTime;
183
      this.doAnimate();
184
    }
185
  };
186

187

188
  var tweens = {
189
    linear:function (k) {
190
      return k;
191
    },
192
    easeOutSine:function (k) {
193
      return Math.sin(k * Math.PI / 2 );
194
    }
195
  };
196
  return $;
194 197
});

+ 41 - 39
ipu-server/web/res/js/ui/wm-css3animate.js

@ -1,43 +1,43 @@
1 1
/**
2 2
 * wm.css3animate - a css3 animation library that supports chaning/callbacks
3 3
 */
4
 /*  EXAMPLE
5

6
  $("#animate").css3Animate({
7
        width: "100px",
8
        height: "100px",
9
        x: "20%",
10
        y: "30%",
11
        time: "1000ms",
12
        opacity: .5,
13
        callback: function () {
14
            //execute when finished
15
        }
16
    });
17

18
    //Chain animations
19
    $("#animate").css3Animate({
20
        x: 20,
21
        y: 30,
22
        time: "300ms",
23
        callback: function () {
24
            $("#animate").css3Animate({
25
                x: 20,
26
                y: 30,
27
                time: "500ms",
28
                previous: true,
29
                callback: function () {
30
                    reset();
31
                }
32
            });
33
        }
34
    });
35
 */
36

37
 /* global wm*/
38
 /* global numOnly*/
39
define(["jcl"],function($){
40
	"use strict";
4
/*  EXAMPLE
5

6
 $("#animate").css3Animate({
7
       width: "100px",
8
       height: "100px",
9
       x: "20%",
10
       y: "30%",
11
       time: "1000ms",
12
       opacity: .5,
13
       callback: function () {
14
           //execute when finished
15
       }
16
   });
17

18
   //Chain animations
19
   $("#animate").css3Animate({
20
       x: 20,
21
       y: 30,
22
       time: "300ms",
23
       callback: function () {
24
           $("#animate").css3Animate({
25
               x: 20,
26
               y: 30,
27
               time: "500ms",
28
               previous: true,
29
               callback: function () {
30
                   reset();
31
               }
32
           });
33
       }
34
   });
35
*/
36

37
/* global wm*/
38
/* global numOnly*/
39
define(["jcl","wmBase"],function($){
40
    "use strict";
41 41
    var cache = [];
42 42
    var objId = function(obj) {
43 43
        if (!obj.wmCSS3AnimateId) obj.wmCSS3AnimateId = $.uuid();
@ -111,7 +111,9 @@ define(["jcl"],function($){
111 111
            $(this.el).bind("destroy", function() {
112 112
                var id = that.el.wmCSS3AnimateId;
113 113
                that.callbacksStack = [];
114
                if (cache[id]) delete cache[id];
114
                if (cache[id]) {
115
                    cache[id] = null;
116
                }
115 117
            });
116 118
        };
117 119
        css3Animate.prototype = {
@ -216,7 +218,7 @@ define(["jcl"],function($){
216 218
                this.countStack++;
217 219

218 220
                var that = this,
219
                    duration;
221
                  duration;
220 222
                var style = window.getComputedStyle(this.el);
221 223
                if (classMode) {
222 224
                    //get the duration

+ 4 - 2
ipu-server/web/res/js/ui/wm-scroller.js

@ -34,7 +34,7 @@ define(["jcl","wmBase","wmAnimate"],function($){
34 34

35 35
    function checkConsistency(id) {
36 36
        if (!cache[id].el) {
37
            delete cache[id];
37
            cache[id] = null;
38 38
            return false;
39 39
        }
40 40
        return true;
@ -208,7 +208,9 @@ define(["jcl","wmBase","wmAnimate"],function($){
208 208
                this.afEl.bind("destroy", function () {
209 209
                    that.disable(true); //with destroy notice
210 210
                    var id = that.el.afScrollerId;
211
                    if (cache[id]) delete cache[id];
211
                    if (cache[id]){
212
                        cache[id] = null;
213
                    }
212 214
                    $.unbind($.touchLayer, "orientationchange-reshape", orientationChangeProxy);
213 215
                });
214 216
                $.bind($.touchLayer, "orientationchange-reshape", orientationChangeProxy);

+ 5 - 0
ipu-server/web/res/js/ui/wm-tooltip.js

@ -32,6 +32,11 @@ define(["jcl","wmWebUI"], function($,WmWebUI){
32 32
		}else if(typeof ele =="string"){
33 33
			e = $("#"+ele);
34 34
		}
35

36
		if(!e){
37
			return ;
38
		}
39

35 40
		var o = e.offset();
36 41
		var h = e.height();
37 42
		var w = e.width();