jquery.qtip.debug-1.0.0-rc3.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * jquery.qtip.debug. The jQuery tooltip plugin debugger
  3. *
  4. * Debug mode logs all tooltip events and error messages to the
  5. * global $.fn.qtip.log object, as well as creates an array of
  6. * references to all tooltips on the page.
  7. *
  8. * If a console is present, such as firebug (http://getfirebug.com),
  9. * Opera's inbuilt Drangonfly, or IE8's internal Web Developer tool,
  10. * errors will be reported to the console based on your set report
  11. * mask, which is explained in details below.
  12. *
  13. *
  14. * Copyright (c) 2009 Craig Thompson
  15. * http://craigsworks.com
  16. *
  17. * Licensed under MIT
  18. * http://www.opensource.org/licenses/mit-license.php
  19. *
  20. * Launch : February 2009
  21. * Version : 1.0.0-rc3
  22. * Released: Friday 27th April, 2009 - 23:30
  23. */
  24. /* DEBUG MODE - OFF BY DEFAULT - set to true to enable debugging */
  25. $.fn.qtip.debug = true;
  26. if($.fn.qtip.debug)
  27. {
  28. // Create new debug constants
  29. $.fn.qtip.constants =
  30. {
  31. /* Error messages */
  32. NO_TOOLTIP_PRESENT: 'No tooltip is present on the selected element. Cannot proceed with API call.',
  33. TOOLTIP_NOT_RENDERED: 'Tooltip has not yet been rendered! Cannot proceed with API call.',
  34. NO_VALID_CONTENT: 'No valid content was provided in the options. Using blank content.',
  35. TOOLTIP_IS_DISABLED: 'Tooltip is disabled, cannot proceed with API call.',
  36. TOOLTIP_ALREADY_DISABLED: 'Tooltip is already disabled.',
  37. TOOLTIP_ALREADY_ENABLED: 'Tooltip is already enabled.',
  38. CANVAS_VML_NOT_SUPPORTED: 'Niether canvas or VML are supported, corner and tips will not be drawn.',
  39. STYLE_NOT_DEFINED: 'No such style is defined in the global styles object.',
  40. INVALID_AREA_SHAPE: 'The AREA element used as your target has an invalid area shape. Possible values are: rect, circle, poly.',
  41. CANNOT_FOCUS_STATIC: 'Focusing static elements is not possible as they don\'t have z-index properties.',
  42. CANNOT_POSITION_STATIC: 'Positioning static elements is not possible as they don\'t have left or top properties.',
  43. NO_CONTENT_PROVIDED: 'You must specify some content with which to update.',
  44. /* Event messages */
  45. EVENT_RENDERED: '(Event) Tooltip has been rendered.',
  46. EVENT_SHOWN: '(Event) Tooltip has been shown.',
  47. EVENT_HIDDEN: '(Event) Tooltip has been hidden.',
  48. EVENT_FOCUSED: '(Event) Tooltip has been focused.',
  49. EVENT_DISABLED: '(Event) Tooltip has been disabled.',
  50. EVENT_ENABLED: '(Event) Tooltip has been enabled.',
  51. EVENT_DESTROYED: '(Event) Tooltip has been destroyed.',
  52. EVENT_POSITION_UPDATED: '(Event) Tooltip position has been updated.',
  53. EVENT_CONTENT_UPDATED: '(Event) Tooltip contents have been updated.',
  54. EVENT_CONTENT_LOADED: '(Event) Tooltip contents have been loaded from specified URL.',
  55. EVENT_TITLE_UPDATED: '(Event) Tooltip title has been updated.',
  56. EVENT_STYLE_UPDATED: '(Event) Tooltip style has been updated.',
  57. EVENT_WIDTH_UPDATED: '(Event) Tooltip width has been updated.'
  58. };
  59. // Define qTip log object
  60. $.fn.qtip.log = {
  61. /* CONSOLE REPORTING MASK
  62. To use this functionality you need a console installed, such as firebug:
  63. http://getfirebug.com
  64. This mask determines what errors are reported to the console. Possible values are:
  65. 7 = Errors, warnings and messages
  66. 6 = Errors and warnings
  67. 5 = Errors and messages
  68. 4 = Errors only
  69. 3 = Warnings and messages
  70. 2 = Warnings only
  71. 1 = Messages only
  72. */
  73. report: 7,
  74. /* DO NOT ALTER ANYTHING BELOW HERE! */
  75. qtips: [],
  76. messages: [],
  77. errors: [],
  78. /* Error handler function */
  79. error: function(type, message, method)
  80. {
  81. var self = this;
  82. // Format type string
  83. switch(type)
  84. {
  85. case 1:
  86. var typeString = 'info';
  87. var addTo = 'messages';
  88. break;
  89. case 2:
  90. var typeString = 'warn';
  91. var addTo = 'messages';
  92. break;
  93. default: case 4:
  94. var typeString = 'error';
  95. var addTo = 'errors';
  96. break;
  97. }
  98. // Format time
  99. var DateObj = new Date();
  100. var time = DateObj.getHours() + ':' +
  101. DateObj.getMinutes() + ':' +
  102. DateObj.getSeconds();
  103. // Log the error into the log array
  104. $.fn.qtip.log[addTo].push({
  105. time: time,
  106. message: message,
  107. api: self,
  108. callee: self[method] || method || null
  109. });
  110. // If debug mode is enabled, display the error
  111. if($.fn.qtip.log.report & type > 0)
  112. {
  113. var logMessage = 'qTip '
  114. + ((typeof self.id !== 'undefined') ? '['+self.id+']' : '')
  115. + ': ' + message;
  116. // Check console is present
  117. if(window.console) window.console[typeString](logMessage);
  118. // Check for Opera Dragonfly
  119. else if($.browser.opera && window.opera.postError) window.opera.postError(logMessage);
  120. }
  121. return self;
  122. }
  123. };
  124. };