-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
651 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
.npmrc | ||
.tmp | ||
.DS_Store | ||
Thumbs.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>floating label field input</title> | ||
<link rel="stylesheet" type="text/css" href="normalize.css"> | ||
<script src="demo.js"></script> | ||
<style type="text/css" media="screen"> | ||
body { | ||
font-size: 12px; | ||
padding: 10px | ||
} | ||
.bottom { | ||
position: absolute; | ||
bottom: 0; | ||
} | ||
|
||
.label { | ||
padding: 4px 4px 4px 0; | ||
} | ||
|
||
.message { | ||
/*position: absolute; | ||
top: 0;*/ | ||
display: inline-block; | ||
padding: 2px 4px 2px 4px; | ||
} | ||
|
||
.message p { | ||
margin: 0; | ||
} | ||
|
||
.message-error { | ||
background: pink; | ||
border-radius: 2px; | ||
z-index: -1; | ||
color: crimson; | ||
} | ||
|
||
.float-container { | ||
position: relative; | ||
height: 48px; | ||
display: block; | ||
} | ||
|
||
.floating-label { | ||
z-index: -1; | ||
font-weight: bold; | ||
display: inline-block; | ||
position: absolute; | ||
top: 30px; | ||
visibility: none; | ||
-webkit-transition: top .2s; | ||
transition: top .2s; | ||
} | ||
|
||
.floating-label.floating { | ||
display: inline-block; | ||
visibility: visible; | ||
top: 5px; | ||
} | ||
|
||
.div-table { | ||
display: table; | ||
} | ||
.div-row { | ||
display: table-row; | ||
} | ||
.div-cell { | ||
display: table-cell; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="target"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
var AmpersandView = require( 'ampersand-view' ), | ||
AmpersandForm = require( 'ampersand-form-view' ), | ||
Input = require('ampersand-input-view'), | ||
FloatingInput = require( '../ampersand-floatinglabel-input-view' ), | ||
domready = require('domready'), | ||
view; | ||
|
||
var DemoView = AmpersandView.extend({ | ||
template: [ | ||
'<div>', | ||
'<form method="POST" action="/login" role="form" data-target="form">', | ||
'<div data-hook="floatme"></div>', | ||
'</form>', | ||
'</div>' | ||
].join(''), | ||
render: function() { | ||
'use strict'; | ||
view = this; | ||
|
||
this.renderWithTemplate(); | ||
|
||
this.form = new AmpersandForm({ | ||
autoAppend: false, | ||
el: this.query( 'form' ), | ||
submitCallback: function( data ) { | ||
console.log( 'here\'s your data!:' ); | ||
console.dir( data ); | ||
}, | ||
validCallback: function( data ) { | ||
console.log( "am i valid form?: " + data ); | ||
}, | ||
fields: [ | ||
new FloatingInput({ | ||
template: [ | ||
'<div class="float-container">', | ||
'<input class="bottom form-input">', | ||
'<div class="floating-label div-table" data-hook="label-container">', | ||
'<div class="div-row">', | ||
'<span class="label div-cell" data-hook="label"></span>', | ||
'<span class="div-cell message message-error" data-hook="message-container message-text"></span>', | ||
'</div>', | ||
'</div>', | ||
'</div>' | ||
].join(''), | ||
labelClass: 'floating', | ||
el: view.queryByHook('floatme'), | ||
type: 'email', | ||
name: 'email', | ||
label: 'Email', | ||
placeholder: 'Email', | ||
required: false, | ||
tests: [ | ||
function( val ) { | ||
if ( val.length < 5 ) { | ||
return 'Your email must be at least 5 characters'; | ||
} | ||
} | ||
] | ||
}) | ||
// new FloatingInput({ | ||
// el: view.queryByHook('floatme'), | ||
// name: 'test', | ||
// label: 'Test label', | ||
// value: 'Test value' | ||
// }) | ||
] | ||
}); | ||
|
||
this.registerSubview( this.form ); | ||
} | ||
}); | ||
|
||
domready(function() { | ||
var demoView = new DemoView({ | ||
el: window.document.getElementById('target') | ||
}); | ||
demoView.render(); | ||
view.form._fieldViewsArray[0].render() | ||
}); |
Oops, something went wrong.