Code Monkey home page Code Monkey logo

angular-read-more's Introduction

hm-read-more

Build Status Coverage Status Dependency Status

AngularJS directive that limit text and adds read more / read less links to your text when it exeeds certain limit of characters. No requirements to JQuery. Angular animations are used for fade in/out.

Codepen demo

Codepen demo AngularJS Read More

Install client side

$ bower install angular-read-more --save-dev 

Note that angular-sanitize is required since this directive is allowing HTML tags to be used in text.

Run example locally

$ git clone
$ npm install
$ bower install
$ gulp watch

Test locally

$ git clone
$ npm install
$ bower install
$ gulp karma

How to use in HTML

Include JS script

<script src="//cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.6.4/angular-sanitize.min.js"></script>
<script src="/bower_components/angular-read-more/readmore.min.js"></script>

Add the module to your app,

angular.module("app", ["hm.readmore"]);

As element

<hm-read-more
		hm-text="{{ text }}" 
		hm-limit="100" 
		hm-more-text="read more" 
		hm-less-text="read less"
		hm-dots-class="dots"
        hm-link-class="links">
</hm-read-more>

As attribute

<div hm-read-more
		hm-text="{{ text }}" 
		hm-limit="100" 
		hm-more-text="read more" 
		hm-less-text="read less"
		hm-dots-class="dots"
        hm-link-class="links">
</div>
  • hm-text - full text
  • hm-limit - number > 0 of maximum characters before adding "..." and the more/less text. Default: unlimited
  • hm-more-text - link text for read more. Default: Read more
  • hm-less-text - link text for read less. Default: Read less
  • hm-dots-class - css class for dots
  • hm-link-class - css class for links of read more/read less text

License

angular-read-more is licensed under the MIT license.

Release new Github and Bower version

gulp bump
gulp build
git add .
git commit -m ""
git push

Use Github UI to create new tag and release

Register bower package for the first time

bower register angular-read-more git://github.com/ismarslomic/angular-read-more.git

angular-read-more's People

Contributors

adam187 avatar gabzim avatar hiteshmodha avatar hjmodha avatar ismarslomic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-read-more's Issues

Why an '@' binding for text?

The purpose of this directive is to summarise a long piece of text, why then force the user to use {{ }} inside the hm-text attribute? Not only does the DOM end up with a huge attribute, but if the user will always have to use bindings like that, the extra {{ }} look ugly. I suggest moving from a '@' binding to '='. What do you think?

Disable debug

There needs to be a way to disable the package's debug messages, its flooding my console.
Also this is not cool, as its app wide

Not working on first time

It is not working on initialization. It is working fine if i change some value in "text" textarea. Can you help me out how to sore out this?

ngBindHtml option to put on/off

Hey,

regarding to this Issue #6 now the Html Tags are converting the Text.
But in my case I dont want it.
The output text should show me the Html Tags
Can there be an Option implemented to shut off/on this possibility?
<hm-read-more
....
hm-html-convert='true/false' //default would be true for converting?
..>

Read more using all space available in one line

What do you think of having a "version" that allows to be not by word count but by filling all the available space existing in one line.

Using text-overflowproperty ellipsis this is possible, using the browser to manage that.

Avoid <pre> tags in the template

I tried to integrate the angular-read-more library into a web app and everything works fine except for the pre tags in the template (used to wrap both short and long texts).
pre is a pretty invasive html tag and it strongly modifies the page layout. To make a simple test i manually substituted pre tags with span tags and the library seem still to work for me (with no impact on the page layout).
May be possible to optionally use span instead of pre to wrap text?
Many thanks

Read more adds a single space that breaks the text

If the limit falls on a non-empty space, cutting off a word in the middle, the 'show more' will add a single space to the word after its clicked. In the demo you have here change the limit to 198 instead of 200. The '...' will appear on the last two letters of the word "mauris". Once you click show more, the word will be displayed like this "mauri s".

extra space appended

if a word is broken while showing less text an extra space gets added after that character when full text is shown.

out t ... Read more on expand becomes t hese collection. An extra space gets added after t

cutest words

hello am using your plugin with textAngular which is wisiwig text editor for angular
the plugin works correctly but it cuts words and shows ...readmore and when i click readmore it wont start continuing where it exactly at it cuts which it should be. and also other issue is when i click readmore it starts continuing in new line and readleas showed at the end of the line with some spaces left. let me show you my snap shot.
capture
capture2

Doesn't preserve line breaks

In my application a user enters text into a textarea, when they enter a line break the value \n gets added to the text, This gets stored and is pulled back for display with the read-more plugin but the plugin just ignores the line break \n value. Is there an option to tell it to respect the line breaks?

Codepen - http://codepen.io/anon/pen/adXNXJ

When I try to force it via CSS it leaves a large space between the cut off value of the text and the read more/read less text

Codepen for that - http://codepen.io/anon/pen/dGaMLd

<pre>

is this tested with

?
With
, it comes with a large textbox+scrollbar, which is not what I want.

gulp-bump should be a dev dependency

Since gulp-bump is only used during the build / release process it should be listed under devDependencies and not under dependencies in package.json.

Only functions on first load

I have implemented this standard from bower and it works fine on the first load. However when I change the view and come back into the same page it does not work (nothing shows, there are no errors).

How can I use hm-read-more with ng-bind-html

Hello - my original code - before I apply hm-read-more, looks like:
<p ng-bind-html="page.content | unsafe"></p>

I have to use ng-bind-html in order to get page.content to pass through the unsafe filter. How would I apply the hm-read-more directive in this instance?

Event emitted when toggle is clicked

Needed for rearrange the parent element.
For example , using read more directive inside a widget managed by masonry . When read More is clicked the widget's height will grow and masonry needs to be called to rearrange the widgets .

Thanks,
Catalin

Breaking word across elements

screen shot 2016-02-23 at 3 29 53 pm
screen shot 2016-02-23 at 3 29 49 pm

If the character limit ends in the middle of a word that word is split over the two

elements when the more-text is shown.

Expected behaviour would be the more-text

element would contain the whole text and the read more would toggle ng-show between both elements?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.