public function init() {
$this->view->headScript()->appendFile('js/prototype.js');
- $this->view->headScript()->appendFile('js/forms.js');
- $this->view->headScript()->appendFile('js/highlight.js');
+ $this->view->headScript()->appendFile('js/utils.js');
$this->view->headScript()->appendFile('js/account.js');
$this->view->headLink()->appendStylesheet('css/generic.css');
$this->view->headLink()->appendStylesheet('css/account.css');
public function init() {
$this->view->headScript()->appendFile('js/prototype.js');
- $this->view->headScript()->appendFile('js/forms.js');
- $this->view->headScript()->appendFile('js/highlight.js');
+ $this->view->headScript()->appendFile('js/utils.js');
$this->view->headScript()->appendFile('js/contact.js');
$this->view->headLink()->appendStylesheet('css/generic.css');
$this->view->headLink()->appendStylesheet('css/contact.css');
$this->view->headScript()->appendFile('js/ModifiablePath.js');
$this->view->headScript()->appendFile('js/prototype.js');
$this->view->headScript()->appendFile('js/simplebox.js');
- $this->view->headScript()->appendFile('js/closebtn.js');
- $this->view->headScript()->appendFile('js/highlight.js');
- $this->view->headScript()->appendFile('js/deck.js');
- $this->view->headScript()->appendFile('js/ajaxize.js');
- $this->view->headScript()->appendFile('js/message.js');
+ $this->view->headScript()->appendFile('js/utils.js');
$this->view->headScript()->appendFile('js/syj.js');
$this->view->headLink()->appendStylesheet('css/openlayers/style.css');
$this->view->headLink()->appendStylesheet('css/generic.css');
public function init() {
$this->view->headTitle($this->view->translate("login"));
$this->view->headScript()->appendFile('js/prototype.js');
- $this->view->headScript()->appendFile('js/forms.js');
- $this->view->headScript()->appendFile('js/highlight.js');
+ $this->view->headScript()->appendFile('js/utils.js');
$this->view->headScript()->appendFile('js/login.js');
$this->view->headLink()->appendStylesheet('css/generic.css');
$this->view->headLink()->appendStylesheet('css/login.css');
public function init() {
$this->view->headScript()->appendFile('js/prototype.js');
$this->view->headScript()->appendFile('js/newpwd.js');
- $this->view->headScript()->appendFile('js/highlight.js');
+ $this->view->headScript()->appendFile('js/utils.js');
$this->view->headLink()->appendStylesheet('css/generic.css');
$this->view->headLink()->appendStylesheet('css/newpwd.css');
}
+++ /dev/null
-/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
- and is published under the AGPL license. */
-
-// wrapper around Form.request that sets up the submit listener, stops the
-// submit event, calls presubmit function, calls Form.request and calls a
-// postsubmit function
-Element.addMethods('form', {ajaxize : function(form, options) {
- var reqoptions, timeout;
-
- options = Object.clone(options);
- reqoptions = Object.clone(options);
- timeout = null;
-
- function onSuccess(transport, json) {
- if (timeout) {
- window.clearTimeout(timeout);
- timeout = null;
- }
- if (transport.getStatus() === 0) {
- options.onFailure(transport, json);
- } else {
- options.onSuccess(transport, json);
- }
- }
-
- function onFailure(transport, json) {
- if (timeout) {
- window.clearTimeout(timeout);
- timeout = null;
- }
- options.onFailure(transport, json);
- }
-
- delete(reqoptions.presubmit);
- delete(reqoptions.postsubmit);
-
- $(form).observe('submit', function(evt) {
- var req;
-
- evt.stop(); // cancel form submission
- if (Object.isFunction(options.presubmit)) {
- if (options.presubmit(this) === false) {
- return;
- }
- }
- req = this.request(Object.extend(reqoptions, {
- onSuccess: onSuccess,
- onFailure: onFailure
- }));
- timeout = (function() {
- options.onFailure(null);
- req.abort();
- }).delay(options.timeout || 20);
- if (Object.isFunction(options.postsubmit)) {
- options.postsubmit(this);
- }
- });
-}});
+++ /dev/null
-/* Copyright (c) 2010 Arnaud Renevier, Inc, published under the modified BSD
- * license. */
-
-var CloseBtn = Class.create({
- initialize: function(elt, options) {
- var btn, imgsrc, style;
-
- elt = $(elt);
- if (!elt) {
- return;
- }
-
- style = Object.extend({
- float: "right",
- margin: "2px",
- fontWeight: "bold",
- padding: "0px"
- }, typeof options === "object" ? options.style: {});
-
- imgsrc = (options && options.closeBtnSrc) || "icons/close.png";
- btn = new Element("input", { type: "image", src: imgsrc, alt: "X"}).setStyle(style);
- elt.insert({top: btn});
- btn.observe("click", function(evt) {
- elt.hide();
- });
- }
-});
+++ /dev/null
-/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
- and is published under the AGPL license. */
-var Deck = Class.create();
-Deck.prototype = {
- initialize: function(elt, options) {
- this.element = $(elt);
- this.index = null;
- this.setIndex(parseInt(this.element.readAttribute("selectedindex") || 0, 10));
- },
- setIndex: function(idx) {
- if (idx === this.index) {
- return;
- }
-
- var childs = this.element.childElements();
- if (childs.length === 0) {
- this.index = -1;
- return;
- }
- idx = Math.max(0, idx);
- idx = Math.min(childs.length - 1, idx);
-
- childs.each(function(item, i) {
- if (idx === i) {
- item.show();
- } else {
- item.hide();
- }
- });
- this.index = idx;
- },
- getIndex: function() {
- return this.index;
- }
-};
+++ /dev/null
-/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
- and is published under the AGPL license. */
-Element.addMethods(['input', 'textarea'], {
- check: function(control, callback, errorMessage) {
- if (callback.call(control)) {
- return true;
- }
- control.insert({
- after: new Element("div", {className: 'error'}).update(errorMessage)
- });
- return false;
- }
-});
-
-Element.addMethods('form', {
- focus: function(form) {
- var tofocus, error;
-
- tofocus = null;
- error = form.down('.error');
- if (error) {
- tofocus = error.previous('input,textarea');
- } else {
- tofocus = form.down('input:not([readonly],[disabled]),textarea:not([readonly][disabled])');
- }
- if (tofocus) {
- if (error && (typeof tofocus.highlight === "function")) {
- tofocus.highlight('#F08080');
- }
- tofocus.focus();
- tofocus.select();
- }
- },
-
- checkEmptyElements: function(form, errorMessage) {
- var results = [];
- form.select('.required').each(function(elt) {
- var id = elt.getAttribute('for'), control = $(id);
- if (!control) {
- return;
- }
- if (!control.check(function() {
- return !this.value.strip().empty();
- }, errorMessage)) {
- results.push(control);
- }
- });
- return results;
- }
-
-});
+++ /dev/null
-Element.addMethods({
- highlight: function(element, color, timeout) {
- var current;
- if (typeof timeout === "undefined") {
- timeout = 0.3;
- }
- current = element.getStyle('backgroundColor');
- Element.setStyle(element, {'backgroundColor': color});
- Element.setStyle.delay(timeout, element, {'backgroundColor': current});
- return element;
- }
-});
+++ /dev/null
-/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
- and is published under the AGPL license. */
-Element.addMethods('div', {
- setMessage: function(div, message, status) {
- div.clearMessages();
- if (status) {
- div.setMessageStatus(status);
- }
- if (message) {
- div.addMessage(message);
- }
- return div;
- },
-
- clearMessages: function(div) {
- var node = div.firstChild;
- while (node) {
- var nextNode = node.nextSibling;
- if (node.nodeType == 3 || node.tagName.toLowerCase() == 'br') {
- div.removeChild(node);
- }
- node = nextNode;
- }
-
- return div;
- },
-
- addMessage: function(div, message) {
- var node = (div.ownerDocument || document).createTextNode(message);
- if (!div.empty()) {
- div.insert(new Element('br'));
- }
- div.appendChild(node);
- return div.show();
- },
-
- setMessageStatus: function(div, status) {
- return div.removeClassName('error').
- removeClassName('warn').
- removeClassName('info').
- removeClassName('success').
- addClassName(status);
- }
-});
--- /dev/null
+/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+ and is published under the AGPL license. */
+
+var CloseBtn = Class.create({
+ initialize: function(elt, options) {
+ var btn, imgsrc, style;
+
+ elt = $(elt);
+ if (!elt) {
+ return;
+ }
+
+ style = Object.extend({
+ float: "right",
+ margin: "2px",
+ fontWeight: "bold",
+ padding: "0px"
+ }, typeof options === "object" ? options.style: {});
+
+ imgsrc = (options && options.closeBtnSrc) || "icons/close.png";
+ btn = new Element("input", { type: "image", src: imgsrc, alt: "X"}).setStyle(style);
+ elt.insert({top: btn});
+ btn.observe("click", function(evt) {
+ elt.hide();
+ });
+ }
+});
+
+var Deck = Class.create({
+ initialize: function(elt, options) {
+ this.element = $(elt);
+ this.index = null;
+ this.setIndex(parseInt(this.element.readAttribute("selectedindex") || 0, 10));
+ },
+ setIndex: function(idx) {
+ if (idx === this.index) {
+ return;
+ }
+
+ var childs = this.element.childElements();
+ if (childs.length === 0) {
+ this.index = -1;
+ return;
+ }
+ idx = Math.max(0, idx);
+ idx = Math.min(childs.length - 1, idx);
+
+ childs.each(function(item, i) {
+ if (idx === i) {
+ item.show();
+ } else {
+ item.hide();
+ }
+ });
+ this.index = idx;
+ },
+ getIndex: function() {
+ return this.index;
+ }
+});
+
+Element.addMethods({
+ highlight: function(element, color, timeout) {
+ var current;
+ if (typeof timeout === "undefined") {
+ timeout = 0.3;
+ }
+ current = element.getStyle('backgroundColor');
+ Element.setStyle(element, {'backgroundColor': color});
+ Element.setStyle.delay(timeout, element, {'backgroundColor': current});
+ return element;
+ }
+});
+
+// wrapper around Form.request that sets up the submit listener, stops the
+// submit event, calls presubmit function, calls Form.request and calls a
+// postsubmit function
+Element.addMethods('form', {
+ ajaxize : function(form, options) {
+ var reqoptions, timeout;
+
+ options = Object.clone(options);
+ reqoptions = Object.clone(options);
+ timeout = null;
+
+ function onSuccess(transport, json) {
+ if (timeout) {
+ window.clearTimeout(timeout);
+ timeout = null;
+ }
+ if (transport.getStatus() === 0) {
+ options.onFailure(transport, json);
+ } else {
+ options.onSuccess(transport, json);
+ }
+ }
+
+ function onFailure(transport, json) {
+ if (timeout) {
+ window.clearTimeout(timeout);
+ timeout = null;
+ }
+ options.onFailure(transport, json);
+ }
+
+ delete(reqoptions.presubmit);
+ delete(reqoptions.postsubmit);
+
+ $(form).observe('submit', function(evt) {
+ var req;
+
+ evt.stop(); // cancel form submission
+ if (Object.isFunction(options.presubmit)) {
+ if (options.presubmit(this) === false) {
+ return;
+ }
+ }
+ req = this.request(Object.extend(reqoptions, {
+ onSuccess: onSuccess,
+ onFailure: onFailure
+ }));
+ timeout = (function() {
+ options.onFailure(null);
+ req.abort();
+ }).delay(options.timeout || 20);
+ if (Object.isFunction(options.postsubmit)) {
+ options.postsubmit(this);
+ }
+ });
+ },
+
+ focus: function(form) {
+ var tofocus, error;
+
+ tofocus = null;
+ error = form.down('.error');
+ if (error) {
+ tofocus = error.previous('input,textarea');
+ } else {
+ tofocus = form.down('input:not([readonly],[disabled]),textarea:not([readonly][disabled])');
+ }
+ if (tofocus) {
+ if (error && (typeof tofocus.highlight === "function")) {
+ tofocus.highlight('#F08080');
+ }
+ tofocus.focus();
+ tofocus.select();
+ }
+ },
+
+ checkEmptyElements: function(form, errorMessage) {
+ var results = [];
+ form.select('.required').each(function(elt) {
+ var id = elt.getAttribute('for'), control = $(id);
+ if (!control) {
+ return;
+ }
+ if (!control.check(function() {
+ return !this.value.strip().empty();
+ }, errorMessage)) {
+ results.push(control);
+ }
+ });
+ return results;
+ }
+});
+
+Element.addMethods(['input', 'textarea'], {
+ check: function(control, callback, errorMessage) {
+ if (callback.call(control)) {
+ return true;
+ }
+ control.insert({
+ after: new Element("div", {className: 'error'}).update(errorMessage)
+ });
+ return false;
+ }
+});
+
+Element.addMethods('div', {
+ setMessage: function(div, message, status) {
+ div.clearMessages();
+ if (status) {
+ div.setMessageStatus(status);
+ }
+ if (message) {
+ div.addMessage(message);
+ }
+ return div;
+ },
+
+ clearMessages: function(div) {
+ var node = div.firstChild, nextNode;
+
+ while (node) {
+ nextNode = node.nextSibling;
+ if (node.nodeType === 3 || node.tagName.toLowerCase() === 'br') {
+ div.removeChild(node);
+ }
+ node = nextNode;
+ }
+
+ return div;
+ },
+
+ addMessage: function(div, message) {
+ var node = (div.ownerDocument || document).createTextNode(message);
+ if (!div.empty()) {
+ div.insert(new Element('br'));
+ }
+ div.appendChild(node);
+ return div.show();
+ },
+
+ setMessageStatus: function(div, status) {
+ return div.removeClassName('error').
+ removeClassName('warn').
+ removeClassName('info').
+ removeClassName('success').
+ addClassName(status);
+ }
+});