better resizing in editor

This commit is contained in:
rolux 2010-11-25 10:05:50 +00:00
parent df324f8efa
commit d4a17c5972

View file

@ -1520,12 +1520,14 @@ requires
}
function dragStart(e) {
if (!self.options.collapsed) {
self.startPos = e[self.clientXY];
self.startSize = self.options.size;
Ox.print('startSize', self.startSize)
$window.mousemove(drag);
$window.one('mouseup', dragStop);
}
}
function dragStop() {
$window.unbind('mousemove');
@ -1780,7 +1782,7 @@ requires
triggerResizeEvent();
}
function resize(event) {
function resize(event) { // fixme: reserved jquery string?
var documentWidth = $document.width(),
documentHeight = $document.height(),
elementWidth = that.width(),
@ -1899,7 +1901,7 @@ requires
return that;
};
that.resize = function(width, height, callback) {
that.size = function(width, height, callback) {
$.extend(self, {
initialWidth: width,
initialHeight: height
@ -5767,8 +5769,8 @@ requires
that.$element.closePreview();
};
that.resize = function() {
that.$element.resize();
that.size = function() {
that.$element.size();
}
that.sortList = function(key, operator) {
@ -6001,7 +6003,7 @@ requires
updateQuery();
Ox.print('s.o', self.options)
that.addEvent(self.keyboardEvents);
$window.resize(that.resize);
$window.resize(that.size);
function addAboveToSelection() {
var pos = getAbove();
@ -6204,6 +6206,10 @@ requires
), 0);
}
function getPageByPosition(pos) {
return parseInt(self.options.pageLength / pos);
}
function getPositions() {
Ox.print('getPositions', $.map(self.selected, function(v, i) {
return self.ids[v];
@ -6223,6 +6229,7 @@ requires
function getPositionsCallback(result) {
Ox.print('getPositionsCallback', result)
var pos = 0;
if (result) {
$.extend(self, {
ids: {},
@ -6232,8 +6239,14 @@ requires
Ox.print('id', id, 'pos', pos)
self.selected.push(pos);
});
pos = Ox.min(self.selected);
self.page = getPageByPosition(pos);
}
load();
that.scrollTop(0);
that.$content.empty();
loadPages(self.page, function() {
scrollTo(pos);
});
}
function getPrevious() {
@ -6277,12 +6290,6 @@ requires
return self.selected.indexOf(pos) > -1;
}
function load() {
that.scrollTop(0);
that.$content.empty();
loadPages(self.page);
}
function loadPage(page, callback) {
if (page < 0 || page >= self.pages) {
!Ox.isUndefined(callback) && callback();
@ -6340,8 +6347,7 @@ requires
function loadPages(page, callback) {
var counter = 0,
fn = function() {
counter++;
counter == 2 && !Ox.isUndefined(callback) && callback();
++counter == 2 && !Ox.isUndefined(callback) && callback();
};
loadPage(page, function() {
loadPage(page - 1, fn);
@ -6651,7 +6657,7 @@ requires
return that;
};
that.resize = function() {
that.size = function() {
if (self.options.orientation == 'both') {
var rowLength = getRowLength(),
pageLength = self.pageLengthByRowLength[rowLength];
@ -6667,7 +6673,7 @@ requires
});
}
} else if (self.options.type == 'text') {
Ox.print('that.resize, type==text')
Ox.print('that.size, type==text')
emptyFirstPage();
fillFirstPage();
}
@ -7192,9 +7198,9 @@ requires
that.$body.closePreview();
};
that.resize = function() {
that.size = function() {
setWidth();
that.$body.resize();
that.$body.size();
}
that.resizeColumn = function(id, width) {
@ -8869,7 +8875,7 @@ requires
Ox.print(self.options.elements[pos])
};
that.resize = function(id, size) {
that.size = function(id, size) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id);
// Ox.print('pos', pos, self.options.elements, $.map(self.options.elements, function(v, i) { return v.element.options('id'); }))
@ -9223,6 +9229,10 @@ requires
margin: 8
});
that.css({
height: ((self.height + self.margin) * self.lines + 4) + 'px'
});
getTimelineImageURL(function(url) {
self.timelineImageURL = url;
@ -9488,6 +9498,7 @@ requires
duration: 0,
find: '',
frameURL: function() {},
height: 0,
largeTimeline: true,
matches: [],
points: [0, 0],
@ -9502,7 +9513,12 @@ requires
width: 0
})
.options(options || {})
.addClass('OxEditor');
.addClass('OxEditor')
.css({
height: self.options.height + 'px',
overflowY: 'auto',
width: self.options.width + 'px'
});
$.extend(self, {
$player: [],
@ -9716,14 +9732,16 @@ requires
}
function getSizes() {
var size = {
var scrollbarWidth = oxui.scrollbarSize,
contentWidth = self.options.width - scrollbarWidth,
size = {
player: [],
timeline: []
},
width, widths;
if (self.options.videoSize == 'small') {
width = 0;
widths = Ox.divideInt(self.options.width - 4 * self.margin, 3);
widths = Ox.divideInt(contentWidth - 4 * self.margin, 3);
[1, 0, 2].forEach(function(v, i) {
size.player[v] = {
left: (i + 0.5) * self.margin + width,
@ -9737,13 +9755,13 @@ requires
size.player[0] = {
left: self.margin / 2,
top: self.margin / 2,
width: Math.round((self.options.width - 3 * self.margin + (self.controlsHeight + self.margin) / 2 * self.videoRatio) * 2/3),
width: Math.round((contentWidth - 3 * self.margin + (self.controlsHeight + self.margin) / 2 * self.videoRatio) * 2/3),
}
size.player[0].height = Math.round(size.player[0].width / self.videoRatio);
size.player[1] = {
left: size.player[0].left + size.player[0].width + self.margin,
top: size.player[0].top,
width: self.options.width - 3 * self.margin - size.player[0].width
width: contentWidth - 3 * self.margin - size.player[0].width
}
size.player[1].height = Math.ceil(size.player[1].width / self.videoRatio)
size.player[2] = {
@ -9756,7 +9774,7 @@ requires
size.timeline[0] = {
left: self.margin / 2,
top: size.player[0].height + self.controlsHeight + 1.5 * self.margin,
width: self.options.width - 2 * self.margin,
width: contentWidth - 2 * self.margin,
height: 64
}
size.timeline[1] = {
@ -9891,6 +9909,7 @@ requires
self.onChange = function(key, value) {
if (key == 'width') {
that.width(value);
setSizes();
}
};