diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php index be13b1fd1..0ba206483 100644 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php @@ -31,10 +31,10 @@ class AttributeFamilyTableSeeder extends Seeder 'code' => 'url_key', 'position' => 3 ], [ - 'code' => 'new_from', + 'code' => 'new', 'position' => 4 ], [ - 'code' => 'new_to', + 'code' => 'featured', 'position' => 5 ], [ 'code' => 'visible_individually', diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php index a2189e0f6..fa7c1f887 100644 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php @@ -14,9 +14,9 @@ class AttributeTableSeeder extends Seeder [ 'code' => 'sku', 'admin_name' => 'SKU', - // 'en' => [ - // 'name' => 'SKU' - // ], + 'en' => [ + 'name' => 'SKU' + ], 'type' => 'text', 'position' => 1, 'is_unique' => 1, @@ -29,9 +29,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'name', 'admin_name' => 'Name', - // 'en' => [ - // 'name' => 'Name' - // ], + 'en' => [ + 'name' => 'Name' + ], 'type' => 'text', 'position' => 2, 'is_required' => 1, @@ -43,9 +43,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'url_key', 'admin_name' => 'URL Key', - // 'en' => [ - // 'name' => 'URL Key' - // ], + 'en' => [ + 'name' => 'URL Key' + ], 'type' => 'text', 'position' => 3, 'is_unique' => 1, @@ -56,12 +56,12 @@ class AttributeTableSeeder extends Seeder 'is_configurable' => 0, 'is_user_defined' => 0 ], [ - 'code' => 'new_from', - 'admin_name' => 'New From', - // 'en' => [ - // 'name' => 'New From' - // ], - 'type' => 'datetime', + 'code' => 'new', + 'admin_name' => 'New', + 'en' => [ + 'name' => 'New' + ], + 'type' => 'boolean', 'position' => 4, 'is_required' => 0, 'value_per_locale' => 0, @@ -70,12 +70,12 @@ class AttributeTableSeeder extends Seeder 'is_configurable' => 0, 'is_user_defined' => 0 ], [ - 'code' => 'new_to', - 'admin_name' => 'New To', - // 'en' => [ - // 'name' => 'New To' - // ], - 'type' => 'datetime', + 'code' => 'featured', + 'admin_name' => 'Featured', + 'en' => [ + 'name' => 'Featured' + ], + 'type' => 'boolean', 'position' => 5, 'is_required' => 0, 'value_per_locale' => 0, @@ -86,9 +86,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'visible_individually', 'admin_name' => 'Visible Individually', - // 'en' => [ - // 'name' => 'Visible Individually' - // ], + 'en' => [ + 'name' => 'Visible Individually' + ], 'type' => 'boolean', 'position' => 6, 'is_required' => 1, @@ -100,9 +100,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'status', 'admin_name' => 'Status', - // 'en' => [ - // 'name' => 'Status' - // ], + 'en' => [ + 'name' => 'Status' + ], 'type' => 'boolean', 'position' => 7, 'is_required' => 1, @@ -114,9 +114,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'short_description', 'admin_name' => 'Short Description', - // 'en' => [ - // 'name' => 'Short Description' - // ], + 'en' => [ + 'name' => 'Short Description' + ], 'type' => 'textarea', 'position' => 8, 'is_required' => 1, @@ -128,9 +128,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'description', 'admin_name' => 'Description', - // 'en' => [ - // 'name' => 'Description' - // ], + 'en' => [ + 'name' => 'Description' + ], 'type' => 'textarea', 'position' => 9, 'is_required' => 1, @@ -142,9 +142,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'price', 'admin_name' => 'Price', - // 'en' => [ - // 'name' => 'Price' - // ], + 'en' => [ + 'name' => 'Price' + ], 'type' => 'price', 'position' => 10, 'is_required' => 1, @@ -156,9 +156,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'cost', 'admin_name' => 'Cost', - // 'en' => [ - // 'name' => 'Cost' - // ], + 'en' => [ + 'name' => 'Cost' + ], 'type' => 'price', 'position' => 11, 'is_required' => 0, @@ -170,9 +170,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'special_price', 'admin_name' => 'Special Price', - // 'en' => [ - // 'name' => 'Special Price' - // ], + 'en' => [ + 'name' => 'Special Price' + ], 'type' => 'price', 'position' => 12, 'is_required' => 0, @@ -184,9 +184,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'special_price_from', 'admin_name' => 'Special Price From', - // 'en' => [ - // 'name' => 'Special Price From' - // ], + 'en' => [ + 'name' => 'Special Price From' + ], 'type' => 'date', 'position' => 13, 'is_required' => 0, @@ -198,9 +198,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'special_price_to', 'admin_name' => 'Special Price To', - // 'en' => [ - // 'name' => 'Special Price To' - // ], + 'en' => [ + 'name' => 'Special Price To' + ], 'type' => 'date', 'position' => 14, 'is_required' => 0, @@ -212,9 +212,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'meta_title', 'admin_name' => 'Meta Title', - // 'en' => [ - // 'name' => 'Meta Description' - // ], + 'en' => [ + 'name' => 'Meta Description' + ], 'type' => 'textarea', 'position' => 15, 'is_required' => 0, @@ -226,9 +226,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'meta_keywords', 'admin_name' => 'Meta Keywords', - // 'en' => [ - // 'name' => 'Meta Keywords' - // ], + 'en' => [ + 'name' => 'Meta Keywords' + ], 'type' => 'textarea', 'position' => 16, 'is_required' => 0, @@ -240,9 +240,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'meta_description', 'admin_name' => 'Meta Description', - // 'en' => [ - // 'name' => 'Meta Description' - // ], + 'en' => [ + 'name' => 'Meta Description' + ], 'type' => 'textarea', 'position' => 17, 'is_required' => 0, @@ -254,9 +254,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'width', 'admin_name' => 'Width', - // 'en' => [ - // 'name' => 'Width' - // ], + 'en' => [ + 'name' => 'Width' + ], 'type' => 'text', 'validation' => 'numeric', 'position' => 18, @@ -269,9 +269,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'height', 'admin_name' => 'Height', - // 'en' => [ - // 'name' => 'Height' - // ], + 'en' => [ + 'name' => 'Height' + ], 'type' => 'text', 'validation' => 'numeric', 'position' => 19, @@ -284,9 +284,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'depth', 'admin_name' => 'Depth', - // 'en' => [ - // 'name' => 'Depth' - // ], + 'en' => [ + 'name' => 'Depth' + ], 'type' => 'text', 'validation' => 'numeric', 'position' => 20, @@ -299,9 +299,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'weight', 'admin_name' => 'Weight', - // 'en' => [ - // 'name' => 'Weight' - // ], + 'en' => [ + 'name' => 'Weight' + ], 'type' => 'text', 'validation' => 'numeric', 'position' => 21, @@ -314,9 +314,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'color', 'admin_name' => 'Color', - // 'en' => [ - // 'name' => 'Color' - // ], + 'en' => [ + 'name' => 'Color' + ], 'type' => 'select', 'position' => 22, 'is_required' => 0, @@ -356,9 +356,9 @@ class AttributeTableSeeder extends Seeder ], [ 'code' => 'size', 'admin_name' => 'Size', - // 'en' => [ - // 'name' => 'Size' - // ], + 'en' => [ + 'name' => 'Size' + ], 'type' => 'select', 'position' => 23, 'is_required' => 0, diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index bf2d7132b..aa2849732 100644 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -109,25 +109,11 @@ class Cart { } } + $child = $childData = null; if($product->type == 'configurable') { //Check if the product is salable $child = $this->product->findOneByField('id', $data['selected_configurable_option']); - $parentData = [ - 'sku' => $product->sku, - 'product_id' => $productId, - 'quantity' => $data['quantity'], - 'type' => 'configurable', - 'name' => $product->name, - 'price' => ($price = $child->price), //This should be price from the price helper - 'base_price' => $price, - 'total' => $price * $data['quantity'], - 'base_total' => $price * $data['quantity'], - 'weight' => ($weight = $child->weight), - 'total_weight' => $weight * $data['quantity'], - 'base_total_weight' => $weight * $data['quantity'], - ]; - //child row data $childData = [ 'product_id' => $data['selected_configurable_option'], @@ -136,33 +122,31 @@ class Cart { 'type' => $child->type, 'name' => $child->name ]; - - return ['parent' => $parentData, 'child' => $childData]; - } else { - $parentData = [ - 'sku' => $product->sku, - 'product_id' => $productId, - 'quantity' => $data['quantity'], - 'type' => 'simple', - 'name' => $product->name, - 'price' => $product->price, - 'base_price' => $product->price, - 'total' => $product->price * $data['quantity'], - 'base_total' => $product->price * $data['quantity'], - 'weight' => $product->weight, - 'total_weight' => $product->weight * $data['quantity'], - 'base_total_weight' => $product->weight * $data['quantity'], - ]; - - return ['parent' => $parentData, 'child' => null]; } + + $parentData = [ + 'sku' => $product->sku, + 'product_id' => $productId, + 'quantity' => $data['quantity'], + 'type' => $product->type, + 'name' => $product->name, + 'price' => $price = ($product->type == 'configurable' ? $child->price : $product->price), + 'base_price' => $price, + 'total' => $price * $data['quantity'], + 'base_total' => $price * $data['quantity'], + 'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight), + 'total_weight' => $weight * $data['quantity'], + 'base_total_weight' => $weight * $data['quantity'] + ]; + + return ['parent' => $parentData, 'child' => $childData]; } /** * Create new cart instance with the current item success. * * @param integer $id - * @param array $data + * @param array $data * * @return Response */ @@ -175,63 +159,74 @@ class Cart { //auth user details else they will be set when the customer is guest if(auth()->guard('customer')->check()) { $cartData['customer_id'] = auth()->guard('customer')->user()->id; - $cartData['is_guest'] = 0; - $cartData['customer_first_name'] = auth()->guard('customer')->user()->first_name; - $cartData['customer_last_name'] = auth()->guard('customer')->user()->last_name; + $cartData['customer_email'] = auth()->guard('customer')->user()->email; } else { $cartData['is_guest'] = 1; } $cartData['items_count'] = 1; - $cartData['items_qty'] = $data['quantity']; if($cart = $this->cart->create($cartData)) { $itemData['parent']['cart_id'] = $cart->id; + $product = $this->product->find($id); - if ($this->product->find($id)->type == "configurable") { + if ($product->type == "configurable") { //parent item entry $itemData['parent']['additional'] = json_encode($data); - if($parent = $this->cartItem->create($itemData['parent'])) { + if($parent = $this->cartItem->create($itemData['parent'])) { //child item entry $itemData['child']['parent_id'] = $parent->id; $itemData['child']['cart_id'] = $cart->id; + if($child = $this->cartItem->create($itemData['child'])) { - session()->put('cart', $cart); + $this->putCart($cart); session()->flash('success', trans('shop::app.checkout.cart.item.success')); $this->collectTotals(); - return redirect()->back(); + return $cart; } } - } else if($this->product->find($id)->type != "configurable") { - if($result = $this->cartItem->create($itemData['parent'])) { - session()->put('cart', $cart); + } else if($product->type != "configurable") { + if($this->cartItem->create($itemData['parent'])) { + $this->putCart($cart); session()->flash('success', trans('shop::app.checkout.cart.item.success')); $this->collectTotals(); - return redirect()->back(); + return $cart; } } } session()->flash('error', trans('shop::app.checkout.cart.item.error_add')); - return redirect()->back(); + return false; + } + + /** + * Save cart + * + * @return mixed + */ + public function putCart($cart) + { + if(!auth()->guard('customer')->check()) { + session()->put('cart', $cart); + } } /** * Returns cart * - * @return Mixed + * @return mixed */ public function getCart() { @@ -276,38 +271,26 @@ class Cart { */ public function canAddOrUpdate($itemId, $quantity) { - $item = $this->cartItem->findOneByField('id', $itemId); - - $inventories = $item->product->inventories; - - $inventory_sources = $item->product->inventory_sources; - - $totalQty = 0; - - foreach($inventory_sources as $inventory_source) { - if($inventory_source->status && $inventory_source->toArray()['pivot']['qty']) { - $totalQty = $totalQty + $inventory_source->toArray()['pivot']['qty']; - } - } - if ($quantity < 1) { session()->flash('warning', trans('shop::app.checkout.cart.quantity.warning')); return redirect()->back(); } - if($quantity <= $totalQty) { + $item = $this->cartItem->findOneByField('id', $itemId); + + if($item->product->haveSufficientQuantity($quantity)) { return true; - } else { - return false; } + + return false; } /** * Add Items in a cart with some cart and item details. * - * @param @id - * @param $data + * @param integer $id + * @param array $data * * @return void */ @@ -315,14 +298,14 @@ class Cart { { $itemData = $this->prepareItemData($id, $data); - if(session()->has('cart')) { - $cart = $this->getCart(); + if($cart = $this->getCart()) { + $product = $this->product->find($id); - $cartItems = $cart->items()->get(); + $cartItems = $cart->items; - if(isset($cartItems)) { + if($cartItems->count()) { foreach($cartItems as $cartItem) { - if($this->product->find($id)->type == "simple") { + if($product->type == "simple") { if($cartItem->product_id == $id) { $prevQty = $cartItem->quantity; @@ -348,7 +331,7 @@ class Cart { return redirect()->back(); } - } else if($this->product->find($id)->type == "configurable") { + } else if($product->type == "configurable") { if($cartItem->type == "configurable") { $temp = $this->cartItem->findOneByField('parent_id', $cartItem->id); if($temp->product_id == $data['selected_configurable_option']) { @@ -384,17 +367,13 @@ class Cart { } } - if($this->product->find($id)->type == "configurable") { + if($product->type == "configurable") { $parent = $cart->items()->create($itemData['parent']); $itemData['child']['parent_id'] = $parent->id; - // $this->canAddOrUpdate($parent->child->id, $parent->quantity); - $cart->items()->create($itemData['child']); - } else if($this->product->find($id)->type != "configurable"){ - // $this->canAddOrUpdate($parent->id, $parent->quantity); - + } else if($product->type != "configurable"){ $parent = $cart->items()->create($itemData['parent']); } @@ -402,16 +381,16 @@ class Cart { session()->flash('success', trans('shop::app.checkout.cart.item.success')); - return redirect()->back(); + return $cart; } else { if(isset($cart)) { $this->cart->delete($cart->id); } else { - $this->createNewCart($id, $data); + return $this->createNewCart($id, $data); } } } else { - $this->createNewCart($id, $data); + return $this->createNewCart($id, $data); } } @@ -421,9 +400,7 @@ class Cart { */ public function update($itemIds) { - if(session()->has('cart')) { - $cart = $this->getCart(); - + if($cart = $this->getCart()) { $items = $cart->items; foreach($items as $item) { @@ -438,7 +415,7 @@ class Cart { if($canBe == false) { session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning')); - return redirect()->back(); + return $cart; } $item->update(['quantity' => $quantity]); @@ -447,10 +424,11 @@ class Cart { } } } - session()->flash('success', trans('shop::app.checkout.cart.quantity.success')); - return redirect()->back(); + session()->flash('success', trans('shop::app.checkout.cart.quantity.success')); } + + return $cart; } /** @@ -461,46 +439,17 @@ class Cart { public function removeItem($itemId) { if($cart = $this->getCart()) { - $items = $cart->items; - - foreach($items as $item) { - if($item->id == $itemId) { - if($item->type == "configurable") { - $child = $item->child; - - //delete the child first - $result = $this->cartItem->delete($child->id); - if($result) - $result = $this->cartItem->delete($item->id); - - $this->collectTotals(); - } else if($item->type == "simple" && $item->parent_id == null){ - $result = $this->cartItem->delete($item->id); - - $this->collectTotals(); - } - } - } - $countItems = $this->cart->findOneByField('id', $cart->id)->items->count(); + $this->cartItem->delete($itemId); //delete the cart instance if no items are there - if($countItems == 0) { - $result = $this->cart->delete($cart->id); + if($cart->items()->get()->count() == 0) { + $this->cart->delete($cart->id); session()->forget('cart'); - } else { - session()->forget('cart'); - session()->put('cart', $this->cart->findOneByField('id', $cart->id)); - } - - if ($result) { - session()->flash('sucess', trans('shop::app.checkout.cart.quantity.success_remove')); - } else { - session()->flash('error', trans('shop::app.checkout.cart.quantity.error_remove')); + session()->flash('success', trans('shop::app.checkout.cart.quantity.success_remove')); } } - return redirect()->back(); } /** @@ -676,7 +625,7 @@ class Cart { if(session()->has('cart')) { $cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id); - $guestCart = $this->getCart(); + $guestCart = session()->get('cart'); if(!isset($cart)) { $guestCart->update(['customer_id' => auth()->guard('customer')->user()->id, 'is_guest' => 0]); @@ -777,9 +726,6 @@ class Cart { //forget the guest cart instance session()->forget('cart'); - //put the customer cart instance - session()->put('cart', $cart); - $this->collectTotals(); return redirect()->back(); @@ -788,22 +734,6 @@ class Cart { } } - /** - * Destroys the session maintained for cart on customer logout. - * - * @return response - */ - public function destroyCart() - { - if(session()->has('cart')) { - session()->forget('cart'); - - return redirect()->back(); - } else { - return redirect()->back(); - } - } - /** * Checks if cart has any error * diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php index 57c9a8de5..02096f95c 100644 --- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php +++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php @@ -57,7 +57,7 @@ class CreateCartItemsTable extends Migration }); Schema::table('cart_items', function (Blueprint $table) { - $table->foreign('parent_id')->references('id')->on('cart_items'); + $table->foreign('parent_id')->references('id')->on('cart_items')->onDelete('cascade'); }); } diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php index ff92b9051..f5b395c62 100644 --- a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -12,30 +12,14 @@ class CustomerEventsHandler { public function onCustomerLogin($event) { /** - * handle the user login - * event to manage the - * after login, if - * the user has added any - * products as guest then - * the cart items from session - * will be transferred from - * cookie to the cart table - * in the database. + * handle the user login event to manage the after login, if the user has added any products as guest then + * the cart items from session will be transferred from cookie to the cart table in the database. * - * Check whether cookie is - * present or not and then - * check emptiness and then - * do the appropriate actions. + * Check whether cookie is present or not and then check emptiness and then do the appropriate actions. */ Cart::mergeCart(); } - //Customer Logout Event Handler. - public function onCustomerLogout($event) - { - Cart::destroyCart(); - } - /** * Register the listeners for the subscriber. * @@ -45,7 +29,5 @@ class CustomerEventsHandler { public function subscribe($events) { $events->listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); - - $events->listen('customer.after.logout', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogout'); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php new file mode 100644 index 000000000..d27474bab --- /dev/null +++ b/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php @@ -0,0 +1,49 @@ +attribute = $attribute; + } + + /** + * Apply criteria in query repository + * + * @param string $model + * @param RepositoryInterface $repository + * + * @return mixed + */ + public function apply($model, RepositoryInterface $repository) + { + $attribute = $this->attribute->findOneByField('code', 'featured'); + + $model = $model->leftJoin('product_attribute_values as filter_featured', 'products.id', '=', 'filter_featured.product_id'); + + $model->where('filter_featured.boolean_value', 1) + ->where('filter_featured.attribute_id', $attribute->id); + + return $model; + } +} diff --git a/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php new file mode 100644 index 000000000..72ee4c9d4 --- /dev/null +++ b/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php @@ -0,0 +1,49 @@ +attribute = $attribute; + } + + /** + * Apply criteria in query repository + * + * @param string $model + * @param RepositoryInterface $repository + * + * @return mixed + */ + public function apply($model, RepositoryInterface $repository) + { + $attribute = $this->attribute->findOneByField('code', 'new'); + + $model = $model->leftJoin('product_attribute_values as filter_new', 'products.id', '=', 'filter_new.product_id'); + + $model->where('filter_new.boolean_value', 1) + ->where('filter_new.attribute_id', $attribute->id); + + return $model; + } +} diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index b1d8bd1e4..223bcad22 100644 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -185,27 +185,7 @@ class Product extends Model $attributeModel = $this->attribute_family->custom_attributes()->where('attributes.code', $key)->first(); - if($attributeModel) { - $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); - - $locale = request()->get('locale') ?: app()->getLocale(); - - if($attributeModel->value_per_channel) { - if($attributeModel->value_per_locale) { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attributeModel->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attributeModel->id)->first(); - } - } else { - if($attributeModel->value_per_locale) { - $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attributeModel->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('attribute_id', $attributeModel->id)->first(); - } - } - - $this->attributes[$key] = $attributeValue[ProductAttributeValue::$attributeTypeFields[$attributeModel->type]]; - } + $this->attributes[$key] = $this->getCustomAttributeValue($attributeModel); return $this->getAttributeValue($key); } @@ -225,36 +205,49 @@ class Product extends Model $hiddenAttributes = $this->getHidden(); if(isset($this->id)) { - $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); - - $locale = request()->get('locale') ?: app()->getLocale(); - foreach ($this->attribute_family->custom_attributes as $attribute) { if (in_array($attribute->code, $hiddenAttributes)) { continue; } - if($attribute->value_per_channel) { - if($attribute->value_per_locale) { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attribute->id)->first(); - } - } else { - if($attribute->value_per_locale) { - $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('attribute_id', $attribute->id)->first(); - } - } - - $attributes[$attribute->code] = $attributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]]; + $attributes[$attribute->code] = $this->getCustomAttributeValue($attribute); } } return $attributes; } + /** + * Get an product attribute value. + * + * @return mixed + */ + public function getCustomAttributeValue($attribute) + { + if(!$attribute) + return; + + $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); + + $locale = request()->get('locale') ?: app()->getLocale(); + + if($attribute->value_per_channel) { + if($attribute->value_per_locale) { + $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); + } else { + $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attribute->id)->first(); + } + } else { + if($attribute->value_per_locale) { + $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); + } else { + $attributeValue = $this->attribute_values()->where('attribute_id', $attribute->id)->first(); + } + } + + return $attributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]]; + } + /** * Overrides the default Eloquent query builder * diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 553953e37..c770749a8 100644 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -14,6 +14,8 @@ use Webkul\Product\Contracts\Criteria\SortCriteria; use Webkul\Product\Contracts\Criteria\AttributeToSelectCriteria; use Webkul\Product\Contracts\Criteria\FilterByAttributesCriteria; use Webkul\Product\Contracts\Criteria\FilterByCategoryCriteria; +use Webkul\Product\Contracts\Criteria\NewProductsCriteria; +use Webkul\Product\Contracts\Criteria\FeaturedProductsCriteria; use Illuminate\Database\Eloquent\ModelNotFoundException; /** @@ -425,12 +427,13 @@ class ProductRepository extends Repository } /** - * Return newly added product + * Returns newly added product * * @return Collection */ public function getNewProducts() { + $this->pushCriteria(app(NewProductsCriteria::class)); $this->pushCriteria(app(AttributeToSelectCriteria::class)->addAttribueToSelect([ 'name', 'description', @@ -443,7 +446,32 @@ class ProductRepository extends Repository $params = request()->input(); - return $this->scopeQuery(function($query){ + return $this->scopeQuery(function($query) { + return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc'); + })->paginate(4, ['products.id']); + } + + /** + * Returns featured product + * + * @return Collection + */ + public function getFeaturedProducts() + { + $this->pushCriteria(app(FeaturedProductsCriteria::class)); + $this->pushCriteria(app(AttributeToSelectCriteria::class)->addAttribueToSelect([ + 'name', + 'description', + 'short_description', + 'price', + 'special_price', + 'special_price_from', + 'special_price_to' + ])); + + $params = request()->input(); + + return $this->scopeQuery(function($query) { return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc'); })->paginate(4, ['products.id']); } diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index 30f4a4635..d3a66910d 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -13,10 +13,8 @@ use Webkul\Product\Product\View as ProductView; use Cart; /** - * Cart controller for the customer - * and guest users for adding and - * removing the products in the - * cart. + * Cart controller for the customer and guest users for adding and + * removing the products in the cart. * * @author Prashant Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) @@ -25,9 +23,7 @@ class CartController extends Controller { /** - * Protected Variables that - * holds instances of the - * repository classes. + * Protected Variables that holds instances of the repository classes. * * @param Array $_config * @param $cart @@ -85,9 +81,7 @@ class CartController extends Controller } /** - * Function for guests - * user to add the product - * in the cart. + * Function for guests user to add the product in the cart. * * @return Mixed */ @@ -101,8 +95,7 @@ class CartController extends Controller } /** - * Removes the item from - * the cart if it exists + * Removes the item from the cart if it exists * * @param integer $itemId */ @@ -113,8 +106,7 @@ class CartController extends Controller } /** - * Updates the quantity of the - * items present in the cart. + * Updates the quantity of the items present in the cart. * * @return response */ diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php new file mode 100644 index 000000000..64dd9d8d1 --- /dev/null +++ b/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php @@ -0,0 +1,47 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class FeaturedProductListComposer +{ + /** + * ProductRepository object + * + * @var array + */ + protected $product; + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function __construct(Product $product) + { + $this->product = $product; + } + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function compose(View $view) + { + $products = $this->product->getFeaturedProducts(); + + $view->with('products', $products); + } +} diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php index b6414a931..08410cfd7 100644 --- a/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php +++ b/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php @@ -40,7 +40,6 @@ class NewProductListComposer */ public function compose(View $view) { - // dd($mytime = \Carbon\Carbon::now()); $products = $this->product->getNewProducts(); $view->with('products', $products); diff --git a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php index b6d6380bc..0accfe8c1 100644 --- a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php +++ b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php @@ -26,5 +26,10 @@ class ComposerServiceProvider extends ServiceProvider ['shop::home.new-products'], 'Webkul\Shop\Http\ViewComposers\NewProductListComposer' ); + + View::composer( + ['shop::home.featured-products'], + 'Webkul\Shop\Http\ViewComposers\FeaturedProductListComposer' + ); } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index 2aa802a9f..1b26b6bbf 100644 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -1,6 +1,10 @@ [ + 'featured-products' => 'Featured Products', + 'new-products' => 'New Products' + ], 'customer' => [ 'signup-text' => [ 'account_exists' => 'Already have an account', diff --git a/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php b/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php index 09f2262e6..6fe603bb1 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php @@ -1,31 +1,21 @@ - +@endif \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php index 47b282aed..e1ac27d3b 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php @@ -1,93 +1,21 @@ - +@endif diff --git a/public/themes/default/assets/js/shop.js b/public/themes/default/assets/js/shop.js index 6ec7a5900..b7b305970 100644 --- a/public/themes/default/assets/js/shop.js +++ b/public/themes/default/assets/js/shop.js @@ -31518,7 +31518,7 @@ if (false) { /* 50 */ /***/ (function(module, exports, __webpack_require__) { -!function(t,e){ true?module.exports=e():"function"==typeof define&&define.amd?define("vue-slider-component",[],e):"object"==typeof exports?exports["vue-slider-component"]=e():t["vue-slider-component"]=e()}(this,function(){return function(t){function e(s){if(i[s])return i[s].exports;var r=i[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var i={};return e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,s){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:s})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,i){i(7);var s=i(5)(i(1),i(6),null,null);t.exports=s.exports},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=function(){var t="undefined"!=typeof window?window.devicePixelRatio||1:1;return function(e){return Math.round(e*t)/t}}();e.default={name:"VueSliderComponent",props:{width:{type:[Number,String],default:"auto"},height:{type:[Number,String],default:6},data:{type:Array,default:null},dotSize:{type:Number,default:16},dotWidth:{type:Number,required:!1},dotHeight:{type:Number,required:!1},min:{type:Number,default:0},max:{type:Number,default:100},interval:{type:Number,default:1},show:{type:Boolean,default:!0},disabled:{type:[Boolean,Array],default:!1},piecewise:{type:Boolean,default:!1},tooltip:{type:[String,Boolean],default:"always"},eventType:{type:String,default:"auto"},direction:{type:String,default:"horizontal"},reverse:{type:Boolean,default:!1},lazy:{type:Boolean,default:!1},clickable:{type:Boolean,default:!0},speed:{type:Number,default:.5},realTime:{type:Boolean,default:!1},stopPropagation:{type:Boolean,default:!1},value:{type:[String,Number,Array,Object],default:0},piecewiseLabel:{type:Boolean,default:!1},debug:{type:Boolean,default:!0},fixed:{type:Boolean,default:!1},processDragable:{type:Boolean,default:!1},useKeyboard:{type:Boolean,default:!1},actionsKeyboard:{type:Array,default:function(){return[function(t){return t-1},function(t){return t+1}]}},tooltipMerge:{type:Boolean,default:!0},startAnimation:{type:Boolean,default:!1},sliderStyle:[Array,Object,Function],focusStyle:[Array,Object,Function],tooltipDir:[Array,String],formatter:[String,Function],mergeFormatter:[String,Function],piecewiseStyle:Object,disabledStyle:Object,piecewiseActiveStyle:Object,processStyle:Object,bgStyle:Object,tooltipStyle:[Array,Object,Function],disabledDotStyle:[Array,Object,Function],labelStyle:Object,labelActiveStyle:Object},data:function(){return{flag:!1,keydownFlag:null,focusFlag:!1,processFlag:!1,processSign:null,size:0,fixedValue:0,focusSlider:0,currentValue:0,currentSlider:0,isComponentExists:!0,isMounted:!1}},computed:{dotWidthVal:function(){return"number"==typeof this.dotWidth?this.dotWidth:this.dotSize},dotHeightVal:function(){return"number"==typeof this.dotHeight?this.dotHeight:this.dotSize},flowDirection:function(){return"vue-slider-"+this.direction+(this.reverse?"-reverse":"")},tooltipMergedPosition:function(){if(!this.isMounted)return{};var t=this.tooltipDirection[0];if(this.$refs.dot0){if("vertical"===this.direction){var e={};return e[t]="-"+(this.dotHeightVal/2-this.width/2+9)+"px",e}var i={};return i[t]="-"+(this.dotWidthVal/2-this.height/2+9)+"px",i.left="50%",i}},tooltipDirection:function(){var t=this.tooltipDir||("vertical"===this.direction?"left":"top");return Array.isArray(t)?this.isRange?t:t[1]:this.isRange?[t,t]:t},tooltipStatus:function(){return"hover"===this.tooltip&&this.flag?"vue-slider-always":this.tooltip?"vue-slider-"+this.tooltip:""},tooltipClass:function(){return["vue-slider-tooltip-"+this.tooltipDirection,"vue-slider-tooltip"]},disabledArray:function(){return Array.isArray(this.disabled)?this.disabled:[this.disabled,this.disabled]},boolDisabled:function(){return this.disabledArray.every(function(t){return!0===t})},isDisabled:function(){return"none"===this.eventType||this.boolDisabled},disabledClass:function(){return this.boolDisabled?"vue-slider-disabled":""},stateClass:function(){return{"vue-slider-state-process-drag":this.processFlag,"vue-slider-state-drag":this.flag&&!this.processFlag&&!this.keydownFlag,"vue-slider-state-focus":this.focusFlag}},isRange:function(){return Array.isArray(this.value)},slider:function(){return this.isRange?[this.$refs.dot0,this.$refs.dot1]:this.$refs.dot},minimum:function(){return this.data?0:this.min},val:{get:function(){return this.data?this.isRange?[this.data[this.currentValue[0]],this.data[this.currentValue[1]]]:this.data[this.currentValue]:this.currentValue},set:function(t){if(this.data)if(this.isRange){var e=this.data.indexOf(t[0]),i=this.data.indexOf(t[1]);e>-1&&i>-1&&(this.currentValue=[e,i])}else{var s=this.data.indexOf(t);s>-1&&(this.currentValue=s)}else this.currentValue=t}},currentIndex:function(){return this.isRange?this.data?this.currentValue:[this.getIndexByValue(this.currentValue[0]),this.getIndexByValue(this.currentValue[1])]:this.getIndexByValue(this.currentValue)},indexRange:function(){return this.isRange?this.currentIndex:[0,this.currentIndex]},maximum:function(){return this.data?this.data.length-1:this.max},multiple:function(){var t=(""+this.interval).split(".")[1];return t?Math.pow(10,t.length):1},spacing:function(){return this.data?1:this.interval},total:function(){return this.data?this.data.length-1:(Math.floor((this.maximum-this.minimum)*this.multiple)%(this.interval*this.multiple)!=0&&this.printError("Prop[interval] is illegal, Please make sure that the interval can be divisible"),(this.maximum-this.minimum)/this.interval)},gap:function(){return this.size/this.total},position:function(){return this.isRange?[(this.currentValue[0]-this.minimum)/this.spacing*this.gap,(this.currentValue[1]-this.minimum)/this.spacing*this.gap]:(this.currentValue-this.minimum)/this.spacing*this.gap},limit:function(){return this.isRange?this.fixed?[[0,(this.total-this.fixedValue)*this.gap],[this.fixedValue*this.gap,this.size]]:[[0,this.position[1]],[this.position[0],this.size]]:[0,this.size]},valueLimit:function(){return this.isRange?this.fixed?[[this.minimum,this.maximum-this.fixedValue*(this.spacing*this.multiple)/this.multiple],[this.minimum+this.fixedValue*(this.spacing*this.multiple)/this.multiple,this.maximum]]:[[this.minimum,this.currentValue[1]],[this.currentValue[0],this.maximum]]:[this.minimum,this.maximum]},idleSlider:function(){return 0===this.currentSlider?1:0},wrapStyles:function(){return"vertical"===this.direction?{height:"number"==typeof this.height?this.height+"px":this.height,padding:this.dotHeightVal/2+"px "+this.dotWidthVal/2+"px"}:{width:"number"==typeof this.width?this.width+"px":this.width,padding:this.dotHeightVal/2+"px "+this.dotWidthVal/2+"px"}},sliderStyles:function(){return Array.isArray(this.sliderStyle)?this.isRange?this.sliderStyle:this.sliderStyle[1]:"function"==typeof this.sliderStyle?this.sliderStyle(this.val,this.currentIndex):this.isRange?[this.sliderStyle,this.sliderStyle]:this.sliderStyle},focusStyles:function(){return Array.isArray(this.focusStyle)?this.isRange?this.focusStyle:this.focusStyle[1]:"function"==typeof this.focusStyle?this.focusStyle(this.val,this.currentIndex):this.isRange?[this.focusStyle,this.focusStyle]:this.focusStyle},disabledDotStyles:function(){var t=this.disabledDotStyle;if(Array.isArray(t))return t;if("function"==typeof t){var e=t(this.val,this.currentIndex);return Array.isArray(e)?e:[e,e]}return t?[t,t]:[{backgroundColor:"#ccc"},{backgroundColor:"#ccc"}]},tooltipStyles:function(){return Array.isArray(this.tooltipStyle)?this.isRange?this.tooltipStyle:this.tooltipStyle[1]:"function"==typeof this.tooltipStyle?this.tooltipStyle(this.val,this.currentIndex):this.isRange?[this.tooltipStyle,this.tooltipStyle]:this.tooltipStyle},elemStyles:function(){return"vertical"===this.direction?{width:this.width+"px",height:"100%"}:{height:this.height+"px"}},dotStyles:function(){return"vertical"===this.direction?{width:this.dotWidthVal+"px",height:this.dotHeightVal+"px",left:-(this.dotWidthVal-this.width)/2+"px"}:{width:this.dotWidthVal+"px",height:this.dotHeightVal+"px",top:-(this.dotHeightVal-this.height)/2+"px"}},piecewiseDotStyle:function(){return"vertical"===this.direction?{width:this.width+"px",height:this.width+"px"}:{width:this.height+"px",height:this.height+"px"}},piecewiseDotWrap:function(){if(!this.piecewise&&!this.piecewiseLabel)return!1;for(var t=[],e=0;e<=this.total;e++){var i="vertical"===this.direction?{bottom:this.gap*e-this.width/2+"px",left:0}:{left:this.gap*e-this.height/2+"px",top:0},s=this.reverse?this.total-e:e,r=this.data?this.data[s]:this.spacing*s+this.min;t.push({style:i,label:this.formatter?this.formatting(r):r,inRange:s>=this.indexRange[0]&&s<=this.indexRange[1]})}return t}},watch:{value:function(t){this.flag||this.setValue(t,!0)},max:function(t){if(tthis.max)return this.printError("The minimum value can not be greater than the maximum value.");var e=this.limitValue(this.val);this.setValue(e),this.refresh()},show:function(t){var e=this;t&&!this.size&&this.$nextTick(function(){e.refresh()})},fixed:function(){this.computedFixedValue()}},methods:{bindEvents:function(){document.addEventListener("touchmove",this.moving,{passive:!1}),document.addEventListener("touchend",this.moveEnd,{passive:!1}),document.addEventListener("mousedown",this.blurSlider),document.addEventListener("mousemove",this.moving),document.addEventListener("mouseup",this.moveEnd),document.addEventListener("mouseleave",this.moveEnd),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("keyup",this.handleKeyup),window.addEventListener("resize",this.refresh),this.isRange&&this.tooltipMerge&&(this.$refs.dot0.addEventListener("transitionend",this.handleOverlapTooltip),this.$refs.dot1.addEventListener("transitionend",this.handleOverlapTooltip))},unbindEvents:function(){document.removeEventListener("touchmove",this.moving),document.removeEventListener("touchend",this.moveEnd),document.removeEventListener("mousedown",this.blurSlider),document.removeEventListener("mousemove",this.moving),document.removeEventListener("mouseup",this.moveEnd),document.removeEventListener("mouseleave",this.moveEnd),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("keyup",this.handleKeyup),window.removeEventListener("resize",this.refresh),this.isRange&&this.tooltipMerge&&(this.$refs.dot0.removeEventListener("transitionend",this.handleOverlapTooltip),this.$refs.dot1.removeEventListener("transitionend",this.handleOverlapTooltip))},handleKeydown:function(t){if(!this.useKeyboard||!this.focusFlag)return!1;switch(t.keyCode){case 37:case 40:t.preventDefault(),this.keydownFlag=!0,this.flag=!0,this.changeFocusSlider(this.actionsKeyboard[0]);break;case 38:case 39:t.preventDefault(),this.keydownFlag=!0,this.flag=!0,this.changeFocusSlider(this.actionsKeyboard[1])}},handleKeyup:function(){this.keydownFlag&&(this.keydownFlag=!1,this.flag=!1)},changeFocusSlider:function(t){var e=this;if(this.isRange){var i=this.currentIndex.map(function(i,s){if(s===e.focusSlider||e.fixed){var r=t(i),o=e.fixed?e.valueLimit[s]:[0,e.total];if(r<=o[1]&&r>=o[0])return r}return i});i[0]>i[1]&&(this.focusSlider=0===this.focusSlider?1:0,i=i.reverse()),this.setIndex(i)}else this.setIndex(t(this.currentIndex))},blurSlider:function(t){var e=this.isRange?this.$refs["dot"+this.focusSlider]:this.$refs.dot;if(!e||e===t.target)return!1;this.focusFlag=!1},formatting:function(t){return"string"==typeof this.formatter?this.formatter.replace(/\{value\}/,t):this.formatter(t)},mergeFormatting:function(t,e){return"string"==typeof this.mergeFormatter?this.mergeFormatter.replace(/\{(value1|value2)\}/g,function(i,s){return"value1"===s?t:e}):this.mergeFormatter(t,e)},getPos:function(t){return this.realTime&&this.getStaticData(),"vertical"===this.direction?this.reverse?t.pageY-this.offset:this.size-(t.pageY-this.offset):this.reverse?this.size-(t.clientX-this.offset):t.clientX-this.offset},processClick:function(t){this.fixed&&t.stopPropagation()},wrapClick:function(t){var e=this;if(this.isDisabled||!this.clickable||this.processFlag)return!1;var i=this.getPos(t);if(this.isRange)if(this.disabledArray.every(function(t){return!1===t}))this.currentSlider=i>(this.position[1]-this.position[0])/2+this.position[0]?1:0;else if(this.disabledArray[0]){if(ithis.position[1])return!1;this.currentSlider=0}if(this.disabledArray[this.currentSlider])return!1;if(this.setValueOnPos(i),this.isRange&&this.tooltipMerge){var s=setInterval(function(){return e.handleOverlapTooltip()},16.7);setTimeout(function(){return window.clearInterval(s)},1e3*this.speed)}},moveStart:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments[2];if(this.disabledArray[e])return!1;if(this.stopPropagation&&t.stopPropagation(),this.isRange&&(this.currentSlider=e,i)){if(!this.processDragable)return!1;this.processFlag=!0,this.processSign={pos:this.position,start:this.getPos(t.targetTouches&&t.targetTouches[0]?t.targetTouches[0]:t)}}!i&&this.useKeyboard&&(this.focusFlag=!0,this.focusSlider=e),this.flag=!0,this.$emit("drag-start",this)},moving:function(t){if(this.stopPropagation&&t.stopPropagation(),!this.flag)return!1;t.preventDefault(),t.targetTouches&&t.targetTouches[0]&&(t=t.targetTouches[0]),this.processFlag?(this.currentSlider=0,this.setValueOnPos(this.processSign.pos[0]+this.getPos(t)-this.processSign.start,!0),this.currentSlider=1,this.setValueOnPos(this.processSign.pos[1]+this.getPos(t)-this.processSign.start,!0)):this.setValueOnPos(this.getPos(t),!0),this.isRange&&this.tooltipMerge&&this.handleOverlapTooltip()},moveEnd:function(t){var e=this;if(this.stopPropagation&&t.stopPropagation(),!this.flag)return!1;this.$emit("drag-end",this),this.lazy&&this.isDiff(this.val,this.value)&&this.syncValue(),this.flag=!1,window.setTimeout(function(){e.processFlag=!1},0),this.setPosition()},setValueOnPos:function(t,e){var i=this.isRange?this.limit[this.currentSlider]:this.limit,s=this.isRange?this.valueLimit[this.currentSlider]:this.valueLimit;if(t>=i[0]&&t<=i[1]){this.setTransform(t);var r=this.getValueByIndex(Math.round(t/this.gap));this.setCurrentValue(r,e),this.isRange&&this.fixed&&(this.setTransform(t+this.fixedValue*this.gap*(0===this.currentSlider?1:-1),!0),this.setCurrentValue((r*this.multiple+this.fixedValue*this.spacing*this.multiple*(0===this.currentSlider?1:-1))/this.multiple,e,!0))}else tthis.maximum)return!1;this.isRange?this.isDiff(this.currentValue[s],t)&&(this.currentValue.splice(s,1,t),this.lazy&&this.flag||this.syncValue()):this.isDiff(this.currentValue,t)&&(this.currentValue=t,this.lazy&&this.flag||this.syncValue()),e||this.setPosition()},getValueByIndex:function(t){return(this.spacing*this.multiple*t+this.minimum*this.multiple)/this.multiple},getIndexByValue:function(t){return Math.round((t-this.minimum)*this.multiple)/(this.spacing*this.multiple)},setIndex:function(t){if(Array.isArray(t)&&this.isRange){var e=void 0;e=this.data?[this.data[t[0]],this.data[t[1]]]:[this.getValueByIndex(t[0]),this.getValueByIndex(t[1])],this.setValue(e)}else t=this.getValueByIndex(t),this.isRange&&(this.currentSlider=t>(this.currentValue[1]-this.currentValue[0])/2+this.currentValue[0]?1:0),this.setCurrentValue(t)},setValue:function(t,e,i){var s=this;if(this.isDiff(this.val,t)){var r=this.limitValue(t);this.val=this.isRange?r.concat():r,this.computedFixedValue(),this.syncValue(e)}this.$nextTick(function(){return s.setPosition(i)})},computedFixedValue:function(){if(!this.fixed)return this.fixedValue=0,!1;this.fixedValue=this.currentIndex[1]-this.currentIndex[0]},setPosition:function(t){this.flag||this.setTransitionTime(void 0===t?this.speed:t),this.isRange?(this.setTransform(this.position[0],1===this.currentSlider),this.setTransform(this.position[1],0===this.currentSlider)):this.setTransform(this.position),this.flag||this.setTransitionTime(0)},setTransform:function(t,e){var i=e?this.idleSlider:this.currentSlider,r=s(("vertical"===this.direction?this.dotHeightVal/2-t:t-this.dotWidthVal/2)*(this.reverse?-1:1)),o="vertical"===this.direction?"translateY("+r+"px)":"translateX("+r+"px)",n=this.fixed?this.fixedValue*this.gap+"px":(0===i?this.position[1]-t:t-this.position[0])+"px",l=this.fixed?(0===i?t:t-this.fixedValue*this.gap)+"px":(0===i?t:this.position[0])+"px";this.isRange?(this.slider[i].style.transform=o,this.slider[i].style.WebkitTransform=o,this.slider[i].style.msTransform=o,"vertical"===this.direction?(this.$refs.process.style.height=n,this.$refs.process.style[this.reverse?"top":"bottom"]=l):(this.$refs.process.style.width=n,this.$refs.process.style[this.reverse?"right":"left"]=l)):(this.slider.style.transform=o,this.slider.style.WebkitTransform=o,this.slider.style.msTransform=o,"vertical"===this.direction?(this.$refs.process.style.height=t+"px",this.$refs.process.style[this.reverse?"top":"bottom"]=0):(this.$refs.process.style.width=t+"px",this.$refs.process.style[this.reverse?"right":"left"]=0))},setTransitionTime:function(t){if(t||this.$refs.process.offsetWidth,this.isRange){for(var e=0;ee.max?(e.printError("The value of the slider is "+t+", the maximum value is "+e.max+", the value of this slider can not be greater than the maximum value"),e.max):i};return this.isRange?t.map(function(t){return i(t)}):i(t)},syncValue:function(t){var e=this.isRange?this.val.concat():this.val;this.$emit("input",e),this.keydownFlag&&this.$emit("on-keypress",e),t||this.$emit("callback",e)},getValue:function(){return this.val},getIndex:function(){return this.currentIndex},getStaticData:function(){this.$refs.elem&&(this.size="vertical"===this.direction?this.$refs.elem.offsetHeight:this.$refs.elem.offsetWidth,this.offset="vertical"===this.direction?this.$refs.elem.getBoundingClientRect().top+window.pageYOffset||document.documentElement.scrollTop:this.$refs.elem.getBoundingClientRect().left)},refresh:function(){this.$refs.elem&&(this.getStaticData(),this.computedFixedValue(),this.setPosition())},printError:function(t){this.debug&&console.error("[VueSlider error]: "+t)},handleOverlapTooltip:function(){var t=this.tooltipDirection[0]===this.tooltipDirection[1];if(this.isRange&&t){var e=this.reverse?this.$refs.tooltip1:this.$refs.tooltip0,i=this.reverse?this.$refs.tooltip0:this.$refs.tooltip1,s=e.getBoundingClientRect().right,r=i.getBoundingClientRect().left,o=e.getBoundingClientRect().y,n=i.getBoundingClientRect().y+i.getBoundingClientRect().height,l="horizontal"===this.direction&&s>r,a="vertical"===this.direction&&n>o;l||a?this.handleDisplayMergedTooltip(!0):this.handleDisplayMergedTooltip(!1)}},handleDisplayMergedTooltip:function(t){var e=this.$refs.tooltip0,i=this.$refs.tooltip1,s=this.$refs.process.getElementsByClassName("vue-merged-tooltip")[0];t?(e.style.visibility="hidden",i.style.visibility="hidden",s.style.visibility="visible"):(e.style.visibility="visible",i.style.visibility="visible",s.style.visibility="hidden")}},mounted:function(){var t=this;if(this.isComponentExists=!0,"undefined"==typeof window||"undefined"==typeof document)return this.printError("window or document is undefined, can not be initialization.");this.$nextTick(function(){t.isComponentExists&&(t.getStaticData(),t.setValue(t.limitValue(t.value),!0,t.startAnimation?t.speed:0),t.bindEvents())}),this.isMounted=!0},beforeDestroy:function(){this.isComponentExists=!1,this.unbindEvents()}}},function(t,e,i){"use strict";var s=i(0);t.exports=s},function(t,e,i){e=t.exports=i(4)(),e.push([t.i,'.vue-slider-component{position:relative;box-sizing:border-box;-ms-user-select:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-o-user-select:none}.vue-slider-component.vue-slider-disabled{opacity:.5;cursor:not-allowed}.vue-slider-component.vue-slider-has-label{margin-bottom:15px}.vue-slider-component.vue-slider-disabled .vue-slider-dot{cursor:not-allowed}.vue-slider-component .vue-slider{position:relative;display:block;border-radius:15px;background-color:#ccc}.vue-slider-component .vue-slider:after{content:"";position:absolute;left:0;top:0;width:100%;height:100%;z-index:2}.vue-slider-component .vue-slider-process{position:absolute;border-radius:15px;background-color:#3498db;transition:all 0s;z-index:1}.vue-slider-component .vue-slider-process.vue-slider-process-dragable{cursor:pointer;z-index:3}.vue-slider-component.vue-slider-horizontal .vue-slider-process{width:0;height:100%;top:0;left:0;will-change:width}.vue-slider-component.vue-slider-vertical .vue-slider-process{width:100%;height:0;bottom:0;left:0;will-change:height}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-process{width:0;height:100%;top:0;right:0}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-process{width:100%;height:0;top:0;left:0}.vue-slider-component .vue-slider-dot{position:absolute;border-radius:50%;background-color:#fff;box-shadow:.5px .5px 2px 1px rgba(0,0,0,.32);transition:all 0s;will-change:transform;cursor:pointer;z-index:5}.vue-slider-component .vue-slider-dot.vue-slider-dot-focus{box-shadow:0 0 2px 1px #3498db}.vue-slider-component .vue-slider-dot.vue-slider-dot-dragging{z-index:5}.vue-slider-component .vue-slider-dot.vue-slider-dot-disabled{z-index:4}.vue-slider-component.vue-slider-horizontal .vue-slider-dot{left:0}.vue-slider-component.vue-slider-vertical .vue-slider-dot{bottom:0}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-dot{right:0}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-dot{top:0}.vue-slider-component .vue-slider-tooltip-wrap{display:none;position:absolute;z-index:9}.vue-slider-component .vue-slider-tooltip{display:block;font-size:14px;white-space:nowrap;padding:2px 5px;min-width:20px;text-align:center;color:#fff;border-radius:5px;border:1px solid #3498db;background-color:#3498db}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-top{top:-9px;left:50%;transform:translate(-50%,-100%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-bottom{bottom:-9px;left:50%;transform:translate(-50%,100%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-left{top:50%;left:-9px;transform:translate(-100%,-50%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-right{top:50%;right:-9px;transform:translate(100%,-50%)}.vue-slider-component .vue-slider-tooltip-top .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-top .vue-slider-tooltip:before{content:"";position:absolute;bottom:-10px;left:50%;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-top-color:inherit;transform:translate(-50%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-merged-tooltip{display:block;visibility:hidden}.vue-slider-component .vue-slider-tooltip-bottom .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-bottom .vue-slider-tooltip:before{content:"";position:absolute;top:-10px;left:50%;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-bottom-color:inherit;transform:translate(-50%)}.vue-slider-component .vue-slider-tooltip-left .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-left .vue-slider-tooltip:before{content:"";position:absolute;top:50%;right:-10px;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-left-color:inherit;transform:translateY(-50%)}.vue-slider-component .vue-slider-tooltip-right .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-right .vue-slider-tooltip:before{content:"";position:absolute;top:50%;left:-10px;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-right-color:inherit;transform:translateY(-50%)}.vue-slider-component .vue-slider-dot.vue-slider-hover:hover .vue-slider-tooltip-wrap{display:block}.vue-slider-component .vue-slider-dot.vue-slider-always .vue-slider-tooltip-wrap{display:block!important}.vue-slider-component .vue-slider-piecewise{position:absolute;width:100%;padding:0;margin:0;left:0;top:0;height:100%;list-style:none}.vue-slider-component .vue-slider-piecewise-item{position:absolute;width:8px;height:8px}.vue-slider-component .vue-slider-piecewise-dot{position:absolute;left:50%;top:50%;width:100%;height:100%;display:inline-block;background-color:rgba(0,0,0,.16);border-radius:50%;transform:translate(-50%,-50%);z-index:2;transition:all .3s}.vue-slider-component .vue-slider-piecewise-item:first-child .vue-slider-piecewise-dot,.vue-slider-component .vue-slider-piecewise-item:last-child .vue-slider-piecewise-dot{visibility:hidden}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-piecewise-label,.vue-slider-component.vue-slider-horizontal .vue-slider-piecewise-label{position:absolute;display:inline-block;top:100%;left:50%;white-space:nowrap;font-size:12px;color:#333;transform:translate(-50%,8px);visibility:visible}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-piecewise-label,.vue-slider-component.vue-slider-vertical .vue-slider-piecewise-label{position:absolute;display:inline-block;top:50%;left:100%;white-space:nowrap;font-size:12px;color:#333;transform:translate(8px,-50%);visibility:visible}.vue-slider-component .vue-slider-sr-only{clip:rect(1px,1px,1px,1px);height:1px;width:1px;overflow:hidden;position:absolute!important}',""])},function(t,e){t.exports=function(){var t=[];return t.toString=function(){for(var t=[],e=0;ei.parts.length&&(s.parts.length=i.parts.length)}else{for(var n=[],r=0;r-1&&i>-1&&(this.currentValue=[e,i])}else{var s=this.data.indexOf(t);s>-1&&(this.currentValue=s)}else this.currentValue=t}},currentIndex:function(){return this.isRange?this.data?this.currentValue:[this.getIndexByValue(this.currentValue[0]),this.getIndexByValue(this.currentValue[1])]:this.getIndexByValue(this.currentValue)},indexRange:function(){return this.isRange?this.currentIndex:[0,this.currentIndex]},maximum:function(){return this.data?this.data.length-1:this.max},multiple:function(){var t=(""+this.interval).split(".")[1];return t?Math.pow(10,t.length):1},spacing:function(){return this.data?1:this.interval},total:function(){return this.data?this.data.length-1:(Math.floor((this.maximum-this.minimum)*this.multiple)%(this.interval*this.multiple)!=0&&this.printError("Prop[interval] is illegal, Please make sure that the interval can be divisible"),(this.maximum-this.minimum)/this.interval)},gap:function(){return this.size/this.total},position:function(){return this.isRange?[(this.currentValue[0]-this.minimum)/this.spacing*this.gap,(this.currentValue[1]-this.minimum)/this.spacing*this.gap]:(this.currentValue-this.minimum)/this.spacing*this.gap},limit:function(){return this.isRange?this.fixed?[[0,(this.total-this.fixedValue)*this.gap],[this.fixedValue*this.gap,this.size]]:[[0,this.position[1]],[this.position[0],this.size]]:[0,this.size]},valueLimit:function(){return this.isRange?this.fixed?[[this.minimum,this.maximum-this.fixedValue*(this.spacing*this.multiple)/this.multiple],[this.minimum+this.fixedValue*(this.spacing*this.multiple)/this.multiple,this.maximum]]:[[this.minimum,this.currentValue[1]],[this.currentValue[0],this.maximum]]:[this.minimum,this.maximum]},idleSlider:function(){return 0===this.currentSlider?1:0},wrapStyles:function(){return"vertical"===this.direction?{height:"number"==typeof this.height?this.height+"px":this.height,padding:this.dotHeightVal/2+"px "+this.dotWidthVal/2+"px"}:{width:"number"==typeof this.width?this.width+"px":this.width,padding:this.dotHeightVal/2+"px "+this.dotWidthVal/2+"px"}},sliderStyles:function(){return Array.isArray(this.sliderStyle)?this.isRange?this.sliderStyle:this.sliderStyle[1]:"function"==typeof this.sliderStyle?this.sliderStyle(this.val,this.currentIndex):this.isRange?[this.sliderStyle,this.sliderStyle]:this.sliderStyle},focusStyles:function(){return Array.isArray(this.focusStyle)?this.isRange?this.focusStyle:this.focusStyle[1]:"function"==typeof this.focusStyle?this.focusStyle(this.val,this.currentIndex):this.isRange?[this.focusStyle,this.focusStyle]:this.focusStyle},disabledDotStyles:function(){var t=this.disabledDotStyle;if(Array.isArray(t))return t;if("function"==typeof t){var e=t(this.val,this.currentIndex);return Array.isArray(e)?e:[e,e]}return t?[t,t]:[{backgroundColor:"#ccc"},{backgroundColor:"#ccc"}]},tooltipStyles:function(){return Array.isArray(this.tooltipStyle)?this.isRange?this.tooltipStyle:this.tooltipStyle[1]:"function"==typeof this.tooltipStyle?this.tooltipStyle(this.val,this.currentIndex):this.isRange?[this.tooltipStyle,this.tooltipStyle]:this.tooltipStyle},elemStyles:function(){return"vertical"===this.direction?{width:this.width+"px",height:"100%"}:{height:this.height+"px"}},dotStyles:function(){return"vertical"===this.direction?{width:this.dotWidthVal+"px",height:this.dotHeightVal+"px",left:-(this.dotWidthVal-this.width)/2+"px"}:{width:this.dotWidthVal+"px",height:this.dotHeightVal+"px",top:-(this.dotHeightVal-this.height)/2+"px"}},piecewiseDotStyle:function(){return"vertical"===this.direction?{width:this.width+"px",height:this.width+"px"}:{width:this.height+"px",height:this.height+"px"}},piecewiseDotWrap:function(){if(!this.piecewise&&!this.piecewiseLabel)return!1;for(var t=[],e=0;e<=this.total;e++){var i="vertical"===this.direction?{bottom:this.gap*e-this.width/2+"px",left:0}:{left:this.gap*e-this.height/2+"px",top:0},s=this.reverse?this.total-e:e,r=this.data?this.data[s]:this.spacing*s+this.min;t.push({style:i,label:this.formatter?this.formatting(r):r,inRange:s>=this.indexRange[0]&&s<=this.indexRange[1]})}return t}},watch:{value:function(t){this.flag||this.setValue(t,!0)},max:function(t){if(tthis.max)return this.printError("The minimum value can not be greater than the maximum value.");var e=this.limitValue(this.val);this.setValue(e),this.refresh()},show:function(t){var e=this;t&&!this.size&&this.$nextTick(function(){e.refresh()})},fixed:function(){this.computedFixedValue()}},methods:{bindEvents:function(){document.addEventListener("touchmove",this.moving,{passive:!1}),document.addEventListener("touchend",this.moveEnd,{passive:!1}),document.addEventListener("mousedown",this.blurSlider),document.addEventListener("mousemove",this.moving),document.addEventListener("mouseup",this.moveEnd),document.addEventListener("mouseleave",this.moveEnd),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("keyup",this.handleKeyup),window.addEventListener("resize",this.refresh),this.isRange&&this.tooltipMerge&&(this.$refs.dot0.addEventListener("transitionend",this.handleOverlapTooltip),this.$refs.dot1.addEventListener("transitionend",this.handleOverlapTooltip))},unbindEvents:function(){document.removeEventListener("touchmove",this.moving),document.removeEventListener("touchend",this.moveEnd),document.removeEventListener("mousedown",this.blurSlider),document.removeEventListener("mousemove",this.moving),document.removeEventListener("mouseup",this.moveEnd),document.removeEventListener("mouseleave",this.moveEnd),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("keyup",this.handleKeyup),window.removeEventListener("resize",this.refresh),this.isRange&&this.tooltipMerge&&(this.$refs.dot0.removeEventListener("transitionend",this.handleOverlapTooltip),this.$refs.dot1.removeEventListener("transitionend",this.handleOverlapTooltip))},handleKeydown:function(t){if(!this.useKeyboard||!this.focusFlag)return!1;switch(t.keyCode){case 37:case 40:t.preventDefault(),this.keydownFlag=!0,this.flag=!0,this.changeFocusSlider(this.actionsKeyboard[0]);break;case 38:case 39:t.preventDefault(),this.keydownFlag=!0,this.flag=!0,this.changeFocusSlider(this.actionsKeyboard[1])}},handleKeyup:function(){this.keydownFlag&&(this.keydownFlag=!1,this.flag=!1)},changeFocusSlider:function(t){var e=this;if(this.isRange){var i=this.currentIndex.map(function(i,s){if(s===e.focusSlider||e.fixed){var r=t(i),o=e.fixed?e.valueLimit[s]:[0,e.total];if(r<=o[1]&&r>=o[0])return r}return i});i[0]>i[1]&&(this.focusSlider=0===this.focusSlider?1:0,i=i.reverse()),this.setIndex(i)}else this.setIndex(t(this.currentIndex))},blurSlider:function(t){var e=this.isRange?this.$refs["dot"+this.focusSlider]:this.$refs.dot;if(!e||e===t.target)return!1;this.focusFlag=!1},formatting:function(t){return"string"==typeof this.formatter?this.formatter.replace(/\{value\}/,t):this.formatter(t)},mergeFormatting:function(t,e){return"string"==typeof this.mergeFormatter?this.mergeFormatter.replace(/\{(value1|value2)\}/g,function(i,s){return"value1"===s?t:e}):this.mergeFormatter(t,e)},getPos:function(t){return this.realTime&&this.getStaticData(),"vertical"===this.direction?this.reverse?t.pageY-this.offset:this.size-(t.pageY-this.offset):this.reverse?this.size-(t.clientX-this.offset):t.clientX-this.offset},processClick:function(t){this.fixed&&t.stopPropagation()},wrapClick:function(t){var e=this;if(this.isDisabled||!this.clickable||this.processFlag)return!1;var i=this.getPos(t);if(this.isRange)if(this.disabledArray.every(function(t){return!1===t}))this.currentSlider=i>(this.position[1]-this.position[0])/2+this.position[0]?1:0;else if(this.disabledArray[0]){if(ithis.position[1])return!1;this.currentSlider=0}if(this.disabledArray[this.currentSlider])return!1;if(this.setValueOnPos(i),this.isRange&&this.tooltipMerge){var s=setInterval(function(){return e.handleOverlapTooltip()},16.7);setTimeout(function(){return window.clearInterval(s)},1e3*this.speed)}},moveStart:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments[2];if(this.disabledArray[e])return!1;if(this.stopPropagation&&t.stopPropagation(),this.isRange&&(this.currentSlider=e,i)){if(!this.processDragable)return!1;this.processFlag=!0,this.processSign={pos:this.position,start:this.getPos(t.targetTouches&&t.targetTouches[0]?t.targetTouches[0]:t)}}!i&&this.useKeyboard&&(this.focusFlag=!0,this.focusSlider=e),this.flag=!0,this.$emit("drag-start",this)},moving:function(t){if(this.stopPropagation&&t.stopPropagation(),!this.flag)return!1;t.preventDefault(),t.targetTouches&&t.targetTouches[0]&&(t=t.targetTouches[0]),this.processFlag?(this.currentSlider=0,this.setValueOnPos(this.processSign.pos[0]+this.getPos(t)-this.processSign.start,!0),this.currentSlider=1,this.setValueOnPos(this.processSign.pos[1]+this.getPos(t)-this.processSign.start,!0)):this.setValueOnPos(this.getPos(t),!0),this.isRange&&this.tooltipMerge&&this.handleOverlapTooltip()},moveEnd:function(t){var e=this;if(this.stopPropagation&&t.stopPropagation(),!this.flag)return!1;this.$emit("drag-end",this),this.lazy&&this.isDiff(this.val,this.value)&&this.syncValue(),this.flag=!1,window.setTimeout(function(){e.processFlag=!1},0),this.setPosition()},setValueOnPos:function(t,e){var i=this.isRange?this.limit[this.currentSlider]:this.limit,s=this.isRange?this.valueLimit[this.currentSlider]:this.valueLimit;if(t>=i[0]&&t<=i[1]){this.setTransform(t);var r=this.getValueByIndex(Math.round(t/this.gap));this.setCurrentValue(r,e),this.isRange&&this.fixed&&(this.setTransform(t+this.fixedValue*this.gap*(0===this.currentSlider?1:-1),!0),this.setCurrentValue((r*this.multiple+this.fixedValue*this.spacing*this.multiple*(0===this.currentSlider?1:-1))/this.multiple,e,!0))}else tthis.maximum)return!1;this.isRange?this.isDiff(this.currentValue[s],t)&&(this.currentValue.splice(s,1,t),this.lazy&&this.flag||this.syncValue()):this.isDiff(this.currentValue,t)&&(this.currentValue=t,this.lazy&&this.flag||this.syncValue()),e||this.setPosition()},getValueByIndex:function(t){return(this.spacing*this.multiple*t+this.minimum*this.multiple)/this.multiple},getIndexByValue:function(t){return Math.round((t-this.minimum)*this.multiple)/(this.spacing*this.multiple)},setIndex:function(t){if(Array.isArray(t)&&this.isRange){var e=void 0;e=this.data?[this.data[t[0]],this.data[t[1]]]:[this.getValueByIndex(t[0]),this.getValueByIndex(t[1])],this.setValue(e)}else t=this.getValueByIndex(t),this.isRange&&(this.currentSlider=t>(this.currentValue[1]-this.currentValue[0])/2+this.currentValue[0]?1:0),this.setCurrentValue(t)},setValue:function(t,e,i){var s=this;if(this.isDiff(this.val,t)){var r=this.limitValue(t);this.val=this.isRange?r.concat():r,this.computedFixedValue(),this.syncValue(e)}this.$nextTick(function(){return s.setPosition(i)})},computedFixedValue:function(){if(!this.fixed)return this.fixedValue=0,!1;this.fixedValue=this.currentIndex[1]-this.currentIndex[0]},setPosition:function(t){this.flag||this.setTransitionTime(void 0===t?this.speed:t),this.isRange?(this.setTransform(this.position[0],1===this.currentSlider),this.setTransform(this.position[1],0===this.currentSlider)):this.setTransform(this.position),this.flag||this.setTransitionTime(0)},setTransform:function(t,e){var i=e?this.idleSlider:this.currentSlider,r=s(("vertical"===this.direction?this.dotHeightVal/2-t:t-this.dotWidthVal/2)*(this.reverse?-1:1)),o="vertical"===this.direction?"translateY("+r+"px)":"translateX("+r+"px)",n=this.fixed?this.fixedValue*this.gap+"px":(0===i?this.position[1]-t:t-this.position[0])+"px",l=this.fixed?(0===i?t:t-this.fixedValue*this.gap)+"px":(0===i?t:this.position[0])+"px";this.isRange?(this.slider[i].style.transform=o,this.slider[i].style.WebkitTransform=o,this.slider[i].style.msTransform=o,"vertical"===this.direction?(this.$refs.process.style.height=n,this.$refs.process.style[this.reverse?"top":"bottom"]=l):(this.$refs.process.style.width=n,this.$refs.process.style[this.reverse?"right":"left"]=l)):(this.slider.style.transform=o,this.slider.style.WebkitTransform=o,this.slider.style.msTransform=o,"vertical"===this.direction?(this.$refs.process.style.height=t+"px",this.$refs.process.style[this.reverse?"top":"bottom"]=0):(this.$refs.process.style.width=t+"px",this.$refs.process.style[this.reverse?"right":"left"]=0))},setTransitionTime:function(t){if(t||this.$refs.process.offsetWidth,this.isRange){for(var e=0;ee.max?(e.printError("The value of the slider is "+t+", the maximum value is "+e.max+", the value of this slider can not be greater than the maximum value"),e.max):i};return this.isRange?t.map(function(t){return i(t)}):i(t)},syncValue:function(t){var e=this.isRange?this.val.concat():this.val;this.$emit("input",e),t||this.$emit("callback",e)},getValue:function(){return this.val},getIndex:function(){return this.currentIndex},getStaticData:function(){this.$refs.elem&&(this.size="vertical"===this.direction?this.$refs.elem.offsetHeight:this.$refs.elem.offsetWidth,this.offset="vertical"===this.direction?this.$refs.elem.getBoundingClientRect().top+window.pageYOffset||document.documentElement.scrollTop:this.$refs.elem.getBoundingClientRect().left)},refresh:function(){this.$refs.elem&&(this.getStaticData(),this.computedFixedValue(),this.setPosition())},printError:function(t){this.debug&&console.error("[VueSlider error]: "+t)},handleOverlapTooltip:function(){var t=this.tooltipDirection[0]===this.tooltipDirection[1];if(this.isRange&&t){var e=this.reverse?this.$refs.tooltip1:this.$refs.tooltip0,i=this.reverse?this.$refs.tooltip0:this.$refs.tooltip1,s=e.getBoundingClientRect().right,r=i.getBoundingClientRect().left,o=e.getBoundingClientRect().y,n=i.getBoundingClientRect().y+i.getBoundingClientRect().height,l="horizontal"===this.direction&&s>r,a="vertical"===this.direction&&n>o;l||a?this.handleDisplayMergedTooltip(!0):this.handleDisplayMergedTooltip(!1)}},handleDisplayMergedTooltip:function(t){var e=this.$refs.tooltip0,i=this.$refs.tooltip1,s=this.$refs.process.getElementsByClassName("vue-merged-tooltip")[0];t?(e.style.visibility="hidden",i.style.visibility="hidden",s.style.visibility="visible"):(e.style.visibility="visible",i.style.visibility="visible",s.style.visibility="hidden")}},mounted:function(){var t=this;if(this.isComponentExists=!0,"undefined"==typeof window||"undefined"==typeof document)return this.printError("window or document is undefined, can not be initialization.");this.$nextTick(function(){t.isComponentExists&&(t.getStaticData(),t.setValue(t.limitValue(t.value),!0,0),t.bindEvents())}),this.isMounted=!0},beforeDestroy:function(){this.isComponentExists=!1,this.unbindEvents()}}},function(t,e,i){"use strict";var s=i(0);t.exports=s},function(t,e,i){e=t.exports=i(4)(),e.push([t.i,'.vue-slider-component{position:relative;box-sizing:border-box;-ms-user-select:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-o-user-select:none}.vue-slider-component.vue-slider-disabled{opacity:.5;cursor:not-allowed}.vue-slider-component.vue-slider-has-label{margin-bottom:15px}.vue-slider-component.vue-slider-disabled .vue-slider-dot{cursor:not-allowed}.vue-slider-component .vue-slider{position:relative;display:block;border-radius:15px;background-color:#ccc}.vue-slider-component .vue-slider:after{content:"";position:absolute;left:0;top:0;width:100%;height:100%;z-index:2}.vue-slider-component .vue-slider-process{position:absolute;border-radius:15px;background-color:#3498db;transition:all 0s;z-index:1}.vue-slider-component .vue-slider-process.vue-slider-process-dragable{cursor:pointer;z-index:3}.vue-slider-component.vue-slider-horizontal .vue-slider-process{width:0;height:100%;top:0;left:0;will-change:width}.vue-slider-component.vue-slider-vertical .vue-slider-process{width:100%;height:0;bottom:0;left:0;will-change:height}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-process{width:0;height:100%;top:0;right:0}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-process{width:100%;height:0;top:0;left:0}.vue-slider-component .vue-slider-dot{position:absolute;border-radius:50%;background-color:#fff;box-shadow:.5px .5px 2px 1px rgba(0,0,0,.32);transition:all 0s;will-change:transform;cursor:pointer;z-index:5}.vue-slider-component .vue-slider-dot.vue-slider-dot-focus{box-shadow:0 0 2px 1px #3498db}.vue-slider-component .vue-slider-dot.vue-slider-dot-dragging{z-index:5}.vue-slider-component .vue-slider-dot.vue-slider-dot-disabled{z-index:4}.vue-slider-component.vue-slider-horizontal .vue-slider-dot{left:0}.vue-slider-component.vue-slider-vertical .vue-slider-dot{bottom:0}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-dot{right:0}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-dot{top:0}.vue-slider-component .vue-slider-tooltip-wrap{display:none;position:absolute;z-index:9}.vue-slider-component .vue-slider-tooltip{display:block;font-size:14px;white-space:nowrap;padding:2px 5px;min-width:20px;text-align:center;color:#fff;border-radius:5px;border:1px solid #3498db;background-color:#3498db}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-top{top:-9px;left:50%;-webkit-transform:translate(-50%,-100%);transform:translate(-50%,-100%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-bottom{bottom:-9px;left:50%;-webkit-transform:translate(-50%,100%);transform:translate(-50%,100%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-left{top:50%;left:-9px;-webkit-transform:translate(-100%,-50%);transform:translate(-100%,-50%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-right{top:50%;right:-9px;-webkit-transform:translate(100%,-50%);transform:translate(100%,-50%)}.vue-slider-component .vue-slider-tooltip-top .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-top .vue-slider-tooltip:before{content:"";position:absolute;bottom:-10px;left:50%;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-top-color:inherit;-webkit-transform:translate(-50%);transform:translate(-50%)}.vue-slider-component .vue-slider-tooltip-wrap.vue-merged-tooltip{display:block;visibility:hidden}.vue-slider-component .vue-slider-tooltip-bottom .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-bottom .vue-slider-tooltip:before{content:"";position:absolute;top:-10px;left:50%;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-bottom-color:inherit;-webkit-transform:translate(-50%);transform:translate(-50%)}.vue-slider-component .vue-slider-tooltip-left .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-left .vue-slider-tooltip:before{content:"";position:absolute;top:50%;right:-10px;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-left-color:inherit;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.vue-slider-component .vue-slider-tooltip-right .vue-merged-tooltip .vue-slider-tooltip:before,.vue-slider-component .vue-slider-tooltip-wrap.vue-slider-tooltip-right .vue-slider-tooltip:before{content:"";position:absolute;top:50%;left:-10px;width:0;height:0;border:5px solid transparent;border:6px solid transparent\\0;border-right-color:inherit;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.vue-slider-component .vue-slider-dot.vue-slider-hover:hover .vue-slider-tooltip-wrap{display:block}.vue-slider-component .vue-slider-dot.vue-slider-always .vue-slider-tooltip-wrap{display:block!important}.vue-slider-component .vue-slider-piecewise{position:absolute;width:100%;padding:0;margin:0;left:0;top:0;height:100%;list-style:none}.vue-slider-component .vue-slider-piecewise-item{position:absolute;width:8px;height:8px}.vue-slider-component .vue-slider-piecewise-dot{position:absolute;left:50%;top:50%;width:100%;height:100%;display:inline-block;background-color:rgba(0,0,0,.16);border-radius:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:2;transition:all .3s}.vue-slider-component .vue-slider-piecewise-item:first-child .vue-slider-piecewise-dot,.vue-slider-component .vue-slider-piecewise-item:last-child .vue-slider-piecewise-dot{visibility:hidden}.vue-slider-component.vue-slider-horizontal-reverse .vue-slider-piecewise-label,.vue-slider-component.vue-slider-horizontal .vue-slider-piecewise-label{position:absolute;display:inline-block;top:100%;left:50%;white-space:nowrap;font-size:12px;color:#333;-webkit-transform:translate(-50%,8px);transform:translate(-50%,8px);visibility:visible}.vue-slider-component.vue-slider-vertical-reverse .vue-slider-piecewise-label,.vue-slider-component.vue-slider-vertical .vue-slider-piecewise-label{position:absolute;display:inline-block;top:50%;left:100%;white-space:nowrap;font-size:12px;color:#333;-webkit-transform:translate(8px,-50%);transform:translate(8px,-50%);visibility:visible}.vue-slider-component .vue-slider-sr-only{clip:rect(1px,1px,1px,1px);height:1px;width:1px;overflow:hidden;position:absolute!important}',""])},function(t,e){t.exports=function(){var t=[];return t.toString=function(){for(var t=[],e=0;ei.parts.length&&(s.parts.length=i.parts.length)}else{for(var n=[],r=0;r