merging changes
This commit is contained in:
parent
5dffb191ee
commit
9c143f7891
3 changed files with 152 additions and 87 deletions
|
@ -177,6 +177,8 @@ Ox.equals = function(obj0, obj1) {
|
||||||
} else if (Ox.isObject(obj0)) {
|
} else if (Ox.isObject(obj0)) {
|
||||||
ret = Ox.equals(Ox.keys(obj0), Ox.keys(obj1)) &&
|
ret = Ox.equals(Ox.keys(obj0), Ox.keys(obj1)) &&
|
||||||
Ox.equals(Ox.values(obj0), Ox.values(obj1));
|
Ox.equals(Ox.values(obj0), Ox.values(obj1));
|
||||||
|
} else if (Ox.isFunction(obj0)) {
|
||||||
|
ret = obj0.toString() == obj1.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ox.print('Ox.equals', obj0, obj1, ret)
|
Ox.print('Ox.equals', obj0, obj1, ret)
|
||||||
|
@ -1727,7 +1729,7 @@ Ox.toTitleCase = function(str) {
|
||||||
>>> Ox.toTitleCase("Apple releases iPhone, IBM stock plummets")
|
>>> Ox.toTitleCase("Apple releases iPhone, IBM stock plummets")
|
||||||
"Apple Releases iPhone, IBM Stock Plummets"
|
"Apple Releases iPhone, IBM Stock Plummets"
|
||||||
*/
|
*/
|
||||||
return $.map(str.split(" "), function(v) {
|
return $.map(str.split(' '), function(v) {
|
||||||
var sub = v.substr(1),
|
var sub = v.substr(1),
|
||||||
low = sub.toLowerCase();
|
low = sub.toLowerCase();
|
||||||
if (sub == low) {
|
if (sub == low) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ $(function() {
|
||||||
'Chrome': 'http://www.google.com/chrome/',
|
'Chrome': 'http://www.google.com/chrome/',
|
||||||
'Firefox': 'http://www.mozilla.org/firefox/',
|
'Firefox': 'http://www.mozilla.org/firefox/',
|
||||||
'Internet Explorer': '',
|
'Internet Explorer': '',
|
||||||
'Opera': '',
|
'Opera': 'http://www.opera.com/',
|
||||||
'Safari': 'http://www.apple.com/safari/'
|
'Safari': 'http://www.apple.com/safari/'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ requires
|
||||||
$elements = {},
|
$elements = {},
|
||||||
$window, $document, $body;
|
$window, $document, $body;
|
||||||
|
|
||||||
//_$elements = $elements;
|
_$elements = $elements;
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$window = $(window),
|
$window = $(window),
|
||||||
|
@ -151,6 +151,7 @@ requires
|
||||||
|
|
||||||
function getUserData() {
|
function getUserData() {
|
||||||
//return {};
|
//return {};
|
||||||
|
return {};
|
||||||
return {
|
return {
|
||||||
navigator: {
|
navigator: {
|
||||||
cookieEnabled: navigator.cookieEnabled,
|
cookieEnabled: navigator.cookieEnabled,
|
||||||
|
@ -208,7 +209,7 @@ requires
|
||||||
that.launch = function(callback) {
|
that.launch = function(callback) {
|
||||||
var time = +new Date(),
|
var time = +new Date(),
|
||||||
userAgent = getUserAgent(),
|
userAgent = getUserAgent(),
|
||||||
userAgents = ['Chrome', 'Firefox', 'Safari'];
|
userAgents = ['Chrome', 'Firefox', 'Opera', 'Safari'];
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
timeout: self.options.apiTimeout,
|
timeout: self.options.apiTimeout,
|
||||||
type: self.options.apiType,
|
type: self.options.apiType,
|
||||||
|
@ -623,7 +624,7 @@ requires
|
||||||
buffer += key == 'SPACE' ? ' ' : key;
|
buffer += key == 'SPACE' ? ' ' : key;
|
||||||
bufferTime = time;
|
bufferTime = time;
|
||||||
}
|
}
|
||||||
focused && $elements[focused].trigger('ox_key_' + key);
|
focused && $elements[focused].triggerEvent('key_' + key);
|
||||||
//return false;
|
//return false;
|
||||||
/*
|
/*
|
||||||
$.each(stack, function(i, v) {
|
$.each(stack, function(i, v) {
|
||||||
|
@ -741,12 +742,21 @@ requires
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(request.responseText);
|
data = JSON.parse(request.responseText);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
try {
|
||||||
data = {
|
data = {
|
||||||
status: {
|
status: {
|
||||||
code: request ? request.status : '0',
|
code: request.status,
|
||||||
text: request ? request.statusText : 'Unknown Error'
|
text: request.statusText
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} catch (err) {
|
||||||
|
data = {
|
||||||
|
status: {
|
||||||
|
code: '500',
|
||||||
|
text: 'Unknown Error'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.status.code < 500) {
|
if (data.status.code < 500) {
|
||||||
|
@ -884,27 +894,29 @@ requires
|
||||||
return function(options, self) {
|
return function(options, self) {
|
||||||
|
|
||||||
// construct
|
// construct
|
||||||
options = options || {};
|
|
||||||
self = self || {};
|
self = self || {};
|
||||||
|
self.options = options || {};
|
||||||
|
if (!self.$eventHandler) {
|
||||||
|
self.$eventHandler = $('<div>');
|
||||||
|
}
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
// init
|
// init
|
||||||
(function() {
|
(function() {
|
||||||
// allow for Ox.Widget('tagname', self)
|
// allow for Ox.Element('tagname', self)
|
||||||
if (typeof options == 'string') {
|
if (typeof self.options == 'string') {
|
||||||
options = {
|
self.options = {
|
||||||
element: options
|
element: self.options
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
that.ox = Ox.version;
|
that.ox = Ox.version;
|
||||||
that.id = Ox.uid();
|
that.id = Ox.uid();
|
||||||
that.$element = $('<' + (options.element || 'div') + '/>', {
|
that.$element = $('<' + (self.options.element || 'div') + '/>', {
|
||||||
data: {
|
data: {
|
||||||
ox: that.id
|
ox: that.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$elements[that.id] = that;
|
$elements[that.id] = that;
|
||||||
self.$eventHandler = $('<div>');
|
|
||||||
wrapjQuery();
|
wrapjQuery();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -1027,24 +1039,25 @@ requires
|
||||||
returns that
|
returns that
|
||||||
*/
|
*/
|
||||||
var args,
|
var args,
|
||||||
id = self.options && self.options.id,
|
|
||||||
length = arguments.length,
|
length = arguments.length,
|
||||||
oldOptions,
|
oldOptions,
|
||||||
ret;
|
ret;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
// options()
|
// options()
|
||||||
ret = self.options || options; // this is silly. make sure self.options get populated with options
|
ret = self.options;
|
||||||
} else if (length == 1 && typeof arguments[0] == 'string') {
|
} else if (length == 1 && typeof arguments[0] == 'string') {
|
||||||
// options(str)
|
// options(str)
|
||||||
ret = self.options ? self.options[arguments[0]] : options[arguments[0]];
|
ret = self.options ? self.options[arguments[0]] : options[arguments[0]];
|
||||||
} else {
|
} else {
|
||||||
// options (str, val) or options({str: val, ...})
|
// options (str, val) or options({str: val, ...})
|
||||||
// translate (str, val) to ({str: val})
|
// translate (str, val) to ({str: val})
|
||||||
args = Ox.makeObject.apply(that, arguments);
|
args = Ox.makeObject.apply(that, arguments || {});
|
||||||
oldOptions = $.extend({}, self.options);
|
oldOptions = $.extend({}, self.options);
|
||||||
// if options have not been set, extend defaults,
|
// if options have not been set, extend defaults,
|
||||||
// otherwise, extend options
|
// otherwise, extend options
|
||||||
self.options = $.extend(self.options || self.defaults, args);
|
//self.options = $.extend(self.options, self.options ? {} : self.defaults, args);
|
||||||
|
self.options = $.extend({}, self.defaults, self.options, args);
|
||||||
|
//self.options = $.extend(self.options || self.defaults, args);
|
||||||
$.each(args, function(key, value) {
|
$.each(args, function(key, value) {
|
||||||
// key == 'id' && id && Ox.Event.changeId(id, value);
|
// key == 'id' && id && Ox.Event.changeId(id, value);
|
||||||
/*!Ox.equals(value, oldOptions[key]) &&*/ self.onChange(key, value);
|
/*!Ox.equals(value, oldOptions[key]) &&*/ self.onChange(key, value);
|
||||||
|
@ -1057,7 +1070,7 @@ requires
|
||||||
that.remove = function() { // fixme: clashes with jquery, should be removeElement
|
that.remove = function() { // fixme: clashes with jquery, should be removeElement
|
||||||
//self.options && Ox.Event.unbind(self.options.id); // there are optionless elements, like the dialog layer
|
//self.options && Ox.Event.unbind(self.options.id); // there are optionless elements, like the dialog layer
|
||||||
//that.loseFocus();
|
//that.loseFocus();
|
||||||
delete self.$eventHandler;
|
//delete self.$eventHandler;
|
||||||
that.$element.remove();
|
that.$element.remove();
|
||||||
delete $elements[that.ox];
|
delete $elements[that.ox];
|
||||||
return that;
|
return that;
|
||||||
|
@ -1074,7 +1087,7 @@ requires
|
||||||
self.$eventHandler.trigger('ox_' + event, data);
|
self.$eventHandler.trigger('ox_' + event, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Ox.print(that.id, self.options ? self.options.id : '', 'trigger', arguments[0], arguments[1] || {});
|
Ox.print('??', that.id, self.options ? self.options.id : '', 'trigger', arguments[0], arguments[1] || {});
|
||||||
self.$eventHandler.trigger('ox_' + arguments[0], arguments[1] || {});
|
self.$eventHandler.trigger('ox_' + arguments[0], arguments[1] || {});
|
||||||
}
|
}
|
||||||
return that;
|
return that;
|
||||||
|
@ -5762,8 +5775,11 @@ requires
|
||||||
id: '',
|
id: '',
|
||||||
item: function() {},
|
item: function() {},
|
||||||
keys: [],
|
keys: [],
|
||||||
|
max: -1,
|
||||||
|
min: 0,
|
||||||
orientation: 'both',
|
orientation: 'both',
|
||||||
request: function() {},
|
request: function() {},
|
||||||
|
selected: [],
|
||||||
size: 128,
|
size: 128,
|
||||||
sort: [],
|
sort: [],
|
||||||
})
|
})
|
||||||
|
@ -5782,12 +5798,15 @@ requires
|
||||||
keys: self.options.keys,
|
keys: self.options.keys,
|
||||||
orientation: self.options.orientation,
|
orientation: self.options.orientation,
|
||||||
keys: self.options.keys,
|
keys: self.options.keys,
|
||||||
|
max: self.options.max,
|
||||||
|
min: self.options.min,
|
||||||
request: self.options.request,
|
request: self.options.request,
|
||||||
|
selected: self.options.selected,
|
||||||
size: self.options.size,
|
size: self.options.size,
|
||||||
sort: self.options.sort,
|
sort: self.options.sort,
|
||||||
type: 'icon',
|
type: 'icon',
|
||||||
unique: self.options.unique
|
unique: self.options.unique
|
||||||
}/*, self*/)
|
}, $.extend({}, self)) // pass event handler
|
||||||
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
|
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
|
||||||
.click(click)
|
.click(click)
|
||||||
.dblclick(dblclick)
|
.dblclick(dblclick)
|
||||||
|
@ -5867,9 +5886,9 @@ requires
|
||||||
.options(options || {})
|
.options(options || {})
|
||||||
|
|
||||||
$.extend(self, {
|
$.extend(self, {
|
||||||
fontSize: self.options.size == 64 ? 7 : 9,
|
fontSize: self.options.size == 64 ? 6 : 9,
|
||||||
height: self.options.size * 1.5,
|
height: self.options.size * 1.5,
|
||||||
lineLength: self.options.size == 64 ? 17 : 23,
|
lineLength: self.options.size == 64 ? 15 : 23,
|
||||||
lines: self.options.size == 64 ? 4 : 5,
|
lines: self.options.size == 64 ? 4 : 5,
|
||||||
url: oxui.path + '/png/ox.ui/transparent.png',
|
url: oxui.path + '/png/ox.ui/transparent.png',
|
||||||
width: self.options.size
|
width: self.options.size
|
||||||
|
@ -5884,7 +5903,7 @@ requires
|
||||||
that.$icon = $('<div>')
|
that.$icon = $('<div>')
|
||||||
.addClass('OxIcon')
|
.addClass('OxIcon')
|
||||||
.css({
|
.css({
|
||||||
top: self.options.size == 64 ? -72 : -124,
|
top: self.options.size == 64 ? -64 : -124,
|
||||||
width: (self.options.size + 4) + 'px',
|
width: (self.options.size + 4) + 'px',
|
||||||
height: (self.options.size + 4) + 'px'
|
height: (self.options.size + 4) + 'px'
|
||||||
});
|
});
|
||||||
|
@ -5906,7 +5925,7 @@ requires
|
||||||
.css({
|
.css({
|
||||||
top: (self.options.size / 2) + 'px',
|
top: (self.options.size / 2) + 'px',
|
||||||
width: (self.options.size + 4) + 'px',
|
width: (self.options.size + 4) + 'px',
|
||||||
height: (self.options.size == 64 ? 38 : 58) + 'px'
|
height: (self.options.size == 64 ? 30 : 58) + 'px'
|
||||||
})
|
})
|
||||||
that.$text = $('<div>')
|
that.$text = $('<div>')
|
||||||
.addClass('OxTarget')
|
.addClass('OxTarget')
|
||||||
|
@ -6013,9 +6032,12 @@ requires
|
||||||
itemHeight: 16,
|
itemHeight: 16,
|
||||||
itemWidth: 16,
|
itemWidth: 16,
|
||||||
keys: [],
|
keys: [],
|
||||||
|
max: -1,
|
||||||
|
min: 0,
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
pageLength: 100,
|
pageLength: 100,
|
||||||
request: function() {}, // (data, callback), without data returns {items, size etc.}
|
request: function() {}, // (data, callback), without data returns {items, size etc.}
|
||||||
|
selected: [],
|
||||||
sort: [],
|
sort: [],
|
||||||
type: 'text',
|
type: 'text',
|
||||||
unique: ''
|
unique: ''
|
||||||
|
@ -6032,9 +6054,6 @@ requires
|
||||||
ids: {},
|
ids: {},
|
||||||
itemMargin: self.options.type == 'text' ? 0 : 8, // 2 x 4 px margin ... fixme: the 2x should be computed later
|
itemMargin: self.options.type == 'text' ? 0 : 8, // 2 x 4 px margin ... fixme: the 2x should be computed later
|
||||||
keyboardEvents: {
|
keyboardEvents: {
|
||||||
key_alt_control_a: invertSelection,
|
|
||||||
key_control_a: selectAll,
|
|
||||||
key_control_shift_a: selectNone,
|
|
||||||
key_end: scrollToFirst,
|
key_end: scrollToFirst,
|
||||||
key_enter: open,
|
key_enter: open,
|
||||||
key_home: scrollToLast,
|
key_home: scrollToLast,
|
||||||
|
@ -6050,23 +6069,41 @@ requires
|
||||||
scrollTimeout: 0,
|
scrollTimeout: 0,
|
||||||
selected: []
|
selected: []
|
||||||
});
|
});
|
||||||
|
if (self.options.max == -1) {
|
||||||
|
$.extend(self.keyboardEvents, {
|
||||||
|
key_alt_control_a: invertSelection,
|
||||||
|
key_control_a: selectAll
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (self.options.min == 0) {
|
||||||
|
$.extend(self.keyboardEvents, {
|
||||||
|
key_control_shift_a: selectNone
|
||||||
|
});
|
||||||
|
}
|
||||||
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'up' : 'left')] = selectPrevious;
|
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'up' : 'left')] = selectPrevious;
|
||||||
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'down' : 'right')] = selectNext;
|
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'down' : 'right')] = selectNext;
|
||||||
|
if (self.options.max == -1) {
|
||||||
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'shift_up' : 'shift_left')] = addPreviousToSelection;
|
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'shift_up' : 'shift_left')] = addPreviousToSelection;
|
||||||
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'shift_down' : 'shift_right')] = addNextToSelection;
|
self.keyboardEvents['key_' + (self.options.orientation == 'vertical' ? 'shift_down' : 'shift_right')] = addNextToSelection;
|
||||||
|
}
|
||||||
if (self.options.orientation == 'both') {
|
if (self.options.orientation == 'both') {
|
||||||
$.extend(self.keyboardEvents, {
|
$.extend(self.keyboardEvents, {
|
||||||
key_down: selectBelow,
|
key_down: selectBelow,
|
||||||
key_up: selectAbove,
|
key_up: selectAbove
|
||||||
|
});
|
||||||
|
if (self.options.max == -1) {
|
||||||
|
$.extend(self.keyboardEvents, {
|
||||||
key_shift_down: addBelowToSelection,
|
key_shift_down: addBelowToSelection,
|
||||||
key_shift_up: addAboveToSelection
|
key_shift_up: addAboveToSelection
|
||||||
});
|
});
|
||||||
|
}
|
||||||
self.pageLengthByRowLength = [
|
self.pageLengthByRowLength = [
|
||||||
0, 60, 60, 60, 60, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68, 72, 76, 60
|
0, 60, 60, 60, 60, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68, 72, 76, 60
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
updateQuery();
|
updateQuery();
|
||||||
|
self.options.selected.length && getPositions(self.options.selected);
|
||||||
Ox.print('s.o', self.options)
|
Ox.print('s.o', self.options)
|
||||||
that.bindEvent(self.keyboardEvents);
|
that.bindEvent(self.keyboardEvents);
|
||||||
$window.resize(that.size);
|
$window.resize(that.size);
|
||||||
|
@ -6252,8 +6289,10 @@ requires
|
||||||
return that.height() - (that.$content.width() > that.width() ? oxui.scrollbarSize : 0);
|
return that.height() - (that.$content.width() > that.width() ? oxui.scrollbarSize : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListHeight() {
|
function getListSize() {
|
||||||
return Math.ceil(self.listLength * (self.options.itemHeight + self.itemMargin) / self.rowLength); // fixme: should be listSize
|
return Math.ceil(self.listLength *
|
||||||
|
(self.options[self.options.orientation == 'horizontal' ?
|
||||||
|
'itemWidth' : 'itemHeight'] + self.itemMargin) / self.rowLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNext() {
|
function getNext() {
|
||||||
|
@ -6293,22 +6332,21 @@ requires
|
||||||
) * self.rowLength;
|
) * self.rowLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPositions() {
|
function getPositions(ids) {
|
||||||
Ox.print('getPositions', $.map(self.selected, function(v, i) {
|
ids = ids || getSelectedIds();
|
||||||
return self.ids[v];
|
|
||||||
}));
|
|
||||||
// fixme: optimize: send non-selected ids if more than half of the items are selected
|
// fixme: optimize: send non-selected ids if more than half of the items are selected
|
||||||
if (self.selected.length /*&& self.selected.length < self.listLength*/) {
|
if (ids.length /*&& ids.length < self.listLength*/) {
|
||||||
Ox.print('-- request', {
|
alert('getPositions ' + JSON.stringify(ids) )
|
||||||
ids: $.map(self.selected, function(v, i) {
|
Ox.print('-------- request', {
|
||||||
return self.ids[v];
|
ids: ids,
|
||||||
}),
|
|
||||||
sort: self.options.sort
|
sort: self.options.sort
|
||||||
});
|
});
|
||||||
|
alert(JSON.stringify({
|
||||||
|
ids: ids,
|
||||||
|
sort: self.options.sort
|
||||||
|
}))
|
||||||
self.requests.push(self.options.request({
|
self.requests.push(self.options.request({
|
||||||
ids: $.map(self.selected, function(v, i) {
|
ids: ids,
|
||||||
return self.ids[v];
|
|
||||||
}),
|
|
||||||
sort: self.options.sort
|
sort: self.options.sort
|
||||||
}, getPositionsCallback));
|
}, getPositionsCallback));
|
||||||
} else {
|
} else {
|
||||||
|
@ -6320,6 +6358,7 @@ requires
|
||||||
Ox.print('getPositionsCallback', result)
|
Ox.print('getPositionsCallback', result)
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
if (result) {
|
if (result) {
|
||||||
|
alert('getPositionsCallback ' + JSON.stringify(result))
|
||||||
$.extend(self, {
|
$.extend(self, {
|
||||||
ids: {},
|
ids: {},
|
||||||
selected: []
|
selected: []
|
||||||
|
@ -6398,15 +6437,19 @@ requires
|
||||||
range: range,
|
range: range,
|
||||||
sort: self.options.sort
|
sort: self.options.sort
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
self.$pages[page] = new Ox.ListPage()
|
self.$pages[page] = new Ox.ListPage();
|
||||||
.css({
|
|
||||||
width: self.pageWidth + 'px'
|
|
||||||
});
|
|
||||||
if (self.options.orientation == 'horizontal') {
|
if (self.options.orientation == 'horizontal') {
|
||||||
|
self.$pages[page].css({
|
||||||
|
left: (page * self.pageWidth + self.listMargin / 2) + 'px',
|
||||||
|
top: (self.listMargin / 2) + 'px',
|
||||||
|
width: (page < self.pages - 1 ? self.pageWidth :
|
||||||
|
self.listLength % self.pageLength *
|
||||||
|
(self.options.itemWidth + self.itemMargin)) + 'px'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
self.$pages[page].css({
|
self.$pages[page].css({
|
||||||
top: (page * self.pageHeight + self.listMargin / 2) + 'px'
|
top: (page * self.pageHeight + self.listMargin / 2) + 'px',
|
||||||
|
width: self.pageWidth + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$.each(result.data.items, function(i, v) {
|
$.each(result.data.items, function(i, v) {
|
||||||
|
@ -6459,13 +6502,13 @@ requires
|
||||||
if (!self.clickTimeout) {
|
if (!self.clickTimeout) {
|
||||||
// click
|
// click
|
||||||
pos = $item.data('position');
|
pos = $item.data('position');
|
||||||
if (e.metaKey) {
|
if (e.metaKey && self.options.max == -1) {
|
||||||
if (!isSelected(pos)) {
|
if (!isSelected(pos)) {
|
||||||
addToSelection(pos);
|
addToSelection(pos);
|
||||||
} else {
|
} else {
|
||||||
deselectTimeout = true;
|
deselectTimeout = true;
|
||||||
}
|
}
|
||||||
} else if (e.shiftKey) {
|
} else if (e.shiftKey && self.options.max == -1) {
|
||||||
addAllToSelection(pos);
|
addAllToSelection(pos);
|
||||||
} else if (!isSelected(pos)) {
|
} else if (!isSelected(pos)) {
|
||||||
select(pos);
|
select(pos);
|
||||||
|
@ -6486,7 +6529,7 @@ requires
|
||||||
self.clickTimeout = 0;
|
self.clickTimeout = 0;
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (self.options.min == 0) {
|
||||||
selectNone();
|
selectNone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6549,12 +6592,22 @@ requires
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollTo(value) {
|
function scrollTo(value) {
|
||||||
that.animate({
|
that.animate(self.options.orientation == 'horizontal' ? {
|
||||||
scrollTop: (self.listHeight * value) + 'px'
|
scrollLeft: (self.listSize * value) + 'px'
|
||||||
}, 0)
|
} : {
|
||||||
|
scrollTop: (self.listSize * value) + 'px'
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollToPosition(pos, topAlign) {
|
function scrollToFirst() {
|
||||||
|
that[self.options.orientation == 'horizontal' ? 'scrollLeft' : 'scrollTop'](0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToLast() {
|
||||||
|
that[self.options.orientation == 'horizontal' ? 'scrollLeft' : 'scrollTop'](self.listSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToPosition(pos, leftOrTopAlign) {
|
||||||
var itemHeight = self.options.itemHeight + self.itemMargin,
|
var itemHeight = self.options.itemHeight + self.itemMargin,
|
||||||
itemWidth = self.options.itemWidth + self.itemMargin,
|
itemWidth = self.options.itemWidth + self.itemMargin,
|
||||||
positions = [],
|
positions = [],
|
||||||
|
@ -6562,15 +6615,24 @@ requires
|
||||||
size;
|
size;
|
||||||
if (self.options.orientation == 'horizontal') {
|
if (self.options.orientation == 'horizontal') {
|
||||||
positions[0] = pos * itemWidth;
|
positions[0] = pos * itemWidth;
|
||||||
positions[1] = positions[0] + itemWidth;
|
positions[1] = positions[0] + itemWidth + self.itemMargin;
|
||||||
scroll = that.scrollLeft();
|
scroll = that.scrollLeft();
|
||||||
size = getWidth();
|
size = getWidth();
|
||||||
|
if (positions[0] < scroll || leftOrTopAlign) {
|
||||||
|
that.animate({
|
||||||
|
scrollLeft: positions[0] + 'px'
|
||||||
|
}, 0);
|
||||||
|
} else if (positions[1] > scroll + size) {
|
||||||
|
that.animate({
|
||||||
|
scrollLeft: (positions[1] - size) + 'px'
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
positions[0] = (self.options.orientation == 'vertical' ? pos : getRow(pos)) * itemHeight;
|
positions[0] = (self.options.orientation == 'vertical' ? pos : getRow(pos)) * itemHeight;
|
||||||
positions[1] = positions[0] + itemHeight + (self.options.orientation == 'vertical' ? 0 : self.itemMargin);
|
positions[1] = positions[0] + itemHeight + (self.options.orientation == 'vertical' ? 0 : self.itemMargin);
|
||||||
scroll = that.scrollTop();
|
scroll = that.scrollTop();
|
||||||
size = getHeight();
|
size = getHeight();
|
||||||
if (positions[0] < scroll || topAlign) {
|
if (positions[0] < scroll || leftOrTopAlign) {
|
||||||
that.animate({
|
that.animate({
|
||||||
scrollTop: positions[0] + 'px'
|
scrollTop: positions[0] + 'px'
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -6582,14 +6644,6 @@ requires
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollToFirst() {
|
|
||||||
that.scrollTop(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollToLast() {
|
|
||||||
that.scrollTop(self.listHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
function select(pos) {
|
function select(pos) {
|
||||||
if (!isSelected(pos) || self.selected.length > 1) {
|
if (!isSelected(pos) || self.selected.length > 1) {
|
||||||
selectNone();
|
selectNone();
|
||||||
|
@ -6710,15 +6764,18 @@ requires
|
||||||
listLength: result.data.items,
|
listLength: result.data.items,
|
||||||
pages: Math.ceil(result.data.items / self.pageLength),
|
pages: Math.ceil(result.data.items / self.pageLength),
|
||||||
pageWidth: self.options.orientation == 'vertical' ? 0 :
|
pageWidth: self.options.orientation == 'vertical' ? 0 :
|
||||||
(self.options.itemWidth + self.itemMargin) * self.rowLength,
|
(self.options.itemWidth + self.itemMargin) *
|
||||||
|
(self.options.orientation == 'horizontal' ?
|
||||||
|
self.pageLength : self.rowLength),
|
||||||
pageHeight: self.options.orientation == 'horizontal' ? 0 :
|
pageHeight: self.options.orientation == 'horizontal' ? 0 :
|
||||||
Math.ceil(self.pageLength * (self.options.itemHeight + self.itemMargin) / self.rowLength)
|
Math.ceil(self.pageLength * (self.options.itemHeight +
|
||||||
});
|
self.itemMargin) / self.rowLength)
|
||||||
self.listHeight = getListHeight();
|
|
||||||
Ox.print('list self', self, self.listHeight);
|
|
||||||
that.$content.css({
|
|
||||||
height: self.listHeight + 'px'
|
|
||||||
});
|
});
|
||||||
|
self.listSize = getListSize();
|
||||||
|
that.$content.css(
|
||||||
|
self.options.orientation == 'horizontal' ? 'width' : 'height',
|
||||||
|
self.listSize + 'px'
|
||||||
|
);
|
||||||
getPositions();
|
getPositions();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -6728,13 +6785,13 @@ requires
|
||||||
clear();
|
clear();
|
||||||
self.pageLength = self.pageLengthByRowLength[self.rowLength]
|
self.pageLength = self.pageLengthByRowLength[self.rowLength]
|
||||||
$.extend(self, {
|
$.extend(self, {
|
||||||
listHeight: getListHeight(), // fixme: should be listSize
|
listSize: getListSize(),
|
||||||
pages: Math.ceil(self.listLength / self.pageLength),
|
pages: Math.ceil(self.listLength / self.pageLength),
|
||||||
pageWidth: (self.options.itemWidth + self.itemMargin) * self.rowLength,
|
pageWidth: (self.options.itemWidth + self.itemMargin) * self.rowLength,
|
||||||
pageHeight: getPageHeight()
|
pageHeight: getPageHeight()
|
||||||
});
|
});
|
||||||
that.$content.css({
|
that.$content.css({
|
||||||
height: self.listHeight + 'px'
|
height: self.listSize + 'px'
|
||||||
});
|
});
|
||||||
self.page = getPageByPosition(pos);
|
self.page = getPageByPosition(pos);
|
||||||
//that.scrollTop(0);
|
//that.scrollTop(0);
|
||||||
|
@ -6782,7 +6839,7 @@ requires
|
||||||
var rowLength = getRowLength(),
|
var rowLength = getRowLength(),
|
||||||
pageLength = self.pageLengthByRowLength[rowLength],
|
pageLength = self.pageLengthByRowLength[rowLength],
|
||||||
pos = getPosition(),
|
pos = getPosition(),
|
||||||
scroll = that.scrollTop() / self.listHeight;
|
scroll = that.scrollTop() / self.listSize;
|
||||||
if (pageLength != self.pageLength) {
|
if (pageLength != self.pageLength) {
|
||||||
self.pageLength = pageLength;
|
self.pageLength = pageLength;
|
||||||
self.rowLength = rowLength;
|
self.rowLength = rowLength;
|
||||||
|
@ -6790,7 +6847,7 @@ requires
|
||||||
} else if (rowLength != self.rowLength) {
|
} else if (rowLength != self.rowLength) {
|
||||||
self.rowLength = rowLength;
|
self.rowLength = rowLength;
|
||||||
self.pageWidth = (self.options.itemWidth + self.itemMargin) * self.rowLength; // fixme: make function
|
self.pageWidth = (self.options.itemWidth + self.itemMargin) * self.rowLength; // fixme: make function
|
||||||
self.listHeight = getListHeight();
|
self.listSize = getListSize();
|
||||||
self.pageHeight = getPageHeight();
|
self.pageHeight = getPageHeight();
|
||||||
$.each(self.$pages, function(i, $page) {
|
$.each(self.$pages, function(i, $page) {
|
||||||
!Ox.isUndefined($page) && $page.css({
|
!Ox.isUndefined($page) && $page.css({
|
||||||
|
@ -6799,7 +6856,7 @@ requires
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
that.$content.css({
|
that.$content.css({
|
||||||
height: self.listHeight + 'px'
|
height: self.listSize + 'px'
|
||||||
});
|
});
|
||||||
Ox.print('scrolling to', scroll)
|
Ox.print('scrolling to', scroll)
|
||||||
scrollTo(scroll);
|
scrollTo(scroll);
|
||||||
|
@ -6872,6 +6929,9 @@ requires
|
||||||
columnsResizable: false,
|
columnsResizable: false,
|
||||||
columnWidth: [40, 800],
|
columnWidth: [40, 800],
|
||||||
id: '',
|
id: '',
|
||||||
|
max: -1,
|
||||||
|
min: 0,
|
||||||
|
selected: [],
|
||||||
request: function() {}, // {sort, range, keys, callback}
|
request: function() {}, // {sort, range, keys, callback}
|
||||||
sort: []
|
sort: []
|
||||||
})
|
})
|
||||||
|
@ -6948,12 +7008,15 @@ requires
|
||||||
keys: $.map(self.visibleColumns, function(v, i) {
|
keys: $.map(self.visibleColumns, function(v, i) {
|
||||||
return v.id;
|
return v.id;
|
||||||
}),
|
}),
|
||||||
|
max: self.options.max,
|
||||||
|
min: self.options.min,
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
request: self.options.request,
|
request: self.options.request,
|
||||||
|
selected: self.options.selected,
|
||||||
sort: self.options.sort,
|
sort: self.options.sort,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
unique: self.unique
|
unique: self.unique
|
||||||
})
|
}, $.extend({}, self)) // pass event handler
|
||||||
.addClass('OxBody')
|
.addClass('OxBody')
|
||||||
.scroll(function() {
|
.scroll(function() {
|
||||||
var scrollLeft = $(this).scrollLeft();
|
var scrollLeft = $(this).scrollLeft();
|
||||||
|
|
Loading…
Reference in a new issue