Commit f5e7dc5f authored by Olga Brani's avatar Olga Brani
Browse files

astakos: Add placeholder to inputs with no label

parent dcd21004
......@@ -23,7 +23,7 @@ form .form-row.submit { margin: 22px 0 ;}
form .form-row .extra-link { color: #808080; text-decoration: none; border: none; margin-top:15px; line-height:98%; display:inline-block; padding-top:15px; float: right; position:absolute; right:0; top:0; }
form .form-row .extra-link:hover { border-bottom:1px solid #9e9e9e;}
form .form-row label { font-size: 1.077em; }
form.innerlabels label { position: absolute; bottom: 11px; left: 1.5em; color: #808080 ; }
form.innerlabels label { display: none;}
form.innerlabels p { margin:0; position: relative;}
form.innerlabels p.p15px { font-size:1.154em;}
form.innerlabels p.p15px a { margin:0 5px;}
......@@ -229,3 +229,22 @@ form .refresh.open p:hover span.extra-img:hover { background-position: -33px -5
form.withlabels.upperlabels label { text-transform: uppercase;}
form.withlabels.upperlabels textarea { margin-top:10px;}
form.innerlabels input::-webkit-input-placeholder {
color: #808080;
font-style: normal;
}
form.innerlabels input:-moz-placeholder { /* Firefox 18- */
color: #808080;
font-style: normal;
}
form.innerlabels input::-moz-placeholder { /* Firefox 19+ */
color: #808080;
font-style: normal;
}
form.innerlabels input:-ms-input-placeholder {
color: #808080;
font-style: normal;
}
......@@ -398,17 +398,18 @@ $(document).ready(function() {
$('.hidden-submit .form-row.submit').slideDown(500);
});
setTimeout(function() {
var innerInputs = $('form.innerlabels input[type="text"], form.innerlabels input[type="password"]');
_.each(innerInputs, function(val, key,list){
if ($(val).val()){
$(val).siblings('label').css('opacity','0');
};
});
}, 200);
var innerInputs = $('form.innerlabels input[type="text"], form.innerlabels input[type="password"]');
_.each(innerInputs, function(val, key, list){
var txt = $(val).siblings('label').text();
$(val).attr('placeholder',txt);
});
$(function() {
$('input, textarea').placeholder();
});
// landing-page initialization
// landing-page initialization
if ($('.landing-page').length > 0) {
var wrapper = $(".landing-page");
var services = wrapper.find(".landing-service");
......
/*! http://mths.be/placeholder v2.0.7 by @mathias */
;(function(window, document, $) {
// Opera Mini v7 doesn’t support placeholder although its DOM seems to indicate so
var isOperaMini = Object.prototype.toString.call(window.operamini) == '[object OperaMini]';
var isInputSupported = 'placeholder' in document.createElement('input') && !isOperaMini;
var isTextareaSupported = 'placeholder' in document.createElement('textarea') && !isOperaMini;
var prototype = $.fn;
var valHooks = $.valHooks;
var propHooks = $.propHooks;
var hooks;
var placeholder;
if (isInputSupported && isTextareaSupported) {
placeholder = prototype.placeholder = function() {
return this;
};
placeholder.input = placeholder.textarea = true;
} else {
placeholder = prototype.placeholder = function() {
var $this = this;
$this
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
.not('.placeholder')
.bind({
'focus.placeholder': clearPlaceholder,
'blur.placeholder': setPlaceholder
})
.data('placeholder-enabled', true)
.trigger('blur.placeholder');
return $this;
};
placeholder.input = isInputSupported;
placeholder.textarea = isTextareaSupported;
hooks = {
'get': function(element) {
var $element = $(element);
var $passwordInput = $element.data('placeholder-password');
if ($passwordInput) {
return $passwordInput[0].value;
}
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
},
'set': function(element, value) {
var $element = $(element);
var $passwordInput = $element.data('placeholder-password');
if ($passwordInput) {
return $passwordInput[0].value = value;
}
if (!$element.data('placeholder-enabled')) {
return element.value = value;
}
if (value == '') {
element.value = value;
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
if (element != safeActiveElement()) {
// We can't use `triggerHandler` here because of dummy text/password inputs :(
setPlaceholder.call(element);
}
} else if ($element.hasClass('placeholder')) {
clearPlaceholder.call(element, true, value) || (element.value = value);
} else {
element.value = value;
}
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
return $element;
}
};
if (!isInputSupported) {
valHooks.input = hooks;
propHooks.value = hooks;
}
if (!isTextareaSupported) {
valHooks.textarea = hooks;
propHooks.value = hooks;
}
$(function() {
// Look for forms
$(document).delegate('form', 'submit.placeholder', function() {
// Clear the placeholder values so they don't get submitted
var $inputs = $('.placeholder', this).each(clearPlaceholder);
setTimeout(function() {
$inputs.each(setPlaceholder);
}, 10);
});
});
// Clear placeholder values upon page reload
$(window).bind('beforeunload.placeholder', function() {
$('.placeholder').each(function() {
this.value = '';
});
});
}
function args(elem) {
// Return an object of element attributes
var newAttrs = {};
var rinlinejQuery = /^jQuery\d+$/;
$.each(elem.attributes, function(i, attr) {
if (attr.specified && !rinlinejQuery.test(attr.name)) {
newAttrs[attr.name] = attr.value;
}
});
return newAttrs;
}
function clearPlaceholder(event, value) {
var input = this;
var $input = $(input);
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
if ($input.data('placeholder-password')) {
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
// If `clearPlaceholder` was called from `$.valHooks.input.set`
if (event === true) {
return $input[0].value = value;
}
$input.focus();
} else {
input.value = '';
$input.removeClass('placeholder');
input == safeActiveElement() && input.select();
}
}
}
function setPlaceholder() {
var $replacement;
var input = this;
var $input = $(input);
var id = this.id;
if (input.value == '') {
if (input.type == 'password') {
if (!$input.data('placeholder-textinput')) {
try {
$replacement = $input.clone().attr({ 'type': 'text' });
} catch(e) {
$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
}
$replacement
.removeAttr('name')
.data({
'placeholder-password': $input,
'placeholder-id': id
})
.bind('focus.placeholder', clearPlaceholder);
$input
.data({
'placeholder-textinput': $replacement,
'placeholder-id': id
})
.before($replacement);
}
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
// Note: `$input[0] != input` now!
}
$input.addClass('placeholder');
$input[0].value = $input.attr('placeholder');
} else {
$input.removeClass('placeholder');
}
}
function safeActiveElement() {
// Avoid IE9 `document.activeElement` of death
// https://github.com/mathiasbynens/jquery-placeholder/pull/99
try {
return document.activeElement;
} catch (err) {}
}
}(this, document, jQuery));
\ No newline at end of file
......@@ -48,7 +48,6 @@
<script src="{{ IM_STATIC_URL }}js/os.js"></script>
<script src="{{ IM_STATIC_URL }}js/modernizr-2.0.6.js"></script>
<script src="{{ IM_STATIC_URL }}js/jquery.js"></script>
<script src="{{ IM_STATIC_URL }}js/jquery.infieldlabel.js"></script>
<script src="{{ IM_STATIC_URL }}js/forms.js"></script>
<script src="{{ IM_STATIC_URL }}js/jquery.dropkick-1.0.0.js"></script>
<script src="{{ IM_STATIC_URL }}js/jquery-ui-1.8.21.custom.min.js"></script>
......@@ -58,13 +57,13 @@
<script src="{{ IM_STATIC_URL }}js/jquery.dataTables.js"></script>
<script src="{{ IM_STATIC_URL }}js/dataTables.date.js"></script>
<script src="{{ IM_STATIC_URL }}js/dataTables.numbersHTML.js"></script>
<script src="{{ IM_STATIC_URL }}js/jquery.placeholder.js"></script>
<script src="{{ IM_STATIC_URL }}js/common.js"></script>
{% endblock headjs %}
{% block endhead %}{% endblock endhead %}
<script type="text/javascript">
$(document).ready(function() {
$("form.innerlabels label").inFieldLabels();
$("form").each(function(){
if ($(this).hasClass("login")) { return }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment