Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <menutitle>Bootstrap - Movie Card 2up with Filter</menutitle>
- <<MC HTML Page>>
- <<header>>
- <title>Movie List - <<moviecount>> titles</title>
- <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css" />
- <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" >
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
- <script type="text/javascript">
- function ucwords(str) {
- return (str + '').replace(/^([a-z])|[\s_]+([a-z])/g, function ($1) {
- return $1.toUpperCase();
- })
- };
- var movieList = {
- titleList: {},
- genreList: {},
- filterTitle: [],
- filterGenre: {
- and: [],
- not: []
- },
- movies: {}, // object containing jQuery collection of movies
- dom: {
- ul_filterTitle: {},
- ul_filterGenre: {},
- div_loading: {},
- div_loadingMessage: {}
- },
- functions: {
- showLoading: function(message) {
- movieList.dom.div_loadingMessage.html(message);
- var w = $(window).width(), h = $(window).height();
- movieList.dom.div_loading.height(h).width(w);
- movieList.dom.div_loadingMessage.css('margin-top', (h / 2)+'px');
- movieList.dom.div_loading.show();
- },
- hideLoading: function() {
- movieList.dom.div_loading.hide();
- },
- toggleFilter: function(type, filter) {
- movieList.functions.showLoading('FILTERING');
- var icon = filter.children('i');
- var filterText = filter.attr('data-filter');
- if (type == 'title') {
- switch (icon.prop('class')) {
- case 'icon-plus-sign':
- icon.prop('class', 'icon-minus-sign');
- movieList.filterTitle.push(filterText);
- break;
- case 'icon-minus-sign':
- icon.prop('class', 'icon-plus-sign');
- for (var k in movieList.filterTitle) {
- if (movieList.filterTitle[k] == filterText) {
- movieList.filterTitle.splice(k, 1);
- }
- }
- break;
- }
- } else {
- switch (icon.prop('class')) {
- case 'icon-question-sign':
- icon.prop('class', 'icon-plus-sign');
- movieList.filterGenre.and.push(filterText);
- break;
- case 'icon-plus-sign':
- icon.prop('class', 'icon-minus-sign');
- for (var k in movieList.filterGenre.and) {
- if (movieList.filterGenre.and[k] == filterText) {
- movieList.filterGenre.and.splice(k, 1);
- }
- }
- movieList.filterGenre.not.push(filterText);
- break;
- case 'icon-minus-sign':
- icon.prop('class', 'icon-question-sign');
- for (var k in movieList.filterGenre.not) {
- if (movieList.filterGenre.not[k] == filterText) {
- movieList.filterGenre.not.splice(k, 1);
- }
- }
- break;
- }
- }
- var show = movieList.movies;
- for (var f in movieList.filterTitle) {
- show = show.not(movieList.titleList[movieList.filterTitle[f]]);
- }
- for (var g in movieList.filterGenre.and) {
- var show2 = $.extend(true, {}, show);
- show2.each(function(i, e) {
- if (movieList.genreList[movieList.filterGenre.and[g]].index(e) == -1) {
- show = show.not(e);
- }
- });
- }
- for (var g in movieList.filterGenre.not) {
- var show2 = $.extend(true, {}, show);
- show2.each(function(i, e) {
- if (movieList.genreList[movieList.filterGenre.not[g]].index(e) != -1) {
- show = show.not(e);
- }
- });
- }
- hide = movieList.movies.not(show);
- show.show();
- hide.hide();
- movieList.functions.hideLoading();
- }
- }
- };
- $(function(){
- for (var d in movieList.dom) {
- movieList.dom[d] = $('#'+d);
- }
- movieList.movies = $('.movie');
- movieList.dom.ul_filterTitle.on('click', 'li', function(e) {
- movieList.functions.toggleFilter('title', $(this));
- });
- movieList.dom.ul_filterGenre.on('click', 'li', function(e) {
- movieList.functions.toggleFilter('genre', $(this));
- });
- movieList.movies.each(function(i, e){
- var that = $(this);
- var firstLetter = $(e).attr('data-title').substr(0, 1).toLowerCase();
- if (firstLetter.search(/[0-9]/) == -1) {
- if (!movieList.titleList.hasOwnProperty(firstLetter)) {
- movieList.titleList[firstLetter] = $();
- movieList.filterTitle.push(firstLetter);
- }
- movieList.titleList[firstLetter] = movieList.titleList[firstLetter].add(that);
- } else {
- if (!movieList.titleList.hasOwnProperty('0-9')) {
- movieList.titleList['0-9'] = $();
- movieList.filterTitle.push('0-9');
- }
- movieList.titleList['0-9'] = movieList.titleList['0-9'].add(that);
- }
- $(e).attr('data-genre').split('/').forEach(function(g){
- g = g.trim().toLowerCase();
- if (!movieList.genreList.hasOwnProperty(g)) {
- movieList.genreList[g] = $();
- }
- movieList.genreList[g] = movieList.genreList[g].add(that);
- });
- });
- // Populate filter options
- for (letter in movieList.titleList) {
- movieList.dom.ul_filterTitle.append('<li data-filter="'+letter+'"><i class="icon-minus-sign"></i>'+letter.toUpperCase()+'</li>');
- }
- for (genre in movieList.genreList) {
- movieList.dom.ul_filterGenre.append('<li data-filter="'+genre+'"><i class="icon-question-sign"></i>'+ucwords(genre)+'</li>');
- }
- var maxWidth = 0;
- movieList.dom.ul_filterGenre.children('li').each(function(i, e){
- var that = $(this);
- if (that.width() > maxWidth) { maxWidth = that.width() + 10; }
- });
- movieList.dom.ul_filterGenre.children('li').width(maxWidth);
- movieList.functions.toggleFilter('title', movieList.dom.ul_filterTitle.children('li').first());
- });
- </script>
- <style type="text/css">
- @charset "utf-8";
- body {
- font-size: 12px;
- font-family: 'Open Sans', sans-serif;
- margin: 20px auto;;
- overflow-y: scroll;
- width: 960px;
- }
- #movieCollection {
- margin: auto;
- }
- #movieCollection .movie {
- position: relative;
- margin: 0 10px 20px 10px;
- background: #f0f0f0;
- }
- #movieCollection .movie .title {
- text-align: left;
- color: #ffffff;
- background: #000000;
- font-size: 1.3em;
- font-weight: 700;
- line-height: 1.3em;
- padding: 4px;
- }
- #movieCollection .movie .title a {
- color: inherit;
- }
- #movieCollection .movie img {
- margin-right: 5px;
- }
- #movieCollection .movie .description {
- height: 175px;
- display: table;
- position: relative;
- }
- #movieCollection .movie .description dl {
- overflow: auto;
- margin-top: 0;
- margin-bottom: 0;
- }
- #movieCollection .movie .description .descLabel,
- #movieCollection .movie .description dl dt {
- width: 50px;
- padding-right: 5px;
- }
- #movieCollection .movie .description dl dd {
- margin-left: 55px;
- }
- #movieCollection .movie .description .descLabel {
- display: inline-block;
- text-align: right;
- }
- #movieCollection .movie .description .top {
- height: 150px;
- }
- #movieCollection .movie .description .bottom {
- position: absolute;
- bottom: 0;
- width: 100%;
- height: 20px;
- padding-bottom: 5px;
- }
- #movieCollection .movie .description .bottom .runtime {
- padding-right: 5px;
- }
- #movieCollection .movie .description .rating {
- display: inline-block;
- width: 50px;
- }
- #div_loading {
- position: absolute;
- top: 0;
- left: 0;
- background: #000000;
- color: #ffffff;
- font-size: 10em;
- opacity: 0.8;
- text-align: center;
- z-index: 1;
- font-weight: 700;
- }
- .filter {
- display: block;
- overflow: hidden;
- position: relative;
- padding: 5px 0 5px 80px;
- margin: 5px 0;
- background: #e0e0e0;
- font-weight: 700;
- }
- .filter ul {
- display: block;
- list-style: none;
- margin: 0;
- text-align: left;
- }
- .filter ul li {
- display: inline-block;
- cursor: pointer;
- margin: 2px 4px;
- text-align: left;
- }
- .filter ul li i {
- margin-right: 2px;
- }
- .filter .filterTitle {
- font-size: 2em;
- height: 100%;
- left: 5px;
- top: 0;
- position: absolute;
- }
- .verticalCenterOuter {
- overflow: hidden;
- display: table;
- height: 100%;
- }
- .verticalCenterMiddle {
- display: table-cell;
- vertical-align: middle;
- width: 100%;
- position: static;
- }
- .verticalCenterInner {
- position: static;
- }
- </style>
- <</header>>
- <<body>>
- <div id="div_loading"><div id="div_loadingMessage"></div></div>
- <div id="filterOptions">
- <div class="filter"><div class="filterTitle"><div class="verticalCenterOuter"><div class="verticalCenterMiddle"><div class="verticalCenterInner">Title</div></div></div></div><ul id="ul_filterTitle"></ul></div>
- <div class="filter"><div class="filterTitle"><div class="verticalCenterOuter"><div class="verticalCenterMiddle"><div class="verticalCenterInner">Genre</div></div></div></div><ul id="ul_filterGenre"></ul></div>
- </div>
- <div id="movieCollection" class="row">
- <<media_item>>
- <div class="movie span6" data-genre="<<moviegenre>>" data-title="<<title>>">
- <div class="title strong"><<title>> (<<movieyear>>)<a href="<<imdb_url>>">IMDB</a></div>
- <img class="pull-left" src="<<createimage:175>>" />
- <div class="description">
- <div class="top">
- <dl class="dl-horizontal">
- <dt><strong>Stars:</strong></dt><dd><<stars>></dd>
- <dt><strong>Genre:</strong></dt><dd><<moviegenre>></dd>
- </dl>
- <div class="descLabel"><strong>Outline:</strong></div><<nfo:outline>>
- </div>
- <div class="bottom">
- <div class="rating"><strong><<rating>></strong>/10</div><strong>Cert: </strong><abbr title="<<nfo:mpaa>>"><<nfo:mpaa:30>></abbr>
- <div class="runtime pull-right"><<runtime>></div>
- </div>
- </div>
- </div>
- <</media_item>>
- </div>
- <</body>>
- <<footer>><</footer>>
- <</MC HTML Page>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement