forked from 0x2620/oxjs
updates for html parsing, request handling, and editable elements
This commit is contained in:
parent
a949ad2cf4
commit
62f8a907ea
6 changed files with 153 additions and 69 deletions
|
|
@ -18,12 +18,11 @@ Ox.Editable = function(options, self) {
|
|||
tooltip: options.tooltip
|
||||
}, self)
|
||||
.defaults({
|
||||
clickLink: function(e) {
|
||||
document.location.href = $(e.target).attr('href');
|
||||
},
|
||||
clickLink: null,
|
||||
editable: true,
|
||||
editing: false,
|
||||
format: null,
|
||||
height: 0,
|
||||
placeholder: '',
|
||||
tooltip: '',
|
||||
value: '',
|
||||
|
|
@ -33,16 +32,20 @@ Ox.Editable = function(options, self) {
|
|||
.options(options || {})
|
||||
.addClass('OxEditableElement')
|
||||
.bind({
|
||||
click: function(e) {
|
||||
if ($(e.target).is('a')) {
|
||||
return false;
|
||||
}
|
||||
click: function() {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.bindEvent({
|
||||
doubleclick: edit,
|
||||
singleclick: function(e) {
|
||||
$(e.target).is('a') && self.options.clickLink(e);
|
||||
if ($(e.target).is('a')) {
|
||||
if (self.options.clickLink) {
|
||||
self.options.clickLink(e);
|
||||
} else {
|
||||
document.location.href = $(e.target).attr('href');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -56,8 +59,9 @@ Ox.Editable = function(options, self) {
|
|||
//border: '1px solid transparent'
|
||||
} : {
|
||||
//padding: '0 4px 0 4px'
|
||||
width: self.options.width + 'px'
|
||||
//width: self.options.width + 'px'
|
||||
})
|
||||
//.css({background: 'red'})
|
||||
.html(formatValue())
|
||||
//[self.options.editing ? 'hide' : 'show']()
|
||||
.appendTo(that);
|
||||
|
|
@ -112,10 +116,11 @@ Ox.Editable = function(options, self) {
|
|||
function change(event) {
|
||||
var height, width;
|
||||
self.options.value = event.value;
|
||||
self.$value.html(formatValue);
|
||||
self.$value.html(formatValue());
|
||||
self.$test.html(formatTestValue());
|
||||
height = self.options.height || self.$test.height();
|
||||
width = self.options.width || Ox.limit(self.$test.width() + 2, self.minWidth, self.maxWidth)
|
||||
//height = self.options.height || Ox.limit(self.$test.height() + 2, self.minHeight, self.maxHeight);
|
||||
height = self.options.height || Math.max(self.$test.height() + 2, self.minHeight);
|
||||
width = self.options.width || Ox.limit(self.$test.width() + 2, self.minWidth, self.maxWidth);
|
||||
Ox.print(self.options.width, self.$test.width(), 'wxh', width, height)
|
||||
if (self.options.type == 'input') {
|
||||
self.$input.options({
|
||||
|
|
@ -146,14 +151,16 @@ Ox.Editable = function(options, self) {
|
|||
var height, width;
|
||||
if (self.options.editable && !self.options.editing) {
|
||||
self.originalValue = self.options.value;
|
||||
self.minWidth = 8
|
||||
self.minWidth = 8;
|
||||
self.maxWidth = that.parent().width();
|
||||
Ox.print('MAX WIDTH', self.maxWidth);
|
||||
self.minHeight = 14;
|
||||
self.maxHeight = that.parent().height();
|
||||
height = self.options.height || self.$value.height();
|
||||
width = self.$value.width();
|
||||
width = self.options.width || self.$value.width();
|
||||
self.$value.hide();
|
||||
//self.$test.show();
|
||||
Ox.print('HEIGHT', height)
|
||||
|
||||
Ox.print("H:::", self.options.height, self.maxHeight, height)
|
||||
|
||||
self.$input.options({
|
||||
height: height,
|
||||
width: width
|
||||
|
|
@ -179,9 +186,11 @@ Ox.Editable = function(options, self) {
|
|||
}
|
||||
|
||||
function formatInputValue() {
|
||||
return self.options.type == 'input'
|
||||
? self.options.value
|
||||
: self.options.value.replace(/<br\/?>/g, '\n');
|
||||
return Ox.decodeHTML(
|
||||
self.options.type == 'input'
|
||||
? self.options.value
|
||||
: self.options.value.replace(/<br\/?><br\/?>/g, '\n\n')
|
||||
);
|
||||
}
|
||||
|
||||
function formatTestValue() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue