Code Monkey home page Code Monkey logo

ember-cli-tooltipster's Introduction

This repository is no longer maintained. As a replacement check out: https://github.com/sir-dunxalot/ember-tooltips


Ember CLI Tooltipster

An Ember CLI add-on that wraps Tooltipster into an ember component. The component supports most of Tooltipster features.

DEMO

Installation

ember install ember-cli-tooltipster

Basic Usage

  {{#tool-tipster title="This is my tooltip message!"}} 
    Checkout my tooltip
  {{/tool-tipster}}

With options

  {{#tool-tipster 
     content="This is my tooltip message!" 
     triggerEvent="click" 
     side="right"
   }} 
   The tooltip is displayed on the right when you click it!
  {{/tool-tipster}}

Extending the component

You can also easily extend the component to modify it to your needs (e.g a button component)

Just import TooltipsterComponent into your component and extend it

//components/my-button.js
import TooltipsterComponent from 'ember-cli-tooltipster/components/tool-tipster';

export default TooltipsterComponent.extend({
  tagName: 'button',

  classNames: ['my-awesome-button'],

  // define properties
  content: 'My awesome tooltip button',

  side: 'right',

  timer: 2000 // set the timer to automatically close after 2 seconds
});

Then in your template.

{{#my-button}} Tooltip Button {{/my-button}}

That's it, now your button will display a nice tooltip on the right that will automatically close after 2 seconds.

Themes

Besides the default theme four other themes are available that you can use for your tooltip.

By default the themes are not included when you install the addon.

To include the desired theme you need to set the corresponding setting in your build file.

//ember-cli-build.js

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    'ember-cli-tooltipster': {
      importTooltipsterPunk: true
    }
  });

  return app.toTree();
};

Available Settings

importTooltipsterBorderless:  false,
importTooltipsterLight:  false,
importTooltipsterNoir:   false,
importTooltipsterPunk:   false,
importTooltipsterShadow: false

Default/Bundled Styles

Unlike the themes above, the default base styles are included when you install the addon. To remove the base styles you need to set importTooltipsterDefaultStyles to false in your build file.

Available Options

When using the component, the following options are available:

animation

Type: string

Default: fade

Determines how the tooltip will animate in and out. In addition to the built-in transitions, you may also create custom transitions in your CSS files. In IE9 and lower, all animations default to a JavaScript generated, fade animation

Available Options: [fade, grow, swing, slide, fall]

animationDuration

Type: integer, integer[]

Default: 350

Sets the duration of the animation, in milliseconds. If you wish to provide different durations for the opening and closing animations, provide an array of two different values.

arrow

Type: boolean

Default: true

Adds the "speech bubble arrow" to the tooltip.

content

Type: String,jQuery object

Default: null

If set, this will override the content of the tooltip. If you provide something else than a string or jQuery-wrapped HTML element, you will need to use the 'functionFormat' option to format your content for display.

contentAsHTML

Type: boolean

Default: false

If the content of the tooltip is provided as a string, it is displayed as plain text by default. If this content should actually be interpreted as HTML, set this option to true.

contentCloning

Type: boolean

Default: false

If you provide a jQuery object to the 'content' option, this sets if it is a clone of this object that should actually be used.

debug

Type: boolean

Default: true

Tooltipster logs hints and notices into the console when you're doing something you ideally shouldn't be doing. Set to false to disable logging.

delay

Type: integer, integer[]

Default: 300

Upon mouse interaction, this is the delay before the tooltip starts its opening and closing animations when the 'hover' trigger is used. If you wish to specify different delays for opening and closing, you may provide an array of two different values.

delayTouch

Type: integer, integer[]

Default: [300, 500]

Upon touch interaction, this is the delay before the tooltip starts its opening and closing animations when the 'hover' trigger is used (*). If you wish to specify different delays for opening and closing, you may provide an array of two different values.

distance

Type: integer, integer[]

Default: 6

The distance between the origin and the tooltip, in pixels. The value may be an integer or an array of integers (in the usual CSS syntax) if you wish to specify a different distance for each side.

IEmin

Type: integer

Default: 6

The minimum version of Internet Explorer to run on.

interactive

Type: boolean

Default: false

Give users the possibility to interact with the content of the tooltip. If you want them to be able to make clicks, fill forms or do other interactions inside the tooltip, you have to set this option to true. When the 'hover' close trigger is used, the user has to move the cursor to the tooltip before it starts closing (this lapse of time has its duration set by the 'delay' option)

minWidth

Type: integer

Default: 0 (auto width)

Set a minimum width for the tooltip.

minIntersection

Type: integer

Default: 16

Corresponds to the minimum distance to enforce between the center of the arrow and the edges of the tooltip. Mainly used to create an arrow bigger than those of the default themes.

maxWidth

Type: integer

Default null (no max width)

Set a maximum width for the tooltip.

repositionOnScroll

Type: boolean

Default fale

Repositions the tooltip if it goes out of the viewport when the user scrolls the page, in order to keep it visible as long as possible.

restoration

Type: string

Default none

Specifies if a TITLE attribute should be restored on the HTML element after a call to the 'destroy' method. This attribute may be omitted, or be restored with the value that existed before Tooltipster was initialized, or be restored with the stringified value of the current content. Note: in case of multiple tooltips on a single element, only the last destroyed tooltip may trigger a restoration.

Available options: none, previous, current

selfDestruction

Type: boolean

Default true

Sets if the tooltip should self-destruct after a few seconds when its origin is removed from the DOM. This prevents memory leaks.

side

Type: string, string[]

Default: ['top', 'bottom', 'right', 'left']

Sets the side of the tooltip. The value may one of the following: 'top', 'bottom', 'left', 'right'. It may also be an array containing one or more of these values. When using an array, the order of values is taken into account as order of fallbacks and the absence of a side disables it

Available options: ['top', 'bottom', 'right', 'left']

timer

Type: integer

Default: 0 (disabled)

How long the tooltip should be allowed to live before hiding.

theme

Type: string,string[] (CSS class)

Default: empty array

Set a theme that will override the default tooltip appearance. You may provide an array of strings to apply several themes at once.

trackerInterval

Type: integer

Default: 500

Sets how often the tracker should run (see trackOrigin and trackTooltip), in milliseconds. The tracker runs even if trackOrigin and trackTooltip are false to check if the origin has not been removed while the tooltip was open, so you shouldn't set too high or too low values unless you need to.

trackOrigin

Type: boolean

Default: false

Repositions the tooltip if the origin moves or is resized. As this option may have an impact on performance, we suggest you enable it only if you need to.

trackTooltip

Type: boolean

Default: false

Repositions the tooltip if its size changes. When the size change results from a call to the 'content' method, the tooltip is already repositioned without the need to enable this option. As this option may have an impact on performance, we suggest you enable it only if you need to.

triggerEvent

Type: string

Default: hover

Sets when the tooltip should open and close. 'hover' and 'click' correspond to predefined sets of built-in triggers, while 'custom' lets you create your own, for a completely customized behavior.

Available options: hover, click, custom

triggerClose

Type: object

When 'trigger' is set to 'custom', all built-in close triggers are disabled by default. This option allows you to reactivate the triggers of your choice to create a customized behavior. Only applies if 'trigger' is set to 'custom'.

triggerOpen

Type: object

Similar to 'triggerClose'.

updateAnimation

Type: string

Default: rotate

Plays a subtle animation when the content of the tooltip is updated (if the tooltip is open). You may create custom animations in your CSS files. Set to null to disable the animation.

Available options: fade, rotate, scale, null

viewportAware

Type: boolean

Default: true

Tries to place the tooltip in such a way that it will be entirely visible on screen when it's opened. If the tooltip is to be opened while its origin is off screen (using a method call), you may want to set this option to false.

zIndex

Type: integer

Default: 9999999

Set the z-index of the tooltip.

Advanced Options

In order to use the advanced options you need to extend the component and implement the functions. For more information check the examples on Tooltipster Docs

functionInit

Type: function

Default: none(null)

A custom function to be fired only once at instantiation.

functionBefore

Type: function

Default: none(null)

A custom function to be fired before the tooltip is opened. This function may prevent the opening if it returns false.

functionReady

Type: function

Default: none(null)

A custom function to be fired when the tooltip and its contents have been added to the DOM.

functionAfter

Type: function

Default: none(null)

A custom function to be fired once the tooltip has been closed and removed from the DOM.

functionFormat

Type: function

Default: none(null)

A custom function that does not modify the content but that can format it for display. It gets the two first usual arguments and also the content as third argument. It must return the value that will be displayed in the tooltip, either a string or a jQuery-wrapped HTML element.

functionPosition

Type: function

Default: none(null)

A custom function fired when the tooltip is repositioned. It gives you the ability to slightly or completely modify the position that Tooltipster is about to give to the tooltip. It gets the proposed set of placement values as third argument. The function must return the set of placement values, which you may have edited.

ember-cli-tooltipster's People

Contributors

altrim avatar cibernox avatar eturino avatar ffaubry avatar johanrd avatar selvarajantonyraj avatar tennisonchan avatar toddsmithsalter avatar tylerturdenpants avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-tooltipster's Issues

Fastboot Compatibility

I have interest in fastboot compatibility. I've started working on it but get ReferenceError: jQuery is not defined when I serve the addon.

Upgrading from 0.0.11 to 0.1.0 throws a merge error

After upgrading from 0.0.11 to 0.1.0 and run ember server I get this error:

Merge error: file app/styles/app.scss exists in /tmp/broccoli_merge_trees-input_base_path-SblWTnuS.tmp/18 and /tmp/broccoli_merge_trees-input_base_path-SblWTnuS.tmp/28
Pass option { overwrite: true } to mergeTrees in order to have the latter file win.

I compared the 2 versions 3ce8815...811f764 and I think it is caused by @import 'ember-paper';. If I remove that from the add-on my ember app starts, but off course the add-on no longer works ;)

