console.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. (function($){
  2. var count = 0,
  3. oldMessage;
  4. window.kendoConsole = {
  5. log: function(message, isError) {
  6. var oldContainer = $(".console div:first"),
  7. counter = oldContainer.find(".count");
  8. if (!oldContainer.length || message != oldMessage) {
  9. oldMessage = message;
  10. count = 1;
  11. $("<div" + (isError ? " class='error'" : "") + "/>")
  12. .css({
  13. marginTop: -24,
  14. backgroundColor: isError ? "#ffbbbb" : "#bbddff"
  15. })
  16. .html(message)
  17. .prependTo(".console")
  18. .animate({ marginTop: 0 }, 300)
  19. .animate({ backgroundColor: isError ? "#ffdddd" : "#ffffff" }, 800);
  20. } else {
  21. count++;
  22. if (counter.length) {
  23. counter.html(count);
  24. } else {
  25. oldContainer.html(oldMessage)
  26. .append("<span class='count'>" + count + "</span>");
  27. }
  28. }
  29. },
  30. error: function(message) {
  31. this.log(message, true);
  32. }
  33. };
  34. })(jQuery);
  35. /*
  36. * jQuery Color Animations
  37. * Copyright 2007 John Resig
  38. * Released under the MIT and GPL licenses.
  39. */
  40. (function(jQuery) {
  41. // We override the animation for all of these color styles
  42. jQuery.each(["backgroundColor", "borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor", "color", "outlineColor"], function(i, attr) {
  43. jQuery.fx.step[attr] = function(fx) {
  44. if (!fx.state || typeof fx.end == typeof "") {
  45. fx.start = getColor(fx.elem, attr);
  46. fx.end = getRGB(fx.end);
  47. }
  48. fx.elem.style[attr] = ["rgb(", [
  49. Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0),
  50. Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0),
  51. Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0)
  52. ].join(","), ")"].join("");
  53. };
  54. });
  55. // Color Conversion functions from highlightFade
  56. // By Blair Mitchelmore
  57. // http://jquery.offput.ca/highlightFade/
  58. // Parse strings looking for color tuples [255,255,255]
  59. function getRGB(color) {
  60. var result;
  61. // Check if we're already dealing with an array of colors
  62. if (color && color.constructor == Array && color.length == 3) {
  63. return color;
  64. }
  65. // Look for rgb(num,num,num)
  66. result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color);
  67. if (result) {
  68. return [parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10)];
  69. }
  70. // Look for #a0b1c2
  71. result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color);
  72. if (result) {
  73. return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];
  74. }
  75. // Otherwise, we're most likely dealing with a named color
  76. return jQuery.trim(color).toLowerCase();
  77. }
  78. function getColor(elem, attr) {
  79. var color;
  80. do {
  81. color = jQuery.css(elem, attr);
  82. // Keep going until we find an element that has color, or we hit the body
  83. if (color && color != "transparent" || jQuery.nodeName(elem, "body")) {
  84. break;
  85. }
  86. attr = "backgroundColor";
  87. elem = elem.parentNode;
  88. } while (elem);
  89. return getRGB(color);
  90. }
  91. var href = window.location.href;
  92. if (href.indexOf("culture") > -1) {
  93. $("#culture").val(href.replace(/(.*)culture=([^&]*)/, "$2"));
  94. }
  95. function onlocalizationchange() {
  96. var value = $(this).val();
  97. var href = window.location.href;
  98. if (href.indexOf("culture") > -1) {
  99. href = href.replace(/culture=([^&]*)/, "culture=" + value);
  100. } else {
  101. href += href.indexOf("?") > -1 ? "&culture=" + value : "?culture=" + value;
  102. }
  103. window.location.href = href;
  104. }
  105. $("#culture").change(onlocalizationchange);
  106. })(jQuery);