summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/vendor')
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/jquery.creditCardValidator.js208
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/router.js75
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js20
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/serializable.js129
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/view.js147
5 files changed, 208 insertions, 371 deletions
diff --git a/StoneIsland/platforms/ios/www/js/vendor/jquery.creditCardValidator.js b/StoneIsland/platforms/ios/www/js/vendor/jquery.creditCardValidator.js
new file mode 100644
index 00000000..56ce1bf6
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/jquery.creditCardValidator.js
@@ -0,0 +1,208 @@
+// Generated by CoffeeScript 1.8.0
+
+/*
+jQuery Credit Card Validator 1.0
+
+Copyright 2012-2015 Pawel Decowski
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
+ */
+
+(function() {
+ var $,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ $ = jQuery;
+
+ $.fn.validateCreditCard = function(callback, options) {
+ var bind, card, card_type, card_types, get_card_type, is_valid_length, is_valid_luhn, normalize, validate, validate_number, _i, _len, _ref;
+ card_types = [
+ {
+ name: 'amex',
+ pattern: /^3[47]/,
+ valid_length: [15]
+ }, {
+ name: 'diners_club_carte_blanche',
+ pattern: /^30[0-5]/,
+ valid_length: [14]
+ }, {
+ name: 'diners_club_international',
+ pattern: /^36/,
+ valid_length: [14]
+ }, {
+ name: 'jcb',
+ pattern: /^35(2[89]|[3-8][0-9])/,
+ valid_length: [16]
+ }, {
+ name: 'laser',
+ pattern: /^(6304|670[69]|6771)/,
+ valid_length: [16, 17, 18, 19]
+ }, {
+ name: 'visa_electron',
+ pattern: /^(4026|417500|4508|4844|491(3|7))/,
+ valid_length: [16]
+ }, {
+ name: 'visa',
+ pattern: /^4/,
+ valid_length: [16]
+ }, {
+ name: 'mastercard',
+ pattern: /^5[1-5]/,
+ valid_length: [16]
+ }, {
+ name: 'maestro',
+ pattern: /^(5018|5020|5038|6304|6759|676[1-3])/,
+ valid_length: [12, 13, 14, 15, 16, 17, 18, 19]
+ }, {
+ name: 'discover',
+ pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
+ valid_length: [16]
+ }
+ ];
+ bind = false;
+ if (callback) {
+ if (typeof callback === 'object') {
+ options = callback;
+ bind = false;
+ callback = null;
+ } else if (typeof callback === 'function') {
+ bind = true;
+ }
+ }
+ if (options == null) {
+ options = {};
+ }
+ if (options.accept == null) {
+ options.accept = (function() {
+ var _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = card_types.length; _i < _len; _i++) {
+ card = card_types[_i];
+ _results.push(card.name);
+ }
+ return _results;
+ })();
+ }
+ _ref = options.accept;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ card_type = _ref[_i];
+ if (__indexOf.call((function() {
+ var _j, _len1, _results;
+ _results = [];
+ for (_j = 0, _len1 = card_types.length; _j < _len1; _j++) {
+ card = card_types[_j];
+ _results.push(card.name);
+ }
+ return _results;
+ })(), card_type) < 0) {
+ throw "Credit card type '" + card_type + "' is not supported";
+ }
+ }
+ get_card_type = function(number) {
+ var _j, _len1, _ref1;
+ _ref1 = (function() {
+ var _k, _len1, _ref1, _results;
+ _results = [];
+ for (_k = 0, _len1 = card_types.length; _k < _len1; _k++) {
+ card = card_types[_k];
+ if (_ref1 = card.name, __indexOf.call(options.accept, _ref1) >= 0) {
+ _results.push(card);
+ }
+ }
+ return _results;
+ })();
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ card_type = _ref1[_j];
+ if (number.match(card_type.pattern)) {
+ return card_type;
+ }
+ }
+ return null;
+ };
+ is_valid_luhn = function(number) {
+ var digit, n, sum, _j, _len1, _ref1;
+ sum = 0;
+ _ref1 = number.split('').reverse();
+ for (n = _j = 0, _len1 = _ref1.length; _j < _len1; n = ++_j) {
+ digit = _ref1[n];
+ digit = +digit;
+ if (n % 2) {
+ digit *= 2;
+ if (digit < 10) {
+ sum += digit;
+ } else {
+ sum += digit - 9;
+ }
+ } else {
+ sum += digit;
+ }
+ }
+ return sum % 10 === 0;
+ };
+ is_valid_length = function(number, card_type) {
+ var _ref1;
+ return _ref1 = number.length, __indexOf.call(card_type.valid_length, _ref1) >= 0;
+ };
+ validate_number = (function(_this) {
+ return function(number) {
+ var length_valid, luhn_valid;
+ card_type = get_card_type(number);
+ luhn_valid = false;
+ length_valid = false;
+ if (card_type != null) {
+ luhn_valid = is_valid_luhn(number);
+ length_valid = is_valid_length(number, card_type);
+ }
+ return {
+ card_type: card_type,
+ valid: luhn_valid && length_valid,
+ luhn_valid: luhn_valid,
+ length_valid: length_valid
+ };
+ };
+ })(this);
+ validate = (function(_this) {
+ return function() {
+ var number;
+ number = normalize($(_this).val());
+ return validate_number(number);
+ };
+ })(this);
+ normalize = function(number) {
+ return (number || "").replace(/[ -]/g, '');
+ };
+ if (!bind) {
+ return validate();
+ }
+ this.on('input.jccv', (function(_this) {
+ return function() {
+ $(_this).off('keyup.jccv');
+ return callback.call(_this, validate());
+ };
+ })(this));
+ this.on('keyup.jccv', (function(_this) {
+ return function() {
+ return callback.call(_this, validate());
+ };
+ })(this));
+ callback.call(this, validate());
+ return this;
+ };
+
+}).call(this);
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/router.js b/StoneIsland/platforms/ios/www/js/vendor/view/router.js
deleted file mode 100644
index a8ec331f..00000000
--- a/StoneIsland/platforms/ios/www/js/vendor/view/router.js
+++ /dev/null
@@ -1,75 +0,0 @@
-var Router = View.extend({
-
- routeByHash: false,
-
- go: function(url){
- this.parseRoute(url)
- },
-
- route: function(){
- var path = this.routeByHash ? window.location.hash.substr(0) : window.location.pathname
- path = path || "/"
- this.originalPath = path
- this.parseRoute(path)
- },
-
- parseRoute: function(pathname){
-
- pathname = pathname.replace(/^#/, "")
-
- if (pathname[0] !== "/") { pathname = "/" + pathname }
-
- var routes = this.routes,
- path = pathname.split("/");
-
- for (var i = 0; i < path.length; i++) {
- if (! path[i].length) {
- path[i] = null
- }
- }
-
- if (pathname in routes) {
- this[this.routes[pathname]]()
- return
- }
-
- if (path[path.length-1] == null) {
- path.pop()
- }
-
- for (var route in routes) {
- var routePath = route.split("/")
- if (routePath[1] == path[1]) {
- if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) {
- this[this.routes[route]](path[2])
- return
- }
- else if (routePath[2] == path[2]) {
- if (routePath[3] && path[3]) {
- if (routePath[3].indexOf(":") !== -1) {
- this[this.routes[route]](path[3])
- return
- }
- else if (routePath[3] == path[3]) {
- this[this.routes[route]]()
- return
- }
- }
- else if (! routePath[3] && ! path[3]) {
- this[this.routes[route]]()
- return
- }
- }
- else if (! routePath[2] && (! path[2].length || ! path[2])) {
- this[this.routes[route]]()
- return
- }
- }
- }
-
- if (is_mobile) {
- window.location.href = "/"
- }
- }
-
-})
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js b/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js
deleted file mode 100644
index 7cd96f89..00000000
--- a/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var ScrollableView = View.extend({
-
- events: {
- "load img": "deferScrollToTop",
- },
-
- deferScrollToTop: function(){
- setTimeout(this.scrollToTop.bind(this), 0)
- },
-
- refreshScroller: function(){
- this.scroller.refresh()
- },
-
- scrollToTop: function(){
- this.scroller.refresh()
- app.collection.scroller.scrollTo(0, 0)
- },
-
-}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js b/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js
deleted file mode 100644
index e9459229..00000000
--- a/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js
+++ /dev/null
@@ -1,129 +0,0 @@
-var SerializableView = View.extend({
-
- events: {
- "change select": "update_select",
- "focus input": "focus_input",
- },
-
- preload: function(data){
- if (! data && sdk.env == "production") { return }
- data = data || this.test_data
- if (! data) { return }
-
- Object.keys(data).forEach(function(key){
- var value = data[key]
- var $el = this.$("[name=" + key + "]")
-
- if ($el.attr("type") == "checkbox") {
- $el.prop("checked", value)
- }
- else if ($el.prop("tagName") == "SELECT") {
- $el.val( value )
- this.update_select({ currentTarget: $el })
- }
- else {
- $el.val( value )
- }
- }.bind(this))
- },
-
- serialize: function(){
- var fields = {}
- this.$("input[name], select[name], textarea[name]").each( function(){
- if (this.type == "checkbox") {
- if ($(this).prop("checked")) {
- fields[this.name] = this.value
- }
- }
- else {
- fields[this.name] = this.value
- }
- })
- return fields
- },
-
- deserialize: function(data){
- this.$("input[name], textarea[name]").val("")
- Object.keys(data).forEach(function(k){
- this.$("[" + k + "]").val(data[k])
- })
- },
-
- focus_input: function(e){
- $(e.currentTarget).removeClass("error_hilite")
- },
-
- update_select: function(e){
- var $target = $(e.currentTarget), value = $target.val()
- var label = $($("select")[0]).find("option").filter(function(){ return this.value === value }).html()
-
- $target.parent().addClass("picked")
- $target.parent().find("span").html(label)
- },
-
- validate: function(errors){
- var data = this.serialize()
- var errors = []
- var presence_msgs = this.validate_presence
- Object.keys(presence_msgs).forEach(function(k){
- if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
- })
- this.validate_fields && this.validate_fields(data, errors)
- this.cc && this.cc.validate(errors)
- this.address && this.address.validate(errors)
- return { errors: errors, data: data }
- },
-
- show_errors: function(errors){
- var msgs = []
- errors.forEach(function(e, i){
- if (i > 0) { return }
- this.$("[name=" + e[0] + "]").addClass('error_hilite')
- msgs.push(e[1])
- }.bind(this))
- this.$msg.html(msgs.join("<br>"))
- this.$msg.addClass('alert-notice')
- },
-
- hide_errors: function(){
- this.$msg.removeClass('alert-notice')
- this.$msg.html("")
- },
-
- save: function(e){
- e && e.preventDefault()
-
- var valid = this.validate()
- if (valid.errors.length) {
- this.show_errors(valid.errors)
- return
- }
- else {
- this.hide_errors()
- }
-
- app.curtain.show("loading")
- this.action({
- data: valid.data,
- success: function(data){
- app.curtain.hide("loading")
- this.success(data)
- }.bind(this),
- error: function(data){
- app.curtain.hide("loading")
- this.error(data)
- }.bind(this),
- })
- },
-
- success: function(data){
- console.log("SUCCESS", data)
- },
-
- error: function(data){
- console.log("FAIL", data)
- },
-
-})
-
-var FormView = View.extend(SerializableView.prototype).extend(ScrollableView.prototype)
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/view.js b/StoneIsland/platforms/ios/www/js/vendor/view/view.js
deleted file mode 100644
index 41638ab7..00000000
--- a/StoneIsland/platforms/ios/www/js/vendor/view/view.js
+++ /dev/null
@@ -1,147 +0,0 @@
-var View = (function($, _){
-
- var View = function(options) {
- this._id = _.uniqueId('view')
- this.type = "view"
- options || (options = {});
- _.extend(this, _.pick(options, viewOptions))
- this._ensureElement()
- this.initialize.apply(this, arguments)
- this.delegateEvents()
- }
-
- var delegateEventSplitter = /^(\S+)\s*(.*)$/;
-
- var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
-
- _.extend(View.prototype, {
-
- // The default `tagName` of a View's element is `"div"`.
- tagName: 'div',
-
- $: function(selector) {
- return this.$el.find(selector);
- },
-
- initialize: function(){},
-
- setElement: function(element, delegate) {
- if (this.$el) this.undelegateEvents();
- this.$el = element instanceof $ ? element : $(element);
- this.el = this.$el[0];
- if (delegate !== false) this.delegateEvents();
- return this;
- },
-
- // Set callbacks, where `this.events` is a hash of
- //
- // *{"event selector": "callback"}*
- //
- // {
- // 'mousedown .title': 'edit',
- // 'click .button': 'save',
- // 'click .open': function(e) { ... }
- // }
- //
- // pairs. Callbacks will be bound to the view, with `this` set properly.
- // Uses event delegation for efficiency.
- // Omitting the selector binds the event to `this.el`.
- // This only works for delegate-able events: not `focus`, `blur`, and
- // not `change`, `submit`, and `reset` in Internet Explorer.
- delegateEvents: function(events) {
- if (!(events || (events = _.result(this, 'events')))) return this;
- this.undelegateEvents();
- for (var key in events) {
- var method = events[key];
- if (!_.isFunction(method)) method = this[events[key]];
- if (!method) continue;
-
- var match = key.match(delegateEventSplitter);
- var eventName = match[1], selector = match[2];
- method = _.bind(method, this);
- eventName += '.delegateEvents' + this._id;
- if (is_mobile) {
- if (eventName === 'mouseenter' || eventName === 'mouseleave') {
- continue
- }
-// if (eventName === 'click') {
-// eventName = 'tap'
-// }
- }
- if (selector === '') {
- this.$el.on(eventName, method);
- } else {
- this.$el.on(eventName, selector, method);
- }
- }
- return this;
- },
-
- // Clears all callbacks previously bound to the view with `delegateEvents`.
- undelegateEvents: function() {
- this.$el.off('.delegateEvents' + this._id);
- return this;
- },
-
- // Ensure that the View has a DOM element to render into.
- // If `this.el` is a string, pass it through `$()`, take the first
- // matching element, and re-assign it to `el`. Otherwise, create
- // an element from the `id`, `className` and `tagName` properties.
- _ensureElement: function() {
- this.setElement(_.result(this, 'el'), false);
- },
-
- preventDefault: function(e){
- e && e.preventDefault()
- },
-
- stopPropagation: function(e){
- e && e.stopPropagation()
- },
-
- });
-
-
- var extend = function(protoProps, staticProps) {
- var staticProps = staticProps || {}
- var parent = this;
- var child;
- var childEvents = {};
-
- // The constructor function for the new subclass is either defined by you
- // (the "constructor" property in your `extend` definition), or defaulted
- // by us to simply call the parent's constructor.
- if (protoProps && _.has(protoProps, 'constructor')) {
- child = protoProps.constructor;
- } else {
- child = function(){ return parent.apply(this, arguments); };
- }
-
- // Extend events so we can subclass views
- _.extend(childEvents, parent.prototype.events, protoProps.events)
-
- // Add static properties to the constructor function, if supplied.
- _.extend(child, parent, staticProps);
-
- // Set the prototype chain to inherit from `parent`, without calling
- // `parent`'s constructor function.
- var Surrogate = function(){ this.constructor = child; };
- Surrogate.prototype = parent.prototype;
- child.prototype = new Surrogate;
-
- // Add prototype properties (instance properties) to the subclass,
- // if supplied.
- if (protoProps) _.extend(child.prototype, protoProps);
-
- // Set a convenience property in case the parent's prototype is needed
- // later.
- child.prototype.__super__ = parent.prototype;
- child.prototype.events = childEvents
-
- return child;
- };
-
- View.extend = extend;
-
- return View;
-})(jQuery, _)