copy & paste
This commit is contained in:
parent
f7b61b9907
commit
bb9f04b7e8
2 changed files with 126 additions and 18 deletions
|
@ -1597,6 +1597,17 @@ Ox.sinh = function(x) {
|
|||
return (Math.exp(x) - Math.exp(-x)) / 2;
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
RegExp functions
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
Ox.regexp = {
|
||||
'accents': '¨´`ˆ˜',
|
||||
'letters': 'a-z¨´`ˆ˜äåáàâãæçëéèèñïíìîöóòôõøœßúùûÿ'
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
String functions
|
||||
|
|
|
@ -275,6 +275,22 @@ requires
|
|||
|
||||
}();
|
||||
|
||||
Ox.Clipboard = function() {
|
||||
var clipboard = {};
|
||||
return {
|
||||
_print: function() {
|
||||
Ox.print(JSON.stringify(clipboard));
|
||||
},
|
||||
copy: function(data) {
|
||||
clipboard = data;
|
||||
Ox.print('copy', JSON.stringify(clipboard));
|
||||
},
|
||||
paste: function(type) {
|
||||
return clipboard;
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
/**
|
||||
Ox.Event event object
|
||||
*/
|
||||
|
@ -413,8 +429,6 @@ requires
|
|||
if (index > -1 && index == stack.length - 1) {
|
||||
stack.length == 1 ? stack.pop() :
|
||||
stack.splice(stack.length - 2, 0, stack.pop());
|
||||
// fix later: Ox.Event.unbindKeyboard($elements[id].options('id'));
|
||||
// fix later: stack.length && Ox.Event.bindKeyboard($elements[stack[stack.length - 1]].options('id'));
|
||||
//$elements[id].removeClass('OxFocus');
|
||||
$('.OxFocus').removeClass('OxFocus'); // fixme: the above is better, and should work
|
||||
stack.length && $elements[stack[stack.length - 1]].addClass('OxFocus');
|
||||
|
@ -424,10 +438,8 @@ requires
|
|||
focus: function(id) {
|
||||
var index = stack.indexOf(id);
|
||||
if (index == -1 || index < stack.length - 1) {
|
||||
// fix later: stack.length && Ox.Event.unbindKeyboard($elements[stack[stack.length - 1]].options('id'));
|
||||
index > -1 && stack.splice(index, 1);
|
||||
stack.push(id);
|
||||
// fix later: Ox.Event.bindKeyboard($elements[id].options('id'));
|
||||
$('.OxFocus').removeClass('OxFocus'); // fixme: see above
|
||||
$elements[id].addClass('OxFocus');
|
||||
Ox.print('focus', id, stack);
|
||||
|
@ -2587,6 +2599,7 @@ requires
|
|||
.bindEvent($.extend(self.options.type == 'textarea' ? {} : {
|
||||
key_enter: submit
|
||||
}, {
|
||||
key_control_v: paste,
|
||||
key_escape: cancel
|
||||
}));
|
||||
|
||||
|
@ -3088,6 +3101,11 @@ requires
|
|||
}
|
||||
}
|
||||
|
||||
function paste() {
|
||||
var data = Ox.Clipboard.paste();
|
||||
data.text && self.$input.val(data.text);
|
||||
}
|
||||
|
||||
function selectMenu(event, data) {
|
||||
var pos = cursor();
|
||||
//Ox.print('selectMenu', pos)
|
||||
|
@ -3159,7 +3177,7 @@ requires
|
|||
} else if (key == 'placeholder') {
|
||||
setPlaceholder();
|
||||
} else if (key == 'value') {
|
||||
val = self.$input.val();
|
||||
val = self.$input.val(); // fixme: ??
|
||||
self.$input.val(value);
|
||||
setPlaceholder();
|
||||
} else if (key == 'width') {
|
||||
|
@ -5887,6 +5905,8 @@ requires
|
|||
self.onChange = function(key, value) {
|
||||
if (key == 'request') {
|
||||
that.$element.options(key, value);
|
||||
} else if (key == 'paste') {
|
||||
that.$element.options(key, value);
|
||||
} else if (key == 'selected') {
|
||||
that.$element.options(key, value);
|
||||
}
|
||||
|
@ -5896,13 +5916,23 @@ requires
|
|||
that.$element.closePreview();
|
||||
};
|
||||
|
||||
that.paste = function(data) {
|
||||
that.$element.paste(data);
|
||||
return that;
|
||||
};
|
||||
|
||||
that.reloadList = function() {
|
||||
that.$element.reloadList();
|
||||
return that;
|
||||
};
|
||||
|
||||
that.scrollToSelection = function() {
|
||||
that.$element.scrollToSelection();
|
||||
};
|
||||
|
||||
that.size = function() {
|
||||
that.$element.size();
|
||||
}
|
||||
};
|
||||
|
||||
that.sortList = function(key, operator) {
|
||||
self.options.sort = [{
|
||||
|
@ -5911,6 +5941,18 @@ requires
|
|||
}];
|
||||
updateKeys();
|
||||
that.$element.sortList(key, operator);
|
||||
};
|
||||
|
||||
that.value = function(id, key, value) {
|
||||
// fixme: make this accept id, {k: v, ...}
|
||||
if (arguments.length == 1) {
|
||||
return that.$element.value(id);
|
||||
} else if (arguments.length == 2) {
|
||||
return that.$element.value(id, key);
|
||||
} else {
|
||||
that.$element.value(id, key, value);
|
||||
return that;
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
|
@ -6110,7 +6152,10 @@ requires
|
|||
ids: [],
|
||||
itemMargin: self.options.type == 'text' ? 0 : 8, // 2 x 4 px margin ... fixme: the 2x should be computed later
|
||||
keyboardEvents: {
|
||||
key_backspace: deleteItems,
|
||||
key_control_c: copyItems,
|
||||
key_control_n: addItem,
|
||||
key_control_v: pasteItems,
|
||||
key_control_x: cutItems,
|
||||
key_delete: deleteItems,
|
||||
key_end: scrollToFirst,
|
||||
key_enter: open,
|
||||
|
@ -6230,6 +6275,10 @@ requires
|
|||
}
|
||||
}
|
||||
|
||||
function addItem() {
|
||||
that.triggerEvent('add', {});
|
||||
}
|
||||
|
||||
function addNextToSelection() {
|
||||
var pos = getNext();
|
||||
if (pos > -1) {
|
||||
|
@ -6289,6 +6338,27 @@ requires
|
|||
return $page;
|
||||
}
|
||||
|
||||
function copyItems() {
|
||||
var ids = getSelectedIds();
|
||||
ids.length && that.triggerEvent('copy', {
|
||||
ids: ids
|
||||
});
|
||||
/*
|
||||
ids.length && self.options.copy && Ox.Clipboard.copy(
|
||||
self.options.copy(
|
||||
$.map(ids, function(id) {
|
||||
return that.value(id);
|
||||
})
|
||||
)
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
function cutItems() {
|
||||
copyItems();
|
||||
deleteItems();
|
||||
}
|
||||
|
||||
function deleteItems() {
|
||||
var ids = getSelectedIds();
|
||||
ids.length && that.triggerEvent('delete', {
|
||||
|
@ -6750,6 +6820,10 @@ requires
|
|||
});
|
||||
}
|
||||
|
||||
function pasteItems() {
|
||||
that.triggerEvent('paste', Ox.Clipboard.paste());
|
||||
}
|
||||
|
||||
function preview() {
|
||||
var ids = getSelectedIds();
|
||||
if (ids.length) {
|
||||
|
@ -6880,9 +6954,8 @@ requires
|
|||
}
|
||||
|
||||
function selectAll() {
|
||||
$.each(Ox.range(self.listLength), function(i, v) {
|
||||
//Ox.print('adding', v);
|
||||
addToSelection(v);
|
||||
Ox.range(self.listLength).forEach(function(pos) {
|
||||
addToSelection(pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7075,10 +7148,15 @@ requires
|
|||
return that;
|
||||
};
|
||||
|
||||
that.paste = function(data) {
|
||||
pasteItems(data);
|
||||
return that;
|
||||
};
|
||||
|
||||
that.reloadList = function() {
|
||||
updateQuery();
|
||||
return that;
|
||||
}
|
||||
};
|
||||
|
||||
that.reloadPages = function() {
|
||||
//Ox.print('---------------- list reload, page', self.page)
|
||||
|
@ -7155,7 +7233,9 @@ requires
|
|||
$item = self.$items[pos],
|
||||
data = $item.options('data'),
|
||||
oldValue;
|
||||
if (arguments.length == 2) {
|
||||
if (arguments.length == 1) {
|
||||
return data;
|
||||
} else if (arguments.length == 2) {
|
||||
return data[key];
|
||||
} else {
|
||||
oldValue = data[key];
|
||||
|
@ -7270,12 +7350,15 @@ requires
|
|||
|
||||
$.extend(self, {
|
||||
columnPositions: [],
|
||||
defaultColumnWidths: $.map(self.options.columns, function(v) {
|
||||
return v.width;
|
||||
}),
|
||||
itemHeight: 16,
|
||||
page: 0,
|
||||
pageLength: 100,
|
||||
scrollLeft: 0,
|
||||
selectedColumn: getColumnIndexById(self.options.sort[0].key),
|
||||
visibleColumns: $.map(self.options.columns, function(v, i) {
|
||||
visibleColumns: $.map(self.options.columns, function(v) {
|
||||
return v.visible ? v : null;
|
||||
})
|
||||
});
|
||||
|
@ -7342,6 +7425,7 @@ requires
|
|||
max: self.options.max,
|
||||
min: self.options.min,
|
||||
pageLength: self.options.pageLength,
|
||||
paste: self.options.paste,
|
||||
orientation: 'vertical',
|
||||
request: self.options.request,
|
||||
selected: self.options.selected,
|
||||
|
@ -7495,7 +7579,10 @@ requires
|
|||
});
|
||||
})
|
||||
.dblclick(function() {
|
||||
resizeColumn(v.id, v.width);
|
||||
Ox.print('dblclick')
|
||||
resizeColumn(
|
||||
v.id, self.defaultColumnWidths[getColumnIndexById(v.id)]
|
||||
);
|
||||
});
|
||||
}
|
||||
$left = $('<div>').addClass('OxLeft').appendTo($resize);
|
||||
|
@ -7610,7 +7697,7 @@ requires
|
|||
}
|
||||
|
||||
function getCell(id, key) {
|
||||
//Ox.print('getCell', id, key)
|
||||
Ox.print('getCell', id, key)
|
||||
var $item = getItem(id);
|
||||
return $($item.find('.OxCell.OxColumn' + Ox.toTitleCase(key))[0]);
|
||||
}
|
||||
|
@ -7708,6 +7795,7 @@ requires
|
|||
}
|
||||
|
||||
function resizeColumn(id, width) {
|
||||
Ox.print('resizeColumn', id, width)
|
||||
var i = getColumnIndexById(id),
|
||||
pos = getColumnPositionById(id);
|
||||
self.options.columns[i].width = width;
|
||||
|
@ -7765,6 +7853,8 @@ requires
|
|||
if (key == 'request') {
|
||||
//alert('request set!!')
|
||||
that.$body.options(key, value);
|
||||
} else if (key == 'paste') {
|
||||
that.$body.options(key, value);
|
||||
} else if (key == 'selected') {
|
||||
that.$body.options(key, value);
|
||||
}
|
||||
|
@ -7831,6 +7921,11 @@ requires
|
|||
return that;
|
||||
}
|
||||
|
||||
that.paste = function(data) {
|
||||
that.$body.paste();
|
||||
return that;
|
||||
};
|
||||
|
||||
that.reloadList = function() {
|
||||
that.$body.reloadList();
|
||||
return that;
|
||||
|
@ -7870,9 +7965,11 @@ requires
|
|||
that.value = function(id, key, value) {
|
||||
// fixme: make this accept id, {k: v, ...}
|
||||
var $item = getItem(id),
|
||||
$cell = getCell(id, key),
|
||||
//$cell = getCell(id, key),
|
||||
column = self.options.columns[getColumnIndexById(key)];
|
||||
if (arguments.length == 2) {
|
||||
if (arguments.length == 1) {
|
||||
return that.$body.value(id);
|
||||
} else if (arguments.length == 2) {
|
||||
return that.$body.value(id, key);
|
||||
} else {
|
||||
that.$body.value(id, key, value);
|
||||
|
@ -9497,7 +9594,7 @@ requires
|
|||
$title.html(self.options.title);
|
||||
}
|
||||
};
|
||||
that.update = function() {
|
||||
that.update = function() { // fixme: used anywhere?
|
||||
self.options.collapsed && that.$content.css({
|
||||
marginTop: -that.$content.height()
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue