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

Commit

Permalink
refactor(macModal): Updated mac-modal service to work with jqLite
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlee44 committed Sep 15, 2013
1 parent 3794efb commit e3dc31d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/services/modal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ angular.module("Mac").service("modal", [
viewScope = $rootScope.$new()
viewScope.modal = this
viewScope.closeOverlay = ($event) =>
if options.overlayClose and angular.element($event.target).hasClass("modal-overlay")
if options.overlayClose and
angular.element($event.target).hasClass("modal-overlay")
@hide()

if options.controller
Expand All @@ -103,8 +104,9 @@ angular.module("Mac").service("modal", [

angular.extend options.attributes, {id}
element = angular.element(@modalTemplate).attr options.attributes
angular.element(".modal-content-wrapper", element).html template
angular.element("body").append $compile(element) viewScope
wrapper = angular.element element[0].getElementsByClassName("modal-content-wrapper")
wrapper.html template
angular.element(document.body).append $compile(element) viewScope

showModal element

Expand Down Expand Up @@ -140,18 +142,21 @@ angular.module("Mac").service("modal", [
element = modalObject.element
options = modalObject.options

modal = $(".modal", element).attr "style", ""
modal = angular.element(element[0].getElementsByClassName "modal").attr "style", ""
height = modal.outerHeight()
width = modal.outerWidth()

css =
if $(window).height() > height
if angular.element(window).height() > height
marginTop: -height / 2
else
top: options.topOffset
css.marginLeft = -width / 2

modal.css css
angular.forEach css, (value, key) ->
if not isNaN(+value) and angular.isNumber +value
value = "#{value}px"
modal.css key, value

#
# @name hide
Expand Down Expand Up @@ -189,10 +194,10 @@ angular.module("Mac").service("modal", [
options = @opened.options

if options.keyboard
$(document)[action] "keydown", escapeKeyHandler
angular.element(document)[action] "keydown", escapeKeyHandler

if options.resize
$(window)[action] "resize", resizeHandler
angular.element(window)[action] "resize", resizeHandler

#
# @name register
Expand Down

0 comments on commit e3dc31d

Please sign in to comment.