Permalink
Browse files

gallery-2014.02.05-23-53 ItsAsbreuk gallery-itsacheckbox

  • Loading branch information...
1 parent 34ba2f7 commit 13189c24a7abfb71c79879c7a37c7f74f6b8784d Ezequiel committed Feb 5, 2014
Showing with 970 additions and 54 deletions.
  1. +5 −6 build/gallery-itsacheckbox/assets/gallery-itsacheckbox-core.css
  2. +1 −1 build/gallery-itsacheckbox/assets/skins/sam/gallery-itsacheckbox.css
  3. +2 −2 build/gallery-itsacheckbox/gallery-itsacheckbox-coverage.js
  4. +95 −11 build/gallery-itsacheckbox/gallery-itsacheckbox-debug.js
  5. +2 −2 build/gallery-itsacheckbox/gallery-itsacheckbox-min.js
  6. +95 −11 build/gallery-itsacheckbox/gallery-itsacheckbox.js
  7. +5 −1 src/gallery-itsacheckbox/HISTORY.md
  8. +5 −6 src/gallery-itsacheckbox/assets/gallery-itsacheckbox/gallery-itsacheckbox-core.css
  9. +29 −1 src/gallery-itsacheckbox/docs/index.mustache
  10. +1 −1 src/gallery-itsacheckbox/docs/partials/init-loaderconfig-js.mustache
  11. +4 −1 src/gallery-itsacheckbox/docs/partials/rendering-using-html-css.mustache
  12. +1 −1 src/gallery-itsacheckbox/docs/partials/rendering-using-html-html.mustache
  13. +39 −0 src/gallery-itsacheckbox/docs/test.mustache
  14. +2 −0 src/gallery-itsacheckbox/group/HISTORY.md
  15. +2 −0 src/gallery-itsacheckbox/group/README.md
  16. +10 −0 src/gallery-itsacheckbox/group/build.json
  17. +21 −0 src/gallery-itsacheckbox/group/docs/component.json
  18. +16 −0 src/gallery-itsacheckbox/group/docs/index.mustache
  19. +7 −0 src/gallery-itsacheckbox/group/docs/partials/init-loaderconfig-js.mustache
  20. +38 −0 src/gallery-itsacheckbox/group/docs/partials/loaderconfig-js.mustache
  21. +14 −0 src/gallery-itsacheckbox/group/docs/partials/using-itsacheckboxgroup-css.mustache
  22. +4 −0 src/gallery-itsacheckbox/group/docs/partials/using-itsacheckboxgroup-html.mustache
  23. +21 −0 src/gallery-itsacheckbox/group/docs/partials/using-itsacheckboxgroup-js.mustache
  24. +27 −0 src/gallery-itsacheckbox/group/docs/using-itsacheckboxgroup.mustache
  25. +288 −0 src/gallery-itsacheckbox/group/js/gallery-itsacheckboxgroup.js
  26. +11 −0 src/gallery-itsacheckbox/group/meta/gallery-itsacheckboxgroup.json
  27. +25 −0 src/gallery-itsacheckbox/group/tests/unit/index.html
  28. +15 −0 src/gallery-itsacheckbox/group/tests/unit/js/tests.js
  29. +94 −10 src/gallery-itsacheckbox/js/gallery-itsacheckbox.js
  30. +8 −0 src/gallery-itsacheckbox/logs/tests.json
  31. +2 −0 src/gallery-itsacheckbox/logs/yogi.stderr.log
  32. +81 −0 src/gallery-itsacheckbox/logs/yogi.stdout.log