Any suggestions on how I can fix this error?

Using tooltipster with ember-i18n does not work correctly

I'm using ember-i18n and try to use tooltipster in my template as
{{#tool-tipster title="(t 'translation.key')"}}

This seems to work well and the tooltip shows me the correct text, but the console returns the following error:
Uncaught TypeError: e.clone is not a function

button onclick event / component event handlers?

Can we use this to replace a button component, setting an action that is handled by the component or route as usual?

It seems like this is getting swallowed when setting on a {{#tool-tipster and there are no examples in the docs of regular component actions / button usage.

tooltip not going away when selection made in 'select2' box

I have tooltips on boxes that are set up with ember-select-2.
When I select the content and it is in the box the tooltip does not go away.
I have the tooltip on top and move down to select content in box.
Is there a way to automatically set it to go away in a couple seconds? How do I fix this?

Thanks.

0.4.6 is broken because of missing ember-string-ishtmlsafe-polyfill dependency

ember-string-ishtmlsafe-polyfill should defined as a runtime dependency or should be listed as a prerequisite in the README.md.
Currently, it is listed in the package.json as a devDependency.
The result is that ember-cli-tooltipster is broking projects at runtime if these projects don't already have the ember-string-ishtmlsafe-polyfill as a dependency.
I will propose a PR for making ember-string-ishtmlsafe-polyfill a runtime dependency of ember-cli-tooltipster

Cannot read property 'trigger' of null

Hi,

I have a tooltip with a link like this :

{{#tool-tipster tagName='span' title=(t 'kohordeAdmin.forms.index.edit') theme="tooltipster-light" animation="grow" side="bottom"}}
  {{#link-to 'kohorde-admin.forms/edit' form class='edit'}}
    <i class="fa fa-pencil fa-lg" aria-hidden="true"></i>
  {{/link-to}} 
{{/tool-tipster}}

When I click on the link, I have Cannot read property 'trigger' of null. It produce the error at this line.

I think it do this because the the tooltip is not destroyed before the transition. When I scroll, I have Cannot read property 'attr' of null at this line.

Getting Merge Trees Error.

Getting the following error, I am using SASS also in my project, maybe that is why.

version: 2.4.2
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
The Broccoli Plugin: [BroccoliMergeTrees] failed with:
Error: Merge error: file app/styles/app.scss exists in /Users/jack/git/my-project/tmp/broccoli_merge_trees-input_base_path-baeLMgXN.tmp/23 and /Users/jack/git/my-project/tmp/broccoli_merge_trees-input_base_path-baeLMgXN.tmp/49

_onContentDidChange may execute after _destroyTooltipster, causing error

Hey,

I'm using the ember-cli-tooltipster on a live-updating graph that is constantly re-rendering in real time. As such, I'm continuously generating new tooltipsters on new components when new data comes in, and destroying the old tooltipsters as well.

As a consequence of this, I'm encountering a bug where the observer _onContentDidChange is being called after _destroyTooltipster in the small window between willDestroyElement and when it is actually destroyed. Thus, when _onContentDidChange is run, tooltipsterInstance has been set to null and the method breaks with TypeError: Cannot read property 'content' of null.

A quick solution to this that I am using locally is:

_onContentDidChange: observer('content', 'title', function() {
  run.scheduleOnce('afterRender', this, () => {
    let content = this.get('content') || this.get('title');
    if (content instanceof SafeString) {
      content = content.toString();
    }
    if (this.get('tooltipsterInstance') !== null) {
      this.get('tooltipsterInstance').content(content);
    }
  });
}),

By checking for null, it's not an issue anymore. However, I'm not sure if there's a better implementation you may have in mind, or if using a library like ember-concurrency would be the better solution.

What do you think? I've also submitted a PR with this quick fix just in case.

Thanks!

Regression of 'destroy' call

Hi. Thanks for recent updates.
In 0.0.11 you add check for presence of initialized tooltipster that fix my issues in component integration tests.

In commit b8ca9d you removed this check and my tests are failing again.

Does any particular reason to remove this check?
Thanks.

Tooltipster css import is breaking yarn workspace

I have yarn workspace under which an addon and an application and both of them depends on ember-cli-tooltipster.

So, yarn rolls up the ember-cli-tooltipster to the root(workspace) directory. But since ember-cli-tooltipster is using project.root, it is still trying to import the css from invalid directory.

This can be fixed by using relative path(require.resolve('tooltipster')).

I will submit a PR for same.

Contextual Interactive Content

Is it possible to pass contextual interactive content to Tooltipster?

For example, might you pass the yield of a block-level component to the content option?  Something like this (note: this doesn't work)… 

// foo.hbs

{{#interactive-tooltip
  title='This is my trigger'
}}
  <h6>This is my tooltip content.</h6>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
{{/interactive-tooltip}}
// interactive-tooltip.hbs

{{#tool-tipster
  content=yield
  interactive=true
  contentAsHTML=true
  triggerEvent='click'
}}
  {{title}}
{{/tool-tipster}}
 

Possibility of removing tooltipster as a bower dependency

Sometime ago, we moved to yarn as our deps manager, and migrated all our deps from bower to npm packages.

Tooltipster is also available as a npm package but ember-cli-tooltipster relies on tooltipster bower component (https://github.com/altrim/ember-cli-tooltipster/blob/master/index.js#L51) to work, what forces the use of bower.

Do you think there is any possibility that you remove this, so anybody could use the package manager of their choice (bower, npm, yarn, ... )?

Many thanks !!!

Title still shows up

I'm getting weirdness where the tooltip shows up, but so does the title tooltip.

screen shot 2015-07-16 at 9 59 01 am

Тooltip is not removed when the value is empty

Example:
component.js:

  tooltipContent: Ember.computed(
    'title',
    function () {
      if (this.get('title')) {
        return this.get('title');
      }
      return '';
    }
  ),

template.hbs

{{#tool-tipster content=tooltipContent}}
  item
{{/tool-tipster}}

step 1: title is not empty and tooltip shows title value
step 2: set the title empty value. The tooltip will remain old value, and it will be shown

Failing build on ember-cli 2.7.0

Tried upgrading to the latest version (from 0.1), and getting

route-recognizer#0.1.11 bower_components/route-recognizer
⠴ BuildingThe Broccoli Plugin: [SourceMapConcat: Concat: Vendor /assets/vendor.js] failed with:
Error: ENOENT: no such file or directory, stat '/Users/rot/workspace/src/opensource/v/backslash/webapp/tmp/source_map_concat-input_base_path-t4T7aSJH.tmp/0/bower_components/tooltipster/dist/js/tooltipster.bundle.min.js'
    at Error (native)
    at Object.fs.statSync (fs.js:892:18)
    at ConcatWithMaps.keyForFile (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-caching-writer/index.js:87:20)
    at Array.map (native)
    at ConcatWithMaps.CachingWriter._conditionalBuild (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-caching-writer/index.js:109:65)
    at /Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-caching-writer/node_modules/broccoli-plugin/read_compat.js:61:34
    at lib$rsvp$$internal$$tryCatch (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/rsvp/dist/rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/rsvp/dist/rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/rsvp/dist/rsvp.js:1198:9)

The broccoli plugin was instantiated at:
    at ConcatWithMaps.Plugin (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-caching-writer/node_modules/broccoli-plugin/index.js:10:31)
    at ConcatWithMaps.CachingWriter [as constructor] (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-caching-writer/index.js:18:10)
    at new ConcatWithMaps (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-concat/concat.js:24:17)
    at module.exports (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/broccoli-concat/index.js:26:10)
    at EmberApp.concatFiles (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/ember-cli/lib/broccoli/ember-app.js:368:10)
    at EmberApp._concatFiles (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/ember-cli/lib/broccoli/ember-app.js:381:15)
    at EmberApp.javascript (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/ember-cli/lib/broccoli/ember-app.js:1252:12)
    at EmberApp.toArray (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/ember-cli/lib/broccoli/ember-app.js:1604:10)
    at EmberApp.toTree (/Users/rot/workspace/src/opensource/v/backslash/webapp/node_modules/ember-cli/lib/broccoli/ember-app.js:1626:30)
    at module.exports (/Users/rot/workspace/src/opensource/v/backslash/webapp/ember-cli-build.js:54:26)

Fix breaking changes in FastBoot 1.0

The current ember-cli-fastboot releases (1.0.0-rc.1 and above) introduce breaking changes. These will most likely break your current FastBoot implementation.

See ember-fastboot/ember-cli-fastboot#387 for more information and a guide on how to fix your addon. Also you may want to visit the -fastboot Slack channel to get help from other users.

Note: this issue has been created automatically, by searching for certain patterns in your code. If you think this has been falsely created, feel free to close!

Support for Tooltipster plugins

Tooltipster doesn't support the ability to follow cursor positioning, as noted in #13. However, the plugin tooltipster-follower can add this functionality.

I'd like to be able to use Tooltipster plugins in my Ember Tooltipster Components.

Add a disabled option?

I am running into an issue where I want to have a tooltip using this addon only when a certain property is true or false.

Right now I am doing this by have an if else block and copying the wrapped component in both.

A better solution would be if this addon allowed passing in a property to control if the tooltip shows or not.

Disable native tooltip when using variable in handlebars

I want to pass a variable to the tooltip helper like this:

{{#info-tooltip title="Edit #[...] post" var=post.id}}{{post.title}}{{/info-tooltip}}

This is the component:

// components/info-tooltip.js
import TooltipsterComponent from 'ember-cli-tooltipster/components/tool-tipster';

var InfoTooltipComponent = TooltipsterComponent.extend({
  tagName: 'span',
  classNames: ['info-tooltip'],
  attributeBindings: ['customTitle:title'],
  customTitle: function() {
    return this.get('title').replace('[...]', this.get('var'));
  }.property('title', 'var')
});

export default InfoTooltipComponent;

It looks like this:
image

It looks like is does not support a variable in the helper because the double tooltip will not show up when I use it like this:

{{#info-tooltip title="Edit #[...] post"}}{{post.title}}{{/info-tooltip}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.