@@ -168,15 +168,11 @@ <h2>Material Design</h2>
168168 < div layout ="column " flex ="45 ">
169169 < h3 > The Generated Form</ h3 >
170170
171- < form name ="ngform " sf-model ="modelData " sf-form ="form " sf-schema ="schema " ng-submit ="submitForm(ngform,modelData) "> </ form >
172- <!--
173171 < form name ="ngform "
174172 sf-model ="modelData "
175173 sf-form ="form "
176174 sf-schema ="schema "
177- ng-submit="submitForm(ngform,modelData)">
178- </form>
179- -->
175+ ng-submit ="submitForm(ngform,modelData) "> </ form >
180176
181177 < div ng-show ="ngform.$valid "> < em > Form is valid</ em > </ div >
182178 < div ng-show ="ngform.$invalid "> < em > Form is not valid</ em > </ div >
@@ -245,10 +241,6 @@ <h3>Schema</h3>
245241< script type ="text/javascript " src ="../bower_components/angular-ui-ace/ui-ace.js "> </ script >
246242< script type ="text/javascript " src ="../bower_components/objectpath/lib/ObjectPath.js "> </ script >
247243<!--
248- <script type="text/javascript" src="../bower_components/pickadate/lib/picker.js"></script>
249- <script type="text/javascript" src="../bower_components/pickadate/lib/picker.date.js"></script>
250- <script type="text/javascript" src="../bower_components/pickadate/lib/translations/nl_NL.js"></script>
251-
252244<script type="text/javascript" src="../bower_components/spectrum/spectrum.js"></script>
253245<script type="text/javascript" src="../bower_components/spectrum/i18n/jquery.spectrum-sv.js"></script>
254246<script type="text/javascript" src="../bower_components/angular-spectrum-colorpicker/dist/angular-spectrum-colorpicker.min.js"></script>
@@ -284,10 +276,10 @@ <h3>Schema</h3>
284276} ) ;
285277
286278
287- app . controller ( 'TestCtrl' , function ( $scope , $http , $location ) {
279+ app . controller ( 'TestCtrl' , function ( $scope , $http , $location , $timeout , $q ) {
288280
289281 $scope . tests = [
290- /* { name: "Autocomplete", data: 'data/autocomplete.json' },*/
282+ { name : "Autocomplete" , data : 'data/autocomplete.json' } ,
291283 { name : "Simple" , data : 'data/simple.json' } ,
292284 { name : "Basic JSON Schema Type" , data : 'data/types.json' } ,
293285 { name : "TitleMap Examples" , data : 'data/titlemaps.json' } ,
@@ -300,6 +292,106 @@ <h3>Schema</h3>
300292 { name : "Hack: Conditional required" , data : 'data/conditional-required.json' } ,
301293 ] ;
302294
295+ /////////////////////////////////////////////////////////////////////////
296+ //// Autocomplete code //////////////////////////////////////////////////
297+ $scope . arnieFlix = loadFlix ( ) ;
298+ $scope . searchText = null ;
299+ $scope . simulateQuery = false ;
300+ $scope . querySearch = querySearch ;
301+ $scope . info = function ( t ) {
302+ console . info ( t ) ;
303+ } ;
304+ /**
305+ * Search for arnieFlix... use $timeout to simulate
306+ * remote dataservice call.
307+ */
308+ function querySearch ( query ) {
309+ var results = query ? $scope . arnieFlix . filter ( createFilterFor ( query ) ) : $scope . arnieFlix ,
310+ deferred ;
311+ if ( $scope . simulateQuery ) {
312+ deferred = $q . defer ( ) ;
313+ $timeout ( function ( ) { deferred . resolve ( results ) ; } , Math . random ( ) * 1000 , false ) ;
314+ return deferred . promise ;
315+ } else {
316+ return results ;
317+ }
318+ } ;
319+
320+ /**
321+ * Create filter function for a query string
322+ */
323+ function createFilterFor ( query ) {
324+ var lowercaseQuery = angular . lowercase ( query ) ;
325+ return function filterFn ( item ) {
326+ return ( item . value . indexOf ( lowercaseQuery ) === 0 ) ;
327+ } ;
328+ } ;
329+
330+ function loadFlix ( ) {
331+ var films = [
332+ { "year" : undefined , "title" : "The Legend of Conan" } ,
333+ { "year" : undefined , "title" : "Triplets" } ,
334+ { "year" : 2015 , "title" : "Terminator Genisys" } ,
335+ { "year" : 2015 , "title" : "Maggie" } ,
336+ { "year" : 2014 , "title" : "The Expendables 3" } ,
337+ { "year" : 2014 , "title" : "Sabotage" } ,
338+ { "year" : 2013 , "title" : "Escape Plan" } ,
339+ { "year" : 2013 , "title" : "The Last Stand" } ,
340+ { "year" : 2012 , "title" : "The Expendables 2" } ,
341+ { "year" : 2010 , "title" : "The Expendables" } ,
342+ { "year" : 2005 , "title" : "The Kid & I" } ,
343+ { "year" : 2004 , "title" : "Around the World in 80 Days" } ,
344+ { "year" : 2003 , "title" : "Welcome to the Jungle" } ,
345+ { "year" : 2003 , "title" : "Terminator 3: Rise of the Machines" } ,
346+ { "year" : 2002 , "title" : "Collateral Damage" } ,
347+ { "year" : 2000 , "title" : "The 6th Day" } ,
348+ { "year" : 1999 , "title" : "End of Days" } ,
349+ { "year" : 1997 , "title" : "Batman & Robin" } ,
350+ { "year" : 1996 , "title" : "Jingle All the Way" } ,
351+ { "year" : 1996 , "title" : "Eraser" } ,
352+ { "year" : 1994 , "title" : "Junior" } ,
353+ { "year" : 1994 , "title" : "True Lies" } ,
354+ { "year" : 1993 , "title" : "Last Action Hero" } ,
355+ { "year" : 1993 , "title" : "Dave" } ,
356+ { "year" : 1991 , "title" : "Terminator 2: Judgment Day" } ,
357+ { "year" : 1990 , "title" : "Kindergarten Cop" } ,
358+ { "year" : 1990 , "title" : "Total Recall" } ,
359+ { "year" : 1988 , "title" : "Twins" } ,
360+ { "year" : 1988 , "title" : "Red Heat" } ,
361+ { "year" : 1987 , "title" : "The Running Man" } ,
362+ { "year" : 1987 , "title" : "Predator" } ,
363+ { "year" : 1986 , "title" : "Raw Deal" } ,
364+ { "year" : 1985 , "title" : "Commando" } ,
365+ { "year" : 1985 , "title" : "Red Sonja" } ,
366+ { "year" : 1984 , "title" : "The Terminator" } ,
367+ { "year" : 1984 , "title" : "Conan the Destroyer" } ,
368+ { "year" : 1982 , "title" : "Conan the Barbarian" } ,
369+ { "year" : 1980 , "title" : "The Jayne Mansfield Story" } ,
370+ { "year" : 1979 , "title" : "Scavenger Hunt" } ,
371+ { "year" : 1979 , "title" : "The Villain" } ,
372+ { "year" : 1976 , "title" : "Stay Hungry" } ,
373+ { "year" : 1974 , "title" : "Happy Anniversary and Goodbye" } ,
374+ { "year" : 1973 , "title" : "The Long Goodbye" } ,
375+ { "year" : 1969 , "title" : "Hercules in New York" } ,
376+ { "year" : 1969 , "title" : "Hercules" }
377+ ] ;
378+ return films . map ( function ( film ) {
379+ film . name = film . title ;
380+ film . value = film . title . toLowerCase ( ) ;
381+ return film ;
382+ } ) ;
383+ } ;
384+
385+ // $scope.autocompleteTmpl = `
386+ // <span class="item-year">
387+ // <span> {{item.year}} </span>
388+ // </span>
389+ // <span class="item-title">
390+ // <strong>{{item.title}}</strong>
391+ // </span>`;
392+ //// Autocomplete code end //////////////////////////////////////////////
393+ /////////////////////////////////////////////////////////////////////////
394+
303395 $scope . navbarMode = 'default' ;
304396 //$scope.hasFlash = swfobject.hasFlashPlayerVersion('9');
305397
0 commit comments