Skip to content
Browse files

updated netteForms & Adminer

  • Loading branch information...
1 parent 4c9defd commit c4200560d6a53fea89a68bb5fbff022d00bd17ca @dg dg committed
Showing with 962 additions and 1,160 deletions.
  1. +905 −1,131 www/adminer/index.php
  2. +57 −29 www/js/netteForms.js
View
2,036 www/adminer/index.php
905 additions, 1,131 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
86 www/js/netteForms.js
@@ -79,15 +79,21 @@ Nette.validateControl = function(elem, rules, onlyCheck) {
var el = rule.control ? elem.form.elements[rule.control] : elem;
var success = Nette.validateRule(el, rule.op, rule.arg);
- if (success === null) { continue; }
- if (rule.neg) { success = !success; }
+ if (success === null) {
+ continue;
+ }
+ if (rule.neg) {
+ success = !success;
+ }
if (rule.condition && success) {
if (!Nette.validateControl(elem, rule.rules, onlyCheck)) {
return false;
}
} else if (!rule.condition && !success) {
- if (el.disabled) { continue; }
+ if (el.disabled) {
+ continue;
+ }
if (!onlyCheck) {
Nette.addError(el, rule.msg.replace('%value', Nette.getValue(el)));
}
@@ -142,7 +148,9 @@ Nette.validateRule = function(elem, op, arg) {
var val = Nette.getValue(elem);
if (elem.getAttribute) {
- if (val === elem.getAttribute('data-nette-empty-value')) { val = ''; }
+ if (val === elem.getAttribute('data-nette-empty-value')) {
+ val = '';
+ }
}
if (op.charAt(0) === ':') {
@@ -191,7 +199,7 @@ Nette.validators = {
},
email: function(elem, arg, val) {
- return (/^("([ !\x23-\x5B\x5D-\x7E]*|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF][-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF]$/i).test(val);
+ return (/^("([ !\x23-\x5B\x5D-\x7E]*|\\[ -~])+"|[-a-z0-9!#$%&'*+\/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+\/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF][-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF]$/i).test(val);
},
url: function(elem, arg, val) {
@@ -226,6 +234,10 @@ Nette.validators = {
submitted: function(elem, arg, val) {
return elem.form['nette-submittedBy'] === elem;
+ },
+
+ fileSize: function(elem, arg, val) {
+ return window.FileList ? elem.files[0].size <= arg : true;
}
};
@@ -247,19 +259,27 @@ Nette.toggleForm = function(form) {
*/
Nette.toggleControl = function(elem, rules, firsttime) {
rules = rules || eval('[' + (elem.getAttribute('data-nette-rules') || '') + ']');
- var has = false, __hasProp = Object.prototype.hasOwnProperty, handler = function() { Nette.toggleForm(elem.form); };
+ var has = false, __hasProp = Object.prototype.hasOwnProperty, handler = function() {
+ Nette.toggleForm(elem.form);
+ };
for (var id = 0, len = rules.length; id < len; id++) {
var rule = rules[id], op = rule.op.match(/(~)?([^?]+)/);
rule.neg = op[1];
rule.op = op[2];
rule.condition = !!rule.rules;
- if (!rule.condition) { continue; }
+ if (!rule.condition) {
+ continue;
+ }
var el = rule.control ? elem.form.elements[rule.control] : elem;
var success = Nette.validateRule(el, rule.op, rule.arg);
- if (success === null) { continue; }
- if (rule.neg) { success = !success; }
+ if (success === null) {
+ continue;
+ }
+ if (rule.neg) {
+ success = !success;
+ }
if (Nette.toggleControl(elem, rule.rules, firsttime) || rule.toggle) {
has = true;
@@ -275,7 +295,9 @@ Nette.toggleControl = function(elem, rules, firsttime) {
}
}
for (var id2 in rule.toggle || []) {
- if (__hasProp.call(rule.toggle, id2)) { Nette.toggle(id2, success ? rule.toggle[id2] : !rule.toggle[id2]); }
+ if (__hasProp.call(rule.toggle, id2)) {
+ Nette.toggle(id2, success ? rule.toggle[id2] : !rule.toggle[id2]);
+ }
}
}
}
@@ -300,8 +322,15 @@ Nette.toggle = function(id, visible) {
Nette.initForm = function(form) {
form.noValidate = 'novalidate';
- Nette.addEvent(form, 'submit', function() {
- return Nette.validateForm(form);
+ Nette.addEvent(form, 'submit', function(e) {
+ if (!Nette.validateForm(form)) {
+ e = e || event;
+ e.cancelBubble = true;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ return false;
+ }
});
Nette.addEvent(form, 'click', function(e) {
@@ -313,23 +342,6 @@ Nette.initForm = function(form) {
for (var i = 0; i < form.elements.length; i++) {
Nette.toggleControl(form.elements[i], null, true);
}
-
- if (/MSIE/.exec(navigator.userAgent)) {
- var labels = {},
- wheelHandler = function() { return false; },
- clickHandler = function() { document.getElementById(this.htmlFor).focus(); return false; };
-
- for (i = 0, elms = form.getElementsByTagName('label'); i < elms.length; i++) {
- labels[elms[i].htmlFor] = elms[i];
- }
-
- for (i = 0, elms = form.getElementsByTagName('select'); i < elms.length; i++) {
- Nette.addEvent(elms[i], 'mousewheel', wheelHandler); // prevents accidental change in IE
- if (labels[elms[i].htmlId]) {
- Nette.addEvent(labels[elms[i].htmlId], 'click', clickHandler); // prevents deselect in IE 5 - 6
- }
- }
- }
};
@@ -346,3 +358,19 @@ Nette.addEvent(window, 'load', function() {
Nette.initForm(document.forms[i]);
}
});
+
+
+/**
+ * Converts string to web safe characters [a-z0-9-] text.
+ */
+Nette.webalize = function(s) {
+ s = s.toLowerCase();
+ var res = '', i, ch;
+ for (i = 0; i < s.length; i++) {
+ ch = Nette.webalizeTable[s.charAt(i)];
+ res += ch ? ch : s.charAt(i);
+ }
+ return res.replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
+};
+
+Nette.webalizeTable = {\u00e1: 'a', \u010d: 'c', \u010f: 'd', \u00e9: 'e', \u011b: 'e', \u00ed: 'i', \u0148: 'n', \u00f3: 'o', \u0159: 'r', \u0161: 's', \u0165: 't', \u00fa: 'u', \u016f: 'u', \u00fd: 'y', \u017e: 'z'};

0 comments on commit c420056

Please sign in to comment.
Something went wrong with that request. Please try again.