@@ -7,15 +7,14 @@
.pure-form-stacked label {
display: block;
}
+.yui3-itsacheckbox-hidden,
.yui3-itsacheckbox-loading,
.yui3-itsacheckbox-created-checkbox,
.yui3-itsacheckbox-rerender {
- position: absolute;
- left: -9999px;
- top: -9999px;
-}
-.yui3-itsacheckbox-hidden {
- display: none;
+ position: absolute !important;
+ visibility: hidden !important;
+ left: -9999px !important;
+ top: -9999px !important;
}
.itsa-widget-parent {
display: inline-block;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -20,7 +20,9 @@ YUI.add('gallery-itsacheckbox', function (Y, NAME) {
var LANG = Y.Lang,
YARRAY = Y.Array,
- WIDGET_CLASS = 'yui3-itsacheckbox',
+ Node = Y.Node,
+ YUI3_ = 'yui3-',
+ WIDGET_CLASS = YUI3_+'itsacheckbox',
READONLY = 'readonly',
READONLY_CLASS = WIDGET_CLASS + '-' + READONLY,
PARENT_CLASS = 'itsa-widget-parent',
@@ -66,6 +68,7 @@ var LANG = Y.Lang,
DATA_SUBMITONENTER = DATA_+SUBMITONENTER,
DATA_PRIMARYBTNONENTER = DATA_+PRIMARYBTNONENTER,
DATA_FOCUSNEXTONENTER = DATA_+'focusnext'+ONENTER,
+ BOUNDINGBOX_TEMPLATE_NEWVERSION = DIVCLASS+YUI3_+'widget '+WIDGET_CLASS+' '+WIDGET_CLASS+'-content">'+ENDDIV,
HTML_CHECKBOX_TEMPLATE = '<input id="{id}" type="checkbox" class="'+CREATED_CHECKBOX+'"{'+READONLY+'}{'+CHECKED+'}{'+DISABLED+'}>',
TEMPLATE = '{htmlcheckbox}'+
DIVCLASS+OPTION_WRAPPER+'">'+
@@ -155,6 +158,29 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
* @private
*/
+
+
+ /**
+ * Reference to the parentnode of srcNode (input-element). Is used to check if a label-element is wrapping the html-checkbox
+ * @property _srcParentNode
+ * @type Y.Node
+ * @private
+ */
+
+ /**
+ * Flag to indicate if the original html-checkbox comes in front of the text: ONLY applyable when is wrapped by a label-element
+ * @property _checkBoxBeforeText
+ * @type Boolean
+ * @private
+ */
+
+ /**
+ * Backup-ref to the label-element - if applyable
+ * @property _bkpLabel
+ * @type Y.Node
+ * @private
+ */
+
/**
* @method initializer
* @protected
@@ -182,12 +208,47 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
Y.log('renderUI ', 'cmas', 'ITSACheckBox');
var instance = this,
boundingBox = instance.get(BOUNDINGBOX),
- src;
- src = instance.get('srcNode');
+ src, bkpLabel, checkBoxInsideLabel, srcParentNode, checkBoxBeforeText;
+ src = instance._src = instance.get('srcNode');
if (src && (src.get('tagName')==='INPUT') && (src.getAttribute('type')==='checkbox')) {
- instance._src = Y.one(src);
- src.addClass(HIDDEN_CLASS);
- boundingBox.insert(src, 'before');
+ src.addClass(HIDDEN_CLASS);
+ // Need to check if checkbox is inside a label-element --> due to HTML validation the widget CANNOT lie inside a label!
+ instance._srcParentNode = srcParentNode = src.get('parentNode');
+ checkBoxInsideLabel = (srcParentNode.get('tagName')==='LABEL');
+ // in yui before 3.13.0 the boundingBox was created as a DIV behind srcNode
+ // as from 3.13.0, boundingBox===srcNode
+ if (boundingBox.get('tagName')==='INPUT') {
+ // as from 3.13.0
+ // no insert, because srcNode already is in the DOM
+ clonedNode = Node.create(BOUNDINGBOX_TEMPLATE_NEWVERSION);
+ if (!checkBoxInsideLabel) {
+ src.insert(clonedNode, 'after');
+ }
+ else {
+ instance._checkBoxBeforeText = checkBoxBeforeText = (srcParentNode.getHTML().toLowerCase().substr(0, 6)==='<label');
+ srcParentNode.insert(clonedNode, checkBoxBeforeText ? 'before' : 'after');
+ // now: mode the checkbox outside its parent labelnode:
+ srcParentNode.insert(src, 'after');
+ }
+ instance._set(BOUNDINGBOX, clonedNode); // redefine the boudingbox --> it has to be a node separate from srcNode
+ // Next, correct the classes that were added to the input-tag during initialization
+ src.removeClass(LOADING_CLASS);
+ src.removeClass(YUI3_+'widget');
+ src.removeClass(WIDGET_CLASS);
+ src.removeClass(WIDGET_CLASS+'-content');
+ if (instance.get(READONLY)) {
+ src.removeClass(READONLY_CLASS);
+ }
+ }
+ else {
+ // before 3.13.0
+ boundingBox.insert(src, 'before');
+ }
+ // now disable label-activity:
+ bkpLabel = instance._bkpLabel = Y.one('label[for="'+src.get('id')+'"]');
+/*jshint expr:true */
+ bkpLabel && bkpLabel.removeAttribute('for');
+/*jshint expr:false */
}
if (instance._parentNode) {
instance._parentNode.addClass(PARENT_CLASS);
@@ -249,6 +310,7 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
*/
instance.fire(VALUECHANGE_EVT, e);
if (instance._src) {
+ instance._src.set(CHECKED, checked);
if (checked) {
instance._src.setAttribute(CHECKED, CHECKED);
}
@@ -327,9 +389,17 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
);
instance._eventhandlers.push(
- parentNode.on('blur', function() {
- instance.blur();
- })
+ parentNode.on(
+ 'blur',
+ Y.bind(instance.blur, instance)
+ )
+ );
+
+ instance._eventhandlers.push(
+ Y.after(
+ 'rerenderCheckbox',
+ Y.bind(instance.syncUI, instance)
+ )
);
instance._eventhandlers.push(
@@ -421,6 +491,9 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
var instance = this,
prevVal = instance.get(CHECKED),
newVal;
+ if (instance.get(READONLY)) {
+ return;
+ }
if (prevVal!==null) {
instance.set(CHECKED, !prevVal);
newVal = instance.get(CHECKED);
@@ -452,10 +525,11 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
Y.log('destructor', 'info', 'ITSACheckBox');
var instance = this,
dd = instance.dd,
+ checkBoxBeforeText = instance._checkBoxBeforeText,
createdSrc = instance._createdSrc,
+ bkpLabel = instance._bkpLabel,
src = instance._src;
instance._destroyAllNodes = true; // making always destroy nodes,
- // independent whether developer calls destroy(true) or destroy(false)
if (dd) {
dd.destroy();
}
@@ -471,6 +545,16 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
if (instance._parentNode) {
instance._parentNode.removeClass(PARENT_CLASS);
}
+ // now reset label-activity:
+/*jshint expr:true */
+ bkpLabel && bkpLabel.setAttribute('for', src.get('id'));
+/*jshint expr:false */
+ // now: replace the checkbox inside its parent labelnode
+ if (typeof checkBoxBeforeText==='boolean') {
+/*jshint expr:true */
+ checkBoxBeforeText ? instance._srcParentNode.prepend(src) : instance._srcParentNode.append(src);
+/*jshint expr:false */
+ }
},
//------------------------------------------------------------------------------
@@ -893,7 +977,7 @@ Y.ITSACheckbox = Y.Base.create('itsacheckbox', Y.Widget, [], {
}
);
-}, '@VERSION@', {
+}, 'gallery-2014.02.05-23-53', {
"requires": [
"yui-base",
"dd-ddm",
Oops, something went wrong.

0 comments on commit 13189c2

Please sign in to comment.