register.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. $(document).ready(function(){
  2. function doNotShowPopup(){
  3. $.get(baseUrl+"Usersettings/donotshowregistrationpopup", {format:"json"});
  4. }
  5. var dialog = $("#register_popup");
  6. dialog.dialog({
  7. autoOpen: false,
  8. width: 500,
  9. resizable: false,
  10. modal: true,
  11. position:['center',50],
  12. close: doNotShowPopup,
  13. buttons: [
  14. {
  15. id: "remind_me",
  16. text: $.i18n._("Remind me in 1 week"),
  17. "class": "btn",
  18. click: function() {
  19. var url = baseUrl+'Usersettings/remindme';
  20. $.ajax({
  21. url: url,
  22. data: {format:"json"}
  23. });
  24. $(this).dialog("close");
  25. }
  26. },
  27. {
  28. id: "remind_never",
  29. text: $.i18n._("Remind me never"),
  30. "class": "btn",
  31. click: function() {
  32. var url =baseUrl+'Usersettings/remindme-never';
  33. $.ajax({
  34. url: url,
  35. data: {format:"json"}
  36. });
  37. $(this).dialog("close");
  38. }
  39. },
  40. {
  41. id: "help_airtime",
  42. text: sprintf($.i18n._("Yes, help %s"), PRODUCT_NAME),
  43. "class": "btn",
  44. click: function() {
  45. $("#register-form").submit();
  46. }
  47. }
  48. ]
  49. });
  50. var button = $("#help_airtime");
  51. if($("#link_to_terms_and_condition").length > 0 ){
  52. button.removeAttr('disabled').removeClass('ui-state-disabled');
  53. }else{
  54. button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
  55. }
  56. dialog.dialog('open');
  57. $('.collapsible-header').live('click',function() {
  58. $(this).next().toggle('fast');
  59. $(this).toggleClass("close");
  60. return false;
  61. }).next().hide();
  62. $("#SupportFeedback").live('click', function(){
  63. var pub = $("#Publicise");
  64. var privacy = $("#Privacy");
  65. var button = $("#help_airtime");
  66. if( !$(this).is(':checked') ){
  67. pub.removeAttr("checked");
  68. pub.attr("disabled", true);
  69. $("#public-info").hide();
  70. button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
  71. }else{
  72. pub.removeAttr("disabled");
  73. if(privacy.length == 0 || privacy.is(':checked')){
  74. button.removeAttr('disabled').removeClass('ui-state-disabled');
  75. }
  76. }
  77. });
  78. var promote = $("#Publicise");
  79. promote.live('click', function(){
  80. if($(this).is(':checked')){
  81. $("#public-info").show();
  82. }else{
  83. $("#public-info").hide();
  84. }
  85. });
  86. if( promote.is(":checked")){
  87. $("#public-info").show();
  88. }
  89. $("#Privacy").live('click', function(){
  90. var support = $("#SupportFeedback");
  91. var button = $("#help_airtime");
  92. if($(this).is(':checked') && support.is(':checked')){
  93. button.removeAttr('disabled').removeClass('ui-state-disabled');
  94. }else{
  95. button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
  96. }
  97. });
  98. if($("#SupportFeedback").is(':checked') && ($("#Privacy").length == 0 || $("#Privacy").is(':checked'))){
  99. button.removeAttr('disabled').removeClass('ui-state-disabled');
  100. }else{
  101. button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
  102. }
  103. $('.toggle legend').live('click',function() {
  104. $('.toggle').toggleClass('closed');
  105. return false;
  106. });
  107. $("#Logo").live('change', function(ev){
  108. var content, res, logoEl;
  109. content = $(this).val();
  110. res = content.match(/(jpg|jpeg|png|gif)$/gi);
  111. logoEl = $("#Logo-element");
  112. //not an accepted image extension.
  113. if (!res) {
  114. var ul, li;
  115. ul = logoEl.find('.errors');
  116. li = $("<li/>").append($.i18n._("Image must be one of jpg, jpeg, png, or gif"));
  117. //errors ul has already been created.
  118. if (ul.length > 0) {
  119. ul.empty()
  120. .append(li);
  121. }
  122. else {
  123. logoEl
  124. .append('<ul class="errors"></ul>')
  125. .find(".errors")
  126. .append(li);
  127. }
  128. $(this).val("");
  129. }
  130. else {
  131. logoEl.find(".errors").remove();
  132. }
  133. });
  134. });
  135. function resizeImg(ele, targetWidth, targetHeight){
  136. var img = $(ele);
  137. var width = ele.width;
  138. var height = ele.height;
  139. // resize img proportionaly
  140. if( width > height && width > targetWidth){
  141. var ratio = targetWidth/width;
  142. img.css("width", targetHeight+"px");
  143. var newHeight = height * ratio;
  144. img.css("height", newHeight);
  145. }else if( width < height && height > targetHeight){
  146. var ratio = targetHeight/height;
  147. img.css("height", targetHeight+"px");
  148. var newWidth = width * ratio;
  149. img.css("width", newWidth);
  150. }else if( width == height && width > targetWidth){
  151. img.css("height", targetHeight+"px");
  152. img.css("width", targetWidth+"px" );
  153. }
  154. }