Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
refactor(macTooltip): Namespaced tooltip class names to prevent style…
Browse files Browse the repository at this point in the history
… conflicts

BREAKING CHANGE
`tooltip` class has been renamed to `mac-tooltip`
  • Loading branch information
adrianlee44 committed May 22, 2014
1 parent 7d86a3e commit d0e4c23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/css/tooltip.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.tooltip
.mac-tooltip
background rgba(47,48,53,0.75)
text-align center
color #FFF
Expand Down
2 changes: 1 addition & 1 deletion src/directives/tooltip.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ angular.module("Mac").directive "macTooltip", [
## Check if the tooltip still exist, remove if it does
removeTip(0)

tooltip = angular.element """<div class="tooltip #{opts.direction}"><div class="tooltip-message">#{text}</div></div>"""
tooltip = angular.element """<div class="mac-tooltip #{opts.direction}"><div class="tooltip-message">#{text}</div></div>"""
tip.append tooltip

# Only get element offset when not adding tooltip within the element.
Expand Down
22 changes: 11 additions & 11 deletions test/unit/tooltip.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe "Mac Tooltip", ->
$timeout = _$timeout_

afterEach ->
$(".tooltip").remove()
$(".mac-tooltip").remove()

describe "Basic Initialization", ->

Expand All @@ -19,7 +19,7 @@ describe "Mac Tooltip", ->
$rootScope.$digest()
tip.trigger "mouseenter"

expect($(".tooltip").length).toBe 1
expect($(".mac-tooltip").length).toBe 1

it "should display the correct message", ->
tip = $compile("<div mac-tooltip='hello world'></div>") $rootScope
Expand All @@ -35,19 +35,19 @@ describe "Mac Tooltip", ->
$rootScope.$digest()
tip.trigger "mouseenter"

expect($(".tooltip").length).toBe 1
expect($(".mac-tooltip").length).toBe 1

tip.trigger "mouseleave"
$timeout.flush()

expect($(".tooltip").length).toBe 0
expect($(".mac-tooltip").length).toBe 0

it "should show and hide on click", ->
tip = $compile("<div mac-tooltip='test' mac-tooltip-trigger='click'></div>") $rootScope
$rootScope.$digest()
# show
tip.trigger "click"
expect($(".tooltip").length).toBe 1
expect($(".mac-tooltip").length).toBe 1

# hide
tip.trigger "click"
Expand All @@ -69,15 +69,15 @@ describe "Mac Tooltip", ->

tip.trigger "mouseenter"

expect($(".tooltip").hasClass "top").toBe true
expect($(".mac-tooltip").hasClass "top").toBe true

it "should set the direction to bottom", ->
tip = $compile("<div mac-tooltip='test' mac-tooltip-direction='bottom'></div>") $rootScope
$rootScope.$digest()

tip.trigger "mouseenter"

expect($(".tooltip").hasClass "bottom").toBe true
expect($(".mac-tooltip").hasClass "bottom").toBe true

describe "disabled", ->

Expand All @@ -86,14 +86,14 @@ describe "Mac Tooltip", ->
$rootScope.$digest()

tip.trigger "mouseenter"
expect($(".tooltip").length).toBe 0
expect($(".mac-tooltip").length).toBe 0

it "should create a tooltip", ->
tip = $compile("<div mac-tooltip='test' mac-tooltip-disabled='false'></div>") $rootScope
$rootScope.$digest()

tip.trigger "mouseenter"
expect($(".tooltip").length).toBe 1
expect($(".mac-tooltip").length).toBe 1

describe "Inside", ->

Expand All @@ -103,12 +103,12 @@ describe "Mac Tooltip", ->

tip.trigger "mouseenter"

expect($(".tooltip", tip).length).toBe 1
expect($(".mac-tooltip", tip).length).toBe 1

it "should not append tooltip inside of trigger", ->
tip = $compile("<div mac-tooltip='test'></div>") $rootScope
$rootScope.$digest()

tip.trigger "mouseenter"

expect($(".tooltip", tip).length).toBe 0
expect($(".mac-tooltip", tip).length).toBe 0

0 comments on commit d0e4c23

Please sign in to comment.