forked from ClickerMonkey/SemanticUI-Angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sm-shape.js
91 lines (72 loc) · 2.12 KB
/
sm-shape.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(function(app)
{
app
.factory('SemanticShapeLink', ['SemanticUI', SemanticShapeLink])
.directive('smShapeBind', ['SemanticUI', SemanticShapeBind])
.directive('smShape', ['SemanticShapeLink', SemanticShape])
;
var BEHAVIORS = {
smShapeFlipUp: 'flip up',
smShapeFlipDown: 'flip down',
smShapeFlipLeft: 'flip left',
smShapeFlipRight: 'flip right',
smShapeFlipOver: 'flip over',
smShapeFlipBack: 'flip back',
smShapeSetNextSide: 'set next side',
smShapeReset: 'reset',
smShapeQueue: 'queue',
smShapeRepaint: 'repaint',
smShapeSetDefaultSide: 'set default side',
smShapeSetStageSize: 'set stage size',
smShapeRefresh: 'refresh'
};
angular.forEach( BEHAVIORS, function(method, directive)
{
app.directive( directive, ['SemanticUI', function(SemanticUI)
{
return SemanticUI.createBehavior( directive, 'shape', method );
}]);
});
function SemanticShapeBind(SemanticUI)
{
return SemanticUI.createBind( 'smShapeBind', 'shape' );
}
function SemanticShape(SemanticShapeLink)
{
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
settings: '=',
onInit: '=',
/* Events */
onBeforeChange: '=',
onChange: '=',
},
template: [
'<div class="ui shape">',
' <div class="sides" ng-transclude>',
' </div>',
'</div>'
].join('\n'),
link: SemanticShapeLink
};
}
function SemanticShapeLink(SemanticUI)
{
return function(scope, element, attributes)
{
var settings = scope.settings || {};
SemanticUI.linkSettings( scope, element, attributes, 'shape' );
SemanticUI.linkEvents( scope, settings, $.fn.shape.settings, {
onBeforeChange: 'onBeforeChange',
onChange: 'onChange'
});
element.shape( settings );
if ( angular.isFunction( scope.onInit ) ) {
scope.onInit( element );
}
};
}
})( angular.module('semantic-ui-shape', ['semantic-ui-core']) );