-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#84 - added drawer component, removed few files
- Loading branch information
Showing
12 changed files
with
92 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* @ngInject */ | ||
export default function drawerClosed (DrawerSettings) { | ||
// Usage: | ||
// <button drawer-closed="css-class-to-apply-when-closed"></button> | ||
// Creates: | ||
// an action which will toggle the drawer | ||
var directive = { | ||
link: link, | ||
restrict: 'A' | ||
}; | ||
return directive; | ||
|
||
function link(scope, element, attrs) { | ||
var cssClassToApply = attrs.drawerClosed; | ||
scope.drawerOpened = DrawerSettings.opened; | ||
scope.$watch('drawerOpened()', function (nState, oldState) { | ||
if (nState !== oldState) { | ||
addStateAsClass(); | ||
} | ||
}); | ||
|
||
addStateAsClass(); | ||
|
||
function addStateAsClass () { | ||
element.toggleClass(cssClassToApply, !DrawerSettings.opened()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* @ngInject */ | ||
export default function DrawerSettings () { | ||
var isOpen = true; | ||
var service = { | ||
toggle: toggle, | ||
opened: opened | ||
}; | ||
return service; | ||
|
||
//////////////// | ||
|
||
function toggle() { | ||
isOpen = !isOpen; | ||
} | ||
|
||
function opened () { | ||
return isOpen; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* @ngInject */ | ||
export default function drawerToggle (DrawerSettings) { | ||
// Usage: | ||
// <button drawer-toggle="css-class-to-apply"></button> | ||
// Creates: | ||
// an action which will toggle the drawer | ||
var directive = { | ||
link: link, | ||
restrict: 'A' | ||
}; | ||
return directive; | ||
|
||
function link(scope, element, attrs) { | ||
var cssClassToApply = attrs.drawerToggle; | ||
element.bind('click', function (ev) { | ||
ev.preventDefault(); | ||
DrawerSettings.toggle(); | ||
if (cssClassToApply && cssClassToApply.length) { | ||
addStateAsClass(); | ||
} | ||
scope.$apply(); | ||
}); | ||
|
||
addStateAsClass(); | ||
|
||
function addStateAsClass () { | ||
element.toggleClass(cssClassToApply, DrawerSettings.opened()); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import angular from 'angular'; | ||
import DrawerSettings from './drawer-settings.service.js'; | ||
import drawerToggle from './drawer-toggle.component'; | ||
import drawerClosed from './drawer-closed.component'; | ||
|
||
export default angular.module('drawer', [ | ||
'app.core' | ||
]) | ||
.factory('DrawerSettings', DrawerSettings) | ||
.directive('drawerToggle', drawerToggle) | ||
.directive('drawerClosed', drawerClosed) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters