// no context inferring on vertical right now
this.verticalPositionClass = this.originalVerticalPosition = this.getVerticalPositionClass(this.options.positionClass);
this.originalHorizontalPosition = this.getHorizontalPositionClass(this.options.positionClass);
+ this.checkForCenterClass(this.options.positionClass);
this.horizontalPositionClass = this.originalHorizontalPosition.length ? this.originalHorizontalPosition : this.inferHorizontalPositionClass();
+
this.positionClass = [this.horizontalPositionClass, this.verticalPositionClass].join(' ').trim();
+ this.fixedExhausted = false;
this.counter = 6;
this.usedPositions = [];
this.$element.attr({
return horizontalPosition;
}
+ checkForCenterClass(className) {
+ if(typeof(className) === 'undefined' || !className.length) {
+ className = this.$element[0].className;
+ }
+
+ var hasCenterClass = className.match(/center/);
+ if(hasCenterClass) {
+ if(this.originalHorizontalPosition) {
+ this.verticalPosition = this.originalVerticalPosition = 'center';
+ } else {
+ this.originalHorizontalPosition = 'center';
+ }
+ }
+ }
+
getNextClass(current, array) {
var index = array.indexOf(current);
return array[(index + 1) % array.length];
}
+ // We want to always respect explicitly set positioning,
+ // so this method checks if we've exhausted the possibilities.
+ checkFixedExhausted() {
+ if(this.originalHorizontalPosition.length && this.originalVerticalPosition.length) {
+ return true;
+ }
+
+ if(this.originalHorizontalPosition.length || this.originalVerticalPosition.length) {
+ return this.usedPositions.length > 4;
+ }
+
+ return false;
+ }
+
/**
* Adjusts the dropdown panes orientation by adding/removing positioning classes.
* @function
this.$element.removeClass(position);
this.$element.addClass(newPosition);
this.classChanged = true;
+ this.fixedExhausted = this.checkFixedExhausted();
this.counter--;
}
$eleDims = Foundation.Box.GetDimensions(this.$element),
$anchorDims = Foundation.Box.GetDimensions(this.$anchor);
-
+ debugger;
if(($eleDims.width >= $eleDims.windowDims.width) || (!this.counter && !Foundation.Box.ImNotTouchingYou(this.$element))){
this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$anchor, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({
}
this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$anchor, position, this.options.vOffset, this.options.hOffset));
- while(!Foundation.Box.ImNotTouchingYou(this.$element, false, true) && this.counter){
+ while(!Foundation.Box.ImNotTouchingYou(this.$element, false, true) && this.counter && !this.fixedExhausted) {
this._reposition(position);
this._setPosition();
}
--- /dev/null
+<!doctype html>
+<!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
+<html class="no-js" lang="en" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <title>Foundation for Sites Testing</title>
+ <link href="../assets/css/foundation.css" rel="stylesheet" />
+ </head>
+ <body>
+ <div class="row column">
+ <h1>Dropdown: Positioning Content</h1>
+
+ <p>These dropdowns test various positioning and position offsets</p>
+
+ <p>This dropdown should be offset by 10 down and 30 to the right</p>
+ <button class="button" type="button" data-toggle="example-dropdown">Toggle Dropdown</button>
+ <div class="dropdown-pane" id="example-dropdown" data-dropdown data-v-offset="10" data-h-offset="30" data-auto-focus="true">
+ <p>This dropdown should be offset by 10 down and 30 to the right</p>
+ </div>
+ <p>This dropdown should go off the screen left because it is 100% explicitly positioned.</p>
+ <button class="button" type="button" data-toggle="example-dropdown2">Toggle Dropdown</button>
+ <div class="dropdown-pane center left" id="example-dropdown2" data-dropdown data-auto-focus="true">
+ <p>This dropdown should go off the screen left because it is 100% explicitly positioned.</p>
+ </div>
+ <p>This dropdown should go off the screen left because it is 100% explicitly positioned.</p>
+ <button class="button" type="button" data-toggle="example-dropdown3">Toggle Dropdown</button>
+ <div class="dropdown-pane left" id="example-dropdown3" data-dropdown data-auto-focus="true">
+ <p>This dropdown should go left if there is room and otherwise below</p>
+ </div>
+ </div>
+
+ <script src="../assets/js/vendor.js"></script>
+ <script src="../assets/js/foundation.js"></script>
+ <script>
+ $(document).foundation();
+ </script>
+ </body>
+</html>