Browse code

Fixes #35, fixes #36

Bruno Spyckerelle authored on 14/10/2016 10:11:26
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@ var GlobalPinni = null;
7 7
 var GlobalProcessing = false;
8 8
 var GlobalWindowFocus = true;
9 9
 var GlobalFilters = new Array();
10
+var GlobalOnTouch = false;
10 11
 
11 12
 var norloge_exp = new RegExp("((?:1[0-2]|0[1-9])/(?:3[0-1]|[1-2][0-9]|0[1-9])#)?((?:2[0-3]|[0-1][0-9])):([0-5][0-9])(:[0-5][0-9])?([¹²³]|[:\^][1-9]|[:\^][1-9][0-9])?(@[A-Za-z0-9_]+)?", "");
12 13
 
... ...
@@ -685,12 +686,16 @@ $(document).ready(function(){
685 686
                 jqxhr
686 687
                     .success(function(){
687 688
                         $("#message").val('');
688
-                        closeKeyboard($("#message"));
689
+                        if(GlobalOnTouch) {
690
+                            closeKeyboard($("#message"));
691
+                        }
689 692
                     })
690 693
                     .fail(function(){
691 694
                         if(jqxhr.status == 302) {
692 695
                             $("#message").val('');
693
-                            closeKeyboard($("#message"));
696
+                            if(GlobalOnTouch) {
697
+                                closeKeyboard($("#message"));
698
+                            }
694 699
                         }
695 700
                     });
696 701
             }
... ...
@@ -799,7 +804,7 @@ $(document).ready(function(){
799 804
             $("#form-totoz .form-group").addClass('unfocus').removeClass('focusin');
800 805
         }
801 806
     });
802
-
807
+	
803 808
     //close popover when click outside
804 809
     $(document).on('click', function (e) {
805 810
         $('[data-toggle="popover"],[data-original-title]').each(function () {
... ...
@@ -906,8 +911,33 @@ $(document).ready(function(){
906 911
     /* Interactions tactiles */
907 912
     /* ********************* */
908 913
 
914
+	//detect keyboard appearing/closing
915
+	var _originalSize = $(window).width() + $(window).height()
916
+	$(window).resize(function(){
917
+		if($(window).width() + $(window).height() < _originalSize - 50){
918
+			//console.log("keyboard show up");  
919
+			if($("#form-totoz .popover").length > 0) {
920
+                $("#form-totoz input").popover('show');
921
+			}
922
+		}else{
923
+			//console.log("keyboard closed");
924
+			if($("#form-totoz .popover").length > 0) {
925
+				$("#form-totoz input").popover('show');
926
+			}
927
+		}
928
+	});
929
+	
909 930
     //allow text selection
910 931
     delete Hammer.defaults.cssProps.userSelect;
932
+	//touch events on palmi : only to detect device's type
933
+	var mcPalmi = new Hammer.Manager(document.getElementById('message'));
934
+	mcPalmi.add(new Hammer.Tap({ event: 'tap'}));
935
+	mcPalmi.on('tap', function(ev){
936
+        if(ev.pointerType == 'touch') {
937
+            GlobalOnTouch = true;
938
+        }
939
+	});
940
+	//touch events on Pinni
911 941
     PreventGhostClick(GlobalPinni);
912 942
     var mc = new Hammer.Manager(GlobalPinni);
913 943
 
... ...
@@ -949,14 +979,15 @@ $(document).ready(function(){
949 979
     });
950 980
 
951 981
     mc.on('singletap', function(ev) {
982
+        GlobalOnTouch = true;
952 983
         if(ev.pointerType == 'touch') {
953 984
             var target = $(ev.target);
954 985
             if (target.is('a') 
955
-		|| target.hasClass('clock')
956
-	        || target.hasClass('clockref')
957
-	        || target.hasClass('ua')
958
-	        || target.hasClass('login')
959
-	        || target.hasClass('tab')) {
986
+                || target.hasClass('clock')
987
+                || target.hasClass('clockref')
988
+                || target.hasClass('ua')
989
+                || target.hasClass('login')
990
+                || target.hasClass('tab')) {
960 991
 				if (target.closest('li').hasClass('tab')) {
961 992
 					var boardName = target.closest('li').attr('id').substr(4);
962 993
 					GlobalBoardTabs[boardName].toggle();
... ...
@@ -969,10 +1000,12 @@ $(document).ready(function(){
969 1000
                 hilightPost(parent.attr('id'), parent[0]);
970 1001
             }
971 1002
             removeNotif();
1003
+            $("#form-totoz input").popover('destroy');
972 1004
         }
973 1005
     });
974 1006
 
975 1007
     mc.on('swipe', function(ev) {
1008
+        GlobalOnTouch = true;
976 1009
         if(ev.direction == Hammer.DIRECTION_LEFT && !$("#wrapper").hasClass("toggled")) {
977 1010
             $("#menu-toggle").trigger('click');
978 1011
         } else if(ev.direction == Hammer.DIRECTION_RIGHT && $("#wrapper").hasClass("toggled")) {
... ...
@@ -985,6 +1018,7 @@ $(document).ready(function(){
985 1018
 
986 1019
     mc2.add( new Hammer.Swipe({event: 'swipe', direction: Hammer.DIRECTION_HORIZONTAL}));
987 1020
     mc2.on('swipe', function(ev) {
1021
+        GlobalOnTouch = true;
988 1022
         if(ev.direction == Hammer.DIRECTION_LEFT && !$("#wrapper").hasClass("toggled")) {
989 1023
             $("#menu-toggle").trigger('click');
990 1024
         } else if(ev.direction == Hammer.DIRECTION_RIGHT && $("#wrapper").hasClass("toggled")) {
... ...
@@ -1023,6 +1057,7 @@ $(document).ready(function(){
1023 1057
 
1024 1058
     mc2.on('tap', function(ev){
1025 1059
         if(ev.pointerType == 'touch') {
1060
+            GlobalOnTouch = true;
1026 1061
             var target = $(ev.target);
1027 1062
             if (target.closest('li').hasClass('tab')) {
1028 1063
                 var boardName = target.closest('li').attr('id').substr(4);