Added character restrictions, Usage: add attribute "restrict=[\'max\']" in the DOM
This commit is contained in:
parent
bc3aa5ce81
commit
73c53370a4
@ -21,7 +21,7 @@ Tag { Always spaces between values
|
|||||||
Animation related items
|
Animation related items
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@import url(https://fonts.googleapis.com/css?family=Raleway:200,400,600);
|
@import url(https://fonts.googleapis.com/css?family=Raleway:200,300italic,400,600);
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-family: 'Raleway';
|
font-family: 'Raleway';
|
||||||
@ -373,7 +373,7 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fa-times-circle-o:active {
|
.fa-times-circle-o:active {
|
||||||
color: #ff1A1A;
|
color: #FF1A1A;
|
||||||
|
|
||||||
-webkit-transition: background-color 0.2s ease;
|
-webkit-transition: background-color 0.2s ease;
|
||||||
-moz-transition: background-color 0.2s ease;
|
-moz-transition: background-color 0.2s ease;
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
#motdBox span {
|
#motdBox span {
|
||||||
font-size: 130% !important;
|
font-size: 130% !important;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: #FFF !important;
|
color: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
@ -276,3 +276,11 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#restrict {
|
||||||
|
font-size: 100%;
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: 300;
|
||||||
|
padding-left: 1%;
|
||||||
|
color: #999 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<div id="profBanner" style="{{banner}};"></div>
|
<div id="profBanner" style="{{banner}};"></div>
|
||||||
<div id="profAvatar" style="{{avatar}};{{avatarDim}}"></div>
|
<div id="profAvatar" style="{{avatar}};{{avatarDim}}"></div>
|
||||||
<div id="motdBox">
|
<div id="motdBox">
|
||||||
<span class="username">{{username}} - </span><span class="change mo" id="motd">{{motd}}</span>
|
<span class="username">{{username}} - </span><span class="change mo" restrict="50" id="motd">{{motd}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="profCards">
|
<div id="profCards">
|
||||||
<div id="profInfo" class="card" style="background-color:{{divColor 'cards'}}">
|
<div id="profInfo" class="card" style="background-color:{{divColor 'cards'}}">
|
||||||
|
|||||||
@ -155,7 +155,6 @@ Template.profile.events({
|
|||||||
|
|
||||||
if(ele.getAttribute("type") !== null) {
|
if(ele.getAttribute("type") !== null) {
|
||||||
input.type = ele.getAttribute("type");
|
input.type = ele.getAttribute("type");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
input.type = "text";
|
input.type = "text";
|
||||||
}
|
}
|
||||||
@ -173,6 +172,17 @@ Template.profile.events({
|
|||||||
input.select();
|
input.select();
|
||||||
}
|
}
|
||||||
input.focus();
|
input.focus();
|
||||||
|
if(ele.getAttribute("restrict") !== null) {
|
||||||
|
var span = document.createElement("span");
|
||||||
|
span.id = "restrict";
|
||||||
|
var num = parseInt(ele.getAttribute("restrict"))-input.value.length;
|
||||||
|
if(num <= 0) {
|
||||||
|
span.style.setProperty("color","#FF1A1A","important");
|
||||||
|
num = 0;
|
||||||
|
}
|
||||||
|
span.appendChild(document.createTextNode(num.toString()+" characters left"));
|
||||||
|
ele.parentNode.appendChild(span);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'click' (event) {
|
'click' (event) {
|
||||||
var sessval = Session.get("modifying");
|
var sessval = Session.get("modifying");
|
||||||
@ -183,13 +193,30 @@ Template.profile.events({
|
|||||||
closeDivFade(document.getElementsByClassName("profOptions")[Session.get("radioDiv")]);
|
closeDivFade(document.getElementsByClassName("profOptions")[Session.get("radioDiv")]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'keyup' (event) {
|
'keydown' (event) {
|
||||||
var sessval = Session.get("modifying");
|
var sessval = Session.get("modifying");
|
||||||
if(event.keyCode == 13) {
|
if(event.keyCode == 13) {
|
||||||
try {
|
try {
|
||||||
closeInput(sessval);
|
closeInput(sessval);
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
}
|
}
|
||||||
|
var restrict = document.getElementById(sessval).getAttribute("restrict");
|
||||||
|
if(restrict !== null) {
|
||||||
|
var num = parseInt(restrict)-event.target.value.length;
|
||||||
|
var restext = document.getElementById("restrict");
|
||||||
|
if(num === 1) {
|
||||||
|
restext.childNodes[0].nodeValue = num.toString()+" character left";
|
||||||
|
restext.style.setProperty("color","#999","important");
|
||||||
|
} else if(num <= 0) {
|
||||||
|
var input = document.getElementById(sessval+"a");
|
||||||
|
input.value = input.value.substring(0,parseInt(restrict));
|
||||||
|
restext.childNodes[0].nodeValue = "0 characters left";
|
||||||
|
restext.style.setProperty("color","#FF1A1A","important");
|
||||||
|
} else {
|
||||||
|
restext.childNodes[0].nodeValue = num.toString()+" characters left";
|
||||||
|
restext.style.setProperty("color","#999","important");
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'click .radio' (event) {
|
'click .radio' (event) {
|
||||||
Session.set("radioDiv", event.target.getAttribute("op"));
|
Session.set("radioDiv", event.target.getAttribute("op"));
|
||||||
@ -235,7 +262,7 @@ Template.profile.events({
|
|||||||
'click .fa-times-thin' () {
|
'click .fa-times-thin' () {
|
||||||
Session.set("searching",false);
|
Session.set("searching",false);
|
||||||
},
|
},
|
||||||
'keyup #profClassSearch' (event) {
|
'keydown #profClassSearch' (event) {
|
||||||
if(event.target.value === "") {
|
if(event.target.value === "") {
|
||||||
Session.set("notsearching",true);
|
Session.set("notsearching",true);
|
||||||
} else {
|
} else {
|
||||||
@ -299,6 +326,10 @@ function closeInput(sessval) {
|
|||||||
var input = document.getElementById(sessval+"a");
|
var input = document.getElementById(sessval+"a");
|
||||||
var span = document.getElementById(sessval);
|
var span = document.getElementById(sessval);
|
||||||
input.parentNode.removeChild(input);
|
input.parentNode.removeChild(input);
|
||||||
|
try{
|
||||||
|
var restrict = document.getElementById("restrict");
|
||||||
|
restrict.parentNode.removeChild(restrict)
|
||||||
|
} catch(err) {}
|
||||||
if(input.value == "") {
|
if(input.value == "") {
|
||||||
span.childNodes[0].nodeValue = "Click here to edit...";
|
span.childNodes[0].nodeValue = "Click here to edit...";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ Meteor.methods({
|
|||||||
current.avatar = change[3];
|
current.avatar = change[3];
|
||||||
current.banner = change[4];
|
current.banner = change[4];
|
||||||
if (schools.findOne({name:current.school}) != null && Number.isInteger(current.grade) &&
|
if (schools.findOne({name:current.school}) != null && Number.isInteger(current.grade) &&
|
||||||
current.grade >= 9 && current.grade <= 12 && current.description.length <= 100) {
|
current.grade >= 9 && current.grade <= 12 && current.description.length <= 50) {
|
||||||
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user