Authored by biao

update for the calculation of layer position

@@ -3,8 +3,7 @@ @@ -3,8 +3,7 @@
3 * @author: bikai<kai.bi@yoho.cn> 3 * @author: bikai<kai.bi@yoho.cn>
4 * @date: 2015/10/28 4 * @date: 2015/10/28
5 */ 5 */
6 -var $ = require('jquery'),  
7 - security = require('../plugin/security'); 6 +var $ = require('jquery');
8 7
9 var $searchBox = $('.search-box'), 8 var $searchBox = $('.search-box'),
10 $box = $('.box'), 9 $box = $('.box'),
@@ -44,9 +43,6 @@ $searchBox.children('.clear-text').on('touchstart', function() { @@ -44,9 +43,6 @@ $searchBox.children('.clear-text').on('touchstart', function() {
44 }); 43 });
45 44
46 $searchBox.children('.search-icon').on('touchstart', function() { 45 $searchBox.children('.search-icon').on('touchstart', function() {
47 - if (security.hasDangerInput()) {  
48 - return false;  
49 - }  
50 $indexSearch.submit(); 46 $indexSearch.submit();
51 }); 47 });
52 48
@@ -74,6 +70,7 @@ $channelLink.on('touchstart', function() { @@ -74,6 +70,7 @@ $channelLink.on('touchstart', function() {
74 }); 70 });
75 var updateLayerPosition = (function() { 71 var updateLayerPosition = (function() {
76 var init = false; 72 var init = false;
  73 + var windowViewHeight = 0;
77 return function() { 74 return function() {
78 var winHeight = window.innerHeight; 75 var winHeight = window.innerHeight;
79 var bodyHeight = $doc.height(); 76 var bodyHeight = $doc.height();
@@ -82,11 +79,22 @@ var updateLayerPosition = (function() { @@ -82,11 +79,22 @@ var updateLayerPosition = (function() {
82 var layerPaddingTop = parseInt($appFloatLayer.css('padding-top')); 79 var layerPaddingTop = parseInt($appFloatLayer.css('padding-top'));
83 var layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')); 80 var layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom'));
84 var newPosition; 81 var newPosition;
  82 +
85 if(init){ 83 if(init){
86 - newPosition = bodyHeight - winHeight- scrollTopPosition; 84 + if (windowViewHeight - winHeight > 200){//keyboard is shown
  85 + newPosition = bodyHeight - winHeight - scrollTopPosition - (layerHeight + layerPaddingTop + layerPaddingBottom);
  86 + } else {
  87 + newPosition = bodyHeight - winHeight -scrollTopPosition;
  88 + }
  89 +
  90 + if (scrollTopPosition + winHeight === bodyHeight) {
  91 + console.log('got end');
  92 + newPosition = 0;
  93 + }
87 }else{ 94 }else{
88 - init = true; 95 + windowViewHeight = winHeight;
89 newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight + layerPaddingTop + layerPaddingBottom; 96 newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight + layerPaddingTop + layerPaddingBottom;
  97 + init = true;
90 } 98 }
91 $appFloatLayer.css({ 99 $appFloatLayer.css({
92 'position': 'relative', 100 'position': 'relative',
@@ -96,8 +104,20 @@ var updateLayerPosition = (function() { @@ -96,8 +104,20 @@ var updateLayerPosition = (function() {
96 })(); 104 })();
97 105
98 $win.scroll(function() { 106 $win.scroll(function() {
  107 +
99 updateLayerPosition(); 108 updateLayerPosition();
  109 + //clearTimeout($.data(this, 'scrollTimer'));
  110 + //$.data(this, 'scrollTimer', setTimeout(function() {
  111 + // updateLayerPosition();
  112 + //}, 2));
100 }); 113 });
101 114
  115 +//$search.focusin(function() {
  116 +// $body.css('overflow','hidden');
  117 +//});
  118 +//
  119 +//$search.focusout(function() {
  120 +// $body.css('overflow','auto');
  121 +//});
102 122
103 $doc.on('ready', updateLayerPosition); 123 $doc.on('ready', updateLayerPosition);