-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-ellipsis.html
More file actions
143 lines (109 loc) · 8.21 KB
/
angular-ellipsis.html
File metadata and controls
143 lines (109 loc) · 8.21 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="Dibari.github.io : " />
<meta description="Angular directive to truncate multi-line text to visible height. The end of the visible text is appended with an ellipsis and optional text.">
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>Angular Ellipsis Directive | DiBari.github.io</title>
<script src="javascripts/angular.js"></script>
<script>
var exampleApp = angular.module("ellipsisApp", []);
</script>
<script src="javascripts/angular-ellipsis.js"></script>
<script>
(function(ng, app){
"use strict";
app.controller("EllipsisController", function($scope, $interval) {
var i = 1;
$scope.paragraphText = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate, we can not consecrate, we can not hallow, this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.";
$scope.ellipsisText = "But wait, there's more";
$scope.linkAddress = "http://www.google.com";
$interval(function() {
$scope.incrementing = "But wait, there's more x" + i;
i++;
}, 1000);
$scope.showFullText = function() {
alert('On click function');
};
});
})(angular, exampleApp);
</script>
<style type="text/css">
p {max-height: 75px; overflow: hidden; margin-top: 3px; margin-bottom: 30px;}
p span {color: red; font-weight: bold;}
code {font-size: .7em;}
</style>
</head>
<body id="ng-app" data-ng-app="ellipsisApp" data-ng-controller="EllipsisController">
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/dibari/angular-ellipsis">View on GitHub</a>
<h1 id="project_title">Angular Ellipsis</h1>
<h2 id="project_tagline">Angular directive to truncate multi-line text to visible height</h2>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<section id="main-content">
<p style="max-height: none;">Below are examples of the <a href="https://www.github.com/dibari/angular-ellipsis">Angular Ellipsis Directive</a> in action. The directive is fully responsive; it will update on window resizing. All that is required is for the element to have a set height or max-height. Custom append text (which are wrapped in a span tag) is shown in bold and red. These styles are set to highlight functionality, and are by default not styled. All of the examples below use max-height unless specifically noted.</p>
<h3><a name="welcome-to-github-pages" class="anchor" href="#welcome-to-github-pages"><span class="octicon octicon-link"></span></a>Angular Ellipsis Examples</h3>
<h5>Basic Usage</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis></p></code>
<p data-ng-bind="paragraphText" data-ellipsis></p>
<h5>Custom Ellipsis Symbol/String</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-symbol="--"></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-symbol="--"></p>
<h5>Custom Append Text</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more"></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more"></p>
<h5>Custom Ellipsis Symbol/String and Append Text</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-symbol="---" data-ellipsis-append="read more"></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-symbol="---" data-ellipsis-append="read more"></p>
<h5>Custom Append Text using Scope Variable</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="{{<span>ellipsisText</span>}}"></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="{{ellipsisText}}"></p>
<h5>Custom Append Text using Updating Scope Variable</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="{{<span>incrementing</span>}}"></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="{{incrementing}}"></p>
<h5>Custom Append Text with Click Function</h5>
<code><p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more" data-ellipsis-append-click="showFullText()" ></p></code>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more" data-ellipsis-append-click="showFullText()"></p>
<h3 class="link toggleNext">Angular controller and scope data used in examples</h3>
<code>
app.controller("EllipsisController", function($scope, $interval) {<br>
var i = 0;<br><br>
$scope.paragraphText = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate, we can not consecrate, we can not hallow, this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.";<br><br>
$scope.ellipsisText = "But wait, there's more";<br><br>
$interval(function() {<br>
$scope.incrementing = "But wait, there's more x" + i;<br>
i++;<br>
}, 1000);<br><br>
$scope.showFullText = function() {<br>
alert('On click function');<br>
};<br>
});
</code>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-45318609-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>