Skip to content

Commit

Permalink
gallery-2014.02.26-18-54 ItsAsbreuk gallery-itsaformmodel
Browse files Browse the repository at this point in the history
  • Loading branch information
ekashida committed Feb 26, 2014
1 parent 2c28b9f commit 88b43d6
Show file tree
Hide file tree
Showing 36 changed files with 334 additions and 79 deletions.
4 changes: 2 additions & 2 deletions build/gallery-itsaformmodel/gallery-itsaformmodel-coverage.js

Large diffs are not rendered by default.

103 changes: 94 additions & 9 deletions build/gallery-itsaformmodel/gallery-itsaformmodel-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ ITSAFormModel.prototype.initializer = function() {
instance._ATTRS_nodes = {},

/**
* internal backup of which nodeid's have been inserted in the dom before, referenced by nodei's
* internal backup of which nodeid's have been inserted in the dom before, referenced by nodeid's
* object-properties are 'true' when not found the be removed from the dom yet and a timestamps when
* out of the dom (stamped with the time out-of-dom was registered)
* @property _knownNodeIds
Expand Down Expand Up @@ -640,15 +640,15 @@ ITSAFormModel.prototype.disableUI = function() {
* Only to be used when destroyed - or when a containernode gets empty.
*
* @method cleanup
* @param [container] {Y.Node} only cleanup items inside this container
* @protected
* @since 0.1
*/
ITSAFormModel.prototype.cleanup = function() {
// TODO: also destroy the widgets in case their nodeid's are in the dom
ITSAFormModel.prototype.cleanup = function(container) {
var instance = this;
instance._FORM_elements = {};
instance._ATTRS_nodes = {};
instance._knownNodeIds = {};
/*jshint expr:true */
container ? instance._cleanupContainer(container) : instance._cleanup();
/*jshint expr:false */
};

/**
Expand Down Expand Up @@ -1703,7 +1703,7 @@ ITSAFormModel.prototype.translatePromise = ITSAFormModel.translatePromise;
* @since 0.1
*/
ITSAFormModel.prototype.validated = function() {
Y.log('destructor', 'info', 'ITSAFormModel');
Y.log('validated', 'info', 'ITSAFormModel');
return (this.getUnvalidatedUI().size()===0);
};

Expand Down Expand Up @@ -1957,6 +1957,87 @@ ITSAFormModel.prototype._bindUI = function() {

};

/**
* Cleans up internal references of everything the formmodel has inserted in the dom.
* Only to be used when destroyed - or when a containernode gets empty.
*
* @method _cleanup
* @protected
* @private
* @since 0.1
*/
ITSAFormModel.prototype._cleanup = function() {
var instance = this,
formelements = instance.getCurrentFormElements(),
node;
YArray.each(
formelements,
function(formelement) {
/*jshint expr:true */
formelement.widget && formelement.widget.destroy(true);
/*jshint expr:false */
node = Y.one('#'+formelement.nodeid);
if (node) {
node.get('childNodes').destroy(true);
node.remove(true);
}
}
);
instance._FORM_elements = {};
instance._ATTRS_nodes = {};
instance._knownNodeIds = {};
};

/**
* Cleans up internal references of everything the formmodel has inserted inside the container.
* Only to be used when a containernode gets empty.
*
* @method _cleanupContainer
* @param [container] {Y.Node} only cleanup items inside this container
* @protected
* @private
* @since 0.1
*/
ITSAFormModel.prototype._cleanupContainer = function(container) {
var instance = this,
attributenodes = instance._ATTRS_nodes,
formelements = instance._FORM_elements,
knownNodeIds = instance._knownNodeIds,
knowdIdsRemoval = [],
node, formelement, attribute, indexofitem;
YObject.each(
knownNodeIds,
function(value, nodeid) {
formelement = formelements[nodeid];
node = container.one('#'+nodeid);
// remove node
if (node) {
/*jshint expr:true */
formelement.widget && formelement.widget.destroy(true);
/*jshint expr:false */
node.get('childNodes').destroy(true);
node.remove(true);
delete formelements[nodeid];
// now find the inside the array _ATTRS_nodes[attribute] for the item that holds ref. to the nodeid
attribute = formelement.name;
indexofitem = attributenodes[attribute].indexOf(nodeid);
/*jshint expr:true */
indexofitem && attributenodes[attribute].splice(indexofitem, 1);
/*jshint expr:false */
// now store the nodeid, because it has to be removed from instance._knownNodeIds
knowdIdsRemoval.push(nodeid);
}
}
);
// now remove it from knownNodeIds
YArray.each(
knowdIdsRemoval,
function(nodeid) {
delete knownNodeIds[nodeid];
}
);
};

/**
* Cleaning up all eventlisteners
*
Expand Down Expand Up @@ -2034,7 +2115,11 @@ ITSAFormModel.prototype._defFn_changedate = function(e) {
// be carefull: button might not exist anymore, when the view is rerendered
if (node) {
node.removeAttribute(DATA_CONTENT);
node.focus();
try {
// ALWAYS focus nodes using try/catch to prevent js-error when node not in the dom
node.focus();
}
catch(err) {}
tipsycontent = node.getAttribute(DATA+'-contentvalid');
/*jshint expr:true */
tipsycontent && node.setAttribute(DATA_CONTENT, tipsycontent);
Expand Down Expand Up @@ -2720,7 +2805,7 @@ YArray.each(
}
);

}, 'gallery-2014.01.10-22-44', {
}, 'gallery-2014.02.26-18-54', {
"requires": [
"yui-base",
"event-valuechange",
Expand Down
8 changes: 4 additions & 4 deletions build/gallery-itsaformmodel/gallery-itsaformmodel-min.js

Large diffs are not rendered by default.

101 changes: 93 additions & 8 deletions build/gallery-itsaformmodel/gallery-itsaformmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ ITSAFormModel.prototype.initializer = function() {
instance._ATTRS_nodes = {},

/**
* internal backup of which nodeid's have been inserted in the dom before, referenced by nodei's
* internal backup of which nodeid's have been inserted in the dom before, referenced by nodeid's
* object-properties are 'true' when not found the be removed from the dom yet and a timestamps when
* out of the dom (stamped with the time out-of-dom was registered)
* @property _knownNodeIds
Expand Down Expand Up @@ -637,15 +637,15 @@ ITSAFormModel.prototype.disableUI = function() {
* Only to be used when destroyed - or when a containernode gets empty.
*
* @method cleanup
* @param [container] {Y.Node} only cleanup items inside this container
* @protected
* @since 0.1
*/
ITSAFormModel.prototype.cleanup = function() {
// TODO: also destroy the widgets in case their nodeid's are in the dom
ITSAFormModel.prototype.cleanup = function(container) {
var instance = this;
instance._FORM_elements = {};
instance._ATTRS_nodes = {};
instance._knownNodeIds = {};
/*jshint expr:true */
container ? instance._cleanupContainer(container) : instance._cleanup();
/*jshint expr:false */
};

/**
Expand Down Expand Up @@ -1915,6 +1915,87 @@ ITSAFormModel.prototype._bindUI = function() {

};

/**
* Cleans up internal references of everything the formmodel has inserted in the dom.
* Only to be used when destroyed - or when a containernode gets empty.
*
* @method _cleanup
* @protected
* @private
* @since 0.1
*/
ITSAFormModel.prototype._cleanup = function() {
var instance = this,
formelements = instance.getCurrentFormElements(),
node;
YArray.each(
formelements,
function(formelement) {
/*jshint expr:true */
formelement.widget && formelement.widget.destroy(true);
/*jshint expr:false */
node = Y.one('#'+formelement.nodeid);
if (node) {
node.get('childNodes').destroy(true);
node.remove(true);
}
}
);
instance._FORM_elements = {};
instance._ATTRS_nodes = {};
instance._knownNodeIds = {};
};

/**
* Cleans up internal references of everything the formmodel has inserted inside the container.
* Only to be used when a containernode gets empty.
*
* @method _cleanupContainer
* @param [container] {Y.Node} only cleanup items inside this container
* @protected
* @private
* @since 0.1
*/
ITSAFormModel.prototype._cleanupContainer = function(container) {
var instance = this,
attributenodes = instance._ATTRS_nodes,
formelements = instance._FORM_elements,
knownNodeIds = instance._knownNodeIds,
knowdIdsRemoval = [],
node, formelement, attribute, indexofitem;
YObject.each(
knownNodeIds,
function(value, nodeid) {
formelement = formelements[nodeid];
node = container.one('#'+nodeid);
// remove node
if (node) {
/*jshint expr:true */
formelement.widget && formelement.widget.destroy(true);
/*jshint expr:false */
node.get('childNodes').destroy(true);
node.remove(true);
delete formelements[nodeid];
// now find the inside the array _ATTRS_nodes[attribute] for the item that holds ref. to the nodeid
attribute = formelement.name;
indexofitem = attributenodes[attribute].indexOf(nodeid);
/*jshint expr:true */
indexofitem && attributenodes[attribute].splice(indexofitem, 1);
/*jshint expr:false */
// now store the nodeid, because it has to be removed from instance._knownNodeIds
knowdIdsRemoval.push(nodeid);
}
}
);
// now remove it from knownNodeIds
YArray.each(
knowdIdsRemoval,
function(nodeid) {
delete knownNodeIds[nodeid];
}
);
};

/**
* Cleaning up all eventlisteners
*
Expand Down Expand Up @@ -1990,7 +2071,11 @@ ITSAFormModel.prototype._defFn_changedate = function(e) {
// be carefull: button might not exist anymore, when the view is rerendered
if (node) {
node.removeAttribute(DATA_CONTENT);
node.focus();
try {
// ALWAYS focus nodes using try/catch to prevent js-error when node not in the dom
node.focus();
}
catch(err) {}
tipsycontent = node.getAttribute(DATA+'-contentvalid');
/*jshint expr:true */
tipsycontent && node.setAttribute(DATA_CONTENT, tipsycontent);
Expand Down Expand Up @@ -2658,7 +2743,7 @@ YArray.each(
}
);

}, 'gallery-2014.01.10-22-44', {
}, 'gallery-2014.02.26-18-54', {
"requires": [
"yui-base",
"event-valuechange",
Expand Down
2 changes: 1 addition & 1 deletion build/gallery-itsaformmodel/lang/gallery-itsaformmodel.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88b43d6

Please sign in to comment.