From b017edcaaa9d879b09777de4140714daf2d50a4f Mon Sep 17 00:00:00 2001 From: josdejong Date: Wed, 15 Jan 2014 11:49:39 +0100 Subject: [PATCH] Functions `select` and `unselect` on Items working --- NOTICE | 2 +- README.md | 2 +- docs/index.html | 2 +- src/timeline/component/css/item.css | 8 ++++++++ src/timeline/component/item/Item.js | 2 ++ src/timeline/component/item/ItemBox.js | 18 ------------------ src/timeline/component/item/ItemPoint.js | 18 ------------------ src/timeline/component/item/ItemRange.js | 21 ++------------------- 8 files changed, 15 insertions(+), 58 deletions(-) diff --git a/NOTICE b/NOTICE index f8f5cecc..b1a08849 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ Vis.js -Copyright 2010-2013 Almende B.V. +Copyright 2010-2014 Almende B.V. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index deaada66..b6b80643 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Then run the tests: ## License -Copyright (C) 2010-2013 Almende B.V. +Copyright (C) 2010-2014 Almende B.V. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docs/index.html b/docs/index.html index bbaf818b..0fcc85ca 100644 --- a/docs/index.html +++ b/docs/index.html @@ -179,7 +179,7 @@ var timeline = new vis.Timeline(container, data, options);

License

- Copyright (C) 2010-2013 Almende B.V. + Copyright (C) 2010-2014 Almende B.V.

diff --git a/src/timeline/component/css/item.css b/src/timeline/component/css/item.css index 579d1e5e..cc6cdccb 100644 --- a/src/timeline/component/css/item.css +++ b/src/timeline/component/css/item.css @@ -13,6 +13,14 @@ z-index: 999; } +.vis.timeline .item.point.selected { + background-color: #FFF785; + z-index: 999; +} +.vis.timeline .item.point.selected .dot { + border-color: #FFC200; +} + .vis.timeline .item.cluster { /* TODO: use another color or pattern? */ background: #97B0F8 url('img/cluster_bg.png'); diff --git a/src/timeline/component/item/Item.js b/src/timeline/component/item/Item.js index a706993f..590ee551 100644 --- a/src/timeline/component/item/Item.js +++ b/src/timeline/component/item/Item.js @@ -27,6 +27,7 @@ function Item (parent, data, options, defaultOptions) { */ Item.prototype.select = function select() { this.selected = true; + if (this.visible) this.repaint(); }; /** @@ -34,6 +35,7 @@ Item.prototype.select = function select() { */ Item.prototype.unselect = function unselect() { this.selected = false; + if (this.visible) this.repaint(); }; /** diff --git a/src/timeline/component/item/ItemBox.js b/src/timeline/component/item/ItemBox.js index 4ad671c6..15f9c6ed 100644 --- a/src/timeline/component/item/ItemBox.js +++ b/src/timeline/component/item/ItemBox.js @@ -29,24 +29,6 @@ function ItemBox (parent, data, options, defaultOptions) { ItemBox.prototype = new Item (null, null); -/** - * Select the item - * @override - */ -ItemBox.prototype.select = function select() { - this.selected = true; - // TODO: select and unselect -}; - -/** - * Unselect the item - * @override - */ -ItemBox.prototype.unselect = function unselect() { - this.selected = false; - // TODO: select and unselect -}; - /** * Repaint the item * @return {Boolean} changed diff --git a/src/timeline/component/item/ItemPoint.js b/src/timeline/component/item/ItemPoint.js index 1d0d7ce7..f42d6322 100644 --- a/src/timeline/component/item/ItemPoint.js +++ b/src/timeline/component/item/ItemPoint.js @@ -26,24 +26,6 @@ function ItemPoint (parent, data, options, defaultOptions) { ItemPoint.prototype = new Item (null, null); -/** - * Select the item - * @override - */ -ItemPoint.prototype.select = function select() { - this.selected = true; - // TODO: select and unselect -}; - -/** - * Unselect the item - * @override - */ -ItemPoint.prototype.unselect = function unselect() { - this.selected = false; - // TODO: select and unselect -}; - /** * Repaint the item * @return {Boolean} changed diff --git a/src/timeline/component/item/ItemRange.js b/src/timeline/component/item/ItemRange.js index 50c800c3..92774683 100644 --- a/src/timeline/component/item/ItemRange.js +++ b/src/timeline/component/item/ItemRange.js @@ -21,24 +21,6 @@ function ItemRange (parent, data, options, defaultOptions) { ItemRange.prototype = new Item (null, null); -/** - * Select the item - * @override - */ -ItemRange.prototype.select = function select() { - this.selected = true; - // TODO: select and unselect -}; - -/** - * Unselect the item - * @override - */ -ItemRange.prototype.unselect = function unselect() { - this.selected = false; - // TODO: select and unselect -}; - /** * Repaint the item * @return {Boolean} changed @@ -86,7 +68,8 @@ ItemRange.prototype.repaint = function repaint() { } // update class - var className = this.data.className ? (' ' + this.data.className) : ''; + var className = (this.data.className? ' ' + this.data.className : '') + + (this.selected ? ' selected' : ''); if (this.className != className) { this.className = className; dom.box.className = 'item range' + className;