"wl"
Bootstrap 3.0.0 Snippet by irinashuvalova

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <link rel="stylesheet" href=""> </head> <body> <div class="wl-container"> <h1 class="wl-title js-wl-title">Title</h1> <div class="wl-add-container"> <input type="text" class="js-wish-title" placeholder="title" /> <input type="text" class="js-wish-price" placeholder="price" /> <button type="button" class="js-add-wish">Add</button> </div> <p class="wl-sum js-wl-sum">0</p> <ul class="wl js-wl"></ul> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.2/jquery.min.js"></script> <script src="wl.js"></script> </body> </html>
var app = function(wishList) { this.WishList = new WishList(wishList); } var WishListView = function(wishList) { this.wishList = wishList; } WishListView.prototype.init = function() { var that = this; $('.js-add-wish').on('click', function() { that.wishList.addWish(); that.render(); }) $('.js-wl').on('click', '.js-wish-remove', function() { var id = $(this).data('id'); that.wishList.removeWish(id); that.render(); }) } WishListView.prototype.render = function() { $('.js-wl-title').text(wishList.title); $('.js-wl').html(''); var elements = ''; this.wishList.list.map(function(key, index) { return elements += '<li>' + key.title + ' - ' + key.price + '<span class="js-wish-remove" data-id="' + key.id + '">' + '(remove)</span></li>'; }) $('.js-wl').html(elements); $('.js-wl-sum').html(this.wishList.getSum()); } var WishList = function(wishList, title) { this.list = wishList; this.title = title != undefined ? title :"default"; } function clearInput() { $('.js-wish-title').val(''); $('.js-wish-price').val(''); } WishList.prototype.getAll = function() { return this.list; } WishList.prototype.removeWish = function(wishID) { this.list = this.list.filter(function(item) { return item.id != wishID; }) } WishList.prototype.getSum = function() { var sum = 0; this.list.map(function (item) { return sum += parseInt(item.price); }); return sum; } WishList.prototype.addWish = function() { var wishTitle = $('.js-wish-title').val(); var wishPrice = $('.js-wish-price').val(); var wish = new Wish(wishTitle, wishPrice); this.list.push(wish); clearInput(); } WishList.prototype.setTitle = function(title) { this.title = title; } var Wish = function(title, price, id) { this.id = id || new Date().valueOf(); this.title = title; this.price = price; } var list = [ new Wish("a", 100, 1), new Wish("b", 200, 2), new Wish("c", 300, 3), ] var wishList = new WishList(list, "WL"); var wishListView = new WishListView(wishList); wishListView.init(); wishListView.render(); $('.js-newbie-position').dotdotdot({ wrap: 'word', ellipsis: '... ', height: 28, callback: function(isTruncated, orgContent) { if (isTruncated) { var parent = $(this).parent() var title = $(parent).data('position'); $(parent).attr('title', title); } } }) $('.js-newbie-department').dotdotdot({ wrap: 'word', ellipsis: '... ', height: 14 }) console.log($(item).parent().attr('title', )); var truncated = $('.c-newbie-informer').find('.is-truncated'); Array.prototype.map.call(truncated, function(item) { console.log($(item).parent()); var title = })

Related: See More


Questions / Comments: