<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.css" />
</head>
<body ng-app="slick">
<div class="container" ng-include="'breakpoints.html'" ng-controller="MainCtrl"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.5.0.min.js"></script>
<script src="slick.js"></script>
<script src="breakpoint-controller.js"></script>
</body>
</html>
/* Styles go here */
@font-face {
font-family: 'Pacifico';
src: url('pacifico.eot');
src: url('pacifico.eot?#iefix') format('embedded-opentype'),
url('pacifico.woff') format('woff'),
url('pacifico.ttf') format('truetype'),
url('pacifico.svg#Pacifico') format('svg');
}
#disqus_thread{margin-top:20px;}
*{-moz-box-sizing:border-box;box-sizing:border-box;}
.blue{background:#3498db;color:#fff;}
.blue h3{background:#fff;color:#3498db;font-size:36px;line-height:100px;margin:10px;padding:2%;position:relative;text-align:center;}
.button{background:#3498db;color:#fff;display:block;font-size:16px;margin:20px auto;padding:20px;text-align:center;text-decoration:none;width:48%;}
.buttons{padding:0 20px 20px; margin-bottom: 10px;}
.buttons .button{background:#FFF;color:#3498db;float:left;margin:5px;}
.center .slick-center h3{-moz-transform:scale(1.08);-ms-transform:scale(1.08);-o-transform:scale(1.08);-webkit-transform:scale(1.08);color:#e67e22;opacity:1;transform:scale(1.08);}
.center h3{opacity:0.8;transition:all 300ms ease;}
.content{margin:auto;padding:20px;width:600px;}
.content:after,.buttons::after{clear:both;content:"";display:table;}
.destroy{font-weight:400;margin-top:40px;}
.features{display:block;list-style-type:none;margin-top:30px;padding:0;text-align:center;}
.features li{margin:20px 0;}
.filter .button{background:#FFF;color:#3498db; margin-bottom: 40px;}
.fixed-header{background:#FFF;box-shadow:2px 0 5px rgba(0,0,0,0.5);display:none;padding:10px;position:fixed;top:0;width:100%;z-index:10000;}
.fixed-header .header-content{margin:auto;width:600px;}
.fixed-header .subheading{display:none;}
.fixed-header h1.title{float:left;font-size:24px;margin:0;}
.fixed-header ul.nav{float:right;margin:0;padding:5px;}
.fixed-header ul.nav li{margin:0 0 0 10px;}
.header{padding:20px 0;}
.margin-40{margin-bottom:40px;}
.more,.button.first{margin-top:40px;}
.red{background:#e74c3c;color:#fff;}
.slick-slide .image{padding:10px;}
.slick-slide img{border:5px solid #FFF;display:block;width:100%;}
.slick-slide img.slick-loading{border:0 }
.slick-slider{margin:30px auto 50px;}
.subheading{color:#555;font-size:12px;font-style:italic;font-weight:400;margin:10px auto;text-align:center;}
.white{background:#fff;color:#3498db;}
.white pre,.white hr{background:#3498db;}
a{color:#3498db;}
body,html{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;background:#fff;font-family:'Lucida Grande', sans-serif;height:100%;line-height:1;margin:0;padding:0;text-rendering:optimizeLegibility;width:100%;}
code{color:#000; overflow-x: scroll;}
h1{color:#3498db;font-family:Pacifico;font-size:72px;font-weight:400;line-height:1.2;margin:0 auto 10px;text-align:center;}
h1.title{font-size:96px;}
h2{font-family:Pacifico;font-size:36px;margin:20px auto;text-align:center;}
h4{font-family:Pacifico;font-size:28px;margin:20px auto;text-align:center;}
hr{background:#fff;border:0;height:1px;margin:40px 0;}
p{font-size:18px;font-weight:700;line-height:1.5;margin-bottom:40px;text-align:center;}
p.guff{font-size:16px;}
pre{background:#fff;margin:0 10px 20px;padding:10px;}
section{width:100%;}
table{border-collapse:collapse;border-spacing:0;margin:40px auto;text-align:left;width:100%; table-layout: fixed; font-size: 14px; line-height: 1.4;}
tbody{background:#fff;border-color:#fff;}
td{background:#3498db;border:1px solid #fff;color:#fff;padding:10px;width:33%; vertical-align: top;}
th{border-left:1px solid #3498db;padding:10px;}
td:first-child { font-weight: bold;}
th.last{width: 230px;}
th.type {width: 80px;}
th.default { width: 100px; }
th:first-child{border-left:0;}
thead{background:#fff;border-color:#3498db;color:#3498db;}
tr{background:#fff;border-right:1px solid #fff;}
ul.nav{margin-bottom:0;padding-left:0;text-align:center;}
ul.nav li{display:inline-block;list-style-type:none;margin:0 20px;}
ul.nav li a{font-size:12px;text-decoration:none;}
@media (max-width: 420px) {
ul.nav li a{display:block;font-size:10px;}
}
@media (max-width: 768px) {
.blue h3{font-size:24px;}
.button{margin:0 auto 20px;width:auto;}
.button.first{margin-top:40px;}
.buttons{padding:0 0 20px;}
.buttons .button{float:left;font-size:12px;margin:1%;width:48%;}
.center{margin-left:-40px;margin-right:-40px;}
.center .slick-center h3{-moz-transform:scale(1);-ms-transform:scale(1);-o-transform:scale(1);-webkit-transform:scale(1);color:#e67e22;opacity:1;transform:scale(1);}
.center h3{-moz-transform:scale(0.95);-ms-transform:scale(0.95);-o-transform:scale(0.95);-webkit-transform:scale(0.95);opacity:0.8;transform:scale(0.95);transition:all 300ms ease;}
.content{margin:auto;padding:20px 40px;width:auto;}
.fixed-header .header-content{width:auto;}
pre{font-size:12px; overflow-x: scroll;}
table{font-size:14px;line-height:18px;margin:40px auto 20px; display: block; float: left;}
tr { width: 100%; border-right: none; border-bottom: 1px solid #fff; margin: 0px 0px 20px; padding: 0px 0px 20px; background: transparent; float: left; }
thead { display: none; }
td { border: 0; padding: 10px 0px;}
td,tbody { display: block; width: 100% !important;}
table.settings td:nth-of-type(1), table.methods td:nth-of-type(1){font-weight: bold; font-size: 16px; line-height: 18px;}
table.settings td:nth-of-type(2):before{content: 'Type: '; font-weight: bold;}
table.settings td:nth-of-type(3):before{content: 'Default: '; font-weight: bold;}
table.methods td:nth-of-type(2):before{content: 'Arguments: '; font-weight: bold;}
}
'use strict';
angular.module('slick', []).directive('slick', [
'$timeout',
function ($timeout) {
return {
restrict: 'AEC',
scope: {
initOnload: '@',
data: '=',
currentIndex: '=',
accessibility: '@',
adaptiveHeight: '@',
arrows: '@',
asNavFor: '@',
appendArrows: '@',
appendDots: '@',
autoplay: '@',
autoplaySpeed: '@',
centerMode: '@',
centerPadding: '@',
cssEase: '@',
customPaging: '&',
dots: '@',
draggable: '@',
easing: '@',
fade: '@',
focusOnSelect: '@',
infinite: '@',
initialSlide: '@',
lazyLoad: '@',
onBeforeChange: '&',
onAfterChange: '&',
onInit: '&',
onReInit: '&',
onSetPosition: '&',
pauseOnHover: '@',
pauseOnDotsHover: '@',
responsive: '=',
rtl: '@',
slide: '@',
slidesToShow: '@',
slidesToScroll: '@',
speed: '@',
swipe: '@',
swipeToSlide: '@',
touchMove: '@',
touchThreshold: '@',
useCSS: '@',
variableWidth: '@',
vertical: '@',
prevArrow: '@',
nextArrow: '@'
},
link: function (scope, element, attrs) {
var destroySlick, initializeSlick, isInitialized;
destroySlick = function () {
return $timeout(function () {
var slider;
slider = $(element);
slider.slick('unslick');
slider.find('.slick-list').remove();
return slider;
});
};
initializeSlick = function () {
return $timeout(function () {
var currentIndex, customPaging, slider;
slider = $(element);
if (scope.currentIndex != null) {
currentIndex = scope.currentIndex;
}
customPaging = function (slick, index) {
return scope.customPaging({
slick: slick,
index: index
});
};
slider.slick({
accessibility: scope.accessibility !== 'false',
adaptiveHeight: scope.adaptiveHeight === 'true',
arrows: scope.arrows !== 'false',
asNavFor: scope.asNavFor ? scope.asNavFor : void 0,
appendArrows: scope.appendArrows ? $(scope.appendArrows) : $(element),
appendDots: scope.appendDots ? $(scope.appendDots) : $(element),
autoplay: scope.autoplay === 'true',
autoplaySpeed: scope.autoplaySpeed != null ? parseInt(scope.autoplaySpeed, 10) : 3000,
centerMode: scope.centerMode === 'true',
centerPadding: scope.centerPadding || '50px',
cssEase: scope.cssEase || 'ease',
customPaging: attrs.customPaging ? customPaging : void 0,
dots: scope.dots === 'true',
draggable: scope.draggable !== 'false',
easing: scope.easing || 'linear',
fade: scope.fade === 'true',
focusOnSelect: scope.focusOnSelect === 'true',
infinite: scope.infinite !== 'false',
initialSlide: scope.initialSlide || 0,
lazyLoad: scope.lazyLoad || 'ondemand',
beforeChange: attrs.onBeforeChange ? scope.onBeforeChange : void 0,
onReInit: attrs.onReInit ? scope.onReInit : void 0,
onSetPosition: attrs.onSetPosition ? scope.onSetPosition : void 0,
pauseOnHover: scope.pauseOnHover !== 'false',
responsive: scope.responsive || void 0,
rtl: scope.rtl === 'true',
slide: scope.slide || 'div',
slidesToShow: scope.slidesToShow != null ? parseInt(scope.slidesToShow, 10) : 1,
slidesToScroll: scope.slidesToScroll != null ? parseInt(scope.slidesToScroll, 10) : 1,
speed: scope.speed != null ? parseInt(scope.speed, 10) : 300,
swipe: scope.swipe !== 'false',
swipeToSlide: scope.swipeToSlide === 'true',
touchMove: scope.touchMove !== 'false',
touchThreshold: scope.touchThreshold ? parseInt(scope.touchThreshold, 10) : 5,
useCSS: scope.useCSS !== 'false',
variableWidth: scope.variableWidth === 'true',
vertical: scope.vertical === 'true',
prevArrow: scope.prevArrow ? $(scope.prevArrow) : void 0,
nextArrow: scope.nextArrow ? $(scope.nextArrow) : void 0
});
slider.on('init', function (sl) {
if (attrs.onInit) {
scope.onInit();
}
if (currentIndex != null) {
return sl.slideHandler(currentIndex);
}
});
slider.on('afterChange', function (event, slick, currentSlide, nextSlide) {
if (scope.onAfterChange) {
scope.onAfterChange();
}
if (currentIndex != null) {
return scope.$apply(function () {
currentIndex = currentSlide;
return scope.currentIndex = currentSlide;
});
}
});
return scope.$watch('currentIndex', function (newVal, oldVal) {
if (currentIndex != null && newVal != null && newVal !== currentIndex) {
return slider.slick('slickGoTo', newVal);
}
});
});
};
if (scope.initOnload) {
isInitialized = false;
return scope.$watch('data', function (newVal, oldVal) {
if (newVal != null) {
if (isInitialized) {
destroySlick();
}
initializeSlick();
return isInitialized = true;
}
});
} else {
return initializeSlick();
}
}
};
}
]);
<div class="header">
<div class="header-content">
<h1 class="title">angular-slick</h1>
<p class="subheading">Angular directive for <a href="https://github.com/kenwheeler/slick">slick</a> carousel.</p>
<ul class="nav">
<li><a href="">download</a></li>
<li><a href="#getting-started">github</a></li>
</ul>
</div>
</div>
<section id="features" class="blue" ng-init="index=2">
<div class="content">
<h2>Working</h2>
<slick class="slider single-item" responsive="breakpoints" slides-to-show=3 slides-to-scroll=3>
<div ng-repeat="n in working">
<h3>{{ n.name }}</h3>
</div>
</slick>
<h2>Here is working but not in my code :( </h2>
<slick class="slider single-item" responsive="breakpoints" slides-to-show=3 slides-to-scroll=3>
<div ng-repeat="i in users">
<h3>{{ i.get("username") }}</h3>
</div>
</slick>
<br>
</div>
</section>
<section id="go-get-it" class="white">
<div class="content">
<p class="guff">Information about all settings you can find at original <a href="http://kenwheeler.github.io/slick/">slick</a> site.</p>
</div>
</section>
// this code is based on http://stackoverflow.com/questions/29101254/angularjs-slick-js-carousel-ng-click-not-firing-with-responsive-attribute-settin/30584787
// error goes away when updating to last slick version 1.5.9/slick.min.js
(function() {
'use strict';
Parse.initialize("g9bGHKMyAme6ju3tW4tQ487TntRT9vMWZ1LF2xQd", "yPzOr1oXenajJFyeqYIxtMYuu7C3NaoPzlXCiQcW");
angular.module('slick').controller('MainCtrl', function($scope, myService) {
$scope.breakpoints = [{
breakpoint: 768,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
}, {
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}];
myService.parse().then(function(users){
console.log(users);
$scope.users = users;
});
myService.working().then(function(data1) {
//console.log(data1);
$scope.working = data1;
});
myService.not_working().then(function(data2) {
console.log(data2);
$scope.not_working = data2;
});
}).factory('myService', function($http, $q) {
function parse() {
var deferral = $q.defer();
var User = Parse.Object.extend("_User");
var query = new Parse.Query(User).limit(10);
query.find({
success: function(users) {
console.log(users);
/*for (var i = 0; i < users.length; i++) {
console.log(users[i].get("username"));
}*/
deferral.resolve(users);
},
error: function(error) {
console.warn(error);
deferral.reject();
}
});
return deferral.promise;
}
function working() {
var deferral = $q.defer();
$http.get('working.json').success(function(data) {
deferral.resolve(data);
}).error(function(msg, code) {
deferral.reject(msg);
console.log(msg, code);
});
return deferral.promise;
}
function not_working() {
var deferral = $q.defer();
$http.get('not_working.json').success(function(data) {
deferral.resolve(data);
}).error(function(msg, code) {
deferral.reject(msg);
console.log(msg, code);
});
return deferral.promise;
}
return {
parse: parse,
working: working,
not_working: not_working
};
});
}).call(this);
[{
"id": 1,
"name": "Foo"
}, {
"id": 2,
"name": "Bar"
}, {
"id": 3,
"name": "Fua"
}, {
"id": 4,
"name": "Borr"
}]
[{
"name": "Foo"
}, {
"name": "Bar"
}, {
"name": "Fua"
}, {
"name": "Borr"
}]