remove code for footer position calculation and add SQL attack prevent for enter…
… key. code review by LZF
Showing
1 changed file
with
10 additions
and
50 deletions
@@ -10,24 +10,12 @@ var $searchBox = $('.search-box'), | @@ -10,24 +10,12 @@ var $searchBox = $('.search-box'), | ||
10 | $box = $('.box'), | 10 | $box = $('.box'), |
11 | $indexSearch = $('.index-search'), | 11 | $indexSearch = $('.index-search'), |
12 | $indexLogo = $('.index-logo'), | 12 | $indexLogo = $('.index-logo'), |
13 | - $channelLink = $('.index-channel a'), | ||
14 | - $win = $(window), | ||
15 | - $doc = $(document), | ||
16 | - $appFloatLayer = $('#float-layer-app'); | 13 | + $channelLink = $('.index-channel a'); |
17 | 14 | ||
18 | var $search = $searchBox.children('input[type="text"]'), | 15 | var $search = $searchBox.children('input[type="text"]'), |
19 | $cancelSearch = $box.children('.no-search'), | 16 | $cancelSearch = $box.children('.no-search'), |
20 | $searchIcon = $searchBox.children('.search-icon'); | 17 | $searchIcon = $searchBox.children('.search-icon'); |
21 | 18 | ||
22 | -// variables for calculate the app download layer position | ||
23 | -var layerInit = false, | ||
24 | - windowViewHeight = 0, | ||
25 | - layerContentHeight = $appFloatLayer.height(), | ||
26 | - layerPaddingTop = parseInt($appFloatLayer.css('padding-top')), | ||
27 | - layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')), | ||
28 | - layerHeight = layerContentHeight + layerPaddingTop + layerPaddingBottom, | ||
29 | - layerNewPos; | ||
30 | - | ||
31 | require('../common'); | 19 | require('../common'); |
32 | 20 | ||
33 | $search.on('focus', function() { | 21 | $search.on('focus', function() { |
@@ -59,6 +47,15 @@ $searchBox.children('.search-icon').on('touchstart', function() { | @@ -59,6 +47,15 @@ $searchBox.children('.search-icon').on('touchstart', function() { | ||
59 | $indexSearch.submit(); | 47 | $indexSearch.submit(); |
60 | }); | 48 | }); |
61 | 49 | ||
50 | +$searchBox.keyup(function(e) { | ||
51 | + if (e.keyCode === 13) { | ||
52 | + if (security.hasDangerInput()) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + $indexSearch.submit(); | ||
56 | + } | ||
57 | +}); | ||
58 | + | ||
62 | $('.index-channel img').on('load error', function() { | 59 | $('.index-channel img').on('load error', function() { |
63 | window.rePosFooter && window.rePosFooter(); | 60 | window.rePosFooter && window.rePosFooter(); |
64 | }); | 61 | }); |
@@ -81,40 +78,3 @@ $channelLink.on('touchstart', function() { | @@ -81,40 +78,3 @@ $channelLink.on('touchstart', function() { | ||
81 | borderColor: '#fff' | 78 | borderColor: '#fff' |
82 | }); | 79 | }); |
83 | }); | 80 | }); |
84 | - | ||
85 | - | ||
86 | -function updateLayerPosition() { | ||
87 | - var winHeight = window.innerHeight, | ||
88 | - bodyHeight = $doc.height(), | ||
89 | - scrollTopPosition = $win.scrollTop(); | ||
90 | - | ||
91 | - if (layerInit) { | ||
92 | - | ||
93 | - //keyboard is shown | ||
94 | - if (windowViewHeight - winHeight > 200) { | ||
95 | - if (scrollTopPosition + windowViewHeight + layerHeight >= bodyHeight) { | ||
96 | - layerNewPos = 0; | ||
97 | - } else { | ||
98 | - layerNewPos = bodyHeight - windowViewHeight - scrollTopPosition - layerHeight; | ||
99 | - } | ||
100 | - } else { | ||
101 | - layerNewPos = bodyHeight - winHeight - scrollTopPosition; | ||
102 | - } | ||
103 | - | ||
104 | - } else { | ||
105 | - windowViewHeight = winHeight; | ||
106 | - layerNewPos = bodyHeight - winHeight - scrollTopPosition + layerHeight; | ||
107 | - layerInit = true; | ||
108 | - } | ||
109 | - | ||
110 | - $appFloatLayer.css({ | ||
111 | - position: 'relative', | ||
112 | - bottom: layerNewPos + 'px' | ||
113 | - }); | ||
114 | -} | ||
115 | - | ||
116 | -$(window).scroll(function() { | ||
117 | - window.requestAnimationFrame(updateLayerPosition); | ||
118 | -}); | ||
119 | - | ||
120 | -$doc.on('ready', updateLayerPosition); |
-
Please register or login to post a comment