forked from fanruan/fineui
Browse Source
* commit '531014f290d463e394f34839113c29c91423e11a': add add 加个删除tab项的方法 add add add addes6
guy
8 years ago
13 changed files with 2736 additions and 2697 deletions
@ -1,115 +1,115 @@
|
||||
/** |
||||
* |
||||
* 表格单元格 |
||||
* |
||||
* Created by GUY on 2016/1/12. |
||||
* @class BI.ResizableTableCell |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.ResizableTableCell = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.ResizableTableCell.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-resizable-table-cell", |
||||
cell: {}, |
||||
minSize: 15, |
||||
// suitableSize,
|
||||
maxSize: Number.MAX_VALUE, |
||||
start: BI.emptyFn, |
||||
resize: BI.emptyFn, |
||||
stop: BI.emptyFn |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.ResizableTableCell.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.cell = BI.createWidget(BI.extend({type: "bi.label"}, o.cell, {width: o.width, height: o.height})); |
||||
|
||||
var startDrag = false; |
||||
var size = 0, offset = 0, defaultSize = o.width; |
||||
|
||||
function optimizeSize(s) { |
||||
var optSize = BI.clamp(s, o.minSize, o.maxSize || Number.MAX_VALUE); |
||||
if (o.suitableSize) { |
||||
if (Math.abs(o.suitableSize - optSize) < 5) { |
||||
optSize = o.suitableSize; |
||||
self.handler.element.addClass("suitable"); |
||||
} else { |
||||
self.handler.element.removeClass("suitable"); |
||||
} |
||||
} |
||||
return optSize; |
||||
} |
||||
|
||||
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { |
||||
if (mouseMoveTracker.isDragging()) { |
||||
startDrag = true; |
||||
offset += deltaX; |
||||
size = optimizeSize(defaultSize + offset); |
||||
self.handler.element.addClass("dragging"); |
||||
o.resize(size); |
||||
} |
||||
}, function () { |
||||
if (startDrag === true) { |
||||
size = optimizeSize(size); |
||||
o.stop(size); |
||||
size = 0; |
||||
offset = 0; |
||||
defaultSize = o.width; |
||||
startDrag = false; |
||||
} |
||||
self.handler.element.removeClass("dragging"); |
||||
self.handler.element.removeClass("suitable"); |
||||
mouseMoveTracker.releaseMouseMoves(); |
||||
}, document); |
||||
this.handler = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
cls: "resizable-table-cell-resizer-container", |
||||
width: 6, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.layout", |
||||
cls: "resizable-table-cell-resizer-knob", |
||||
width: 4 |
||||
}, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}] |
||||
}); |
||||
this.handler.element.on("mousedown", function (event) { |
||||
defaultSize = o.width; |
||||
optimizeSize(defaultSize); |
||||
mouseMoveTracker.captureMouseMoves(event); |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [{ |
||||
el: this.cell, |
||||
left: 0, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}, { |
||||
el: this.handler, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}] |
||||
}) |
||||
}, |
||||
|
||||
setWidth: function (width) { |
||||
BI.ResizableTableCell.superclass.setWidth.apply(this, arguments); |
||||
var o = this.options; |
||||
this.cell.setWidth(o.width); |
||||
}, |
||||
|
||||
setHeight: function (height) { |
||||
BI.ResizableTableCell.superclass.setHeight.apply(this, arguments); |
||||
var o = this.options; |
||||
this.cell.setHeight(o.height); |
||||
} |
||||
}); |
||||
/** |
||||
* |
||||
* 表格单元格 |
||||
* |
||||
* Created by GUY on 2016/1/12. |
||||
* @class BI.ResizableTableCell |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.ResizableTableCell = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.ResizableTableCell.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-resizable-table-cell", |
||||
cell: {}, |
||||
minSize: 15, |
||||
// suitableSize,
|
||||
maxSize: Number.MAX_VALUE, |
||||
start: BI.emptyFn, |
||||
resize: BI.emptyFn, |
||||
stop: BI.emptyFn |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.ResizableTableCell.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.cell = BI.createWidget(BI.extend({type: "bi.label"}, o.cell, {width: o.width, height: o.height})); |
||||
|
||||
var startDrag = false; |
||||
var size = 0, offset = 0, defaultSize = o.width; |
||||
|
||||
function optimizeSize(s) { |
||||
var optSize = BI.clamp(s, o.minSize, o.maxSize || Number.MAX_VALUE); |
||||
// if (o.suitableSize) {
|
||||
// if (Math.abs(o.suitableSize - optSize) < 5) {
|
||||
// optSize = o.suitableSize;
|
||||
// self.handler.element.addClass("suitable");
|
||||
// } else {
|
||||
// self.handler.element.removeClass("suitable");
|
||||
// }
|
||||
// }
|
||||
return optSize; |
||||
} |
||||
|
||||
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { |
||||
if (mouseMoveTracker.isDragging()) { |
||||
startDrag = true; |
||||
offset += deltaX; |
||||
size = optimizeSize(defaultSize + offset); |
||||
self.handler.element.addClass("dragging"); |
||||
o.resize(size); |
||||
} |
||||
}, function () { |
||||
if (startDrag === true) { |
||||
size = optimizeSize(size); |
||||
o.stop(size); |
||||
size = 0; |
||||
offset = 0; |
||||
defaultSize = o.width; |
||||
startDrag = false; |
||||
} |
||||
self.handler.element.removeClass("dragging"); |
||||
self.handler.element.removeClass("suitable"); |
||||
mouseMoveTracker.releaseMouseMoves(); |
||||
}, document); |
||||
this.handler = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
cls: "resizable-table-cell-resizer-container", |
||||
width: 6, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.layout", |
||||
cls: "resizable-table-cell-resizer-knob", |
||||
width: 4 |
||||
}, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}] |
||||
}); |
||||
this.handler.element.on("mousedown", function (event) { |
||||
defaultSize = o.width; |
||||
optimizeSize(defaultSize); |
||||
mouseMoveTracker.captureMouseMoves(event); |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [{ |
||||
el: this.cell, |
||||
left: 0, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}, { |
||||
el: this.handler, |
||||
right: 0, |
||||
top: 0, |
||||
bottom: 0 |
||||
}] |
||||
}) |
||||
}, |
||||
|
||||
setWidth: function (width) { |
||||
BI.ResizableTableCell.superclass.setWidth.apply(this, arguments); |
||||
var o = this.options; |
||||
this.cell.setWidth(o.width); |
||||
}, |
||||
|
||||
setHeight: function (height) { |
||||
BI.ResizableTableCell.superclass.setHeight.apply(this, arguments); |
||||
var o = this.options; |
||||
this.cell.setHeight(o.height); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.resizable_table_cell", BI.ResizableTableCell); |
@ -1,224 +1,222 @@
|
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @class BI.BubbleCombo |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.BubbleCombo = BI.inherit(BI.Widget, { |
||||
_const: { |
||||
TRIANGLE_LENGTH: 6 |
||||
}, |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-bubble-combo", |
||||
trigger: "click", |
||||
toggle: true, |
||||
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
|
||||
isDefaultInit: false, |
||||
destroyWhenHide: false, |
||||
isNeedAdjustHeight: true,//是否需要高度调整
|
||||
isNeedAdjustWidth: true, |
||||
stopPropagation: false, |
||||
adjustLength: 0,//调整的距离
|
||||
// adjustXOffset: 0,
|
||||
// adjustYOffset: 10,
|
||||
hideChecker: BI.emptyFn, |
||||
offsetStyle: "left", //left,right,center
|
||||
el: {}, |
||||
popup: {}, |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.BubbleCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
element: this, |
||||
trigger: o.trigger, |
||||
toggle: o.toggle, |
||||
direction: o.direction, |
||||
isDefaultInit: o.isDefaultInit, |
||||
destroyWhenHide: o.destroyWhenHide, |
||||
isNeedAdjustHeight: o.isNeedAdjustHeight, |
||||
isNeedAdjustWidth: o.isNeedAdjustWidth, |
||||
adjustLength: this._getAdjustLength(), |
||||
stopPropagation: o.stopPropagation, |
||||
adjustXOffset: 0, |
||||
adjustYOffset: 0, |
||||
hideChecker: o.hideChecker, |
||||
offsetStyle: o.offsetStyle, |
||||
el: o.el, |
||||
popup: BI.extend({ |
||||
type: "bi.bubble_popup_view" |
||||
}, o.popup), |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_EXPAND, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { |
||||
self._showTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { |
||||
self._hideTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_getAdjustLength: function () { |
||||
return this._const.TRIANGLE_LENGTH + this.options.adjustLength; |
||||
}, |
||||
|
||||
_createTriangle: function (direction) { |
||||
var pos = {}, op = {}; |
||||
var adjustLength = this.options.adjustLength; |
||||
var offset = this.element.offset(); |
||||
var left = offset.left, right = offset.left + this.element.outerWidth(); |
||||
var top = offset.top, bottom = offset.top + this.element.outerHeight(); |
||||
switch (direction) { |
||||
case "left": |
||||
pos = { |
||||
top: top, |
||||
height: this.element.outerHeight(), |
||||
left: left - adjustLength - this._const.TRIANGLE_LENGTH |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "right": |
||||
pos = { |
||||
top: top, |
||||
height: this.element.outerHeight(), |
||||
left: right + adjustLength |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "top": |
||||
pos = { |
||||
left: left, |
||||
width: this.element.outerWidth(), |
||||
top: top - adjustLength - this._const.TRIANGLE_LENGTH |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "bottom": |
||||
pos = { |
||||
left: left, |
||||
width: this.element.outerWidth(), |
||||
top: bottom + adjustLength |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
this.triangle = BI.createWidget(op, { |
||||
type: "bi.center_adapt", |
||||
cls: "button-combo-triangle-wrapper", |
||||
items: [{ |
||||
type: "bi.layout", |
||||
cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" |
||||
}] |
||||
}); |
||||
pos.el = this.triangle; |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [pos] |
||||
}) |
||||
}, |
||||
|
||||
_createLeftTriangle: function () { |
||||
this._createTriangle("left"); |
||||
}, |
||||
|
||||
_createRightTriangle: function () { |
||||
this._createTriangle("right"); |
||||
}, |
||||
|
||||
_createTopTriangle: function () { |
||||
this._createTriangle("top"); |
||||
}, |
||||
|
||||
_createBottomTriangle: function () { |
||||
this._createTriangle("bottom"); |
||||
}, |
||||
|
||||
_showTriangle: function () { |
||||
var pos = this.combo.getPopupPosition(); |
||||
switch (pos.dir) { |
||||
case "left,top": |
||||
case "left,bottom": |
||||
this._createLeftTriangle(); |
||||
this.combo.getView().showLine("right"); |
||||
break; |
||||
case "right,top": |
||||
case "right,bottom": |
||||
this._createRightTriangle(); |
||||
this.combo.getView().showLine("left"); |
||||
break; |
||||
case "top,left": |
||||
case "top,right": |
||||
this._createTopTriangle(); |
||||
this.combo.getView().showLine("bottom"); |
||||
break; |
||||
case "bottom,left": |
||||
case "bottom,right": |
||||
this._createBottomTriangle(); |
||||
this.combo.getView().showLine("top"); |
||||
break; |
||||
} |
||||
}, |
||||
|
||||
_hideTriangle: function () { |
||||
this.triangle && this.triangle.destroy(); |
||||
this.combo.getView() && this.combo.getView().hideLine(); |
||||
}, |
||||
|
||||
hideView: function () { |
||||
this._hideTriangle(); |
||||
this.combo && this.combo.hideView(); |
||||
}, |
||||
|
||||
showView: function () { |
||||
this.combo && this.combo.showView(); |
||||
}, |
||||
|
||||
hasView: function () { |
||||
return BI.isNotNull(this.combo.getView()); |
||||
}, |
||||
|
||||
isViewVisible: function () { |
||||
return this.combo.isViewVisible(); |
||||
} |
||||
}); |
||||
|
||||
BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; |
||||
BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; |
||||
BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; |
||||
BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; |
||||
|
||||
|
||||
BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; |
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @class BI.BubbleCombo |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.BubbleCombo = BI.inherit(BI.Widget, { |
||||
_const: { |
||||
TRIANGLE_LENGTH: 6 |
||||
}, |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-bubble-combo", |
||||
trigger: "click", |
||||
toggle: true, |
||||
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
|
||||
isDefaultInit: false, |
||||
destroyWhenHide: false, |
||||
isNeedAdjustHeight: true,//是否需要高度调整
|
||||
isNeedAdjustWidth: true, |
||||
stopPropagation: false, |
||||
adjustLength: 0,//调整的距离
|
||||
// adjustXOffset: 0,
|
||||
// adjustYOffset: 10,
|
||||
hideChecker: BI.emptyFn, |
||||
offsetStyle: "left", //left,right,center
|
||||
el: {}, |
||||
popup: {}, |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.BubbleCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
element: this, |
||||
trigger: o.trigger, |
||||
toggle: o.toggle, |
||||
direction: o.direction, |
||||
isDefaultInit: o.isDefaultInit, |
||||
destroyWhenHide: o.destroyWhenHide, |
||||
isNeedAdjustHeight: o.isNeedAdjustHeight, |
||||
isNeedAdjustWidth: o.isNeedAdjustWidth, |
||||
adjustLength: this._getAdjustLength(), |
||||
stopPropagation: o.stopPropagation, |
||||
adjustXOffset: 0, |
||||
adjustYOffset: 0, |
||||
hideChecker: o.hideChecker, |
||||
offsetStyle: o.offsetStyle, |
||||
el: o.el, |
||||
popup: BI.extend({ |
||||
type: "bi.bubble_popup_view" |
||||
}, o.popup), |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_EXPAND, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { |
||||
self._showTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { |
||||
self._hideTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_getAdjustLength: function () { |
||||
return this._const.TRIANGLE_LENGTH + this.options.adjustLength; |
||||
}, |
||||
|
||||
_createTriangle: function (direction) { |
||||
var pos = {}, op = {}; |
||||
var adjustLength = this.options.adjustLength; |
||||
var offset = this.element.offset(); |
||||
var left = offset.left, right = offset.left + this.element.outerWidth(); |
||||
var top = offset.top, bottom = offset.top + this.element.outerHeight(); |
||||
switch (direction) { |
||||
case "left": |
||||
pos = { |
||||
top: top, |
||||
height: this.element.outerHeight(), |
||||
left: left - adjustLength - this._const.TRIANGLE_LENGTH |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "right": |
||||
pos = { |
||||
top: top, |
||||
height: this.element.outerHeight(), |
||||
left: right + adjustLength |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "top": |
||||
pos = { |
||||
left: left, |
||||
width: this.element.outerWidth(), |
||||
top: top - adjustLength - this._const.TRIANGLE_LENGTH |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "bottom": |
||||
pos = { |
||||
left: left, |
||||
width: this.element.outerWidth(), |
||||
top: bottom + adjustLength |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
this.triangle && this.triangle.destroy(); |
||||
this.triangle = BI.createWidget(op, { |
||||
type: "bi.center_adapt", |
||||
cls: "button-combo-triangle-wrapper", |
||||
items: [{ |
||||
type: "bi.layout", |
||||
cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" |
||||
}] |
||||
}); |
||||
pos.el = this.triangle; |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [pos] |
||||
}) |
||||
}, |
||||
|
||||
_createLeftTriangle: function () { |
||||
this._createTriangle("left"); |
||||
}, |
||||
|
||||
_createRightTriangle: function () { |
||||
this._createTriangle("right"); |
||||
}, |
||||
|
||||
_createTopTriangle: function () { |
||||
this._createTriangle("top"); |
||||
}, |
||||
|
||||
_createBottomTriangle: function () { |
||||
this._createTriangle("bottom"); |
||||
}, |
||||
|
||||
_showTriangle: function () { |
||||
var pos = this.combo.getPopupPosition(); |
||||
switch (pos.dir) { |
||||
case "left,top": |
||||
case "left,bottom": |
||||
this._createLeftTriangle(); |
||||
this.combo.getView().showLine("right"); |
||||
break; |
||||
case "right,top": |
||||
case "right,bottom": |
||||
this._createRightTriangle(); |
||||
this.combo.getView().showLine("left"); |
||||
break; |
||||
case "top,left": |
||||
case "top,right": |
||||
this._createTopTriangle(); |
||||
this.combo.getView().showLine("bottom"); |
||||
break; |
||||
case "bottom,left": |
||||
case "bottom,right": |
||||
this._createBottomTriangle(); |
||||
this.combo.getView().showLine("top"); |
||||
break; |
||||
} |
||||
}, |
||||
|
||||
_hideTriangle: function () { |
||||
this.triangle && this.triangle.destroy(); |
||||
this.triangle = null; |
||||
this.combo.getView() && this.combo.getView().hideLine(); |
||||
}, |
||||
|
||||
hideView: function () { |
||||
this._hideTriangle(); |
||||
this.combo && this.combo.hideView(); |
||||
}, |
||||
|
||||
showView: function () { |
||||
this.combo && this.combo.showView(); |
||||
}, |
||||
|
||||
isViewVisible: function () { |
||||
return this.combo.isViewVisible(); |
||||
} |
||||
}); |
||||
|
||||
BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; |
||||
BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; |
||||
BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; |
||||
BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; |
||||
|
||||
|
||||
BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; |
||||
BI.shortcut("bi.bubble_combo", BI.BubbleCombo); |
@ -1,173 +1,176 @@
|
||||
/** |
||||
* Created by GUY on 2016/4/29. |
||||
* |
||||
* @class BI.SortList |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.SortList = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SortList.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-sort-list", |
||||
|
||||
isDefaultInit: true,//是否默认初始化数据
|
||||
|
||||
//下面是button_group的属性
|
||||
el: { |
||||
type: "bi.button_group" |
||||
}, |
||||
|
||||
items: [], |
||||
itemsCreator: BI.emptyFn, |
||||
onLoaded: BI.emptyFn, |
||||
|
||||
//下面是分页信息
|
||||
count: false, |
||||
next: {}, |
||||
hasNext: BI.emptyFn |
||||
|
||||
//containment: this.element,
|
||||
//connectWith: ".bi-sort-list",
|
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SortList.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.loader = BI.createWidget({ |
||||
type: "bi.list_loader", |
||||
element: this, |
||||
isDefaultInit: o.isDefaultInit, |
||||
el: o.el, |
||||
items: this._formatItems(o.items), |
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator(op, function (items) { |
||||
callback(self._formatItems(items)); |
||||
}); |
||||
}, |
||||
onLoaded: o.onLoaded, |
||||
count: o.count, |
||||
next: o.next, |
||||
hasNext: o.hasNext |
||||
}); |
||||
this.loader.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.SortList.EVENT_CHANGE, value, obj); |
||||
} |
||||
}); |
||||
|
||||
this.loader.element.sortable({ |
||||
containment: o.containment || this.element, |
||||
connectWith: o.connectWith || ".bi-sort-list", |
||||
items: ".sort-item", |
||||
cursor: o.cursor || "drag", |
||||
tolerance: o.tolerance || "intersect", |
||||
placeholder: { |
||||
element: function ($currentItem) { |
||||
var holder = BI.createWidget({ |
||||
type: "bi.layout", |
||||
cls: "bi-sortable-holder", |
||||
height: $currentItem.outerHeight() |
||||
}); |
||||
holder.element.css({ |
||||
"margin-left": $currentItem.css("margin-left"), |
||||
"margin-right": $currentItem.css("margin-right"), |
||||
"margin-top": $currentItem.css("margin-top"), |
||||
"margin-bottom": $currentItem.css("margin-bottom"), |
||||
"margin": $currentItem.css("margin") |
||||
}); |
||||
return holder.element; |
||||
}, |
||||
update: function () { |
||||
|
||||
} |
||||
}, |
||||
start: function (event, ui) { |
||||
|
||||
}, |
||||
stop: function (event, ui) { |
||||
self.fireEvent(BI.SortList.EVENT_CHANGE); |
||||
}, |
||||
over: function (event, ui) { |
||||
|
||||
} |
||||
}); |
||||
}, |
||||
|
||||
_formatItems: function (items) { |
||||
BI.each(items, function (i, item) { |
||||
item = BI.stripEL(item); |
||||
item.cls = item.cls ? item.cls + " sort-item" : "sort-item"; |
||||
item.attributes = { |
||||
sorted: item.value |
||||
}; |
||||
}); |
||||
return items; |
||||
}, |
||||
|
||||
hasNext: function () { |
||||
return this.loader.hasNext(); |
||||
}, |
||||
|
||||
addItems: function (items) { |
||||
this.loader.addItems(items); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.loader.populate.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
empty: function () { |
||||
this.loader.empty(); |
||||
}, |
||||
|
||||
setNotSelectedValue: function () { |
||||
this.loader.setNotSelectedValue.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
getNotSelectedValue: function () { |
||||
return this.loader.getNotSelectedValue(); |
||||
}, |
||||
|
||||
setValue: function () { |
||||
this.loader.setValue.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.loader.getValue(); |
||||
}, |
||||
|
||||
getAllButtons: function () { |
||||
return this.loader.getAllButtons(); |
||||
}, |
||||
|
||||
getAllLeaves: function () { |
||||
return this.loader.getAllLeaves(); |
||||
}, |
||||
|
||||
getSelectedButtons: function () { |
||||
return this.loader.getSelectedButtons(); |
||||
}, |
||||
|
||||
getNotSelectedButtons: function () { |
||||
return this.loader.getNotSelectedButtons(); |
||||
}, |
||||
|
||||
getIndexByValue: function (value) { |
||||
return this.loader.getIndexByValue(value); |
||||
}, |
||||
|
||||
getNodeById: function (id) { |
||||
return this.loader.getNodeById(id); |
||||
}, |
||||
|
||||
getNodeByValue: function (value) { |
||||
return this.loader.getNodeByValue(value); |
||||
}, |
||||
|
||||
getSortedValues: function () { |
||||
return this.loader.element.sortable("toArray", {attribute: "sorted"}); |
||||
} |
||||
}); |
||||
BI.SortList.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
/** |
||||
* Created by GUY on 2016/4/29. |
||||
* |
||||
* @class BI.SortList |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.SortList = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SortList.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-sort-list", |
||||
|
||||
isDefaultInit: true,//是否默认初始化数据
|
||||
|
||||
//下面是button_group的属性
|
||||
el: { |
||||
type: "bi.button_group" |
||||
}, |
||||
|
||||
items: [], |
||||
itemsCreator: BI.emptyFn, |
||||
onLoaded: BI.emptyFn, |
||||
|
||||
//下面是分页信息
|
||||
count: false, |
||||
next: {}, |
||||
hasNext: BI.emptyFn |
||||
|
||||
//containment: this.element,
|
||||
//connectWith: ".bi-sort-list",
|
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SortList.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.loader = BI.createWidget({ |
||||
type: "bi.list_loader", |
||||
element: this, |
||||
isDefaultInit: o.isDefaultInit, |
||||
el: o.el, |
||||
items: this._formatItems(o.items), |
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator(op, function (items) { |
||||
callback(self._formatItems(items)); |
||||
}); |
||||
}, |
||||
onLoaded: o.onLoaded, |
||||
count: o.count, |
||||
next: o.next, |
||||
hasNext: o.hasNext |
||||
}); |
||||
this.loader.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.SortList.EVENT_CHANGE, value, obj); |
||||
} |
||||
}); |
||||
|
||||
this.loader.element.sortable({ |
||||
containment: o.containment || this.element, |
||||
connectWith: o.connectWith || ".bi-sort-list", |
||||
items: ".sort-item", |
||||
cursor: o.cursor || "drag", |
||||
tolerance: o.tolerance || "intersect", |
||||
placeholder: { |
||||
element: function ($currentItem) { |
||||
var holder = BI.createWidget({ |
||||
type: "bi.layout", |
||||
cls: "bi-sortable-holder", |
||||
height: $currentItem.outerHeight() |
||||
}); |
||||
holder.element.css({ |
||||
"margin-left": $currentItem.css("margin-left"), |
||||
"margin-right": $currentItem.css("margin-right"), |
||||
"margin-top": $currentItem.css("margin-top"), |
||||
"margin-bottom": $currentItem.css("margin-bottom"), |
||||
"margin": $currentItem.css("margin") |
||||
}); |
||||
return holder.element; |
||||
}, |
||||
update: function () { |
||||
|
||||
} |
||||
}, |
||||
start: function (event, ui) { |
||||
|
||||
}, |
||||
stop: function (event, ui) { |
||||
self.fireEvent(BI.SortList.EVENT_CHANGE); |
||||
}, |
||||
over: function (event, ui) { |
||||
|
||||
} |
||||
}); |
||||
}, |
||||
|
||||
_formatItems: function (items) { |
||||
BI.each(items, function (i, item) { |
||||
item = BI.stripEL(item); |
||||
item.cls = item.cls ? item.cls + " sort-item" : "sort-item"; |
||||
item.attributes = { |
||||
sorted: item.value |
||||
}; |
||||
}); |
||||
return items; |
||||
}, |
||||
|
||||
hasNext: function () { |
||||
return this.loader.hasNext(); |
||||
}, |
||||
|
||||
addItems: function (items) { |
||||
this.loader.addItems(items); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
if (items) { |
||||
arguments[0] = this._formatItems(items); |
||||
} |
||||
this.loader.populate.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
empty: function () { |
||||
this.loader.empty(); |
||||
}, |
||||
|
||||
setNotSelectedValue: function () { |
||||
this.loader.setNotSelectedValue.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
getNotSelectedValue: function () { |
||||
return this.loader.getNotSelectedValue(); |
||||
}, |
||||
|
||||
setValue: function () { |
||||
this.loader.setValue.apply(this.loader, arguments); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.loader.getValue(); |
||||
}, |
||||
|
||||
getAllButtons: function () { |
||||
return this.loader.getAllButtons(); |
||||
}, |
||||
|
||||
getAllLeaves: function () { |
||||
return this.loader.getAllLeaves(); |
||||
}, |
||||
|
||||
getSelectedButtons: function () { |
||||
return this.loader.getSelectedButtons(); |
||||
}, |
||||
|
||||
getNotSelectedButtons: function () { |
||||
return this.loader.getNotSelectedButtons(); |
||||
}, |
||||
|
||||
getIndexByValue: function (value) { |
||||
return this.loader.getIndexByValue(value); |
||||
}, |
||||
|
||||
getNodeById: function (id) { |
||||
return this.loader.getNodeById(id); |
||||
}, |
||||
|
||||
getNodeByValue: function (value) { |
||||
return this.loader.getNodeByValue(value); |
||||
}, |
||||
|
||||
getSortedValues: function () { |
||||
return this.loader.element.sortable("toArray", {attribute: "sorted"}); |
||||
} |
||||
}); |
||||
BI.SortList.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.sort_list", BI.SortList); |
@ -1,79 +1,80 @@
|
||||
/** |
||||
* 文本输入框trigger |
||||
* |
||||
* Created by GUY on 2015/9/15. |
||||
* @class BI.EditorTrigger |
||||
* @extends BI.Trigger |
||||
*/ |
||||
BI.EditorTrigger = BI.inherit(BI.Trigger, { |
||||
_const: { |
||||
hgap: 4 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border", |
||||
height: 30, |
||||
validationChecker: BI.emptyFn, |
||||
quitChecker: BI.emptyFn, |
||||
allowBlank: false, |
||||
watermark: "", |
||||
errorText: "", |
||||
triggerWidth: 30 |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
this.options.height -= 2; |
||||
BI.EditorTrigger.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options, c = this._const; |
||||
this.editor = BI.createWidget({ |
||||
type: "bi.sign_editor", |
||||
height: o.height, |
||||
value: o.value, |
||||
validationChecker: o.validationChecker, |
||||
quitChecker: o.quitChecker, |
||||
mouseOut: false, |
||||
allowBlank: o.allowBlank, |
||||
watermark: o.watermark, |
||||
errorText: o.errorText |
||||
}); |
||||
this.editor.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
element: this, |
||||
type: 'bi.htape', |
||||
items: [ |
||||
{ |
||||
el: this.editor |
||||
}, { |
||||
el: { |
||||
type: "bi.trigger_icon_button", |
||||
width: o.triggerWidth |
||||
}, |
||||
width: o.triggerWidth |
||||
} |
||||
] |
||||
}); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.editor.getValue(); |
||||
}, |
||||
|
||||
setValue: function (value) { |
||||
this.editor.setValue(value); |
||||
}, |
||||
|
||||
setText: function (text) { |
||||
this.editor.setState(text); |
||||
} |
||||
}); |
||||
BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE"; |
||||
/** |
||||
* 文本输入框trigger |
||||
* |
||||
* Created by GUY on 2015/9/15. |
||||
* @class BI.EditorTrigger |
||||
* @extends BI.Trigger |
||||
*/ |
||||
BI.EditorTrigger = BI.inherit(BI.Trigger, { |
||||
_const: { |
||||
hgap: 4 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border", |
||||
height: 30, |
||||
validationChecker: BI.emptyFn, |
||||
quitChecker: BI.emptyFn, |
||||
allowBlank: false, |
||||
watermark: "", |
||||
errorText: "", |
||||
triggerWidth: 30 |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
this.options.height -= 2; |
||||
BI.EditorTrigger.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options, c = this._const; |
||||
this.editor = BI.createWidget({ |
||||
type: "bi.sign_editor", |
||||
height: o.height, |
||||
value: o.value, |
||||
validationChecker: o.validationChecker, |
||||
quitChecker: o.quitChecker, |
||||
mouseOut: false, |
||||
allowBlank: o.allowBlank, |
||||
watermark: o.watermark, |
||||
errorText: o.errorText |
||||
}); |
||||
this.editor.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
element: this, |
||||
type: 'bi.htape', |
||||
items: [ |
||||
{ |
||||
el: this.editor |
||||
}, { |
||||
el: { |
||||
type: "bi.trigger_icon_button", |
||||
cls: "bi-border-left", |
||||
width: o.triggerWidth |
||||
}, |
||||
width: o.triggerWidth |
||||
} |
||||
] |
||||
}); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.editor.getValue(); |
||||
}, |
||||
|
||||
setValue: function (value) { |
||||
this.editor.setValue(value); |
||||
}, |
||||
|
||||
setText: function (text) { |
||||
this.editor.setState(text); |
||||
} |
||||
}); |
||||
BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE"; |
||||
BI.shortcut("bi.editor_trigger", BI.EditorTrigger); |
Loading…
Reference in new issue