~davewalker/etherpad/ubuntu-unlimited-max-users-and-revisions

« back to all changes in this revision

Viewing changes to etherpad/src/static/js/billing.js

  • Committer: James Page
  • Date: 2011-04-13 08:00:43 UTC
  • Revision ID: james.page@canonical.com-20110413080043-eee2nq7y1v7cv2mp
* Refactoring to use native Ubuntu Java libraries. 
* debian/control:
  - use openjdk instead of sun's java
  - update maintainer
* debian/etherpad.init.orig, debian/etherpad.upstart:
  - move the init script out of the way
  - create a basic upstart script
  - note that the open office document conversion daemon was dropped
    from the upstart configuration; if this behavior is desired, please
    create a separate upstart job for it
* debian/rules:
  - just use basic dh_installinit, as it will pick up the new upstart job
* New release
* Changed maintainer to Packaging
* Fixed installation scripts
* Initial Release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2009 Google Inc.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS-IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
$(function() {
 
18
  billing.initFieldDisplay();
 
19
  billing.initCcValidation();
 
20
});
 
21
 
 
22
billing.initFieldDisplay = function() {
 
23
  var id = $('#billingselect input:checked').attr("value");
 
24
  $('.billingfield').not('.billingfield.'+id+'req').hide();
 
25
  $('.paymentbutton').click(billing.selectPaymentType);
 
26
  
 
27
  $('#billingCountry').click(billing.selectCountry);
 
28
  billing.selectCountry();
 
29
}
 
30
 
 
31
billing.selectCountry = function() {
 
32
  var countryCode = $('#billingCountry').attr("value");
 
33
  var id = $('#billingselect input:checked').attr("value");
 
34
  if (countryCode != 'US') {
 
35
    $('.billingfield.intonly.'+id+'req').show();
 
36
    $('.billingfield.usonly').hide();
 
37
  } else {
 
38
    $('.billingfield.intonly').hide();
 
39
    $('.billingfield.usonly.'+id+'req').show();    
 
40
  }
 
41
}
 
42
 
 
43
billing.countryAntiSelector = function() {
 
44
  var countryCode = $('#billingCountry').attr("value");
 
45
  if (countryCode != 'US') {
 
46
    return '.usonly';
 
47
  } else {
 
48
    return '.intonly';
 
49
  }
 
50
}
 
51
 
 
52
billing.selectPaymentType = function() {
 
53
  var radio = $(this).children('input');
 
54
  var id = radio.attr("value");
 
55
  radio.attr("checked", "checked");
 
56
 
 
57
  var selector = billing.countryAntiSelector();
 
58
  var toShow = $('.billingfield.'+id+'req:hidden').not('.billingfield'+selector);
 
59
  var toHide = $('.billingfield:visible').not('.billingfield.'+id+'req');
 
60
 
 
61
  if (toShow.size() > 0 && toHide.size() > 0) {
 
62
    toHide.fadeOut(200);
 
63
    setTimeout(function() {
 
64
      toShow.fadeIn(200);
 
65
    }, 200);
 
66
  } else if (toShow.size() > 0 || toHide.size() > 0){
 
67
    toShow.fadeIn(200);
 
68
    toHide.fadeOut(200);
 
69
  }
 
70
}
 
71
 
 
72
billing.extractCcType = function(numsrc) {
 
73
  var number = $(numsrc).val();
 
74
  var newType = billing.getCcType(number);
 
75
  $('.ccimage').removeClass('ccimageselected');
 
76
  if (newType) {
 
77
    $('#img'+newType).addClass('ccimageselected');
 
78
  }
 
79
  if (billing.validateCcNumber(number)) {
 
80
    $('input[name=billingCCNumber]').css('border', '1px solid #0f0');
 
81
  } else if (billing.validateCcLength(number) || 
 
82
             ! (/^\d*$/.test(number))) {
 
83
    $('input[name=billingCCNumber]').css('border', '1px solid #f00');
 
84
  } else {
 
85
    $('input[name=billingCCNumber]').css('border', '1px solid black');
 
86
  }
 
87
}
 
88
 
 
89
billing.handleCcFieldChange = function(target, event) {
 
90
  if (event && 
 
91
      ! (event.keyCode == 8 || 
 
92
         (event.keyCode >= 32 && event.keyCode <= 126))) {
 
93
    return;
 
94
  }
 
95
  var ccValue = $(target).val();
 
96
  if (ccValue == billing.lastCcValue) {
 
97
    return;
 
98
  }
 
99
  billing.lastCcValue = ccValue;
 
100
  setTimeout(function() {
 
101
    billing.extractCcType(target);
 
102
  }, 0);
 
103
}
 
104
 
 
105
billing.initCcValidation = function() {
 
106
  $('input[name=billingCCNumber]').keydown(
 
107
    function(event) { billing.handleCcFieldChange(this, event); });
 
108
  $('input[name=billingCCNumber]').blur(
 
109
    function() { billing.handleCcFieldChange(this) });
 
110
  billing.lastCcValue = $('input[name=billingCCNumber]').val();
 
111
}
 
 
b'\\ No newline at end of file'