How to show message after a while in angular - angularjs

I use from ng-class for div because I want to show message after a while when if is true but delay opacity dose not work . what do yo do ?
this is html
<div class="list" ng-show="item.collapsed == true" ng-class="{'panel-details':item.collapsed == true}">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</div>
this is css
.list {
opacity: 0;
transition: opacity 1s ease-in !important;
}
.panel-details {
opacity: 1;
}

try this
setTimeout(function(){
$('#list').fadeIn(500);
}, 5000);
And do not use opacity but rather the display property

Related

Multi-Column Page Layout using react-pdf

The above picture is an example of a two-column page layout system in MS Word. On the web, a similar layout can be achieved using the following code:
<style>
.two-col {
column-count: 2;
}
</style>
<div class="two-col">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.
</div>
How can it be done with react-pdf?
I tried with flexbox styling but it only works for a single page; continuous text wrapping or page breaking is impossible.

¿How can I split my text in two columns in a VF rendered as PDF? #CSS Not working properly

My code is something like that:
<apex:page renderAs="pdf" standardController="Account" extensions="CNT_Generar_InfoAbante" sidebar="false" showHeader="false" applyBodyTag="false" >
<head>
<style type="text/css" media="print">
#contenedorBody {
column-count: 2;
column-width: 100px;
column-gap: 20px;
text-align: justify;
width: 100%;
height: 1018px;
max-width: 100%;
max-height: 1018px;
}
.contenedorFooter {
width: 100%;
height: 48px;
max-height 48px;
/* background: rgb(255, 220, 206); */
}
</style>
</head>
<div id="contenedorBody">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="contenedorFooter">
<table>
<tr>
<td class="width70"> </td>
<td class="width30"><apex:image styleclass="imgFooter" width="145" height="46" value="{!$Resource.imgLogo}"/></td>
</tr>
</table>
</div>
But still displaying this
Image Pdf 1
instead like this Image Pdf 2 .
I'm just trying to split my text in two columns, but when I render my page as PDF it looks like the CSS stop working. Could somebody help me? Thank you!

AngularJS: Auto-scroll to anchor point after state change

