Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

227 wiersze
6.7 KiB

  1. /*
  2. Copyright (c) 2012-2017 Open Lab
  3. Permission is hereby granted, free of charge, to any person obtaining
  4. a copy of this software and associated documentation files (the
  5. "Software"), to deal in the Software without restriction, including
  6. without limitation the rights to use, copy, modify, merge, publish,
  7. distribute, sublicense, and/or sell copies of the Software, and to
  8. permit persons to whom the Software is furnished to do so, subject to
  9. the following conditions:
  10. The above copyright notice and this permission notice shall be
  11. included in all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. */
  20. //----------------------------------positioning-----------------------------------------------
  21. jQuery.fn.centerOnScreen = function () {
  22. return this.each(function () {
  23. var container = $(this);
  24. //console.debug($(window).height(), container.outerHeight(),(($(window).height() - container.outerHeight()) / 2))
  25. container.css("position", "fixed");
  26. container.css("top", (($(window).height() - container.outerHeight()) / 2) + 'px');
  27. container.css("left", (($(window).width() - container.outerWidth()) / 2) + 'px');
  28. });
  29. };
  30. function nearBestPosition(whereId, theObjId, centerOnEl) {
  31. var el = whereId;
  32. var target = theObjId;
  33. if (typeof whereId != "object") {
  34. el = $("#" + whereId);
  35. }
  36. if (typeof theObjId != "object") {
  37. target = $("#" + theObjId);
  38. }
  39. if (el) {
  40. target.css("visibility", "hidden");
  41. var hasContainment = false;
  42. target.parents().each(function () {
  43. if ($(this).css("position") == "static")
  44. return;
  45. hasContainment = true;
  46. });
  47. var trueX = hasContainment ? el.position().left : el.offset().left;
  48. var trueY = hasContainment ? el.position().top : el.offset().top;
  49. var h = el.outerHeight();
  50. var elHeight = parseFloat(h);
  51. if (centerOnEl) {
  52. var elWidth = parseFloat(el.outerWidth());
  53. var targetWidth = parseFloat(target.outerWidth());
  54. trueX += (elWidth - targetWidth) / 2;
  55. }
  56. trueY += parseFloat(elHeight);
  57. var left = trueX;
  58. var top = trueY;
  59. var barHeight = 45 ;
  60. var barWidth = 20 ;
  61. if (trueX && trueY) {
  62. target.css("left", left);
  63. target.css("top", top);
  64. }
  65. if (target.offset().left >= ( ($(window).width() + $(window).scrollLeft()) - target.outerWidth())) {
  66. left = ( ($(window).width() + $(window).scrollLeft()) - target.outerWidth() - 10 );
  67. target.css({left:left, marginTop: 0});
  68. }
  69. if (target.offset().left < 0) {
  70. left = 10;
  71. target.css("left", left);
  72. }
  73. if ((target.offset().top + target.outerHeight() >= ( ($(window).height() + $(window).scrollTop()) - barHeight)) && (target.outerHeight() < $(window).height())) {
  74. var marginTop = -(target.outerHeight() + el.outerHeight());
  75. target.css("margin-top", marginTop);
  76. }
  77. if (target.offset().top < 0) {
  78. top = 0;
  79. target.css("top", top);
  80. }
  81. target.css("visibility", "visible");
  82. }
  83. }
  84. $.fn.keepItVisible = function (ref) {
  85. var thisTop = $(this).offset().top;
  86. var thisLeft = $(this).offset().left;
  87. var fromTop =0;
  88. var fromLeft =0;
  89. var windowH = $(window).height() + $(window).scrollTop();
  90. var windowW = $(window).width() + $(window).scrollLeft();
  91. if (ref){
  92. fromTop = windowH - (ref.offset().top);
  93. fromLeft = windowW - (ref.offset().left + ref.outerWidth());
  94. }
  95. if (thisTop + $(this).outerHeight() > windowH){
  96. var mt = (thisTop + $(this).outerHeight()) - windowH;
  97. // $(this).css("margin-top", -$(this).outerHeight() - fromTop);
  98. $(this).css("margin-top", -mt - fromTop);
  99. }
  100. if (thisLeft + $(this).outerWidth() > windowW){
  101. var mL = (thisLeft + $(this).outerWidth()) - windowW;
  102. // $(this).css("margin-left", -$(this).outerWidth() - fromLeft);
  103. $(this).css("margin-left", -mL - fromLeft);
  104. }
  105. $(this).css("visibility", "visible");
  106. };
  107. //END positioning
  108. /* Caret Functions
  109. Use setSelection with start = end to set caret
  110. */
  111. function setSelection(input, start, end) {
  112. input.setSelectionRange(start, end);
  113. }
  114. $.fn.setCursorPosition = function(pos) {
  115. this.each(function(index, elem) {
  116. if (elem.setSelectionRange) {
  117. elem.setSelectionRange(pos, pos);
  118. } else if (elem.createTextRange) {
  119. var range = elem.createTextRange();
  120. range.collapse(true);
  121. range.moveEnd('character', pos);
  122. range.moveStart('character', pos);
  123. range.select();
  124. }
  125. });
  126. return this;
  127. };
  128. //-- Caret Functions END ---------------------------------------------------------------------------- --
  129. /*----------------------------------------------------------------- manage bbButtons*/
  130. $.buttonBar = {
  131. defaults: {},
  132. init: function(){
  133. setTimeout(function(){
  134. $.buttonBar.manageButtonBar();
  135. },100);
  136. $(window).on("scroll.ButtonBar",function(){
  137. $.buttonBar.manageButtonBar();
  138. });
  139. $(window).on("resize.ButtonBar",function(){
  140. $.buttonBar.manageButtonBar();
  141. });
  142. },
  143. manageButtonBar: function(anim) {
  144. $(".buttonArea").not(".bbCloned").not(".notFix").each(function(){
  145. var bb = this;
  146. //se usiamo questi si rompe la button bar flottante del save sulla issue list
  147. //bb.originalHeigh=bb.originalHeigh || $(bb).height();
  148. //bb.originalOffsetTop=bb.originalOffsetTop||$(bb).offset().top;
  149. bb.originalHeigh= $(bb).height();
  150. bb.originalOffsetTop=$(bb).offset().top;
  151. bb.isOut = $(window).scrollTop() + $(window).height() - bb.originalHeigh < bb.originalOffsetTop;
  152. if (bb.bbHolder)
  153. bb.bbHolder.css({width: $(bb).outerWidth(),left:$(bb).offset().left});
  154. if (bb.isOut && !bb.isCloned){
  155. if (bb.bbHolder)
  156. bb.bbHolder.remove();
  157. bb.isCloned = true;
  158. bb.bbHolder = $(bb).clone().addClass("bbCloned clone bottom").css({width: $(bb).outerWidth(), marginTop:0,left:$(bb).offset().left});
  159. bb.bbHolder.hide();
  160. bb.bbHolder.css({position:"fixed", bottom:0, left:$(bb).offset().left});
  161. $(bb).after(bb.bbHolder);
  162. bb.bbHolder.show();
  163. $(bb).css("visibility","hidden");
  164. } else if (!bb.isOut && bb.isCloned) {
  165. //} else {
  166. bb.isCloned = false;
  167. bb.bbHolder.remove();
  168. $(bb).css("visibility","visible");
  169. }
  170. });
  171. },
  172. refreshButtonBar: function() {
  173. $(".bbCloned").remove();
  174. $(".buttonArea").not(".bbCloned").each(function(){
  175. var bb = this;
  176. bb.isCloned = false;
  177. });
  178. $.buttonBar.manageButtonBar(false);
  179. }
  180. };