From 42a6e75a5bef01456f8514fcef6333a307ccf29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Mon, 15 Apr 2013 12:21:01 -0400 Subject: [PATCH 1/4] Comments the deform.load since it's documented that the HTML should call it. Since this script needs to be loaded before the HTML, using `$` here impedes that we place the jquery script at the end of the page. --- deform/static/scripts/deform.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/deform/static/scripts/deform.js b/deform/static/scripts/deform.js index 521f3c31..97c2bafc 100644 --- a/deform/static/scripts/deform.js +++ b/deform/static/scripts/deform.js @@ -4,9 +4,24 @@ * to include the call at the end of the page. */ -$(document).ready(function(){ - deform.load(); -}); + + +// XXX: Since `deform` is needed for things like autocompletion, but the deform +// holds this callbacks until load, it's desirabled to load jquery and +// jquery-ui at the end of the page. But placing this, requires that jquery is +// loaded before this tiny script. Since, it's documented that you should call +// deform.load() this is probably redundant. See: +// http://docs.pylonsproject.org/projects/deform/en/latest/basics.html#serving-up-the-rendered-form +// +// "The JavaScript function deform.load() must be called by the HTML page +// (usually in a script tag near the end of the page, ala +// deform.load()) which renders a Deform form in order +// for widgets which use JavaScript to do proper event and behavior +// binding." +// +// $(document).ready(function(){ +// deform.load(); +// }); var deform_loaded = false; From ac1c3708fb3c58e9737a65f2c3599fc47095965a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Mon, 6 May 2013 17:18:42 -0400 Subject: [PATCH 2/4] Totally removing the call to deform.load() --- deform/static/scripts/deform.js | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/deform/static/scripts/deform.js b/deform/static/scripts/deform.js index 97c2bafc..ffbc383f 100644 --- a/deform/static/scripts/deform.js +++ b/deform/static/scripts/deform.js @@ -1,29 +1,9 @@ -/* - * Register a top-level callback to the deform.load() function +/* + * Register a top-level callback to the deform.load() function * this will be called when the DOM has finished loading. No need * to include the call at the end of the page. */ - - -// XXX: Since `deform` is needed for things like autocompletion, but the deform -// holds this callbacks until load, it's desirabled to load jquery and -// jquery-ui at the end of the page. But placing this, requires that jquery is -// loaded before this tiny script. Since, it's documented that you should call -// deform.load() this is probably redundant. See: -// http://docs.pylonsproject.org/projects/deform/en/latest/basics.html#serving-up-the-rendered-form -// -// "The JavaScript function deform.load() must be called by the HTML page -// (usually in a script tag near the end of the page, ala -// deform.load()) which renders a Deform form in order -// for widgets which use JavaScript to do proper event and behavior -// binding." -// -// $(document).ready(function(){ -// deform.load(); -// }); - - var deform_loaded = false; var deform = { From f5aee9ad6009b55e60b509a1005429ca64c933be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Mon, 7 Oct 2013 10:09:17 -0400 Subject: [PATCH 3/4] Removes invalid reintroduced comment --- deform/static/scripts/deform.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/deform/static/scripts/deform.js b/deform/static/scripts/deform.js index 2f9bea40..6932fefc 100644 --- a/deform/static/scripts/deform.js +++ b/deform/static/scripts/deform.js @@ -1,9 +1,3 @@ -/* - * Register a top-level callback to the deform.load() function - * this will be called when the DOM has finished loading. No need - * to include the call at the end of the page. - */ - var deform_loaded = false; var deform = { From bf719062c8b6990e6875806d761f9ac03f00386f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Mon, 7 Oct 2013 10:14:38 -0400 Subject: [PATCH 4/4] Removes traling spaces --- deform/static/scripts/deform.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/deform/static/scripts/deform.js b/deform/static/scripts/deform.js index 6932fefc..4e26f4a1 100644 --- a/deform/static/scripts/deform.js +++ b/deform/static/scripts/deform.js @@ -19,7 +19,7 @@ var deform = { deform_loaded = true; }}); }, - + processCallbacks: function () { $(deform.callbacks).each(function(num, item) { @@ -38,7 +38,7 @@ var deform = { // In order to avoid breaking accessibility: // // - Find each tag within the prototype node with an id - // that has the string ``deformField(\d+)`` within it, and modify + // that has the string ``deformField(\d+)`` within it, and modify // its id to have a random component. // - For each label referencing an change id, change the label's // for attribute to the new id. @@ -53,7 +53,7 @@ var deform = { var genid = deform.randomString(6); var idmap = {}; - // replace ids containing ``deformField`` and associated label for= + // replace ids containing ``deformField`` and associated label for= // items which point at them $idnodes.each(function(idx, node) { @@ -82,7 +82,7 @@ var deform = { var oid = item[0]; var callback = item[1]; var newid = idmap[oid]; - if (newid) { + if (newid) { callback(newid); } }); @@ -103,10 +103,10 @@ var deform = { var max_len = parseInt($before_node.attr('max_len')||'9999', 10); var now_len = parseInt($before_node.attr('now_len')||'0', 10); var orderable = parseInt($before_node.attr('orderable')||'0', 10); - + if (now_len < max_len) { deform.addSequenceItem($proto_node, $before_node); - deform.processSequenceButtons($oid_node, min_len, max_len, + deform.processSequenceButtons($oid_node, min_len, max_len, now_len + 1, orderable); } return false; @@ -123,7 +123,7 @@ var deform = { if (now_len > min_len) { $before_node.attr('now_len', now_len - 1); $item_node.remove(); - deform.processSequenceButtons($oid_node, min_len, max_len, + deform.processSequenceButtons($oid_node, min_len, max_len, now_len-1, orderable); } // we removed something from the dom, trigger a change event @@ -154,9 +154,9 @@ var deform = { if (input) { var raw = input.get(0); if (raw) { - if (raw.type === 'text' || raw.type === 'file' || - raw.type == 'password' || raw.type == 'text' || - raw.type == 'textarea') { + if (raw.type === 'text' || raw.type === 'file' || + raw.type == 'password' || raw.type == 'text' || + raw.type == 'textarea') { if (!input.hasClass("hasDatepicker")) { input.focus(); } @@ -168,11 +168,11 @@ var deform = { randomString: function (length) { var chr='0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'; chr = chr.split(''); - + if (! length) { length = Math.floor(Math.random() * chr.length); } - + var str = ''; for (var i = 0; i < length; i++) { str += chr[Math.floor(Math.random() * chr.length)];