Debian Codegraph @

examples/movies.html

raw
1 <!DOCTYPE html>
2 <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->
3 <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]-->
4 <!--[if IE 8]><html class="no-js lt-ie9"><![endif]-->
5 <!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
6 <head>
7 <meta charset="utf-8">
8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9 <title>Selectize.js Demo</title>
10 <meta name="description" content="">
11 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
12 <link rel="stylesheet" href="css/normalize.css">
13 <link rel="stylesheet" href="css/stylesheet.css">
14 <!--[if IE 8]><script src="js/es5.js"></script><![endif]-->
15 <script src="js/jquery.min.js"></script>
16 <script src="../dist/js/standalone/selectize.js"></script>
17 <script src="js/index.js"></script>
18 <style type="text/css">
19 .selectize-control.movies .selectize-dropdown [data-selectable] {
20 border-bottom: 1px solid rgba(0,0,0,0.05);
21 height: 60px;
22 position: relative;
23 -webkit-box-sizing: content-box;
24 box-sizing: content-box;
25 padding: 10px 10px 10px 60px;
26 }
27 .selectize-control.movies .selectize-dropdown [data-selectable]:last-child {
28 border-bottom: 0 none;
29 }
30 .selectize-control.movies .selectize-dropdown .by {
31 font-size: 11px;
32 opacity: 0.8;
33 }
34 .selectize-control.movies .selectize-dropdown .by::before {
35 content: 'by ';
36 }
37 .selectize-control.movies .selectize-dropdown .name {
38 font-weight: bold;
39 margin-right: 5px;
40 }
41 .selectize-control.movies .selectize-dropdown .description {
42 font-size: 12px;
43 color: #a0a0a0;
44 }
45 .selectize-control.movies .selectize-dropdown .actors,
46 .selectize-control.movies .selectize-dropdown .description,
47 .selectize-control.movies .selectize-dropdown .title {
48 display: block;
49 white-space: nowrap;
50 width: 100%;
51 overflow: hidden;
52 text-overflow: ellipsis;
53 }
54 .selectize-control.movies .selectize-dropdown .actors {
55 font-size: 10px;
56 color: #a0a0a0;
57 }
58 .selectize-control.movies .selectize-dropdown .actors span {
59 color: #606060;
60 }
61 .selectize-control.movies .selectize-dropdown img {
62 height: 60px;
63 left: 10px;
64 position: absolute;
65 border-radius: 3px;
66 background: rgba(0,0,0,0.04);
67 }
68 .selectize-control.movies .selectize-dropdown .meta {
69 list-style: none;
70 margin: 0;
71 padding: 0;
72 font-size: 10px;
73 }
74 .selectize-control.movies .selectize-dropdown .meta li {
75 margin: 0;
76 padding: 0;
77 display: inline;
78 margin-right: 10px;
79 }
80 .selectize-control.movies .selectize-dropdown .meta li span {
81 font-weight: bold;
82 }
83 .selectize-control.movies::before {
84 -moz-transition: opacity 0.2s;
85 -webkit-transition: opacity 0.2s;
86 transition: opacity 0.2s;
87 content: ' ';
88 z-index: 2;
89 position: absolute;
90 display: block;
91 top: 12px;
92 right: 34px;
93 width: 16px;
94 height: 16px;
95 background: url(images/spinner.gif);
96 background-size: 16px 16px;
97 opacity: 0;
98 }
99 .selectize-control.movies.loading::before {
100 opacity: 0.4;
101 }
102 </style>
103 </head>
104 <body>
105 <div id="wrapper">
106 <h1>Selectize.js</h1>
107 <div class="demo">
108 <h2>Loading from API</h2>
109 <p>This demo shows how to integrate third-party data, loaded asynchronously.</p>
110 <div class="control-group">
111 <label for="select-movie">Movie:</label>
112 <select id="select-movie" class="movies" placeholder="Find a movie..."></select>
113 </div>
114 <script>
115 // <select id="select-movie"></select>
116 $('#select-movie').selectize({
117 valueField: 'title',
118 labelField: 'title',
119 searchField: 'title',
120 options: [],
121 create: false,
122 render: {
123 option: function(item, escape) {
124 var actors = [];
125 for (var i = 0, n = item.abridged_cast.length; i < n; i++) {
126 actors.push('<span>' + escape(item.abridged_cast[i].name) + '</span>');
127 }
128
129 return '<div>' +
130 '<img src="' + escape(item.posters.thumbnail) + '" alt="">' +
131 '<span class="title">' +
132 '<span class="name">' + escape(item.title) + '</span>' +
133 '</span>' +
134 '<span class="description">' + escape(item.synopsis || 'No synopsis available at this time.') + '</span>' +
135 '<span class="actors">' + (actors.length ? 'Starring ' + actors.join(', ') : 'Actors unavailable') + '</span>' +
136 '</div>';
137 }
138 },
139 load: function(query, callback) {
140 if (!query.length) return callback();
141 $.ajax({
142 url: 'http://api.rottentomatoes.com/api/public/v1.0/movies.json',
143 type: 'GET',
144 dataType: 'jsonp',
145 data: {
146 q: query,
147 page_limit: 10,
148 apikey: '3qqmdwbuswut94jv4eua3j85'
149 },
150 error: function() {
151 callback();
152 },
153 success: function(res) {
154 console.log(res.movies);
155 callback(res.movies);
156 }
157 });
158 }
159 });
160 </script>
161 </div>
162 </div>
163 </body>
164 </html>