Bookmark Widget (v2.7) Selected Color

221
8
Jump to solution
03-14-2018 09:59 AM
JasonStanton__GISP
Occasional Contributor

I am trying to add a background color to the selected bookmark in the v2.7 widget.  In the v2.4 widget I added the following code to "common.css", but now this is not working.  

      .jimu-img-node.jimu-state-selected{

           background-color: #86b186;

      }

Does anyone have any ideas?

Jason

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

  In 2.7 Card style bookmarks there is no selected class that is added on click of a bookmark. You will have to add two css rules to the common.css and code to the CustomBookmarks.js and WebmapBookmarks.js files

Css rules:

.jimu-img-node.jimu-float-leading.clearFix.selected{
  padding-top: 5px;
  background-color: #86b186;
}

.jimu-img-node.jimu-float-leading.clearFix{
  padding-top: 5px;
}

WebmapBookmarks.js:

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, SpatialReference,
    BaseWidget, _TemplatedMixin, utils, query) {
....

      _onBookmarkClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
....

CustomBookmarks.js

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'dojo/sniff',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  './ItemNode',
  'jimu/dijit/ImageChooser',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, has,
    SpatialReference, BaseWidget, _TemplatedMixin, utils,
    ItemNode, ImageChooser, query) {
....
      _onNodeBoxClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
....

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

  In 2.7 Card style bookmarks there is no selected class that is added on click of a bookmark. You will have to add two css rules to the common.css and code to the CustomBookmarks.js and WebmapBookmarks.js files

Css rules:

.jimu-img-node.jimu-float-leading.clearFix.selected{
  padding-top: 5px;
  background-color: #86b186;
}

.jimu-img-node.jimu-float-leading.clearFix{
  padding-top: 5px;
}

WebmapBookmarks.js:

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, SpatialReference,
    BaseWidget, _TemplatedMixin, utils, query) {
....

      _onBookmarkClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
....

CustomBookmarks.js

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'dojo/sniff',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  './ItemNode',
  'jimu/dijit/ImageChooser',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, has,
    SpatialReference, BaseWidget, _TemplatedMixin, utils,
    ItemNode, ImageChooser, query) {
....
      _onNodeBoxClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
....
0 Kudos
JasonStanton__GISP
Occasional Contributor

Thanks for the help Robert!  I really appreciate it!

Jason

0 Kudos
JasonStanton__GISP
Occasional Contributor

Robert,

I just realized that how I added/replaced the code in CustomBookmarks.js and WebmapBookmarks.js caused the bookmark widget to not work.  I am adding 'dojo/query' under define and query after function.  I am not sure if I should be strictly adding the _onBookmarkClick and _onNodeBoxClick code (and if so where), or if I am replacing current code (and exactly what code I am replacing).  I tired a few variations which all failed.

Can you please help me?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

   You are just adding the dojo/query require to each file and then adding the new

        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');

code to the _onNodeBoxClick functions.

0 Kudos
JasonStanton__GISP
Occasional Contributor

I SWEAR I tried that, but I must not have been using my brain when I did.  It works fine now.  THANK YOU!

JasonStanton__GISP
Occasional Contributor

Robert,

Any idea how to update the 2.13 version to change the background color on the selected bookmark?

Jason

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

   Not much has changed they only added an additional module to the define array...

CustomBookmarks.js

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'dojo/sniff',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  './ItemNode',
  'jimu/dijit/ImageChooser',
  'libs/Sortable',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, has,
    SpatialReference, BaseWidget, _TemplatedMixin, utils,
    ItemNode, ImageChooser, Sortable, query) {
...
      _onNodeBoxClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
...

WebmapBookmarks.js

define([
  'dojo/Evented',
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/html',
  'dojo/_base/array',
  'dojo/on',
  'esri/SpatialReference',
  'jimu/BaseWidget',
  'dijit/_TemplatedMixin',
  './utils',
  'libs/Sortable',
  'dojo/query'
],
  function (Evented, declare, lang, html, array, on, SpatialReference,
    BaseWidget, _TemplatedMixin, utils, Sortable, query) {
...

      _onBookmarkClick: function (bookmark) {
        query('.jimu-img-node.jimu-float-leading.clearFix.selected').forEach(function (node) {
          html.removeClass(node, 'selected');
        });
        html.addClass(bookmark.itemNode.domNode, 'selected');
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
JasonStanton__GISP
Occasional Contributor

Thanks!  Not sure what I was doing wrong, but it works now!

0 Kudos