summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js
diff options
context:
space:
mode:
authorRene Ae <aehtyb@gmail.com>2015-12-04 20:32:44 -0600
committerRene Ae <aehtyb@gmail.com>2015-12-04 20:32:44 -0600
commit10efb0f7b426426057fed757fe3c851a249358dd (patch)
treeb80e285251d30fbca36220c932ef180c29c55dcf /StoneIsland/platforms/android/assets/www/js
parent015b58ff6845b5cb79b13fec109a37b4c10c7813 (diff)
android build
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/index.js86
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/_router.js105
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js129
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js189
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js115
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js82
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js24
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js77
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js53
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js16
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js117
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js228
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js70
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js113
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js24
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js65
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js174
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartError.js28
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js185
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js136
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartSummary.js202
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartThanks.js25
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartView.js66
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/deeplink.js3
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/geo.js39
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/push.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js267
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/CreditCardView.js61
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/CurtainView.js39
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/FooterView.js40
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/HeaderView.js57
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js46
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js157
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/SearchView.js16
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js56
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js114
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/GalleryView.js65
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js397
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/Selector.js48
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/filters/CategoryFilter.js40
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Router.js75
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js27
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js164
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/View.js147
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/_sdk.js38
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/account.js133
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/address.js74
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/auth.js129
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/cart.js248
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/payment.js72
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/product.js37
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/shipping.js85
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/fastclick.js790
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/flickity.pkgd.js5090
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/iscroll.js2011
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/jquery-2.1.4.min.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/jquery.creditCardValidator.js208
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/loader.js97
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/lodash.min.js98
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/moment.js3195
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/oktween.js125
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/prefixfree.js497
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/promise.js34
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/util.js199
64 files changed, 17332 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js
new file mode 100755
index 00000000..0b3531dd
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/index.js
@@ -0,0 +1,86 @@
+var app = (function(){
+ var app = {}
+
+ app.init = function(){
+
+ sdk.init({ env: "production" })
+
+ app.bind()
+ app.build()
+
+ app.iscroll_options = {
+ mouseWheel: true,
+ scrollbars: true,
+ }
+
+ if (window.cordova) {
+ document.addEventListener('deviceready', app.ready, false)
+ }
+ else {
+ app.ready()
+ }
+ }
+
+ app.bind = function(){
+ document.addEventListener('touchmove', function(e){ e.preventDefault() })
+ FastClick.attach(document.body)
+ }
+
+ app.build = function(){
+ app.blog = new BlogView ()
+ app.archive = new ArchiveView ()
+ app.hub = new HubView ()
+ app.story = new StoryView ()
+ app.cart = new CartView ()
+
+ app.intro = new IntroView ()
+ app.header = new HeaderView ()
+ app.footer = new FooterView ()
+ app.curtain = new CurtainView ()
+ app.nav = new NavView ()
+
+ app.account = new AccountView ()
+ app.login = new LoginView ()
+ app.logout = new LogoutView ()
+ app.signup = new SignupView ()
+ app.profile = new ProfileView ()
+ app.payment = new PaymentView ()
+ app.shipping = new ShippingView ()
+ app.settings = new SettingsView ()
+ app.orders = new OrdersView ()
+
+ app.terms = new PageView ({ page: "terms" })
+ app.privacy = new PageView ({ page: "privacy" })
+ app.returns = new PageView ({ page: "returns" })
+ app.care = new PageView ({ page: "care" })
+
+ app.collection = new CollectionView ()
+ app.product = new ProductView ()
+ app.closed = new ClosedStoreView ()
+ app.search = new SearchView ()
+
+ app.selector = new Selector ()
+ }
+
+ app.ready = function(){
+ if (window.cordova) {
+ cordova.plugins.Keyboard.disableScroll(true)
+ geo.fetch()
+ }
+
+ app.view = null
+ app.router = new SiteRouter ()
+// if (sdk.env == "test") {
+// app.router.launch()
+// }
+// else {
+ app.account.connect( app.router.launch.bind(app.router) )
+// }
+
+ $("body").removeClass("loading")
+ }
+
+ return app
+})()
+
+app.init()
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/_router.js b/StoneIsland/platforms/android/assets/www/js/lib/_router.js
new file mode 100755
index 00000000..b1fa1c97
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/_router.js
@@ -0,0 +1,105 @@
+var SiteRouter = Router.extend({
+
+ el: 'body',
+ routeByHash: true,
+
+ routes: {
+ '/': 'intro',
+ '/intro': 'intro',
+ '/hub': 'hub',
+ '/story': 'story',
+ '/archive': 'archive',
+
+ '/store': 'collection',
+ '/store/closed': 'closed',
+ '/store/:code': 'product',
+
+ '/account/login': 'login',
+ '/account/logout': 'logout',
+ '/account/signup': 'signup',
+ '/account/profile': 'profile',
+ '/account/payment': 'payment',
+ '/account/shipping': 'shipping',
+ '/account/orders': 'orders',
+ '/account/settings': 'settings',
+
+ '/page/terms': 'terms',
+ '/page/privacy': 'privacy',
+ '/page/returns': 'returns',
+ '/page/care': 'care',
+
+ '/search': 'search',
+
+ '/cart': 'cart.summary',
+ '/cart/summary': 'cart.summary',
+ '/cart/payment': 'cart.payment',
+ '/cart/shipping': 'cart.shipping',
+ '/cart/confirm': 'cart.confirm',
+ '/cart/thanks': 'cart.thanks',
+ '/cart/error': 'cart.error',
+ },
+
+ initialize: function(){
+ var fn
+ for (var route in this.routes) {
+ fn = this.routes[route]
+ if (! this[fn]) {
+ this[fn] = this.default_view(fn)
+ }
+ }
+ },
+
+ initial_route: null,
+ launch: function(){
+ if (this.initial_route) {
+ this.parseRoute( this.initial_route )
+ }
+ else {
+ this.route()
+ }
+ this.initial_route = null
+ },
+
+ go: function(url){
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ window.location.href = "#/" + url
+ this.parseRoute(url)
+ },
+
+ default_view: function(name){
+ var fn = function(){
+ console.log(name)
+ if (app.view != app.login && app.view != app.signin) {
+ app.last_view = app.view
+ }
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ if (name.match(/\./)) {
+ var n = name.split(".")
+ console.log(name, n)
+ app.view = app[n[0]][n[1]]
+ }
+ else {
+ app.view = app[name]
+ }
+ app.header.set_back( !! app.view.back )
+ app.view.show()
+ }.bind(this)
+ return fn
+ },
+
+ product: function(code){
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ app.view = app.product
+ app.header.set_back( true )
+ app.product.load(code)
+ app.product.show()
+ },
+
+})
+
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js
new file mode 100755
index 00000000..1c5c9f16
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js
@@ -0,0 +1,129 @@
+var AccountView = View.extend({
+
+ initialize: function(){
+ },
+
+ connect: function(cb){
+ auth.init(this.ready.bind(this, cb))
+ },
+
+ ready: function(cb){
+ if (auth.logged_in()) {
+ this.logged_in(cb)
+ }
+ else {
+ this.logged_out(cb)
+ }
+ },
+
+ addresses: [],
+ addressLookup: {},
+ ccs: [],
+ ccLookup: {},
+
+ listAddresses: function(cb){
+ sdk.address.list({
+ success: function(data){
+ this.populateAddresses(data, cb)
+ }.bind(this)
+ })
+ },
+
+ populateAddresses: function(data, cb){
+ console.log("populate addresses:", data.AddressBook.addressBookItem)
+
+ if (! data.AddressBook) {
+ console.log("no addresses")
+ cb && cb()
+ return
+ }
+
+ this.addresses = data.AddressBook.addressBookItem
+ this.addressLookup = {}
+ data.AddressBook.addressBookItem.forEach(function(item){
+ this.addressLookup[ item.Id ] = item
+ if (item.IsDefault) {
+ console.log("SHIPPING ADDRESS", item)
+ app.shipping.populate(item)
+ }
+ if (item.IsBillingDefault) {
+ console.log("BILLING ADDRESS")
+ app.payment.populate(item)
+ }
+ }.bind(this))
+
+ app.cart.shipping.populate()
+
+ cb && cb()
+ },
+
+ listCreditCards: function(cb){
+ sdk.payment.list_credit_cards({
+ success: function(data){
+ this.populateCreditCards(data, cb)
+ }.bind(this)
+ })
+ },
+
+ populateCreditCards: function(data, cb){
+ console.log("populate ccs:", data.CreditCards)
+ this.ccs = data.CreditCards
+ this.ccLookup = {}
+ if (! data.CreditCards || ! data.CreditCards.length) {
+ }
+ else {
+ data.CreditCards.forEach(function(cc){
+ this.ccLookup[cc.Id] = cc
+ }.bind(this))
+ app.payment.populate( data.CreditCards[0] )
+ app.cart.payment.populate()
+ }
+ cb && cb()
+ },
+
+ logged_in: function(cb){
+ this.listAddresses()
+ this.listCreditCards()
+ $("#nav .login").hide()
+ $("#nav .account, #nav .logout").show()
+ if (! auth.deferred_product && app.last_view) {
+ if (app.last_view != app.login && app.last_view != app.signin && app.last_view != app.logout) {
+ app.view && app.view.hide && app.view.hide()
+ app.view = app.last_view
+ app.view.show()
+ }
+ }
+ else {
+ cb && cb()
+ }
+ if ( ! auth.has_cart() ) {
+ app.curtain.show("loading")
+ auth.create_cart(function(){
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ setTimeout(function(){
+ app.curtain.hide("loading")
+ }, 500)
+ })
+ })
+ }
+ else {
+ if (auth.deferred_product) {
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ })
+ }
+ else {
+ app.cart.load()
+ }
+ }
+ },
+
+ logged_out: function(cb){
+ $("#nav .login").show()
+ $("#nav .account, #nav .logout").hide()
+ $("#nav").removeClass("account")
+ cb && cb()
+ },
+
+})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js
new file mode 100755
index 00000000..a1b83767
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js
@@ -0,0 +1,189 @@
+var OrdersView = ScrollableView.extend({
+
+ el: "#orders",
+
+ loaded: false,
+
+ list_template: $("#orders .list_template").html(),
+ item_template: $("#orders .item_template").html(),
+
+ events: {
+ "click .back": "back",
+ "click .item": "load_single",
+ },
+
+ initialize: function(){
+ this.$list = this.$(".list")
+ this.$empty = this.$(".empty")
+ this.$single_order = this.$("#single_order")
+
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
+
+ this.$shipping_address = this.$(".shipping_address")
+ this.$shipping_method = this.$(".shipping_method")
+
+ this.scroller = new IScroll('#orders', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.header.set_back(false)
+ app.footer.hide()
+ document.body.className = "orders"
+ this.deferScrollToTop()
+ this.el.className = ""
+
+ if (this.loaded) {
+ this.populate()
+ }
+ else {
+ this.fetch()
+ }
+ },
+
+ orders: null,
+ orderLookup: {},
+
+ fetch: function(){
+ this.$list.empty()
+ this.$empty.hide()
+ this.loader = new Loader(this.ready.bind(this))
+ app.curtain.show("loading")
+ sdk.account.fetch_orders({
+ success: function(data){
+ this.loader.register("orders")
+ this.orders = data.OrderDetails
+ data.OrderDetails.forEach(function(row){
+ this.loader.register(row.OrderNumber)
+ sdk.account.fetch_single_order({
+ id: row.OrderNumber,
+ success: function(row_data){
+ this.orderLookup[ row.OrderNumber ] = row_data.OrderFullDetails
+ this.loader.ready(row.OrderNumber)
+ }.bind(this),
+ error: function(){
+ this.orderLookup[ row.OrderNumber ] = null
+ this.loader.ready(row.OrderNumber)
+ }.bind(this),
+ })
+ }.bind(this))
+ this.loader.ready("orders")
+ }.bind(this),
+ error: function(){
+ console.log("error fetching orders")
+ }.bind(this),
+ })
+ },
+
+ ready: function(){
+ this.populate()
+ app.curtain.hide("loading")
+ },
+
+ populate: function(){
+ this.$list.empty()
+
+ if (! this.orders.length) {
+ this.$empty.show()
+ return
+ }
+ else {
+ this.$empty.hide()
+ }
+ this.orders.forEach(function(row){
+ var order = this.orderLookup[ row.OrderNumber ]
+ if (! order) { return }
+ var t = this.list_template.replace(/{{date}}/g, moment(order['Date']).format("ddd MM/DD/YYYY").toUpperCase())
+ .replace(/{{id}}/g, row.OrderNumber)
+ .replace(/{{total}}/g, as_cash( order.TotalAmount ))
+ var $t = $(t), $images = $t.find(".images")
+ order.Items.forEach(function(item){
+ var img = new Image ()
+ img.src = sdk.image(item['Code10'], "11_f")
+ $images.append(img)
+ }.bind(this))
+ this.$list.append($t)
+ }.bind(this))
+
+ this.refreshScroller()
+ },
+
+ load_single: function(e){
+ var id = $(e.currentTarget).data("id")
+ var order = this.orderLookup[ id ]
+ if (! order) { return }
+
+ console.log(order)
+
+ this.$rows.empty()
+
+ order.Items.forEach(function(item){
+ var $el = $("<div class='item'><img src='img/spinner.gif'></div>")
+ this.$rows.append($el)
+ var code_ten = item.Code10
+
+ var code = code_ten.substr(0, 8)
+ app.product.find(code, function(data, details){
+ var descriptions = app.product.get_descriptions( details )
+
+ var name_partz = descriptions['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( descriptions['MicroCategory'] )
+
+ var color_name, size_name
+
+ details.Item.ModelColors.some(function(color){
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ return true
+ }
+ return false
+ })
+ size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily
+
+ var t = this.item_template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name || "DEFAULT")
+ .replace(/{{color}}/, color_name || "DEFAULT")
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.data("price", details.Item.Price.DiscountedPrice)
+ $el.html(t)
+ this.refreshScroller()
+ }.bind(this))
+ }.bind(this))
+
+ var subtotal = order.ItemsTotalAmount
+ var shipping_cost = order.Delivery.Amount
+ var tax = order.SalesTaxAmount
+ var total = order.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+
+ var street = order.Delivery.Address.replace(/\n$/,"").replace("\n","<br>")
+ var address = order.Delivery.Name + "<br>" + street + "<br>" + order.Delivery.City + " " + order.Delivery.ZipCode
+ this.$shipping_address.html(address)
+ this.$shipping_method.html(order.Delivery.Type + " - " + order.Delivery.Time)
+
+ app.header.set_back(true)
+ this.$el.addClass("single")
+ },
+
+ back: function(){
+ app.header.set_back(false)
+ this.el.className = ""
+ },
+
+})
+
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js
new file mode 100755
index 00000000..03dc8cbf
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js
@@ -0,0 +1,115 @@
+var PaymentView = FormView.extend({
+
+ el: "#payment",
+
+ action: sdk.payment.add_credit_card,
+
+ events: {
+ },
+
+ test_data: {
+ "Name":"Name",
+ "Surname":"Surname",
+ "Address1":"address",
+ "Address2":"address2",
+ "City":"Ferrara",
+ "Province":"NY",
+ "HolderIsoCountry":"IT",
+ "CreditCardCountry": "US",
+ "ZipCode":"40200",
+ "Type":"Visa",
+ "Number":"4111111111111111",
+ "ExpirationMonth":"09",
+ "ExpirationYear":"2017",
+ "Cvv":"1233",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this, checkPhone: false })
+ this.cc = new CreditCardView ({ parent: this })
+ this.scroller = new IScroll('#payment', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "payment"
+ this.deferScrollToTop()
+ // this.preload()
+ },
+
+ populate: function(data){
+ this.data = data || this.data
+ this.address.populate(data)
+ this.cc.populate(data)
+ },
+
+ finalize: function(data){
+ if (this.cc.data && this.cc.data.Guid) {
+ sdk.payment.delete_credit_card({
+ guid: this.cc.data.Guid,
+ success: function(){},
+ error: function(){},
+ })
+ }
+
+ data.IsDefault = "true" // this.$isDefault.prop("checked") ? "true" : "false"
+ data.UserId = sdk.auth.user_id
+ data.HolderIsoCountry = "US"
+ data.CreditCardNumber = data.Number
+ data.IsPreferred = "true"
+
+ console.log(data)
+ return data
+ },
+
+ success: function(data){
+ app.curtain.show("loading")
+ app.account.listAddresses(function(){
+ app.curtain.hide("loading")
+ })
+ },
+
+ error: function(data){
+ console.log(data)
+ },
+
+ cancel: function(){
+ app.router.go("intro")
+ },
+
+})
+
+/*
+ var new_card = {
+ "Name":"Name",
+ "Surname":"Surname",
+ "Address":"address",
+ "City":"Ferrara",
+ "Province":"FE",
+ "HolderIsoCountry":"IT",
+ "ZipCode":"40200",
+ "Type":"Visa",
+ "Number":"0000567890124285",
+ "ExpirationMonth":"02",
+ "ExpirationYear":"2017",
+ }
+ promise(sdk.payment.add_credit_card, { data: new_card }).then(function(data){
+ last_guid = data['CreditCard']['Guid']
+ assert(data.Header.StatusCode == 201)
+ assert(!! last_guid)
+ done()
+ })
+
+ promise(sdk.payment.list_credit_cards, { data: {} }).then(function(data){
+ assert(data.Header.StatusCode == 201)
+ console.log(data)
+ done()
+ })
+
+ promise(sdk.payment.delete_credit_card, { guid: last_guid }).then(function(data){
+ assert(data.Header.StatusCode == 200)
+ done()
+*/ \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js
new file mode 100755
index 00000000..ed2f3536
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js
@@ -0,0 +1,82 @@
+var ProfileView = FormView.extend({
+
+ el: "#profile",
+
+ events: {
+ },
+
+ action: sdk.account.update,
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#profile', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "profile"
+ this.preload(auth.user)
+ this.deferScrollToTop()
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ },
+
+ validate_fields: function(data, errors){
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (! data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) { errors.push([ "CurrentPassword", "Please enter your current password." ]) }
+ if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) }
+ if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) }
+ // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ },
+
+ finalize: function(data){
+ if (data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) {
+ data.NewPassword = data.NewPassword || data.CurrentPassword
+ data.NewEmail = data.NewEmail || auth.user.Email
+
+ sdk.account.update_mail_and_password({
+ data: {
+ Password: data.CurrentPassword,
+ NewPassword: data.NewPassword || data.CurrentPassword,
+ Email: auth.user,
+ NewEmail: data.NewEmail || auth.user.Email,
+ },
+ success: function(){ console.log("updated password") },
+ error: function(){ console.log("error updating password") },
+ })
+ }
+
+ var submissible_data = _.pick(data, "Name Surname BirthDay YooxLetter".split(" "))
+ submissible_data.Gender = "U"
+// submissible_data.idUser = auth.user_id
+// submissible_data.AccessToken = auth.access_token
+// submissible_data.Premium = "false"
+// submissible_data.LanguageId = ""
+// submissible_data.SiteCode = "STONEISLAND_US"
+// submissible_data.FuriganaName = ""
+// submissible_data.FuriganaSurname = ""
+// submissible_data.UserPromocode = ""
+ submissible_data.BirthDay += "T00:00:00Z"
+ submissible_data.YooxLetter = data.YooxLetter || "false"
+ submissible_data.DataProfiling = "true"
+
+ return submissible_data
+ },
+
+ success: function(data){
+ },
+
+ error: function(data){
+ },
+
+ cancel: function(){
+ app.router.go("intro")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
new file mode 100755
index 00000000..7f96bb88
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
@@ -0,0 +1,24 @@
+var SettingsView = FormView.extend({
+
+ el: "#settings",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#settings', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "settings"
+ this.deferScrollToTop()
+ },
+
+ save: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js
new file mode 100755
index 00000000..39baf2aa
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js
@@ -0,0 +1,77 @@
+var ShippingView = FormView.extend({
+
+ el: "#shipping",
+
+ action: sdk.address.add,
+
+ events: {
+ },
+
+ test_data: {
+ "Name":"name",
+ "Surname":"surname",
+ "Address":"address1\naddress2",
+ "IsDefault":false,
+ "IsBillingDefault":false,
+ "IsOwner":false,
+ "ZipCode":"88040",
+ "City":"City",
+ "Province":"NY",
+ "Phone":"1234567890",
+ "Mobile":"Mobile",
+ "Mail":"Mail",
+ "UserId": sdk.auth.user_id,
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.scroller = new IScroll('#shipping', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+// this.preload( this.data || this.test_data )
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "shipping"
+ this.deferScrollToTop()
+ },
+
+ populate: function(data){
+ this.data = data || this.data
+ this.address.populate(data)
+ },
+
+ finalize: function(data){
+ if (this.address.data && this.address.data.Id) {
+ sdk.address.destroy({
+ id: this.address.data.Id,
+ success: function(){},
+ error: function(){},
+ })
+ }
+
+ data.IsDefault = "true" // this.$isDefault.prop("checked") ? "true" : "false"
+ data.UserId = sdk.auth.user_id
+
+ console.log(data)
+ return data
+ },
+
+ success: function(data){
+ app.curtain.show("loading")
+ app.account.listAddresses(function(){
+ app.curtain.hide("loading")
+ })
+ },
+
+ error: function(data){
+ console.log(data)
+ },
+
+ cancel: function(){
+ app.router.go("intro")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js
new file mode 100755
index 00000000..1f7438cc
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js
@@ -0,0 +1,53 @@
+var LoginView = FormView.extend({
+
+ el: "#login",
+
+ action: sdk.account.login,
+
+ events: {
+ "click .newuser": "new_user",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#login', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "login"
+ },
+
+ new_user: function(){
+ app.router.go("account/signup")
+ },
+
+ validate_presence: {
+ "Email": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ },
+
+ success: function(data){
+ // console.log(data)
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ this.$msg.html("There was an error logging you in. Bad password?")
+ this.$msg.addClass('alert-notice')
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js
new file mode 100755
index 00000000..481dcb8d
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js
@@ -0,0 +1,16 @@
+var LogoutView = View.extend({
+
+ el: "#logout",
+
+ events: {
+ },
+
+ show: function(){
+ document.body.className = "logout"
+ app.header.set_cart_count(0)
+ app.footer.hide()
+ auth.log_out()
+ app.account.logged_out()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js
new file mode 100755
index 00000000..afbb8877
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js
@@ -0,0 +1,117 @@
+var SignupView = FormView.extend({
+
+ el: "#signup",
+
+ action: sdk.account.signup,
+ last_data: null,
+
+/*
+ test_data: {
+ "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com",
+ "Password": "TestPassword",
+ "Password2": "TestPassword",
+ "Gender": "U",
+ "Name": "TestName",
+ "Surname": "TestSurname",
+ "BirthDay": "1978-11-12",
+ "DataProfiling": true,
+ "DataProfiling2": true,
+ },
+*/
+
+ events: {
+ "click .privacy-msg": "privacy_link",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#signup', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "signup"
+
+ this.preload()
+ this.deferScrollToTop()
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ "ConfirmEmail": "Please enter a valid email address.",
+ "BirthDay": "Please enter your birthday.",
+ "Password": "Please enter your password.",
+ "Password2": "Please enter your password again.",
+ "DataProfiling": "You must agree to data profiling.",
+ },
+
+ validate_fields: function(data, errors){
+ if (data.Password.length < 7) { errors.push([ "Password", "Password must be 7 characters or more." ]) }
+ if (data.Password !== data.Password2) { errors.push([ "Password2", "Passwords don't match." ]) }
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (data.Email.toLowerCase() !== data.ConfirmEmail.toLowerCase()) { errors.push([ "ConfirmEmail", "Email addresses don't match." ]) }
+ // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) }
+ if (data.DataProfiling2 !== "true") { errors.push([ "DataProfiling2", "You must consent to use this service." ]) }
+ if (! data.YooxLetter) { data.YooxLetter = false }
+ },
+
+ finalize: function(data){
+ delete data.DataProfiling2
+ delete data.ConfirmEmail
+
+ data.Gender = "U"
+ data.BirthDay += "T00:00:00Z"
+
+ this.last_data = data
+ console.log(data)
+ return data
+ },
+
+ privacy_link: function(){
+ // rewrite app.privacy instance temporarily
+ app.privacy.back = function(){
+ app.router.go("account/signup")
+ }
+ app.privacy.hide = function(){
+ app.privacy.back = app.privacy.hide = null
+ }
+ app.router.go("page/privacy")
+ },
+
+ success: function(data){
+ console.log('success', data)
+ auth.user = auth.user || {}
+ auth.user.Name = this.last_data.Name
+ auth.user.Surname = this.last_data.Surname
+ auth.user.Email = this.last_data.Email
+ auth.user.BirthDay = this.last_data.BirthDay
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ try {
+ data = JSON.parse(data.responseText)
+ app.signup.show_errors([[ 'Name', data['Error']['Description'] ]])
+ }
+ catch (e) {
+ app.signup.show_errors([[ 'Name', "There was an unknown error." ]])
+ }
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js
new file mode 100755
index 00000000..254df6d1
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js
@@ -0,0 +1,228 @@
+var ArchiveView = ScrollableView.extend({
+
+ el: "#archive",
+ menu_template: $("#archive .menu .template").html(),
+ row_template: $("#archive .scroll .template").html(),
+
+ events: {
+ "click .item": "pick",
+ "mousedown .row": "mousedown",
+ "touchstart .row": "touchstart",
+ "mousemove .row": "mousemove",
+ "touchmove .row": "touchmove",
+ "mouseup .row": "mouseup",
+ "touchend .row": "touchend",
+ },
+
+ initialize: function(){
+ this.$menu_items = this.$(".menu .items")
+ this.$content = this.$(".content")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#archive .scroll', app.iscroll_options)
+ this.$subtitle = this.$('.subtitle')
+ this.subtitle_html = this.$subtitle.html()
+
+ },
+
+ back: function(){
+ this.$el.addClass("menu")
+ app.header.set_back(false)
+ this.$subtitle.html( this.subtitle_html )
+ },
+
+ pick: function(e){
+ this.$el.removeClass("menu")
+ app.header.set_back(true)
+ var index = $(e.currentTarget).data("index")
+ this.$subtitle.html( $(e.currentTarget).text() )
+ this.populateDecade(index)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ this.back()
+ document.body.className = "archive"
+ },
+
+ populate: function(data){
+ if (this.loaded) { return }
+ this.loaded = true
+ this.data = data
+ this.$loader.hide()
+ this.$content.empty()
+
+ // id title images[ uri label code caption ]
+ this.data.forEach(function(row, index){
+
+ var t = this.menu_template.replace(/{{title}}/, row.title)
+ var $t = $(t)
+ $t.data("title", row.title)
+ $t.data("index", index)
+ this.$menu_items.append($t)
+ }.bind(this))
+
+ this.back()
+ this.deferScrollToTop()
+
+ this.populateDecade(0, 3)
+ },
+
+ populateDecade: function(index, count){
+ this.$content.empty()
+
+ var loader = new Loader()
+
+ var row = this.data[index]
+
+ count = count || row.images.length
+
+ row.images.forEach(function(cell, i){
+ var $t = $("<div>")
+ $t.addClass("row").addClass("loading")
+ var t = this.row_template.replace(/{{image}}/, cell.uri)
+ .replace(/{{label}}/, cell.label)
+ .replace(/{{code}}/, cell.code)
+ .replace(/{{caption}}/, cell.caption)
+ $t.html(t)
+ $t.data("flipped", false)
+ this.$content.append($t)
+
+ var item = $t[0]
+ var aa = this.build_aa_item( item )
+ aa.q = 0
+ this.render( aa, 0 )
+ aa.flipped = true
+ this.fix_z_index( aa )
+
+ var $text = $t.find(".text")
+ if ( ($text.height() % 2) == 1) {
+ $text.css("margin-bottom", "1px")
+ }
+
+ loader.preloadImage(cell.uri, function(){
+ aa.flipped = false
+ this.fix_z_index( aa )
+ $t.removeClass('loading')
+ }.bind(this))
+ }.bind(this))
+ },
+
+// ['transformProp'] = "translateZ(0) translateX(-50%) translateY(-50%) ";
+// .image, .text
+
+ touchstart: function(e){
+ app.archive.row = e.currentTarget
+ app.archive.mousedown(e.originalEvent.touches[0])
+ },
+ touchmove: function(e){
+ app.archive.mousemove(e.originalEvent.touches[0])
+ },
+ touchend: function(e){
+ app.archive.mouseup()
+ },
+
+ row: null,
+ image: null,
+ text: null,
+ flipped: false,
+ q: 0,
+
+ mousedown: function(e){
+ var aa = app.archive.item = app.archive.build_aa_item( app.archive.row || e.currentTarget )
+ aa.mouse_x = e.pageX
+ aa.mouse_y = e.pageY
+ },
+
+ build_aa_item: function(el){
+ var aa = {}
+ aa.row = el
+ aa.flipped = $(aa.row).data('flipped')
+ aa.image = $(aa.row).find(".image")[0]
+ aa.text = $(aa.row).find(".text")[0]
+ aa.q = 0
+ return aa
+ },
+
+ mousemove: function(e){
+ if (! app.archive.item) return
+ aa = app.archive.item
+ var dx = ( aa.mouse_x - e.pageX ) / window.innerWidth
+ var dy = ( aa.mouse_y - e.pageY ) / window.innerWidth
+
+ var gray, opacity, q
+
+ dx = Math.abs(dx)
+ dx *= 2
+ q = clamp( dx, 0, 1 )
+
+ this.render(aa, q)
+
+ aa.q = q
+/*
+ aa.row.style['transformProp'] = [
+ "translateZ(0)",
+ "translateX(-50%)",
+ "translateY(-50%)",
+ "rotateY(" + dx + "deg)",
+ ].join(" ")
+*/
+ },
+
+ render: function(aa, q){
+ if ( aa.flipped ) {
+ gray = Math.round( (1-q) * 100 )
+ opacity = lerp(q, 0.2, 1)
+ text_opacity = lerp(q, 1, 0.3)
+// console.log("<", gray, opacity)
+ }
+ else {
+ gray = Math.round( q * 100 )
+ opacity = lerp(q, 1, 0.2)
+ text_opacity = lerp(q, 0.3, 1)
+// console.log(">", gray, opacity)
+ }
+ aa.image.style.WebkitFilter = "grayscale(" + gray + "%)"
+ aa.image.style.opacity = opacity
+ aa.text.style.opacity = text_opacity
+ },
+
+ margin: 0.3,
+
+ mouseup: function(e){
+ aa = app.archive.item
+ app.archive.row = null
+ app.archive.item = null
+ var was_flipped = aa.flipped
+ var flipped = aa.flipped ? (aa.q < app.archive.margin) : (aa.q > app.archive.margin)
+ var dest = was_flipped == flipped ? 0 : 1
+ $(aa.row).data('flipped', flipped)
+
+ oktween.add({
+ obj: {q: aa.q},
+ to: {q: dest},
+ duration: 200 * Math.abs(aa.q-dest),
+ update: function(o, dt){
+ app.archive.render(aa, o.q)
+ },
+ })
+
+ this.fix_z_index(aa)
+ },
+
+ fix_z_index: function (aa) {
+ if ( aa.flipped ) {
+ console.log(aa.q)
+ z = aa.q > app.archive.margin ? 2 : 1
+ zz = aa.q > app.archive.margin ? 1 : 2
+ }
+ else {
+ z = aa.q < app.archive.margin ? 2 : 1
+ zz = aa.q < app.archive.margin ? 1 : 2
+ }
+ aa.image.style.zIndex = z
+ aa.text.style.zIndex = zz
+
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
new file mode 100755
index 00000000..9b49abbd
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
@@ -0,0 +1,70 @@
+var BlogView = View.extend({
+
+ data: null,
+ loaded: false,
+ initialize: function(){
+ this.loader = new Loader ()
+ this.fetch()
+ },
+
+ fetch: function(){
+ $.ajax({
+ method: "GET",
+// url: sdk.env == 'test' ? '/db.json' : "http://stone.sup.land/db.json",
+ url: "http://stone.sup.land/db.json",
+ success: this.success.bind(this),
+ cache: true,
+ })
+ },
+
+ success: function(data){
+
+ if (this.loaded) return
+
+ this.loaded = true
+ this.data = data = typeof data == "string" ? JSON.parse(data) : data
+
+ app.archive.populate(data.archive)
+ this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
+ app.hub.populate(data.hub)
+ })
+ this.loader.preloadImage(data.story[0].image.uri, function(img){
+ app.story.populate(data.story)
+ })
+ data.page.forEach(function(page){
+ app[page.tag].populate(page)
+
+ })
+ app.collection.setCollectionName( data.store[0].collection )
+
+ app.closed.populate(data.store[0].ClosedStoreImages)
+ switch (data.store[0].StoreStatus) {
+ case "open":
+ app.closed.storeIsClosed = false
+ break
+ case "closed":
+ app.closed.storeIsClosed = true
+ app.closed.storeOpenDate = null
+ break
+ case "openson":
+ app.closed.storeIsClosed = true
+ app.closed.storeOpenDate = moment(data.store[0].OpensOn)
+ break
+ }
+ console.log(data.store[0].StoreStatus)
+
+ var fits_large = (data.store[0].FitsLarge === "true")
+ app.product.$fit.toggle( fits_large )
+ app.product.$sizing.toggle( fits_large )
+
+ if (data.store[0].BackgroundIsGray === "true") {
+ app.collection.$el.addClass("gray")
+ app.product.gallery.$el.addClass("gray")
+ }
+
+ app.gallery_id = data.store[0].CollectionId
+
+ app.collection.fetch()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
new file mode 100755
index 00000000..49c05ff6
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
@@ -0,0 +1,113 @@
+var HubView = ScrollableView.extend({
+
+ el: "#hub",
+ template: $("#hub .template").html(),
+
+ events: {
+ "click .share": "content-share",
+ "click .store": "store_link",
+ "click .gallery-left": "gallery_left",
+ "click .gallery-right": "gallery_right",
+ "click .play": "play_video",
+ },
+
+ initialize: function(){
+ this.$content = this.$(".content")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#hub', app.iscroll_options)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ document.body.className = "hub"
+ },
+
+ galleries: {},
+ populate: function(data){
+ this.data = data
+ this.$loader.hide()
+ this.$content.empty()
+ this.galleries = {}
+ // id date subtitle body link store image[uri caption]
+ this.data.forEach(function(row){
+ // console.log(row)
+ var t = this.template.replace(/{{id}}/g, row.id)
+ .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY"))
+ .replace(/{{title}}/, row.title)
+ .replace(/{{subtitle}}/, row.subtitle)
+ .replace(/{{link}}/, row.link)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
+ var $t = $(t)
+ if (row.store != "true") {
+ $t.find(".store").remove()
+ }
+ this.$content.append($t)
+
+ if (row.image.length > 1) {
+ // image gallery
+ var $gallery = $(".gallery-" + row.id)
+ row.image.forEach(function(img){
+ var el = document.createElement("div")
+ el.style.backgroundImage = "url(" + img.uri + ")"
+ el.className = "item"
+ $gallery.append(el)
+ })
+ this.galleries[row.id] = new Flickity( ".gallery-" + row.id, {
+ selector: '.item',
+ cellAlign: 'center',
+ autoPlay: false,
+ freeScroll: false,
+ wrapAround: true,
+ imagesLoaded: true,
+ prevNextButtons: false,
+ pageDots: false,
+ contain: true,
+ draggable: true,
+ })
+ }
+ else {
+ // single image
+ var el = document.createElement("div")
+ el.style.backgroundImage = "url(" + row.image[0].uri + ")"
+ el.className = "item"
+ $(".gallery-" + row.id).append(el)
+ $(".gallery-" + row.id).data("row", row)
+
+ // video, append play button
+ if (row.link.match(/youtube|youtu.be|vimeo/)) {
+ var play = document.createElement("div")
+ play.className = "play"
+ $(".gallery-" + row.id).append(play)
+ }
+ $t.find(".gallery-left").remove()
+ $t.find(".gallery-right").remove()
+ }
+
+ }.bind(this))
+
+ this.deferScrollToTop()
+ },
+
+ store_link: function(){
+ app.router.go("store")
+ },
+ play_video: function(e){
+ var row = $(e.currentTarget).closest('.gallery-video-post').data("row")
+ window.open(row.link, '_system')
+ },
+
+ gallery_left: function(e){
+ var id = $(e.currentTarget).closest(".hub_item").data('id')
+ this.galleries[id].previous()
+ },
+ gallery_right: function(e){
+ var id = $(e.currentTarget).closest(".hub_item").data('id')
+ this.galleries[id].next()
+ },
+
+ share: function(){
+ window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js
new file mode 100755
index 00000000..4bf05430
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js
@@ -0,0 +1,24 @@
+var PageView = ScrollableView.extend({
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.page = opt.page
+ this.setElement("#" + opt.page)
+ this.$content = this.$(".content")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#' + this.page, app.iscroll_options)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ document.body.className = this.page
+ },
+
+ populate: function(data){
+ this.$content.html(data.body.replace(/\n/g, "<br>"))
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js
new file mode 100755
index 00000000..84684ff7
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js
@@ -0,0 +1,65 @@
+var StoryView = ScrollableView.extend({
+
+ loaded: false,
+
+ el: "#story",
+ template: $("#story .template").html(),
+
+ events: {
+ "click .links li": "pick",
+ },
+
+ initialize: function(){
+ this.sections = {}
+ this.$img = this.$("img")
+ this.$content = this.$(".content")
+ this.$links = this.$(".links")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#story', app.iscroll_options)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ document.body.className = "story"
+ },
+
+ populate: function(data){
+ if (this.loaded) { console.warn("populate called twice"); return }
+ this.loaded = true
+ this.data = data
+ this.$loader.hide()
+ this.$content.empty()
+ // id title image[uri caption] body
+ this.data.forEach(function(row){
+ var t = this.template.replace(/{{id}}/, row.id)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
+ var li = document.createElement("li")
+ li.dataset.id = row.id
+ li.innerHTML = row.title
+ this.sections[row.id] = row
+ this.$links.append(li)
+ this.$content.append(t)
+ }.bind(this))
+
+ this.set_active( this.data[0].id )
+ },
+
+ pick: function(e){
+ var id = e.currentTarget.dataset.id
+ this.set_active(id)
+ },
+
+ set_active: function(id){
+ this.$links.find(".active").removeClass("active")
+ this.$links.find("[data-id=" + id + "]").addClass("active")
+
+ this.$content.find(".active").removeClass("active")
+ this.$content.find("[data-id=" + id + "]").addClass("active")
+
+ var section = this.sections[id]
+ this.$img.attr("src", section.image.uri)
+ this.deferScrollToTop()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js
new file mode 100755
index 00000000..f6c7f1f5
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js
@@ -0,0 +1,174 @@
+var CartConfirm = FormView.extend({
+
+ el: "#cart_confirm",
+
+ template: $("#cart_confirm .template").html(),
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
+
+ this.$shipping_address = this.$(".shipping_address")
+ this.$shipping_method = this.$(".shipping_method")
+
+ this.$payment_name = this.$(".payment_name")
+ this.$payment_method = this.$(".payment_method")
+ this.$payment_address = this.$(".payment_address")
+
+ this.scroller = new IScroll('#cart_confirm', app.iscroll_options)
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "confirm"
+ app.footer.show("PLACE ORDER", "CANCEL")
+ window.location.hash = "#/cart/confirm"
+ this.deferScrollToTop()
+
+ app.curtain.show("loading")
+ promise(sdk.cart.get_status).then( this.populate.bind(this) )
+ },
+
+ populate: function(data){
+ console.log(data)
+
+ data = data.Cart
+
+ this.$rows.empty()
+
+ data.Items.forEach(function(item){
+ var $el = $("<div class='item'><img src='img/spinner.gif'></div>")
+ this.$rows.append($el)
+ var code_ten = item.Code10
+ var size_id = item.Size
+
+ var code = code_ten.substr(0, 8)
+ app.product.find(code, function(data, details){
+ var descriptions = app.product.get_descriptions( details )
+
+ var name_partz = descriptions['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( descriptions['MicroCategory'] )
+
+ var color_name, size_name
+
+ details.Item.ModelColors.some(function(color){
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ return true
+ }
+ return false
+ })
+
+ details.Item.ModelSizes.some(function(size){
+ if (size['SizeId'] == size_id) {
+ // console.log(size)
+ size_name = size['Default']['Text']
+ size_name = SIZE_LOOKUP[ size_name ] || size_name
+ if (! size_name && ! size['Default']['Labeled']) {
+ size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ }
+
+ return true
+ }
+ return false
+ })
+
+// size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily
+
+ var t = this.template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name || "DEFAULT")
+ .replace(/{{color}}/, color_name || "DEFAULT")
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.data("price", details.Item.Price.DiscountedPrice)
+ $el.html(t)
+ this.refreshScroller()
+ }.bind(this))
+ }.bind(this))
+
+ var subtotal = data.Totals.TotalWithoutPromotions
+ var shipping_cost = data.DeliveryMethod.Selected.Amount.Total
+ var tax = data.Totals.TotalSalesTax
+ var total = data.Totals.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+
+ var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ")
+ var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", "
+ address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode
+
+ this.$shipping_address.html(address)
+ this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING")
+
+ var cc = data.Payment.CreditCard
+ var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ")
+ var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type
+
+ this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() )
+ this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 )
+
+ app.curtain.hide("loading")
+ },
+
+ save: function(){
+ promise(sdk.cart.finalize, {}).then(function(){
+ app.router.go('cart/thanks')
+ }.bind(this)).error(function(data){
+ // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}}
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}'
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The cart cannot be empty.\"\n233"}}
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}}
+ // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}}
+ // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}}
+ switch (data.StatusCode) {
+ case 403: // cart already closed
+ auth.clear_cart(auth.create_cart)
+ app.router.go('thanks')
+ break
+ case 409: // finalization error
+ this.finalization_error(data)
+ break
+ case 440: // genericapierror (credit card error!)
+ case 441: // genericapierror (credit card empty)
+ app.router.go('cart/payment')
+ app.cart.payment.show_errors([["Number","There was a problem with your credit card."]])
+ break
+ }
+ }.bind(this))
+ },
+
+ finalization_error: function(data){
+ if (data['Error']['Description'].match(/receiver validation fails/)) {
+ app.router.go('cart/shipping')
+ app.cart.payment.show_errors([["Number","There was a problem with your credit card."]])
+ }
+ else if (data['Error']['Description'].match(/cart cannot be empty/)) {
+ app.router.go('cart/summary')
+ }
+ else if (data['Error']['Description'].match(/Item has been removed/)) {
+ app.router.go('cart/error')
+ app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.")
+ }
+ },
+
+ cancel: function(){
+ app.router.go('cart/payment')
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartError.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartError.js
new file mode 100755
index 00000000..f9a1963e
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartError.js
@@ -0,0 +1,28 @@
+var CartError = View.extend({
+
+ el: "#cart_error",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$error = this.$(".errrrrrrrrrrrrrrr")
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "error"
+ app.footer.show("&lt; BACK TO CART")
+ app.footer.hide()
+ },
+
+ show_error: function(msg){
+ this.$error.html(msg)
+ },
+
+ ok: function(){
+ app.router.go("cart/summary")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js
new file mode 100755
index 00000000..f3c54d55
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js
@@ -0,0 +1,185 @@
+var CartPayment = FormView.extend({
+
+ el: "#cart_payment",
+
+ address_template: $("#cart_payment .address_row_template").html(),
+ cc_template: $("#cart_payment .cc_template").html(),
+
+ action: sdk.cart.set_credit_card,
+
+ address_list_mode: false,
+ cc_list_mode: false,
+ data: {},
+
+ events: {
+ "change [name=SameAsShipping]": "toggle_shipping",
+ "click .address_dropdown": "toggle_address",
+ "click .cc_dropdown": "toggle_cc",
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.$same_as_shipping = this.$("[name=SameAsShipping]")
+ this.$billing_address_rapper = this.$(".billing_address_rapper")
+ this.$address_list = this.$(".address_list")
+ this.$address_form = this.$(".address")
+ this.$address_dropdown = this.$(".address_dropdown")
+ this.$cc_list = this.$(".cc_list")
+ this.$cc_form = this.$(".cc")
+ this.$cc_dropdown = this.$(".cc_dropdown")
+ this.$cc_confirm = this.$(".cc_confirm")
+
+ this.address = new AddressView ({ parent: this, checkPhone: false })
+ this.cc = new CreditCardView ({ parent: this })
+ this.scroller = new IScroll('#cart_payment', app.iscroll_options)
+ this.address.disabled = true
+ this.cc.disabled = true
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "payment"
+ app.footer.show("CONFIRM &gt;", "CANCEL")
+ window.location.hash = "#/cart/payment"
+
+ this.populate()
+ this.deferScrollToTop()
+ },
+
+ toggle_shipping: function(){
+ setTimeout(function(){
+ var state = this.$same_as_shipping.prop("checked")
+ this.$billing_address_rapper.toggle( ! state )
+ this.address.disabled = state
+ }.bind(this))
+ },
+
+ toggle_address: function(state){
+ if (! app.account.ccs.length) {
+ state = false
+ }
+ // this.$address_dropdown.toggle( !! app.account.ccs.length )
+
+ this.address_list_mode = typeof state == "boolean" ? state : ! this.list_mode
+ this.address.disabled = this.address_list_mode
+ this.$address_form.toggle(! this.address_list_mode)
+ this.$address_list.toggle(this.address_list_mode)
+ },
+
+ toggle_cc: function(state){
+ if (! app.account.ccs.length) {
+ state = false
+ }
+ // this.$cc_dropdown.toggle( !! app.account.ccs.length )
+
+ this.cc_list_mode = typeof state == "boolean" ? state : ! this.cc_list_mode
+ this.cc.disabled = this.cc_list_mode
+ this.$cc_form.toggle(! this.cc_list_mode)
+ this.$cc_list.toggle(this.cc_list_mode)
+ this.$cc_confirm.toggle(this.cc_list_mode)
+ },
+
+ populate: function(){
+ this.$(".save_as_default").show()
+ this.$address_list.empty()
+ this.$cc_list.empty()
+ this.toggle_address( !! app.account.ccs.length )
+ this.toggle_cc( !! app.account.ccs.length )
+
+ app.account.ccs.forEach(function(cc){
+ var address_t = this.address_template.replace(/{{id}}/g, cc.Id)
+ .replace(/{{checked}}/g, cc.IsDefault ? "checked" : "")
+ .replace(/{{name}}/g, (cc.Name + " " + cc.Surname).toUpperCase())
+ .replace(/{{address}}/g, cc.Address.replace(/\n$/,"").replace("\n", ", "))
+ .replace(/{{city}}/g, cc.City)
+ .replace(/{{state}}/g, cc.Province)
+ .replace(/{{zip}}/g, cc.ZipCode)
+
+ var cc_t = this.cc_template.replace(/{{id}}/g, cc.Id)
+ .replace(/{{checked}}/g, cc.IsDefault ? "checked" : "")
+ .replace(/{{number}}/g, cc['Number'])
+ .replace(/{{type}}/g, cc.Type.toUpperCase())
+ .replace(/{{exp}}/g, cc.ExpirationMonth + "/" + cc.ExpirationYear)
+
+ this.$address_list.append(address_t)
+ this.$cc_list.append(cc_t)
+ }.bind(this))
+ },
+
+ finalize: function(data){
+ var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id
+ var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val()
+
+ if (this.$same_as_shipping.prop("checked")) {
+ address_data = app.cart.shipping.data
+ }
+ else if (this.address_list_mode) {
+ address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val()
+ address_data = app.account.addressLookup[ address_id ]
+ }
+ else {
+ address_data = data
+ }
+
+ if (this.cc_list_mode) {
+ cc_id = this.$("[name=CCId]").filter(function(){ return $(this).prop("checked") }).val()
+ cc_data = app.account.ccLookup[ cc_id ]
+
+ var card_on_file = {
+ "guid": cc_data.Guid,
+ "cvv": this.$("[name=CvvConfirm]"),
+ }
+
+ app.curtain.show("loading")
+ promise(sdk.cart.use_stored_credit_card, { data: card_on_file }).then(function(data){
+ app.curtain.hide("loading")
+ this.success()
+ }.bind(this)).error(function(data){
+ app.curtain.hide("loading")
+ console.log(data)
+ }.bind(this))
+
+ return
+ }
+ else {
+ cc_data = data
+ }
+
+ var credit_info = {
+ "HolderName": address_data.Name,
+ "HolderSurname": address_data.Surname,
+ "HolderAddress": address_data.Address || address_data.StreetWithNumber,
+ "HolderCity": address_data.City,
+ "HolderProvince": address_data.Province,
+ "HolderZip": address_data.PostalCode || address_data.ZipCode,
+ "HolderISOCountry": CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US",
+ "HolderEmail": auth.user.Email,
+ "CardNumber": cc_data['Number'],
+ "Type": cc_data.Type,
+ "ExpirationMonth": cc_data.ExpirationMonth,
+ "ExpirationYear": cc_data.ExpirationYear.substr(2,3),
+ "Cvv": cc_data.Cvv,
+ }
+
+ console.log( credit_info )
+
+ return credit_info
+ },
+
+ success: function(){
+ app.router.go('cart/confirm')
+ },
+
+ error: function(data){
+ console.log(data)
+ app.cart.payment.show_errors([["Number","There was a problem with your credit card."]])
+ },
+
+ cancel: function(){
+ app.router.go('cart/shipping')
+ },
+
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js
new file mode 100755
index 00000000..f17d42d2
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js
@@ -0,0 +1,136 @@
+var CartShipping = FormView.extend({
+
+ el: "#cart_shipping",
+
+ action: sdk.cart.set_shipping_address,
+
+ list_mode: true,
+ data: {},
+
+ template: $("#cart_shipping .template").html(),
+
+ events: {
+ "click .dropdown-wrapper": "toggle_dropdown",
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$form = this.$("form")
+ this.$dropdown_wrapper = this.$(".dropdown-wrapper")
+ this.$address_list = this.$(".address_list")
+ this.$address_form = this.$(".address")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.scroller = new IScroll('#cart_shipping', app.iscroll_options)
+ this.address.disabled = true
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "shipping"
+ app.footer.show("PAYMENT &gt;", "CANCEL")
+ window.location.hash = "#/cart/shipping"
+ this.populate()
+ this.deferScrollToTop()
+ },
+
+ populate: function(){
+ // id checked name address city state zip
+ this.$(".save_as_default").show()
+ this.$address_list.empty()
+ if (! app.account.addresses.length) {
+ this.toggle_dropdown(false)
+ return
+ }
+ app.account.addresses.forEach(function(address){
+ var t = this.template.replace(/{{id}}/g, address.Id)
+ .replace(/{{checked}}/g, address.IsDefault ? "checked" : "")
+ .replace(/{{name}}/g, (address.Name + " " + address.Surname).toUpperCase())
+ .replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", ", "))
+ .replace(/{{city}}/g, address.City)
+ .replace(/{{state}}/g, address.Province)
+ .replace(/{{zip}}/g, address.ZipCode)
+ this.$address_list.append(t)
+ }.bind(this))
+ },
+
+ load_form: function(cart_data){
+ var data = cart_data.Cart.Receiver
+ var addy = data.StreetWithNumber.split("\n")
+ data.Address1 = addy[0] || ""
+ data.Address2 = addy[1] || ""
+ data.ZipCode = data.PostalCode
+ data.Province = data.Region
+ this.load_data(data)
+
+ this.data = data
+ if (cart_data.Cart.DeliveryMethod && cart_data.Cart.DeliveryMethod.Selected && cart_data.Cart.DeliveryMethod.Type) {
+ $("#standard-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 1)
+ $("#express-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 2)
+ }
+ },
+
+ toggle_dropdown: function(state){
+ if (! app.account.addresses.length) {
+ state = false
+ }
+ this.list_mode = typeof state == "boolean" ? state : ! this.list_mode
+ this.$dropdown_wrapper.toggle( !! app.account.addresses.length )
+ this.address.disabled = this.list_mode
+ this.$address_form.toggle(! this.list_mode)
+ this.$address_list.toggle(this.list_mode)
+ },
+
+ // sdk.cart.set_shipping_address
+ // sdk.shipping.get_delivery_types
+ // sdk.shipping.set_delivery_type
+
+ shipping_types: {
+ Standard: 1,
+ Express: 2,
+ },
+
+ finalize: function(data){
+ var shipping_info = {}, address_data, address_id
+ var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val()
+
+ sdk.shipping.set_delivery_type({
+ id: this.shipping_types[shipping_type],
+ success: function(data){ console.log("set shipping type", data) },
+ error: function(data){ console.log("didnt set shipping type", data) },
+ })
+
+ if (this.list_mode) {
+ address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val()
+ address_data = app.account.addressLookup[ address_id ]
+ }
+ else {
+ address_data = data
+ }
+
+ shipping_info.Name = address_data.Name
+ shipping_info.Surname = address_data.Surname
+ shipping_info.Email = auth.user.Email
+ shipping_info.Phone = address_data.Phone
+ shipping_info.Mobile = address_data.Phone
+ shipping_info.StreetWithNumber = address_data.Address
+ shipping_info.PostalCode = address_data.ZipCode
+ shipping_info.City = address_data.City
+ shipping_info.Province = address_data.Province
+ shipping_info.Region = address_data.Province
+ shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US"
+
+ this.data = shipping_info
+
+ return shipping_info
+ },
+
+ success: function(){
+ app.router.go('cart/payment')
+ },
+
+ cancel: function(){
+ app.router.go('cart/summary')
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartSummary.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartSummary.js
new file mode 100755
index 00000000..ff1e001f
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartSummary.js
@@ -0,0 +1,202 @@
+var CartSummary = ScrollableView.extend({
+
+ el: "#cart_summary",
+
+ template: $("#cart_summary .template").html(),
+
+ events: {
+ "click .remove": "remove_item",
+ },
+
+ data: null,
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$loader = this.$(".loader")
+ this.$cart_body = this.$(".cart_body")
+ this.$cart_empty = this.$(".cart_empty")
+ this.scroller = new IScroll('#cart_summary', app.iscroll_options)
+
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "summary"
+ window.location.hash = "#/cart/summary"
+ if (auth.has_cart()) {
+ this.load()
+ }
+ else {
+ this.empty()
+ }
+ },
+
+ load: function(){
+ this.el.className = "loading"
+ app.footer.show("SHIPPING &gt;", "CANCEL")
+ app.curtain.show("loading")
+ sdk.cart.get_status({
+ success: this.populate.bind(this),
+ error: this.empty.bind(this),
+ })
+ },
+
+ populate: function(data){
+ this.data = data
+
+ console.log("CART", data)
+
+ if (! data.Cart.Items || data.Cart.Items.length == 0) {
+ return this.empty()
+ }
+
+ this.parent.$steps.show()
+ this.updateCounts()
+
+ this.$rows.empty()
+
+ data.Cart.Items.forEach(function(item){
+ var code_ten = item['Code10']
+ var code = code_ten.substr(0, 8)
+ var size_id = item['Size']
+
+ var $el = $("<div>").addClass("cart_item_row")
+ $el.html("<img src='img/spinner.gif'>")
+ $el.data({
+ code: code_ten,
+ size: size_id,
+ })
+ this.$rows.append($el)
+ app.product.find(code, function(data, details){
+ // console.log(data, details)
+
+ var descriptions = app.product.get_descriptions( details )
+ // console.log(descriptions)
+
+ var name_partz = descriptions['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( descriptions['MicroCategory'] )
+
+ var color_name, size_name
+ // console.log(code)
+ details.Item.ModelColors.some(function(color){
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ // console.log(color)
+ return true
+ }
+ return false
+ })
+ details.Item.ModelSizes.some(function(size){
+ if (size['SizeId'] == size_id) {
+ // console.log(size)
+ size_name = size['Default']['Text']
+ size_name = SIZE_LOOKUP[ size_name ] || size_name
+ if (! size_name && ! size['Default']['Labeled']) {
+ size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ }
+
+ return true
+ }
+ return false
+ })
+
+ var t = this.template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name)
+ .replace(/{{color}}/, color_name)
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.html(t)
+ this.refreshScroller()
+ }.bind(this))
+ }.bind(this))
+
+ if (data.Cart.Receiver && data.Cart.Receiver.City) {
+ app.cart.shipping.load_form( data )
+ }
+
+ this.updateTotals()
+
+ this.el.className = "full"
+ this.refreshScroller()
+ app.curtain.hide("loading")
+ },
+
+ updateCounts: function(){
+ app.header.set_cart_count( this.data.Cart.Items.length )
+ this.parent.setHeaderCount( this.data.Cart.Items.length )
+ },
+
+ updateTotals: function(){
+ var subtotal = this.data.Cart.Totals.TotalWithoutPromotions
+ var shipping_cost = this.data.Cart.DeliveryMethod.Selected.Amount.Total
+ var tax = this.data.Cart.Totals.TotalSalesTax
+ var total = this.data.Cart.Totals.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+ },
+
+ empty: function(){
+ app.footer.hide()
+ app.header.set_cart_count(0)
+ this.parent.setHeaderCount( 0 )
+ this.parent.$itemcount.html("0 ITEMS")
+ this.el.className = "empty"
+ this.parent.$steps.hide()
+ },
+
+ save: function(){
+ app.router.go('cart/shipping')
+ },
+
+ cancel: function(){
+ app.router.go('intro')
+ },
+
+ remove_item: function(e){
+ var $el = $( e.currentTarget ).closest(".cart_item_row")
+ var data = $el.data()
+
+ console.log(this.data.Cart)
+
+ this.data.Cart.Totals.TotalWithoutPromotions -= data.price
+ this.data.Cart.Totals.TotalToPay -= data.price
+ this.data.Cart.Items = this.data.Cart.Items.filter(function(item){
+ return ( item['Code10'] !== data.code || item['Size'] !== data.size)
+ })
+
+ this.updateTotals()
+ this.updateCounts()
+ $el.remove()
+ this.refreshScroller()
+
+ if (this.data.Cart.Items.length == 0) {
+ this.empty()
+ }
+
+ app.curtain.show("loading")
+ sdk.cart.delete_item({
+ data: {
+ Code10: data.code,
+ Size: data.size,
+ },
+ success: function(){
+ app.curtain.hide("loading")
+ },
+ })
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartThanks.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartThanks.js
new file mode 100755
index 00000000..eb95197b
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartThanks.js
@@ -0,0 +1,25 @@
+var CartThanks = View.extend({
+
+ el: "#cart_thanks",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "thanks"
+ app.footer.show("&lt; BACK TO COLLECTION")
+ app.footer.hide()
+
+ app.orders.loaded = false
+ },
+
+ ok: function(){
+ app.router.go("store")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartView.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartView.js
new file mode 100755
index 00000000..1b08e418
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartView.js
@@ -0,0 +1,66 @@
+var CartView = View.extend({
+
+ el: "#cart",
+
+ events: {
+ "click .summary_step": "show_summary",
+ "click .shipping_step": "show_shipping",
+ "click .payment_step": "show_payment",
+ },
+
+ initialize: function(){
+ this.summary = new CartSummary ({ parent: this })
+ this.payment = new CartPayment ({ parent: this })
+ this.shipping = new CartShipping ({ parent: this })
+ this.confirm = new CartConfirm ({ parent: this })
+ this.thanks = new CartThanks ({ parent: this })
+ this.error = new CartError ({ parent: this })
+
+ this.$steps = this.$(".steps")
+ this.$full_msg = this.$(".full_msg")
+ this.$empty_msg = this.$(".empty_msg")
+ this.$itemcount = this.$(".itemcount")
+ },
+
+ load: function(){
+ sdk.cart.get_status({
+ success: function(data){
+ this.summary.data = data
+ this.summary.updateCounts()
+ }.bind(this),
+ error: function(data){
+ console.log(data)
+ },
+ })
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ this.show_summary()
+ },
+
+ show_summary: function(){
+ this.summary.show()
+ },
+
+ show_shipping: function(){
+ this.shipping.show()
+ },
+
+ show_payment: function(){
+ this.payment.show()
+ },
+
+ setHeaderCount: function(n){
+ if (n) {
+ this.$itemcount.html(pluralize(n, "ITEM", "S"))
+ this.$full_msg.show()
+ this.$empty_msg.hide()
+ }
+ else {
+ this.$full_msg.hide()
+ this.$empty_msg.show()
+ }
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/deeplink.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/deeplink.js
new file mode 100755
index 00000000..648dd167
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/deeplink.js
@@ -0,0 +1,3 @@
+function handleOpenURL (url) {
+ app.router.initial_route = url
+} \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/geo.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/geo.js
new file mode 100755
index 00000000..fac34c1e
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/geo.js
@@ -0,0 +1,39 @@
+var geo = (function(){
+ var geo = {}
+
+ geo.fetch = function(){
+ navigator.geolocation.getCurrentPosition(geo.success, geo.error, {timeout: 15000})
+ }
+
+ geo.success = function(position){
+ var lat_str = as_degrees( position.coords.latitude || 40.99167 )
+ var lng_str = as_degrees( position.coords.longitude || -74.07944 )
+ $(".latlng").html( lat_str + " " + lng_str )
+ }
+
+ geo.error = function(error){
+ $(".latlng").html( "+40&deg; 58' 90\" -74&deg; 04' 46\"" )
+ }
+
+ function as_degrees (n) {
+ var s = ""
+ if (n >= 0) s += "+"
+ s += Math.floor(n) + "&deg; "
+
+ n = Math.abs(n)
+ n %= 1
+ n *= 60
+ nn = Math.floor(n)
+ if (nn < 10) nn = "0" + nn
+ s += nn + "' "
+
+ n %= 1
+ n *= 60
+ nn = Math.floor(n)
+ if (nn < 10) nn = "0" + nn
+ s += nn + '"'
+ return s
+ }
+
+ return geo
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
new file mode 100755
index 00000000..ab0c0141
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
@@ -0,0 +1 @@
+// \ No newline at end of file
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
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js
new file mode 100755
index 00000000..5f8c1e84
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js
@@ -0,0 +1,56 @@
+var ClosedStoreView = View.extend({
+
+ el: "#closed",
+
+ storeIsClosed: false,
+
+ events: {
+ "click .website_link": "website_link",
+ },
+
+ delay: 8000,
+
+ timeout: -1,
+ images: null,
+
+ initialize: function(){
+ this.loader = new Loader ()
+ },
+
+ show: function(){
+ document.body.className = "closed"
+ this.animate()
+ app.footer.hide()
+ console.log(this)
+ if (this.storeOpenDate) {
+ var date = moment(this.storeOpenDate).format("MM/DD")
+ console.log(date)
+ $(".closed_store_msg h3").html("THIS STORE WILL OPEN ON " + date)
+ }
+ else {
+ $(".closed_store_msg h3").html("THIS STORE IS CURRENTLY CLOSED")
+ }
+ },
+
+ hide: function(){
+ clearTimeout(this.timeout)
+ },
+
+ animate: function(){
+ this.timeout = setTimeout(this.animate.bind(this), this.delay)
+ if (! this.images) return
+ var url = choice(this.images)
+ this.loader.preloadImage(url, function(img){
+ this.el.style.backgroundImage = 'url(' + img.src + ')'
+ }.bind(this))
+ },
+
+ populate: function(data){
+ this.images = data.map(function(img){ return img.uri })
+ },
+
+ website_link: function(){
+ window.open("http://www.stoneisland.com/", '_system')
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js
new file mode 100755
index 00000000..d4315514
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js
@@ -0,0 +1,114 @@
+
+var CollectionView = ScrollableView.extend({
+
+ el: "#collection",
+ template: $("#collection .template").html(),
+ loaded: false,
+ data: null,
+ items: {},
+
+ events: {
+ "touchstart .item": "touchstart",
+ "touchmove .item": "touchmove",
+ "touchend .item": "touchend",
+ "mousedown .item": "touchstart",
+ "mousemove .item": "touchmove",
+ "mouseup .item": "touchend",
+ },
+
+ initialize: function(){
+ this.$title = this.$("h1")
+ this.$content = this.$(".content")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#collection', app.iscroll_options)
+ this.filterView = new CategoryFilter ({ parent: this })
+ },
+
+ show: function(){
+ if (app.closed.storeIsClosed) {
+ // (! this.storeOpenDate || moment().diff(this.storeOpenDate) > 0 ) ) {
+ return app.closed.show()
+ }
+ app.footer.show("FILTER")
+ document.body.className = "collection"
+ if (this.loaded) {
+ return this.populate(this.data)
+ }
+ // this.fetch()
+ },
+
+ save: function(){
+ this.filterView.filter()
+ },
+
+ fetch: function(){
+ if (this.loaded) return
+ this.$loader.show()
+ sdk.product.collection({
+ gallery_id: app.gallery_id,
+ success: this.populate.bind(this)
+ })
+ },
+
+ populate: function(data){
+ if (this.loaded && ! data) {
+ data = this.data
+ }
+ else {
+ this.data = data
+ }
+ if (! this.loaded) {
+ this.loaded = true
+ this.$loader.hide()
+ this.$content.empty()
+ // DefaultCode10
+ data.SearchResponseFull.Results.Items.forEach(this.append.bind(this))
+ this.deferScrollToTop()
+ }
+ this.afterFetchCallback && this.afterFetchCallback()
+ app.collection.deferRefresh()
+ },
+
+ append: function(item){
+ this.items[ item['Code8'] ] = item
+ var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f'))
+ .replace(/{{code8}}/, item['Code8'])
+ this.$content.append(t)
+ },
+
+ pick: function(e){
+ var code = $(e.currentTarget).data("code")
+ var data = this.items[code]
+ app.product.load(code, data)
+ },
+
+ collectionName: "STONE ISLAND",
+ setCollectionName: function(name){
+ this.collectionName = name
+ this.$title.html(this.collectionName)
+ },
+
+ firstTouch: { x: 0, y: 0, id: "" },
+ lastTouch: { x: 0, y: 0, id: "" },
+ touchstart: function(e){
+ var p = e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent
+ this.firstTouch.x = this.lastTouch.x = p.pageX
+ this.firstTouch.y = this.lastTouch.y = p.pageY
+ this.firstTouch.id = e.currentTarget.dataset.id
+ },
+ touchmove: function(e){
+ var p = e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent
+ this.lastTouch.x = p.pageX
+ this.lastTouch.y = p.pageY
+ this.lastTouch.id = e.currentTarget.dataset.id
+ },
+ touchend: function(e){
+ var first = app.collection.firstTouch
+ var last = app.collection.lastTouch
+ var distance = Math.sqrt( Math.pow(first.x - last.x, 2) + Math.pow(first.y - last.y, 2) )
+ if (distance < 20) {
+ this.pick(e)
+ }
+ },
+
+})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/GalleryView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/GalleryView.js
new file mode 100755
index 00000000..02193f14
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/GalleryView.js
@@ -0,0 +1,65 @@
+var GalleryView = View.extend({
+
+ el: "#gallery",
+ template: $("#gallery .template").html(),
+
+ events: {
+// "click .left": "prev",
+// "click .right": "next",
+// "touchstart .gallery": "touchstart",
+// "touchmove .gallery": "touchmove",
+// "touchend .gallery": "touchend",
+ },
+
+ initialize: function(){
+ this.$(".template").remove()
+ },
+
+ reset: function(){
+ this.gallery && this.gallery.destroy()
+ this.$el.empty()
+ },
+
+ populate: function(code, image_ids){
+ var valid_styles = {}
+ image_ids.forEach(function(id){
+ if (id.indexOf("_") == -1) return
+ var partz = id.split("_")
+ var size = parseInt(partz[0]), style = partz[1]
+ if (size > 13) return;
+ if (! valid_styles[style] || valid_styles[style] < size) {
+ valid_styles[style] = size
+ }
+ })
+ Object.keys(valid_styles).sort(sort_image_styles).forEach(function(style){
+ var id = valid_styles[style] + "_" + style
+ var t = this.template.replace(/{{image}}/, sdk.image(code, id))
+ this.$el.append(t)
+ }.bind(this))
+
+ this.gallery = new Flickity( "#gallery", {
+ selector: '.item',
+ cellAlign: 'center',
+ autoPlay: false,
+ freeScroll: false,
+ wrapAround: true,
+ imagesLoaded: true,
+ prevNextButtons: false,
+ pageDots: false,
+ contain: true,
+ draggable: true,
+ })
+ },
+
+ touchstart: function(e){
+ },
+ touchmove: function(e){
+ },
+ touchend: function(e){
+ },
+
+})
+
+var YOOX_IMAGE_STYLE_ORDER = "ZZZ d f".split(" ")
+
+function sort_image_styles (b,a){ return (YOOX_IMAGE_STYLE_ORDER.indexOf(a)) - (YOOX_IMAGE_STYLE_ORDER.indexOf(b)) } \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
new file mode 100755
index 00000000..4789850a
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
@@ -0,0 +1,397 @@
+
+var ProductView = ScrollableView.extend({
+
+ el: "#product",
+
+ events: {
+ "click .fit": "scroll_to_bottom",
+ "click .size": "select_size",
+ "click .color": "select_color",
+ "click .share": "share",
+ "click .gallery-left": "gallery_left",
+ "click .gallery-right": "gallery_right",
+ },
+
+ initialize: function(){
+ this.gallery = new GalleryView ()
+ this.scroller = new IScroll('#product', app.iscroll_options)
+
+ this.$num = this.$(".num")
+ this.$title = this.$(".title")
+ this.$type = this.$(".type")
+ this.$price = this.$(".price")
+ this.$size = this.$(".size")
+ this.$color = this.$(".color")
+ this.$body = this.$(".body")
+ this.$fit = this.$(".fit")
+ this.$sizing = this.$(".sizing")
+ },
+
+ show: function(){
+ app.footer.show("ADD TO CART", "BUY NOW")
+ document.body.className = "product"
+ },
+ hide: function(){
+ },
+
+ item: null,
+ details: null,
+ size: null,
+ color: null,
+ code: null,
+ is_onesize: false,
+
+ sizes: null,
+ colors: null,
+
+ cache: {},
+
+ gallery_prev: function(){
+ app.product.gallery.gallery.previous()
+ },
+ gallery_right: function(){
+ app.product.gallery.gallery.next()
+ },
+
+ find: function(code, cb){
+ data = app.collection.items[code] || {}
+ if (code in this.cache) {
+ return cb(data, this.cache[code])
+ }
+ sdk.product.item({
+ code: code
+ }).done(function(details){
+ this.cache[code] = details
+ cb(data, details)
+ }.bind(this))
+ },
+
+ load: function(code, data){
+ this.gallery.reset()
+ this.show()
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ app.view = this
+ app.header.set_back(true)
+
+ if (! app.collection.loaded) {
+ this.el.className = "loading"
+ app.collection.afterFetchCallback = this.load.bind(this, code, data)
+ app.collection.fetch()
+ return
+ }
+ else {
+ app.collection.afterFetchCallback = null
+ }
+ window.location.href = "#/store/" + code
+
+ console.log(data)
+ if (data) {
+ app.collection.items[code] = data
+ }
+
+ this.el.className = "loading"
+ this.find(code, this.populate.bind(this))
+ },
+
+ populate: function(data, details){
+ this.el.className = ""
+
+ console.log(data, details)
+
+ var descriptions = this.get_descriptions(details)
+
+ this.gallery.populate( data['Code8'], details['Item']['ImageTypes'] )
+
+ var name_partz = data['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( data['MicroCategory'] )
+ var price = "$" + data['DiscountedPrice'] + ".00"
+ var body = descriptions['EditorialDescription'].replace(/<br>/g, "<br><br>")
+
+ var default_color_id = this.populate_selectors(data, details)
+
+ var color = this.colors[default_color_id]
+ var color_label = color.label
+ var sizes = this.find_sizes_for_color(default_color_id)
+ var size = sizes[0]
+ var size_label = this.sizes[size].label
+
+ this.is_onesize = !! this.sizes[1]
+
+ // console.log(color, color_label, size, size_label)
+
+ this.item = data
+ this.details = details['Item']
+ this.code = data['DefaultCode10']
+
+ this.color = color
+ this.size = size
+
+ this.$num.html(num)
+ this.$title.html(title)
+ this.$type.html(type)
+ this.$price.html(price)
+ this.$body.html(body)
+
+ this.$size.html(size_label)
+ if (color_label) {
+ this.$color.show().html(color_label)
+ }
+ else {
+ this.$color.hide()
+ }
+
+ this.deferScrollToTop()
+ },
+
+ get_descriptions: function (details){
+ var descriptions = {}
+ details['Item']['Descriptions'].forEach(function(pair){
+ descriptions[pair.Key] = pair.Value
+ })
+ return descriptions
+ },
+ find_sizes_for_color: function(color_id){
+ return Object.keys( this.colors[color_id].sizes ).sort(function(a,b){
+ var ao = SIZE_ORDER[ a.label ], bo = SIZE_ORDER[ b.label ]
+ return ao<bo?-1:ao==bo?0:1
+ })
+ },
+ find_colors_for_size: function(size_id){
+ return Object.keys( this.sizes[size_id].colors )
+ },
+
+ populate_selectors: function(data, details){
+ var sizes = {}, colors = {}, size_lookup = {}, default_color
+ details['Item']['ModelColors'].forEach(function(color, index){
+ if (! default_color || color['Code10'] == data['DefaultCode10']) {
+ default_color = color['ColorId']
+ }
+ colors[ color['ColorId'] ] = {
+ id: color['Code10'],
+ code: color['Code10'],
+ label: color['ColorDescription'].toUpperCase(),
+ sizes: {},
+ }
+ })
+
+ details['Item']['ModelSizes'].forEach(function(size){
+ var label = SIZE_LOOKUP[ size['Default']['Text'] ]
+ if (! label && ! size['Default']['Labeled']) {
+ label = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ }
+ size_lookup[ label ] = size['SizeId']
+ console.log( label )
+ sizes[ size['SizeId'] ] = {
+ id: label,
+ label: label.toUpperCase(),
+ colors: {},
+ }
+ })
+ details['Item']['ModelColorSize'].forEach(function(cs){
+ colors[ cs['IdColor'] ].sizes[ cs['IdSize'] ] = true
+ sizes[ cs['IdSize'] ].colors[ cs['IdColor'] ] = true
+ })
+
+ this.sizes = sizes
+ this.colors = colors
+ return default_color
+ },
+
+ select_size: function(){
+ if (this.is_onesize) { return this.select_color() }
+ if (this.item['Sizes'].length == 0) { return }
+ var sizes = Object.keys(this.sizes).map(function(key){
+ return this.sizes[key]
+ }.bind(this))
+ app.selector.select(sizes, function(size){
+ this.size = size.value
+ this.$size.html(size.label)
+ }.bind(this))
+ },
+
+ select_color: function(){
+ if (this.item['Colors'].length == 0) { return }
+ var colors = Object.keys(this.colors).map(function(key){
+ return this.colors[key]
+ }.bind(this))
+ app.selector.select(colors, function(color){
+ this.code = color.code
+ this.$color.html(color.label)
+ }.bind(this))
+ },
+
+ // ADD TO CART
+ save: function(){
+ this.add_to_cart({ route: false })
+ },
+ // BUY NOW
+ cancel: function(){
+ this.add_to_cart({ route: true })
+ },
+
+ add_to_cart: function(opt){
+ auth.deferred_product = { Size: this.size, Code10: this.code }
+ if ( ! auth.logged_in() ) {
+ app.router.go("account/login")
+ app.last_view = app.cart
+ }
+ else if ( ! auth.has_cart() ) {
+ app.curtain.show("loading")
+ auth.create_cart(function(){
+ auth.add_deferred_product_to_cart(function(){
+ app.curtain.hide("loading")
+ app.router.go("cart")
+ })
+ })
+ }
+ else {
+ app.curtain.show("loading")
+ auth.add_deferred_product_to_cart(function(){
+ app.curtain.hide("loading")
+ if (opt.route) {
+ app.router.go("cart")
+ }
+ })
+ }
+ },
+
+ back: function(){
+ app.router.go('store')
+ },
+
+ scroll_to_bottom: function(){
+ },
+
+ share: function(){
+ window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/")
+ },
+
+})
+
+var SIZE_LOOKUP = {
+ "XS": "X-SMALL",
+ "S": "SMALL",
+ "M": "MEDIUM",
+ "L": "LARGE",
+ "XL": "X-LARGE",
+ "XXL": "XX-LARGE",
+ "3XL": "3X-LARGE",
+ "OneSize": "ONESIZE",
+}
+
+var SIZE_ORDER = "XS S M L XL XXL 3XL".split(" ")
+
+/*
+{
+ "Code8": "41504876",
+ "BrandName": "STONE ISLAND",
+ "DefaultCode10": "41504876MA",
+ "MicroCategory": "Jacket",
+ "MacroCategory": "COATS & JACKETS",
+ "FullPrice": 728,
+ "DiscountedPrice": 437,
+ "PriceListId": 155702498,
+ "ModelNames": "41764 FLOWING CAMO WATRO",
+ "Sizes": [
+ {
+ "Id": 4,
+ "Text": "S",
+ "ClassFamily": "INT",
+ "Labeled": true
+ },
+ {
+ "Id": 6,
+ "Text": "L",
+ "ClassFamily": "INT",
+ "Labeled": true
+ },
+ {
+ "Id": 7,
+ "Text": "XL",
+ "ClassFamily": "INT",
+ "Labeled": true
+ },
+ {
+ "Id": 8,
+ "Text": "XXL",
+ "ClassFamily": "INT",
+ "Labeled": true
+ }
+ ],
+ "Colors": [
+ {
+ "Id": 3152,
+ "Code10": {
+ "Id": 6769575,
+ "Value": "41504876MA"
+ },
+ "Description": "Green",
+ "MacroColorId": 3152,
+ "Rgb": "3C941F"
+ }
+ ],
+ "SizeTypeId": 928,
+ "HasFlipSide": false,
+ "SeasonOfSale": "PE15",
+ "SalesLineId": "126",
+ "SalesLine": "18_STONE ISLAND",
+ "MarketId": 19,
+ "Criteria": {
+ "Sizes": [
+ "3",
+ "5",
+ "6",
+ "7"
+ ],
+ "Looks": [],
+ "Styles": [],
+ "WashTypes": [],
+ "WashStories": [],
+ "WashCodes": [],
+ "Waists": [],
+ "Fabrics": [],
+ "ColorTypes": [],
+ "ModelNames": [],
+ "Material": []
+ },
+ "NoveltyPoints": 0,
+ "C10Attributes": [
+ {
+ "Key": "MFC",
+ "Value": "621541764CC-6215-64V0050",
+ "C10": "41504876MA"
+ }
+ ],
+ "MacroCategoryId": 224,
+ "MicroCategoryId": 1319
+},
+
+DESCRIPTIONS:
+
+Age: "Adult"
+Appliqué: "Logo detail"
+ColoreFoto_ID: "3140"
+Composition: "100% Cotton"
+CustomsInvoiceDescr: "Woven"
+Design: "Solid color"
+EditorialDescription: "20081 DATA DRIP PIN<br>Short sleeve T-Shirt in cotton jersey. Garment dyed.<br>Stone Island Compass logo print on the front, made up of a series of numbers."
+ItemDescription: "Logo detail<br>Jersey<br>Round collar<br>Solid color<br>"
+KeywordDescription: "Logo detail Jersey Round collar Solid color Jersey Woven not made of fur "
+Kind of fabric: "Woven"
+MFC: "631520081CC-6315-81V0060"
+MacroCategory: "POLO SHIRTS & T-SHIRTS"
+MadeIn: "Made In Turkmenistan"
+MadeInIsoCode: "TN"
+MainMaterial: "Cotton"
+Material Description: "Jersey"
+MicroCategory: "Short sleeve t-shirt"
+MicroCategoryPlural: "Short sleeve t-shirts"
+ModelFabric: "631520081CC-6315-81"
+ModelNames: "20081 DATA DRIP PIN"
+Neckline: "Claudine or round collar"
+
+*/ \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/Selector.js b/StoneIsland/platforms/android/assets/www/js/lib/products/Selector.js
new file mode 100755
index 00000000..76c498ec
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/Selector.js
@@ -0,0 +1,48 @@
+var Selector = View.extend({
+
+ el: "#selector",
+ template: $("#selector .template").html(),
+
+ events: {
+ "click .close": "hide",
+ "click .options div": "pick",
+ },
+
+ initialize: function(){
+ this.$options = this.$(".options")
+ },
+
+ lookup: null,
+ callback: null,
+ select: function(options, callback){
+ this.lookup = {}
+ this.callback = callback || function(item){ console.log(item) }
+ this.$options.empty()
+ options.forEach(function(opt){
+ this.lookup[String(opt.id)] = opt
+ var t = this.template.replace(/{{id}}/, opt.id)
+ .replace(/{{label}}/, opt.label)
+ this.$options.append(t)
+ }.bind(this))
+ this.$el.show()
+ app.curtain.show("white")
+ this.visible = true
+ },
+
+ hide: function(){
+ this.lookup = this.callback = null
+ this.$el.hide()
+ app.curtain.hide()
+ this.visible = false
+ },
+
+ pick: function(e){
+ var $option = $(e.currentTarget)
+ var id = String($option.data("id"))
+ var selection = this.lookup[id]
+
+ this.callback( selection )
+ this.hide()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/filters/CategoryFilter.js b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/CategoryFilter.js
new file mode 100755
index 00000000..4e6baf62
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/CategoryFilter.js
@@ -0,0 +1,40 @@
+var CategoryFilter = View.extend({
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ filter: function(){
+ var cats = this.parent.data.SearchResponseFull.Refinements.Filters.Categories.map(function(cat){
+ return {
+ id: cat.Id,
+ label: cat.Value
+ }
+ })
+ if (this.last_choice) {
+ cats.push({
+ id: "__remove_filter",
+ label: "REMOVE FILTER",
+ })
+ }
+ app.selector.select(cats, this.pick.bind(this))
+ },
+
+ last_choice: null,
+
+ pick: function(choice){
+ this.parent.$content.empty()
+ if (choice.id == "__remove_filter") {
+ this.last_choice = null
+ this.parent.data.SearchResponseFull.Results.Items.forEach(this.parent.append.bind(this.parent))
+ }
+ else {
+ this.last_choice = choice
+ this.parent.data.SearchResponseFull.Results.Items.filter(function(item){
+ return item.MacroCategory == choice.label
+ }).forEach(this.parent.append.bind(this.parent))
+ }
+ this.parent.deferScrollToTop()
+ },
+
+})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js
new file mode 100755
index 00000000..a8ec331f
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js
@@ -0,0 +1,75 @@
+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/android/assets/www/js/lib/view/Scrollable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
new file mode 100755
index 00000000..d06ed590
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
@@ -0,0 +1,27 @@
+var ScrollableView = View.extend({
+
+ events: {
+ "load img": "deferRefresh",
+ },
+
+ deferScrollToTop: function(){
+ setTimeout(this.scrollToTop.bind(this), 0)
+ },
+
+ refreshScroller: function(){
+ this.scroller.refresh()
+ clearTimeout( this.scrollerRefreshTimeout )
+ },
+
+ scrollerRefreshTimeout: null,
+ deferRefresh: function(){
+ clearTimeout( this.scrollerRefreshTimeout )
+ this.scrollerRefreshTimeout = setTimeout(this.refreshScroller.bind(this))
+ },
+
+ scrollToTop: function(){
+ this.scroller.refresh()
+ app.collection.scroller.scrollTo(0, 0)
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
new file mode 100755
index 00000000..98aa8ce3
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
@@ -0,0 +1,164 @@
+var SerializableView = View.extend({
+
+ events: {
+ "change select": "update_select",
+ "change [type=date]": "update_date",
+ "focus input": "focus_input",
+ "click .date-wrapper": "focus_date",
+ "submit form": "save",
+ },
+
+ preload: function(data){
+ if (! data && sdk.env == "production") { return }
+ data = data || this.test_data
+ if (! data) { return }
+ this.load_data(data)
+ },
+
+ load_data: function(data){
+ Object.keys(data).forEach(function(key){
+ var value = data[key]
+ var $el = this.$("[name=" + key + "]")
+
+ if ($el.attr("type") == "checkbox") {
+ $el.prop("checked", value)
+ }
+ if ($el.attr("type") == "date") {
+ $el.val( value )
+ this.update_date({ currentTarget: $el })
+ }
+ 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")
+ },
+
+ focus_date: function(e){
+ $(e.currentTarget).find("input").focus()
+ },
+
+ update_select: function(e){
+ var $target = $(e.currentTarget), value = $target.val()
+ var label = $target.find("option").filter(function(){ return this.value === value }).html()
+ $target.parent().addClass("picked")
+ $target.parent().find("span").html(label)
+ },
+
+ update_date: function(e){
+ var $target = $(e.currentTarget), value = $target.val()
+ var label = moment(value).format("MM/DD/YYYY")
+ $target.parent().addClass("picked")
+ $target.parent().find("span").html(label)
+ },
+
+ validate: function(data, errors){
+ var data = data || this.serialize()
+ var errors = errors || []
+ var presence_msgs = this.validate_presence || {}
+ if (! this.disabled) {
+ 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(data, errors)
+ this.address && this.address.validate(data, errors)
+ return { errors: errors, data: data }
+ },
+
+ show_errors: function(errors){
+ console.log(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("")
+ },
+
+ finalize: function(data){
+ return data
+ },
+
+ save: function(e){
+ e && e.preventDefault()
+
+ var valid = this.validate()
+ if (valid.errors.length) {
+ this.show_errors(valid.errors)
+ return
+ }
+ else {
+ this.hide_errors()
+ }
+
+ var finalized_data = this.finalize(valid.data)
+ this.submit( finalized_data )
+ },
+
+ submit: function(data){
+ if (! data) {
+ return
+ }
+ app.curtain.show("loading")
+ this.action({
+ data: 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/android/assets/www/js/lib/view/View.js b/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
new file mode 100755
index 00000000..41638ab7
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
@@ -0,0 +1,147 @@
+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, _)
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js
new file mode 100755
index 00000000..b7880e50
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js
@@ -0,0 +1,38 @@
+var sdk = (function(){
+ var sdk = {}
+
+ sdk.env = "development"
+
+ var endpoint = "https://secure.api.yoox.biz/"
+ // var endpoint = "http://api.yoox.biz/"
+
+ sdk.init = function(opt){
+ switch (sdk.env = opt.env || "development") {
+ case 'test':
+ endpoint = "http://lvh.me:9090/"
+ break
+ default:
+ case 'development':
+ endpoint = "/"
+ break
+ case 'production':
+ endpoint = "https://secure.api.yoox.biz/"
+ break
+ }
+ }
+
+ sdk.path = function(api, path){
+ return endpoint + api + "/STONEISLAND_US/" + path
+ }
+
+ sdk.image = function(code, size){
+ return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code.substr(0,8) + "_" + size + ".jpg"
+ }
+
+ $.ajaxSetup({
+ // possibly: application/json; charset=utf-8"
+ contentType: "application/json",
+ })
+
+ return sdk
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/account.js b/StoneIsland/platforms/android/assets/www/js/sdk/account.js
new file mode 100755
index 00000000..3eb3f3bd
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/account.js
@@ -0,0 +1,133 @@
+sdk.account = (function(){
+
+ var user_id, access_token
+
+ // https://gist.github.com/fanfare/d18498e7fa25acbd4486
+ var account = {}
+ account.signup = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "users.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-api-key": auth.apikey,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ user_id = data['UserAccount']['UserId']
+ access_token = data['UserAccount']['AccessToken']
+
+ auth.set_user(user_id, access_token)
+
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.login = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "authfull.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ auth.user = data['UserFull']
+ user_id = data['UserFull']['idUser']
+ access_token = data['UserFull']['AccessToken']
+
+ auth.set_user(user_id, access_token)
+
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.checkin = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: "{}",
+ success: function(data){
+ auth.user = data.User
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update_mail_and_password = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "auth/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.fetch_orders = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/orders.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.fetch_single_order = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/orders/" + opt.id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return account
+
+})()
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/address.js b/StoneIsland/platforms/android/assets/www/js/sdk/address.js
new file mode 100755
index 00000000..4fb12ad0
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/address.js
@@ -0,0 +1,74 @@
+sdk.address = (function(){
+ var address = {}
+
+ address.list = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: opt.data,
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ address.add = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook/item.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ address.update = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook/item.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ address.destroy = function(opt){
+ return $.ajax({
+ method: "DELETE",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/" + opt.id + "/addressBook.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return address
+
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/auth.js b/StoneIsland/platforms/android/assets/www/js/sdk/auth.js
new file mode 100755
index 00000000..87ce60ea
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/auth.js
@@ -0,0 +1,129 @@
+/*
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ "x-yoox-device": auth.device,
+ "x-yoox-api-key": auth.apikey,
+ },
+*/
+
+var auth = sdk.auth = (function(){
+ var auth = {}
+
+ auth.appname = is_iphone ? "native-iphone-stoneisland/1.0.0" : "native-android-stoneisland/1.0.0"
+ auth.apikey = "U2FsdGVkX18fThqg9bF0/ZgE9Jg948hn8O9EXli4B2729nAESCQaexv//M5+7+za"
+ auth.device = "smartphone"
+
+ auth.access_token = ""
+ auth.user_id = -1
+
+ auth.next_view = null
+ auth.deferred_product = null
+
+ // ios: integrate keychain api
+ // android: cordova.file.externalRootDirectory api
+
+ auth.init = function(fn){
+ console.log("AUTH INIT")
+ auth.get_user(function(){
+ if (auth.logged_in()) {
+ sdk.account.checkin({
+ success: function(data){
+ fn && fn( auth.logged_in() )
+ }
+ })
+ auth.get_cart()
+ }
+ else {
+ fn && fn( auth.logged_in() )
+ }
+ })
+ }
+
+ auth.set_user = function(user_id, access_token, cb){
+ auth.access_token = access_token
+ auth.user_id = user_id
+
+ localStorage.setItem("yoox.access_token", access_token)
+ localStorage.setItem("yoox.user_id", user_id)
+ cb && cb()
+ }
+ auth.get_user = function(cb){
+ auth.access_token = localStorage.getItem("yoox.access_token") || ""
+ auth.user_id = localStorage.getItem("yoox.user_id") || -1
+ cb && cb()
+ }
+ auth.clear_user = function(cb){
+ auth.access_token = ""
+ auth.user_id = -1
+ localStorage.removeItem("yoox.access_token")
+ localStorage.removeItem("yoox.user_id")
+ cb && cb()
+ }
+
+ auth.set_cart = function(cart_id, cart_token, cb){
+ localStorage.setItem("yoox.cart_token", cart_token)
+ localStorage.setItem("yoox.cart_id", cart_id)
+ cb && cb()
+ }
+ auth.get_cart = function(cb){
+ sdk.cart.token = localStorage.getItem("yoox.cart_token") || ""
+ sdk.cart.id = localStorage.getItem("yoox.cart_id") || -1
+ cb && cb()
+ }
+ auth.clear_cart = function(cb){
+ sdk.cart.token = ""
+ sdk.cart.id = -1
+ localStorage.removeItem("yoox.cart_token")
+ localStorage.removeItem("yoox.cart_id")
+ cb && cb()
+ }
+ auth.create_cart = function(cb){
+ if (auth.has_cart()) { return cb() }
+ sdk.cart.initialize({
+ success: function(data){
+ sdk.cart.set_user({
+ success: function(){
+ auth.set_cart(sdk.cart.id, sdk.cart.token, function(){
+ cb && cb()
+ })
+ }
+ })
+ }
+ })
+ }
+ auth.add_deferred_product_to_cart = function(cb){
+ // auth.deferred_product
+ if (! auth.deferred_product) {
+ console.log("VV NO DEF PROD")
+ cb && cb()
+ return
+ }
+ sdk.cart.add_item({
+ data: auth.deferred_product,
+ success: function(){
+ console.log("ADDED ITEM")
+ cb && cb()
+ },
+ error: function(data){
+ console.log("ERROR ADDING ITEM", data)
+ cb && cb()
+ },
+ })
+ auth.deferred_product = null
+ app.header.increment_cart_count()
+ }
+
+ auth.log_out = function(){
+ auth.clear_user()
+ auth.clear_cart()
+ }
+ auth.logged_in = function(){
+ return (auth.user_id && auth.user_id !== -1 && auth.user_id !== "undefined")
+ }
+ auth.has_cart = function(){
+ return (sdk.cart.id && sdk.cart.id !== -1 && sdk.cart.id !== "undefined")
+ }
+
+ return auth
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/cart.js b/StoneIsland/platforms/android/assets/www/js/sdk/cart.js
new file mode 100755
index 00000000..3ff2e1d2
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/cart.js
@@ -0,0 +1,248 @@
+sdk.cart = (function(){
+ var cart = {}
+
+ cart.id = ""
+ cart.token = ""
+
+ // https://gist.github.com/fanfare/9a50c524aea417d0bf3e
+ cart.initialize = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Cart.API/1.6", "carts.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-device": auth.device,
+ },
+ data: "{}",
+ // data: opt.data,
+ success: function(data){
+ cart.id = data["CartSession"]["CartId"]
+ cart.token = data["CartSession"]["CartToken"]
+ auth.set_cart( cart.id, cart.token )
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.set_user = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/user.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify({
+ "UserId": auth.user_id,
+ "UserToken": auth.access_token,
+ }),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ // Code10, Size, Section
+ cart.add_item = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/items.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.delete_item = function(opt){
+ return $.ajax({
+ method: "DELETE",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id +
+ "/items/" + opt.data.Code10 +
+ "/" + opt.data.Size + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: "{}",
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.get_status = function(opt){
+ if (! cart.id) {
+ return opt.error({ error: "no cart" })
+ }
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ "x-yoox-device": auth.device,
+ },
+ success: function(data){
+ if (data['Error']) {
+ opt.error && opt.error(data)
+ }
+ else {
+ opt.success(data)
+ }
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.set_shipping_address = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/receiver.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify(opt.data),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ // NB: Payment type may simply be 1 (credit card)
+ cart.set_payment_type = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/paymentType.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.get_card_types = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "cardTypes.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: "",
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ // use with full CC data if not storing it in wallet
+ cart.set_credit_card = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/creditCard.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ // use with a stored GUID
+ // NB: if "verification number" is 1, use CVV/CID/CVC security code
+ // if "verification number" is 2, use "Issue Number"
+ cart.use_stored_credit_card = function(opt){
+ var data = {
+ "Guid": opt.data.guid,
+ "UserId": auth.user_id,
+ "AccessToken": auth.access_token,
+ }
+ if (opt.data.cvv) {
+ data["Cvv"] = opt.data.cvv
+ }
+ if (opt.data.issue) {
+ data["Issue"] = opt.data.issue
+ }
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/userCreditCard.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify(data),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.secure_finalize = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/secureFinalizer.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ "x-yoox-device": auth.device,
+ },
+ data: JSON.stringify( opt.data || {} ),
+ success: function(data){
+ console.log(data)
+ // order number is:
+ // "Info": "2905Y07FA13020"
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ cart.finalize = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/finalizer.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: JSON.stringify( opt.data || {} ),
+ success: function(data){
+ console.log(data)
+ // order number is:
+ // "Info": "2905Y07FA13020"
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return cart
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/payment.js b/StoneIsland/platforms/android/assets/www/js/sdk/payment.js
new file mode 100755
index 00000000..283fee92
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/payment.js
@@ -0,0 +1,72 @@
+sdk.payment = (function(){
+ var payment = {}
+
+ payment.add_credit_card = function(opt){
+ return $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ payment.list_credit_cards = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: opt.data,
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ payment.delete_credit_card = function(opt){
+ return $.ajax({
+ method: "DELETE",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards/" + opt.guid + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: "{}",
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ payment.get_payment_types = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "availablePaymentTypes.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-device": auth.device,
+ },
+ data: opt.data,
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return payment
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/product.js b/StoneIsland/platforms/android/assets/www/js/sdk/product.js
new file mode 100755
index 00000000..55f1940a
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/product.js
@@ -0,0 +1,37 @@
+sdk.product = (function(){
+ var product = {}
+
+ var default_gallery = 31617
+
+ product.collection = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Search.API/1.2", "search.json"),
+ data: { format: "full", gallery: opt.gallery_id || default_gallery, productsPerPage: 100 },
+ success: opt.success,
+ error: opt.error,
+ })
+ }
+
+ // https://gist.github.com/fanfare/2d25d1b36944188948ff
+ product.item = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Item.API/1.0", "item/" + opt.code + ".json"),
+ success: opt.success,
+ error: opt.error,
+ })
+ }
+
+ product.search = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Search.API/1.2", "search.json"),
+ data: { format: "full", gallery: opt.gallery_id || default_gallery, textSearch: opt.query, productsPerPage: 100 },
+ success: opt.success,
+ error: opt.error,
+ })
+ }
+
+ return product
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/shipping.js b/StoneIsland/platforms/android/assets/www/js/sdk/shipping.js
new file mode 100755
index 00000000..28a0db76
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/shipping.js
@@ -0,0 +1,85 @@
+sdk.shipping = (function() {
+ var shipping = {}
+
+
+ // https://gist.github.com/fanfare/edb524128461b573d833
+
+ // BOX TYPE
+
+ shipping.get_box_types = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/availableBoxTypes.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": sdk.cart.token,
+ },
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ shipping.set_box_type = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/boxType.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": sdk.cart.token,
+ },
+ data: JSON.stringify({
+ "Type": opt.type,
+ }),
+ success: function(data){
+ // console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+
+ // DELIVERY TYPES
+
+ // The response is different than described in the API reference..
+ // https://gist.github.com/fanfare/15dfbca6a16ae6bed503
+
+ shipping.get_delivery_types = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/availableDeliveryTypes.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": sdk.cart.token,
+ },
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ shipping.set_delivery_type = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/deliveryType.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": sdk.cart.token,
+ },
+ data: JSON.stringify({
+ "Id": opt.id,
+ }),
+ success: function(data){
+ //console.log(data)
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return shipping
+})()
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/fastclick.js b/StoneIsland/platforms/android/assets/www/js/vendor/fastclick.js
new file mode 100755
index 00000000..9c746c2b
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/fastclick.js
@@ -0,0 +1,790 @@
+/**
+ * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
+ *
+ * @version 1.0.1
+ * @codingstandard ftlabs-jsv2
+ * @copyright The Financial Times Limited [All Rights Reserved]
+ * @license MIT License (see LICENSE.txt)
+ */
+
+/*jslint browser:true, node:true*/
+/*global define, Event, Node*/
+
+
+/**
+ * Instantiate fast-clicking listeners on the specified layer.
+ *
+ * @constructor
+ * @param {Element} layer The layer to listen on
+ * @param {Object} options The options to override the defaults
+ */
+function FastClick(layer, options) {
+ 'use strict';
+ var oldOnClick;
+
+ options = options || {};
+
+ /**
+ * Whether a click is currently being tracked.
+ *
+ * @type boolean
+ */
+ this.trackingClick = false;
+
+
+ /**
+ * Timestamp for when click tracking started.
+ *
+ * @type number
+ */
+ this.trackingClickStart = 0;
+
+
+ /**
+ * The element being tracked for a click.
+ *
+ * @type EventTarget
+ */
+ this.targetElement = null;
+
+
+ /**
+ * X-coordinate of touch start event.
+ *
+ * @type number
+ */
+ this.touchStartX = 0;
+
+
+ /**
+ * Y-coordinate of touch start event.
+ *
+ * @type number
+ */
+ this.touchStartY = 0;
+
+
+ /**
+ * ID of the last touch, retrieved from Touch.identifier.
+ *
+ * @type number
+ */
+ this.lastTouchIdentifier = 0;
+
+
+ /**
+ * Touchmove boundary, beyond which a click will be cancelled.
+ *
+ * @type number
+ */
+ this.touchBoundary = options.touchBoundary || 10;
+
+
+ /**
+ * The FastClick layer.
+ *
+ * @type Element
+ */
+ this.layer = layer;
+
+ /**
+ * The minimum time between tap(touchstart and touchend) events
+ *
+ * @type number
+ */
+ this.tapDelay = options.tapDelay || 200;
+
+ if (FastClick.notNeeded(layer)) {
+ return;
+ }
+
+ // Some old versions of Android don't have Function.prototype.bind
+ function bind(method, context) {
+ return function() { return method.apply(context, arguments); };
+ }
+
+
+ var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
+ var context = this;
+ for (var i = 0, l = methods.length; i < l; i++) {
+ context[methods[i]] = bind(context[methods[i]], context);
+ }
+
+ // Set up event handlers as required
+ if (deviceIsAndroid) {
+ layer.addEventListener('mouseover', this.onMouse, true);
+ layer.addEventListener('mousedown', this.onMouse, true);
+ layer.addEventListener('mouseup', this.onMouse, true);
+ }
+
+ layer.addEventListener('click', this.onClick, true);
+ layer.addEventListener('touchstart', this.onTouchStart, false);
+ layer.addEventListener('touchmove', this.onTouchMove, false);
+ layer.addEventListener('touchend', this.onTouchEnd, false);
+ layer.addEventListener('touchcancel', this.onTouchCancel, false);
+
+ // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
+ // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
+ // layer when they are cancelled.
+ if (!Event.prototype.stopImmediatePropagation) {
+ layer.removeEventListener = function(type, callback, capture) {
+ var rmv = Node.prototype.removeEventListener;
+ if (type === 'click') {
+ rmv.call(layer, type, callback.hijacked || callback, capture);
+ } else {
+ rmv.call(layer, type, callback, capture);
+ }
+ };
+
+ layer.addEventListener = function(type, callback, capture) {
+ var adv = Node.prototype.addEventListener;
+ if (type === 'click') {
+ adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
+ if (!event.propagationStopped) {
+ callback(event);
+ }
+ }), capture);
+ } else {
+ adv.call(layer, type, callback, capture);
+ }
+ };
+ }
+
+ // If a handler is already declared in the element's onclick attribute, it will be fired before
+ // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
+ // adding it as listener.
+ if (typeof layer.onclick === 'function') {
+
+ // Android browser on at least 3.2 requires a new reference to the function in layer.onclick
+ // - the old one won't work if passed to addEventListener directly.
+ oldOnClick = layer.onclick;
+ layer.addEventListener('click', function(event) {
+ oldOnClick(event);
+ }, false);
+ layer.onclick = null;
+ }
+}
+
+
+/**
+ * Android requires exceptions.
+ *
+ * @type boolean
+ */
+var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0;
+
+
+/**
+ * iOS requires exceptions.
+ *
+ * @type boolean
+ */
+var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent);
+
+
+/**
+ * iOS 4 requires an exception for select elements.
+ *
+ * @type boolean
+ */
+var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
+
+
+/**
+ * iOS 6.0(+?) requires the target element to be manually derived
+ *
+ * @type boolean
+ */
+var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
+
+
+/**
+ * Determine whether a given element requires a native click.
+ *
+ * @param {EventTarget|Element} target Target DOM element
+ * @returns {boolean} Returns true if the element needs a native click
+ */
+FastClick.prototype.needsClick = function(target) {
+ 'use strict';
+ switch (target.nodeName.toLowerCase()) {
+
+ // Don't send a synthetic click to disabled inputs (issue #62)
+ case 'button':
+ case 'select':
+ case 'textarea':
+ if (target.disabled) {
+ return true;
+ }
+
+ break;
+ case 'input':
+
+ // File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
+ if ((deviceIsIOS && target.type === 'file') || target.disabled) {
+ return true;
+ }
+
+ break;
+ case 'label':
+ case 'video':
+ return true;
+ }
+
+ return (/\bneedsclick\b/).test(target.className);
+};
+
+
+/**
+ * Determine whether a given element requires a call to focus to simulate click into element.
+ *
+ * @param {EventTarget|Element} target Target DOM element
+ * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
+ */
+FastClick.prototype.needsFocus = function(target) {
+ 'use strict';
+ switch (target.nodeName.toLowerCase()) {
+ case 'textarea':
+ return true;
+ case 'select':
+ return !deviceIsAndroid;
+ case 'input':
+ switch (target.type) {
+ case 'button':
+ case 'checkbox':
+ case 'file':
+ case 'image':
+ case 'radio':
+ case 'submit':
+ return false;
+ }
+
+ // No point in attempting to focus disabled inputs
+ return !target.disabled && !target.readOnly;
+ default:
+ return (/\bneedsfocus\b/).test(target.className);
+ }
+};
+
+
+/**
+ * Send a click event to the specified element.
+ *
+ * @param {EventTarget|Element} targetElement
+ * @param {Event} event
+ */
+FastClick.prototype.sendClick = function(targetElement, event) {
+ 'use strict';
+ var clickEvent, touch;
+
+ // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
+ if (document.activeElement && document.activeElement !== targetElement) {
+ document.activeElement.blur();
+ }
+
+ touch = event.changedTouches[0];
+
+ // Synthesise a click event, with an extra attribute so it can be tracked
+ clickEvent = document.createEvent('MouseEvents');
+ clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
+ clickEvent.forwardedTouchEvent = true;
+ targetElement.dispatchEvent(clickEvent);
+};
+
+FastClick.prototype.determineEventType = function(targetElement) {
+ 'use strict';
+
+ //Issue #159: Android Chrome Select Box does not open with a synthetic click event
+ if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
+ return 'mousedown';
+ }
+
+ return 'click';
+};
+
+
+/**
+ * @param {EventTarget|Element} targetElement
+ */
+FastClick.prototype.focus = function(targetElement) {
+ 'use strict';
+ var length;
+
+ // Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
+ if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') {
+ length = targetElement.value.length;
+ targetElement.setSelectionRange(length, length);
+ } else {
+ targetElement.focus();
+ }
+};
+
+
+/**
+ * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
+ *
+ * @param {EventTarget|Element} targetElement
+ */
+FastClick.prototype.updateScrollParent = function(targetElement) {
+ 'use strict';
+ var scrollParent, parentElement;
+
+ scrollParent = targetElement.fastClickScrollParent;
+
+ // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
+ // target element was moved to another parent.
+ if (!scrollParent || !scrollParent.contains(targetElement)) {
+ parentElement = targetElement;
+ do {
+ if (parentElement.scrollHeight > parentElement.offsetHeight) {
+ scrollParent = parentElement;
+ targetElement.fastClickScrollParent = parentElement;
+ break;
+ }
+
+ parentElement = parentElement.parentElement;
+ } while (parentElement);
+ }
+
+ // Always update the scroll top tracker if possible.
+ if (scrollParent) {
+ scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
+ }
+};
+
+
+/**
+ * @param {EventTarget} targetElement
+ * @returns {Element|EventTarget}
+ */
+FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
+ 'use strict';
+
+ // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
+ if (eventTarget.nodeType === Node.TEXT_NODE) {
+ return eventTarget.parentNode;
+ }
+
+ return eventTarget;
+};
+
+
+/**
+ * On touch start, record the position and scroll offset.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.onTouchStart = function(event) {
+ 'use strict';
+ var targetElement, touch, selection;
+
+ // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
+ if (event.targetTouches.length > 1) {
+ return true;
+ }
+
+ targetElement = this.getTargetElementFromEventTarget(event.target);
+ touch = event.targetTouches[0];
+
+ if (deviceIsIOS) {
+
+ // Only trusted events will deselect text on iOS (issue #49)
+ selection = window.getSelection();
+ if (selection.rangeCount && !selection.isCollapsed) {
+ return true;
+ }
+
+ if (!deviceIsIOS4) {
+
+ // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
+ // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
+ // with the same identifier as the touch event that previously triggered the click that triggered the alert.
+ // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
+ // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
+ if (touch.identifier === this.lastTouchIdentifier) {
+ event.preventDefault();
+ return false;
+ }
+
+ this.lastTouchIdentifier = touch.identifier;
+
+ // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
+ // 1) the user does a fling scroll on the scrollable layer
+ // 2) the user stops the fling scroll with another tap
+ // then the event.target of the last 'touchend' event will be the element that was under the user's finger
+ // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
+ // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
+ this.updateScrollParent(targetElement);
+ }
+ }
+
+ this.trackingClick = true;
+ this.trackingClickStart = event.timeStamp;
+ this.targetElement = targetElement;
+
+ this.touchStartX = touch.pageX;
+ this.touchStartY = touch.pageY;
+
+ // Prevent phantom clicks on fast double-tap (issue #36)
+ if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
+ event.preventDefault();
+ }
+
+ return true;
+};
+
+
+/**
+ * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.touchHasMoved = function(event) {
+ 'use strict';
+ var touch = event.changedTouches[0], boundary = this.touchBoundary;
+
+ if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
+ return true;
+ }
+
+ return false;
+};
+
+
+/**
+ * Update the last position.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.onTouchMove = function(event) {
+ 'use strict';
+ if (!this.trackingClick) {
+ return true;
+ }
+
+ // If the touch has moved, cancel the click tracking
+ if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
+ this.trackingClick = false;
+ this.targetElement = null;
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempt to find the labelled control for the given label element.
+ *
+ * @param {EventTarget|HTMLLabelElement} labelElement
+ * @returns {Element|null}
+ */
+FastClick.prototype.findControl = function(labelElement) {
+ 'use strict';
+
+ // Fast path for newer browsers supporting the HTML5 control attribute
+ if (labelElement.control !== undefined) {
+ return labelElement.control;
+ }
+
+ // All browsers under test that support touch events also support the HTML5 htmlFor attribute
+ if (labelElement.htmlFor) {
+ return document.getElementById(labelElement.htmlFor);
+ }
+
+ // If no for attribute exists, attempt to retrieve the first labellable descendant element
+ // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
+ return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
+};
+
+
+/**
+ * On touch end, determine whether to send a click event at once.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.onTouchEnd = function(event) {
+ 'use strict';
+ var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
+
+ if (!this.trackingClick) {
+ return true;
+ }
+
+ // Prevent phantom clicks on fast double-tap (issue #36)
+ if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
+ this.cancelNextClick = true;
+ return true;
+ }
+
+ // Reset to prevent wrong click cancel on input (issue #156).
+ this.cancelNextClick = false;
+
+ this.lastClickTime = event.timeStamp;
+
+ trackingClickStart = this.trackingClickStart;
+ this.trackingClick = false;
+ this.trackingClickStart = 0;
+
+ // On some iOS devices, the targetElement supplied with the event is invalid if the layer
+ // is performing a transition or scroll, and has to be re-detected manually. Note that
+ // for this to function correctly, it must be called *after* the event target is checked!
+ // See issue #57; also filed as rdar://13048589 .
+ if (deviceIsIOSWithBadTarget) {
+ touch = event.changedTouches[0];
+
+ // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
+ targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
+ targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
+ }
+
+ targetTagName = targetElement.tagName.toLowerCase();
+ if (targetTagName === 'label') {
+ forElement = this.findControl(targetElement);
+ if (forElement) {
+ this.focus(targetElement);
+ if (deviceIsAndroid) {
+ return false;
+ }
+
+ targetElement = forElement;
+ }
+ } else if (this.needsFocus(targetElement)) {
+
+ // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
+ // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
+ if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
+ this.targetElement = null;
+ return false;
+ }
+
+ this.focus(targetElement);
+ this.sendClick(targetElement, event);
+
+ // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
+ // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
+ if (!deviceIsIOS || targetTagName !== 'select') {
+ this.targetElement = null;
+ event.preventDefault();
+ }
+
+ return false;
+ }
+
+ if (deviceIsIOS && !deviceIsIOS4) {
+
+ // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
+ // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
+ scrollParent = targetElement.fastClickScrollParent;
+ if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
+ return true;
+ }
+ }
+
+ // Prevent the actual click from going though - unless the target node is marked as requiring
+ // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
+ if (!this.needsClick(targetElement)) {
+ event.preventDefault();
+ this.sendClick(targetElement, event);
+ }
+
+ return false;
+};
+
+
+/**
+ * On touch cancel, stop tracking the click.
+ *
+ * @returns {void}
+ */
+FastClick.prototype.onTouchCancel = function() {
+ 'use strict';
+ this.trackingClick = false;
+ this.targetElement = null;
+};
+
+
+/**
+ * Determine mouse events which should be permitted.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.onMouse = function(event) {
+ 'use strict';
+
+ // If a target element was never set (because a touch event was never fired) allow the event
+ if (!this.targetElement) {
+ return true;
+ }
+
+ if (event.forwardedTouchEvent) {
+ return true;
+ }
+
+ // Programmatically generated events targeting a specific element should be permitted
+ if (!event.cancelable) {
+ return true;
+ }
+
+ // Derive and check the target element to see whether the mouse event needs to be permitted;
+ // unless explicitly enabled, prevent non-touch click events from triggering actions,
+ // to prevent ghost/doubleclicks.
+ if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
+
+ // Prevent any user-added listeners declared on FastClick element from being fired.
+ if (event.stopImmediatePropagation) {
+ event.stopImmediatePropagation();
+ } else {
+
+ // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
+ event.propagationStopped = true;
+ }
+
+ // Cancel the event
+ event.stopPropagation();
+ event.preventDefault();
+
+ return false;
+ }
+
+ // If the mouse event is permitted, return true for the action to go through.
+ return true;
+};
+
+
+/**
+ * On actual clicks, determine whether this is a touch-generated click, a click action occurring
+ * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
+ * an actual click which should be permitted.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+FastClick.prototype.onClick = function(event) {
+ 'use strict';
+ var permitted;
+
+ // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
+ if (this.trackingClick) {
+ this.targetElement = null;
+ this.trackingClick = false;
+ return true;
+ }
+
+ // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
+ if (event.target.type === 'submit' && event.detail === 0) {
+ return true;
+ }
+
+ permitted = this.onMouse(event);
+
+ // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
+ if (!permitted) {
+ this.targetElement = null;
+ }
+
+ // If clicks are permitted, return true for the action to go through.
+ return permitted;
+};
+
+
+/**
+ * Remove all FastClick's event listeners.
+ *
+ * @returns {void}
+ */
+FastClick.prototype.destroy = function() {
+ 'use strict';
+ var layer = this.layer;
+
+ if (deviceIsAndroid) {
+ layer.removeEventListener('mouseover', this.onMouse, true);
+ layer.removeEventListener('mousedown', this.onMouse, true);
+ layer.removeEventListener('mouseup', this.onMouse, true);
+ }
+
+ layer.removeEventListener('click', this.onClick, true);
+ layer.removeEventListener('touchstart', this.onTouchStart, false);
+ layer.removeEventListener('touchmove', this.onTouchMove, false);
+ layer.removeEventListener('touchend', this.onTouchEnd, false);
+ layer.removeEventListener('touchcancel', this.onTouchCancel, false);
+};
+
+
+/**
+ * Check whether FastClick is needed.
+ *
+ * @param {Element} layer The layer to listen on
+ */
+FastClick.notNeeded = function(layer) {
+ 'use strict';
+ var metaViewport;
+ var chromeVersion;
+
+ // Devices that don't support touch don't need FastClick
+ if (typeof window.ontouchstart === 'undefined') {
+ return true;
+ }
+
+ // Chrome version - zero for other browsers
+ chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
+
+ if (chromeVersion) {
+
+ if (deviceIsAndroid) {
+ metaViewport = document.querySelector('meta[name=viewport]');
+
+ if (metaViewport) {
+ // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
+ if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
+ return true;
+ }
+ // Chrome 32 and above with width=device-width or less don't need FastClick
+ if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
+ return true;
+ }
+ }
+
+ // Chrome desktop doesn't need FastClick (issue #15)
+ } else {
+ return true;
+ }
+ }
+
+ // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
+ if (layer.style.msTouchAction === 'none') {
+ return true;
+ }
+
+ return false;
+};
+
+
+/**
+ * Factory method for creating a FastClick object
+ *
+ * @param {Element} layer The layer to listen on
+ * @param {Object} options The options to override the defaults
+ */
+FastClick.attach = function(layer, options) {
+ 'use strict';
+ return new FastClick(layer, options);
+};
+
+
+if (typeof define !== 'undefined' && define.amd) {
+
+ // AMD. Register as an anonymous module.
+ define(function() {
+ 'use strict';
+ return FastClick;
+ });
+} else if (typeof module !== 'undefined' && module.exports) {
+ module.exports = FastClick.attach;
+ module.exports.FastClick = FastClick;
+} else {
+ window.FastClick = FastClick;
+}
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/flickity.pkgd.js b/StoneIsland/platforms/android/assets/www/js/vendor/flickity.pkgd.js
new file mode 100755
index 00000000..0471fa5b
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/flickity.pkgd.js
@@ -0,0 +1,5090 @@
+/*!
+ * Flickity PACKAGED v1.0.1
+ * Touch, responsive, flickable galleries
+ *
+ * Licensed GPLv3 for open source use
+ * or Flickity Commercial License for commercial use
+ *
+ * http://flickity.metafizzy.co
+ * Copyright 2015 Metafizzy
+ */
+
+/**
+ * Bridget makes jQuery widgets
+ * v1.1.0
+ * MIT license
+ */
+
+( function( window ) {
+
+
+
+// -------------------------- utils -------------------------- //
+
+var slice = Array.prototype.slice;
+
+function noop() {}
+
+// -------------------------- definition -------------------------- //
+
+function defineBridget( $ ) {
+
+// bail if no jQuery
+if ( !$ ) {
+ return;
+}
+
+// -------------------------- addOptionMethod -------------------------- //
+
+/**
+ * adds option method -> $().plugin('option', {...})
+ * @param {Function} PluginClass - constructor class
+ */
+function addOptionMethod( PluginClass ) {
+ // don't overwrite original option method
+ if ( PluginClass.prototype.option ) {
+ return;
+ }
+
+ // option setter
+ PluginClass.prototype.option = function( opts ) {
+ // bail out if not an object
+ if ( !$.isPlainObject( opts ) ){
+ return;
+ }
+ this.options = $.extend( true, this.options, opts );
+ };
+}
+
+// -------------------------- plugin bridge -------------------------- //
+
+// helper function for logging errors
+// $.error breaks jQuery chaining
+var logError = typeof console === 'undefined' ? noop :
+ function( message ) {
+ console.error( message );
+ };
+
+/**
+ * jQuery plugin bridge, access methods like $elem.plugin('method')
+ * @param {String} namespace - plugin name
+ * @param {Function} PluginClass - constructor class
+ */
+function bridge( namespace, PluginClass ) {
+ // add to jQuery fn namespace
+ $.fn[ namespace ] = function( options ) {
+ if ( typeof options === 'string' ) {
+ // call plugin method when first argument is a string
+ // get arguments for method
+ var args = slice.call( arguments, 1 );
+
+ for ( var i=0, len = this.length; i < len; i++ ) {
+ var elem = this[i];
+ var instance = $.data( elem, namespace );
+ if ( !instance ) {
+ logError( "cannot call methods on " + namespace + " prior to initialization; " +
+ "attempted to call '" + options + "'" );
+ continue;
+ }
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) {
+ logError( "no such method '" + options + "' for " + namespace + " instance" );
+ continue;
+ }
+
+ // trigger method with arguments
+ var returnValue = instance[ options ].apply( instance, args );
+
+ // break look and return first value if provided
+ if ( returnValue !== undefined ) {
+ return returnValue;
+ }
+ }
+ // return this if no return value
+ return this;
+ } else {
+ return this.each( function() {
+ var instance = $.data( this, namespace );
+ if ( instance ) {
+ // apply options & init
+ instance.option( options );
+ instance._init();
+ } else {
+ // initialize new instance
+ instance = new PluginClass( this, options );
+ $.data( this, namespace, instance );
+ }
+ });
+ }
+ };
+
+}
+
+// -------------------------- bridget -------------------------- //
+
+/**
+ * converts a Prototypical class into a proper jQuery plugin
+ * the class must have a ._init method
+ * @param {String} namespace - plugin name, used in $().pluginName
+ * @param {Function} PluginClass - constructor class
+ */
+$.bridget = function( namespace, PluginClass ) {
+ addOptionMethod( PluginClass );
+ bridge( namespace, PluginClass );
+};
+
+return $.bridget;
+
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget );
+} else if ( typeof exports === 'object' ) {
+ defineBridget( require('jquery') );
+} else {
+ // get jquery from browser global
+ defineBridget( window.jQuery );
+}
+
+})( window );
+
+/*!
+ * classie v1.0.1
+ * class helper functions
+ * from bonzo https://github.com/ded/bonzo
+ * MIT license
+ *
+ * classie.has( elem, 'my-class' ) -> true/false
+ * classie.add( elem, 'my-new-class' )
+ * classie.remove( elem, 'my-unwanted-class' )
+ * classie.toggle( elem, 'my-class' )
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( window ) {
+
+
+
+// class helper functions from bonzo https://github.com/ded/bonzo
+
+function classReg( className ) {
+ return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
+}
+
+// classList support for class management
+// altho to be fair, the api sucks because it won't accept multiple classes at once
+var hasClass, addClass, removeClass;
+
+if ( 'classList' in document.documentElement ) {
+ hasClass = function( elem, c ) {
+ return elem.classList.contains( c );
+ };
+ addClass = function( elem, c ) {
+ elem.classList.add( c );
+ };
+ removeClass = function( elem, c ) {
+ elem.classList.remove( c );
+ };
+}
+else {
+ hasClass = function( elem, c ) {
+ return classReg( c ).test( elem.className );
+ };
+ addClass = function( elem, c ) {
+ if ( !hasClass( elem, c ) ) {
+ elem.className = elem.className + ' ' + c;
+ }
+ };
+ removeClass = function( elem, c ) {
+ elem.className = elem.className.replace( classReg( c ), ' ' );
+ };
+}
+
+function toggleClass( elem, c ) {
+ var fn = hasClass( elem, c ) ? removeClass : addClass;
+ fn( elem, c );
+}
+
+var classie = {
+ // full names
+ hasClass: hasClass,
+ addClass: addClass,
+ removeClass: removeClass,
+ toggleClass: toggleClass,
+ // short names
+ has: hasClass,
+ add: addClass,
+ remove: removeClass,
+ toggle: toggleClass
+};
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'classie/classie',classie );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = classie;
+} else {
+ // browser global
+ window.classie = classie;
+}
+
+})( window );
+
+/*!
+ * EventEmitter v4.2.11 - git.io/ee
+ * Unlicense - http://unlicense.org/
+ * Oliver Caldwell - http://oli.me.uk/
+ * @preserve
+ */
+
+;(function () {
+
+
+ /**
+ * Class for managing events.
+ * Can be extended to provide event functionality in other classes.
+ *
+ * @class EventEmitter Manages event registering and emitting.
+ */
+ function EventEmitter() {}
+
+ // Shortcuts to improve speed and size
+ var proto = EventEmitter.prototype;
+ var exports = this;
+ var originalGlobalValue = exports.EventEmitter;
+
+ /**
+ * Finds the index of the listener for the event in its storage array.
+ *
+ * @param {Function[]} listeners Array of listeners to search through.
+ * @param {Function} listener Method to look for.
+ * @return {Number} Index of the specified listener, -1 if not found
+ * @api private
+ */
+ function indexOfListener(listeners, listener) {
+ var i = listeners.length;
+ while (i--) {
+ if (listeners[i].listener === listener) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Alias a method while keeping the context correct, to allow for overwriting of target method.
+ *
+ * @param {String} name The name of the target method.
+ * @return {Function} The aliased method
+ * @api private
+ */
+ function alias(name) {
+ return function aliasClosure() {
+ return this[name].apply(this, arguments);
+ };
+ }
+
+ /**
+ * Returns the listener array for the specified event.
+ * Will initialise the event object and listener arrays if required.
+ * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
+ * Each property in the object response is an array of listener functions.
+ *
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
+ * @return {Function[]|Object} All listener functions for the event.
+ */
+ proto.getListeners = function getListeners(evt) {
+ var events = this._getEvents();
+ var response;
+ var key;
+
+ // Return a concatenated array of all matching events if
+ // the selector is a regular expression.
+ if (evt instanceof RegExp) {
+ response = {};
+ for (key in events) {
+ if (events.hasOwnProperty(key) && evt.test(key)) {
+ response[key] = events[key];
+ }
+ }
+ }
+ else {
+ response = events[evt] || (events[evt] = []);
+ }
+
+ return response;
+ };
+
+ /**
+ * Takes a list of listener objects and flattens it into a list of listener functions.
+ *
+ * @param {Object[]} listeners Raw listener objects.
+ * @return {Function[]} Just the listener functions.
+ */
+ proto.flattenListeners = function flattenListeners(listeners) {
+ var flatListeners = [];
+ var i;
+
+ for (i = 0; i < listeners.length; i += 1) {
+ flatListeners.push(listeners[i].listener);
+ }
+
+ return flatListeners;
+ };
+
+ /**
+ * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
+ *
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
+ * @return {Object} All listener functions for an event in an object.
+ */
+ proto.getListenersAsObject = function getListenersAsObject(evt) {
+ var listeners = this.getListeners(evt);
+ var response;
+
+ if (listeners instanceof Array) {
+ response = {};
+ response[evt] = listeners;
+ }
+
+ return response || listeners;
+ };
+
+ /**
+ * Adds a listener function to the specified event.
+ * The listener will not be added if it is a duplicate.
+ * If the listener returns true then it will be removed after it is called.
+ * If you pass a regular expression as the event name then the listener will be added to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addListener = function addListener(evt, listener) {
+ var listeners = this.getListenersAsObject(evt);
+ var listenerIsWrapped = typeof listener === 'object';
+ var key;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
+ listeners[key].push(listenerIsWrapped ? listener : {
+ listener: listener,
+ once: false
+ });
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of addListener
+ */
+ proto.on = alias('addListener');
+
+ /**
+ * Semi-alias of addListener. It will add a listener that will be
+ * automatically removed after its first execution.
+ *
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addOnceListener = function addOnceListener(evt, listener) {
+ return this.addListener(evt, {
+ listener: listener,
+ once: true
+ });
+ };
+
+ /**
+ * Alias of addOnceListener.
+ */
+ proto.once = alias('addOnceListener');
+
+ /**
+ * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
+ * You need to tell it what event names should be matched by a regex.
+ *
+ * @param {String} evt Name of the event to create.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.defineEvent = function defineEvent(evt) {
+ this.getListeners(evt);
+ return this;
+ };
+
+ /**
+ * Uses defineEvent to define multiple events.
+ *
+ * @param {String[]} evts An array of event names to define.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.defineEvents = function defineEvents(evts) {
+ for (var i = 0; i < evts.length; i += 1) {
+ this.defineEvent(evts[i]);
+ }
+ return this;
+ };
+
+ /**
+ * Removes a listener function from the specified event.
+ * When passed a regular expression as the event name, it will remove the listener from all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to remove the listener from.
+ * @param {Function} listener Method to remove from the event.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeListener = function removeListener(evt, listener) {
+ var listeners = this.getListenersAsObject(evt);
+ var index;
+ var key;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key)) {
+ index = indexOfListener(listeners[key], listener);
+
+ if (index !== -1) {
+ listeners[key].splice(index, 1);
+ }
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of removeListener
+ */
+ proto.off = alias('removeListener');
+
+ /**
+ * Adds listeners in bulk using the manipulateListeners method.
+ * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
+ * You can also pass it a regular expression to add the array of listeners to all events that match it.
+ * Yeah, this function does quite a bit. That's probably a bad thing.
+ *
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to add.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addListeners = function addListeners(evt, listeners) {
+ // Pass through to manipulateListeners
+ return this.manipulateListeners(false, evt, listeners);
+ };
+
+ /**
+ * Removes listeners in bulk using the manipulateListeners method.
+ * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
+ * You can also pass it an event name and an array of listeners to be removed.
+ * You can also pass it a regular expression to remove the listeners from all events that match it.
+ *
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to remove.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeListeners = function removeListeners(evt, listeners) {
+ // Pass through to manipulateListeners
+ return this.manipulateListeners(true, evt, listeners);
+ };
+
+ /**
+ * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
+ * The first argument will determine if the listeners are removed (true) or added (false).
+ * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
+ * You can also pass it an event name and an array of listeners to be added/removed.
+ * You can also pass it a regular expression to manipulate the listeners of all events that match it.
+ *
+ * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
+ var i;
+ var value;
+ var single = remove ? this.removeListener : this.addListener;
+ var multiple = remove ? this.removeListeners : this.addListeners;
+
+ // If evt is an object then pass each of its properties to this method
+ if (typeof evt === 'object' && !(evt instanceof RegExp)) {
+ for (i in evt) {
+ if (evt.hasOwnProperty(i) && (value = evt[i])) {
+ // Pass the single listener straight through to the singular method
+ if (typeof value === 'function') {
+ single.call(this, i, value);
+ }
+ else {
+ // Otherwise pass back to the multiple function
+ multiple.call(this, i, value);
+ }
+ }
+ }
+ }
+ else {
+ // So evt must be a string
+ // And listeners must be an array of listeners
+ // Loop over it and pass each one to the multiple method
+ i = listeners.length;
+ while (i--) {
+ single.call(this, evt, listeners[i]);
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Removes all listeners from a specified event.
+ * If you do not specify an event then all listeners will be removed.
+ * That means every event will be emptied.
+ * You can also pass a regex to remove all events that match it.
+ *
+ * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeEvent = function removeEvent(evt) {
+ var type = typeof evt;
+ var events = this._getEvents();
+ var key;
+
+ // Remove different things depending on the state of evt
+ if (type === 'string') {
+ // Remove all listeners for the specified event
+ delete events[evt];
+ }
+ else if (evt instanceof RegExp) {
+ // Remove all events matching the regex.
+ for (key in events) {
+ if (events.hasOwnProperty(key) && evt.test(key)) {
+ delete events[key];
+ }
+ }
+ }
+ else {
+ // Remove all listeners in all events
+ delete this._events;
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of removeEvent.
+ *
+ * Added to mirror the node API.
+ */
+ proto.removeAllListeners = alias('removeEvent');
+
+ /**
+ * Emits an event of your choice.
+ * When emitted, every listener attached to that event will be executed.
+ * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
+ * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
+ * So they will not arrive within the array on the other side, they will be separate.
+ * You can also pass a regular expression to emit to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
+ * @param {Array} [args] Optional array of arguments to be passed to each listener.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.emitEvent = function emitEvent(evt, args) {
+ var listeners = this.getListenersAsObject(evt);
+ var listener;
+ var i;
+ var key;
+ var response;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key)) {
+ i = listeners[key].length;
+
+ while (i--) {
+ // If the listener returns true then it shall be removed from the event
+ // The function is executed either with a basic call or an apply if there is an args array
+ listener = listeners[key][i];
+
+ if (listener.once === true) {
+ this.removeListener(evt, listener.listener);
+ }
+
+ response = listener.listener.apply(this, args || []);
+
+ if (response === this._getOnceReturnValue()) {
+ this.removeListener(evt, listener.listener);
+ }
+ }
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of emitEvent
+ */
+ proto.trigger = alias('emitEvent');
+
+ /**
+ * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
+ * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
+ * @param {...*} Optional additional arguments to be passed to each listener.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.emit = function emit(evt) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return this.emitEvent(evt, args);
+ };
+
+ /**
+ * Sets the current value to check against when executing listeners. If a
+ * listeners return value matches the one set here then it will be removed
+ * after execution. This value defaults to true.
+ *
+ * @param {*} value The new value to check for when executing listeners.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.setOnceReturnValue = function setOnceReturnValue(value) {
+ this._onceReturnValue = value;
+ return this;
+ };
+
+ /**
+ * Fetches the current value to check against when executing listeners. If
+ * the listeners return value matches this one then it should be removed
+ * automatically. It will return true by default.
+ *
+ * @return {*|Boolean} The current value to check for or the default, true.
+ * @api private
+ */
+ proto._getOnceReturnValue = function _getOnceReturnValue() {
+ if (this.hasOwnProperty('_onceReturnValue')) {
+ return this._onceReturnValue;
+ }
+ else {
+ return true;
+ }
+ };
+
+ /**
+ * Fetches the events object and creates one if required.
+ *
+ * @return {Object} The events storage object.
+ * @api private
+ */
+ proto._getEvents = function _getEvents() {
+ return this._events || (this._events = {});
+ };
+
+ /**
+ * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
+ *
+ * @return {Function} Non conflicting EventEmitter class.
+ */
+ EventEmitter.noConflict = function noConflict() {
+ exports.EventEmitter = originalGlobalValue;
+ return EventEmitter;
+ };
+
+ // Expose the class either via AMD, CommonJS or the global object
+ if (typeof define === 'function' && define.amd) {
+ define('eventEmitter/EventEmitter',[],function () {
+ return EventEmitter;
+ });
+ }
+ else if (typeof module === 'object' && module.exports){
+ module.exports = EventEmitter;
+ }
+ else {
+ exports.EventEmitter = EventEmitter;
+ }
+}.call(this));
+
+/*!
+ * eventie v1.0.6
+ * event binding helper
+ * eventie.bind( elem, 'click', myFn )
+ * eventie.unbind( elem, 'click', myFn )
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( window ) {
+
+
+
+var docElem = document.documentElement;
+
+var bind = function() {};
+
+function getIEEvent( obj ) {
+ var event = window.event;
+ // add event.target
+ event.target = event.target || event.srcElement || obj;
+ return event;
+}
+
+if ( docElem.addEventListener ) {
+ bind = function( obj, type, fn ) {
+ obj.addEventListener( type, fn, false );
+ };
+} else if ( docElem.attachEvent ) {
+ bind = function( obj, type, fn ) {
+ obj[ type + fn ] = fn.handleEvent ?
+ function() {
+ var event = getIEEvent( obj );
+ fn.handleEvent.call( fn, event );
+ } :
+ function() {
+ var event = getIEEvent( obj );
+ fn.call( obj, event );
+ };
+ obj.attachEvent( "on" + type, obj[ type + fn ] );
+ };
+}
+
+var unbind = function() {};
+
+if ( docElem.removeEventListener ) {
+ unbind = function( obj, type, fn ) {
+ obj.removeEventListener( type, fn, false );
+ };
+} else if ( docElem.detachEvent ) {
+ unbind = function( obj, type, fn ) {
+ obj.detachEvent( "on" + type, obj[ type + fn ] );
+ try {
+ delete obj[ type + fn ];
+ } catch ( err ) {
+ // can't delete window object properties
+ obj[ type + fn ] = undefined;
+ }
+ };
+}
+
+var eventie = {
+ bind: bind,
+ unbind: unbind
+};
+
+// ----- module definition ----- //
+
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'eventie/eventie',eventie );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = eventie;
+} else {
+ // browser global
+ window.eventie = eventie;
+}
+
+})( window );
+
+/*!
+ * getStyleProperty v1.0.4
+ * original by kangax
+ * http://perfectionkills.com/feature-testing-css-properties/
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true */
+/*global define: false, exports: false, module: false */
+
+( function( window ) {
+
+
+
+var prefixes = 'Webkit Moz ms Ms O'.split(' ');
+var docElemStyle = document.documentElement.style;
+
+function getStyleProperty( propName ) {
+ if ( !propName ) {
+ return;
+ }
+
+ // test standard property first
+ if ( typeof docElemStyle[ propName ] === 'string' ) {
+ return propName;
+ }
+
+ // capitalize
+ propName = propName.charAt(0).toUpperCase() + propName.slice(1);
+
+ // test vendor specific properties
+ var prefixed;
+ for ( var i=0, len = prefixes.length; i < len; i++ ) {
+ prefixed = prefixes[i] + propName;
+ if ( typeof docElemStyle[ prefixed ] === 'string' ) {
+ return prefixed;
+ }
+ }
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'get-style-property/get-style-property',[],function() {
+ return getStyleProperty;
+ });
+} else if ( typeof exports === 'object' ) {
+ // CommonJS for Component
+ module.exports = getStyleProperty;
+} else {
+ // browser global
+ window.getStyleProperty = getStyleProperty;
+}
+
+})( window );
+
+/*!
+ * getSize v1.2.2
+ * measure size of elements
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, exports: false, require: false, module: false, console: false */
+
+( function( window, undefined ) {
+
+
+
+// -------------------------- helpers -------------------------- //
+
+// get a number from a string, not a percentage
+function getStyleSize( value ) {
+ var num = parseFloat( value );
+ // not a percent like '100%', and a number
+ var isValid = value.indexOf('%') === -1 && !isNaN( num );
+ return isValid && num;
+}
+
+function noop() {}
+
+var logError = typeof console === 'undefined' ? noop :
+ function( message ) {
+ console.error( message );
+ };
+
+// -------------------------- measurements -------------------------- //
+
+var measurements = [
+ 'paddingLeft',
+ 'paddingRight',
+ 'paddingTop',
+ 'paddingBottom',
+ 'marginLeft',
+ 'marginRight',
+ 'marginTop',
+ 'marginBottom',
+ 'borderLeftWidth',
+ 'borderRightWidth',
+ 'borderTopWidth',
+ 'borderBottomWidth'
+];
+
+function getZeroSize() {
+ var size = {
+ width: 0,
+ height: 0,
+ innerWidth: 0,
+ innerHeight: 0,
+ outerWidth: 0,
+ outerHeight: 0
+ };
+ for ( var i=0, len = measurements.length; i < len; i++ ) {
+ var measurement = measurements[i];
+ size[ measurement ] = 0;
+ }
+ return size;
+}
+
+
+
+function defineGetSize( getStyleProperty ) {
+
+// -------------------------- setup -------------------------- //
+
+var isSetup = false;
+
+var getStyle, boxSizingProp, isBoxSizeOuter;
+
+/**
+ * setup vars and functions
+ * do it on initial getSize(), rather than on script load
+ * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
+ */
+function setup() {
+ // setup once
+ if ( isSetup ) {
+ return;
+ }
+ isSetup = true;
+
+ var getComputedStyle = window.getComputedStyle;
+ getStyle = ( function() {
+ var getStyleFn = getComputedStyle ?
+ function( elem ) {
+ return getComputedStyle( elem, null );
+ } :
+ function( elem ) {
+ return elem.currentStyle;
+ };
+
+ return function getStyle( elem ) {
+ var style = getStyleFn( elem );
+ if ( !style ) {
+ logError( 'Style returned ' + style +
+ '. Are you running this code in a hidden iframe on Firefox? ' +
+ 'See http://bit.ly/getsizebug1' );
+ }
+ return style;
+ };
+ })();
+
+ // -------------------------- box sizing -------------------------- //
+
+ boxSizingProp = getStyleProperty('boxSizing');
+
+ /**
+ * WebKit measures the outer-width on style.width on border-box elems
+ * IE & Firefox measures the inner-width
+ */
+ if ( boxSizingProp ) {
+ var div = document.createElement('div');
+ div.style.width = '200px';
+ div.style.padding = '1px 2px 3px 4px';
+ div.style.borderStyle = 'solid';
+ div.style.borderWidth = '1px 2px 3px 4px';
+ div.style[ boxSizingProp ] = 'border-box';
+
+ var body = document.body || document.documentElement;
+ body.appendChild( div );
+ var style = getStyle( div );
+
+ isBoxSizeOuter = getStyleSize( style.width ) === 200;
+ body.removeChild( div );
+ }
+
+}
+
+// -------------------------- getSize -------------------------- //
+
+function getSize( elem ) {
+ setup();
+
+ // use querySeletor if elem is string
+ if ( typeof elem === 'string' ) {
+ elem = document.querySelector( elem );
+ }
+
+ // do not proceed on non-objects
+ if ( !elem || typeof elem !== 'object' || !elem.nodeType ) {
+ return;
+ }
+
+ var style = getStyle( elem );
+
+ // if hidden, everything is 0
+ if ( style.display === 'none' ) {
+ return getZeroSize();
+ }
+
+ var size = {};
+ size.width = elem.offsetWidth;
+ size.height = elem.offsetHeight;
+
+ var isBorderBox = size.isBorderBox = !!( boxSizingProp &&
+ style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' );
+
+ // get all measurements
+ for ( var i=0, len = measurements.length; i < len; i++ ) {
+ var measurement = measurements[i];
+ var value = style[ measurement ];
+ value = mungeNonPixel( elem, value );
+ var num = parseFloat( value );
+ // any 'auto', 'medium' value will be 0
+ size[ measurement ] = !isNaN( num ) ? num : 0;
+ }
+
+ var paddingWidth = size.paddingLeft + size.paddingRight;
+ var paddingHeight = size.paddingTop + size.paddingBottom;
+ var marginWidth = size.marginLeft + size.marginRight;
+ var marginHeight = size.marginTop + size.marginBottom;
+ var borderWidth = size.borderLeftWidth + size.borderRightWidth;
+ var borderHeight = size.borderTopWidth + size.borderBottomWidth;
+
+ var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
+
+ // overwrite width and height if we can get it from style
+ var styleWidth = getStyleSize( style.width );
+ if ( styleWidth !== false ) {
+ size.width = styleWidth +
+ // add padding and border unless it's already including it
+ ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
+ }
+
+ var styleHeight = getStyleSize( style.height );
+ if ( styleHeight !== false ) {
+ size.height = styleHeight +
+ // add padding and border unless it's already including it
+ ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
+ }
+
+ size.innerWidth = size.width - ( paddingWidth + borderWidth );
+ size.innerHeight = size.height - ( paddingHeight + borderHeight );
+
+ size.outerWidth = size.width + marginWidth;
+ size.outerHeight = size.height + marginHeight;
+
+ return size;
+}
+
+// IE8 returns percent values, not pixels
+// taken from jQuery's curCSS
+function mungeNonPixel( elem, value ) {
+ // IE8 and has percent value
+ if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
+ return value;
+ }
+ var style = elem.style;
+ // Remember the original values
+ var left = style.left;
+ var rs = elem.runtimeStyle;
+ var rsLeft = rs && rs.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
+ style.left = value;
+ value = style.pixelLeft;
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
+
+ return value;
+}
+
+return getSize;
+
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD for RequireJS
+ define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS for Component
+ module.exports = defineGetSize( require('desandro-get-style-property') );
+} else {
+ // browser global
+ window.getSize = defineGetSize( window.getStyleProperty );
+}
+
+})( window );
+
+/*!
+ * docReady v1.0.4
+ * Cross browser DOMContentLoaded event emitter
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true*/
+/*global define: false, require: false, module: false */
+
+( function( window ) {
+
+
+
+var document = window.document;
+// collection of functions to be triggered on ready
+var queue = [];
+
+function docReady( fn ) {
+ // throw out non-functions
+ if ( typeof fn !== 'function' ) {
+ return;
+ }
+
+ if ( docReady.isReady ) {
+ // ready now, hit it
+ fn();
+ } else {
+ // queue function when ready
+ queue.push( fn );
+ }
+}
+
+docReady.isReady = false;
+
+// triggered on various doc ready events
+function onReady( event ) {
+ // bail if already triggered or IE8 document is not ready just yet
+ var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
+ if ( docReady.isReady || isIE8NotReady ) {
+ return;
+ }
+
+ trigger();
+}
+
+function trigger() {
+ docReady.isReady = true;
+ // process queue
+ for ( var i=0, len = queue.length; i < len; i++ ) {
+ var fn = queue[i];
+ fn();
+ }
+}
+
+function defineDocReady( eventie ) {
+ // trigger ready if page is ready
+ if ( document.readyState === 'complete' ) {
+ trigger();
+ } else {
+ // listen for events
+ eventie.bind( document, 'DOMContentLoaded', onReady );
+ eventie.bind( document, 'readystatechange', onReady );
+ eventie.bind( window, 'load', onReady );
+ }
+
+ return docReady;
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady );
+} else if ( typeof exports === 'object' ) {
+ module.exports = defineDocReady( require('eventie') );
+} else {
+ // browser global
+ window.docReady = defineDocReady( window.eventie );
+}
+
+})( window );
+
+/**
+ * matchesSelector v1.0.3
+ * matchesSelector( element, '.selector' )
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( ElemProto ) {
+
+
+
+ var matchesMethod = ( function() {
+ // check for the standard method name first
+ if ( ElemProto.matches ) {
+ return 'matches';
+ }
+ // check un-prefixed
+ if ( ElemProto.matchesSelector ) {
+ return 'matchesSelector';
+ }
+ // check vendor prefixes
+ var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
+
+ for ( var i=0, len = prefixes.length; i < len; i++ ) {
+ var prefix = prefixes[i];
+ var method = prefix + 'MatchesSelector';
+ if ( ElemProto[ method ] ) {
+ return method;
+ }
+ }
+ })();
+
+ // ----- match ----- //
+
+ function match( elem, selector ) {
+ return elem[ matchesMethod ]( selector );
+ }
+
+ // ----- appendToFragment ----- //
+
+ function checkParent( elem ) {
+ // not needed if already has parent
+ if ( elem.parentNode ) {
+ return;
+ }
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild( elem );
+ }
+
+ // ----- query ----- //
+
+ // fall back to using QSA
+ // thx @jonathantneal https://gist.github.com/3062955
+ function query( elem, selector ) {
+ // append to fragment if no parent
+ checkParent( elem );
+
+ // match elem with all selected elems of parent
+ var elems = elem.parentNode.querySelectorAll( selector );
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ // return true if match
+ if ( elems[i] === elem ) {
+ return true;
+ }
+ }
+ // otherwise return false
+ return false;
+ }
+
+ // ----- matchChild ----- //
+
+ function matchChild( elem, selector ) {
+ checkParent( elem );
+ return match( elem, selector );
+ }
+
+ // ----- matchesSelector ----- //
+
+ var matchesSelector;
+
+ if ( matchesMethod ) {
+ // IE9 supports matchesSelector, but doesn't work on orphaned elems
+ // check for that
+ var div = document.createElement('div');
+ var supportsOrphans = match( div, 'div' );
+ matchesSelector = supportsOrphans ? match : matchChild;
+ } else {
+ matchesSelector = query;
+ }
+
+ // transport
+ if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'matches-selector/matches-selector',[],function() {
+ return matchesSelector;
+ });
+ } else if ( typeof exports === 'object' ) {
+ module.exports = matchesSelector;
+ }
+ else {
+ // browser global
+ window.matchesSelector = matchesSelector;
+ }
+
+})( Element.prototype );
+
+/**
+ * Fizzy UI utils v1.0.1
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'fizzy-ui-utils/utils',[
+ 'doc-ready/doc-ready',
+ 'matches-selector/matches-selector'
+ ], function( docReady, matchesSelector ) {
+ return factory( window, docReady, matchesSelector );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('doc-ready'),
+ require('desandro-matches-selector')
+ );
+ } else {
+ // browser global
+ window.fizzyUIUtils = factory(
+ window,
+ window.docReady,
+ window.matchesSelector
+ );
+ }
+
+}( window, function factory( window, docReady, matchesSelector ) {
+
+
+
+var utils = {};
+
+// ----- extend ----- //
+
+// extends objects
+utils.extend = function( a, b ) {
+ for ( var prop in b ) {
+ a[ prop ] = b[ prop ];
+ }
+ return a;
+};
+
+// ----- modulo ----- //
+
+utils.modulo = function( num, div ) {
+ return ( ( num % div ) + div ) % div;
+};
+
+// ----- isArray ----- //
+
+var objToString = Object.prototype.toString;
+utils.isArray = function( obj ) {
+ return objToString.call( obj ) == '[object Array]';
+};
+
+// ----- makeArray ----- //
+
+// turn element or nodeList into an array
+utils.makeArray = function( obj ) {
+ var ary = [];
+ if ( utils.isArray( obj ) ) {
+ // use object if already an array
+ ary = obj;
+ } else if ( obj && typeof obj.length == 'number' ) {
+ // convert nodeList to array
+ for ( var i=0, len = obj.length; i < len; i++ ) {
+ ary.push( obj[i] );
+ }
+ } else {
+ // array of single index
+ ary.push( obj );
+ }
+ return ary;
+};
+
+// ----- indexOf ----- //
+
+// index of helper cause IE8
+utils.indexOf = Array.prototype.indexOf ? function( ary, obj ) {
+ return ary.indexOf( obj );
+ } : function( ary, obj ) {
+ for ( var i=0, len = ary.length; i < len; i++ ) {
+ if ( ary[i] === obj ) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+// ----- removeFrom ----- //
+
+utils.removeFrom = function( ary, obj ) {
+ var index = utils.indexOf( ary, obj );
+ if ( index != -1 ) {
+ ary.splice( index, 1 );
+ }
+};
+
+// ----- isElement ----- //
+
+// http://stackoverflow.com/a/384380/182183
+utils.isElement = ( typeof HTMLElement == 'function' || typeof HTMLElement == 'object' ) ?
+ function isElementDOM2( obj ) {
+ return obj instanceof HTMLElement;
+ } :
+ function isElementQuirky( obj ) {
+ return obj && typeof obj == 'object' &&
+ obj.nodeType == 1 && typeof obj.nodeName == 'string';
+ };
+
+// ----- setText ----- //
+
+utils.setText = ( function() {
+ var setTextProperty;
+ function setText( elem, text ) {
+ // only check setTextProperty once
+ setTextProperty = setTextProperty || ( document.documentElement.textContent !== undefined ? 'textContent' : 'innerText' );
+ elem[ setTextProperty ] = text;
+ }
+ return setText;
+})();
+
+// ----- getParent ----- //
+
+utils.getParent = function( elem, selector ) {
+ while ( elem != document.body ) {
+ elem = elem.parentNode;
+ if ( matchesSelector( elem, selector ) ) {
+ return elem;
+ }
+ }
+};
+
+// ----- getQueryElement ----- //
+
+// use element as selector string
+utils.getQueryElement = function( elem ) {
+ if ( typeof elem == 'string' ) {
+ return document.querySelector( elem );
+ }
+ return elem;
+};
+
+// ----- handleEvent ----- //
+
+// enable .ontype to trigger from .addEventListener( elem, 'type' )
+utils.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+};
+
+// ----- filterFindElements ----- //
+
+utils.filterFindElements = function( elems, selector ) {
+ // make array of elems
+ elems = utils.makeArray( elems );
+ var ffElems = [];
+
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ // check that elem is an actual element
+ if ( !utils.isElement( elem ) ) {
+ continue;
+ }
+ // filter & find items if we have a selector
+ if ( selector ) {
+ // filter siblings
+ if ( matchesSelector( elem, selector ) ) {
+ ffElems.push( elem );
+ }
+ // find children
+ var childElems = elem.querySelectorAll( selector );
+ // concat childElems to filterFound array
+ for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
+ ffElems.push( childElems[j] );
+ }
+ } else {
+ ffElems.push( elem );
+ }
+ }
+
+ return ffElems;
+};
+
+// ----- debounceMethod ----- //
+
+utils.debounceMethod = function( _class, methodName, threshold ) {
+ // original method
+ var method = _class.prototype[ methodName ];
+ var timeoutName = methodName + 'Timeout';
+
+ _class.prototype[ methodName ] = function() {
+ var timeout = this[ timeoutName ];
+ if ( timeout ) {
+ clearTimeout( timeout );
+ }
+ var args = arguments;
+
+ var _this = this;
+ this[ timeoutName ] = setTimeout( function() {
+ method.apply( _this, args );
+ delete _this[ timeoutName ];
+ }, threshold || 100 );
+ };
+};
+
+// ----- htmlInit ----- //
+
+// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
+utils.toDashed = function( str ) {
+ return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
+ return $1 + '-' + $2;
+ }).toLowerCase();
+};
+
+var console = window.console;
+/**
+ * allow user to initialize classes via .js-namespace class
+ * htmlInit( Widget, 'widgetName' )
+ * options are parsed from data-namespace-option attribute
+ */
+utils.htmlInit = function( WidgetClass, namespace ) {
+ docReady( function() {
+ var dashedNamespace = utils.toDashed( namespace );
+ var elems = document.querySelectorAll( '.js-' + dashedNamespace );
+ var dataAttr = 'data-' + dashedNamespace + '-options';
+
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ var attr = elem.getAttribute( dataAttr );
+ var options;
+ try {
+ options = attr && JSON.parse( attr );
+ } catch ( error ) {
+ // log error, do not initialize
+ if ( console ) {
+ console.error( 'Error parsing ' + dataAttr + ' on ' +
+ elem.nodeName.toLowerCase() + ( elem.id ? '#' + elem.id : '' ) + ': ' +
+ error );
+ }
+ continue;
+ }
+ // initialize
+ var instance = new WidgetClass( elem, options );
+ // make available via $().data('layoutname')
+ var jQuery = window.jQuery;
+ if ( jQuery ) {
+ jQuery.data( elem, namespace, instance );
+ }
+ }
+ });
+};
+
+// ----- ----- //
+
+return utils;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/cell',[
+ 'get-size/get-size'
+ ], function( getSize ) {
+ return factory( window, getSize );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('get-size')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.Cell = factory(
+ window,
+ window.getSize
+ );
+ }
+
+}( window, function factory( window, getSize ) {
+
+
+
+function Cell( elem, parent ) {
+ this.element = elem;
+ this.parent = parent;
+
+ this.create();
+}
+
+var isIE8 = 'attachEvent' in window;
+
+Cell.prototype.create = function() {
+ this.element.style.position = 'absolute';
+ // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183
+ if ( isIE8 ) {
+ this.element.setAttribute( 'unselectable', 'on' );
+ }
+ this.x = 0;
+ this.shift = 0;
+};
+
+Cell.prototype.destroy = function() {
+ // reset style
+ this.element.style.position = '';
+ var side = this.parent.originSide;
+ this.element.style[ side ] = '';
+};
+
+Cell.prototype.getSize = function() {
+ this.size = getSize( this.element );
+};
+
+Cell.prototype.setPosition = function( x ) {
+ this.x = x;
+ this.setDefaultTarget();
+ this.renderPosition( x );
+};
+
+Cell.prototype.setDefaultTarget = function() {
+ var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
+ this.target = this.x + this.size[ marginProperty ] +
+ this.size.width * this.parent.cellAlign;
+};
+
+Cell.prototype.renderPosition = function( x ) {
+ // render position of cell with in slider
+ var side = this.parent.originSide;
+ this.element.style[ side ] = this.parent.getPositionValue( x );
+};
+
+/**
+ * @param {Integer} factor - 0, 1, or -1
+**/
+Cell.prototype.wrapShift = function( shift ) {
+ this.shift = shift;
+ this.renderPosition( this.x + this.parent.slideableWidth * shift );
+};
+
+Cell.prototype.remove = function() {
+ this.element.parentNode.removeChild( this.element );
+};
+
+return Cell;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/animate',[
+ 'get-style-property/get-style-property',
+ 'fizzy-ui-utils/utils'
+ ], function( getStyleProperty, utils ) {
+ return factory( window, getStyleProperty, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-get-style-property'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.animatePrototype = factory(
+ window,
+ window.getStyleProperty,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, getStyleProperty, utils ) {
+
+
+
+// -------------------------- requestAnimationFrame -------------------------- //
+
+// https://gist.github.com/1866474
+
+var lastTime = 0;
+var prefixes = 'webkit moz ms o'.split(' ');
+// get unprefixed rAF and cAF, if present
+var requestAnimationFrame = window.requestAnimationFrame;
+var cancelAnimationFrame = window.cancelAnimationFrame;
+// loop through vendor prefixes and get prefixed rAF and cAF
+var prefix;
+for( var i = 0; i < prefixes.length; i++ ) {
+ if ( requestAnimationFrame && cancelAnimationFrame ) {
+ break;
+ }
+ prefix = prefixes[i];
+ requestAnimationFrame = requestAnimationFrame || window[ prefix + 'RequestAnimationFrame' ];
+ cancelAnimationFrame = cancelAnimationFrame || window[ prefix + 'CancelAnimationFrame' ] ||
+ window[ prefix + 'CancelRequestAnimationFrame' ];
+}
+
+// fallback to setTimeout and clearTimeout if either request/cancel is not supported
+if ( !requestAnimationFrame || !cancelAnimationFrame ) {
+ requestAnimationFrame = function( callback ) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
+ var id = window.setTimeout( function() {
+ callback( currTime + timeToCall );
+ }, timeToCall );
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+
+ cancelAnimationFrame = function( id ) {
+ window.clearTimeout( id );
+ };
+}
+
+// -------------------------- animate -------------------------- //
+
+var proto = {};
+
+proto.startAnimation = function() {
+ if ( this.isAnimating ) {
+ return;
+ }
+
+ this.isAnimating = true;
+ this.restingFrames = 0;
+ this.animate();
+};
+
+proto.animate = function() {
+ this.applySelectedAttraction();
+
+ var previousX = this.x;
+
+ this.integratePhysics();
+ this.positionSlider();
+ this.settle( previousX );
+ // animate next frame
+ if ( this.isAnimating ) {
+ var _this = this;
+ requestAnimationFrame( function animateFrame() {
+ _this.animate();
+ });
+ }
+
+ /** /
+ // log animation frame rate
+ var now = new Date();
+ if ( this.then ) {
+ console.log( ~~( 1000 / (now-this.then)) + 'fps' )
+ }
+ this.then = now;
+ /**/
+};
+
+
+var transformProperty = getStyleProperty('transform');
+var is3d = !!getStyleProperty('perspective');
+
+proto.positionSlider = function() {
+ var x = this.x;
+ // wrap position around
+ if ( this.options.wrapAround && this.cells.length > 1 ) {
+ x = utils.modulo( x, this.slideableWidth );
+ x = x - this.slideableWidth;
+ this.shiftWrapCells( x );
+ }
+
+ x = x + this.cursorPosition;
+
+ // reverse if right-to-left and using transform
+ x = this.options.rightToLeft && transformProperty ? -x : x;
+
+ var value = this.getPositionValue( x );
+
+ if ( transformProperty ) {
+ // use 3D tranforms for hardware acceleration on iOS
+ // but use 2D when settled, for better font-rendering
+ this.slider.style[ transformProperty ] = is3d && this.isAnimating ?
+ 'translate3d(' + value + ',0,0)' : 'translateX(' + value + ')';
+ } else {
+ this.slider.style[ this.originSide ] = value;
+ }
+};
+
+proto.positionSliderAtSelected = function() {
+ if ( !this.cells.length ) {
+ return;
+ }
+ var selectedCell = this.cells[ this.selectedIndex ];
+ this.x = -selectedCell.target;
+ this.positionSlider();
+};
+
+proto.getPositionValue = function( position ) {
+ if ( this.options.percentPosition ) {
+ // percent position, round to 2 digits, like 12.34%
+ return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 )+ '%';
+ } else {
+ // pixel positioning
+ return Math.round( position ) + 'px';
+ }
+};
+
+proto.settle = function( previousX ) {
+ // keep track of frames where x hasn't moved
+ if ( !this.isPointerDown && Math.round( this.x * 100 ) == Math.round( previousX * 100 ) ) {
+ this.restingFrames++;
+ }
+ // stop animating if resting for 3 or more frames
+ if ( this.restingFrames > 2 ) {
+ this.isAnimating = false;
+ delete this.isFreeScrolling;
+ // render position with translateX when settled
+ if ( is3d ) {
+ this.positionSlider();
+ }
+ this.dispatchEvent('settle');
+ }
+};
+
+proto.shiftWrapCells = function( x ) {
+ // shift before cells
+ var beforeGap = this.cursorPosition + x;
+ this._shiftCells( this.beforeShiftCells, beforeGap, -1 );
+ // shift after cells
+ var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition );
+ this._shiftCells( this.afterShiftCells, afterGap, 1 );
+};
+
+proto._shiftCells = function( cells, gap, shift ) {
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ var cellShift = gap > 0 ? shift : 0;
+ cell.wrapShift( cellShift );
+ gap -= cell.size.outerWidth;
+ }
+};
+
+proto._unshiftCells = function( cells ) {
+ if ( !cells || !cells.length ) {
+ return;
+ }
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ cells[i].wrapShift( 0 );
+ }
+};
+
+// -------------------------- physics -------------------------- //
+
+proto.integratePhysics = function() {
+ this.velocity += this.accel;
+ this.x += this.velocity;
+ this.velocity *= this.getFrictionFactor();
+ // reset acceleration
+ this.accel = 0;
+};
+
+proto.applyForce = function( force ) {
+ this.accel += force;
+};
+
+proto.getFrictionFactor = function() {
+ return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ];
+};
+
+
+proto.getRestingPosition = function() {
+ // my thanks to Steven Wittens, who simplified this math greatly
+ return this.x + this.velocity / ( 1 - this.getFrictionFactor() );
+};
+
+
+proto.applySelectedAttraction = function() {
+ // do not attract if pointer down or no cells
+ var len = this.cells.length;
+ if ( this.isPointerDown || this.isFreeScrolling || !len ) {
+ return;
+ }
+ var cell = this.cells[ this.selectedIndex ];
+ var wrap = this.options.wrapAround && len > 1 ?
+ this.slideableWidth * Math.floor( this.selectedIndex / len ) : 0;
+ var distance = ( cell.target + wrap ) * -1 - this.x;
+ var force = distance * this.options.selectedAttraction;
+ this.applyForce( force );
+};
+
+return proto;
+
+}));
+
+/*!
+ * Flickity v1.0.1
+ * Touch, responsive, flickable galleries
+ *
+ * Licensed GPLv3 for open source use
+ * or Flickity Commercial License for commercial use
+ *
+ * http://flickity.metafizzy.co
+ * Copyright 2015 Metafizzy
+ */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/flickity',[
+ 'classie/classie',
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie',
+ 'get-size/get-size',
+ 'fizzy-ui-utils/utils',
+ './cell',
+ './animate'
+ ], function( classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype ) {
+ return factory( window, classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('wolfy87-eventemitter'),
+ require('eventie'),
+ require('get-size'),
+ require('fizzy-ui-utils'),
+ require('./cell'),
+ require('./animate')
+ );
+ } else {
+ // browser global
+ var _Flickity = window.Flickity;
+
+ window.Flickity = factory(
+ window,
+ window.classie,
+ window.EventEmitter,
+ window.eventie,
+ window.getSize,
+ window.fizzyUIUtils,
+ _Flickity.Cell,
+ _Flickity.animatePrototype
+ );
+ }
+
+}( window, function factory( window, classie, EventEmitter, eventie, getSize,
+ utils, Cell, animatePrototype ) {
+
+
+
+// vars
+var jQuery = window.jQuery;
+var getComputedStyle = window.getComputedStyle;
+var console = window.console;
+
+function moveElements( elems, toElem ) {
+ elems = utils.makeArray( elems );
+ while ( elems.length ) {
+ toElem.appendChild( elems.shift() );
+ }
+}
+
+// -------------------------- Flickity -------------------------- //
+
+// globally unique identifiers
+var GUID = 0;
+// internal store of all Flickity intances
+var instances = {};
+
+function Flickity( element, options ) {
+ var queryElement = utils.getQueryElement( element );
+ if ( !queryElement ) {
+ if ( console ) {
+ console.error( 'Bad element for Flickity: ' + ( queryElement || element ) );
+ }
+ return;
+ }
+ this.element = queryElement;
+ // add jQuery
+ if ( jQuery ) {
+ this.$element = jQuery( this.element );
+ }
+ // options
+ this.options = utils.extend( {}, this.constructor.defaults );
+ this.option( options );
+
+ // kick things off
+ this._create();
+}
+
+Flickity.defaults = {
+ accessibility: true,
+ cellAlign: 'center',
+ // cellSelector: undefined,
+ // contain: false,
+ freeScrollFriction: 0.075, // friction when free-scrolling
+ friction: 0.28, // friction when selecting
+ // initialIndex: 0,
+ percentPosition: true,
+ resize: true,
+ selectedAttraction: 0.025,
+ setGallerySize: true
+ // watchCSS: false,
+ // wrapAround: false
+};
+
+// hash of methods triggered on _create()
+Flickity.createMethods = [];
+
+// inherit EventEmitter
+utils.extend( Flickity.prototype, EventEmitter.prototype );
+
+Flickity.prototype._create = function() {
+ // add id for Flickity.data
+ var id = this.guid = ++GUID;
+ this.element.flickityGUID = id; // expando
+ instances[ id ] = this; // associate via id
+ // initial properties
+ this.selectedIndex = this.options.initialIndex || 0;
+ // how many frames slider has been in same position
+ this.restingFrames = 0;
+ // initial physics properties
+ this.x = 0;
+ this.velocity = 0;
+ this.accel = 0;
+ this.originSide = this.options.rightToLeft ? 'right' : 'left';
+ // create viewport & slider
+ this.viewport = document.createElement('div');
+ this.viewport.className = 'flickity-viewport';
+ Flickity.setUnselectable( this.viewport );
+ this._createSlider();
+
+ if ( this.options.resize || this.options.watchCSS ) {
+ eventie.bind( window, 'resize', this );
+ this.isResizeBound = true;
+ }
+
+ for ( var i=0, len = Flickity.createMethods.length; i < len; i++ ) {
+ var method = Flickity.createMethods[i];
+ this[ method ]();
+ }
+
+ if ( this.options.watchCSS ) {
+ this.watchCSS();
+ } else {
+ this.activate();
+ }
+
+};
+
+/**
+ * set options
+ * @param {Object} opts
+ */
+Flickity.prototype.option = function( opts ) {
+ utils.extend( this.options, opts );
+};
+
+Flickity.prototype.activate = function() {
+ if ( this.isActive ) {
+ return;
+ }
+ this.isActive = true;
+ classie.add( this.element, 'flickity-enabled' );
+ if ( this.options.rightToLeft ) {
+ classie.add( this.element, 'flickity-rtl' );
+ }
+
+ // move initial cell elements so they can be loaded as cells
+ var cellElems = this._filterFindCellElements( this.element.children );
+ moveElements( cellElems, this.slider );
+ this.viewport.appendChild( this.slider );
+ this.element.appendChild( this.viewport );
+
+ this.getSize();
+ // get cells from children
+ this.reloadCells();
+
+ if ( this.options.accessibility ) {
+ // allow element to focusable
+ this.element.tabIndex = 0;
+ // listen for key presses
+ eventie.bind( this.element, 'keydown', this );
+ }
+
+ this.emit('activate');
+
+ this.positionSliderAtSelected();
+ this.select( this.selectedIndex );
+};
+
+// slider positions the cells
+Flickity.prototype._createSlider = function() {
+ // slider element does all the positioning
+ var slider = document.createElement('div');
+ slider.className = 'flickity-slider';
+ slider.style[ this.originSide ] = 0;
+ this.slider = slider;
+};
+
+Flickity.prototype._filterFindCellElements = function( elems ) {
+ return utils.filterFindElements( elems, this.options.cellSelector );
+};
+
+// goes through all children
+Flickity.prototype.reloadCells = function() {
+ // collection of item elements
+ this.cells = this._makeCells( this.slider.children );
+ this.positionCells();
+ this._getWrapShiftCells();
+ this.setGallerySize();
+};
+
+/**
+ * turn elements into Flickity.Cells
+ * @param {Array or NodeList or HTMLElement} elems
+ * @returns {Array} items - collection of new Flickity Cells
+ */
+Flickity.prototype._makeCells = function( elems ) {
+ var cellElems = this._filterFindCellElements( elems );
+
+ // create new Flickity for collection
+ var cells = [];
+ for ( var i=0, len = cellElems.length; i < len; i++ ) {
+ var elem = cellElems[i];
+ var cell = new Cell( elem, this );
+ cells.push( cell );
+ }
+
+ return cells;
+};
+
+Flickity.prototype.getLastCell = function() {
+ return this.cells[ this.cells.length - 1 ];
+};
+
+// positions all cells
+Flickity.prototype.positionCells = function() {
+ // size all cells
+ this._sizeCells( this.cells );
+ // position all cells
+ this._positionCells( 0 );
+};
+
+/**
+ * position certain cells
+ * @param {Integer} index - which cell to start with
+ */
+Flickity.prototype._positionCells = function( index ) {
+ // also measure maxCellHeight
+ // start 0 if positioning all cells
+ this.maxCellHeight = index ? this.maxCellHeight || 0 : 0;
+ var cellX = 0;
+ // get cellX
+ if ( index > 0 ) {
+ var startCell = this.cells[ index - 1 ];
+ cellX = startCell.x + startCell.size.outerWidth;
+ }
+ var cell;
+ for ( var len = this.cells.length, i=index; i < len; i++ ) {
+ cell = this.cells[i];
+ cell.setPosition( cellX );
+ cellX += cell.size.outerWidth;
+ this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight );
+ }
+ // keep track of cellX for wrap-around
+ this.slideableWidth = cellX;
+ // contain cell target
+ this._containCells();
+};
+
+/**
+ * cell.getSize() on multiple cells
+ * @param {Array} cells
+ */
+Flickity.prototype._sizeCells = function( cells ) {
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ cell.getSize();
+ }
+};
+
+// alias _init for jQuery plugin .flickity()
+Flickity.prototype._init =
+Flickity.prototype.reposition = function() {
+ this.positionCells();
+ this.positionSliderAtSelected();
+};
+
+Flickity.prototype.getSize = function() {
+ this.size = getSize( this.element );
+ this.setCellAlign();
+ this.cursorPosition = this.size.innerWidth * this.cellAlign;
+};
+
+var cellAlignShorthands = {
+ // cell align, then based on origin side
+ center: {
+ left: 0.5,
+ right: 0.5
+ },
+ left: {
+ left: 0,
+ right: 1
+ },
+ right: {
+ right: 0,
+ left: 1
+ }
+};
+
+Flickity.prototype.setCellAlign = function() {
+ var shorthand = cellAlignShorthands[ this.options.cellAlign ];
+ this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign;
+};
+
+Flickity.prototype.setGallerySize = function() {
+ if ( this.options.setGallerySize ) {
+ this.viewport.style.height = this.maxCellHeight + 'px';
+ }
+};
+
+Flickity.prototype._getWrapShiftCells = function() {
+ // only for wrap-around
+ if ( !this.options.wrapAround ) {
+ return;
+ }
+ // unshift previous cells
+ this._unshiftCells( this.beforeShiftCells );
+ this._unshiftCells( this.afterShiftCells );
+ // get before cells
+ // initial gap
+ var gapX = this.cursorPosition;
+ var cellIndex = this.cells.length - 1;
+ this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );
+ // get after cells
+ // ending gap between last cell and end of gallery viewport
+ gapX = this.size.innerWidth - this.cursorPosition;
+ // start cloning at first cell, working forwards
+ this.afterShiftCells = this._getGapCells( gapX, 0, 1 );
+};
+
+Flickity.prototype._getGapCells = function( gapX, cellIndex, increment ) {
+ // keep adding cells until the cover the initial gap
+ var cells = [];
+ while ( gapX > 0 ) {
+ var cell = this.cells[ cellIndex ];
+ if ( !cell ) {
+ break;
+ }
+ cells.push( cell );
+ cellIndex += increment;
+ gapX -= cell.size.outerWidth;
+ }
+ return cells;
+};
+
+// ----- contain ----- //
+
+// contain cell targets so no excess sliding
+Flickity.prototype._containCells = function() {
+ if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) {
+ return;
+ }
+ var startMargin = this.options.rightToLeft ? 'marginRight' : 'marginLeft';
+ var endMargin = this.options.rightToLeft ? 'marginLeft' : 'marginRight';
+ var firstCellStartMargin = this.cells[0].size[ startMargin ];
+ var lastCell = this.getLastCell();
+ var contentWidth = this.slideableWidth - lastCell.size[ endMargin ];
+ var endLimit = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign );
+ // content is less than gallery size
+ var isContentSmaller = contentWidth < this.size.innerWidth;
+ // contain each cell target
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ // reset default target
+ cell.setDefaultTarget();
+ if ( isContentSmaller ) {
+ // all cells fit inside gallery
+ cell.target = contentWidth * this.cellAlign;
+ } else {
+ // contain to bounds
+ cell.target = Math.max( cell.target, this.cursorPosition + firstCellStartMargin );
+ cell.target = Math.min( cell.target, endLimit );
+ }
+ }
+};
+
+// ----- ----- //
+
+/**
+ * emits events via eventEmitter and jQuery events
+ * @param {String} type - name of event
+ * @param {Event} event - original event
+ * @param {Array} args - extra arguments
+ */
+Flickity.prototype.dispatchEvent = function( type, event, args ) {
+ var emitArgs = [ event ].concat( args );
+ this.emitEvent( type, emitArgs );
+
+ if ( jQuery && this.$element ) {
+ if ( event ) {
+ // create jQuery event
+ var $event = jQuery.Event( event );
+ $event.type = type;
+ this.$element.trigger( $event, args );
+ } else {
+ // just trigger with type if no event available
+ this.$element.trigger( type, args );
+ }
+ }
+};
+
+// -------------------------- select -------------------------- //
+
+/**
+ * @param {Integer} index - index of the cell
+ * @param {Boolean} isWrap - will wrap-around to last/first if at the end
+ */
+Flickity.prototype.select = function( index, isWrap ) {
+ if ( !this.isActive ) {
+ return;
+ }
+ // wrap position so slider is within normal area
+ var len = this.cells.length;
+ if ( this.options.wrapAround && len > 1 ) {
+ if ( index < 0 ) {
+ this.x -= this.slideableWidth;
+ } else if ( index >= len ) {
+ this.x += this.slideableWidth;
+ }
+ }
+
+ if ( this.options.wrapAround || isWrap ) {
+ index = utils.modulo( index, len );
+ }
+
+ if ( this.cells[ index ] ) {
+ this.selectedIndex = index;
+ this.setSelectedCell();
+ this.startAnimation();
+ this.dispatchEvent('cellSelect');
+ }
+};
+
+Flickity.prototype.previous = function( isWrap ) {
+ this.select( this.selectedIndex - 1, isWrap );
+};
+
+Flickity.prototype.next = function( isWrap ) {
+ this.select( this.selectedIndex + 1, isWrap );
+};
+
+Flickity.prototype.setSelectedCell = function() {
+ this._removeSelectedCellClass();
+ this.selectedCell = this.cells[ this.selectedIndex ];
+ this.selectedElement = this.selectedCell.element;
+ classie.add( this.selectedElement, 'is-selected' );
+};
+
+Flickity.prototype._removeSelectedCellClass = function() {
+ if ( this.selectedCell ) {
+ classie.remove( this.selectedCell.element, 'is-selected' );
+ }
+};
+
+// -------------------------- get cells -------------------------- //
+
+/**
+ * get Flickity.Cell, given an Element
+ * @param {Element} elem
+ * @returns {Flickity.Cell} item
+ */
+Flickity.prototype.getCell = function( elem ) {
+ // loop through cells to get the one that matches
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ if ( cell.element == elem ) {
+ return cell;
+ }
+ }
+};
+
+/**
+ * get collection of Flickity.Cells, given Elements
+ * @param {Element, Array, NodeList} elems
+ * @returns {Array} cells - Flickity.Cells
+ */
+Flickity.prototype.getCells = function( elems ) {
+ elems = utils.makeArray( elems );
+ var cells = [];
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ var cell = this.getCell( elem );
+ if ( cell ) {
+ cells.push( cell );
+ }
+ }
+ return cells;
+};
+
+/**
+ * get cell elements
+ * @returns {Array} cellElems
+ */
+Flickity.prototype.getCellElements = function() {
+ var cellElems = [];
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ cellElems.push( this.cells[i].element );
+ }
+ return cellElems;
+};
+
+/**
+ * get parent cell from an element
+ * @param {Element} elem
+ * @returns {Flickit.Cell} cell
+ */
+Flickity.prototype.getParentCell = function( elem ) {
+ // first check if elem is cell
+ var cell = this.getCell( elem );
+ if ( cell ) {
+ return cell;
+ }
+ // try to get parent cell elem
+ elem = utils.getParent( elem, '.flickity-slider > *' );
+ return this.getCell( elem );
+};
+
+// -------------------------- events -------------------------- //
+
+Flickity.prototype.uiChange = function() {
+ this.emit('uiChange');
+};
+
+Flickity.prototype.childUIPointerDown = function( event ) {
+ this.emitEvent( 'childUIPointerDown', [ event ] );
+};
+
+// ----- resize ----- //
+
+Flickity.prototype.onresize = function() {
+ this.watchCSS();
+ this.resize();
+};
+
+utils.debounceMethod( Flickity, 'onresize', 150 );
+
+Flickity.prototype.resize = function() {
+ if ( !this.isActive ) {
+ return;
+ }
+ this.getSize();
+ // wrap values
+ if ( this.options.wrapAround ) {
+ this.x = utils.modulo( this.x, this.slideableWidth );
+ }
+ this.positionCells();
+ this._getWrapShiftCells();
+ this.setGallerySize();
+ this.positionSliderAtSelected();
+};
+
+var supportsConditionalCSS = Flickity.supportsConditionalCSS = ( function() {
+ var supports;
+ return function checkSupport() {
+ if ( supports !== undefined ) {
+ return supports;
+ }
+ if ( !getComputedStyle ) {
+ supports = false;
+ return;
+ }
+ // style body's :after and check that
+ var style = document.createElement('style');
+ var cssText = document.createTextNode('body:after { content: "foo"; display: none; }');
+ style.appendChild( cssText );
+ document.head.appendChild( style );
+ var afterContent = getComputedStyle( document.body, ':after' ).content;
+ // check if able to get :after content
+ supports = afterContent.indexOf('foo') != -1;
+ document.head.removeChild( style );
+ return supports;
+ };
+})();
+
+// watches the :after property, activates/deactivates
+Flickity.prototype.watchCSS = function() {
+ var watchOption = this.options.watchCSS;
+ if ( !watchOption ) {
+ return;
+ }
+ var supports = supportsConditionalCSS();
+ if ( !supports ) {
+ // activate if watch option is fallbackOn
+ var method = watchOption == 'fallbackOn' ? 'activate' : 'deactivate';
+ this[ method ]();
+ return;
+ }
+
+ var afterContent = getComputedStyle( this.element, ':after' ).content;
+ // activate if :after { content: 'flickity' }
+ if ( afterContent.indexOf('flickity') != -1 ) {
+ this.activate();
+ } else {
+ this.deactivate();
+ }
+};
+
+// ----- keydown ----- //
+
+// go previous/next if left/right keys pressed
+Flickity.prototype.onkeydown = function( event ) {
+ // only work if element is in focus
+ if ( !this.options.accessibility ||
+ ( document.activeElement && document.activeElement != this.element ) ) {
+ return;
+ }
+
+ if ( event.keyCode == 37 ) {
+ // go left
+ var leftMethod = this.options.rightToLeft ? 'next' : 'previous';
+ this.uiChange();
+ this[ leftMethod ]();
+ } else if ( event.keyCode == 39 ) {
+ // go right
+ var rightMethod = this.options.rightToLeft ? 'previous' : 'next';
+ this.uiChange();
+ this[ rightMethod ]();
+ }
+};
+
+// -------------------------- destroy -------------------------- //
+
+// deactivate all Flickity functionality, but keep stuff available
+Flickity.prototype.deactivate = function() {
+ if ( !this.isActive ) {
+ return;
+ }
+ classie.remove( this.element, 'flickity-enabled' );
+ classie.remove( this.element, 'flickity-rtl' );
+ // destroy cells
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ cell.destroy();
+ }
+ this._removeSelectedCellClass();
+ this.element.removeChild( this.viewport );
+ // move child elements back into element
+ moveElements( this.slider.children, this.element );
+ if ( this.options.accessibility ) {
+ this.element.removeAttribute('tabIndex');
+ eventie.unbind( this.element, 'keydown', this );
+ }
+ // set flags
+ this.isActive = false;
+ this.emit('deactivate');
+};
+
+Flickity.prototype.destroy = function() {
+ this.deactivate();
+ if ( this.isResizeBound ) {
+ eventie.unbind( window, 'resize', this );
+ }
+ this.emit('destroy');
+ if ( jQuery && this.$element ) {
+ jQuery.removeData( this.element, 'flickity' );
+ }
+ delete this.element.flickityGUID;
+ delete instances[ this.guid ];
+};
+
+// -------------------------- prototype -------------------------- //
+
+utils.extend( Flickity.prototype, animatePrototype );
+
+// -------------------------- extras -------------------------- //
+
+// quick check for IE8
+var isIE8 = 'attachEvent' in window;
+
+Flickity.setUnselectable = function( elem ) {
+ if ( !isIE8 ) {
+ return;
+ }
+ // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183
+ elem.setAttribute( 'unselectable', 'on' );
+};
+
+/**
+ * get Flickity instance from element
+ * @param {Element} elem
+ * @returns {Flickity}
+ */
+Flickity.data = function( elem ) {
+ elem = utils.getQueryElement( elem );
+ var id = elem && elem.flickityGUID;
+ return id && instances[ id ];
+};
+
+utils.htmlInit( Flickity, 'flickity' );
+
+if ( jQuery && jQuery.bridget ) {
+ jQuery.bridget( 'flickity', Flickity );
+}
+
+Flickity.Cell = Cell;
+
+return Flickity;
+
+}));
+
+/*!
+ * Unipointer v1.1.0
+ * base class for doing one thing with pointer event
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true */
+/*global define: false, module: false, require: false */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'unipointer/unipointer',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie'
+ ], function( EventEmitter, eventie ) {
+ return factory( window, EventEmitter, eventie );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('wolfy87-eventemitter'),
+ require('eventie')
+ );
+ } else {
+ // browser global
+ window.Unipointer = factory(
+ window,
+ window.EventEmitter,
+ window.eventie
+ );
+ }
+
+}( window, function factory( window, EventEmitter, eventie ) {
+
+
+
+function noop() {}
+
+function Unipointer() {}
+
+// inherit EventEmitter
+Unipointer.prototype = new EventEmitter();
+
+Unipointer.prototype.bindStartEvent = function( elem ) {
+ this._bindStartEvent( elem, true );
+};
+
+Unipointer.prototype.unbindStartEvent = function( elem ) {
+ this._bindStartEvent( elem, false );
+};
+
+/**
+ * works as unbinder, as you can ._bindStart( false ) to unbind
+ * @param {Boolean} isBind - will unbind if falsey
+ */
+Unipointer.prototype._bindStartEvent = function( elem, isBind ) {
+ // munge isBind, default to true
+ isBind = isBind === undefined ? true : !!isBind;
+ var bindMethod = isBind ? 'bind' : 'unbind';
+
+ if ( window.navigator.pointerEnabled ) {
+ // W3C Pointer Events, IE11. See https://coderwall.com/p/mfreca
+ eventie[ bindMethod ]( elem, 'pointerdown', this );
+ } else if ( window.navigator.msPointerEnabled ) {
+ // IE10 Pointer Events
+ eventie[ bindMethod ]( elem, 'MSPointerDown', this );
+ } else {
+ // listen for both, for devices like Chrome Pixel
+ eventie[ bindMethod ]( elem, 'mousedown', this );
+ eventie[ bindMethod ]( elem, 'touchstart', this );
+ }
+};
+
+// trigger handler methods for events
+Unipointer.prototype.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+};
+
+// returns the touch that we're keeping track of
+Unipointer.prototype.getTouch = function( touches ) {
+ for ( var i=0, len = touches.length; i < len; i++ ) {
+ var touch = touches[i];
+ if ( touch.identifier == this.pointerIdentifier ) {
+ return touch;
+ }
+ }
+};
+
+// ----- start event ----- //
+
+Unipointer.prototype.onmousedown = function( event ) {
+ // dismiss clicks from right or middle buttons
+ var button = event.button;
+ if ( button && ( button !== 0 && button !== 1 ) ) {
+ return;
+ }
+ this._pointerDown( event, event );
+};
+
+Unipointer.prototype.ontouchstart = function( event ) {
+ this._pointerDown( event, event.changedTouches[0] );
+};
+
+Unipointer.prototype.onMSPointerDown =
+Unipointer.prototype.onpointerdown = function( event ) {
+ this._pointerDown( event, event );
+};
+
+/**
+ * pointer start
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unipointer.prototype._pointerDown = function( event, pointer ) {
+ // dismiss other pointers
+ if ( this.isPointerDown ) {
+ return;
+ }
+
+ this.isPointerDown = true;
+ // save pointer identifier to match up touch events
+ this.pointerIdentifier = pointer.pointerId !== undefined ?
+ // pointerId for pointer events, touch.indentifier for touch events
+ pointer.pointerId : pointer.identifier;
+
+ this.pointerDown( event, pointer );
+};
+
+Unipointer.prototype.pointerDown = function( event, pointer ) {
+ this._bindPostStartEvents( event );
+ this.emitEvent( 'pointerDown', [ event, pointer ] );
+};
+
+// hash of events to be bound after start event
+var postStartEvents = {
+ mousedown: [ 'mousemove', 'mouseup' ],
+ touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],
+ pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],
+ MSPointerDown: [ 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel' ]
+};
+
+Unipointer.prototype._bindPostStartEvents = function( event ) {
+ if ( !event ) {
+ return;
+ }
+ // get proper events to match start event
+ var events = postStartEvents[ event.type ];
+ // IE8 needs to be bound to document
+ var node = event.preventDefault ? window : document;
+ // bind events to node
+ for ( var i=0, len = events.length; i < len; i++ ) {
+ var evnt = events[i];
+ eventie.bind( node, evnt, this );
+ }
+ // save these arguments
+ this._boundPointerEvents = {
+ events: events,
+ node: node
+ };
+};
+
+Unipointer.prototype._unbindPostStartEvents = function() {
+ var args = this._boundPointerEvents;
+ // IE8 can trigger dragEnd twice, check for _boundEvents
+ if ( !args || !args.events ) {
+ return;
+ }
+
+ for ( var i=0, len = args.events.length; i < len; i++ ) {
+ var event = args.events[i];
+ eventie.unbind( args.node, event, this );
+ }
+ delete this._boundPointerEvents;
+};
+
+// ----- move event ----- //
+
+Unipointer.prototype.onmousemove = function( event ) {
+ this._pointerMove( event, event );
+};
+
+Unipointer.prototype.onMSPointerMove =
+Unipointer.prototype.onpointermove = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerMove( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchmove = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerMove( event, touch );
+ }
+};
+
+/**
+ * pointer move
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerMove = function( event, pointer ) {
+ this.pointerMove( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerMove = function( event, pointer ) {
+ this.emitEvent( 'pointerMove', [ event, pointer ] );
+};
+
+// ----- end event ----- //
+
+
+Unipointer.prototype.onmouseup = function( event ) {
+ this._pointerUp( event, event );
+};
+
+Unipointer.prototype.onMSPointerUp =
+Unipointer.prototype.onpointerup = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerUp( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchend = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerUp( event, touch );
+ }
+};
+
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerUp = function( event, pointer ) {
+ this._pointerDone();
+ this.pointerUp( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerUp = function( event, pointer ) {
+ this.emitEvent( 'pointerUp', [ event, pointer ] );
+};
+
+// ----- pointer done ----- //
+
+// triggered on pointer up & pointer cancel
+Unipointer.prototype._pointerDone = function() {
+ // reset properties
+ this.isPointerDown = false;
+ delete this.pointerIdentifier;
+ // remove events
+ this._unbindPostStartEvents();
+ this.pointerDone();
+};
+
+Unipointer.prototype.pointerDone = noop;
+
+// ----- pointer cancel ----- //
+
+Unipointer.prototype.onMSPointerCancel =
+Unipointer.prototype.onpointercancel = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerCancel( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchcancel = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerCancel( event, touch );
+ }
+};
+
+/**
+ * pointer cancel
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerCancel = function( event, pointer ) {
+ this._pointerDone();
+ this.pointerCancel( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerCancel = function( event, pointer ) {
+ this.emitEvent( 'pointerCancel', [ event, pointer ] );
+};
+
+// ----- ----- //
+
+// utility function for getting x/y cooridinates from event, because IE8
+Unipointer.getPointerPoint = function( pointer ) {
+ return {
+ x: pointer.pageX !== undefined ? pointer.pageX : pointer.clientX,
+ y: pointer.pageY !== undefined ? pointer.pageY : pointer.clientY
+ };
+};
+
+// ----- ----- //
+
+return Unipointer;
+
+}));
+
+/*!
+ * Unidragger v1.1.3
+ * Draggable base class
+ * MIT license
+ */
+
+/*jshint browser: true, unused: true, undef: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'unidragger/unidragger',[
+ 'eventie/eventie',
+ 'unipointer/unipointer'
+ ], function( eventie, Unipointer ) {
+ return factory( window, eventie, Unipointer );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('unipointer')
+ );
+ } else {
+ // browser global
+ window.Unidragger = factory(
+ window,
+ window.eventie,
+ window.Unipointer
+ );
+ }
+
+}( window, function factory( window, eventie, Unipointer ) {
+
+
+
+// ----- ----- //
+
+function noop() {}
+
+// handle IE8 prevent default
+function preventDefaultEvent( event ) {
+ if ( event.preventDefault ) {
+ event.preventDefault();
+ } else {
+ event.returnValue = false;
+ }
+}
+
+// -------------------------- Unidragger -------------------------- //
+
+function Unidragger() {}
+
+// inherit Unipointer & EventEmitter
+Unidragger.prototype = new Unipointer();
+
+// ----- bind start ----- //
+
+Unidragger.prototype.bindHandles = function() {
+ this._bindHandles( true );
+};
+
+Unidragger.prototype.unbindHandles = function() {
+ this._bindHandles( false );
+};
+
+var navigator = window.navigator;
+/**
+ * works as unbinder, as you can .bindHandles( false ) to unbind
+ * @param {Boolean} isBind - will unbind if falsey
+ */
+Unidragger.prototype._bindHandles = function( isBind ) {
+ // munge isBind, default to true
+ isBind = isBind === undefined ? true : !!isBind;
+ // extra bind logic
+ var binderExtra;
+ if ( navigator.pointerEnabled ) {
+ binderExtra = function( handle ) {
+ // disable scrolling on the element
+ handle.style.touchAction = isBind ? 'none' : '';
+ };
+ } else if ( navigator.msPointerEnabled ) {
+ binderExtra = function( handle ) {
+ // disable scrolling on the element
+ handle.style.msTouchAction = isBind ? 'none' : '';
+ };
+ } else {
+ binderExtra = function() {
+ // TODO re-enable img.ondragstart when unbinding
+ if ( isBind ) {
+ disableImgOndragstart( handle );
+ }
+ };
+ }
+ // bind each handle
+ var bindMethod = isBind ? 'bind' : 'unbind';
+ for ( var i=0, len = this.handles.length; i < len; i++ ) {
+ var handle = this.handles[i];
+ this._bindStartEvent( handle, isBind );
+ binderExtra( handle );
+ eventie[ bindMethod ]( handle, 'click', this );
+ }
+};
+
+// remove default dragging interaction on all images in IE8
+// IE8 does its own drag thing on images, which messes stuff up
+
+function noDragStart() {
+ return false;
+}
+
+// TODO replace this with a IE8 test
+var isIE8 = 'attachEvent' in document.documentElement;
+
+// IE8 only
+var disableImgOndragstart = !isIE8 ? noop : function( handle ) {
+
+ if ( handle.nodeName == 'IMG' ) {
+ handle.ondragstart = noDragStart;
+ }
+
+ var images = handle.querySelectorAll('img');
+ for ( var i=0, len = images.length; i < len; i++ ) {
+ var img = images[i];
+ img.ondragstart = noDragStart;
+ }
+};
+
+// ----- start event ----- //
+
+/**
+ * pointer start
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerDown = function( event, pointer ) {
+ this._dragPointerDown( event, pointer );
+ // kludge to blur focused inputs in dragger
+ var focused = document.activeElement;
+ if ( focused && focused.blur ) {
+ focused.blur();
+ }
+ // bind move and end events
+ this._bindPostStartEvents( event );
+ this.emitEvent( 'pointerDown', [ event, pointer ] );
+};
+
+// base pointer down logic
+Unidragger.prototype._dragPointerDown = function( event, pointer ) {
+ // track to see when dragging starts
+ this.pointerDownPoint = Unipointer.getPointerPoint( pointer );
+
+ // prevent default, unless touchstart or <select>
+ var isTouchstart = event.type == 'touchstart';
+ var targetNodeName = event.target.nodeName;
+ if ( !isTouchstart && targetNodeName != 'SELECT' ) {
+ preventDefaultEvent( event );
+ }
+};
+
+// ----- move event ----- //
+
+/**
+ * drag move
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerMove = function( event, pointer ) {
+ var moveVector = this._dragPointerMove( event, pointer );
+ this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );
+ this._dragMove( event, pointer, moveVector );
+};
+
+// base pointer move logic
+Unidragger.prototype._dragPointerMove = function( event, pointer ) {
+ var movePoint = Unipointer.getPointerPoint( pointer );
+ var moveVector = {
+ x: movePoint.x - this.pointerDownPoint.x,
+ y: movePoint.y - this.pointerDownPoint.y
+ };
+ // start drag if pointer has moved far enough to start drag
+ if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {
+ this._dragStart( event, pointer );
+ }
+ return moveVector;
+};
+
+// condition if pointer has moved far enough to start drag
+Unidragger.prototype.hasDragStarted = function( moveVector ) {
+ return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;
+};
+
+
+// ----- end event ----- //
+
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerUp = function( event, pointer ) {
+ this.emitEvent( 'pointerUp', [ event, pointer ] );
+ this._dragPointerUp( event, pointer );
+};
+
+Unidragger.prototype._dragPointerUp = function( event, pointer ) {
+ if ( this.isDragging ) {
+ this._dragEnd( event, pointer );
+ } else {
+ // pointer didn't move enough for drag to start
+ this._staticClick( event, pointer );
+ }
+};
+
+// -------------------------- drag -------------------------- //
+
+// dragStart
+Unidragger.prototype._dragStart = function( event, pointer ) {
+ this.isDragging = true;
+ this.dragStartPoint = Unidragger.getPointerPoint( pointer );
+ // prevent clicks
+ this.isPreventingClicks = true;
+
+ this.dragStart( event, pointer );
+};
+
+Unidragger.prototype.dragStart = function( event, pointer ) {
+ this.emitEvent( 'dragStart', [ event, pointer ] );
+};
+
+// dragMove
+Unidragger.prototype._dragMove = function( event, pointer, moveVector ) {
+ // do not drag if not dragging yet
+ if ( !this.isDragging ) {
+ return;
+ }
+
+ this.dragMove( event, pointer, moveVector );
+};
+
+Unidragger.prototype.dragMove = function( event, pointer, moveVector ) {
+ preventDefaultEvent( event );
+ this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );
+};
+
+// dragEnd
+Unidragger.prototype._dragEnd = function( event, pointer ) {
+ // set flags
+ this.isDragging = false;
+ // re-enable clicking async
+ var _this = this;
+ setTimeout( function() {
+ delete _this.isPreventingClicks;
+ });
+
+ this.dragEnd( event, pointer );
+};
+
+Unidragger.prototype.dragEnd = function( event, pointer ) {
+ this.emitEvent( 'dragEnd', [ event, pointer ] );
+};
+
+// ----- onclick ----- //
+
+// handle all clicks and prevent clicks when dragging
+Unidragger.prototype.onclick = function( event ) {
+ if ( this.isPreventingClicks ) {
+ preventDefaultEvent( event );
+ }
+};
+
+// ----- staticClick ----- //
+
+// triggered after pointer down & up with no/tiny movement
+Unidragger.prototype._staticClick = function( event, pointer ) {
+ // allow click in <input>s and <textarea>s
+ var nodeName = event.target.nodeName;
+ if ( nodeName == 'INPUT' || nodeName == 'TEXTAREA' ) {
+ event.target.focus();
+ }
+ this.staticClick( event, pointer );
+};
+
+Unidragger.prototype.staticClick = function( event, pointer ) {
+ this.emitEvent( 'staticClick', [ event, pointer ] );
+};
+
+// ----- ----- //
+
+Unidragger.getPointerPoint = function( pointer ) {
+ return {
+ x: pointer.pageX !== undefined ? pointer.pageX : pointer.clientX,
+ y: pointer.pageY !== undefined ? pointer.pageY : pointer.clientY
+ };
+};
+
+// ----- ----- //
+
+Unidragger.getPointerPoint = Unipointer.getPointerPoint;
+
+return Unidragger;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/drag',[
+ 'classie/classie',
+ 'eventie/eventie',
+ './flickity',
+ 'unidragger/unidragger',
+ 'fizzy-ui-utils/utils'
+ ], function( classie, eventie, Flickity, Unidragger, utils ) {
+ return factory( window, classie, eventie, Flickity, Unidragger, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('eventie'),
+ require('./flickity'),
+ require('unidragger'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.dragPrototype = factory(
+ window,
+ window.classie,
+ window.eventie,
+ window.Flickity,
+ window.Unidragger,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, classie, eventie, Flickity, Unidragger, utils ) {
+
+
+
+// handle IE8 prevent default
+function preventDefaultEvent( event ) {
+ if ( event.preventDefault ) {
+ event.preventDefault();
+ } else {
+ event.returnValue = false;
+ }
+}
+
+// ----- defaults ----- //
+
+utils.extend( Flickity.defaults, {
+ draggable: true,
+ touchVerticalScroll: true
+});
+
+// ----- create ----- //
+
+Flickity.createMethods.push('_createDrag');
+
+// -------------------------- drag prototype -------------------------- //
+
+var proto = {};
+utils.extend( proto, Unidragger.prototype );
+
+// -------------------------- -------------------------- //
+
+proto._createDrag = function() {
+ this.on( 'activate', this.bindDrag );
+ this.on( 'uiChange', this._uiChangeDrag );
+ this.on( 'childUIPointerDown', this._childUIPointerDownDrag );
+ this.on( 'deactivate', this.unbindDrag );
+};
+
+proto.bindDrag = function() {
+ if ( !this.options.draggable || this.isDragBound ) {
+ return;
+ }
+ classie.add( this.element, 'is-draggable' );
+ this.handles = [ this.viewport ];
+ this.bindHandles();
+ this.isDragBound = true;
+};
+
+proto.unbindDrag = function() {
+ if ( !this.isDragBound ) {
+ return;
+ }
+ classie.remove( this.element, 'is-draggable' );
+ this.unbindHandles();
+ delete this.isDragBound;
+};
+
+proto._uiChangeDrag = function() {
+ delete this.isFreeScrolling;
+};
+
+proto._childUIPointerDownDrag = function( event ) {
+ preventDefaultEvent( event );
+ this.pointerDownFocus( event );
+};
+
+// -------------------------- pointer events -------------------------- //
+
+proto.pointerDown = function( event, pointer ) {
+ this._dragPointerDown( event, pointer );
+
+ // kludge to blur focused inputs in dragger
+ var focused = document.activeElement;
+ if ( focused && focused.blur && focused != this.element &&
+ // do not blur body for IE9 & 10, #117
+ focused != document.body ) {
+ focused.blur();
+ }
+ this.pointerDownFocus( event );
+ // stop if it was moving
+ this.velocity = 0;
+ classie.add( this.viewport, 'is-pointer-down' );
+ // bind move and end events
+ this._bindPostStartEvents( event );
+ this.dispatchEvent( 'pointerDown', event, [ pointer ] );
+};
+
+var touchStartEvents = {
+ touchstart: true,
+ MSPointerDown: true
+};
+
+var focusNodes = {
+ INPUT: true,
+ SELECT: true
+};
+
+proto.pointerDownFocus = function( event ) {
+ // focus element, if not touch, and its not an input or select
+ if ( this.options.accessibility && !touchStartEvents[ event.type ] &&
+ !focusNodes[ event.target.nodeName ] ) {
+ this.element.focus();
+ }
+};
+
+// ----- move ----- //
+
+proto.pointerMove = function( event, pointer ) {
+ var moveVector = this._dragPointerMove( event, pointer );
+ this.touchVerticalScrollMove( event, pointer, moveVector );
+ this._dragMove( event, pointer, moveVector );
+ this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );
+};
+
+proto.hasDragStarted = function( moveVector ) {
+ return !this.isTouchScrolling && Math.abs( moveVector.x ) > 3;
+};
+
+// ----- up ----- //
+
+proto.pointerUp = function( event, pointer ) {
+ delete this.isTouchScrolling;
+ classie.remove( this.viewport, 'is-pointer-down' );
+ this.dispatchEvent( 'pointerUp', event, [ pointer ] );
+ this._dragPointerUp( event, pointer );
+};
+
+// -------------------------- vertical scroll -------------------------- //
+
+var touchScrollEvents = {
+ // move events
+ // mousemove: true,
+ touchmove: true,
+ MSPointerMove: true
+};
+
+// position of pointer, relative to window
+function getPointerWindowY( pointer ) {
+ var pointerPoint = Unidragger.getPointerPoint( pointer );
+ return pointerPoint.y - window.pageYOffset;
+}
+
+proto.touchVerticalScrollMove = function( event, pointer, moveVector ) {
+ // do not scroll if already dragging, if disabled
+ var touchVerticalScroll = this.options.touchVerticalScroll;
+ // if touchVerticalScroll is 'withDrag', allow scrolling and dragging
+ var canNotScroll = touchVerticalScroll == 'withDrag' ? !touchVerticalScroll :
+ this.isDragging || !touchVerticalScroll;
+ if ( canNotScroll || !touchScrollEvents[ event.type ] ) {
+ return;
+ }
+ // don't start vertical scrolling until pointer has moved 10 pixels in a direction
+ if ( !this.isTouchScrolling && Math.abs( moveVector.y ) > 10 ) {
+ // start touch vertical scrolling
+ // scroll & pointerY when started
+ this.startScrollY = window.pageYOffset;
+ this.pointerWindowStartY = getPointerWindowY( pointer );
+ // start scroll animation
+ this.isTouchScrolling = true;
+ }
+};
+
+// -------------------------- dragging -------------------------- //
+
+proto.dragStart = function( event, pointer ) {
+ this.dragStartPosition = this.x;
+ this.startAnimation();
+ this.dispatchEvent( 'dragStart', event, [ pointer ] );
+};
+
+proto.dragMove = function( event, pointer, moveVector ) {
+ preventDefaultEvent( event );
+
+ this.previousDragX = this.x;
+
+ var movedX = moveVector.x;
+ // reverse if right-to-left
+ var direction = this.options.rightToLeft ? -1 : 1;
+ this.x = this.dragStartPosition + movedX * direction;
+
+ if ( !this.options.wrapAround && this.cells.length ) {
+ // slow drag
+ var originBound = Math.max( -this.cells[0].target, this.dragStartPosition);
+ this.x = this.x > originBound ? ( this.x - originBound ) * 0.5 + originBound : this.x;
+ var endBound = Math.min( -this.getLastCell().target, this.dragStartPosition );
+ this.x = this.x < endBound ? ( this.x - endBound ) * 0.5 + endBound : this.x;
+ }
+
+ this.previousDragMoveTime = this.dragMoveTime;
+ this.dragMoveTime = new Date();
+ this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );
+};
+
+proto.dragEnd = function( event, pointer ) {
+ this.dragEndFlick();
+ if ( this.options.freeScroll ) {
+ this.isFreeScrolling = true;
+ }
+ // set selectedIndex based on where flick will end up
+ var index = this.dragEndRestingSelect();
+
+ if ( this.options.freeScroll && !this.options.wrapAround ) {
+ // if free-scroll & not wrap around
+ // do not free-scroll if going outside of bounding cells
+ // so bounding cells can attract slider, and keep it in bounds
+ var restingX = this.getRestingPosition();
+ this.isFreeScrolling = -restingX > this.cells[0].target &&
+ -restingX < this.getLastCell().target;
+ } else if ( !this.options.freeScroll && index == this.selectedIndex ) {
+ // boost selection if selected index has not changed
+ index += this.dragEndBoostSelect();
+ }
+ // apply selection
+ // TODO refactor this, selecting here feels weird
+ this.select( index );
+ this.dispatchEvent( 'dragEnd', event, [ pointer ] );
+};
+
+// apply velocity after dragging
+proto.dragEndFlick = function() {
+ if ( !isFinite( this.previousDragX ) ) {
+ return;
+ }
+ // set slider velocity
+ var timeDelta = this.dragMoveTime - this.previousDragMoveTime;
+ // prevent divide by 0, if dragMove & dragEnd happened at same time
+ if ( timeDelta ) {
+ // 60 frames per second, ideally
+ // TODO, velocity should be in pixels per millisecond
+ // currently in pixels per frame
+ timeDelta /= 1000 / 60;
+ var xDelta = this.x - this.previousDragX;
+ this.velocity = xDelta / timeDelta;
+ }
+ // reset
+ delete this.previousDragX;
+};
+
+proto.dragEndRestingSelect = function() {
+ var restingX = this.getRestingPosition();
+ // how far away from selected cell
+ var distance = Math.abs( this.getCellDistance( -restingX, this.selectedIndex ) );
+ // get closet resting going up and going down
+ var positiveResting = this._getClosestResting( restingX, distance, 1 );
+ var negativeResting = this._getClosestResting( restingX, distance, -1 );
+ // use closer resting for wrap-around
+ var index = positiveResting.distance < negativeResting.distance ?
+ positiveResting.index : negativeResting.index;
+ // for contain, force boost if delta is not greater than 1
+ if ( this.options.contain && !this.options.wrapAround ) {
+ index = Math.abs( index - this.selectedIndex ) <= 1 ? this.selectedIndex : index;
+ }
+ return index;
+};
+
+/**
+ * given resting X and distance to selected cell
+ * get the distance and index of the closest cell
+ * @param {Number} restingX - estimated post-flick resting position
+ * @param {Number} distance - distance to selected cell
+ * @param {Integer} increment - +1 or -1, going up or down
+ * @returns {Object} - { distance: {Number}, index: {Integer} }
+ */
+proto._getClosestResting = function( restingX, distance, increment ) {
+ var index = this.selectedIndex;
+ var minDistance = Infinity;
+ var condition = this.options.contain && !this.options.wrapAround ?
+ // if contain, keep going if distance is equal to minDistance
+ function( d, md ) { return d <= md; } : function( d, md ) { return d < md; };
+ while ( condition( distance, minDistance ) ) {
+ // measure distance to next cell
+ index += increment;
+ minDistance = distance;
+ distance = this.getCellDistance( -restingX, index );
+ if ( distance === null ) {
+ break;
+ }
+ distance = Math.abs( distance );
+ }
+ return {
+ distance: minDistance,
+ // selected was previous index
+ index: index - increment
+ };
+};
+
+/**
+ * measure distance between x and a cell target
+ * @param {Number} x
+ * @param {Integer} index - cell index
+ */
+proto.getCellDistance = function( x, index ) {
+ var len = this.cells.length;
+ // wrap around if at least 2 cells
+ var isWrapAround = this.options.wrapAround && len > 1;
+ var cellIndex = isWrapAround ? utils.modulo( index, len ) : index;
+ var cell = this.cells[ cellIndex ];
+ if ( !cell ) {
+ return null;
+ }
+ // add distance for wrap-around cells
+ var wrap = isWrapAround ? this.slideableWidth * Math.floor( index / len ) : 0;
+ return x - ( cell.target + wrap );
+};
+
+proto.dragEndBoostSelect = function() {
+ var distance = this.getCellDistance( -this.x, this.selectedIndex );
+ if ( distance > 0 && this.velocity < -1 ) {
+ // if moving towards the right, and positive velocity, and the next attractor
+ return 1;
+ } else if ( distance < 0 && this.velocity > 1 ) {
+ // if moving towards the left, and negative velocity, and previous attractor
+ return -1;
+ }
+ return 0;
+};
+
+// ----- staticClick ----- //
+
+proto.staticClick = function( event, pointer ) {
+ // get clickedCell, if cell was clicked
+ var clickedCell = this.getParentCell( event.target );
+ var cellElem = clickedCell && clickedCell.element;
+ var cellIndex = clickedCell && utils.indexOf( this.cells, clickedCell );
+ this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] );
+};
+
+// ----- ----- //
+
+utils.extend( Flickity.prototype, proto );
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/*!
+ * Tap listener v1.1.0
+ * listens to taps
+ * MIT license
+ */
+
+/*jshint browser: true, unused: true, undef: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'tap-listener/tap-listener',[
+ 'unipointer/unipointer'
+ ], function( Unipointer ) {
+ return factory( window, Unipointer );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('unipointer')
+ );
+ } else {
+ // browser global
+ window.TapListener = factory(
+ window,
+ window.Unipointer
+ );
+ }
+
+}( window, function factory( window, Unipointer ) {
+
+
+
+// -------------------------- TapListener -------------------------- //
+
+function TapListener( elem ) {
+ this.bindTap( elem );
+}
+
+// inherit Unipointer & EventEmitter
+TapListener.prototype = new Unipointer();
+
+/**
+ * bind tap event to element
+ * @param {Element} elem
+ */
+TapListener.prototype.bindTap = function( elem ) {
+ if ( !elem ) {
+ return;
+ }
+ this.unbindTap();
+ this.tapElement = elem;
+ this._bindStartEvent( elem, true );
+};
+
+TapListener.prototype.unbindTap = function() {
+ if ( !this.tapElement ) {
+ return;
+ }
+ this._bindStartEvent( this.tapElement, true );
+ delete this.tapElement;
+};
+
+var isPageOffset = window.pageYOffset !== undefined;
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+TapListener.prototype.pointerUp = function( event, pointer ) {
+ var pointerPoint = Unipointer.getPointerPoint( pointer );
+ var boundingRect = this.tapElement.getBoundingClientRect();
+ // standard or IE8 scroll positions
+ var scrollX = isPageOffset ? window.pageXOffset : document.body.scrollLeft;
+ var scrollY = isPageOffset ? window.pageYOffset : document.body.scrollTop;
+ // calculate if pointer is inside tapElement
+ var isInside = pointerPoint.x >= boundingRect.left + scrollX &&
+ pointerPoint.x <= boundingRect.right + scrollX &&
+ pointerPoint.y >= boundingRect.top + scrollY &&
+ pointerPoint.y <= boundingRect.bottom + scrollY;
+ // trigger callback if pointer is inside element
+ if ( isInside ) {
+ this.emitEvent( 'tap', [ event, pointer ] );
+ }
+};
+
+TapListener.prototype.destroy = function() {
+ this.pointerDone();
+ this.unbindTap();
+};
+
+// ----- ----- //
+
+return TapListener;
+
+}));
+
+// -------------------------- prev/next button -------------------------- //
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/prev-next-button',[
+ 'eventie/eventie',
+ './flickity',
+ 'tap-listener/tap-listener',
+ 'fizzy-ui-utils/utils'
+ ], function( eventie, Flickity, TapListener, utils ) {
+ return factory( window, eventie, Flickity, TapListener, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('./flickity'),
+ require('tap-listener'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.PrevNextButton = factory(
+ window,
+ window.eventie,
+ window.Flickity,
+ window.TapListener,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, eventie, Flickity, TapListener, utils ) {
+
+
+
+// ----- inline SVG support ----- //
+
+var svgURI = 'http://www.w3.org/2000/svg';
+
+// only check on demand, not on script load
+var supportsInlineSVG = ( function() {
+ var supports;
+ function checkSupport() {
+ if ( supports !== undefined ) {
+ return supports;
+ }
+ var div = document.createElement('div');
+ div.innerHTML = '<svg/>';
+ supports = ( div.firstChild && div.firstChild.namespaceURI ) == svgURI;
+ return supports;
+ }
+ return checkSupport;
+})();
+
+// -------------------------- PrevNextButton -------------------------- //
+
+function PrevNextButton( direction, parent ) {
+ this.direction = direction;
+ this.parent = parent;
+ this._create();
+}
+
+PrevNextButton.prototype = new TapListener();
+
+PrevNextButton.prototype._create = function() {
+ // properties
+ this.isEnabled = true;
+ this.isPrevious = this.direction == -1;
+ var leftDirection = this.parent.options.rightToLeft ? 1 : -1;
+ this.isLeft = this.direction == leftDirection;
+
+ var element = this.element = document.createElement('button');
+ element.className = 'flickity-prev-next-button';
+ element.className += this.isPrevious ? ' previous' : ' next';
+ // prevent button from submitting form http://stackoverflow.com/a/10836076/182183
+ element.setAttribute( 'type', 'button' );
+ Flickity.setUnselectable( element );
+ // create arrow
+ if ( supportsInlineSVG() ) {
+ var svg = this.createSVG();
+ element.appendChild( svg );
+ } else {
+ // SVG not supported, set button text
+ this.setArrowText();
+ element.className += ' no-svg';
+ }
+ // update on select
+ var _this = this;
+ this.onCellSelect = function() {
+ _this.update();
+ };
+ this.parent.on( 'cellSelect', this.onCellSelect );
+ // tap
+ this.on( 'tap', this.onTap );
+ // pointerDown
+ this.on( 'pointerDown', function onPointerDown( button, event ) {
+ _this.parent.childUIPointerDown( event );
+ });
+};
+
+PrevNextButton.prototype.activate = function() {
+ this.update();
+ this.bindTap( this.element );
+ // click events from keyboard
+ eventie.bind( this.element, 'click', this );
+ // add to DOM
+ this.parent.element.appendChild( this.element );
+};
+
+PrevNextButton.prototype.deactivate = function() {
+ // remove from DOM
+ this.parent.element.removeChild( this.element );
+ // do regular TapListener destroy
+ TapListener.prototype.destroy.call( this );
+ // click events from keyboard
+ eventie.unbind( this.element, 'click', this );
+};
+
+PrevNextButton.prototype.createSVG = function() {
+ var svg = document.createElementNS( svgURI, 'svg');
+ svg.setAttribute( 'viewBox', '0 0 100 100' );
+ var path = document.createElementNS( svgURI, 'path');
+ path.setAttribute( 'd', 'M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z' );
+ path.setAttribute( 'class', 'arrow' );
+ // adjust arrow
+ var arrowTransform = this.isLeft ? 'translate(15,0)' :
+ 'translate(85,100) rotate(180)';
+ path.setAttribute( 'transform', arrowTransform );
+ svg.appendChild( path );
+ return svg;
+};
+
+PrevNextButton.prototype.setArrowText = function() {
+ var parentOptions = this.parent.options;
+ var arrowText = this.isLeft ? parentOptions.leftArrowText : parentOptions.rightArrowText;
+ utils.setText( this.element, arrowText );
+};
+
+PrevNextButton.prototype.onTap = function() {
+ if ( !this.isEnabled ) {
+ return;
+ }
+ this.parent.uiChange();
+ var method = this.isPrevious ? 'previous' : 'next';
+ this.parent[ method ]();
+};
+
+PrevNextButton.prototype.handleEvent = utils.handleEvent;
+
+PrevNextButton.prototype.onclick = function() {
+ // only allow clicks from keyboard
+ var focused = document.activeElement;
+ if ( focused && focused == this.element ) {
+ this.onTap();
+ }
+};
+
+// ----- ----- //
+
+PrevNextButton.prototype.enable = function() {
+ if ( this.isEnabled ) {
+ return;
+ }
+ this.element.disabled = false;
+ this.isEnabled = true;
+};
+
+PrevNextButton.prototype.disable = function() {
+ if ( !this.isEnabled ) {
+ return;
+ }
+ this.element.disabled = true;
+ this.isEnabled = false;
+};
+
+PrevNextButton.prototype.update = function() {
+ // index of first or last cell, if previous or next
+ var cells = this.parent.cells;
+ // enable is wrapAround and at least 2 cells
+ if ( this.parent.options.wrapAround && cells.length > 1 ) {
+ this.enable();
+ return;
+ }
+ var lastIndex = cells.length ? cells.length - 1 : 0;
+ var boundIndex = this.isPrevious ? 0 : lastIndex;
+ var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable';
+ this[ method ]();
+};
+
+PrevNextButton.prototype.destroy = function() {
+ this.deactivate();
+};
+
+// -------------------------- Flickity prototype -------------------------- //
+
+utils.extend( Flickity.defaults, {
+ prevNextButtons: true,
+ leftArrowText: '‹',
+ rightArrowText: '›'
+});
+
+Flickity.createMethods.push('_createPrevNextButtons');
+
+Flickity.prototype._createPrevNextButtons = function() {
+ if ( !this.options.prevNextButtons ) {
+ return;
+ }
+
+ this.prevButton = new PrevNextButton( -1, this );
+ this.nextButton = new PrevNextButton( 1, this );
+
+ this.on( 'activate', this.activatePrevNextButtons );
+};
+
+Flickity.prototype.activatePrevNextButtons = function() {
+ this.prevButton.activate();
+ this.nextButton.activate();
+ this.on( 'deactivate', this.deactivatePrevNextButtons );
+};
+
+Flickity.prototype.deactivatePrevNextButtons = function() {
+ this.prevButton.deactivate();
+ this.nextButton.deactivate();
+ this.off( 'deactivate', this.deactivatePrevNextButtons );
+};
+
+// -------------------------- -------------------------- //
+
+Flickity.PrevNextButton = PrevNextButton;
+
+return PrevNextButton;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/page-dots',[
+ 'eventie/eventie',
+ './flickity',
+ 'tap-listener/tap-listener',
+ 'fizzy-ui-utils/utils'
+ ], function( eventie, Flickity, TapListener, utils ) {
+ return factory( window, eventie, Flickity, TapListener, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('./flickity'),
+ require('tap-listener'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.PageDots = factory(
+ window,
+ window.eventie,
+ window.Flickity,
+ window.TapListener,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, eventie, Flickity, TapListener, utils ) {
+
+// -------------------------- PageDots -------------------------- //
+
+
+
+function PageDots( parent ) {
+ this.parent = parent;
+ this._create();
+}
+
+PageDots.prototype = new TapListener();
+
+PageDots.prototype._create = function() {
+ // create holder element
+ this.holder = document.createElement('ol');
+ this.holder.className = 'flickity-page-dots';
+ Flickity.setUnselectable( this.holder );
+ // create dots, array of elements
+ this.dots = [];
+ // update on select
+ var _this = this;
+ this.onCellSelect = function() {
+ _this.updateSelected();
+ };
+ this.parent.on( 'cellSelect', this.onCellSelect );
+ // tap
+ this.on( 'tap', this.onTap );
+ // pointerDown
+ this.on( 'pointerDown', function onPointerDown( button, event ) {
+ _this.parent.childUIPointerDown( event );
+ });
+};
+
+PageDots.prototype.activate = function() {
+ this.setDots();
+ this.updateSelected();
+ this.bindTap( this.holder );
+ // add to DOM
+ this.parent.element.appendChild( this.holder );
+};
+
+PageDots.prototype.deactivate = function() {
+ // remove from DOM
+ this.parent.element.removeChild( this.holder );
+ TapListener.prototype.destroy.call( this );
+};
+
+PageDots.prototype.setDots = function() {
+ // get difference between number of cells and number of dots
+ var delta = this.parent.cells.length - this.dots.length;
+ if ( delta > 0 ) {
+ this.addDots( delta );
+ } else if ( delta < 0 ) {
+ this.removeDots( -delta );
+ }
+};
+
+PageDots.prototype.addDots = function( count ) {
+ var fragment = document.createDocumentFragment();
+ var newDots = [];
+ while ( count ) {
+ var dot = document.createElement('li');
+ dot.className = 'dot';
+ fragment.appendChild( dot );
+ newDots.push( dot );
+ count--;
+ }
+ this.holder.appendChild( fragment );
+ this.dots = this.dots.concat( newDots );
+};
+
+PageDots.prototype.removeDots = function( count ) {
+ // remove from this.dots collection
+ var removeDots = this.dots.splice( this.dots.length - count, count );
+ // remove from DOM
+ for ( var i=0, len = removeDots.length; i < len; i++ ) {
+ var dot = removeDots[i];
+ this.holder.removeChild( dot );
+ }
+};
+
+PageDots.prototype.updateSelected = function() {
+ // remove selected class on previous
+ if ( this.selectedDot ) {
+ this.selectedDot.className = 'dot';
+ }
+ // don't proceed if no dots
+ if ( !this.dots.length ) {
+ return;
+ }
+ this.selectedDot = this.dots[ this.parent.selectedIndex ];
+ this.selectedDot.className = 'dot is-selected';
+};
+
+PageDots.prototype.onTap = function( event ) {
+ var target = event.target;
+ // only care about dot clicks
+ if ( target.nodeName != 'LI' ) {
+ return;
+ }
+
+ this.parent.uiChange();
+ var index = utils.indexOf( this.dots, target );
+ this.parent.select( index );
+};
+
+PageDots.prototype.destroy = function() {
+ this.deactivate();
+};
+
+Flickity.PageDots = PageDots;
+
+// -------------------------- Flickity -------------------------- //
+
+utils.extend( Flickity.defaults, {
+ pageDots: true
+});
+
+Flickity.createMethods.push('_createPageDots');
+
+Flickity.prototype._createPageDots = function() {
+ if ( !this.options.pageDots ) {
+ return;
+ }
+ this.pageDots = new PageDots( this );
+ this.on( 'activate', this.activatePageDots );
+ this.on( 'cellAddedRemoved', this.onCellAddedRemovedPageDots );
+ this.on( 'deactivate', this.deactivatePageDots );
+};
+
+Flickity.prototype.activatePageDots = function() {
+ this.pageDots.activate();
+};
+
+Flickity.prototype.onCellAddedRemovedPageDots = function() {
+ this.pageDots.setDots();
+};
+
+Flickity.prototype.deactivatePageDots = function() {
+ this.pageDots.deactivate();
+};
+
+// ----- ----- //
+
+Flickity.PageDots = PageDots;
+
+return PageDots;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/player',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie',
+ './flickity'
+ ], function( EventEmitter, eventie, Flickity ) {
+ return factory( EventEmitter, eventie, Flickity );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ require('wolfy87-eventemitter'),
+ require('eventie'),
+ require('./flickity')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.Player = factory(
+ window.EventEmitter,
+ window.eventie,
+ window.Flickity
+ );
+ }
+
+}( window, function factory( EventEmitter, eventie, Flickity ) {
+
+
+
+// -------------------------- Page Visibility -------------------------- //
+// https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API
+
+var hiddenProperty, visibilityEvent;
+if ( 'hidden' in document ) {
+ hiddenProperty = 'hidden';
+ visibilityEvent = 'visibilitychange';
+} else if ( 'webkitHidden' in document ) {
+ hiddenProperty = 'webkitHidden';
+ visibilityEvent = 'webkitvisibilitychange';
+}
+
+// -------------------------- Player -------------------------- //
+
+function Player( parent ) {
+ this.isPlaying = false;
+ this.parent = parent;
+ // visibility change event handler
+ if ( visibilityEvent ) {
+ var _this = this;
+ this.onVisibilityChange = function() {
+ _this.visibilityChange();
+ };
+ }
+}
+
+Player.prototype = new EventEmitter();
+
+// start play
+Player.prototype.play = function() {
+ this.isPlaying = true;
+ // playing kills pauses
+ delete this.isPaused;
+ // listen to visibility change
+ if ( visibilityEvent ) {
+ document.addEventListener( visibilityEvent, this.onVisibilityChange, false );
+ }
+ // start ticking
+ this.tick();
+};
+
+Player.prototype.tick = function() {
+ // do not tick if paused or not playing
+ if ( !this.isPlaying || this.isPaused ) {
+ return;
+ }
+ // keep track of when .tick()
+ this.tickTime = new Date();
+ var time = this.parent.options.autoPlay;
+ // default to 3 seconds
+ time = typeof time == 'number' ? time : 3000;
+ var _this = this;
+ this.timeout = setTimeout( function() {
+ _this.parent.next( true );
+ _this.tick();
+ }, time );
+};
+
+Player.prototype.stop = function() {
+ this.isPlaying = false;
+ // stopping kills pauses
+ delete this.isPaused;
+ this.clear();
+ // remove visibility change event
+ if ( visibilityEvent ) {
+ document.removeEventListener( visibilityEvent, this.onVisibilityChange, false );
+ }
+};
+
+Player.prototype.clear = function() {
+ clearTimeout( this.timeout );
+};
+
+Player.prototype.pause = function() {
+ if ( this.isPlaying ) {
+ this.isPaused = true;
+ this.clear();
+ }
+};
+
+Player.prototype.unpause = function() {
+ // re-start play if in unpaused state
+ if ( this.isPaused ) {
+ this.play();
+ }
+};
+
+// pause if page visibility is hidden, unpause if visible
+Player.prototype.visibilityChange = function() {
+ var isHidden = document[ hiddenProperty ];
+ this[ isHidden ? 'pause' : 'unpause' ]();
+};
+
+// -------------------------- Flickity -------------------------- //
+
+// utils.extend( Flickity.defaults, {
+// autoPlay: false
+// });
+
+Flickity.createMethods.push('_createPlayer');
+
+Flickity.prototype._createPlayer = function() {
+ this.player = new Player( this );
+
+ this.on( 'activate', this.activatePlayer );
+ this.on( 'uiChange', this.stopPlayer );
+ this.on( 'pointerDown', this.stopPlayer );
+ this.on( 'deactivate', this.deactivatePlayer );
+};
+
+Flickity.prototype.activatePlayer = function() {
+ if ( !this.options.autoPlay ) {
+ return;
+ }
+ this.player.play();
+ eventie.bind( this.element, 'mouseenter', this );
+ this.isMouseenterBound = true;
+};
+
+Flickity.prototype.stopPlayer = function() {
+ this.player.stop();
+};
+
+Flickity.prototype.deactivatePlayer = function() {
+ this.player.stop();
+ if ( this.isMouseenterBound ) {
+ eventie.unbind( this.element, 'mouseenter', this );
+ delete this.isMouseenterBound;
+ }
+};
+
+// ----- mouseenter/leave ----- //
+
+// pause auto-play on hover
+Flickity.prototype.onmouseenter = function() {
+ this.player.pause();
+ eventie.bind( this.element, 'mouseleave', this );
+};
+
+// resume auto-play on hover off
+Flickity.prototype.onmouseleave = function() {
+ this.player.unpause();
+ eventie.unbind( this.element, 'mouseleave', this );
+};
+
+// ----- ----- //
+
+Flickity.Player = Player;
+
+return Player;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/add-remove-cell',[
+ './flickity',
+ 'fizzy-ui-utils/utils'
+ ], function( Flickity, utils ) {
+ return factory( window, Flickity, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('./flickity'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity = factory(
+ window,
+ window.Flickity,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, Flickity, utils ) {
+
+
+
+// append cells to a document fragment
+function getCellsFragment( cells ) {
+ var fragment = document.createDocumentFragment();
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ fragment.appendChild( cell.element );
+ }
+ return fragment;
+}
+
+// -------------------------- add/remove cell prototype -------------------------- //
+
+/**
+ * Insert, prepend, or append cells
+ * @param {Element, Array, NodeList} elems
+ * @param {Integer} index
+ */
+Flickity.prototype.insert = function( elems, index ) {
+ var cells = this._makeCells( elems );
+ if ( !cells || !cells.length ) {
+ return;
+ }
+ var len = this.cells.length;
+ // default to append
+ index = index === undefined ? len : index;
+ // add cells with document fragment
+ var fragment = getCellsFragment( cells );
+ // append to slider
+ var isAppend = index == len;
+ if ( isAppend ) {
+ this.slider.appendChild( fragment );
+ } else {
+ var insertCellElement = this.cells[ index ].element;
+ this.slider.insertBefore( fragment, insertCellElement );
+ }
+ // add to this.cells
+ if ( index === 0 ) {
+ // prepend, add to start
+ this.cells = cells.concat( this.cells );
+ } else if ( isAppend ) {
+ // append, add to end
+ this.cells = this.cells.concat( cells );
+ } else {
+ // insert in this.cells
+ var endCells = this.cells.splice( index, len - index );
+ this.cells = this.cells.concat( cells ).concat( endCells );
+ }
+
+ this._sizeCells( cells );
+
+ var selectedIndexDelta = index > this.selectedIndex ? 0 : cells.length;
+ this._cellAddedRemoved( index, selectedIndexDelta );
+};
+
+Flickity.prototype.append = function( elems ) {
+ this.insert( elems, this.cells.length );
+};
+
+Flickity.prototype.prepend = function( elems ) {
+ this.insert( elems, 0 );
+};
+
+/**
+ * Remove cells
+ * @param {Element, Array, NodeList} elems
+ */
+Flickity.prototype.remove = function( elems ) {
+ var cells = this.getCells( elems );
+ var selectedIndexDelta = 0;
+ var i, len, cell;
+ // calculate selectedIndexDelta, easier if done in seperate loop
+ for ( i=0, len = cells.length; i < len; i++ ) {
+ cell = cells[i];
+ var wasBefore = utils.indexOf( this.cells, cell ) < this.selectedIndex;
+ selectedIndexDelta -= wasBefore ? 1 : 0;
+ }
+
+ for ( i=0, len = cells.length; i < len; i++ ) {
+ cell = cells[i];
+ cell.remove();
+ // remove item from collection
+ utils.removeFrom( this.cells, cell );
+ }
+
+ if ( cells.length ) {
+ // update stuff
+ this._cellAddedRemoved( 0, selectedIndexDelta );
+ }
+};
+
+// updates when cells are added or removed
+Flickity.prototype._cellAddedRemoved = function( changedCellIndex, selectedIndexDelta ) {
+ selectedIndexDelta = selectedIndexDelta || 0;
+ this.selectedIndex += selectedIndexDelta;
+ this.selectedIndex = Math.max( 0, Math.min( this.cells.length - 1, this.selectedIndex ) );
+
+ this.emitEvent( 'cellAddedRemoved', [ changedCellIndex, selectedIndexDelta ] );
+ this.cellChange( changedCellIndex );
+};
+
+/**
+ * logic to be run after a cell's size changes
+ * @param {Element} elem - cell's element
+ */
+Flickity.prototype.cellSizeChange = function( elem ) {
+ var cell = this.getCell( elem );
+ if ( !cell ) {
+ return;
+ }
+ cell.getSize();
+
+ var index = utils.indexOf( this.cells, cell );
+ this.cellChange( index );
+};
+
+/**
+ * logic any time a cell is changed: added, removed, or size changed
+ * @param {Integer} changedCellIndex - index of the changed cell, optional
+ */
+Flickity.prototype.cellChange = function( changedCellIndex ) {
+ // TODO maybe always size all cells unless isSkippingSizing
+ // size all cells if necessary
+ // if ( !isSkippingSizing ) {
+ // this._sizeCells( this.cells );
+ // }
+
+ changedCellIndex = changedCellIndex || 0;
+
+ this._positionCells( changedCellIndex );
+ this._getWrapShiftCells();
+ this.setGallerySize();
+ // position slider
+ if ( this.options.freeScroll ) {
+ this.positionSlider();
+ } else {
+ this.positionSliderAtSelected();
+ this.select( this.selectedIndex );
+ }
+};
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/**
+ * Flickity index
+ * used for AMD and CommonJS exports
+ */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/index',[
+ './flickity',
+ './drag',
+ './prev-next-button',
+ './page-dots',
+ './player',
+ './add-remove-cell'
+ ], factory );
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ require('./flickity'),
+ require('./drag'),
+ require('./prev-next-button'),
+ require('./page-dots'),
+ require('./player'),
+ require('./add-remove-cell')
+ );
+ }
+
+})( window, function factory( Flickity ) {
+ /*jshint strict: false*/
+ return Flickity;
+});
+
+/*!
+ * Flickity asNavFor v1.0.1
+ * enable asNavFor for Flickity
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true*/
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity-as-nav-for/as-nav-for',[
+ 'classie/classie',
+ 'flickity/js/index',
+ 'fizzy-ui-utils/utils'
+ ], function( classie, Flickity, utils ) {
+ return factory( window, classie, Flickity, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('flickity'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = factory(
+ window,
+ window.classie,
+ window.Flickity,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, classie, Flickity, utils ) {
+
+
+
+// -------------------------- asNavFor prototype -------------------------- //
+
+// Flickity.defaults.asNavFor = null;
+
+Flickity.createMethods.push('_createAsNavFor');
+
+Flickity.prototype._createAsNavFor = function() {
+ this.on( 'activate', this.activateAsNavFor );
+ this.on( 'deactivate', this.deactivateAsNavFor );
+ this.on( 'destroy', this.destroyAsNavFor );
+
+ var asNavForOption = this.options.asNavFor;
+ if ( !asNavForOption ) {
+ return;
+ }
+ // HACK do async, give time for other flickity to be initalized
+ var _this = this;
+ setTimeout( function initNavCompanion() {
+ _this.setNavCompanion( asNavForOption );
+ });
+};
+
+Flickity.prototype.setNavCompanion = function( elem ) {
+ elem = utils.getQueryElement( elem );
+ var companion = Flickity.data( elem );
+ // stop if no companion or companion is self
+ if ( !companion || companion == this ) {
+ return;
+ }
+
+ this.navCompanion = companion;
+ // companion select
+ var _this = this;
+ this.onNavCompanionSelect = function() {
+ _this.navCompanionSelect();
+ };
+ companion.on( 'cellSelect', this.onNavCompanionSelect );
+ // click
+ this.on( 'staticClick', this.onNavStaticClick );
+
+ this.navCompanionSelect();
+};
+
+Flickity.prototype.navCompanionSelect = function() {
+ if ( !this.navCompanion ) {
+ return;
+ }
+ var index = this.navCompanion.selectedIndex;
+ this.select( index );
+ // set nav selected class
+ this.removeNavSelectedElement();
+ // stop if companion has more cells than this one
+ if ( this.selectedIndex != index ) {
+ return;
+ }
+ this.navSelectedElement = this.cells[ index ].element;
+ classie.add( this.navSelectedElement, 'is-nav-selected' );
+};
+
+Flickity.prototype.activateAsNavFor = function() {
+ this.navCompanionSelect();
+};
+
+Flickity.prototype.removeNavSelectedElement = function() {
+ if ( !this.navSelectedElement ) {
+ return;
+ }
+ classie.remove( this.navSelectedElement, 'is-nav-selected' );
+ delete this.navSelectedElement;
+};
+
+Flickity.prototype.onNavStaticClick = function( event, pointer, cellElement, cellIndex ) {
+ if ( typeof cellIndex == 'number' ) {
+ this.navCompanion.select( cellIndex );
+ }
+};
+
+Flickity.prototype.deactivateAsNavFor = function() {
+ this.removeNavSelectedElement();
+};
+
+Flickity.prototype.destroyAsNavFor = function() {
+ if ( !this.navCompanion ) {
+ return;
+ }
+ this.navCompanion.off( 'cellSelect', this.onNavCompanionSelect );
+ this.off( 'staticClick', this.onNavStaticClick );
+ delete this.navCompanion;
+};
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/*!
+ * imagesLoaded v3.1.8
+ * JavaScript is all like "You images are done yet or what?"
+ * MIT License
+ */
+
+( function( window, factory ) {
+ // universal module definition
+
+ /*global define: false, module: false, require: false */
+
+ if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'imagesloaded/imagesloaded',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie'
+ ], function( EventEmitter, eventie ) {
+ return factory( window, EventEmitter, eventie );
+ });
+ } else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('wolfy87-eventemitter'),
+ require('eventie')
+ );
+ } else {
+ // browser global
+ window.imagesLoaded = factory(
+ window,
+ window.EventEmitter,
+ window.eventie
+ );
+ }
+
+})( window,
+
+// -------------------------- factory -------------------------- //
+
+function factory( window, EventEmitter, eventie ) {
+
+
+
+var $ = window.jQuery;
+var console = window.console;
+var hasConsole = typeof console !== 'undefined';
+
+// -------------------------- helpers -------------------------- //
+
+// extend objects
+function extend( a, b ) {
+ for ( var prop in b ) {
+ a[ prop ] = b[ prop ];
+ }
+ return a;
+}
+
+var objToString = Object.prototype.toString;
+function isArray( obj ) {
+ return objToString.call( obj ) === '[object Array]';
+}
+
+// turn element or nodeList into an array
+function makeArray( obj ) {
+ var ary = [];
+ if ( isArray( obj ) ) {
+ // use object if already an array
+ ary = obj;
+ } else if ( typeof obj.length === 'number' ) {
+ // convert nodeList to array
+ for ( var i=0, len = obj.length; i < len; i++ ) {
+ ary.push( obj[i] );
+ }
+ } else {
+ // array of single index
+ ary.push( obj );
+ }
+ return ary;
+}
+
+ // -------------------------- imagesLoaded -------------------------- //
+
+ /**
+ * @param {Array, Element, NodeList, String} elem
+ * @param {Object or Function} options - if function, use as callback
+ * @param {Function} onAlways - callback function
+ */
+ function ImagesLoaded( elem, options, onAlways ) {
+ // coerce ImagesLoaded() without new, to be new ImagesLoaded()
+ if ( !( this instanceof ImagesLoaded ) ) {
+ return new ImagesLoaded( elem, options );
+ }
+ // use elem as selector string
+ if ( typeof elem === 'string' ) {
+ elem = document.querySelectorAll( elem );
+ }
+
+ this.elements = makeArray( elem );
+ this.options = extend( {}, this.options );
+
+ if ( typeof options === 'function' ) {
+ onAlways = options;
+ } else {
+ extend( this.options, options );
+ }
+
+ if ( onAlways ) {
+ this.on( 'always', onAlways );
+ }
+
+ this.getImages();
+
+ if ( $ ) {
+ // add jQuery Deferred object
+ this.jqDeferred = new $.Deferred();
+ }
+
+ // HACK check async to allow time to bind listeners
+ var _this = this;
+ setTimeout( function() {
+ _this.check();
+ });
+ }
+
+ ImagesLoaded.prototype = new EventEmitter();
+
+ ImagesLoaded.prototype.options = {};
+
+ ImagesLoaded.prototype.getImages = function() {
+ this.images = [];
+
+ // filter & find items if we have an item selector
+ for ( var i=0, len = this.elements.length; i < len; i++ ) {
+ var elem = this.elements[i];
+ // filter siblings
+ if ( elem.nodeName === 'IMG' ) {
+ this.addImage( elem );
+ }
+ // find children
+ // no non-element nodes, #143
+ var nodeType = elem.nodeType;
+ if ( !nodeType || !( nodeType === 1 || nodeType === 9 || nodeType === 11 ) ) {
+ continue;
+ }
+ var childElems = elem.querySelectorAll('img');
+ // concat childElems to filterFound array
+ for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
+ var img = childElems[j];
+ this.addImage( img );
+ }
+ }
+ };
+
+ /**
+ * @param {Image} img
+ */
+ ImagesLoaded.prototype.addImage = function( img ) {
+ var loadingImage = new LoadingImage( img );
+ this.images.push( loadingImage );
+ };
+
+ ImagesLoaded.prototype.check = function() {
+ var _this = this;
+ var checkedCount = 0;
+ var length = this.images.length;
+ this.hasAnyBroken = false;
+ // complete if no images
+ if ( !length ) {
+ this.complete();
+ return;
+ }
+
+ function onConfirm( image, message ) {
+ if ( _this.options.debug && hasConsole ) {
+ console.log( 'confirm', image, message );
+ }
+
+ _this.progress( image );
+ checkedCount++;
+ if ( checkedCount === length ) {
+ _this.complete();
+ }
+ return true; // bind once
+ }
+
+ for ( var i=0; i < length; i++ ) {
+ var loadingImage = this.images[i];
+ loadingImage.on( 'confirm', onConfirm );
+ loadingImage.check();
+ }
+ };
+
+ ImagesLoaded.prototype.progress = function( image ) {
+ this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
+ // HACK - Chrome triggers event before object properties have changed. #83
+ var _this = this;
+ setTimeout( function() {
+ _this.emit( 'progress', _this, image );
+ if ( _this.jqDeferred && _this.jqDeferred.notify ) {
+ _this.jqDeferred.notify( _this, image );
+ }
+ });
+ };
+
+ ImagesLoaded.prototype.complete = function() {
+ var eventName = this.hasAnyBroken ? 'fail' : 'done';
+ this.isComplete = true;
+ var _this = this;
+ // HACK - another setTimeout so that confirm happens after progress
+ setTimeout( function() {
+ _this.emit( eventName, _this );
+ _this.emit( 'always', _this );
+ if ( _this.jqDeferred ) {
+ var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve';
+ _this.jqDeferred[ jqMethod ]( _this );
+ }
+ });
+ };
+
+ // -------------------------- jquery -------------------------- //
+
+ if ( $ ) {
+ $.fn.imagesLoaded = function( options, callback ) {
+ var instance = new ImagesLoaded( this, options, callback );
+ return instance.jqDeferred.promise( $(this) );
+ };
+ }
+
+
+ // -------------------------- -------------------------- //
+
+ function LoadingImage( img ) {
+ this.img = img;
+ }
+
+ LoadingImage.prototype = new EventEmitter();
+
+ LoadingImage.prototype.check = function() {
+ // first check cached any previous images that have same src
+ var resource = cache[ this.img.src ] || new Resource( this.img.src );
+ if ( resource.isConfirmed ) {
+ this.confirm( resource.isLoaded, 'cached was confirmed' );
+ return;
+ }
+
+ // If complete is true and browser supports natural sizes,
+ // try to check for image status manually.
+ if ( this.img.complete && this.img.naturalWidth !== undefined ) {
+ // report based on naturalWidth
+ this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
+ return;
+ }
+
+ // If none of the checks above matched, simulate loading on detached element.
+ var _this = this;
+ resource.on( 'confirm', function( resrc, message ) {
+ _this.confirm( resrc.isLoaded, message );
+ return true;
+ });
+
+ resource.check();
+ };
+
+ LoadingImage.prototype.confirm = function( isLoaded, message ) {
+ this.isLoaded = isLoaded;
+ this.emit( 'confirm', this, message );
+ };
+
+ // -------------------------- Resource -------------------------- //
+
+ // Resource checks each src, only once
+ // separate class from LoadingImage to prevent memory leaks. See #115
+
+ var cache = {};
+
+ function Resource( src ) {
+ this.src = src;
+ // add to cache
+ cache[ src ] = this;
+ }
+
+ Resource.prototype = new EventEmitter();
+
+ Resource.prototype.check = function() {
+ // only trigger checking once
+ if ( this.isChecked ) {
+ return;
+ }
+ // simulate loading on detached element
+ var proxyImage = new Image();
+ eventie.bind( proxyImage, 'load', this );
+ eventie.bind( proxyImage, 'error', this );
+ proxyImage.src = this.src;
+ // set flag
+ this.isChecked = true;
+ };
+
+ // ----- events ----- //
+
+ // trigger specified handler for event type
+ Resource.prototype.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+ };
+
+ Resource.prototype.onload = function( event ) {
+ this.confirm( true, 'onload' );
+ this.unbindProxyEvents( event );
+ };
+
+ Resource.prototype.onerror = function( event ) {
+ this.confirm( false, 'onerror' );
+ this.unbindProxyEvents( event );
+ };
+
+ // ----- confirm ----- //
+
+ Resource.prototype.confirm = function( isLoaded, message ) {
+ this.isConfirmed = true;
+ this.isLoaded = isLoaded;
+ this.emit( 'confirm', this, message );
+ };
+
+ Resource.prototype.unbindProxyEvents = function( event ) {
+ eventie.unbind( event.target, 'load', this );
+ eventie.unbind( event.target, 'error', this );
+ };
+
+ // ----- ----- //
+
+ return ImagesLoaded;
+
+});
+
+/*!
+ * Flickity imagesLoaded v1.0.0
+ * enables imagesLoaded option for Flickity
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( [
+ 'flickity/js/index',
+ 'imagesloaded/imagesloaded'
+ ], function( Flickity, imagesLoaded ) {
+ return factory( window, Flickity, imagesLoaded );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('flickity'),
+ require('imagesloaded')
+ );
+ } else {
+ // browser global
+ window.Flickity = factory(
+ window,
+ window.Flickity,
+ window.imagesLoaded
+ );
+ }
+
+}( window, function factory( window, Flickity, imagesLoaded ) {
+
+
+Flickity.createMethods.push('_createImagesLoaded');
+
+Flickity.prototype._createImagesLoaded = function() {
+ this.on( 'activate', this.imagesLoaded );
+};
+
+Flickity.prototype.imagesLoaded = function() {
+ if ( !this.options.imagesLoaded ) {
+ return;
+ }
+ var _this = this;
+ function onImagesLoadedProgress( instance, image ) {
+ var cell = _this.getParentCell( image.img );
+ _this.cellSizeChange( cell && cell.element );
+ }
+ this.loader = imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress );
+};
+
+return Flickity;
+
+}));
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/iscroll.js b/StoneIsland/platforms/android/assets/www/js/vendor/iscroll.js
new file mode 100755
index 00000000..8bd2b8da
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/iscroll.js
@@ -0,0 +1,2011 @@
+/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.prefixPointerEvent = function (pointerEvent) {
+ return window.MSPointerEvent ?
+ 'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
+ pointerEvent;
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ pointerdown: 3,
+ pointermove: 3,
+ pointerup: 3,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+ resizeScrollbars: true,
+
+ mouseWheelSpeed: 20,
+
+ snapThreshold: 0.334,
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+ if ( this.options.shrinkScrollbars == 'scale' ) {
+ this.options.useTransition = false;
+ }
+
+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.3',
+
+ _init: function () {
+ this._initEvents();
+
+ if ( this.options.scrollbars || this.options.indicators ) {
+ this._initIndicators();
+ }
+
+ if ( this.options.mouseWheel ) {
+ this._initWheel();
+ }
+
+ if ( this.options.snap ) {
+ this._initSnap();
+ }
+
+ if ( this.options.keyBindings ) {
+ this._initKeys();
+ }
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+ }
+
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTime(time);
+ }
+ }
+
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTimingFunction(easing);
+ }
+ }
+
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].updatePosition();
+ }
+ }
+
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
+ eventType(target, utils.prefixPointerEvent('pointermove'), this);
+ eventType(target, utils.prefixPointerEvent('pointercancel'), this);
+ eventType(target, utils.prefixPointerEvent('pointerup'), this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _initIndicators: function () {
+ var interactive = this.options.interactiveScrollbars,
+ customStyle = typeof this.options.scrollbars != 'string',
+ indicators = [],
+ indicator;
+
+ var that = this;
+
+ this.indicators = [];
+
+ if ( this.options.scrollbars ) {
+ // Vertical scrollbar
+ if ( this.options.scrollY ) {
+ indicator = {
+ el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenX: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+
+ // Horizontal scrollbar
+ if ( this.options.scrollX ) {
+ indicator = {
+ el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenY: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+ }
+
+ if ( this.options.indicators ) {
+ // TODO: check concat compatibility
+ indicators = indicators.concat(this.options.indicators);
+ }
+
+ for ( var i = indicators.length; i--; ) {
+ this.indicators.push( new Indicator(this, indicators[i]) );
+ }
+
+ // TODO: check if we can use array.map (wide compatibility and performance issues)
+ function _indicatorsMap (fn) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
+ }
+
+ if ( this.options.fadeScrollbars ) {
+ this.on('scrollEnd', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollCancel', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1);
+ });
+ });
+
+ this.on('beforeScrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1, true);
+ });
+ });
+ }
+
+
+ this.on('refresh', function () {
+ _indicatorsMap(function () {
+ this.refresh();
+ });
+ });
+
+ this.on('destroy', function () {
+ _indicatorsMap(function () {
+ this.destroy();
+ });
+
+ delete this.indicators;
+ });
+ },
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ if (e.deltaMode === 1) {
+ wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed;
+ wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed;
+ } else {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ }
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+// INSERT POINT: _wheel
+ },
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'pointerdown':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'pointermove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'pointerup':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'pointercancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
+function createDefaultScrollbar (direction, interactive, type) {
+ var scrollbar = document.createElement('div'),
+ indicator = document.createElement('div');
+
+ if ( type === true ) {
+ scrollbar.style.cssText = 'position:absolute;z-index:9999';
+ indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
+ }
+
+ indicator.className = 'iScrollIndicator';
+
+ if ( direction == 'h' ) {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
+ indicator.style.height = '100%';
+ }
+ scrollbar.className = 'iScrollHorizontalScrollbar';
+ } else {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
+ indicator.style.width = '100%';
+ }
+ scrollbar.className = 'iScrollVerticalScrollbar';
+ }
+
+ scrollbar.style.cssText += ';overflow:hidden';
+
+ if ( !interactive ) {
+ scrollbar.style.pointerEvents = 'none';
+ }
+
+ scrollbar.appendChild(indicator);
+
+ return scrollbar;
+}
+
+function Indicator (scroller, options) {
+ this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
+ this.wrapperStyle = this.wrapper.style;
+ this.indicator = this.wrapper.children[0];
+ this.indicatorStyle = this.indicator.style;
+ this.scroller = scroller;
+
+ this.options = {
+ listenX: true,
+ listenY: true,
+ interactive: false,
+ resize: true,
+ defaultScrollbars: false,
+ shrink: false,
+ fade: false,
+ speedRatioX: 0,
+ speedRatioY: 0
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ this.sizeRatioX = 1;
+ this.sizeRatioY = 1;
+ this.maxPosX = 0;
+ this.maxPosY = 0;
+
+ if ( this.options.interactive ) {
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(this.indicator, 'touchstart', this);
+ utils.addEvent(window, 'touchend', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
+ utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(this.indicator, 'mousedown', this);
+ utils.addEvent(window, 'mouseup', this);
+ }
+ }
+
+ if ( this.options.fade ) {
+ this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
+ this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ this.wrapperStyle.opacity = '0';
+ }
+}
+
+Indicator.prototype = {
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'pointerdown':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'pointermove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'pointerup':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'pointercancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ }
+ },
+
+ destroy: function () {
+ if ( this.options.interactive ) {
+ utils.removeEvent(this.indicator, 'touchstart', this);
+ utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
+ utils.removeEvent(this.indicator, 'mousedown', this);
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ utils.removeEvent(window, 'touchend', this);
+ utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this);
+ utils.removeEvent(window, 'mouseup', this);
+ }
+
+ if ( this.options.defaultScrollbars ) {
+ this.wrapper.parentNode.removeChild(this.wrapper);
+ }
+ },
+
+ _start: function (e) {
+ var point = e.touches ? e.touches[0] : e;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.transitionTime();
+
+ this.initiated = true;
+ this.moved = false;
+ this.lastPointX = point.pageX;
+ this.lastPointY = point.pageY;
+
+ this.startTime = utils.getTime();
+
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(window, 'touchmove', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(window, 'mousemove', this);
+ }
+
+ this.scroller._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ var point = e.touches ? e.touches[0] : e,
+ deltaX, deltaY,
+ newX, newY,
+ timestamp = utils.getTime();
+
+ if ( !this.moved ) {
+ this.scroller._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ deltaX = point.pageX - this.lastPointX;
+ this.lastPointX = point.pageX;
+
+ deltaY = point.pageY - this.lastPointY;
+ this.lastPointY = point.pageY;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ this._pos(newX, newY);
+
+// INSERT POINT: indicator._move
+
+ e.preventDefault();
+ e.stopPropagation();
+ },
+
+ _end: function (e) {
+ if ( !this.initiated ) {
+ return;
+ }
+
+ this.initiated = false;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ if ( this.scroller.options.snap ) {
+ var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
+
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.scroller.x - snap.x), 1000),
+ Math.min(Math.abs(this.scroller.y - snap.y), 1000)
+ ), 300);
+
+ if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
+ this.scroller.directionX = 0;
+ this.scroller.directionY = 0;
+ this.scroller.currentPage = snap;
+ this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
+ }
+ }
+
+ if ( this.moved ) {
+ this.scroller._execEvent('scrollEnd');
+ }
+ },
+
+ transitionTime: function (time) {
+ time = time || 0;
+ this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ }
+ },
+
+ transitionTimingFunction: function (easing) {
+ this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
+ },
+
+ refresh: function () {
+ this.transitionTime();
+
+ if ( this.options.listenX && !this.options.listenY ) {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
+ } else if ( this.options.listenY && !this.options.listenX ) {
+ this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
+ } else {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
+ }
+
+ if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
+ utils.addClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '8px';
+ } else {
+ this.wrapper.style.bottom = '8px';
+ }
+ }
+ } else {
+ utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '2px';
+ } else {
+ this.wrapper.style.bottom = '2px';
+ }
+ }
+ }
+
+ var r = this.wrapper.offsetHeight; // force refresh
+
+ if ( this.options.listenX ) {
+ this.wrapperWidth = this.wrapper.clientWidth;
+ if ( this.options.resize ) {
+ this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
+ this.indicatorStyle.width = this.indicatorWidth + 'px';
+ } else {
+ this.indicatorWidth = this.indicator.clientWidth;
+ }
+
+ this.maxPosX = this.wrapperWidth - this.indicatorWidth;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryX = -this.indicatorWidth + 8;
+ this.maxBoundaryX = this.wrapperWidth - 8;
+ } else {
+ this.minBoundaryX = 0;
+ this.maxBoundaryX = this.maxPosX;
+ }
+
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ }
+
+ if ( this.options.listenY ) {
+ this.wrapperHeight = this.wrapper.clientHeight;
+ if ( this.options.resize ) {
+ this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
+ this.indicatorStyle.height = this.indicatorHeight + 'px';
+ } else {
+ this.indicatorHeight = this.indicator.clientHeight;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryY = -this.indicatorHeight + 8;
+ this.maxBoundaryY = this.wrapperHeight - 8;
+ } else {
+ this.minBoundaryY = 0;
+ this.maxBoundaryY = this.maxPosY;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+ this.sizeRatioY = this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY / this.scroller.maxScrollY));
+ }
+
+ this.updatePosition();
+ },
+
+ updatePosition: function () {
+ var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
+ y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
+
+ if ( !this.options.ignoreBoundaries ) {
+ if ( x < this.minBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth + x, 8);
+ this.indicatorStyle.width = this.width + 'px';
+ }
+ x = this.minBoundaryX;
+ } else if ( x > this.maxBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
+ this.indicatorStyle.width = this.width + 'px';
+ x = this.maxPosX + this.indicatorWidth - this.width;
+ } else {
+ x = this.maxBoundaryX;
+ }
+ } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
+ this.width = this.indicatorWidth;
+ this.indicatorStyle.width = this.width + 'px';
+ }
+
+ if ( y < this.minBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight + y * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ y = this.minBoundaryY;
+ } else if ( y > this.maxBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ y = this.maxPosY + this.indicatorHeight - this.height;
+ } else {
+ y = this.maxBoundaryY;
+ }
+ } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
+ this.height = this.indicatorHeight;
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ }
+
+ this.x = x;
+ this.y = y;
+
+ if ( this.scroller.options.useTransform ) {
+ this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
+ } else {
+ this.indicatorStyle.left = x + 'px';
+ this.indicatorStyle.top = y + 'px';
+ }
+ },
+
+ _pos: function (x, y) {
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x > this.maxPosX ) {
+ x = this.maxPosX;
+ }
+
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y > this.maxPosY ) {
+ y = this.maxPosY;
+ }
+
+ x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
+ y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
+
+ this.scroller.scrollTo(x, y);
+ },
+
+ fade: function (val, hold) {
+ if ( hold && !this.visible ) {
+ return;
+ }
+
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+
+ var time = val ? 250 : 500,
+ delay = val ? 0 : 300;
+
+ val = val ? '1' : '0';
+
+ this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
+
+ this.fadeTimeout = setTimeout((function (val) {
+ this.wrapperStyle.opacity = val;
+ this.visible = +val;
+ }).bind(this, val), delay);
+ }
+};
+
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/jquery-2.1.4.min.js b/StoneIsland/platforms/android/assets/www/js/vendor/jquery-2.1.4.min.js
new file mode 100755
index 00000000..49990d6e
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/jquery-2.1.4.min.js
@@ -0,0 +1,4 @@
+/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\f]' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function qa(){}qa.prototype=d.filters=d.pseudos,d.setFilters=new qa,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function ra(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){
+return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||l,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[n.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new n.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=l),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&n.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return n.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=n.extend(new n.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?n.event.trigger(e,null,b):n.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},n.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},n.Event=function(a,b){return this instanceof n.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?Z:$):this.type=a,b&&n.extend(this,b),this.timeStamp=a&&a.timeStamp||n.now(),void(this[n.expando]=!0)):new n.Event(a,b)},n.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Z,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},n.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){n.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!n.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.focusinBubbles||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a),!0)};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),n.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return n().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=n.guid++)),this.each(function(){n.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,n(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){n.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}});var aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ba=/<([\w:]+)/,ca=/<|&#?\w+;/,da=/<(?:script|style|link)/i,ea=/checked\s*(?:[^=]|=\s*.checked.)/i,fa=/^$|\/(?:java|ecma)script/i,ga=/^true\/(.*)/,ha=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ia={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ia.optgroup=ia.option,ia.tbody=ia.tfoot=ia.colgroup=ia.caption=ia.thead,ia.th=ia.td;function ja(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function ka(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function la(a){var b=ga.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ma(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function na(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function oa(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pa(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=oa(h),f=oa(a),d=0,e=f.length;e>d;d++)pa(f[d],g[d]);if(b)if(c)for(f=f||oa(a),g=g||oa(h),d=0,e=f.length;e>d;d++)na(f[d],g[d]);else na(a,h);return g=oa(h,"script"),g.length>0&&ma(g,!i&&oa(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(ca.test(e)){f=f||k.appendChild(b.createElement("div")),g=(ba.exec(e)||["",""])[1].toLowerCase(),h=ia[g]||ia._default,f.innerHTML=h[1]+e.replace(aa,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=oa(k.appendChild(e),"script"),i&&ma(f),c)){j=0;while(e=f[j++])fa.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(oa(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&ma(oa(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(oa(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!da.test(a)&&!ia[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(aa,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(oa(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(oa(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&ea.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(oa(c,"script"),ka),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,oa(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,la),j=0;g>j;j++)h=f[j],fa.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(ha,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qa,ra={};function sa(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function ta(a){var b=l,c=ra[a];return c||(c=sa(a,b),"none"!==c&&c||(qa=(qa||n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qa[0].contentDocument,b.write(),b.close(),c=sa(a,b),qa.detach()),ra[a]=c),c}var ua=/^margin/,va=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wa=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)};function xa(a,b,c){var d,e,f,g,h=a.style;return c=c||wa(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),va.test(g)&&ua.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function ya(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),f.removeChild(c),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var za=/^(none|table(?!-c[ea]).+)/,Aa=new RegExp("^("+Q+")(.*)$","i"),Ba=new RegExp("^([+-])=("+Q+")","i"),Ca={position:"absolute",visibility:"hidden",display:"block"},Da={letterSpacing:"0",fontWeight:"400"},Ea=["Webkit","O","Moz","ms"];function Fa(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Ea.length;while(e--)if(b=Ea[e]+c,b in a)return b;return d}function Ga(a,b,c){var d=Aa.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Ha(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ia(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wa(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xa(a,b,f),(0>e||null==e)&&(e=a.style[b]),va.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Ha(a,b,c||(g?"border":"content"),d,f)+"px"}function Ja(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",ta(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xa(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fa(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Ba.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fa(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xa(a,b,d)),"normal"===e&&b in Da&&(e=Da[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?za.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Ca,function(){return Ia(a,b,d)}):Ia(a,b,d):void 0},set:function(a,c,d){var e=d&&wa(a);return Ga(a,c,d?Ha(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=ya(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xa,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ua.test(a)||(n.cssHooks[a+b].set=Ga)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wa(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Ja(this,!0)},hide:function(){return Ja(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Ka(a,b,c,d,e){return new Ka.prototype.init(a,b,c,d,e)}n.Tween=Ka,Ka.prototype={constructor:Ka,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Ka.propHooks[this.prop];return a&&a.get?a.get(this):Ka.propHooks._default.get(this)},run:function(a){var b,c=Ka.propHooks[this.prop];return this.options.duration?this.pos=b=n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ka.propHooks._default.set(this),this}},Ka.prototype.init.prototype=Ka.prototype,Ka.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Ka.propHooks.scrollTop=Ka.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Ka.prototype.init,n.fx.step={};var La,Ma,Na=/^(?:toggle|show|hide)$/,Oa=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pa=/queueHooks$/,Qa=[Va],Ra={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Oa.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Oa.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sa(){return setTimeout(function(){La=void 0}),La=n.now()}function Ta(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ua(a,b,c){for(var d,e=(Ra[b]||[]).concat(Ra["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Va(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||ta(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Na.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?ta(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ua(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wa(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xa(a,b,c){var d,e,f=0,g=Qa.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=La||Sa(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:La||Sa(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wa(k,j.opts.specialEasing);g>f;f++)if(d=Qa[f].call(j,a,k,j.opts))return d;return n.map(k,Ua,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xa,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Ra[c]=Ra[c]||[],Ra[c].unshift(b)},prefilter:function(a,b){b?Qa.unshift(a):Qa.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xa(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pa.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Ta(b,!0),a,d,e)}}),n.each({slideDown:Ta("show"),slideUp:Ta("hide"),slideToggle:Ta("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(La=n.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||n.fx.stop(),La=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Ma||(Ma=setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){clearInterval(Ma),Ma=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(a,b){return a=n.fx?n.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=l.createElement("input"),b=l.createElement("select"),c=b.appendChild(l.createElement("option"));a.type="checkbox",k.checkOn=""!==a.value,k.optSelected=c.selected,b.disabled=!0,k.optDisabled=!c.disabled,a=l.createElement("input"),a.value="t",a.type="radio",k.radioValue="t"===a.value}();var Ya,Za,$a=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return J(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Za:Ya)),
+void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Za={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$a[b]||n.find.attr;$a[b]=function(a,b,d){var e,f;return d||(f=$a[b],$a[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$a[b]=f),e}});var _a=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_a.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ab=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ab," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ab," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ab," ").indexOf(b)>=0)return!0;return!1}});var bb=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bb,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cb=n.now(),db=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var eb=/#.*$/,fb=/([?&])_=[^&]*/,gb=/^(.*?):[ \t]*([^\r\n]*)$/gm,hb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,ib=/^(?:GET|HEAD)$/,jb=/^\/\//,kb=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,lb={},mb={},nb="*/".concat("*"),ob=a.location.href,pb=kb.exec(ob.toLowerCase())||[];function qb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function rb(a,b,c,d){var e={},f=a===mb;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function sb(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function tb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function ub(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:ob,type:"GET",isLocal:hb.test(pb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":nb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?sb(sb(a,n.ajaxSettings),b):sb(n.ajaxSettings,a)},ajaxPrefilter:qb(lb),ajaxTransport:qb(mb),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=gb.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||ob)+"").replace(eb,"").replace(jb,pb[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=kb.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===pb[1]&&h[2]===pb[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(pb[3]||("http:"===pb[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),rb(lb,k,b,v),2===t)return v;i=n.event&&k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!ib.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(db.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=fb.test(d)?d.replace(fb,"$1_="+cb++):d+(db.test(d)?"&":"?")+"_="+cb++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+nb+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=rb(mb,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=tb(k,v,f)),u=ub(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var vb=/%20/g,wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&").replace(vb,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Bb=0,Cb={},Db={0:200,1223:204},Eb=n.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Cb)Cb[a]()}),k.cors=!!Eb&&"withCredentials"in Eb,k.ajax=Eb=!!Eb,n.ajaxTransport(function(a){var b;return k.cors||Eb&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Bb;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Cb[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Db[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Cb[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),l.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Fb=[],Gb=/(=)\?(?=&|$)|\?\?/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Fb.pop()||n.expando+"_"+cb++;return this[a]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Gb.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Gb.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Gb,"$1"+e):b.jsonp!==!1&&(b.url+=(db.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||n.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Fb.push(e)),g&&n.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),n.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||l;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=n.buildFragment([a],b,e),e&&e.length&&n(e).remove(),n.merge([],d.childNodes))};var Hb=n.fn.load;n.fn.load=function(a,b,c){if("string"!=typeof a&&Hb)return Hb.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=n.trim(a.slice(h)),a=a.slice(0,h)),n.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&n.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?n("<div>").append(n.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n.expr.filters.animated=function(a){return n.grep(n.timers,function(b){return a===b.elem}).length};var Ib=a.document.documentElement;function Jb(a){return n.isWindow(a)?a:9===a.nodeType&&a.defaultView}n.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=n.css(a,"position"),l=n(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=n.css(a,"top"),i=n.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,n.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Jb(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===n.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(d=a.offset()),d.top+=n.css(a[0],"borderTopWidth",!0),d.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-n.css(c,"marginTop",!0),left:b.left-d.left-n.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Ib;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Ib})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;n.fn[b]=function(e){return J(this,function(b,e,f){var g=Jb(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=ya(k.pixelPosition,function(a,c){return c?(c=xa(a,b),va.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var Kb=a.jQuery,Lb=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=Lb),b&&a.jQuery===n&&(a.jQuery=Kb),n},typeof b===U&&(a.jQuery=a.$=n),n});
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/jquery.creditCardValidator.js b/StoneIsland/platforms/android/assets/www/js/vendor/jquery.creditCardValidator.js
new file mode 100755
index 00000000..56ce1bf6
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/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/android/assets/www/js/vendor/loader.js b/StoneIsland/platforms/android/assets/www/js/vendor/loader.js
new file mode 100755
index 00000000..cc9644f8
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/loader.js
@@ -0,0 +1,97 @@
+var Loader = Loader || (function(){
+ function Loader (readyCallback, view){
+ this.assets = {};
+ this.images = [];
+ this.readyCallback = readyCallback;
+ this.count = 0
+ this.view = view
+ this.loaded = false
+ }
+
+ // Register an asset as loading
+ Loader.prototype.register = function(s){
+ this.assets[s] = false;
+ this.count += 1
+ }
+
+ // Signal that an asset has loaded
+ Loader.prototype.ready = function(s){
+ window.debug && console.log("ready >> " + s);
+
+ this.assets[s] = true;
+ if (this.loaded) return;
+
+ this.view && this.view.update( this.percentRemaining() )
+
+ if (! this.isReady()) return;
+
+ this.loaded = true;
+ if (this.view) {
+ this.view && this.view.finish(this.readyCallback)
+ }
+ else {
+ this.readyCallback && this.readyCallback();
+ }
+ }
+
+ // (boolean) Is the loader ready?
+ Loader.prototype.isReady = function(){
+ for (var s in this.assets) {
+ if (this.assets.hasOwnProperty(s) && this.assets[s] != true) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // (float) Percentage of assets remaining
+ Loader.prototype.percentRemaining = function(){
+ return this.remainingAssets() / this.count
+ }
+
+ // (int) Number of assets remaining
+ Loader.prototype.remainingAssets = function(){
+ var n = 0;
+ for (var s in this.assets) {
+ if (this.assets.hasOwnProperty(s) && this.assets[s] != true) {
+ n++;
+ // console.log('remaining: ' + s);
+ }
+ }
+ return n;
+ }
+
+ // Preload the images in config.images
+ Loader.prototype.preloadImages = function(images){
+ this.register("preload");
+ for (var i = 0; i < images.length; i++) {
+ this.preloadImage(images[i]);
+ }
+ this.ready("preload");
+ }
+ Loader.prototype.preloadImage = function(src, register, cb){
+ if (! src || src == "none") return;
+ var _this = this;
+ if (! cb && typeof register !== "string") {
+ cb = register
+ register = null
+ }
+ if (register) {
+ this.register(src);
+ }
+ var img = new Image();
+ img.onload = function(){
+ if (cb) {
+ cb(img);
+ }
+ if (register) {
+ _this.ready(src);
+ }
+ }
+ img.src = src;
+ if (img.complete) img.onload();
+ _this.images.push(img);
+ }
+
+ return Loader;
+})();
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/lodash.min.js b/StoneIsland/platforms/android/assets/www/js/vendor/lodash.min.js
new file mode 100755
index 00000000..e6c9820b
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/lodash.min.js
@@ -0,0 +1,98 @@
+/**
+ * @license
+ * lodash 3.10.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
+ * Build: `lodash modern -o ./lodash.js`
+ */
+;(function(){function n(n,t){if(n!==t){var r=null===n,e=n===w,u=n===n,o=null===t,i=t===w,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(n<t&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function t(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u<e;)if(t(n[u],u,n))return u;return-1}function r(n,t,r){if(t!==t)return p(n,r);r-=1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function e(n){return typeof n=="function"||false}function u(n){return null==n?"":n+""}function o(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););
+return r}function i(n,t){for(var r=n.length;r--&&-1<t.indexOf(n.charAt(r)););return r}function f(t,r){return n(t.a,r.a)||t.b-r.b}function a(n){return Nn[n]}function c(n){return Tn[n]}function l(n,t,r){return t?n=Bn[n]:r&&(n=Dn[n]),"\\"+n}function s(n){return"\\"+Dn[n]}function p(n,t,r){var e=n.length;for(t+=r?0:-1;r?t--:++t<e;){var u=n[t];if(u!==u)return t}return-1}function h(n){return!!n&&typeof n=="object"}function _(n){return 160>=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n);
+}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;)n[r]===t&&(n[r]=z,o[++u]=r);return o}function g(n){for(var t=-1,r=n.length;++t<r&&_(n.charCodeAt(t)););return t}function y(n){for(var t=n.length;t--&&_(n.charCodeAt(t)););return t}function d(n){return Ln[n]}function m(_){function Nn(n){if(h(n)&&!(Oo(n)||n instanceof zn)){if(n instanceof Ln)return n;if(nu.call(n,"__chain__")&&nu.call(n,"__wrapped__"))return Mr(n)}return new Ln(n)}function Tn(){}function Ln(n,t,r){this.__wrapped__=n,this.__actions__=r||[],
+this.__chain__=!!t}function zn(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=false,this.__iteratees__=[],this.__takeCount__=Ru,this.__views__=[]}function Bn(){this.__data__={}}function Dn(n){var t=n?n.length:0;for(this.data={hash:gu(null),set:new lu};t--;)this.push(n[t])}function Mn(n,t){var r=n.data;return(typeof t=="string"||ge(t)?r.set.has(t):r.hash[t])?0:-1}function qn(n,t){var r=-1,e=n.length;for(t||(t=Be(e));++r<e;)t[r]=n[r];return t}function Pn(n,t){for(var r=-1,e=n.length;++r<e&&false!==t(n[r],r,n););
+return n}function Kn(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vn(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Gn(n,t){for(var r=-1,e=n.length,u=Be(e);++r<e;)u[r]=t(n[r],r,n);return u}function Jn(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function Xn(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Hn(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;
+return false}function Qn(n,t,r,e){return n!==w&&nu.call(e,r)?n:t}function nt(n,t,r){for(var e=-1,u=zo(t),o=u.length;++e<o;){var i=u[e],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(f!==w||i in n)||(n[i]=a)}return n}function tt(n,t){return null==t?n:et(t,zo(t),n)}function rt(n,t){for(var r=-1,e=null==n,u=!e&&Er(n),o=u?n.length:0,i=t.length,f=Be(i);++r<i;){var a=t[r];f[r]=u?Cr(a,o)?n[a]:w:e?w:n[a]}return f}function et(n,t,r){r||(r={});for(var e=-1,u=t.length;++e<u;){var o=t[e];r[o]=n[o]}return r}function ut(n,t,r){
+var e=typeof n;return"function"==e?t===w?n:Bt(n,t,r):null==n?Fe:"object"==e?bt(n):t===w?ze(n):xt(n,t)}function ot(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),f!==w)return f;if(!ge(n))return n;if(e=Oo(n)){if(f=kr(n),!t)return qn(n,f)}else{var a=ru.call(n),c=a==K;if(a!=Z&&a!=B&&(!c||u))return Fn[a]?Rr(n,a,t):u?n:{};if(f=Ir(c?{}:n),!t)return tt(f,n)}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pn:_t)(n,function(e,u){f[u]=ot(e,t,r,u,n,o,i)}),f}function it(n,t,r){
+if(typeof n!="function")throw new Ge(L);return su(function(){n.apply(w,r)},t)}function ft(n,t){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=xr(),f=i===r,a=f&&t.length>=F&&gu&&lu?new Dn(t):null,c=t.length;a&&(i=Mn,f=false,t=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(t[l]===a)continue n;u.push(a)}else 0>i(t,a,0)&&u.push(a);return u}function at(n,t){var r=true;return Su(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ct(n,t,r,e){var u=e,o=u;return Su(n,function(n,i,f){i=+t(n,i,f),(r(i,u)||i===e&&i===o)&&(u=i,
+o=n)}),o}function lt(n,t){var r=[];return Su(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function st(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pt(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++u<o;){var i=n[u];h(i)&&Er(i)&&(r||Oo(i)||pe(i))?t?pt(i,t,r,e):Jn(e,i):r||(e[e.length]=i)}return e}function ht(n,t){Nu(n,t,Re)}function _t(n,t){return Nu(n,t,zo)}function vt(n,t){return Tu(n,t,zo)}function gt(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];
+ve(n[i])&&(o[++u]=i)}return o}function yt(n,t,r){if(null!=n){r!==w&&r in Br(n)&&(t=[r]),r=0;for(var e=t.length;null!=n&&r<e;)n=n[t[r++]];return r&&r==e?n:w}}function dt(n,t,r,e,u,o){if(n===t)n=true;else if(null==n||null==t||!ge(n)&&!h(t))n=n!==n&&t!==t;else n:{var i=dt,f=Oo(n),a=Oo(t),c=D,l=D;f||(c=ru.call(n),c==B?c=Z:c!=Z&&(f=xe(n))),a||(l=ru.call(t),l==B?l=Z:l!=Z&&xe(t));var s=c==Z,a=l==Z,l=c==l;if(!l||f||s){if(!e&&(c=s&&nu.call(n,"__wrapped__"),a=a&&nu.call(t,"__wrapped__"),c||a)){n=i(c?n.value():n,a?t.value():t,r,e,u,o);
+break n}if(l){for(u||(u=[]),o||(o=[]),c=u.length;c--;)if(u[c]==n){n=o[c]==t;break n}u.push(n),o.push(t),n=(f?yr:mr)(n,t,i,r,e,u,o),u.pop(),o.pop()}else n=false}else n=dr(n,t,c)}return n}function mt(n,t,r){var e=t.length,u=e,o=!r;if(null==n)return!u;for(n=Br(n);e--;){var i=t[e];if(o&&i[2]?i[1]!==n[i[0]]:!(i[0]in n))return false}for(;++e<u;){var i=t[e],f=i[0],a=n[f],c=i[1];if(o&&i[2]){if(a===w&&!(f in n))return false}else if(i=r?r(a,c,f):w,i===w?!dt(c,a,r,true):!i)return false}return true}function wt(n,t){var r=-1,e=Er(n)?Be(n.length):[];
+return Su(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function bt(n){var t=Ar(n);if(1==t.length&&t[0][2]){var r=t[0][0],e=t[0][1];return function(n){return null==n?false:n[r]===e&&(e!==w||r in Br(n))}}return function(n){return mt(n,t)}}function xt(n,t){var r=Oo(n),e=Wr(n)&&t===t&&!ge(t),u=n+"";return n=Dr(n),function(o){if(null==o)return false;var i=u;if(o=Br(o),!(!r&&e||i in o)){if(o=1==n.length?o:yt(o,Et(n,0,-1)),null==o)return false;i=Zr(n),o=Br(o)}return o[i]===t?t!==w||i in o:dt(t,o[i],w,true)}}function At(n,t,r,e,u){
+if(!ge(n))return n;var o=Er(t)&&(Oo(t)||xe(t)),i=o?w:zo(t);return Pn(i||t,function(f,a){if(i&&(a=f,f=t[a]),h(f)){e||(e=[]),u||(u=[]);n:{for(var c=a,l=e,s=u,p=l.length,_=t[c];p--;)if(l[p]==_){n[c]=s[p];break n}var p=n[c],v=r?r(p,_,c,n,t):w,g=v===w;g&&(v=_,Er(_)&&(Oo(_)||xe(_))?v=Oo(p)?p:Er(p)?qn(p):[]:me(_)||pe(_)?v=pe(p)?ke(p):me(p)?p:{}:g=false),l.push(_),s.push(v),g?n[c]=At(v,_,r,l,s):(v===v?v!==p:p===p)&&(n[c]=v)}}else c=n[a],l=r?r(c,f,a,n,t):w,(s=l===w)&&(l=f),l===w&&(!o||a in n)||!s&&(l===l?l===c:c!==c)||(n[a]=l);
+}),n}function jt(n){return function(t){return null==t?w:t[n]}}function kt(n){var t=n+"";return n=Dr(n),function(r){return yt(r,n,t)}}function It(n,t){for(var r=n?t.length:0;r--;){var e=t[r];if(e!=u&&Cr(e)){var u=e;pu.call(n,e,1)}}}function Rt(n,t){return n+yu(ku()*(t-n+1))}function Ot(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Et(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=r===w||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Be(u);++e<u;)r[e]=n[e+t];
+return r}function Ct(n,t){var r;return Su(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Ut(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function Wt(t,r,e){var u=wr(),o=-1;return r=Gn(r,function(n){return u(n)}),t=wt(t,function(n){return{a:Gn(r,function(t){return t(n)}),b:++o,c:n}}),Ut(t,function(t,r){var u;n:{for(var o=-1,i=t.a,f=r.a,a=i.length,c=e.length;++o<a;)if(u=n(i[o],f[o])){if(o>=c)break n;o=e[o],u*="asc"===o||true===o?1:-1;break n}u=t.b-r.b}return u})}function $t(n,t){
+var r=0;return Su(n,function(n,e,u){r+=+t(n,e,u)||0}),r}function St(n,t){var e=-1,u=xr(),o=n.length,i=u===r,f=i&&o>=F,a=f&&gu&&lu?new Dn(void 0):null,c=[];a?(u=Mn,i=false):(f=false,a=t?[]:c);n:for(;++e<o;){var l=n[e],s=t?t(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;t&&a.push(s),c.push(l)}else 0>u(a,s,0)&&((t||f)&&a.push(s),c.push(l))}return c}function Ft(n,t){for(var r=-1,e=t.length,u=Be(e);++r<e;)u[r]=n[t[r]];return u}function Nt(n,t,r,e){for(var u=n.length,o=e?u:-1;(e?o--:++o<u)&&t(n[o],o,n););
+return r?Et(n,e?0:o,e?o+1:u):Et(n,e?o+1:0,e?u:o)}function Tt(n,t){var r=n;r instanceof zn&&(r=r.value());for(var e=-1,u=t.length;++e<u;)var o=t[e],r=o.func.apply(o.thisArg,Jn([r],o.args));return r}function Lt(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=Eu){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)&&null!==i?e=o+1:u=o}return u}return zt(n,t,Fe,r)}function zt(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,a=t===w;u<o;){var c=yu((u+o)/2),l=r(n[c]),s=l!==w,p=l===l;
+(i?p||e:f?p&&s&&(e||null!=l):a?p&&(e||s):null==l?0:e?l<=t:l<t)?u=c+1:o=c}return xu(o,Ou)}function Bt(n,t,r){if(typeof n!="function")return Fe;if(t===w)return n;switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Dt(n){var t=new ou(n.byteLength);return new hu(t).set(new hu(n)),
+t}function Mt(n,t,r){for(var e=r.length,u=-1,o=bu(n.length-e,0),i=-1,f=t.length,a=Be(f+o);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function qt(n,t,r){for(var e=-1,u=r.length,o=-1,i=bu(n.length-u,0),f=-1,a=t.length,c=Be(i+a);++o<i;)c[o]=n[o];for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function Pt(n,t){return function(r,e,u){var o=t?t():{};if(e=wr(e,u,3),Oo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else Su(r,function(t,r,u){
+n(o,t,e(t,r,u),u)});return o}}function Kt(n){return le(function(t,r){var e=-1,u=null==t?0:r.length,o=2<u?r[u-2]:w,i=2<u?r[2]:w,f=1<u?r[u-1]:w;for(typeof o=="function"?(o=Bt(o,f,5),u-=2):(o=typeof f=="function"?f:w,u-=o?1:0),i&&Ur(r[0],r[1],i)&&(o=3>u?w:o,u=1);++e<u;)(i=r[e])&&n(t,i,o);return t})}function Vt(n,t){return function(r,e){var u=r?Bu(r):0;if(!Sr(u))return n(r,e);for(var o=t?u:-1,i=Br(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}function Zt(n){return function(t,r,e){var u=Br(t);e=e(t);for(var o=e.length,i=n?o:-1;n?i--:++i<o;){
+var f=e[i];if(false===r(u[f],f,u))break}return t}}function Yt(n,t){function r(){return(this&&this!==Zn&&this instanceof r?e:n).apply(t,arguments)}var e=Jt(n);return r}function Gt(n){return function(t){var r=-1;t=$e(Ce(t));for(var e=t.length,u="";++r<e;)u=n(u,t[r],r);return u}}function Jt(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:
+return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=$u(n.prototype),t=n.apply(r,t);return ge(t)?t:r}}function Xt(n){function t(r,e,u){return u&&Ur(r,e,u)&&(e=w),r=gr(r,n,w,w,w,w,w,e),r.placeholder=t.placeholder,r}return t}function Ht(n,t){return le(function(r){var e=r[0];return null==e?e:(r.push(t),n.apply(w,r))})}function Qt(n,t){return function(r,e,u){if(u&&Ur(r,e,u)&&(e=w),e=wr(e,u,3),1==e.length){
+u=r=Oo(r)?r:zr(r);for(var o=e,i=-1,f=u.length,a=t,c=a;++i<f;){var l=u[i],s=+o(l);n(s,a)&&(a=s,c=l)}if(u=c,!r.length||u!==t)return u}return ct(r,e,n,t)}}function nr(n,r){return function(e,u,o){return u=wr(u,o,3),Oo(e)?(u=t(e,u,r),-1<u?e[u]:w):st(e,u,n)}}function tr(n){return function(r,e,u){return r&&r.length?(e=wr(e,u,3),t(r,e,n)):-1}}function rr(n){return function(t,r,e){return r=wr(r,e,3),st(t,r,n,true)}}function er(n){return function(){for(var t,r=arguments.length,e=n?r:-1,u=0,o=Be(r);n?e--:++e<r;){
+var i=o[u++]=arguments[e];if(typeof i!="function")throw new Ge(L);!t&&Ln.prototype.thru&&"wrapper"==br(i)&&(t=new Ln([],true))}for(e=t?-1:r;++e<r;){var i=o[e],u=br(i),f="wrapper"==u?zu(i):w;t=f&&$r(f[0])&&f[1]==(E|k|R|C)&&!f[4].length&&1==f[9]?t[br(f[0])].apply(t,f[3]):1==i.length&&$r(i)?t[u]():t.thru(i)}return function(){var n=arguments,e=n[0];if(t&&1==n.length&&Oo(e)&&e.length>=F)return t.plant(e).value();for(var u=0,n=r?o[u].apply(this,n):e;++u<r;)n=o[u].call(this,n);return n}}}function ur(n,t){
+return function(r,e,u){return typeof e=="function"&&u===w&&Oo(r)?n(r,e):t(r,Bt(e,u,3))}}function or(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r,Re)}}function ir(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r)}}function fr(n){return function(t,r,e){var u={};return r=wr(r,e,3),_t(t,function(t,e,o){o=r(t,e,o),e=n?o:e,t=n?t:o,u[e]=t}),u}}function ar(n){return function(t,r,e){return t=u(t),(n?t:"")+pr(t,r,e)+(n?"":t)}}function cr(n){
+var t=le(function(r,e){var u=v(e,t.placeholder);return gr(r,n,w,e,u)});return t}function lr(n,t){return function(r,e,u,o){var i=3>arguments.length;return typeof e=="function"&&o===w&&Oo(r)?n(r,e,u,i):Ot(r,wr(e,o,4),u,i,t)}}function sr(n,t,r,e,u,o,i,f,a,c){function l(){for(var m=arguments.length,b=m,j=Be(m);b--;)j[b]=arguments[b];if(e&&(j=Mt(j,e,u)),o&&(j=qt(j,o,i)),_||y){var b=l.placeholder,k=v(j,b),m=m-k.length;if(m<c){var I=f?qn(f):w,m=bu(c-m,0),E=_?k:w,k=_?w:k,C=_?j:w,j=_?w:j;return t|=_?R:O,t&=~(_?O:R),
+g||(t&=~(x|A)),j=[n,t,r,C,E,j,k,I,a,m],I=sr.apply(w,j),$r(n)&&Du(I,j),I.placeholder=b,I}}if(b=p?r:this,I=h?b[n]:n,f)for(m=j.length,E=xu(f.length,m),k=qn(j);E--;)C=f[E],j[E]=Cr(C,m)?k[C]:w;return s&&a<j.length&&(j.length=a),this&&this!==Zn&&this instanceof l&&(I=d||Jt(n)),I.apply(b,j)}var s=t&E,p=t&x,h=t&A,_=t&k,g=t&j,y=t&I,d=h?w:Jt(n);return l}function pr(n,t,r){return n=n.length,t=+t,n<t&&mu(t)?(t-=n,r=null==r?" ":r+"",Ue(r,vu(t/r.length)).slice(0,t)):""}function hr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=Be(c+f);++a<c;)l[a]=e[a];
+for(;f--;)l[a++]=arguments[++t];return(this&&this!==Zn&&this instanceof u?i:n).apply(o?r:this,l)}var o=t&x,i=Jt(n);return u}function _r(n){var t=Pe[n];return function(n,r){return(r=r===w?0:+r||0)?(r=au(10,r),t(n*r)/r):t(n)}}function vr(n){return function(t,r,e,u){var o=wr(e);return null==e&&o===ut?Lt(t,r,n):zt(t,r,o(e,u,1),n)}}function gr(n,t,r,e,u,o,i,f){var a=t&A;if(!a&&typeof n!="function")throw new Ge(L);var c=e?e.length:0;if(c||(t&=~(R|O),e=u=w),c-=u?u.length:0,t&O){var l=e,s=u;e=u=w}var p=a?w:zu(n);
+return r=[n,t,r,e,u,l,s,o,i,f],p&&(e=r[1],t=p[1],f=e|t,u=t==E&&e==k||t==E&&e==C&&r[7].length<=p[8]||t==(E|C)&&e==k,(f<E||u)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Mt(u,e,p[4]):qn(e),r[4]=u?v(r[3],z):qn(p[4])),(e=p[5])&&(u=r[5],r[5]=u?qt(u,e,p[6]):qn(e),r[6]=u?v(r[5],z):qn(p[6])),(e=p[7])&&(r[7]=qn(e)),t&E&&(r[8]=null==r[8]?p[8]:xu(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9]),r[9]=null==f?a?0:n.length:bu(f-c,0)||0,(p?Lu:Du)(t==x?Yt(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?sr.apply(w,r):hr.apply(w,r),r);
+}function yr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length;if(a!=c&&(!u||c<=a))return false;for(;++f<a;){var l=n[f],c=t[f],s=e?e(u?c:l,u?l:c,f):w;if(s!==w){if(s)continue;return false}if(u){if(!Hn(t,function(n){return l===n||r(l,n,e,u,o,i)}))return false}else if(l!==c&&!r(l,c,e,u,o,i))return false}return true}function dr(n,t,r){switch(r){case M:case q:return+n==+t;case P:return n.name==t.name&&n.message==t.message;case V:return n!=+n?t!=+t:n==+t;case Y:case G:return n==t+""}return false}function mr(n,t,r,e,u,o,i){var f=zo(n),a=f.length,c=zo(t).length;
+if(a!=c&&!u)return false;for(c=a;c--;){var l=f[c];if(!(u?l in t:nu.call(t,l)))return false}for(var s=u;++c<a;){var l=f[c],p=n[l],h=t[l],_=e?e(u?h:p,u?p:h,l):w;if(_===w?!r(p,h,e,u,o,i):!_)return false;s||(s="constructor"==l)}return s||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false}function wr(n,t,r){var e=Nn.callback||Se,e=e===Se?ut:e;return r?e(n,t,r):e}function br(n){for(var t=n.name+"",r=Wu[t],e=r?r.length:0;e--;){
+var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}function xr(n,t,e){var u=Nn.indexOf||Vr,u=u===Vr?r:u;return n?u(n,t,e):u}function Ar(n){n=Oe(n);for(var t=n.length;t--;){var r=n[t][1];n[t][2]=r===r&&!ge(r)}return n}function jr(n,t){var r=null==n?w:n[t];return ye(r)?r:w}function kr(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&nu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function Ir(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ve),
+new n}function Rr(n,t,r){var e=n.constructor;switch(t){case J:return Dt(n);case M:case q:return new e(+n);case X:case H:case Q:case nn:case tn:case rn:case en:case un:case on:return t=n.buffer,new e(r?Dt(t):t,n.byteOffset,n.length);case V:case G:return new e(n);case Y:var u=new e(n.source,kn.exec(n));u.lastIndex=n.lastIndex}return u}function Or(n,t,r){return null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),t=Zr(t)),t=null==n?n:n[t],null==t?w:t.apply(n,r)}function Er(n){return null!=n&&Sr(Bu(n));
+}function Cr(n,t){return n=typeof n=="number"||On.test(n)?+n:-1,t=null==t?Cu:t,-1<n&&0==n%1&&n<t}function Ur(n,t,r){if(!ge(r))return false;var e=typeof t;return("number"==e?Er(r)&&Cr(t,r.length):"string"==e&&t in r)?(t=r[t],n===n?n===t:t!==t):false}function Wr(n,t){var r=typeof n;return"string"==r&&dn.test(n)||"number"==r?true:Oo(n)?false:!yn.test(n)||null!=t&&n in Br(t)}function $r(n){var t=br(n),r=Nn[t];return typeof r=="function"&&t in zn.prototype?n===r?true:(t=zu(r),!!t&&n===t[0]):false}function Sr(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=Cu;
+}function Fr(n,t){return n===w?t:Eo(n,t,Fr)}function Nr(n,t){n=Br(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function Tr(n,t){var r={};return ht(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function Lr(n){for(var t=Re(n),r=t.length,e=r&&n.length,u=!!e&&Sr(e)&&(Oo(n)||pe(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&Cr(f,e)||nu.call(n,f))&&i.push(f)}return i}function zr(n){return null==n?[]:Er(n)?ge(n)?n:Ve(n):Ee(n)}function Br(n){return ge(n)?n:Ve(n)}function Dr(n){if(Oo(n))return n;
+var t=[];return u(n).replace(mn,function(n,r,e,u){t.push(e?u.replace(An,"$1"):r||n)}),t}function Mr(n){return n instanceof zn?n.clone():new Ln(n.__wrapped__,n.__chain__,qn(n.__actions__))}function qr(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0>t?0:t)):[]}function Pr(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0,0>t?0:t)):[]}function Kr(n){return n?n[0]:w}function Vr(n,t,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?bu(u+e,0):e;else if(e)return e=Lt(n,t),
+e<u&&(t===t?t===n[e]:n[e]!==n[e])?e:-1;return r(n,t,e||0)}function Zr(n){var t=n?n.length:0;return t?n[t-1]:w}function Yr(n){return qr(n,1)}function Gr(n,t,e,u){if(!n||!n.length)return[];null!=t&&typeof t!="boolean"&&(u=e,e=Ur(n,t,u)?w:t,t=false);var o=wr();if((null!=e||o!==ut)&&(e=o(e,u,3)),t&&xr()===r){t=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e<u;){var a=n[e],c=t?t(a,e,n):a;e&&i===c||(i=c,f[++o]=a)}n=f}else n=St(n,e);return n}function Jr(n){if(!n||!n.length)return[];var t=-1,r=0;n=Vn(n,function(n){
+return Er(n)?(r=bu(n.length,r),true):void 0});for(var e=Be(r);++t<r;)e[t]=Gn(n,jt(t));return e}function Xr(n,t,r){return n&&n.length?(n=Jr(n),null==t?n:(t=Bt(t,r,4),Gn(n,function(n){return Xn(n,t,w,true)}))):[]}function Hr(n,t){var r=-1,e=n?n.length:0,u={};for(!e||t||Oo(n[0])||(t=[]);++r<e;){var o=n[r];t?u[o]=t[r]:o&&(u[o[0]]=o[1])}return u}function Qr(n){return n=Nn(n),n.__chain__=true,n}function ne(n,t,r){return t.call(r,n)}function te(n,t,r){var e=Oo(n)?Kn:at;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),
+e(n,t)}function re(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,t)}function ee(n,t,r,e){var u=n?Bu(n):0;return Sr(u)||(n=Ee(n),u=n.length),r=typeof r!="number"||e&&Ur(t,r,e)?0:0>r?bu(u+r,0):r||0,typeof n=="string"||!Oo(n)&&be(n)?r<=u&&-1<n.indexOf(t,r):!!u&&-1<xr(n,t,r)}function ue(n,t,r){var e=Oo(n)?Gn:wt;return t=wr(t,r,3),e(n,t)}function oe(n,t,r){if(r?Ur(n,t,r):null==t){n=zr(n);var e=n.length;return 0<e?n[Rt(0,e-1)]:w}r=-1,n=je(n);var e=n.length,u=e-1;for(t=xu(0>t?0:+t||0,e);++r<t;){var e=Rt(r,u),o=n[e];
+n[e]=n[r],n[r]=o}return n.length=t,n}function ie(n,t,r){var e=Oo(n)?Hn:Ct;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),e(n,t)}function fe(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var e=n;n=t,t=e}return function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=w),r}}function ae(n,t,r){function e(t,r){r&&iu(r),a=p=h=w,t&&(_=ho(),c=n.apply(s,f),p||a||(f=s=w))}function u(){var n=t-(ho()-l);0>=n||n>t?e(h,a):p=su(u,n)}function o(){e(g,p);
+}function i(){if(f=arguments,l=ho(),s=this,h=g&&(p||!y),false===v)var r=y&&!p;else{a||y||(_=l);var e=v-(l-_),i=0>=e||e>v;i?(a&&(a=iu(a)),_=l,c=n.apply(s,f)):a||(a=su(o,e))}return i&&p?p=iu(p):p||t===v||(p=su(u,t)),r&&(i=true,c=n.apply(s,f)),!i||p||a||(f=s=w),c}var f,a,c,l,s,p,h,_=0,v=false,g=true;if(typeof n!="function")throw new Ge(L);if(t=0>t?0:+t||0,true===r)var y=true,g=false;else ge(r)&&(y=!!r.leading,v="maxWait"in r&&bu(+r.maxWait||0,t),g="trailing"in r?!!r.trailing:g);return i.cancel=function(){p&&iu(p),a&&iu(a),
+_=0,a=p=h=w},i}function ce(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Ge(L);return r.cache=new ce.Cache,r}function le(n,t){if(typeof n!="function")throw new Ge(L);return t=bu(t===w?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bu(r.length-t,0),o=Be(u);++e<u;)o[e]=r[t+e];switch(t){case 0:return n.call(this,o);case 1:return n.call(this,r[0],o);
+case 2:return n.call(this,r[0],r[1],o)}for(u=Be(t+1),e=-1;++e<t;)u[e]=r[e];return u[t]=o,n.apply(this,u)}}function se(n,t){return n>t}function pe(n){return h(n)&&Er(n)&&nu.call(n,"callee")&&!cu.call(n,"callee")}function he(n,t,r,e){return e=(r=typeof r=="function"?Bt(r,e,3):w)?r(n,t):w,e===w?dt(n,t,r):!!e}function _e(n){return h(n)&&typeof n.message=="string"&&ru.call(n)==P}function ve(n){return ge(n)&&ru.call(n)==K}function ge(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function ye(n){
+return null==n?false:ve(n)?uu.test(Qe.call(n)):h(n)&&Rn.test(n)}function de(n){return typeof n=="number"||h(n)&&ru.call(n)==V}function me(n){var t;if(!h(n)||ru.call(n)!=Z||pe(n)||!(nu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return ht(n,function(n,t){r=t}),r===w||nu.call(n,r)}function we(n){return ge(n)&&ru.call(n)==Y}function be(n){return typeof n=="string"||h(n)&&ru.call(n)==G}function xe(n){return h(n)&&Sr(n.length)&&!!Sn[ru.call(n)]}function Ae(n,t){
+return n<t}function je(n){var t=n?Bu(n):0;return Sr(t)?t?qn(n):[]:Ee(n)}function ke(n){return et(n,Re(n))}function Ie(n){return gt(n,Re(n))}function Re(n){if(null==n)return[];ge(n)||(n=Ve(n));for(var t=n.length,t=t&&Sr(t)&&(Oo(n)||pe(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=Be(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&Cr(i,t)||"constructor"==i&&(r||!nu.call(n,i))||u.push(i);return u}function Oe(n){n=Br(n);for(var t=-1,r=zo(n),e=r.length,u=Be(e);++t<e;){var o=r[t];
+u[t]=[o,n[o]]}return u}function Ee(n){return Ft(n,zo(n))}function Ce(n){return(n=u(n))&&n.replace(En,a).replace(xn,"")}function Ue(n,t){var r="";if(n=u(n),t=+t,1>t||!n||!mu(t))return r;do t%2&&(r+=n),t=yu(t/2),n+=n;while(t);return r}function We(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function $e(n,t,r){return r&&Ur(n,t,r)&&(t=w),n=u(n),n.match(t||Wn)||[]}function Se(n,t,r){return r&&Ur(n,t,r)&&(t=w),h(n)?Ne(n):ut(n,t)}function Fe(n){
+return n}function Ne(n){return bt(ot(n,true))}function Te(n,t,r){if(null==r){var e=ge(t),u=e?zo(t):w;((u=u&&u.length?gt(t,u):w)?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=gt(t,zo(t)));var o=true,e=-1,i=ve(n),f=u.length;false===r?o=false:ge(r)&&"chain"in r&&(o=r.chain);for(;++e<f;){r=u[e];var a=t[r];n[r]=a,i&&(n.prototype[r]=function(t){return function(){var r=this.__chain__;if(o||r){var e=n(this.__wrapped__);return(e.__actions__=qn(this.__actions__)).push({func:t,args:arguments,thisArg:n}),e.__chain__=r,e}return t.apply(n,Jn([this.value()],arguments));
+}}(a))}return n}function Le(){}function ze(n){return Wr(n)?jt(n):kt(n)}_=_?Yn.defaults(Zn.Object(),_,Yn.pick(Zn,$n)):Zn;var Be=_.Array,De=_.Date,Me=_.Error,qe=_.Function,Pe=_.Math,Ke=_.Number,Ve=_.Object,Ze=_.RegExp,Ye=_.String,Ge=_.TypeError,Je=Be.prototype,Xe=Ve.prototype,He=Ye.prototype,Qe=qe.prototype.toString,nu=Xe.hasOwnProperty,tu=0,ru=Xe.toString,eu=Zn._,uu=Ze("^"+Qe.call(nu).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ou=_.ArrayBuffer,iu=_.clearTimeout,fu=_.parseFloat,au=Pe.pow,cu=Xe.propertyIsEnumerable,lu=jr(_,"Set"),su=_.setTimeout,pu=Je.splice,hu=_.Uint8Array,_u=jr(_,"WeakMap"),vu=Pe.ceil,gu=jr(Ve,"create"),yu=Pe.floor,du=jr(Be,"isArray"),mu=_.isFinite,wu=jr(Ve,"keys"),bu=Pe.max,xu=Pe.min,Au=jr(De,"now"),ju=_.parseInt,ku=Pe.random,Iu=Ke.NEGATIVE_INFINITY,Ru=Ke.POSITIVE_INFINITY,Ou=4294967294,Eu=2147483647,Cu=9007199254740991,Uu=_u&&new _u,Wu={};
+Nn.support={},Nn.templateSettings={escape:_n,evaluate:vn,interpolate:gn,variable:"",imports:{_:Nn}};var $u=function(){function n(){}return function(t){if(ge(t)){n.prototype=t;var r=new n;n.prototype=w}return r||{}}}(),Su=Vt(_t),Fu=Vt(vt,true),Nu=Zt(),Tu=Zt(true),Lu=Uu?function(n,t){return Uu.set(n,t),n}:Fe,zu=Uu?function(n){return Uu.get(n)}:Le,Bu=jt("length"),Du=function(){var n=0,t=0;return function(r,e){var u=ho(),o=S-(u-t);if(t=u,0<o){if(++n>=$)return r}else n=0;return Lu(r,e)}}(),Mu=le(function(n,t){
+return h(n)&&Er(n)?ft(n,pt(t,false,true)):[]}),qu=tr(),Pu=tr(true),Ku=le(function(n){for(var t=n.length,e=t,u=Be(l),o=xr(),i=o===r,f=[];e--;){var a=n[e]=Er(a=n[e])?a:[];u[e]=i&&120<=a.length&&gu&&lu?new Dn(e&&a):null}var i=n[0],c=-1,l=i?i.length:0,s=u[0];n:for(;++c<l;)if(a=i[c],0>(s?Mn(s,a):o(f,a,0))){for(e=t;--e;){var p=u[e];if(0>(p?Mn(p,a):o(n[e],a,0)))continue n}s&&s.push(a),f.push(a)}return f}),Vu=le(function(t,r){r=pt(r);var e=rt(t,r);return It(t,r.sort(n)),e}),Zu=vr(),Yu=vr(true),Gu=le(function(n){return St(pt(n,false,true));
+}),Ju=le(function(n,t){return Er(n)?ft(n,t):[]}),Xu=le(Jr),Hu=le(function(n){var t=n.length,r=2<t?n[t-2]:w,e=1<t?n[t-1]:w;return 2<t&&typeof r=="function"?t-=2:(r=1<t&&typeof e=="function"?(--t,e):w,e=w),n.length=t,Xr(n,r,e)}),Qu=le(function(n){return n=pt(n),this.thru(function(t){t=Oo(t)?t:[Br(t)];for(var r=n,e=-1,u=t.length,o=-1,i=r.length,f=Be(u+i);++e<u;)f[e]=t[e];for(;++o<i;)f[e++]=r[o];return f})}),no=le(function(n,t){return rt(n,pt(t))}),to=Pt(function(n,t,r){nu.call(n,r)?++n[r]:n[r]=1}),ro=nr(Su),eo=nr(Fu,true),uo=ur(Pn,Su),oo=ur(function(n,t){
+for(var r=n.length;r--&&false!==t(n[r],r,n););return n},Fu),io=Pt(function(n,t,r){nu.call(n,r)?n[r].push(t):n[r]=[t]}),fo=Pt(function(n,t,r){n[r]=t}),ao=le(function(n,t,r){var e=-1,u=typeof t=="function",o=Wr(t),i=Er(n)?Be(n.length):[];return Su(n,function(n){var f=u?t:o&&null!=n?n[t]:w;i[++e]=f?f.apply(n,r):Or(n,t,r)}),i}),co=Pt(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),lo=lr(Xn,Su),so=lr(function(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r},Fu),po=le(function(n,t){
+if(null==n)return[];var r=t[2];return r&&Ur(t[0],t[1],r)&&(t.length=1),Wt(n,pt(t),[])}),ho=Au||function(){return(new De).getTime()},_o=le(function(n,t,r){var e=x;if(r.length)var u=v(r,_o.placeholder),e=e|R;return gr(n,e,t,r,u)}),vo=le(function(n,t){t=t.length?pt(t):Ie(n);for(var r=-1,e=t.length;++r<e;){var u=t[r];n[u]=gr(n[u],x,n)}return n}),go=le(function(n,t,r){var e=x|A;if(r.length)var u=v(r,go.placeholder),e=e|R;return gr(t,e,n,r,u)}),yo=Xt(k),mo=Xt(I),wo=le(function(n,t){return it(n,1,t)}),bo=le(function(n,t,r){
+return it(n,t,r)}),xo=er(),Ao=er(true),jo=le(function(n,t){if(t=pt(t),typeof n!="function"||!Kn(t,e))throw new Ge(L);var r=t.length;return le(function(e){for(var u=xu(e.length,r);u--;)e[u]=t[u](e[u]);return n.apply(this,e)})}),ko=cr(R),Io=cr(O),Ro=le(function(n,t){return gr(n,C,w,w,w,pt(t))}),Oo=du||function(n){return h(n)&&Sr(n.length)&&ru.call(n)==D},Eo=Kt(At),Co=Kt(function(n,t,r){return r?nt(n,t,r):tt(n,t)}),Uo=Ht(Co,function(n,t){return n===w?t:n}),Wo=Ht(Eo,Fr),$o=rr(_t),So=rr(vt),Fo=or(Nu),No=or(Tu),To=ir(_t),Lo=ir(vt),zo=wu?function(n){
+var t=null==n?w:n.constructor;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&Er(n)?Lr(n):ge(n)?wu(n):[]}:Lr,Bo=fr(true),Do=fr(),Mo=le(function(n,t){if(null==n)return{};if("function"!=typeof t[0])return t=Gn(pt(t),Ye),Nr(n,ft(Re(n),t));var r=Bt(t[0],t[1],3);return Tr(n,function(n,t,e){return!r(n,t,e)})}),qo=le(function(n,t){return null==n?{}:"function"==typeof t[0]?Tr(n,Bt(t[0],t[1],3)):Nr(n,pt(t))}),Po=Gt(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t);
+}),Ko=Gt(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Vo=ar(),Zo=ar(true),Yo=Gt(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Go=Gt(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),Jo=le(function(n,t){try{return n.apply(w,t)}catch(r){return _e(r)?r:new Me(r)}}),Xo=le(function(n,t){return function(r){return Or(r,n,t)}}),Ho=le(function(n,t){return function(r){return Or(n,r,t)}}),Qo=_r("ceil"),ni=_r("floor"),ti=Qt(se,Iu),ri=Qt(Ae,Ru),ei=_r("round");return Nn.prototype=Tn.prototype,
+Ln.prototype=$u(Tn.prototype),Ln.prototype.constructor=Ln,zn.prototype=$u(Tn.prototype),zn.prototype.constructor=zn,Bn.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},Bn.prototype.get=function(n){return"__proto__"==n?w:this.__data__[n]},Bn.prototype.has=function(n){return"__proto__"!=n&&nu.call(this.__data__,n)},Bn.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this},Dn.prototype.push=function(n){var t=this.data;typeof n=="string"||ge(n)?t.set.add(n):t.hash[n]=true;
+},ce.Cache=Bn,Nn.after=function(n,t){if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var r=n;n=t,t=r}return n=mu(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Nn.ary=function(n,t,r){return r&&Ur(n,t,r)&&(t=w),t=n&&null==t?n.length:bu(+t||0,0),gr(n,E,w,w,w,w,t)},Nn.assign=Co,Nn.at=no,Nn.before=fe,Nn.bind=_o,Nn.bindAll=vo,Nn.bindKey=go,Nn.callback=Se,Nn.chain=Qr,Nn.chunk=function(n,t,r){t=(r?Ur(n,t,r):null==t)?1:bu(yu(t)||1,1),r=0;for(var e=n?n.length:0,u=-1,o=Be(vu(e/t));r<e;)o[++u]=Et(n,r,r+=t);
+return o},Nn.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++t<r;){var o=n[t];o&&(u[++e]=o)}return u},Nn.constant=function(n){return function(){return n}},Nn.countBy=to,Nn.create=function(n,t,r){var e=$u(n);return r&&Ur(n,t,r)&&(t=w),t?tt(e,t):e},Nn.curry=yo,Nn.curryRight=mo,Nn.debounce=ae,Nn.defaults=Uo,Nn.defaultsDeep=Wo,Nn.defer=wo,Nn.delay=bo,Nn.difference=Mu,Nn.drop=qr,Nn.dropRight=Pr,Nn.dropRightWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3),true,true):[]},Nn.dropWhile=function(n,t,r){
+return n&&n.length?Nt(n,wr(t,r,3),true):[]},Nn.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&Ur(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=e===w||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nn.filter=re,Nn.flatten=function(n,t,r){var e=n?n.length:0;return r&&Ur(n,t,r)&&(t=false),e?pt(n,t):[]},Nn.flattenDeep=function(n){return n&&n.length?pt(n,true):[]},Nn.flow=xo,Nn.flowRight=Ao,Nn.forEach=uo,Nn.forEachRight=oo,Nn.forIn=Fo,
+Nn.forInRight=No,Nn.forOwn=To,Nn.forOwnRight=Lo,Nn.functions=Ie,Nn.groupBy=io,Nn.indexBy=fo,Nn.initial=function(n){return Pr(n,1)},Nn.intersection=Ku,Nn.invert=function(n,t,r){r&&Ur(n,t,r)&&(t=w),r=-1;for(var e=zo(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?nu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nn.invoke=ao,Nn.keys=zo,Nn.keysIn=Re,Nn.map=ue,Nn.mapKeys=Bo,Nn.mapValues=Do,Nn.matches=Ne,Nn.matchesProperty=function(n,t){return xt(n,ot(t,true))},Nn.memoize=ce,Nn.merge=Eo,Nn.method=Xo,Nn.methodOf=Ho,
+Nn.mixin=Te,Nn.modArgs=jo,Nn.negate=function(n){if(typeof n!="function")throw new Ge(L);return function(){return!n.apply(this,arguments)}},Nn.omit=Mo,Nn.once=function(n){return fe(2,n)},Nn.pairs=Oe,Nn.partial=ko,Nn.partialRight=Io,Nn.partition=co,Nn.pick=qo,Nn.pluck=function(n,t){return ue(n,ze(t))},Nn.property=ze,Nn.propertyOf=function(n){return function(t){return yt(n,Dr(t),t+"")}},Nn.pull=function(){var n=arguments,t=n[0];if(!t||!t.length)return t;for(var r=0,e=xr(),u=n.length;++r<u;)for(var o=0,i=n[r];-1<(o=e(t,i,o));)pu.call(t,o,1);
+return t},Nn.pullAt=Vu,Nn.range=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0;var e=-1;t=bu(vu((t-n)/(r||1)),0);for(var u=Be(t);++e<t;)u[e]=n,n+=r;return u},Nn.rearg=Ro,Nn.reject=function(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})},Nn.remove=function(n,t,r){var e=[];if(!n||!n.length)return e;var u=-1,o=[],i=n.length;for(t=wr(t,r,3);++u<i;)r=n[u],t(r,u,n)&&(e.push(r),o.push(u));return It(n,o),e},Nn.rest=Yr,Nn.restParam=le,
+Nn.set=function(n,t,r){if(null==n)return n;var e=t+"";t=null!=n[e]||Wr(t,n)?[e]:Dr(t);for(var e=-1,u=t.length,o=u-1,i=n;null!=i&&++e<u;){var f=t[e];ge(i)&&(e==o?i[f]=r:null==i[f]&&(i[f]=Cr(t[e+1])?[]:{})),i=i[f]}return n},Nn.shuffle=function(n){return oe(n,Ru)},Nn.slice=function(n,t,r){var e=n?n.length:0;return e?(r&&typeof r!="number"&&Ur(n,t,r)&&(t=0,r=e),Et(n,t,r)):[]},Nn.sortBy=function(n,t,r){if(null==n)return[];r&&Ur(n,t,r)&&(t=w);var e=-1;return t=wr(t,r,3),n=wt(n,function(n,r,u){return{a:t(n,r,u),
+b:++e,c:n}}),Ut(n,f)},Nn.sortByAll=po,Nn.sortByOrder=function(n,t,r,e){return null==n?[]:(e&&Ur(t,r,e)&&(r=w),Oo(t)||(t=null==t?[]:[t]),Oo(r)||(r=null==r?[]:[r]),Wt(n,t,r))},Nn.spread=function(n){if(typeof n!="function")throw new Ge(L);return function(t){return n.apply(this,t)}},Nn.take=function(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0,0>t?0:t)):[]},Nn.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0>t?0:t)):[]},Nn.takeRightWhile=function(n,t,r){
+return n&&n.length?Nt(n,wr(t,r,3),false,true):[]},Nn.takeWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3)):[]},Nn.tap=function(n,t,r){return t.call(r,n),n},Nn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Ge(L);return false===r?e=false:ge(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ae(n,t,{leading:e,maxWait:+t,trailing:u})},Nn.thru=ne,Nn.times=function(n,t,r){if(n=yu(n),1>n||!mu(n))return[];var e=-1,u=Be(xu(n,4294967295));for(t=Bt(t,r,1);++e<n;)4294967295>e?u[e]=t(e):t(e);
+return u},Nn.toArray=je,Nn.toPlainObject=ke,Nn.transform=function(n,t,r,e){var u=Oo(n)||xe(n);return t=wr(t,e,4),null==r&&(u||ge(n)?(e=n.constructor,r=u?Oo(n)?new e:[]:$u(ve(e)?e.prototype:w)):r={}),(u?Pn:_t)(n,function(n,e,u){return t(r,n,e,u)}),r},Nn.union=Gu,Nn.uniq=Gr,Nn.unzip=Jr,Nn.unzipWith=Xr,Nn.values=Ee,Nn.valuesIn=function(n){return Ft(n,Re(n))},Nn.where=function(n,t){return re(n,bt(t))},Nn.without=Ju,Nn.wrap=function(n,t){return t=null==t?Fe:t,gr(t,R,w,[n],[])},Nn.xor=function(){for(var n=-1,t=arguments.length;++n<t;){
+var r=arguments[n];if(Er(r))var e=e?Jn(ft(e,r),ft(r,e)):r}return e?St(e):[]},Nn.zip=Xu,Nn.zipObject=Hr,Nn.zipWith=Hu,Nn.backflow=Ao,Nn.collect=ue,Nn.compose=Ao,Nn.each=uo,Nn.eachRight=oo,Nn.extend=Co,Nn.iteratee=Se,Nn.methods=Ie,Nn.object=Hr,Nn.select=re,Nn.tail=Yr,Nn.unique=Gr,Te(Nn,Nn),Nn.add=function(n,t){return(+n||0)+(+t||0)},Nn.attempt=Jo,Nn.camelCase=Po,Nn.capitalize=function(n){return(n=u(n))&&n.charAt(0).toUpperCase()+n.slice(1)},Nn.ceil=Qo,Nn.clone=function(n,t,r,e){return t&&typeof t!="boolean"&&Ur(n,t,r)?t=false:typeof t=="function"&&(e=r,
+r=t,t=false),typeof r=="function"?ot(n,t,Bt(r,e,3)):ot(n,t)},Nn.cloneDeep=function(n,t,r){return typeof t=="function"?ot(n,true,Bt(t,r,3)):ot(n,true)},Nn.deburr=Ce,Nn.endsWith=function(n,t,r){n=u(n),t+="";var e=n.length;return r=r===w?e:xu(0>r?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Nn.escape=function(n){return(n=u(n))&&hn.test(n)?n.replace(sn,c):n},Nn.escapeRegExp=function(n){return(n=u(n))&&bn.test(n)?n.replace(wn,l):n||"(?:)"},Nn.every=te,Nn.find=ro,Nn.findIndex=qu,Nn.findKey=$o,Nn.findLast=eo,
+Nn.findLastIndex=Pu,Nn.findLastKey=So,Nn.findWhere=function(n,t){return ro(n,bt(t))},Nn.first=Kr,Nn.floor=ni,Nn.get=function(n,t,r){return n=null==n?w:yt(n,Dr(t),t+""),n===w?r:n},Nn.gt=se,Nn.gte=function(n,t){return n>=t},Nn.has=function(n,t){if(null==n)return false;var r=nu.call(n,t);if(!r&&!Wr(t)){if(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),null==n)return false;t=Zr(t),r=nu.call(n,t)}return r||Sr(n.length)&&Cr(t,n.length)&&(Oo(n)||pe(n))},Nn.identity=Fe,Nn.includes=ee,Nn.indexOf=Vr,Nn.inRange=function(n,t,r){
+return t=+t||0,r===w?(r=t,t=0):r=+r||0,n>=xu(t,r)&&n<bu(t,r)},Nn.isArguments=pe,Nn.isArray=Oo,Nn.isBoolean=function(n){return true===n||false===n||h(n)&&ru.call(n)==M},Nn.isDate=function(n){return h(n)&&ru.call(n)==q},Nn.isElement=function(n){return!!n&&1===n.nodeType&&h(n)&&!me(n)},Nn.isEmpty=function(n){return null==n?true:Er(n)&&(Oo(n)||be(n)||pe(n)||h(n)&&ve(n.splice))?!n.length:!zo(n).length},Nn.isEqual=he,Nn.isError=_e,Nn.isFinite=function(n){return typeof n=="number"&&mu(n)},Nn.isFunction=ve,Nn.isMatch=function(n,t,r,e){
+return r=typeof r=="function"?Bt(r,e,3):w,mt(n,Ar(t),r)},Nn.isNaN=function(n){return de(n)&&n!=+n},Nn.isNative=ye,Nn.isNull=function(n){return null===n},Nn.isNumber=de,Nn.isObject=ge,Nn.isPlainObject=me,Nn.isRegExp=we,Nn.isString=be,Nn.isTypedArray=xe,Nn.isUndefined=function(n){return n===w},Nn.kebabCase=Ko,Nn.last=Zr,Nn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?bu(e+r,0):xu(r||0,e-1))+1;else if(r)return u=Lt(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;
+if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nn.lt=Ae,Nn.lte=function(n,t){return n<=t},Nn.max=ti,Nn.min=ri,Nn.noConflict=function(){return Zn._=eu,this},Nn.noop=Le,Nn.now=ho,Nn.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return e<t&&mu(t)?(e=(t-e)/2,t=yu(e),e=vu(e),r=pr("",e,r),r.slice(0,t)+n+r):n},Nn.padLeft=Vo,Nn.padRight=Zo,Nn.parseInt=function(n,t,r){return(r?Ur(n,t,r):null==t)?t=0:t&&(t=+t),n=We(n),ju(n,t||(In.test(n)?16:10))},Nn.random=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w);
+var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ku(),xu(n+r*(t-n+fu("1e-"+((r+"").length-1))),t)):Rt(n,t)},Nn.reduce=lo,Nn.reduceRight=so,Nn.repeat=Ue,Nn.result=function(n,t,r){var e=null==n?w:n[t];return e===w&&(null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),e=null==n?w:n[Zr(t)]),e=e===w?r:e),ve(e)?e.call(n):e},Nn.round=ei,Nn.runInContext=m,Nn.size=function(n){var t=n?Bu(n):0;
+return Sr(t)?t:zo(n).length},Nn.snakeCase=Yo,Nn.some=ie,Nn.sortedIndex=Zu,Nn.sortedLastIndex=Yu,Nn.startCase=Go,Nn.startsWith=function(n,t,r){return n=u(n),r=null==r?0:xu(0>r?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nn.sum=function(n,t,r){if(r&&Ur(n,t,r)&&(t=w),t=wr(t,r,3),1==t.length){n=Oo(n)?n:zr(n),r=n.length;for(var e=0;r--;)e+=+t(n[r])||0;n=e}else n=$t(n,t);return n},Nn.template=function(n,t,r){var e=Nn.templateSettings;r&&Ur(n,t,r)&&(t=r=w),n=u(n),t=nt(tt({},r||t),e,Qn),r=nt(tt({},t.imports),e.imports,Qn);
+var o,i,f=zo(r),a=Ft(r,f),c=0;r=t.interpolate||Cn;var l="__p+='";r=Ze((t.escape||Cn).source+"|"+r.source+"|"+(r===gn?jn:Cn).source+"|"+(t.evaluate||Cn).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Un,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(fn,""):l).replace(an,"$1").replace(cn,"$1;"),
+l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Jo(function(){return qe(f,p+"return "+l).apply(w,a)}),t.source=l,_e(t))throw t;return t},Nn.trim=We,Nn.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?Ur(e,t,r):null==t)?g(n):o(n,t+"")):n},Nn.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n;
+},Nn.trunc=function(n,t,r){r&&Ur(n,t,r)&&(t=w);var e=U;if(r=W,null!=t)if(ge(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==o)return t+r;if(we(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Ze(o.source,(kn.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),
+-1<o&&(t=t.slice(0,o)));return t+r},Nn.unescape=function(n){return(n=u(n))&&pn.test(n)?n.replace(ln,d):n},Nn.uniqueId=function(n){var t=++tu;return u(n)+t},Nn.words=$e,Nn.all=te,Nn.any=ie,Nn.contains=ee,Nn.eq=he,Nn.detect=ro,Nn.foldl=lo,Nn.foldr=so,Nn.head=Kr,Nn.include=ee,Nn.inject=lo,Te(Nn,function(){var n={};return _t(Nn,function(t,r){Nn.prototype[r]||(n[r]=t)}),n}(),false),Nn.sample=oe,Nn.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return oe(t,n)}):oe(this.value());
+},Nn.VERSION=b,Pn("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nn[n].placeholder=Nn}),Pn(["drop","take"],function(n,t){zn.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new zn(this);r=null==r?1:bu(yu(r)||0,0);var u=this.clone();return e?u.__takeCount__=xu(u.__takeCount__,r):u.__views__.push({size:r,type:n+(0>u.__dir__?"Right":"")}),u},zn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),Pn(["filter","map","takeWhile"],function(n,t){
+var r=t+1,e=r!=T;zn.prototype[n]=function(n,t){var u=this.clone();return u.__iteratees__.push({iteratee:wr(n,t,1),type:r}),u.__filtered__=u.__filtered__||e,u}}),Pn(["first","last"],function(n,t){var r="take"+(t?"Right":"");zn.prototype[n]=function(){return this[r](1).value()[0]}}),Pn(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");zn.prototype[n]=function(){return this.__filtered__?new zn(this):this[r](1)}}),Pn(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?bt:ze;zn.prototype[n]=function(n){
+return this[r](e(n))}}),zn.prototype.compact=function(){return this.filter(Fe)},zn.prototype.reject=function(n,t){return n=wr(n,t,1),this.filter(function(t){return!n(t)})},zn.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=this;return r.__filtered__&&(0<n||0>t)?new zn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==w&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},zn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},zn.prototype.toArray=function(){return this.take(Ru);
+},_t(zn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=Nn[e?"take"+("last"==t?"Right":""):t];u&&(Nn.prototype[t]=function(){function t(n){return e&&i?u(n,1)[0]:u.apply(w,Jn([n],o))}var o=e?[1]:arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof zn,l=o[0],s=c||Oo(f);return s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false),l={func:ne,args:[t],thisArg:w},a=c&&!a,e&&!i?a?(f=f.clone(),f.__actions__.push(l),n.call(f)):u.call(w,this.value())[0]:!e&&s?(f=a?f:new zn(this),
+f=n.apply(f,o),f.__actions__.push(l),new Ln(f,i)):this.thru(t)})}),Pn("join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?He:Je)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Nn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),_t(zn.prototype,function(n,t){var r=Nn[t];if(r){var e=r.name+"";(Wu[e]||(Wu[e]=[])).push({
+name:t,func:r})}}),Wu[sr(w,A).name]=[{name:"wrapper",func:w}],zn.prototype.clone=function(){var n=new zn(this.__wrapped__);return n.__actions__=qn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=qn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=qn(this.__views__),n},zn.prototype.reverse=function(){if(this.__filtered__){var n=new zn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},zn.prototype.value=function(){
+var n,t=this.__wrapped__.value(),r=this.__dir__,e=Oo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,a=-1,c=i.length;++a<c;){var l=i[a],s=l.size;switch(l.type){case"drop":f+=s;break;case"dropRight":n-=s;break;case"take":n=xu(n,f+s);break;case"takeRight":f=bu(f,n-s)}}if(n={start:f,end:n},i=n.start,f=n.end,n=f-i,u=u?f:i-1,i=this.__iteratees__,f=i.length,a=0,c=xu(n,this.__takeCount__),!e||o<F||o==n&&c==n)return Tt(t,this.__actions__);e=[];n:for(;n--&&a<c;){for(u+=r,o=-1,l=t[u];++o<f;){var p=i[o],s=p.type,p=p.iteratee(l);
+if(s==T)l=p;else if(!p){if(s==N)continue n;break n}}e[a++]=l}return e},Nn.prototype.chain=function(){return Qr(this)},Nn.prototype.commit=function(){return new Ln(this.value(),this.__chain__)},Nn.prototype.concat=Qu,Nn.prototype.plant=function(n){for(var t,r=this;r instanceof Tn;){var e=Mr(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nn.prototype.reverse=function(){function n(n){return n.reverse()}var t=this.__wrapped__;return t instanceof zn?(this.__actions__.length&&(t=new zn(this)),
+t=t.reverse(),t.__actions__.push({func:ne,args:[n],thisArg:w}),new Ln(t,this.__chain__)):this.thru(n)},Nn.prototype.toString=function(){return this.value()+""},Nn.prototype.run=Nn.prototype.toJSON=Nn.prototype.valueOf=Nn.prototype.value=function(){return Tt(this.__wrapped__,this.__actions__)},Nn.prototype.collect=Nn.prototype.map,Nn.prototype.head=Nn.prototype.first,Nn.prototype.select=Nn.prototype.filter,Nn.prototype.tail=Nn.prototype.rest,Nn}var w,b="3.10.1",x=1,A=2,j=4,k=8,I=16,R=32,O=64,E=128,C=256,U=30,W="...",$=150,S=16,F=200,N=1,T=2,L="Expected a function",z="__lodash_placeholder__",B="[object Arguments]",D="[object Array]",M="[object Boolean]",q="[object Date]",P="[object Error]",K="[object Function]",V="[object Number]",Z="[object Object]",Y="[object RegExp]",G="[object String]",J="[object ArrayBuffer]",X="[object Float32Array]",H="[object Float64Array]",Q="[object Int8Array]",nn="[object Int16Array]",tn="[object Int32Array]",rn="[object Uint8Array]",en="[object Uint8ClampedArray]",un="[object Uint16Array]",on="[object Uint32Array]",fn=/\b__p\+='';/g,an=/\b(__p\+=)''\+/g,cn=/(__e\(.*?\)|\b__t\))\+'';/g,ln=/&(?:amp|lt|gt|quot|#39|#96);/g,sn=/[&<>"'`]/g,pn=RegExp(ln.source),hn=RegExp(sn.source),_n=/<%-([\s\S]+?)%>/g,vn=/<%([\s\S]+?)%>/g,gn=/<%=([\s\S]+?)%>/g,yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,dn=/^\w*$/,mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,wn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,bn=RegExp(wn.source),xn=/[\u0300-\u036f\ufe20-\ufe23]/g,An=/\\(\\)?/g,jn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kn=/\w*$/,In=/^0[xX]/,Rn=/^\[object .+?Constructor\]$/,On=/^\d+$/,En=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Cn=/($^)/,Un=/['\n\r\u2028\u2029\\]/g,Wn=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),$n="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout isFinite parseFloat parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap".split(" "),Sn={};
+Sn[X]=Sn[H]=Sn[Q]=Sn[nn]=Sn[tn]=Sn[rn]=Sn[en]=Sn[un]=Sn[on]=true,Sn[B]=Sn[D]=Sn[J]=Sn[M]=Sn[q]=Sn[P]=Sn[K]=Sn["[object Map]"]=Sn[V]=Sn[Z]=Sn[Y]=Sn["[object Set]"]=Sn[G]=Sn["[object WeakMap]"]=false;var Fn={};Fn[B]=Fn[D]=Fn[J]=Fn[M]=Fn[q]=Fn[X]=Fn[H]=Fn[Q]=Fn[nn]=Fn[tn]=Fn[V]=Fn[Z]=Fn[Y]=Fn[G]=Fn[rn]=Fn[en]=Fn[un]=Fn[on]=true,Fn[P]=Fn[K]=Fn["[object Map]"]=Fn["[object Set]"]=Fn["[object WeakMap]"]=false;var Nn={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a",
+"\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y",
+"\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Tn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},Ln={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},zn={"function":true,object:true},Bn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Dn={"\\":"\\",
+"'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mn=zn[typeof exports]&&exports&&!exports.nodeType&&exports,qn=zn[typeof module]&&module&&!module.nodeType&&module,Pn=zn[typeof self]&&self&&self.Object&&self,Kn=zn[typeof window]&&window&&window.Object&&window,Vn=qn&&qn.exports===Mn&&Mn,Zn=Mn&&qn&&typeof global=="object"&&global&&global.Object&&global||Kn!==(this&&this.window)&&Kn||Pn||this,Yn=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zn._=Yn, define(function(){
+return Yn})):Mn&&qn?Vn?(qn.exports=Yn)._=Yn:Mn._=Yn:Zn._=Yn}).call(this); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/moment.js b/StoneIsland/platforms/android/assets/www/js/vendor/moment.js
new file mode 100755
index 00000000..30e9239a
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/moment.js
@@ -0,0 +1,3195 @@
+//! moment.js
+//! version : 2.10.6
+//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
+//! license : MIT
+//! momentjs.com
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ global.moment = factory()
+}(this, function () { 'use strict';
+
+ var hookCallback;
+
+ function utils_hooks__hooks () {
+ return hookCallback.apply(null, arguments);
+ }
+
+ // This is done to register the method called with moment()
+ // without creating circular dependencies.
+ function setHookCallback (callback) {
+ hookCallback = callback;
+ }
+
+ function isArray(input) {
+ return Object.prototype.toString.call(input) === '[object Array]';
+ }
+
+ function isDate(input) {
+ return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
+ }
+
+ function map(arr, fn) {
+ var res = [], i;
+ for (i = 0; i < arr.length; ++i) {
+ res.push(fn(arr[i], i));
+ }
+ return res;
+ }
+
+ function hasOwnProp(a, b) {
+ return Object.prototype.hasOwnProperty.call(a, b);
+ }
+
+ function extend(a, b) {
+ for (var i in b) {
+ if (hasOwnProp(b, i)) {
+ a[i] = b[i];
+ }
+ }
+
+ if (hasOwnProp(b, 'toString')) {
+ a.toString = b.toString;
+ }
+
+ if (hasOwnProp(b, 'valueOf')) {
+ a.valueOf = b.valueOf;
+ }
+
+ return a;
+ }
+
+ function create_utc__createUTC (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, true).utc();
+ }
+
+ function defaultParsingFlags() {
+ // We need to deep clone this object.
+ return {
+ empty : false,
+ unusedTokens : [],
+ unusedInput : [],
+ overflow : -2,
+ charsLeftOver : 0,
+ nullInput : false,
+ invalidMonth : null,
+ invalidFormat : false,
+ userInvalidated : false,
+ iso : false
+ };
+ }
+
+ function getParsingFlags(m) {
+ if (m._pf == null) {
+ m._pf = defaultParsingFlags();
+ }
+ return m._pf;
+ }
+
+ function valid__isValid(m) {
+ if (m._isValid == null) {
+ var flags = getParsingFlags(m);
+ m._isValid = !isNaN(m._d.getTime()) &&
+ flags.overflow < 0 &&
+ !flags.empty &&
+ !flags.invalidMonth &&
+ !flags.invalidWeekday &&
+ !flags.nullInput &&
+ !flags.invalidFormat &&
+ !flags.userInvalidated;
+
+ if (m._strict) {
+ m._isValid = m._isValid &&
+ flags.charsLeftOver === 0 &&
+ flags.unusedTokens.length === 0 &&
+ flags.bigHour === undefined;
+ }
+ }
+ return m._isValid;
+ }
+
+ function valid__createInvalid (flags) {
+ var m = create_utc__createUTC(NaN);
+ if (flags != null) {
+ extend(getParsingFlags(m), flags);
+ }
+ else {
+ getParsingFlags(m).userInvalidated = true;
+ }
+
+ return m;
+ }
+
+ var momentProperties = utils_hooks__hooks.momentProperties = [];
+
+ function copyConfig(to, from) {
+ var i, prop, val;
+
+ if (typeof from._isAMomentObject !== 'undefined') {
+ to._isAMomentObject = from._isAMomentObject;
+ }
+ if (typeof from._i !== 'undefined') {
+ to._i = from._i;
+ }
+ if (typeof from._f !== 'undefined') {
+ to._f = from._f;
+ }
+ if (typeof from._l !== 'undefined') {
+ to._l = from._l;
+ }
+ if (typeof from._strict !== 'undefined') {
+ to._strict = from._strict;
+ }
+ if (typeof from._tzm !== 'undefined') {
+ to._tzm = from._tzm;
+ }
+ if (typeof from._isUTC !== 'undefined') {
+ to._isUTC = from._isUTC;
+ }
+ if (typeof from._offset !== 'undefined') {
+ to._offset = from._offset;
+ }
+ if (typeof from._pf !== 'undefined') {
+ to._pf = getParsingFlags(from);
+ }
+ if (typeof from._locale !== 'undefined') {
+ to._locale = from._locale;
+ }
+
+ if (momentProperties.length > 0) {
+ for (i in momentProperties) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (typeof val !== 'undefined') {
+ to[prop] = val;
+ }
+ }
+ }
+
+ return to;
+ }
+
+ var updateInProgress = false;
+
+ // Moment prototype object
+ function Moment(config) {
+ copyConfig(this, config);
+ this._d = new Date(config._d != null ? config._d.getTime() : NaN);
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ utils_hooks__hooks.updateOffset(this);
+ updateInProgress = false;
+ }
+ }
+
+ function isMoment (obj) {
+ return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
+ }
+
+ function absFloor (number) {
+ if (number < 0) {
+ return Math.ceil(number);
+ } else {
+ return Math.floor(number);
+ }
+ }
+
+ function toInt(argumentForCoercion) {
+ var coercedNumber = +argumentForCoercion,
+ value = 0;
+
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
+ value = absFloor(coercedNumber);
+ }
+
+ return value;
+ }
+
+ function compareArrays(array1, array2, dontConvert) {
+ var len = Math.min(array1.length, array2.length),
+ lengthDiff = Math.abs(array1.length - array2.length),
+ diffs = 0,
+ i;
+ for (i = 0; i < len; i++) {
+ if ((dontConvert && array1[i] !== array2[i]) ||
+ (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
+ diffs++;
+ }
+ }
+ return diffs + lengthDiff;
+ }
+
+ function Locale() {
+ }
+
+ var locales = {};
+ var globalLocale;
+
+ function normalizeLocale(key) {
+ return key ? key.toLowerCase().replace('_', '-') : key;
+ }
+
+ // pick the locale from the array
+ // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+ // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
+ function chooseLocale(names) {
+ var i = 0, j, next, locale, split;
+
+ while (i < names.length) {
+ split = normalizeLocale(names[i]).split('-');
+ j = split.length;
+ next = normalizeLocale(names[i + 1]);
+ next = next ? next.split('-') : null;
+ while (j > 0) {
+ locale = loadLocale(split.slice(0, j).join('-'));
+ if (locale) {
+ return locale;
+ }
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
+ //the next array item is better than a shallower substring of this one
+ break;
+ }
+ j--;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ function loadLocale(name) {
+ var oldLocale = null;
+ // TODO: Find a better way to register and load all the locales in Node
+ if (!locales[name] && typeof module !== 'undefined' &&
+ module && module.exports) {
+ try {
+ oldLocale = globalLocale._abbr;
+ require('./locale/' + name);
+ // because defineLocale currently also sets the global locale, we
+ // want to undo that for lazy loaded locales
+ locale_locales__getSetGlobalLocale(oldLocale);
+ } catch (e) { }
+ }
+ return locales[name];
+ }
+
+ // This function will load locale and then set the global locale. If
+ // no arguments are passed in, it will simply return the current global
+ // locale key.
+ function locale_locales__getSetGlobalLocale (key, values) {
+ var data;
+ if (key) {
+ if (typeof values === 'undefined') {
+ data = locale_locales__getLocale(key);
+ }
+ else {
+ data = defineLocale(key, values);
+ }
+
+ if (data) {
+ // moment.duration._locale = moment._locale = data;
+ globalLocale = data;
+ }
+ }
+
+ return globalLocale._abbr;
+ }
+
+ function defineLocale (name, values) {
+ if (values !== null) {
+ values.abbr = name;
+ locales[name] = locales[name] || new Locale();
+ locales[name].set(values);
+
+ // backwards compat for now: also set the locale
+ locale_locales__getSetGlobalLocale(name);
+
+ return locales[name];
+ } else {
+ // useful for testing
+ delete locales[name];
+ return null;
+ }
+ }
+
+ // returns locale data
+ function locale_locales__getLocale (key) {
+ var locale;
+
+ if (key && key._locale && key._locale._abbr) {
+ key = key._locale._abbr;
+ }
+
+ if (!key) {
+ return globalLocale;
+ }
+
+ if (!isArray(key)) {
+ //short-circuit everything else
+ locale = loadLocale(key);
+ if (locale) {
+ return locale;
+ }
+ key = [key];
+ }
+
+ return chooseLocale(key);
+ }
+
+ var aliases = {};
+
+ function addUnitAlias (unit, shorthand) {
+ var lowerCase = unit.toLowerCase();
+ aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
+ }
+
+ function normalizeUnits(units) {
+ return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
+ }
+
+ function normalizeObjectUnits(inputObject) {
+ var normalizedInput = {},
+ normalizedProp,
+ prop;
+
+ for (prop in inputObject) {
+ if (hasOwnProp(inputObject, prop)) {
+ normalizedProp = normalizeUnits(prop);
+ if (normalizedProp) {
+ normalizedInput[normalizedProp] = inputObject[prop];
+ }
+ }
+ }
+
+ return normalizedInput;
+ }
+
+ function makeGetSet (unit, keepTime) {
+ return function (value) {
+ if (value != null) {
+ get_set__set(this, unit, value);
+ utils_hooks__hooks.updateOffset(this, keepTime);
+ return this;
+ } else {
+ return get_set__get(this, unit);
+ }
+ };
+ }
+
+ function get_set__get (mom, unit) {
+ return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
+ }
+
+ function get_set__set (mom, unit, value) {
+ return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+ }
+
+ // MOMENTS
+
+ function getSet (units, value) {
+ var unit;
+ if (typeof units === 'object') {
+ for (unit in units) {
+ this.set(unit, units[unit]);
+ }
+ } else {
+ units = normalizeUnits(units);
+ if (typeof this[units] === 'function') {
+ return this[units](value);
+ }
+ }
+ return this;
+ }
+
+ function zeroFill(number, targetLength, forceSign) {
+ var absNumber = '' + Math.abs(number),
+ zerosToFill = targetLength - absNumber.length,
+ sign = number >= 0;
+ return (sign ? (forceSign ? '+' : '') : '-') +
+ Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
+ }
+
+ var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+
+ var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
+
+ var formatFunctions = {};
+
+ var formatTokenFunctions = {};
+
+ // token: 'M'
+ // padded: ['MM', 2]
+ // ordinal: 'Mo'
+ // callback: function () { this.month() + 1 }
+ function addFormatToken (token, padded, ordinal, callback) {
+ var func = callback;
+ if (typeof callback === 'string') {
+ func = function () {
+ return this[callback]();
+ };
+ }
+ if (token) {
+ formatTokenFunctions[token] = func;
+ }
+ if (padded) {
+ formatTokenFunctions[padded[0]] = function () {
+ return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
+ };
+ }
+ if (ordinal) {
+ formatTokenFunctions[ordinal] = function () {
+ return this.localeData().ordinal(func.apply(this, arguments), token);
+ };
+ }
+ }
+
+ function removeFormattingTokens(input) {
+ if (input.match(/\[[\s\S]/)) {
+ return input.replace(/^\[|\]$/g, '');
+ }
+ return input.replace(/\\/g, '');
+ }
+
+ function makeFormatFunction(format) {
+ var array = format.match(formattingTokens), i, length;
+
+ for (i = 0, length = array.length; i < length; i++) {
+ if (formatTokenFunctions[array[i]]) {
+ array[i] = formatTokenFunctions[array[i]];
+ } else {
+ array[i] = removeFormattingTokens(array[i]);
+ }
+ }
+
+ return function (mom) {
+ var output = '';
+ for (i = 0; i < length; i++) {
+ output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
+ }
+ return output;
+ };
+ }
+
+ // format date using native date object
+ function formatMoment(m, format) {
+ if (!m.isValid()) {
+ return m.localeData().invalidDate();
+ }
+
+ format = expandFormat(format, m.localeData());
+ formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
+
+ return formatFunctions[format](m);
+ }
+
+ function expandFormat(format, locale) {
+ var i = 5;
+
+ function replaceLongDateFormatTokens(input) {
+ return locale.longDateFormat(input) || input;
+ }
+
+ localFormattingTokens.lastIndex = 0;
+ while (i >= 0 && localFormattingTokens.test(format)) {
+ format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
+ localFormattingTokens.lastIndex = 0;
+ i -= 1;
+ }
+
+ return format;
+ }
+
+ var match1 = /\d/; // 0 - 9
+ var match2 = /\d\d/; // 00 - 99
+ var match3 = /\d{3}/; // 000 - 999
+ var match4 = /\d{4}/; // 0000 - 9999
+ var match6 = /[+-]?\d{6}/; // -999999 - 999999
+ var match1to2 = /\d\d?/; // 0 - 99
+ var match1to3 = /\d{1,3}/; // 0 - 999
+ var match1to4 = /\d{1,4}/; // 0 - 9999
+ var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
+
+ var matchUnsigned = /\d+/; // 0 - inf
+ var matchSigned = /[+-]?\d+/; // -inf - inf
+
+ var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
+
+ var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
+
+ // any word (or two) characters or numbers including two/three word month in arabic.
+ var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+
+ var regexes = {};
+
+ function isFunction (sth) {
+ // https://github.com/moment/moment/issues/2325
+ return typeof sth === 'function' &&
+ Object.prototype.toString.call(sth) === '[object Function]';
+ }
+
+
+ function addRegexToken (token, regex, strictRegex) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict) {
+ return (isStrict && strictRegex) ? strictRegex : regex;
+ };
+ }
+
+ function getParseRegexForToken (token, config) {
+ if (!hasOwnProp(regexes, token)) {
+ return new RegExp(unescapeFormat(token));
+ }
+
+ return regexes[token](config._strict, config._locale);
+ }
+
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+ function unescapeFormat(s) {
+ return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return p1 || p2 || p3 || p4;
+ }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }
+
+ var tokens = {};
+
+ function addParseToken (token, callback) {
+ var i, func = callback;
+ if (typeof token === 'string') {
+ token = [token];
+ }
+ if (typeof callback === 'number') {
+ func = function (input, array) {
+ array[callback] = toInt(input);
+ };
+ }
+ for (i = 0; i < token.length; i++) {
+ tokens[token[i]] = func;
+ }
+ }
+
+ function addWeekParseToken (token, callback) {
+ addParseToken(token, function (input, array, config, token) {
+ config._w = config._w || {};
+ callback(input, config._w, config, token);
+ });
+ }
+
+ function addTimeToArrayFromToken(token, input, config) {
+ if (input != null && hasOwnProp(tokens, token)) {
+ tokens[token](input, config._a, config, token);
+ }
+ }
+
+ var YEAR = 0;
+ var MONTH = 1;
+ var DATE = 2;
+ var HOUR = 3;
+ var MINUTE = 4;
+ var SECOND = 5;
+ var MILLISECOND = 6;
+
+ function daysInMonth(year, month) {
+ return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
+ }
+
+ // FORMATTING
+
+ addFormatToken('M', ['MM', 2], 'Mo', function () {
+ return this.month() + 1;
+ });
+
+ addFormatToken('MMM', 0, 0, function (format) {
+ return this.localeData().monthsShort(this, format);
+ });
+
+ addFormatToken('MMMM', 0, 0, function (format) {
+ return this.localeData().months(this, format);
+ });
+
+ // ALIASES
+
+ addUnitAlias('month', 'M');
+
+ // PARSING
+
+ addRegexToken('M', match1to2);
+ addRegexToken('MM', match1to2, match2);
+ addRegexToken('MMM', matchWord);
+ addRegexToken('MMMM', matchWord);
+
+ addParseToken(['M', 'MM'], function (input, array) {
+ array[MONTH] = toInt(input) - 1;
+ });
+
+ addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
+ var month = config._locale.monthsParse(input, token, config._strict);
+ // if we didn't find a month name, mark the date as invalid.
+ if (month != null) {
+ array[MONTH] = month;
+ } else {
+ getParsingFlags(config).invalidMonth = input;
+ }
+ });
+
+ // LOCALES
+
+ var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
+ function localeMonths (m) {
+ return this._months[m.month()];
+ }
+
+ var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
+ function localeMonthsShort (m) {
+ return this._monthsShort[m.month()];
+ }
+
+ function localeMonthsParse (monthName, format, strict) {
+ var i, mom, regex;
+
+ if (!this._monthsParse) {
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ }
+
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, i]);
+ if (strict && !this._longMonthsParse[i]) {
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
+ }
+ if (!strict && !this._monthsParse[i]) {
+ regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
+ this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
+ return i;
+ }
+ }
+ }
+
+ // MOMENTS
+
+ function setMonth (mom, value) {
+ var dayOfMonth;
+
+ // TODO: Move this out of here!
+ if (typeof value === 'string') {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
+ }
+
+ dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
+ return mom;
+ }
+
+ function getSetMonth (value) {
+ if (value != null) {
+ setMonth(this, value);
+ utils_hooks__hooks.updateOffset(this, true);
+ return this;
+ } else {
+ return get_set__get(this, 'Month');
+ }
+ }
+
+ function getDaysInMonth () {
+ return daysInMonth(this.year(), this.month());
+ }
+
+ function checkOverflow (m) {
+ var overflow;
+ var a = m._a;
+
+ if (a && getParsingFlags(m).overflow === -2) {
+ overflow =
+ a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
+ a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
+ a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
+ a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
+ a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
+ a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
+ -1;
+
+ if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
+ overflow = DATE;
+ }
+
+ getParsingFlags(m).overflow = overflow;
+ }
+
+ return m;
+ }
+
+ function warn(msg) {
+ if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
+ // console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+
+ return extend(function () {
+ if (firstTime) {
+ warn(msg + '\n' + (new Error()).stack);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ var deprecations = {};
+
+ function deprecateSimple(name, msg) {
+ if (!deprecations[name]) {
+ warn(msg);
+ deprecations[name] = true;
+ }
+ }
+
+ utils_hooks__hooks.suppressDeprecationWarnings = false;
+
+ var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
+
+ var isoDates = [
+ ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
+ ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
+ ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
+ ['GGGG-[W]WW', /\d{4}-W\d{2}/],
+ ['YYYY-DDD', /\d{4}-\d{3}/]
+ ];
+
+ // iso time formats and regexes
+ var isoTimes = [
+ ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
+ ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
+ ['HH:mm', /(T| )\d\d:\d\d/],
+ ['HH', /(T| )\d\d/]
+ ];
+
+ var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
+
+ // date from iso format
+ function configFromISO(config) {
+ var i, l,
+ string = config._i,
+ match = from_string__isoRegex.exec(string);
+
+ if (match) {
+ getParsingFlags(config).iso = true;
+ for (i = 0, l = isoDates.length; i < l; i++) {
+ if (isoDates[i][1].exec(string)) {
+ config._f = isoDates[i][0];
+ break;
+ }
+ }
+ for (i = 0, l = isoTimes.length; i < l; i++) {
+ if (isoTimes[i][1].exec(string)) {
+ // match[6] should be 'T' or space
+ config._f += (match[6] || ' ') + isoTimes[i][0];
+ break;
+ }
+ }
+ if (string.match(matchOffset)) {
+ config._f += 'Z';
+ }
+ configFromStringAndFormat(config);
+ } else {
+ config._isValid = false;
+ }
+ }
+
+ // date from iso format or fallback
+ function configFromString(config) {
+ var matched = aspNetJsonRegex.exec(config._i);
+
+ if (matched !== null) {
+ config._d = new Date(+matched[1]);
+ return;
+ }
+
+ configFromISO(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ utils_hooks__hooks.createFromInputFallback(config);
+ }
+ }
+
+ utils_hooks__hooks.createFromInputFallback = deprecate(
+ 'moment construction falls back to js Date. This is ' +
+ 'discouraged and will be removed in upcoming major ' +
+ 'release. Please refer to ' +
+ 'https://github.com/moment/moment/issues/1407 for more info.',
+ function (config) {
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ }
+ );
+
+ function createDate (y, m, d, h, M, s, ms) {
+ //can't just apply() to create a date:
+ //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
+ var date = new Date(y, m, d, h, M, s, ms);
+
+ //the date constructor doesn't accept years < 1970
+ if (y < 1970) {
+ date.setFullYear(y);
+ }
+ return date;
+ }
+
+ function createUTCDate (y) {
+ var date = new Date(Date.UTC.apply(null, arguments));
+ if (y < 1970) {
+ date.setUTCFullYear(y);
+ }
+ return date;
+ }
+
+ addFormatToken(0, ['YY', 2], 0, function () {
+ return this.year() % 100;
+ });
+
+ addFormatToken(0, ['YYYY', 4], 0, 'year');
+ addFormatToken(0, ['YYYYY', 5], 0, 'year');
+ addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
+
+ // ALIASES
+
+ addUnitAlias('year', 'y');
+
+ // PARSING
+
+ addRegexToken('Y', matchSigned);
+ addRegexToken('YY', match1to2, match2);
+ addRegexToken('YYYY', match1to4, match4);
+ addRegexToken('YYYYY', match1to6, match6);
+ addRegexToken('YYYYYY', match1to6, match6);
+
+ addParseToken(['YYYYY', 'YYYYYY'], YEAR);
+ addParseToken('YYYY', function (input, array) {
+ array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
+ });
+ addParseToken('YY', function (input, array) {
+ array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
+ });
+
+ // HELPERS
+
+ function daysInYear(year) {
+ return isLeapYear(year) ? 366 : 365;
+ }
+
+ function isLeapYear(year) {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+ }
+
+ // HOOKS
+
+ utils_hooks__hooks.parseTwoDigitYear = function (input) {
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+ };
+
+ // MOMENTS
+
+ var getSetYear = makeGetSet('FullYear', false);
+
+ function getIsLeapYear () {
+ return isLeapYear(this.year());
+ }
+
+ addFormatToken('w', ['ww', 2], 'wo', 'week');
+ addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
+
+ // ALIASES
+
+ addUnitAlias('week', 'w');
+ addUnitAlias('isoWeek', 'W');
+
+ // PARSING
+
+ addRegexToken('w', match1to2);
+ addRegexToken('ww', match1to2, match2);
+ addRegexToken('W', match1to2);
+ addRegexToken('WW', match1to2, match2);
+
+ addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
+ week[token.substr(0, 1)] = toInt(input);
+ });
+
+ // HELPERS
+
+ // firstDayOfWeek 0 = sun, 6 = sat
+ // the day of the week that starts the week
+ // (usually sunday or monday)
+ // firstDayOfWeekOfYear 0 = sun, 6 = sat
+ // the first week is the week that contains the first
+ // of this day of the week
+ // (eg. ISO weeks use thursday (4))
+ function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
+ var end = firstDayOfWeekOfYear - firstDayOfWeek,
+ daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
+ adjustedMoment;
+
+
+ if (daysToDayOfWeek > end) {
+ daysToDayOfWeek -= 7;
+ }
+
+ if (daysToDayOfWeek < end - 7) {
+ daysToDayOfWeek += 7;
+ }
+
+ adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
+ return {
+ week: Math.ceil(adjustedMoment.dayOfYear() / 7),
+ year: adjustedMoment.year()
+ };
+ }
+
+ // LOCALES
+
+ function localeWeek (mom) {
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
+ }
+
+ var defaultLocaleWeek = {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+ };
+
+ function localeFirstDayOfWeek () {
+ return this._week.dow;
+ }
+
+ function localeFirstDayOfYear () {
+ return this._week.doy;
+ }
+
+ // MOMENTS
+
+ function getSetWeek (input) {
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ }
+
+ function getSetISOWeek (input) {
+ var week = weekOfYear(this, 1, 4).week;
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ }
+
+ addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
+
+ // ALIASES
+
+ addUnitAlias('dayOfYear', 'DDD');
+
+ // PARSING
+
+ addRegexToken('DDD', match1to3);
+ addRegexToken('DDDD', match3);
+ addParseToken(['DDD', 'DDDD'], function (input, array, config) {
+ config._dayOfYear = toInt(input);
+ });
+
+ // HELPERS
+
+ //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
+ function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
+ var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
+ if (d < firstDayOfWeek) {
+ d += 7;
+ }
+
+ weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
+
+ dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
+
+ return {
+ year: dayOfYear > 0 ? year : year - 1,
+ dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
+ };
+ }
+
+ // MOMENTS
+
+ function getSetDayOfYear (input) {
+ var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
+ return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function currentDateArray(config) {
+ var now = new Date();
+ if (config._useUTC) {
+ return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
+ }
+ return [now.getFullYear(), now.getMonth(), now.getDate()];
+ }
+
+ // convert an array to a date.
+ // the array should mirror the parameters below
+ // note: all values past the year are optional and will default to the lowest possible value.
+ // [year, month, day , hour, minute, second, millisecond]
+ function configFromArray (config) {
+ var i, date, input = [], currentDate, yearToUse;
+
+ if (config._d) {
+ return;
+ }
+
+ currentDate = currentDateArray(config);
+
+ //compute day of the year from weeks and weekdays
+ if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
+ dayOfYearFromWeekInfo(config);
+ }
+
+ //if the day of the year is set, figure out what it is
+ if (config._dayOfYear) {
+ yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
+
+ if (config._dayOfYear > daysInYear(yearToUse)) {
+ getParsingFlags(config)._overflowDayOfYear = true;
+ }
+
+ date = createUTCDate(yearToUse, 0, config._dayOfYear);
+ config._a[MONTH] = date.getUTCMonth();
+ config._a[DATE] = date.getUTCDate();
+ }
+
+ // Default to current date.
+ // * if no year, month, day of month are given, default to today
+ // * if day of month is given, default month and year
+ // * if month is given, default only year
+ // * if year is given, don't default anything
+ for (i = 0; i < 3 && config._a[i] == null; ++i) {
+ config._a[i] = input[i] = currentDate[i];
+ }
+
+ // Zero out whatever was not defaulted, including time
+ for (; i < 7; i++) {
+ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
+ }
+
+ // Check for 24:00:00.000
+ if (config._a[HOUR] === 24 &&
+ config._a[MINUTE] === 0 &&
+ config._a[SECOND] === 0 &&
+ config._a[MILLISECOND] === 0) {
+ config._nextDay = true;
+ config._a[HOUR] = 0;
+ }
+
+ config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
+ // Apply timezone offset from input. The actual utcOffset can be changed
+ // with parseZone.
+ if (config._tzm != null) {
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
+ }
+
+ if (config._nextDay) {
+ config._a[HOUR] = 24;
+ }
+ }
+
+ function dayOfYearFromWeekInfo(config) {
+ var w, weekYear, week, weekday, dow, doy, temp;
+
+ w = config._w;
+ if (w.GG != null || w.W != null || w.E != null) {
+ dow = 1;
+ doy = 4;
+
+ // TODO: We need to take the current isoWeekYear, but that depends on
+ // how we interpret now (local, utc, fixed offset). So create
+ // a now version of current config (take local/utc/offset flags, and
+ // create now).
+ weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
+ week = defaults(w.W, 1);
+ weekday = defaults(w.E, 1);
+ } else {
+ dow = config._locale._week.dow;
+ doy = config._locale._week.doy;
+
+ weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
+ week = defaults(w.w, 1);
+
+ if (w.d != null) {
+ // weekday -- low day numbers are considered next week
+ weekday = w.d;
+ if (weekday < dow) {
+ ++week;
+ }
+ } else if (w.e != null) {
+ // local weekday -- counting starts from begining of week
+ weekday = w.e + dow;
+ } else {
+ // default to begining of week
+ weekday = dow;
+ }
+ }
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
+
+ config._a[YEAR] = temp.year;
+ config._dayOfYear = temp.dayOfYear;
+ }
+
+ utils_hooks__hooks.ISO_8601 = function () {};
+
+ // date from string and format string
+ function configFromStringAndFormat(config) {
+ // TODO: Move this to another part of the creation flow to prevent circular deps
+ if (config._f === utils_hooks__hooks.ISO_8601) {
+ configFromISO(config);
+ return;
+ }
+
+ config._a = [];
+ getParsingFlags(config).empty = true;
+
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
+ var string = '' + config._i,
+ i, parsedInput, tokens, token, skipped,
+ stringLength = string.length,
+ totalParsedInputLength = 0;
+
+ tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
+
+ for (i = 0; i < tokens.length; i++) {
+ token = tokens[i];
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ if (parsedInput) {
+ skipped = string.substr(0, string.indexOf(parsedInput));
+ if (skipped.length > 0) {
+ getParsingFlags(config).unusedInput.push(skipped);
+ }
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
+ totalParsedInputLength += parsedInput.length;
+ }
+ // don't parse if it's not a known token
+ if (formatTokenFunctions[token]) {
+ if (parsedInput) {
+ getParsingFlags(config).empty = false;
+ }
+ else {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ addTimeToArrayFromToken(token, parsedInput, config);
+ }
+ else if (config._strict && !parsedInput) {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ }
+
+ // add remaining unparsed input length to the string
+ getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
+ if (string.length > 0) {
+ getParsingFlags(config).unusedInput.push(string);
+ }
+
+ // clear _12h flag if hour is <= 12
+ if (getParsingFlags(config).bigHour === true &&
+ config._a[HOUR] <= 12 &&
+ config._a[HOUR] > 0) {
+ getParsingFlags(config).bigHour = undefined;
+ }
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
+
+ configFromArray(config);
+ checkOverflow(config);
+ }
+
+
+ function meridiemFixWrap (locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // this is not supposed to happen
+ return hour;
+ }
+ }
+
+ function configFromStringAndArray(config) {
+ var tempConfig,
+ bestMoment,
+
+ scoreToBeat,
+ i,
+ currentScore;
+
+ if (config._f.length === 0) {
+ getParsingFlags(config).invalidFormat = true;
+ config._d = new Date(NaN);
+ return;
+ }
+
+ for (i = 0; i < config._f.length; i++) {
+ currentScore = 0;
+ tempConfig = copyConfig({}, config);
+ if (config._useUTC != null) {
+ tempConfig._useUTC = config._useUTC;
+ }
+ tempConfig._f = config._f[i];
+ configFromStringAndFormat(tempConfig);
+
+ if (!valid__isValid(tempConfig)) {
+ continue;
+ }
+
+ // if there is any input that was not parsed add a penalty for that format
+ currentScore += getParsingFlags(tempConfig).charsLeftOver;
+
+ //or tokens
+ currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
+
+ getParsingFlags(tempConfig).score = currentScore;
+
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
+ scoreToBeat = currentScore;
+ bestMoment = tempConfig;
+ }
+ }
+
+ extend(config, bestMoment || tempConfig);
+ }
+
+ function configFromObject(config) {
+ if (config._d) {
+ return;
+ }
+
+ var i = normalizeObjectUnits(config._i);
+ config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
+
+ configFromArray(config);
+ }
+
+ function createFromConfig (config) {
+ var res = new Moment(checkOverflow(prepareConfig(config)));
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+ }
+
+ function prepareConfig (config) {
+ var input = config._i,
+ format = config._f;
+
+ config._locale = config._locale || locale_locales__getLocale(config._l);
+
+ if (input === null || (format === undefined && input === '')) {
+ return valid__createInvalid({nullInput: true});
+ }
+
+ if (typeof input === 'string') {
+ config._i = input = config._locale.preparse(input);
+ }
+
+ if (isMoment(input)) {
+ return new Moment(checkOverflow(input));
+ } else if (isArray(format)) {
+ configFromStringAndArray(config);
+ } else if (format) {
+ configFromStringAndFormat(config);
+ } else if (isDate(input)) {
+ config._d = input;
+ } else {
+ configFromInput(config);
+ }
+
+ return config;
+ }
+
+ function configFromInput(config) {
+ var input = config._i;
+ if (input === undefined) {
+ config._d = new Date();
+ } else if (isDate(input)) {
+ config._d = new Date(+input);
+ } else if (typeof input === 'string') {
+ configFromString(config);
+ } else if (isArray(input)) {
+ config._a = map(input.slice(0), function (obj) {
+ return parseInt(obj, 10);
+ });
+ configFromArray(config);
+ } else if (typeof(input) === 'object') {
+ configFromObject(config);
+ } else if (typeof(input) === 'number') {
+ // from milliseconds
+ config._d = new Date(input);
+ } else {
+ utils_hooks__hooks.createFromInputFallback(config);
+ }
+ }
+
+ function createLocalOrUTC (input, format, locale, strict, isUTC) {
+ var c = {};
+
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
+ }
+ // object construction must be done this way.
+ // https://github.com/moment/moment/issues/1423
+ c._isAMomentObject = true;
+ c._useUTC = c._isUTC = isUTC;
+ c._l = locale;
+ c._i = input;
+ c._f = format;
+ c._strict = strict;
+
+ return createFromConfig(c);
+ }
+
+ function local__createLocal (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, false);
+ }
+
+ var prototypeMin = deprecate(
+ 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ function () {
+ var other = local__createLocal.apply(null, arguments);
+ return other < this ? this : other;
+ }
+ );
+
+ var prototypeMax = deprecate(
+ 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ function () {
+ var other = local__createLocal.apply(null, arguments);
+ return other > this ? this : other;
+ }
+ );
+
+ // Pick a moment m from moments so that m[fn](other) is true for all
+ // other. This relies on the function fn to be transitive.
+ //
+ // moments should either be an array of moment objects or an array, whose
+ // first element is an array of moment objects.
+ function pickBy(fn, moments) {
+ var res, i;
+ if (moments.length === 1 && isArray(moments[0])) {
+ moments = moments[0];
+ }
+ if (!moments.length) {
+ return local__createLocal();
+ }
+ res = moments[0];
+ for (i = 1; i < moments.length; ++i) {
+ if (!moments[i].isValid() || moments[i][fn](res)) {
+ res = moments[i];
+ }
+ }
+ return res;
+ }
+
+ // TODO: Use [].sort instead?
+ function min () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isBefore', args);
+ }
+
+ function max () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isAfter', args);
+ }
+
+ function Duration (duration) {
+ var normalizedInput = normalizeObjectUnits(duration),
+ years = normalizedInput.year || 0,
+ quarters = normalizedInput.quarter || 0,
+ months = normalizedInput.month || 0,
+ weeks = normalizedInput.week || 0,
+ days = normalizedInput.day || 0,
+ hours = normalizedInput.hour || 0,
+ minutes = normalizedInput.minute || 0,
+ seconds = normalizedInput.second || 0,
+ milliseconds = normalizedInput.millisecond || 0;
+
+ // representation for dateAddRemove
+ this._milliseconds = +milliseconds +
+ seconds * 1e3 + // 1000
+ minutes * 6e4 + // 1000 * 60
+ hours * 36e5; // 1000 * 60 * 60
+ // Because of dateAddRemove treats 24 hours as different from a
+ // day when working around DST, we need to store them separately
+ this._days = +days +
+ weeks * 7;
+ // It is impossible translate months into days without knowing
+ // which months you are are talking about, so we have to store
+ // it separately.
+ this._months = +months +
+ quarters * 3 +
+ years * 12;
+
+ this._data = {};
+
+ this._locale = locale_locales__getLocale();
+
+ this._bubble();
+ }
+
+ function isDuration (obj) {
+ return obj instanceof Duration;
+ }
+
+ function offset (token, separator) {
+ addFormatToken(token, 0, 0, function () {
+ var offset = this.utcOffset();
+ var sign = '+';
+ if (offset < 0) {
+ offset = -offset;
+ sign = '-';
+ }
+ return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
+ });
+ }
+
+ offset('Z', ':');
+ offset('ZZ', '');
+
+ // PARSING
+
+ addRegexToken('Z', matchOffset);
+ addRegexToken('ZZ', matchOffset);
+ addParseToken(['Z', 'ZZ'], function (input, array, config) {
+ config._useUTC = true;
+ config._tzm = offsetFromString(input);
+ });
+
+ // HELPERS
+
+ // timezone chunker
+ // '+10:00' > ['10', '00']
+ // '-1530' > ['-15', '30']
+ var chunkOffset = /([\+\-]|\d\d)/gi;
+
+ function offsetFromString(string) {
+ var matches = ((string || '').match(matchOffset) || []);
+ var chunk = matches[matches.length - 1] || [];
+ var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
+ var minutes = +(parts[1] * 60) + toInt(parts[2]);
+
+ return parts[0] === '+' ? minutes : -minutes;
+ }
+
+ // Return a moment from input, that is local/utc/zone equivalent to model.
+ function cloneWithOffset(input, model) {
+ var res, diff;
+ if (model._isUTC) {
+ res = model.clone();
+ diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
+ // Use low-level api, because this fn is low-level api.
+ res._d.setTime(+res._d + diff);
+ utils_hooks__hooks.updateOffset(res, false);
+ return res;
+ } else {
+ return local__createLocal(input).local();
+ }
+ }
+
+ function getDateOffset (m) {
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
+ // https://github.com/moment/moment/pull/1871
+ return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
+ }
+
+ // HOOKS
+
+ // This function will be called whenever a moment is mutated.
+ // It is intended to keep the offset in sync with the timezone.
+ utils_hooks__hooks.updateOffset = function () {};
+
+ // MOMENTS
+
+ // keepLocalTime = true means only change the timezone, without
+ // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+ // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
+ // +0200, so we adjust the time as needed, to be valid.
+ //
+ // Keeping the time actually adds/subtracts (one hour)
+ // from the actual represented time. That is why we call updateOffset
+ // a second time. In case it wants us to change the offset again
+ // _changeInProgress == true case, then we have to adjust, because
+ // there is no such time in the given timezone.
+ function getSetOffset (input, keepLocalTime) {
+ var offset = this._offset || 0,
+ localAdjust;
+ if (input != null) {
+ if (typeof input === 'string') {
+ input = offsetFromString(input);
+ }
+ if (Math.abs(input) < 16) {
+ input = input * 60;
+ }
+ if (!this._isUTC && keepLocalTime) {
+ localAdjust = getDateOffset(this);
+ }
+ this._offset = input;
+ this._isUTC = true;
+ if (localAdjust != null) {
+ this.add(localAdjust, 'm');
+ }
+ if (offset !== input) {
+ if (!keepLocalTime || this._changeInProgress) {
+ add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
+ } else if (!this._changeInProgress) {
+ this._changeInProgress = true;
+ utils_hooks__hooks.updateOffset(this, true);
+ this._changeInProgress = null;
+ }
+ }
+ return this;
+ } else {
+ return this._isUTC ? offset : getDateOffset(this);
+ }
+ }
+
+ function getSetZone (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+ }
+
+ function setOffsetToUTC (keepLocalTime) {
+ return this.utcOffset(0, keepLocalTime);
+ }
+
+ function setOffsetToLocal (keepLocalTime) {
+ if (this._isUTC) {
+ this.utcOffset(0, keepLocalTime);
+ this._isUTC = false;
+
+ if (keepLocalTime) {
+ this.subtract(getDateOffset(this), 'm');
+ }
+ }
+ return this;
+ }
+
+ function setOffsetToParsedOffset () {
+ if (this._tzm) {
+ this.utcOffset(this._tzm);
+ } else if (typeof this._i === 'string') {
+ this.utcOffset(offsetFromString(this._i));
+ }
+ return this;
+ }
+
+ function hasAlignedHourOffset (input) {
+ input = input ? local__createLocal(input).utcOffset() : 0;
+
+ return (this.utcOffset() - input) % 60 === 0;
+ }
+
+ function isDaylightSavingTime () {
+ return (
+ this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset()
+ );
+ }
+
+ function isDaylightSavingTimeShifted () {
+ if (typeof this._isDSTShifted !== 'undefined') {
+ return this._isDSTShifted;
+ }
+
+ var c = {};
+
+ copyConfig(c, this);
+ c = prepareConfig(c);
+
+ if (c._a) {
+ var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a);
+ this._isDSTShifted = this.isValid() &&
+ compareArrays(c._a, other.toArray()) > 0;
+ } else {
+ this._isDSTShifted = false;
+ }
+
+ return this._isDSTShifted;
+ }
+
+ function isLocal () {
+ return !this._isUTC;
+ }
+
+ function isUtcOffset () {
+ return this._isUTC;
+ }
+
+ function isUtc () {
+ return this._isUTC && this._offset === 0;
+ }
+
+ var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+
+ // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
+ // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
+ var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
+
+ function create__createDuration (input, key) {
+ var duration = input,
+ // matching against regexp is expensive, do it on demand
+ match = null,
+ sign,
+ ret,
+ diffRes;
+
+ if (isDuration(input)) {
+ duration = {
+ ms : input._milliseconds,
+ d : input._days,
+ M : input._months
+ };
+ } else if (typeof input === 'number') {
+ duration = {};
+ if (key) {
+ duration[key] = input;
+ } else {
+ duration.milliseconds = input;
+ }
+ } else if (!!(match = aspNetRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : 0,
+ d : toInt(match[DATE]) * sign,
+ h : toInt(match[HOUR]) * sign,
+ m : toInt(match[MINUTE]) * sign,
+ s : toInt(match[SECOND]) * sign,
+ ms : toInt(match[MILLISECOND]) * sign
+ };
+ } else if (!!(match = create__isoRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : parseIso(match[2], sign),
+ M : parseIso(match[3], sign),
+ d : parseIso(match[4], sign),
+ h : parseIso(match[5], sign),
+ m : parseIso(match[6], sign),
+ s : parseIso(match[7], sign),
+ w : parseIso(match[8], sign)
+ };
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
+ } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
+ diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
+
+ duration = {};
+ duration.ms = diffRes.milliseconds;
+ duration.M = diffRes.months;
+ }
+
+ ret = new Duration(duration);
+
+ if (isDuration(input) && hasOwnProp(input, '_locale')) {
+ ret._locale = input._locale;
+ }
+
+ return ret;
+ }
+
+ create__createDuration.fn = Duration.prototype;
+
+ function parseIso (inp, sign) {
+ // We'd normally use ~~inp for this, but unfortunately it also
+ // converts floats to ints.
+ // inp may be undefined, so careful calling replace on it.
+ var res = inp && parseFloat(inp.replace(',', '.'));
+ // apply sign while we're at it
+ return (isNaN(res) ? 0 : res) * sign;
+ }
+
+ function positiveMomentsDifference(base, other) {
+ var res = {milliseconds: 0, months: 0};
+
+ res.months = other.month() - base.month() +
+ (other.year() - base.year()) * 12;
+ if (base.clone().add(res.months, 'M').isAfter(other)) {
+ --res.months;
+ }
+
+ res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+
+ return res;
+ }
+
+ function momentsDifference(base, other) {
+ var res;
+ other = cloneWithOffset(other, base);
+ if (base.isBefore(other)) {
+ res = positiveMomentsDifference(base, other);
+ } else {
+ res = positiveMomentsDifference(other, base);
+ res.milliseconds = -res.milliseconds;
+ res.months = -res.months;
+ }
+
+ return res;
+ }
+
+ function createAdder(direction, name) {
+ return function (val, period) {
+ var dur, tmp;
+ //invert the arguments, but complain about it
+ if (period !== null && !isNaN(+period)) {
+ deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
+ tmp = val; val = period; period = tmp;
+ }
+
+ val = typeof val === 'string' ? +val : val;
+ dur = create__createDuration(val, period);
+ add_subtract__addSubtract(this, dur, direction);
+ return this;
+ };
+ }
+
+ function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
+ var milliseconds = duration._milliseconds,
+ days = duration._days,
+ months = duration._months;
+ updateOffset = updateOffset == null ? true : updateOffset;
+
+ if (milliseconds) {
+ mom._d.setTime(+mom._d + milliseconds * isAdding);
+ }
+ if (days) {
+ get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
+ }
+ if (months) {
+ setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
+ }
+ if (updateOffset) {
+ utils_hooks__hooks.updateOffset(mom, days || months);
+ }
+ }
+
+ var add_subtract__add = createAdder(1, 'add');
+ var add_subtract__subtract = createAdder(-1, 'subtract');
+
+ function moment_calendar__calendar (time, formats) {
+ // We want to compare the start of today, vs this.
+ // Getting start-of-today depends on whether we're local/utc/offset or not.
+ var now = time || local__createLocal(),
+ sod = cloneWithOffset(now, this).startOf('day'),
+ diff = this.diff(sod, 'days', true),
+ format = diff < -6 ? 'sameElse' :
+ diff < -1 ? 'lastWeek' :
+ diff < 0 ? 'lastDay' :
+ diff < 1 ? 'sameDay' :
+ diff < 2 ? 'nextDay' :
+ diff < 7 ? 'nextWeek' : 'sameElse';
+ return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now)));
+ }
+
+ function clone () {
+ return new Moment(this);
+ }
+
+ function isAfter (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this > +input;
+ } else {
+ inputMs = isMoment(input) ? +input : +local__createLocal(input);
+ return inputMs < +this.clone().startOf(units);
+ }
+ }
+
+ function isBefore (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this < +input;
+ } else {
+ inputMs = isMoment(input) ? +input : +local__createLocal(input);
+ return +this.clone().endOf(units) < inputMs;
+ }
+ }
+
+ function isBetween (from, to, units) {
+ return this.isAfter(from, units) && this.isBefore(to, units);
+ }
+
+ function isSame (input, units) {
+ var inputMs;
+ units = normalizeUnits(units || 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this === +input;
+ } else {
+ inputMs = +local__createLocal(input);
+ return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ }
+ }
+
+ function diff (input, units, asFloat) {
+ var that = cloneWithOffset(input, this),
+ zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
+ delta, output;
+
+ units = normalizeUnits(units);
+
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
+ output = output / 12;
+ }
+ } else {
+ delta = this - that;
+ output = units === 'second' ? delta / 1e3 : // 1000
+ units === 'minute' ? delta / 6e4 : // 1000 * 60
+ units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
+ units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
+ units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
+ delta;
+ }
+ return asFloat ? output : absFloor(output);
+ }
+
+ function monthDiff (a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ return -(wholeMonthDiff + adjust);
+ }
+
+ utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+
+ function toString () {
+ return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
+ }
+
+ function moment_format__toISOString () {
+ var m = this.clone().utc();
+ if (0 < m.year() && m.year() <= 9999) {
+ if ('function' === typeof Date.prototype.toISOString) {
+ // native implementation is ~50x faster, use it when we can
+ return this.toDate().toISOString();
+ } else {
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ } else {
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ }
+
+ function format (inputString) {
+ var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
+ return this.localeData().postformat(output);
+ }
+
+ function from (time, withoutSuffix) {
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+ return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
+ }
+
+ function fromNow (withoutSuffix) {
+ return this.from(local__createLocal(), withoutSuffix);
+ }
+
+ function to (time, withoutSuffix) {
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+ return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
+ }
+
+ function toNow (withoutSuffix) {
+ return this.to(local__createLocal(), withoutSuffix);
+ }
+
+ function locale (key) {
+ var newLocaleData;
+
+ if (key === undefined) {
+ return this._locale._abbr;
+ } else {
+ newLocaleData = locale_locales__getLocale(key);
+ if (newLocaleData != null) {
+ this._locale = newLocaleData;
+ }
+ return this;
+ }
+ }
+
+ var lang = deprecate(
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
+ function (key) {
+ if (key === undefined) {
+ return this.localeData();
+ } else {
+ return this.locale(key);
+ }
+ }
+ );
+
+ function localeData () {
+ return this._locale;
+ }
+
+ function startOf (units) {
+ units = normalizeUnits(units);
+ // the following switch intentionally omits break keywords
+ // to utilize falling through the cases.
+ switch (units) {
+ case 'year':
+ this.month(0);
+ /* falls through */
+ case 'quarter':
+ case 'month':
+ this.date(1);
+ /* falls through */
+ case 'week':
+ case 'isoWeek':
+ case 'day':
+ this.hours(0);
+ /* falls through */
+ case 'hour':
+ this.minutes(0);
+ /* falls through */
+ case 'minute':
+ this.seconds(0);
+ /* falls through */
+ case 'second':
+ this.milliseconds(0);
+ }
+
+ // weeks are a special case
+ if (units === 'week') {
+ this.weekday(0);
+ }
+ if (units === 'isoWeek') {
+ this.isoWeekday(1);
+ }
+
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
+ return this;
+ }
+
+ function endOf (units) {
+ units = normalizeUnits(units);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
+ }
+
+ function to_type__valueOf () {
+ return +this._d - ((this._offset || 0) * 60000);
+ }
+
+ function unix () {
+ return Math.floor(+this / 1000);
+ }
+
+ function toDate () {
+ return this._offset ? new Date(+this) : this._d;
+ }
+
+ function toArray () {
+ var m = this;
+ return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
+ }
+
+ function toObject () {
+ var m = this;
+ return {
+ years: m.year(),
+ months: m.month(),
+ date: m.date(),
+ hours: m.hours(),
+ minutes: m.minutes(),
+ seconds: m.seconds(),
+ milliseconds: m.milliseconds()
+ };
+ }
+
+ function moment_valid__isValid () {
+ return valid__isValid(this);
+ }
+
+ function parsingFlags () {
+ return extend({}, getParsingFlags(this));
+ }
+
+ function invalidAt () {
+ return getParsingFlags(this).overflow;
+ }
+
+ addFormatToken(0, ['gg', 2], 0, function () {
+ return this.weekYear() % 100;
+ });
+
+ addFormatToken(0, ['GG', 2], 0, function () {
+ return this.isoWeekYear() % 100;
+ });
+
+ function addWeekYearFormatToken (token, getter) {
+ addFormatToken(0, [token, token.length], 0, getter);
+ }
+
+ addWeekYearFormatToken('gggg', 'weekYear');
+ addWeekYearFormatToken('ggggg', 'weekYear');
+ addWeekYearFormatToken('GGGG', 'isoWeekYear');
+ addWeekYearFormatToken('GGGGG', 'isoWeekYear');
+
+ // ALIASES
+
+ addUnitAlias('weekYear', 'gg');
+ addUnitAlias('isoWeekYear', 'GG');
+
+ // PARSING
+
+ addRegexToken('G', matchSigned);
+ addRegexToken('g', matchSigned);
+ addRegexToken('GG', match1to2, match2);
+ addRegexToken('gg', match1to2, match2);
+ addRegexToken('GGGG', match1to4, match4);
+ addRegexToken('gggg', match1to4, match4);
+ addRegexToken('GGGGG', match1to6, match6);
+ addRegexToken('ggggg', match1to6, match6);
+
+ addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
+ week[token.substr(0, 2)] = toInt(input);
+ });
+
+ addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
+ week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
+ });
+
+ // HELPERS
+
+ function weeksInYear(year, dow, doy) {
+ return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
+ }
+
+ // MOMENTS
+
+ function getSetWeekYear (input) {
+ var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
+ return input == null ? year : this.add((input - year), 'y');
+ }
+
+ function getSetISOWeekYear (input) {
+ var year = weekOfYear(this, 1, 4).year;
+ return input == null ? year : this.add((input - year), 'y');
+ }
+
+ function getISOWeeksInYear () {
+ return weeksInYear(this.year(), 1, 4);
+ }
+
+ function getWeeksInYear () {
+ var weekInfo = this.localeData()._week;
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
+ }
+
+ addFormatToken('Q', 0, 0, 'quarter');
+
+ // ALIASES
+
+ addUnitAlias('quarter', 'Q');
+
+ // PARSING
+
+ addRegexToken('Q', match1);
+ addParseToken('Q', function (input, array) {
+ array[MONTH] = (toInt(input) - 1) * 3;
+ });
+
+ // MOMENTS
+
+ function getSetQuarter (input) {
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
+ }
+
+ addFormatToken('D', ['DD', 2], 'Do', 'date');
+
+ // ALIASES
+
+ addUnitAlias('date', 'D');
+
+ // PARSING
+
+ addRegexToken('D', match1to2);
+ addRegexToken('DD', match1to2, match2);
+ addRegexToken('Do', function (isStrict, locale) {
+ return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
+ });
+
+ addParseToken(['D', 'DD'], DATE);
+ addParseToken('Do', function (input, array) {
+ array[DATE] = toInt(input.match(match1to2)[0], 10);
+ });
+
+ // MOMENTS
+
+ var getSetDayOfMonth = makeGetSet('Date', true);
+
+ addFormatToken('d', 0, 'do', 'day');
+
+ addFormatToken('dd', 0, 0, function (format) {
+ return this.localeData().weekdaysMin(this, format);
+ });
+
+ addFormatToken('ddd', 0, 0, function (format) {
+ return this.localeData().weekdaysShort(this, format);
+ });
+
+ addFormatToken('dddd', 0, 0, function (format) {
+ return this.localeData().weekdays(this, format);
+ });
+
+ addFormatToken('e', 0, 0, 'weekday');
+ addFormatToken('E', 0, 0, 'isoWeekday');
+
+ // ALIASES
+
+ addUnitAlias('day', 'd');
+ addUnitAlias('weekday', 'e');
+ addUnitAlias('isoWeekday', 'E');
+
+ // PARSING
+
+ addRegexToken('d', match1to2);
+ addRegexToken('e', match1to2);
+ addRegexToken('E', match1to2);
+ addRegexToken('dd', matchWord);
+ addRegexToken('ddd', matchWord);
+ addRegexToken('dddd', matchWord);
+
+ addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
+ var weekday = config._locale.weekdaysParse(input);
+ // if we didn't get a weekday name, mark the date as invalid
+ if (weekday != null) {
+ week.d = weekday;
+ } else {
+ getParsingFlags(config).invalidWeekday = input;
+ }
+ });
+
+ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
+ week[token] = toInt(input);
+ });
+
+ // HELPERS
+
+ function parseWeekday(input, locale) {
+ if (typeof input !== 'string') {
+ return input;
+ }
+
+ if (!isNaN(input)) {
+ return parseInt(input, 10);
+ }
+
+ input = locale.weekdaysParse(input);
+ if (typeof input === 'number') {
+ return input;
+ }
+
+ return null;
+ }
+
+ // LOCALES
+
+ var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
+ function localeWeekdays (m) {
+ return this._weekdays[m.day()];
+ }
+
+ var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
+ function localeWeekdaysShort (m) {
+ return this._weekdaysShort[m.day()];
+ }
+
+ var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
+ function localeWeekdaysMin (m) {
+ return this._weekdaysMin[m.day()];
+ }
+
+ function localeWeekdaysParse (weekdayName) {
+ var i, mom, regex;
+
+ this._weekdaysParse = this._weekdaysParse || [];
+
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ if (!this._weekdaysParse[i]) {
+ mom = local__createLocal([2000, 1]).day(i);
+ regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
+ this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (this._weekdaysParse[i].test(weekdayName)) {
+ return i;
+ }
+ }
+ }
+
+ // MOMENTS
+
+ function getSetDayOfWeek (input) {
+ var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
+ if (input != null) {
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
+ } else {
+ return day;
+ }
+ }
+
+ function getSetLocaleDayOfWeek (input) {
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
+ }
+
+ function getSetISODayOfWeek (input) {
+ // behaves the same as moment#day except
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
+ // as a setter, sunday should belong to the previous week.
+ return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
+ }
+
+ addFormatToken('H', ['HH', 2], 0, 'hour');
+ addFormatToken('h', ['hh', 2], 0, function () {
+ return this.hours() % 12 || 12;
+ });
+
+ function meridiem (token, lowercase) {
+ addFormatToken(token, 0, 0, function () {
+ return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
+ });
+ }
+
+ meridiem('a', true);
+ meridiem('A', false);
+
+ // ALIASES
+
+ addUnitAlias('hour', 'h');
+
+ // PARSING
+
+ function matchMeridiem (isStrict, locale) {
+ return locale._meridiemParse;
+ }
+
+ addRegexToken('a', matchMeridiem);
+ addRegexToken('A', matchMeridiem);
+ addRegexToken('H', match1to2);
+ addRegexToken('h', match1to2);
+ addRegexToken('HH', match1to2, match2);
+ addRegexToken('hh', match1to2, match2);
+
+ addParseToken(['H', 'HH'], HOUR);
+ addParseToken(['a', 'A'], function (input, array, config) {
+ config._isPm = config._locale.isPM(input);
+ config._meridiem = input;
+ });
+ addParseToken(['h', 'hh'], function (input, array, config) {
+ array[HOUR] = toInt(input);
+ getParsingFlags(config).bigHour = true;
+ });
+
+ // LOCALES
+
+ function localeIsPM (input) {
+ // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
+ // Using charAt should be more compatible.
+ return ((input + '').toLowerCase().charAt(0) === 'p');
+ }
+
+ var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
+ function localeMeridiem (hours, minutes, isLower) {
+ if (hours > 11) {
+ return isLower ? 'pm' : 'PM';
+ } else {
+ return isLower ? 'am' : 'AM';
+ }
+ }
+
+
+ // MOMENTS
+
+ // Setting the hour should keep the time, because the user explicitly
+ // specified which hour he wants. So trying to maintain the same hour (in
+ // a new timezone) makes sense. Adding/subtracting hours does not follow
+ // this rule.
+ var getSetHour = makeGetSet('Hours', true);
+
+ addFormatToken('m', ['mm', 2], 0, 'minute');
+
+ // ALIASES
+
+ addUnitAlias('minute', 'm');
+
+ // PARSING
+
+ addRegexToken('m', match1to2);
+ addRegexToken('mm', match1to2, match2);
+ addParseToken(['m', 'mm'], MINUTE);
+
+ // MOMENTS
+
+ var getSetMinute = makeGetSet('Minutes', false);
+
+ addFormatToken('s', ['ss', 2], 0, 'second');
+
+ // ALIASES
+
+ addUnitAlias('second', 's');
+
+ // PARSING
+
+ addRegexToken('s', match1to2);
+ addRegexToken('ss', match1to2, match2);
+ addParseToken(['s', 'ss'], SECOND);
+
+ // MOMENTS
+
+ var getSetSecond = makeGetSet('Seconds', false);
+
+ addFormatToken('S', 0, 0, function () {
+ return ~~(this.millisecond() / 100);
+ });
+
+ addFormatToken(0, ['SS', 2], 0, function () {
+ return ~~(this.millisecond() / 10);
+ });
+
+ addFormatToken(0, ['SSS', 3], 0, 'millisecond');
+ addFormatToken(0, ['SSSS', 4], 0, function () {
+ return this.millisecond() * 10;
+ });
+ addFormatToken(0, ['SSSSS', 5], 0, function () {
+ return this.millisecond() * 100;
+ });
+ addFormatToken(0, ['SSSSSS', 6], 0, function () {
+ return this.millisecond() * 1000;
+ });
+ addFormatToken(0, ['SSSSSSS', 7], 0, function () {
+ return this.millisecond() * 10000;
+ });
+ addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
+ return this.millisecond() * 100000;
+ });
+ addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
+ return this.millisecond() * 1000000;
+ });
+
+
+ // ALIASES
+
+ addUnitAlias('millisecond', 'ms');
+
+ // PARSING
+
+ addRegexToken('S', match1to3, match1);
+ addRegexToken('SS', match1to3, match2);
+ addRegexToken('SSS', match1to3, match3);
+
+ var token;
+ for (token = 'SSSS'; token.length <= 9; token += 'S') {
+ addRegexToken(token, matchUnsigned);
+ }
+
+ function parseMs(input, array) {
+ array[MILLISECOND] = toInt(('0.' + input) * 1000);
+ }
+
+ for (token = 'S'; token.length <= 9; token += 'S') {
+ addParseToken(token, parseMs);
+ }
+ // MOMENTS
+
+ var getSetMillisecond = makeGetSet('Milliseconds', false);
+
+ addFormatToken('z', 0, 0, 'zoneAbbr');
+ addFormatToken('zz', 0, 0, 'zoneName');
+
+ // MOMENTS
+
+ function getZoneAbbr () {
+ return this._isUTC ? 'UTC' : '';
+ }
+
+ function getZoneName () {
+ return this._isUTC ? 'Coordinated Universal Time' : '';
+ }
+
+ var momentPrototype__proto = Moment.prototype;
+
+ momentPrototype__proto.add = add_subtract__add;
+ momentPrototype__proto.calendar = moment_calendar__calendar;
+ momentPrototype__proto.clone = clone;
+ momentPrototype__proto.diff = diff;
+ momentPrototype__proto.endOf = endOf;
+ momentPrototype__proto.format = format;
+ momentPrototype__proto.from = from;
+ momentPrototype__proto.fromNow = fromNow;
+ momentPrototype__proto.to = to;
+ momentPrototype__proto.toNow = toNow;
+ momentPrototype__proto.get = getSet;
+ momentPrototype__proto.invalidAt = invalidAt;
+ momentPrototype__proto.isAfter = isAfter;
+ momentPrototype__proto.isBefore = isBefore;
+ momentPrototype__proto.isBetween = isBetween;
+ momentPrototype__proto.isSame = isSame;
+ momentPrototype__proto.isValid = moment_valid__isValid;
+ momentPrototype__proto.lang = lang;
+ momentPrototype__proto.locale = locale;
+ momentPrototype__proto.localeData = localeData;
+ momentPrototype__proto.max = prototypeMax;
+ momentPrototype__proto.min = prototypeMin;
+ momentPrototype__proto.parsingFlags = parsingFlags;
+ momentPrototype__proto.set = getSet;
+ momentPrototype__proto.startOf = startOf;
+ momentPrototype__proto.subtract = add_subtract__subtract;
+ momentPrototype__proto.toArray = toArray;
+ momentPrototype__proto.toObject = toObject;
+ momentPrototype__proto.toDate = toDate;
+ momentPrototype__proto.toISOString = moment_format__toISOString;
+ momentPrototype__proto.toJSON = moment_format__toISOString;
+ momentPrototype__proto.toString = toString;
+ momentPrototype__proto.unix = unix;
+ momentPrototype__proto.valueOf = to_type__valueOf;
+
+ // Year
+ momentPrototype__proto.year = getSetYear;
+ momentPrototype__proto.isLeapYear = getIsLeapYear;
+
+ // Week Year
+ momentPrototype__proto.weekYear = getSetWeekYear;
+ momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
+
+ // Quarter
+ momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
+
+ // Month
+ momentPrototype__proto.month = getSetMonth;
+ momentPrototype__proto.daysInMonth = getDaysInMonth;
+
+ // Week
+ momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
+ momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
+ momentPrototype__proto.weeksInYear = getWeeksInYear;
+ momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
+
+ // Day
+ momentPrototype__proto.date = getSetDayOfMonth;
+ momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
+ momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
+ momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
+ momentPrototype__proto.dayOfYear = getSetDayOfYear;
+
+ // Hour
+ momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
+
+ // Minute
+ momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
+
+ // Second
+ momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
+
+ // Millisecond
+ momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
+
+ // Offset
+ momentPrototype__proto.utcOffset = getSetOffset;
+ momentPrototype__proto.utc = setOffsetToUTC;
+ momentPrototype__proto.local = setOffsetToLocal;
+ momentPrototype__proto.parseZone = setOffsetToParsedOffset;
+ momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
+ momentPrototype__proto.isDST = isDaylightSavingTime;
+ momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
+ momentPrototype__proto.isLocal = isLocal;
+ momentPrototype__proto.isUtcOffset = isUtcOffset;
+ momentPrototype__proto.isUtc = isUtc;
+ momentPrototype__proto.isUTC = isUtc;
+
+ // Timezone
+ momentPrototype__proto.zoneAbbr = getZoneAbbr;
+ momentPrototype__proto.zoneName = getZoneName;
+
+ // Deprecations
+ momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
+ momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
+ momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
+ momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
+
+ var momentPrototype = momentPrototype__proto;
+
+ function moment__createUnix (input) {
+ return local__createLocal(input * 1000);
+ }
+
+ function moment__createInZone () {
+ return local__createLocal.apply(null, arguments).parseZone();
+ }
+
+ var defaultCalendar = {
+ sameDay : '[Today at] LT',
+ nextDay : '[Tomorrow at] LT',
+ nextWeek : 'dddd [at] LT',
+ lastDay : '[Yesterday at] LT',
+ lastWeek : '[Last] dddd [at] LT',
+ sameElse : 'L'
+ };
+
+ function locale_calendar__calendar (key, mom, now) {
+ var output = this._calendar[key];
+ return typeof output === 'function' ? output.call(mom, now) : output;
+ }
+
+ var defaultLongDateFormat = {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ };
+
+ function longDateFormat (key) {
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()];
+
+ if (format || !formatUpper) {
+ return format;
+ }
+
+ this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+
+ return this._longDateFormat[key];
+ }
+
+ var defaultInvalidDate = 'Invalid date';
+
+ function invalidDate () {
+ return this._invalidDate;
+ }
+
+ var defaultOrdinal = '%d';
+ var defaultOrdinalParse = /\d{1,2}/;
+
+ function ordinal (number) {
+ return this._ordinal.replace('%d', number);
+ }
+
+ function preParsePostFormat (string) {
+ return string;
+ }
+
+ var defaultRelativeTime = {
+ future : 'in %s',
+ past : '%s ago',
+ s : 'a few seconds',
+ m : 'a minute',
+ mm : '%d minutes',
+ h : 'an hour',
+ hh : '%d hours',
+ d : 'a day',
+ dd : '%d days',
+ M : 'a month',
+ MM : '%d months',
+ y : 'a year',
+ yy : '%d years'
+ };
+
+ function relative__relativeTime (number, withoutSuffix, string, isFuture) {
+ var output = this._relativeTime[string];
+ return (typeof output === 'function') ?
+ output(number, withoutSuffix, string, isFuture) :
+ output.replace(/%d/i, number);
+ }
+
+ function pastFuture (diff, output) {
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
+ return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
+ }
+
+ function locale_set__set (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (typeof prop === 'function') {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
+ }
+
+ var prototype__proto = Locale.prototype;
+
+ prototype__proto._calendar = defaultCalendar;
+ prototype__proto.calendar = locale_calendar__calendar;
+ prototype__proto._longDateFormat = defaultLongDateFormat;
+ prototype__proto.longDateFormat = longDateFormat;
+ prototype__proto._invalidDate = defaultInvalidDate;
+ prototype__proto.invalidDate = invalidDate;
+ prototype__proto._ordinal = defaultOrdinal;
+ prototype__proto.ordinal = ordinal;
+ prototype__proto._ordinalParse = defaultOrdinalParse;
+ prototype__proto.preparse = preParsePostFormat;
+ prototype__proto.postformat = preParsePostFormat;
+ prototype__proto._relativeTime = defaultRelativeTime;
+ prototype__proto.relativeTime = relative__relativeTime;
+ prototype__proto.pastFuture = pastFuture;
+ prototype__proto.set = locale_set__set;
+
+ // Month
+ prototype__proto.months = localeMonths;
+ prototype__proto._months = defaultLocaleMonths;
+ prototype__proto.monthsShort = localeMonthsShort;
+ prototype__proto._monthsShort = defaultLocaleMonthsShort;
+ prototype__proto.monthsParse = localeMonthsParse;
+
+ // Week
+ prototype__proto.week = localeWeek;
+ prototype__proto._week = defaultLocaleWeek;
+ prototype__proto.firstDayOfYear = localeFirstDayOfYear;
+ prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
+
+ // Day of Week
+ prototype__proto.weekdays = localeWeekdays;
+ prototype__proto._weekdays = defaultLocaleWeekdays;
+ prototype__proto.weekdaysMin = localeWeekdaysMin;
+ prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
+ prototype__proto.weekdaysShort = localeWeekdaysShort;
+ prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
+ prototype__proto.weekdaysParse = localeWeekdaysParse;
+
+ // Hours
+ prototype__proto.isPM = localeIsPM;
+ prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
+ prototype__proto.meridiem = localeMeridiem;
+
+ function lists__get (format, index, field, setter) {
+ var locale = locale_locales__getLocale();
+ var utc = create_utc__createUTC().set(setter, index);
+ return locale[field](utc, format);
+ }
+
+ function list (format, index, field, count, setter) {
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+
+ if (index != null) {
+ return lists__get(format, index, field, setter);
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < count; i++) {
+ out[i] = lists__get(format, i, field, setter);
+ }
+ return out;
+ }
+
+ function lists__listMonths (format, index) {
+ return list(format, index, 'months', 12, 'month');
+ }
+
+ function lists__listMonthsShort (format, index) {
+ return list(format, index, 'monthsShort', 12, 'month');
+ }
+
+ function lists__listWeekdays (format, index) {
+ return list(format, index, 'weekdays', 7, 'day');
+ }
+
+ function lists__listWeekdaysShort (format, index) {
+ return list(format, index, 'weekdaysShort', 7, 'day');
+ }
+
+ function lists__listWeekdaysMin (format, index) {
+ return list(format, index, 'weekdaysMin', 7, 'day');
+ }
+
+ locale_locales__getSetGlobalLocale('en', {
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (toInt(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ }
+ });
+
+ // Side effect imports
+ utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
+ utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
+
+ var mathAbs = Math.abs;
+
+ function duration_abs__abs () {
+ var data = this._data;
+
+ this._milliseconds = mathAbs(this._milliseconds);
+ this._days = mathAbs(this._days);
+ this._months = mathAbs(this._months);
+
+ data.milliseconds = mathAbs(data.milliseconds);
+ data.seconds = mathAbs(data.seconds);
+ data.minutes = mathAbs(data.minutes);
+ data.hours = mathAbs(data.hours);
+ data.months = mathAbs(data.months);
+ data.years = mathAbs(data.years);
+
+ return this;
+ }
+
+ function duration_add_subtract__addSubtract (duration, input, value, direction) {
+ var other = create__createDuration(input, value);
+
+ duration._milliseconds += direction * other._milliseconds;
+ duration._days += direction * other._days;
+ duration._months += direction * other._months;
+
+ return duration._bubble();
+ }
+
+ // supports only 2.0-style add(1, 's') or add(duration)
+ function duration_add_subtract__add (input, value) {
+ return duration_add_subtract__addSubtract(this, input, value, 1);
+ }
+
+ // supports only 2.0-style subtract(1, 's') or subtract(duration)
+ function duration_add_subtract__subtract (input, value) {
+ return duration_add_subtract__addSubtract(this, input, value, -1);
+ }
+
+ function absCeil (number) {
+ if (number < 0) {
+ return Math.floor(number);
+ } else {
+ return Math.ceil(number);
+ }
+ }
+
+ function bubble () {
+ var milliseconds = this._milliseconds;
+ var days = this._days;
+ var months = this._months;
+ var data = this._data;
+ var seconds, minutes, hours, years, monthsFromDays;
+
+ // if we have a mix of positive and negative values, bubble down first
+ // check: https://github.com/moment/moment/issues/2166
+ if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
+ (milliseconds <= 0 && days <= 0 && months <= 0))) {
+ milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
+ days = 0;
+ months = 0;
+ }
+
+ // The following code bubbles up values, see the tests for
+ // examples of what that means.
+ data.milliseconds = milliseconds % 1000;
+
+ seconds = absFloor(milliseconds / 1000);
+ data.seconds = seconds % 60;
+
+ minutes = absFloor(seconds / 60);
+ data.minutes = minutes % 60;
+
+ hours = absFloor(minutes / 60);
+ data.hours = hours % 24;
+
+ days += absFloor(hours / 24);
+
+ // convert days to months
+ monthsFromDays = absFloor(daysToMonths(days));
+ months += monthsFromDays;
+ days -= absCeil(monthsToDays(monthsFromDays));
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+ data.days = days;
+ data.months = months;
+ data.years = years;
+
+ return this;
+ }
+
+ function daysToMonths (days) {
+ // 400 years have 146097 days (taking into account leap year rules)
+ // 400 years have 12 months === 4800
+ return days * 4800 / 146097;
+ }
+
+ function monthsToDays (months) {
+ // the reverse of daysToMonths
+ return months * 146097 / 4800;
+ }
+
+ function as (units) {
+ var days;
+ var months;
+ var milliseconds = this._milliseconds;
+
+ units = normalizeUnits(units);
+
+ if (units === 'month' || units === 'year') {
+ days = this._days + milliseconds / 864e5;
+ months = this._months + daysToMonths(days);
+ return units === 'month' ? months : months / 12;
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
+ days = this._days + Math.round(monthsToDays(this._months));
+ switch (units) {
+ case 'week' : return days / 7 + milliseconds / 6048e5;
+ case 'day' : return days + milliseconds / 864e5;
+ case 'hour' : return days * 24 + milliseconds / 36e5;
+ case 'minute' : return days * 1440 + milliseconds / 6e4;
+ case 'second' : return days * 86400 + milliseconds / 1000;
+ // Math.floor prevents floating point math errors here
+ case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
+ default: throw new Error('Unknown unit ' + units);
+ }
+ }
+ }
+
+ // TODO: Use this.as('ms')?
+ function duration_as__valueOf () {
+ return (
+ this._milliseconds +
+ this._days * 864e5 +
+ (this._months % 12) * 2592e6 +
+ toInt(this._months / 12) * 31536e6
+ );
+ }
+
+ function makeAs (alias) {
+ return function () {
+ return this.as(alias);
+ };
+ }
+
+ var asMilliseconds = makeAs('ms');
+ var asSeconds = makeAs('s');
+ var asMinutes = makeAs('m');
+ var asHours = makeAs('h');
+ var asDays = makeAs('d');
+ var asWeeks = makeAs('w');
+ var asMonths = makeAs('M');
+ var asYears = makeAs('y');
+
+ function duration_get__get (units) {
+ units = normalizeUnits(units);
+ return this[units + 's']();
+ }
+
+ function makeGetter(name) {
+ return function () {
+ return this._data[name];
+ };
+ }
+
+ var milliseconds = makeGetter('milliseconds');
+ var seconds = makeGetter('seconds');
+ var minutes = makeGetter('minutes');
+ var hours = makeGetter('hours');
+ var days = makeGetter('days');
+ var months = makeGetter('months');
+ var years = makeGetter('years');
+
+ function weeks () {
+ return absFloor(this.days() / 7);
+ }
+
+ var round = Math.round;
+ var thresholds = {
+ s: 45, // seconds to minute
+ m: 45, // minutes to hour
+ h: 22, // hours to day
+ d: 26, // days to month
+ M: 11 // months to year
+ };
+
+ // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
+ function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
+ return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+ }
+
+ function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
+ var duration = create__createDuration(posNegDuration).abs();
+ var seconds = round(duration.as('s'));
+ var minutes = round(duration.as('m'));
+ var hours = round(duration.as('h'));
+ var days = round(duration.as('d'));
+ var months = round(duration.as('M'));
+ var years = round(duration.as('y'));
+
+ var a = seconds < thresholds.s && ['s', seconds] ||
+ minutes === 1 && ['m'] ||
+ minutes < thresholds.m && ['mm', minutes] ||
+ hours === 1 && ['h'] ||
+ hours < thresholds.h && ['hh', hours] ||
+ days === 1 && ['d'] ||
+ days < thresholds.d && ['dd', days] ||
+ months === 1 && ['M'] ||
+ months < thresholds.M && ['MM', months] ||
+ years === 1 && ['y'] || ['yy', years];
+
+ a[2] = withoutSuffix;
+ a[3] = +posNegDuration > 0;
+ a[4] = locale;
+ return substituteTimeAgo.apply(null, a);
+ }
+
+ // This function allows you to set a threshold for relative time strings
+ function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
+ if (thresholds[threshold] === undefined) {
+ return false;
+ }
+ if (limit === undefined) {
+ return thresholds[threshold];
+ }
+ thresholds[threshold] = limit;
+ return true;
+ }
+
+ function humanize (withSuffix) {
+ var locale = this.localeData();
+ var output = duration_humanize__relativeTime(this, !withSuffix, locale);
+
+ if (withSuffix) {
+ output = locale.pastFuture(+this, output);
+ }
+
+ return locale.postformat(output);
+ }
+
+ var iso_string__abs = Math.abs;
+
+ function iso_string__toISOString() {
+ // for ISO strings we do not use the normal bubbling rules:
+ // * milliseconds bubble up until they become hours
+ // * days do not bubble at all
+ // * months bubble up until they become years
+ // This is because there is no context-free conversion between hours and days
+ // (think of clock changes)
+ // and also not between days and months (28-31 days per month)
+ var seconds = iso_string__abs(this._milliseconds) / 1000;
+ var days = iso_string__abs(this._days);
+ var months = iso_string__abs(this._months);
+ var minutes, hours, years;
+
+ // 3600 seconds -> 60 minutes -> 1 hour
+ minutes = absFloor(seconds / 60);
+ hours = absFloor(minutes / 60);
+ seconds %= 60;
+ minutes %= 60;
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+
+ // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
+ var Y = years;
+ var M = months;
+ var D = days;
+ var h = hours;
+ var m = minutes;
+ var s = seconds;
+ var total = this.asSeconds();
+
+ if (!total) {
+ // this is the same as C#'s (Noda) and python (isodate)...
+ // but not other JS (goog.date)
+ return 'P0D';
+ }
+
+ return (total < 0 ? '-' : '') +
+ 'P' +
+ (Y ? Y + 'Y' : '') +
+ (M ? M + 'M' : '') +
+ (D ? D + 'D' : '') +
+ ((h || m || s) ? 'T' : '') +
+ (h ? h + 'H' : '') +
+ (m ? m + 'M' : '') +
+ (s ? s + 'S' : '');
+ }
+
+ var duration_prototype__proto = Duration.prototype;
+
+ duration_prototype__proto.abs = duration_abs__abs;
+ duration_prototype__proto.add = duration_add_subtract__add;
+ duration_prototype__proto.subtract = duration_add_subtract__subtract;
+ duration_prototype__proto.as = as;
+ duration_prototype__proto.asMilliseconds = asMilliseconds;
+ duration_prototype__proto.asSeconds = asSeconds;
+ duration_prototype__proto.asMinutes = asMinutes;
+ duration_prototype__proto.asHours = asHours;
+ duration_prototype__proto.asDays = asDays;
+ duration_prototype__proto.asWeeks = asWeeks;
+ duration_prototype__proto.asMonths = asMonths;
+ duration_prototype__proto.asYears = asYears;
+ duration_prototype__proto.valueOf = duration_as__valueOf;
+ duration_prototype__proto._bubble = bubble;
+ duration_prototype__proto.get = duration_get__get;
+ duration_prototype__proto.milliseconds = milliseconds;
+ duration_prototype__proto.seconds = seconds;
+ duration_prototype__proto.minutes = minutes;
+ duration_prototype__proto.hours = hours;
+ duration_prototype__proto.days = days;
+ duration_prototype__proto.weeks = weeks;
+ duration_prototype__proto.months = months;
+ duration_prototype__proto.years = years;
+ duration_prototype__proto.humanize = humanize;
+ duration_prototype__proto.toISOString = iso_string__toISOString;
+ duration_prototype__proto.toString = iso_string__toISOString;
+ duration_prototype__proto.toJSON = iso_string__toISOString;
+ duration_prototype__proto.locale = locale;
+ duration_prototype__proto.localeData = localeData;
+
+ // Deprecations
+ duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
+ duration_prototype__proto.lang = lang;
+
+ // Side effect imports
+
+ addFormatToken('X', 0, 0, 'unix');
+ addFormatToken('x', 0, 0, 'valueOf');
+
+ // PARSING
+
+ addRegexToken('x', matchSigned);
+ addRegexToken('X', matchTimestamp);
+ addParseToken('X', function (input, array, config) {
+ config._d = new Date(parseFloat(input, 10) * 1000);
+ });
+ addParseToken('x', function (input, array, config) {
+ config._d = new Date(toInt(input));
+ });
+
+ // Side effect imports
+
+
+ utils_hooks__hooks.version = '2.10.6';
+
+ setHookCallback(local__createLocal);
+
+ utils_hooks__hooks.fn = momentPrototype;
+ utils_hooks__hooks.min = min;
+ utils_hooks__hooks.max = max;
+ utils_hooks__hooks.utc = create_utc__createUTC;
+ utils_hooks__hooks.unix = moment__createUnix;
+ utils_hooks__hooks.months = lists__listMonths;
+ utils_hooks__hooks.isDate = isDate;
+ utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
+ utils_hooks__hooks.invalid = valid__createInvalid;
+ utils_hooks__hooks.duration = create__createDuration;
+ utils_hooks__hooks.isMoment = isMoment;
+ utils_hooks__hooks.weekdays = lists__listWeekdays;
+ utils_hooks__hooks.parseZone = moment__createInZone;
+ utils_hooks__hooks.localeData = locale_locales__getLocale;
+ utils_hooks__hooks.isDuration = isDuration;
+ utils_hooks__hooks.monthsShort = lists__listMonthsShort;
+ utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
+ utils_hooks__hooks.defineLocale = defineLocale;
+ utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
+ utils_hooks__hooks.normalizeUnits = normalizeUnits;
+ utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
+
+ var _moment = utils_hooks__hooks;
+
+ return _moment;
+
+})); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/oktween.js b/StoneIsland/platforms/android/assets/www/js/vendor/oktween.js
new file mode 100755
index 00000000..7e820b04
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/oktween.js
@@ -0,0 +1,125 @@
+/*
+ oktween.add({
+ obj: el.style,
+ units: "px",
+ from: { left: 0 },
+ to: { left: 100 },
+ duration: 1000,
+ easing: oktween.easing.circ_out,
+ finish: function(){
+ console.log("done")
+ }
+ })
+*/
+
+var oktween = (function(){
+ var oktween = {}
+ var tweens = oktween.tweens = []
+ var last_t = 0
+ var id = 0
+ oktween.speed = 1
+ oktween.then = oktween.add = function(tween){
+ tween.id = id++
+ tween.obj = tween.obj || {}
+ if (tween.easing) {
+ if (typeof tween.easing == "string") {
+ tween.easing = oktween.easing[tween.easing]
+ }
+ }
+ else {
+ tween.easing = oktween.easing.linear
+ }
+ if (! ('from' in tween) ) {
+ tween.from = {}
+ tween.keys = Object.keys(tween.to)
+ tween.keys.forEach(function(prop){
+ tween.from[prop] = parseFloat(tween.obj[prop])
+ })
+ }
+ else {
+ tween.keys = Object.keys(tween.from)
+ }
+ tween.delay = tween.delay || 0
+ tween.duration = tween.duration || 200
+ tween.start = last_t + tween.delay
+ tween.done = false
+ tween.then = function(fn){ tween.after = [fn] }
+ tween.finish = function(){ tween.start = 0 }
+ tween.cancel = function(){
+ var idx = tweens.indexOf(tween)
+ if (~idx) { tweens.splice(idx, 1) }
+ }
+ tween.tick = 0
+ tween.skip = tween.skip || 1
+ tweens.push(tween)
+ return tween
+ }
+ oktween.update = function(t) {
+ requestAnimationFrame(oktween.update)
+ last_t = t * oktween.speed
+ if (tweens.length == 0) return
+ var done = false
+ tweens.forEach(function(tween, i){
+ var dt = Math.min(1.0, (t - tween.start) / tween.duration)
+ tween.tick++
+ if (dt < 0 || (dt < 1 && (tween.tick % tween.skip != 0))) return
+ var ddt = tween.dt = tween.easing(dt)
+ tween.keys.forEach(function(prop){
+ val = lerp( ddt, tween.from[prop], tween.to[prop] )
+ if (tween.round) val = Math.round(val)
+ if (tween.units) val = (Math.round(val)) + tween.units
+ tween.obj[prop] = val
+ })
+ tween.update && tween.update(tween.obj, dt)
+ if (dt == 1) {
+ tween.finished && tween.finished(tween)
+ tween.after && tween.after.forEach(function(twn){
+ if (typeof twn == "function") { return twn() }
+ if (! twn.obj) { twn.obj = tween.obj }
+ oktween.add(twn)
+ })
+ if (tween.loop) {
+ tween.start = t + tween.delay
+ }
+ else {
+ done = tween.done = true
+ }
+ }
+ })
+ if (done) {
+ tweens = tweens.filter(function(tween){ return ! tween.done })
+ }
+ }
+ function lerp(n,a,b){ return (b-a)*n+a }
+
+ requestAnimationFrame(oktween.update)
+
+ oktween.easing = {
+ linear: function(t){
+ return t
+ },
+ circ_out: function(t) {
+ return Math.sqrt(1 - (t = t - 1) * t)
+ },
+ circ_in: function(t){
+ return -(Math.sqrt(1 - (t * t)) - 1)
+ },
+ circ_in_out: function(t) {
+ return ((t*=2) < 1) ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1)
+ },
+ quad_in: function(n){
+ return Math.pow(n, 2)
+ },
+ quad_out: function(n){
+ return n * (n - 2) * -1
+ },
+ quad_in_out: function(n){
+ n = n * 2
+ if(n < 1){ return Math.pow(n, 2) / 2 }
+ return -1 * ((--n) * (n - 2) - 1) / 2
+ },
+
+ }
+
+ return oktween
+})()
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/prefixfree.js b/StoneIsland/platforms/android/assets/www/js/vendor/prefixfree.js
new file mode 100755
index 00000000..e2c87c42
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/prefixfree.js
@@ -0,0 +1,497 @@
+/**
+ * StyleFix 1.0.3 & PrefixFree 1.0.7
+ * @author Lea Verou
+ * MIT license
+ */
+
+(function(){
+
+if(!window.addEventListener) {
+ return;
+}
+
+var self = window.StyleFix = {
+ link: function(link) {
+ try {
+ // Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets
+ if(link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')) {
+ return;
+ }
+ }
+ catch(e) {
+ return;
+ }
+
+ var url = link.href || link.getAttribute('data-href'),
+ base = url.replace(/[^\/]+$/, ''),
+ base_scheme = (/^[a-z]{3,10}:/.exec(base) || [''])[0],
+ base_domain = (/^[a-z]{3,10}:\/\/[^\/]+/.exec(base) || [''])[0],
+ base_query = /^([^?]*)\??/.exec(url)[1],
+ parent = link.parentNode,
+ xhr = new XMLHttpRequest(),
+ process;
+
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState === 4) {
+ process();
+ }
+ };
+
+ process = function() {
+ var css = xhr.responseText;
+
+ if(css && link.parentNode && (!xhr.status || xhr.status < 400 || xhr.status > 600)) {
+ css = self.fix(css, true, link);
+
+ // Convert relative URLs to absolute, if needed
+ if(base) {
+ css = css.replace(/url\(\s*?((?:"|')?)(.+?)\1\s*?\)/gi, function($0, quote, url) {
+ if(/^([a-z]{3,10}:|#)/i.test(url)) { // Absolute & or hash-relative
+ return $0;
+ }
+ else if(/^\/\//.test(url)) { // Scheme-relative
+ // May contain sequences like /../ and /./ but those DO work
+ return 'url("' + base_scheme + url + '")';
+ }
+ else if(/^\//.test(url)) { // Domain-relative
+ return 'url("' + base_domain + url + '")';
+ }
+ else if(/^\?/.test(url)) { // Query-relative
+ return 'url("' + base_query + url + '")';
+ }
+ else {
+ // Path-relative
+ return 'url("' + base + url + '")';
+ }
+ });
+
+ // behavior URLs shoudn’t be converted (Issue #19)
+ // base should be escaped before added to RegExp (Issue #81)
+ var escaped_base = base.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1");
+ css = css.replace(RegExp('\\b(behavior:\\s*?url\\(\'?"?)' + escaped_base, 'gi'), '$1');
+ }
+
+ var style = document.createElement('style');
+ style.textContent = css;
+ style.media = link.media;
+ style.disabled = link.disabled;
+ style.setAttribute('data-href', link.getAttribute('href'));
+
+ parent.insertBefore(style, link);
+ parent.removeChild(link);
+
+ style.media = link.media; // Duplicate is intentional. See issue #31
+ }
+ };
+
+ try {
+ xhr.open('GET', url);
+ xhr.send(null);
+ } catch (e) {
+ // Fallback to XDomainRequest if available
+ if (typeof XDomainRequest != "undefined") {
+ xhr = new XDomainRequest();
+ xhr.onerror = xhr.onprogress = function() {};
+ xhr.onload = process;
+ xhr.open("GET", url);
+ xhr.send(null);
+ }
+ }
+
+ link.setAttribute('data-inprogress', '');
+ },
+
+ styleElement: function(style) {
+ if (style.hasAttribute('data-noprefix')) {
+ return;
+ }
+ var disabled = style.disabled;
+
+ style.textContent = self.fix(style.textContent, true, style);
+
+ style.disabled = disabled;
+ },
+
+ styleAttribute: function(element) {
+ var css = element.getAttribute('style');
+
+ css = self.fix(css, false, element);
+
+ element.setAttribute('style', css);
+ },
+
+ process: function() {
+ // Linked stylesheets
+ $('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link);
+
+ // Inline stylesheets
+ $('style').forEach(StyleFix.styleElement);
+
+ // Inline styles
+ $('[style]').forEach(StyleFix.styleAttribute);
+ },
+
+ register: function(fixer, index) {
+ (self.fixers = self.fixers || [])
+ .splice(index === undefined? self.fixers.length : index, 0, fixer);
+ },
+
+ fix: function(css, raw, element) {
+ for(var i=0; i<self.fixers.length; i++) {
+ css = self.fixers[i](css, raw, element) || css;
+ }
+
+ return css;
+ },
+
+ camelCase: function(str) {
+ return str.replace(/-([a-z])/g, function($0, $1) { return $1.toUpperCase(); }).replace('-','');
+ },
+
+ deCamelCase: function(str) {
+ return str.replace(/[A-Z]/g, function($0) { return '-' + $0.toLowerCase() });
+ }
+};
+
+/**************************************
+ * Process styles
+ **************************************/
+(function(){
+ setTimeout(function(){
+ $('link[rel="stylesheet"]').forEach(StyleFix.link);
+ }, 10);
+
+ document.addEventListener('DOMContentLoaded', StyleFix.process, false);
+})();
+
+function $(expr, con) {
+ return [].slice.call((con || document).querySelectorAll(expr));
+}
+
+})();
+
+/**
+ * PrefixFree
+ */
+(function(root){
+
+if(!window.StyleFix || !window.getComputedStyle) {
+ return;
+}
+
+// Private helper
+function fix(what, before, after, replacement, css) {
+ what = self[what];
+
+ if(what.length) {
+ var regex = RegExp(before + '(' + what.join('|') + ')' + after, 'gi');
+
+ css = css.replace(regex, replacement);
+ }
+
+ return css;
+}
+
+var self = window.PrefixFree = {
+ prefixCSS: function(css, raw, element) {
+ var prefix = self.prefix;
+
+ // Gradient angles hotfix
+ if(self.functions.indexOf('linear-gradient') > -1) {
+ // Gradients are supported with a prefix, convert angles to legacy
+ css = css.replace(/(\s|:|,)(repeating-)?linear-gradient\(\s*(-?\d*\.?\d*)deg/ig, function ($0, delim, repeating, deg) {
+ return delim + (repeating || '') + 'linear-gradient(' + (90-deg) + 'deg';
+ });
+ }
+
+ css = fix('functions', '(\\s|:|,)', '\\s*\\(', '$1' + prefix + '$2(', css);
+ css = fix('keywords', '(\\s|:)', '(\\s|;|\\}|$)', '$1' + prefix + '$2$3', css);
+ css = fix('properties', '(^|\\{|\\s|;)', '\\s*:', '$1' + prefix + '$2:', css);
+
+ // Prefix properties *inside* values (issue #8)
+ if (self.properties.length) {
+ var regex = RegExp('\\b(' + self.properties.join('|') + ')(?!:)', 'gi');
+
+ css = fix('valueProperties', '\\b', ':(.+?);', function($0) {
+ return $0.replace(regex, prefix + "$1")
+ }, css);
+ }
+
+ if(raw) {
+ css = fix('selectors', '', '\\b', self.prefixSelector, css);
+ css = fix('atrules', '@', '\\b', '@' + prefix + '$1', css);
+ }
+
+ // Fix double prefixing
+ css = css.replace(RegExp('-' + prefix, 'g'), '-');
+
+ // Prefix wildcard
+ css = css.replace(/-\*-(?=[a-z]+)/gi, self.prefix);
+
+ return css;
+ },
+
+ property: function(property) {
+ return (self.properties.indexOf(property) >=0 ? self.prefix : '') + property;
+ },
+
+ value: function(value, property) {
+ value = fix('functions', '(^|\\s|,)', '\\s*\\(', '$1' + self.prefix + '$2(', value);
+ value = fix('keywords', '(^|\\s)', '(\\s|$)', '$1' + self.prefix + '$2$3', value);
+
+ if(self.valueProperties.indexOf(property) >= 0) {
+ value = fix('properties', '(^|\\s|,)', '($|\\s|,)', '$1'+self.prefix+'$2$3', value);
+ }
+
+ return value;
+ },
+
+ // Warning: Prefixes no matter what, even if the selector is supported prefix-less
+ prefixSelector: function(selector) {
+ return selector.replace(/^:{1,2}/, function($0) { return $0 + self.prefix })
+ },
+
+ // Warning: Prefixes no matter what, even if the property is supported prefix-less
+ prefixProperty: function(property, camelCase) {
+ var prefixed = self.prefix + property;
+
+ return camelCase? StyleFix.camelCase(prefixed) : prefixed;
+ }
+};
+
+/**************************************
+ * Properties
+ **************************************/
+(function() {
+ var prefixes = {},
+ properties = [],
+ shorthands = {},
+ style = getComputedStyle(document.documentElement, null),
+ dummy = document.createElement('div').style;
+
+ // Why are we doing this instead of iterating over properties in a .style object? Cause Webkit won't iterate over those.
+ var iterate = function(property) {
+ if(property.charAt(0) === '-') {
+ properties.push(property);
+
+ var parts = property.split('-'),
+ prefix = parts[1];
+
+ // Count prefix uses
+ prefixes[prefix] = ++prefixes[prefix] || 1;
+
+ // This helps determining shorthands
+ while(parts.length > 3) {
+ parts.pop();
+
+ var shorthand = parts.join('-');
+
+ if(supported(shorthand) && properties.indexOf(shorthand) === -1) {
+ properties.push(shorthand);
+ }
+ }
+ }
+ },
+ supported = function(property) {
+ return StyleFix.camelCase(property) in dummy;
+ }
+
+ // Some browsers have numerical indices for the properties, some don't
+ if(style.length > 0) {
+ for(var i=0; i<style.length; i++) {
+ iterate(style[i])
+ }
+ }
+ else {
+ for(var property in style) {
+ iterate(StyleFix.deCamelCase(property));
+ }
+ }
+
+ // Find most frequently used prefix
+ var highest = {uses:0};
+ for(var prefix in prefixes) {
+ var uses = prefixes[prefix];
+
+ if(highest.uses < uses) {
+ highest = {prefix: prefix, uses: uses};
+ }
+ }
+
+ self.prefix = '-' + highest.prefix + '-';
+ self.Prefix = StyleFix.camelCase(self.prefix);
+
+ self.properties = [];
+
+ // Get properties ONLY supported with a prefix
+ for(var i=0; i<properties.length; i++) {
+ var property = properties[i];
+
+ if(property.indexOf(self.prefix) === 0) { // we might have multiple prefixes, like Opera
+ var unprefixed = property.slice(self.prefix.length);
+
+ if(!supported(unprefixed)) {
+ self.properties.push(unprefixed);
+ }
+ }
+ }
+
+ // IE fix
+ if(self.Prefix == 'Ms'
+ && !('transform' in dummy)
+ && !('MsTransform' in dummy)
+ && ('msTransform' in dummy)) {
+ self.properties.push('transform', 'transform-origin');
+ }
+
+ self.properties.sort();
+})();
+
+/**************************************
+ * Values
+ **************************************/
+(function() {
+// Values that might need prefixing
+var functions = {
+ 'linear-gradient': {
+ property: 'backgroundImage',
+ params: 'red, teal'
+ },
+ 'calc': {
+ property: 'width',
+ params: '1px + 5%'
+ },
+ 'element': {
+ property: 'backgroundImage',
+ params: '#foo'
+ },
+ 'cross-fade': {
+ property: 'backgroundImage',
+ params: 'url(a.png), url(b.png), 50%'
+ }
+};
+
+
+functions['repeating-linear-gradient'] =
+functions['repeating-radial-gradient'] =
+functions['radial-gradient'] =
+functions['linear-gradient'];
+
+// Note: The properties assigned are just to *test* support.
+// The keywords will be prefixed everywhere.
+var keywords = {
+ 'initial': 'color',
+ 'zoom-in': 'cursor',
+ 'zoom-out': 'cursor',
+ 'box': 'display',
+ 'flexbox': 'display',
+ 'inline-flexbox': 'display',
+ 'flex': 'display',
+ 'inline-flex': 'display',
+ 'grid': 'display',
+ 'inline-grid': 'display',
+ 'max-content': 'width',
+ 'min-content': 'width',
+ 'fit-content': 'width',
+ 'fill-available': 'width'
+};
+
+self.functions = [];
+self.keywords = [];
+
+var style = document.createElement('div').style;
+
+function supported(value, property) {
+ style[property] = '';
+ style[property] = value;
+
+ return !!style[property];
+}
+
+for (var func in functions) {
+ var test = functions[func],
+ property = test.property,
+ value = func + '(' + test.params + ')';
+
+ if (!supported(value, property)
+ && supported(self.prefix + value, property)) {
+ // It's supported, but with a prefix
+ self.functions.push(func);
+ }
+}
+
+for (var keyword in keywords) {
+ var property = keywords[keyword];
+
+ if (!supported(keyword, property)
+ && supported(self.prefix + keyword, property)) {
+ // It's supported, but with a prefix
+ self.keywords.push(keyword);
+ }
+}
+
+})();
+
+/**************************************
+ * Selectors and @-rules
+ **************************************/
+(function() {
+
+var
+selectors = {
+ ':read-only': null,
+ ':read-write': null,
+ ':any-link': null,
+ '::selection': null
+},
+
+atrules = {
+ 'keyframes': 'name',
+ 'viewport': null,
+ 'document': 'regexp(".")'
+};
+
+self.selectors = [];
+self.atrules = [];
+
+var style = root.appendChild(document.createElement('style'));
+
+function supported(selector) {
+ style.textContent = selector + '{}'; // Safari 4 has issues with style.innerHTML
+
+ return !!style.sheet.cssRules.length;
+}
+
+for(var selector in selectors) {
+ var test = selector + (selectors[selector]? '(' + selectors[selector] + ')' : '');
+
+ if(!supported(test) && supported(self.prefixSelector(test))) {
+ self.selectors.push(selector);
+ }
+}
+
+for(var atrule in atrules) {
+ var test = atrule + ' ' + (atrules[atrule] || '');
+
+ if(!supported('@' + test) && supported('@' + self.prefix + test)) {
+ self.atrules.push(atrule);
+ }
+}
+
+root.removeChild(style);
+
+})();
+
+// Properties that accept properties as their value
+self.valueProperties = [
+ 'transition',
+ 'transition-property'
+]
+
+// Add class for current prefix
+root.className += ' ' + self.prefix;
+
+StyleFix.register(self.prefixCSS);
+
+
+})(document.documentElement); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/promise.js b/StoneIsland/platforms/android/assets/www/js/vendor/promise.js
new file mode 100755
index 00000000..f458ab06
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/promise.js
@@ -0,0 +1,34 @@
+var promise = function(fn, data){
+ var my_cb, my_res, error_cb, my_error
+ data = data || {}
+ data.success = function(res){
+ my_res = res
+ if (my_cb) {
+ my_cb(res)
+ }
+ }
+ data.error = function(res){
+ my_error = res
+ if (error_cb) {
+ error_cb(res)
+ }
+ else {
+ console.log('error!')
+ console.log(res)
+ }
+ }
+ fn(data)
+ var p = {
+ then: function(cb){
+ if (my_res) cb(my_res)
+ else my_cb = cb
+ return p
+ },
+ error: function(cb){
+ if (my_error) cb(my_error)
+ else error_cb = cb
+ return p
+ }
+ }
+ return p
+}
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/util.js b/StoneIsland/platforms/android/assets/www/js/vendor/util.js
new file mode 100755
index 00000000..23f55d4c
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/util.js
@@ -0,0 +1,199 @@
+if (window.$) {
+ $.fn.int = function() { return parseInt($(this).val(),10) }
+ $.fn.float = function() { return parseFloat($(this).val()) }
+ $.fn.string = function() { return trim($(this).val()) }
+ $.fn.enable = function() { return $(this).attr("disabled",null) }
+ $.fn.disable = function() { return $(this).attr("disabled","disabled") }
+ $.fn.sanitize = function(s) { return trim(sanitize($(this).val())) }
+ $.fn.stripHTML = function(s) { return trim(stripHTML($(this).val())) }
+ $.fn.sanitizeName = function(s) { return trim(sanitizeName($(this).val())) }
+ $.fn.htmlSafe = function(s) { return $(this).html(sanitize(s)) }
+ $.fn.toDollars = function(i) { return $(this).html((i/100).toFixed(2)) }
+}
+
+function trim (s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") }
+function sanitize (s){ return (s || "").replace(new RegExp("[<>&]", 'g'), "") }
+function sanitizeName (s){ return (s || "").replace(new RegExp("[^-_a-zA-Z0-9]", 'g'), "") }
+function stripHTML (s){ return (s || "").replace(/<[^>]+>/g, "") }
+function sanitizeHTML (s){ return (s || "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") }
+function capitalize (s){ return s.split(" ").map(capitalizeWord).join(" ") }
+function capitalizeWord (s){ return s.charAt(0).toUpperCase() + s.slice(1) }
+function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g,"-") }
+function rgb_string (rgb) { return "rgb(" + rgb.map(Math.round).join(",") + ")" }
+function rgba_string (rgb,a) { return "rgba(" + rgb.map(Math.round).join(",") + "," + a + ")" }
+function hex_string (rgb) { return "#" + rgb.map(Math.round).map(function(n){ var s = n.toString(16); return s.length == 1 ? "0"+s : s }).join("") }
+function parse_rgba_string (s) { return s.match(/(\d+)/g).slice(0,3) }
+
+function title_case (str) {
+ return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
+}
+function pluralize (n,s,ss) { return n + " " + s + ( n == 1 ? "" : (ss || "s") ) }
+function as_cash(n){
+ var cents = ((n*100) % 100);
+ if (cents < 10) { cents = "0" + (cents|0) }
+ else { cents = cents|0 }
+ return "$" + (n|0) + "." + cents
+}
+
+var E = Math.E
+var PI = Math.PI
+var PHI = (1+Math.sqrt(5))/2
+var TWO_PI = PI*2
+var HALF_PI = PI/2
+var LN10 = Math.LN10
+function clamp(n,a,b){ return n<a?a:n<b?n:b }
+function norm(n,a,b){ return (n-a) / (b-a) }
+function lerp(n,a,b){ return (b-a)*n+a }
+function mix(n,a,b){ return a*(1-n)+b*n }
+function abs(n){ return Math.abs(n) }
+function sign(n){ return n ? Math.abs(n)/n : 0 }
+function random(){ return Math.random() }
+function rand(n){ return (Math.random()*n) }
+function randint(n){ return rand(n)|0 }
+function randrange(a,b){ return a + rand(b-a) }
+function choice(a){ return a[randint(a.length)] }
+function noop(){}
+
+function range(m,n,s){
+ var a = []
+ s = s || 1
+ for (var i = m; i <= n; i += s) {
+ a.push(i)
+ }
+ return a
+}
+
+function defaults (dest, src) {
+ dest = dest || {}
+ for (var i in src) {
+ dest[i] = typeof dest[i] == 'undefined' ? src[i] : dest[i]
+ }
+ return dest
+}
+
+function pairs(h){
+ var a = []
+ for (var i in h) {
+ if(h.hasOwnProperty(i)) {
+ a.push([i, h[i]])
+ }
+ }
+ return a
+}
+function invert_hash (h) {
+ var k = {}
+ for (var i in h) { if (h.hasOwnProperty(i)) k[h[i]] = i }
+ return k
+}
+function filenameFromUrl (url) {
+ var partz = url.split( "/" )
+ return partz[partz.length-1].split(".")[0]
+}
+
+// Function.bind polyfill
+if (!Function.prototype.bind) {
+ Function.prototype.bind = function(oThis) {
+ if (typeof this !== 'function') {
+ // closest thing possible to the ECMAScript 5
+ // internal IsCallable function
+ throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
+ }
+
+ var aArgs = Array.prototype.slice.call(arguments, 1),
+ fToBind = this,
+ fNOP = function() {},
+ fBound = function() {
+ return fToBind.apply(this instanceof fNOP && oThis
+ ? this
+ : oThis,
+ aArgs.concat(Array.prototype.slice.call(arguments)));
+ };
+
+ fNOP.prototype = this.prototype;
+ fBound.prototype = new fNOP();
+
+ return fBound;
+ };
+}
+
+// rAF polyfill
+(function() {
+ var lastTime = 0;
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
+ for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
+ window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
+ window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
+ || window[vendors[x]+'CancelRequestAnimationFrame'];
+ }
+
+ if (!window.requestAnimationFrame)
+ window.requestAnimationFrame = function(callback, element) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
+ var id = window.setTimeout(function() { callback(currTime + timeToCall); },
+ timeToCall);
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+
+ if (!window.cancelAnimationFrame)
+ window.cancelAnimationFrame = function(id) {
+ clearTimeout(id);
+ };
+}());
+
+// Identify browser based on useragent string
+(function( ua ) {
+ ua = ua.toLowerCase();
+ var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+ /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
+ /(msie) ([\w.]+)/.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
+ [];
+ var matched = {
+ browser: match[ 1 ] || "",
+ version: match[ 2 ] || "0"
+ };
+ browser = {};
+ if ( matched.browser ) {
+ browser[ matched.browser ] = true;
+ browser.version = matched.version;
+ }
+ // Chrome is Webkit, but Webkit is also Safari.
+ if ( browser.chrome ) {
+ browser.webkit = true;
+ } else if ( browser.webkit ) {
+ browser.safari = true;
+ }
+ if (window.$) $.browser = browser;
+ return browser;
+})( navigator.userAgent );
+
+// Naive useragent detection pattern
+var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))
+var is_ipad = (navigator.userAgent.match(/iPad/i))
+var is_android = (navigator.userAgent.match(/Android/i))
+var is_mobile = is_iphone || is_ipad || is_android
+var is_desktop = ! is_mobile;
+var transformProp = browser.safari ? "WebkitTransform" : "transform";
+if (is_android) {
+ document.body.parentNode.classList.add("android")
+}
+else {
+ document.body.parentNode.classList.add("ios")
+}
+
+function selectElementContents(el) {
+ if (window.getSelection && document.createRange) {
+ var sel = window.getSelection();
+ var range = document.createRange();
+ range.selectNodeContents(el);
+ sel.removeAllRanges();
+ sel.addRange(range);
+ } else if (document.selection && document.body.createTextRange) {
+ var textRange = document.body.createTextRange();
+ textRange.moveToElementText(el);
+ textRange.select();
+ }
+}