I am looking to have a user click a link on a page, this will trigger a stateChange and lead them to a new state. what I want to achieve is when the state is finished loading it then scrolls to an anchor on the page specified by the link on the previous page.
to Do this I am using a combination of passing a $stateParam through a ui-sref like so:
<a ui-sref="stateParent.stateChild({id: 'practiceParam'})">goToPage</a>
then when the page is reached there is a div sitting on it with a directive attached that activates on $viewContentLoaded, so the DOM is rendered and I can search for an ID. the HTML div looks like this:
<div scroll-after-load ></div>
and my scrolling directive is as follows:
angular.module( 'app' ).directive('scrollAfterLoad', function() {
return {
restrict: 'A',
link: function(scope, $elm, attrs, $stateParams) {
scope.$on('$viewContentLoaded', function() {
console.log('scrollAfterLoad Directive Loaded, $stateParams are: ', $stateParams );
var idToScroll = attrs.href;
var $target;
if (idToScroll) {
$target = $(idToScroll);
// the -50 accounts for the top navbar which is fixed on the page and removed from pageflow
$("html,body").animate({scrollTop: $target.offset().top - 50}, "slow");
}
});
}
};
});
I have not bothered with setting the href on the div yet as I cannot access the passed parameter, am I accessing it incorrectly? I have also tried using a more standard state.go() to pass a stateParam but my result is still null.
Once I can pass a stateparam the Idea is just to add an href to the params that gets injected into the div on the newly loaded page and autoscroll to another div on that page with an ID that matches my passed parameter.
Also a side note, on my ui-view's i have autoscroll set to true so the pages automatically load at the top, I like this behaviour and it is the reason I need the state to complete loading before the scoll is activated.
Your problem is that you are trying to inject the $stateParams service into the link function. However, the correct place for this kind of injection is at the factory method, means the definition of the directive. A factory method is registered with a module - as in your case with the scrollAfterLoad directive. For more information check AngularJS Dependency Injection.
So back to your question: If you actually inject $stateParams into your factory method of your directive, means at the top you will be able to easily access the params. Your directive could look like this:
angular.module( 'app' ).directive('scrollAfterLoad', ['$stateParams', function($stateParams) {
return {
restrict: 'A',
link: function(scope, $elm, attrs) {
scope.$on('$viewContentLoaded', function() {
console.log('scrollAfterLoad Directive Loaded, $stateParams are: ', $stateParams );
var idToScroll = attrs.href;
var $target;
if (idToScroll) {
$target = $(idToScroll);
// the -50 accounts for the top navbar which is fixed on the page and removed from pageflow
$("html,body").animate({scrollTop: $target.offset().top - 50}, "slow");
}
});
}
};
}]);
Notice that I have removed the $stateParams from your link function and put it at the top. This way the service will be already available within the link function - actually within the whole directive.
I reproduced your scenario in this Plunker.
With angular-scroll you could do it like this:
Pass your scroll target id as state parameter to child state controller and then scroll to the element with scrollToAnimated(element).
If you'd like to have it reusable you could create a factory of that controller and inject it into resolve of child state. That should work too but I haven't tested it.
You probably need to retrigger the scrolling if you're on the child state and click on the state change link again. That's why I've added the method checkState that reloads the current state if we're on child state to repeat the scrolling.
Please have a look at the demo below or in this fiddle.
I think your directive is not working because you're not passing the href attribute to your directive.
You could fix this by passing href="targetId" to your directive where targetId is added with $scope.targetId = $stateParams.id in you child controller. Or you could access the targetId of $scope directly if you're not using an isolated scope.
Anyway I would do it like I did it in the demo or with a factory inside resolve.
angular.module('demoApp', ['ui.router', 'duScroll'])
.controller('MainControlller', MainController)
.config(Config);
function MainController($scope, $state) {
$scope.checkState = function() {
//console.log($state.current);
if($state.current.name == 'parent.child') {
//console.log('parent.child state');
// reload to retrigger scrolling again
$state.reload();
}
};
}
function Config($urlRouterProvider, $stateProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('parent', {
url: '/',
templateUrl: 'home.html'
})
.state('parent.child', {
url: 'child/:id',
templateUrl: 'child.html',
controller: function($scope, $stateParams, $document) {
var scrollElement = angular
.element(document.getElementById($stateParams.id));
console.log(scrollElement);
$document.scrollToElementAnimated(scrollElement);
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-scroll/0.7.3/angular-scroll.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<div ng-app="demoApp" ng-controller="MainController">
<script type="text/ng-template" id="home.html">
<a ui-sref="parent.child({id: 'practiceParam'})" ng-click="checkState()">go to practice</a>
<div ui-view=""></div>
</script>
<script type="text/ng-template" id="child.html">
<!--scroll to practice
--><p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p><p>
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</p><p>
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<h1 id="practiceParam">practice</h1>
<p>
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</p><p>
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</p>
<a ui-sref="parent">back</a>
</script>
<div ui-view=""></div>
</div>

Angular Noob: $resource is not returning the record?

I'm on Rails + Angular. I created a route in rails
http://localhost:3000/api/products/30 that returns JSON:
{"id":30,"name":"blue / red / sky blue square eyeglasses","active":true,"page_title":"","meta_description":"","created_at":"2014-05-27T20:26:03.000Z","updated_at":"2014-07-25T14:42:19.000Z","vendor_id":4,"short_description":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum do","long_description":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum do","shape_id":4,"material_id":1,"category_id":3,"taxable":false,"products_colors":[{"id":31,"color_id":4,"product_id":30,"mens":true,"womens":true,"created_at":"2014-05-27T20:26:03.000Z","updated_at":"2014-05-28T19:05:13.000Z","mens_sort_order":1,"womens_sort_order":0,"color":{"id":4,"name":"sky blue","created_at":"2014-05-16T18:11:03.000Z","updated_at":"2014-05-16T18:11:03.000Z","image":{"url":"/images/no-image.png"}}},{"id":36,"color_id":1,"product_id":30,"mens":true,"womens":true,"created_at":"2014-05-28T20:19:40.000Z","updated_at":"2014-05-28T20:19:40.000Z","mens_sort_order":null,"womens_sort_order":null,"color":{"id":1,"name":"blue","created_at":"2014-05-16T17:01:26.000Z","updated_at":"2014-07-25T18:49:54.000Z","image":{"url":"/uploads/color/1/blackt.jpg"}}},{"id":37,"color_id":3,"product_id":30,"mens":false,"womens":true,"created_at":"2014-05-28T20:20:15.000Z","updated_at":"2014-05-28T20:20:15.000Z","mens_sort_order":null,"womens_sort_order":null,"color":{"id":3,"name":"red","created_at":"2014-05-16T18:10:25.000Z","updated_at":"2014-07-25T18:59:17.000Z","image":{"url":"/images/no-image.png"}}},{"id":38,"color_id":5,"product_id":30,"mens":true,"womens":true,"created_at":"2014-05-28T20:21:58.000Z","updated_at":"2014-05-28T20:21:58.000Z","mens_sort_order":null,"womens_sort_order":null,"color":{"id":5,"name":"pitch black","created_at":"2014-05-22T18:04:25.000Z","updated_at":"2014-05-22T18:04:25.000Z","image":{"url":"/images/no-image.png"}}}]}
However, when I try to retrieve this JSON in angular by using $resource, it's returning a Resource:
provider (should I be using a provider?):
app.provider("SingleProduct", function() {
this.$get = ['$resource', function($resource) {
return {
find: function(path) {
var Product = $resource("/api" + path);
return Product;
}
}
}];
});
controller:
app.controller('ProductCtrl', ['$scope', '$location', '$resource', 'SingleProduct', function($scope, $location, $resource, SingleProduct) {
// $location.path is equal to /products/30
var product = SingleProduct.find($location.path());
$scope.title = "fff";
$scope.product = product;
}]);
view:
<div ng-controller="ProductCtrl">
{{ title }} // prints out fff (CORRECT)
{{ product.name }} // prints out Resource (INCORRECT, should be "blue / red ...")
</div>
What's going on ? This technique worked when I did it for /api/products where it returned an array of products in JSON format.
You never actually call any method on the resource. Your .find returns a resource object with a specified path, now do something with said resource:
var product = SingleProduct.find($location.path());
var products = product.get(); //something like this

AngularJS - Sliding Effect On ng-click

I have created a simple ng-click function that hides and shows a DIV.
However, rather and simply appearing and disappearing, does angular have the ability to give a sliding effect?
Here's a plunkr: http://plnkr.co/edit/jbHidL3oOQvi4RBCkJIF?p=preview
HTML:
<div class="grid-wrap">
<div class="grid-col one-third">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Show the slidy section
</div>
<div class="grid-col two-thirds" ng-show="showMe">
My hidden section that i want to slide out
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis irure dolor in repr</p>
</div>
</div>
You should have a good read about ng-animate (it have to be injected into your app - something a lot of ppl forget) then you can take a look here
http://www.nganimate.org/angularjs/ng-switch/slider-css3-transition-animation
a well designed examples of what ng-animate can do
Google CDN angularjs-animate.min.js

Resources