diff options
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/nav')
8 files changed, 683 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js new file mode 100755 index 00000000..ad5745fb --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js @@ -0,0 +1,267 @@ + +var AddressView = SerializableView.extend({ + + template: $("#address_template").html(), + + disabled: false, + + events: { + "change [name=Province]": 'update_country', + }, + + initialize: function(opt){ + this.parent = opt.parent + this.checkPhone = 'checkPhone' in opt ? opt.checkPhone : true + this.setElement( this.parent.$(".address") ) + this.$el.html(this.template) + }, + + populate: function(data){ + this.data = data + var address = data.Address.split("\n") + data.Address1 = address[0] + data.Address2 = address[1] + this.$(".address input").val("") + this.load_data(data) + this.update_country() + }, + + validate_presence: { + "Name": "Please enter your first name.", + "Surname": "Please enter your last name.", + "Address1": "Please enter your street address.", + "City": "Please enter your city.", + "ZipCode": "Please enter your zip code.", + }, + + validate_fields: function(data, errors){ + if (this.disabled) { return } + if (this.checkPhone && ! data.Phone) { errors.push([ "Phone", "Please enter your phone number." ]) } + if (this.checkPhone && data.Phone && data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) } + if (! data.Province || data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) } + data.Address = data.Address1 + "\n" + data.Address2 + data.UserId = auth.user_id + delete data.Address1 + delete data.Address2 + }, + + update_country: function(){ + var state = this.$("[name=Province]").val() + console.log(state) + if (CANADIAN_LOOKUP[state]) { + this.$(".country-label").html("CANADA") + } + else { + this.$(".country-label").html("UNITED STATES") + } + }, + +}) + +var CANADIAN_PROVINCES = "AB BC MB NB NL NS NT NU ON PE SK QC YT".split(" ") +var CANADIAN_LOOKUP = {} +CANADIAN_PROVINCES.forEach(function(k){ CANADIAN_LOOKUP[k] = true }) + +var COUNTRIES = [ + ['Country Name', 'NONE'], + ['United States', 'US'], + ['Abkhazia', 'GE'], + ['Afghanistan', 'AF'], + ['Albania', 'AL'], + ['Algeria', 'DZ'], + ['Andorra', 'AD'], + ['Angola', 'AO'], + ['Antigua and Barbuda', 'AG'], + ['Argentina', 'AR'], + ['Armenia', 'AM'], + ['Australia', 'AU'], + ['Austria', 'AT'], + ['Azerbaijan', 'AZ'], + ['Bahamas', 'BS'], + ['Bahrain', 'BH'], + ['Bangladesh', 'BD'], + ['Barbados', 'BB'], + ['Belarus', 'BY'], + ['Belgium', 'BE'], + ['Belize', 'BZ'], + ['Benin', 'BJ'], + ['Bhutan', 'BT'], + ['Bolivia', 'BO'], + ['Bosnia and Herzegovina', 'BA'], + ['Botswana', 'BW'], + ['Brazil', 'BR'], + ['Brunei', 'BN'], + ['Bulgaria', 'BG'], + ['Burkina Faso', 'BF'], + ['Burundi', 'BI'], + ['Cambodia', 'KH'], + ['Cameroon', 'CM'], + ['Canada', 'CA'], + ['Cape Verde', 'CV'], + ['Central African Republic', 'CF'], + ['Chad', 'TD'], + ['Chile', 'CL'], + ['China', 'CN'], + ['Colombia', 'CO'], + ['Comoros', 'KM'], + ['Congo', 'CD'], + ['Congo-Brazzaville', 'CG'], + ['Costa Rica', 'CR'], + ['Cote d\'Ivoire (Ivory Coast)', 'CI'], + ['Croatia', 'HR'], + ['Cuba', 'CU'], + ['Cyprus', 'CY'], + ['Czech Republic', 'CZ'], + ['Denmark', 'DK'], + ['Djibouti', 'DJ'], + ['Dominica', 'DM'], + ['Dominican Republic', 'DO'], + ['Ecuador', 'EC'], + ['Egypt', 'EG'], + ['El Salvador', 'SV'], + ['Equatorial Guinea', 'GQ'], + ['Eritrea', 'ER'], + ['Estonia', 'EE'], + ['Ethiopia', 'ET'], + ['Fiji', 'FJ'], + ['Finland', 'FI'], + ['France', 'FR'], + ['Gabon', 'GA'], + ['Gambia', '220'], + ['Georgia', 'GE'], + ['Germany', 'DE'], + ['Ghana', 'GH'], + ['Greece', 'GR'], + ['Grenada', 'GD'], + ['Guatemala', 'GT'], + ['Guinea', 'GN'], + ['Guinea-Bissau', 'GW'], + ['Guyana', 'GY'], + ['Haiti', 'HT'], + ['Honduras', 'HN'], + ['Hungary', 'HU'], + ['Iceland', 'IS'], + ['India', 'IN'], + ['Indonesia', 'ID'], + ['Iran', 'IR'], + ['Iraq', 'IQ'], + ['Ireland', 'IE'], + ['Israel', 'IL'], + ['Italy', 'IT'], + ['Jamaica', 'JM'], + ['Japan', 'JP'], + ['Jordan', 'JO'], + ['Kazakhstan', 'KZ'], + ['Kenya', 'KE'], + ['Kiribati', 'KI'], + ['Kuwait', 'KW'], + ['Kyrgyzstan', 'KG'], + ['Laos', 'LA'], + ['Latvia', 'LV'], + ['Lebanon', 'LB'], + ['Lesotho', 'LS'], + ['Liberia', 'LR'], + ['Libya', 'LY'], + ['Liechtenstein', 'LI'], + ['Lithuania', 'LT'], + ['Luxembourg', 'LU'], + ['Macedonia', 'MK'], + ['Madagascar', 'MG'], + ['Malawi', 'MW'], + ['Malaysia', 'MY'], + ['Maldives', 'MV'], + ['Mali', 'ML'], + ['Malta', 'MT'], + ['Marshall Islands', 'MH'], + ['Mauritania', 'MR'], + ['Mauritius', 'MU'], + ['Mexico', 'MX'], + ['Micronesia', 'FM'], + ['Moldova', 'MD'], + ['Monaco', 'MC'], + ['Mongolia', 'MN'], + ['Montenegro', 'ME'], + ['Morocco', 'MA'], + ['Mozambique', 'MZ'], + ['Myanmar', 'MM'], + ['Nagorno-Karabakh', 'AZ'], + ['Namibia', 'NA'], + ['Nauru', 'NR'], + ['Nepal', 'NP'], + ['Netherlands', 'NL'], + ['New Zealand', 'NZ'], + ['Nicaragua', 'NI'], + ['Niger', 'NE'], + ['Nigeria', 'NG'], + ['North Korea', 'KP'], + ['Northern Cyprus', 'CY'], + ['Norway', 'NO'], + ['Oman', 'OM'], + ['Pakistan', 'PK'], + ['Palau', 'PW'], + ['Panama', 'PA'], + ['Papua New Guinea', 'PG'], + ['Paraguay', 'PY'], + ['Peru', 'PE'], + ['Philippines', 'PH'], + ['Poland', 'PL'], + ['Portugal', 'PT'], + ['Qatar', 'QA'], + ['Romania', 'RO'], + ['Russia', 'RU'], + ['Rwanda', 'RW'], + ['Saint Kitts and Nevis', 'KN'], + ['Saint Lucia', 'LC'], + ['Saint Vincent and the Grenadines', 'VC'], + ['Samoa', 'WS'], + ['San Marino', 'SM'], + ['Sao Tome and Principe', 'ST'], + ['Saudi Arabia', 'SA'], + ['Senegal', 'SN'], + ['Serbia', 'RS'], + ['Seychelles', 'SC'], + ['Sierra Leone', 'SL'], + ['Singapore', 'SG'], + ['Slovakia', 'SK'], + ['Slovenia', 'SI'], + ['Solomon Islands', 'SB'], + ['Somalia', 'SO'], + ['Somaliland', 'SO'], + ['South Africa', 'Rand'], + ['South Korea', 'KR'], + ['South Ossetia', 'GE'], + ['Spain', 'ES'], + ['Sri Lanka', 'LK'], + ['Sudan', 'SD'], + ['Suriname', 'SR'], + ['Swaziland', 'SZ'], + ['Sweden', 'SE'], + ['Switzerland', 'CH'], + ['Syria', 'SY'], + ['Taiwan', 'TW'], + ['Tajikistan', 'TJ'], + ['Tanzania', 'TZ'], + ['Thailand', 'TH'], + ['Timor-Leste', 'TL'], + ['Togo', 'TG'], + ['Tonga', 'TO'], + ['Transnistria', 'MD'], + ['Trinidad and Tobago', 'TT'], + ['Tunisia', 'TN'], + ['Turkey', 'TR'], + ['Turkmenistan', 'TM'], + ['Tuvalu', 'TV'], + ['Uganda', 'UG'], + ['Ukraine', 'UA'], + ['United Arab Emirates', 'AE'], + ['United Kingdom', 'GB'], + ['Uruguay', 'UY'], + ['Uzbekistan', 'UZ'], + ['Vanuatu', 'VU'], + ['Vatican City', 'VA'], + ['Venezuela', 'VE'], + ['Vietnam', 'VN'], + ['Yemen', 'YE'], + ['Zambia', 'ZM'], + ['Zimbabwe', 'ZW'], +] diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/CreditCardView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/CreditCardView.js new file mode 100755 index 00000000..63784618 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/CreditCardView.js @@ -0,0 +1,61 @@ + +var CreditCardView = SerializableView.extend({ + + template: $("#creditcard_template").html(), + + cardOptions: { + accept: ['visa', 'mastercard', 'amex', 'jcb'], + }, + + events: { + }, + + initialize: function(opt){ + this.parent = opt.parent + this.setElement( this.parent.$(".cc") ) + this.$el.html(this.template) + + this.$number = this.$("[name=Number]") + this.$number.validateCreditCard(this.updateCard.bind(this), this.cardOptions) + }, + + populate: function(data){ + this.data = data + data.Number = "XXXX XXXX XXXX " + data.Number + this.$number.attr("type", "text") + this.parent.$(".cc input").val("") + this.$(".cc input").val("") + this.load_data(data) + }, + + updateCard: function(card){ + // console.log(card) + // card.card_type.name + // card.card_type.valid + }, + + validate_presence: { + 'Number': 'Please enter your credit card number.', + 'Cvv': 'Please enter your security code.', + }, + + validate_fields: function(data, errors){ + if (this.disabled) { return } + var card = this.$number.validateCreditCard(this.cardOptions) + if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ]) } + if (! data.ExpirationMonth || data.ExpirationMonth == "NONE") { errors.push([ "ExpirationMonth", "Please enter the expiration month." ]) } + if (! data.ExpirationYear || data.ExpirationYear == "NONE") { errors.push([ "ExpirationYear", "Please select the expiration month." ]) } + data.UserId = auth.user_id + if (card.valid) { + data.Type = YOOX_CREDIT_CARD_NAME_LOOKUP[ card.card_type.name ] + } + }, + +}) + +var YOOX_CREDIT_CARD_NAME_LOOKUP = { + "visa": "Visa", + "mastercard": "Mastercard", + "amex": "AmericanExpress", + "jcb": "JCB", +} diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/CurtainView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/CurtainView.js new file mode 100755 index 00000000..d444fd60 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/CurtainView.js @@ -0,0 +1,39 @@ +var CurtainView = View.extend({ + + el: "#curtain", + + events: { + "click": "click", + }, + + initialize: function(){ + }, + + klass: null, + show: function(klass){ + this.$el.addClass("visible") + if (klass) { + this.klass = klass + this.$el.addClass(klass) + } + }, + + hide: function(k){ + this.$el.removeClass("visible") + if (this.klass) { + setTimeout( function(){ + this.$el.removeClass(this.klass) + }.bind(this), 200 ) + } + }, + + click: function(){ + if (document.body.classList.contains("nav")) { + app.nav.hide() + } + if (app.selector.visible) { + app.selector.hide() + } + }, + +})
\ No newline at end of file diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/FooterView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/FooterView.js new file mode 100755 index 00000000..74b249e6 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/FooterView.js @@ -0,0 +1,40 @@ +var FooterView = View.extend({ + + el: "#footer", + + events: { + "click .ok": "ok", + "click .cancel": "cancel", + }, + + initialize: function(){ + this.$ok = this.$(".ok") + this.$cancel = this.$(".cancel") + }, + + show: function(ok, cancel){ + if (cancel) { + this.$ok.removeClass("wide") + this.$cancel.show().html(cancel) + } + else { + this.$ok.addClass("wide") + this.$cancel.hide() + } + this.$ok.html(ok) + this.$el.show() + }, + + hide: function(){ + this.$el.hide() + }, + + ok: function(){ + (app.view.save || app.view.ok).bind(app.view)() + }, + + cancel: function(){ + app.view.cancel ? app.view.cancel() : app.intro.show() + }, + +})
\ No newline at end of file diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/HeaderView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/HeaderView.js new file mode 100755 index 00000000..b2f01208 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/HeaderView.js @@ -0,0 +1,57 @@ +var HeaderView = View.extend({ + + el: "#header", + + events: { + "click .burger": "nav", + "click .logo": "logo", + "click .cart": "cart", + }, + + initialize: function(){ + this.$burger = this.$(".burger") + this.$cart = this.$(".cart") + this.$cart_count = this.$(".cart_count") + }, + + back_state: false, + set_back: function(state){ + this.back_state = state + if (state) { + this.$burger[0].className = "burger ion-ios-arrow-left" + } + else { + this.$burger[0].className = "burger ion-android-menu" + } + }, + + nav: function(){ + if (this.back_state) { + app.view.back() + } + else { + app.nav.show() + } + }, + + logo: function(){ + app.router.go("intro") + }, + + cart: function(){ + app.router.go("cart") + }, + + count: 0, + set_cart_count: function(n){ + this.count = n + this.$cart_count.html(n || " ") + }, + increment_cart_count: function(){ + this.$cart_count.html( ++this.count ) + }, + decrement_cart_count: function(){ + this.$cart_count.html( --this.count ) + }, + +})
\ No newline at end of file diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js new file mode 100755 index 00000000..2d8dca43 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js @@ -0,0 +1,46 @@ +var IntroView = View.extend({ + + el: "#intro", + + events: { + "click .store": "store", + "click .hub": "hub", + "click .story": "story", + "click .archive": "archive", + }, + + initialize: function(){ + this.compass = this.$("#compass").get(0) + this.orient = this.deviceorientation.bind(this) + }, + + show: function(){ + document.body.className = "intro" + window.addEventListener("deviceorientation", this.orient) + app.footer.hide() + this.orient({ alpha: 0 }) + // get location.. + }, + + hide: function(){ + window.removeEventListener("deviceorientation", this.orient) + }, + + deviceorientation: function(e){ + var heading + if ('webkitCompassHeading' in e) { + heading = e.webkitCompassHeading || 0 + } + else { + heading = e.alpha || 0 + } + heading = - heading + this.compass.style[transformProp] = "translateZ(0) translateX(-50%) translateY(-50%) rotate(" + heading + "deg)" + }, + + store: function(){ app.router.go("store") }, + hub: function(){ app.router.go("hub") }, + story: function(){ app.router.go("story") }, + archive: function(){ app.router.go("archive") }, + +}) diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js new file mode 100755 index 00000000..704aaa34 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js @@ -0,0 +1,157 @@ +var NavView = View.extend({ + + el: "#nav", + + events: { + "click .logo": "intro", + + "click .store": "store", + "click .hub": "hub", + "click .story": "story", + "click .archive": "archive", + + "click .login": "login", + "click .logout": "logout", + "click .account": "account", + "click .faq": "faq", + "click .search": "search", + + "click .main": "back", + "click .account_back": "back", + "click .profile": "profile", + "click .payment": "payment", + "click .shipping": "shipping", + "click .settings": "settings", + "click .orders": "orders", + "click .return_link": "return_link", + + "click .faq_back": "back", + "click .privacy": "privacy", + "click .returns": "returns", + "click .terms": "terms", + "click .care": "care", + + "click .fb": "fb", + "click .insta": "insta", + "click .tw": "tw", + }, + + initialize: function(){ + }, + + show: function(klass){ + $("body").addClass("nav") + app.curtain.show("dark") + if (klass) { + setTimeout(function(){ + this.addClass(klass) + }.bind(this), 500) + } + }, + + hide: function(){ + $("body").removeClass("nav") + app.curtain.hide("dark") + }, + + intro: function(){ + this.hide() + app.router.go("intro") + }, + store: function(){ + this.hide() + app.router.go("store") + }, + hub: function(){ + this.hide() + app.router.go("hub") + }, + story: function(){ + this.hide() + app.router.go("story") + }, + archive: function(){ + this.hide() + app.router.go("archive") + }, + + login: function(){ + this.hide() + auth.last_view = app.view + app.router.go("account/login") + }, + logout: function(){ + this.hide() + auth.last_view = app.view + app.router.go("account/logout") + }, + account: function(){ + this.el.className = "account" + }, + + back: function(){ + this.el.className = "" + }, + + profile: function(){ + this.hide() + app.router.go("account/profile") + }, + payment: function(){ + this.hide() + app.router.go("account/payment") + }, + shipping: function(){ + this.hide() + app.router.go("account/shipping") + }, + orders: function(){ + this.hide() + app.router.go("account/orders") + }, + settings: function(){ + this.hide() + app.router.go("account/settings") + }, + return_link: function(){ + window.open("http://www.stoneisland.com/", '_system') + }, + + + faq: function(){ + this.el.className = "faq" + }, + privacy: function(){ + this.hide() + app.router.go("page/privacy") + }, + returns: function(){ + this.hide() + app.router.go("page/returns") + }, + terms: function(){ + this.hide() + app.router.go("page/terms") + }, + care: function(){ + window.open("http://www.stoneisland.com/localize.asp?tskay=4036416C&page=help/return&deviceYeti=smartphone", '_system') + }, + + + search: function(){ + this.hide() + app.router.go("search") + }, + + + fb: function(){ + window.open("https://www.facebook.com/StoneIsland", '_system') + }, + insta: function(){ + window.open("https://instagram.com/stoneisland_official", '_system') + }, + tw: function(){ + window.open("https://twitter.com/stoneisland", '_system') + }, + +}) diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/SearchView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/SearchView.js new file mode 100755 index 00000000..f21634a5 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/SearchView.js @@ -0,0 +1,16 @@ +var SearchView = View.extend({ + + el: "#search", + + events: { + }, + + show: function(){ + app.footer.show("SEARCH", "CANCEL") + document.body.className = "search" + }, + + save: function(){ + }, + +})
\ No newline at end of file |
