/public/js/functions.js

https://github.com/jrschumacher/jobberbase · JavaScript · 112 lines · 102 code · 10 blank · 0 comment · 15 complexity · 50439c05321123fe58686aca72698f76 MD5 · raw file

  1. (function()
  2. {
  3. Jobber = {
  4. jobber_url: "",
  5. FixPng: function()
  6. {
  7. var arVersion = navigator.appVersion.split("MSIE");
  8. var version = parseFloat(arVersion[1]);
  9. if ((version >= 5.5) && (document.body.filters))
  10. {
  11. for(var i=0; i<document.images.length; i++)
  12. {
  13. var img = document.images[i];
  14. var imgName = img.src.toUpperCase();
  15. if (imgName == this.jobber_url.toUpperCase() + "IMG/BT-RSS.PNG")
  16. {
  17. var imgID = (img.id) ? "id='" + img.id + "' " : "";
  18. var imgClass = (img.className) ? "class='" + img.className + "' " : "";
  19. var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
  20. var imgStyle = "display:inline-block;" + img.style.cssText;
  21. if (img.align == "left") imgStyle = "float:left;" + imgStyle;
  22. if (img.align == "right") imgStyle = "float:right;" + imgStyle;
  23. if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
  24. var strNewHTML = "<span " + imgID + imgClass + imgTitle;
  25. strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";";
  26. strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
  27. strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
  28. img.outerHTML = strNewHTML;
  29. i = i - 1;
  30. }
  31. }
  32. }
  33. },
  34. PerformSearch: function(url, keywords)
  35. {
  36. clearTimeout(window.search_timer);
  37. $('#job-listings').load(url + encodeURIComponent(keywords) + '/');
  38. $("#indicator").hide();
  39. },
  40. HandleLocationOutsideRo: function()
  41. {
  42. if ($("#location_outside_ro").is(":visible"))
  43. {
  44. $("#city_id").removeAttr("disabled");
  45. $("#location_outside_ro").hide();
  46. $("#other_location_label").html(Jobber.I18n.js.location_other);
  47. }
  48. else
  49. {
  50. $("#city_id").attr("disabled", "disabled");
  51. $("#location_outside_ro").show();
  52. $("#location_outside_ro_where").focus();
  53. $("#other_location_label").html(Jobber.I18n.js.location_pick_from_list);
  54. }
  55. },
  56. SendToFriend: {
  57. showHide: function()
  58. {
  59. $("#send-to-friend").toggle();
  60. },
  61. init: function()
  62. {
  63. $("#frm-send-to-friend").ajaxForm(function(responseText) {
  64. if (responseText == "0")
  65. {
  66. var msg = Jobber.I18n.js.send_to_friend_unsuccessful;
  67. $("#send-to-friend-response").css({ color: "red" });
  68. }
  69. else
  70. {
  71. var msg = Jobber.I18n.js.send_to_friend_successful;
  72. $("#frm-send-to-friend").clearForm();
  73. $("#send-to-friend-response").css({ color: "green" });
  74. }
  75. $("#send-to-friend-response").html(msg);
  76. });
  77. }
  78. },
  79. ReportSpam: function(url, job_id)
  80. {
  81. $.ajax({
  82. type: "POST",
  83. url: url,
  84. data: "job_id=" + job_id,
  85. success: function(msg) {
  86. if (msg == "0")
  87. {
  88. var status = Jobber.I18n.js.report_spam_unsuccessful;
  89. $("#report-spam-response").css({ color: "red" });
  90. }
  91. else
  92. {
  93. var status = Jobber.I18n.js.report_spam_successful;
  94. $("#frm-send-to-friend").clearForm();
  95. $("#report-spam-response").css({ color: "green" });
  96. }
  97. $("#report-spam-response").html(status);
  98. }
  99. });
  100. }
  101. }
  102. })();