some improvements for menu and select

This commit is contained in:
Rolux 2010-02-06 15:59:27 +05:30
parent ec1693c2c4
commit 4cc7bad63c
2 changed files with 29 additions and 23 deletions

View file

@ -80,7 +80,7 @@ Ox.user = function() {
var result = re(v);
results[result[1].replace(/Your |\*/, "")] = result[2];
});
console.log(results)
Ox.print(results)
});
return {
document: {
@ -815,7 +815,7 @@ Encoding functions
}
c.context.putImageData(c.imageData, 0, 0);
data = atob(c.canvas.toDataURL().split(",")[1]);
console.log("deflate", len, "->", data.length - 20);
Ox.print("deflate", len, "->", data.length - 20);
return data.substr(8, data.length - 20);
}
@ -827,7 +827,7 @@ Encoding functions
str = Ox.map(Ox.canvas(image).data, function(v, i) {
return i % 4 < 3 ? Ox.char(v) : "";
}).join("");
//console.log(str.length, "len", Ox.decodeBase256(str.substr(0, 4)), str)
//Ox.print(str.length, "len", Ox.decodeBase256(str.substr(0, 4)), str)
return Ox.decodeUTF8(str.substr(4, Ox.decodeBase256(str.substr(0, 4))));
}
@ -916,7 +916,7 @@ Encoding functions
if (len == 0 && !flag) {
len = Ox.decodeBase256(str);
if (len <= 0 || len > max(img.width, img.height)) {
console.log(len);
Ox.print(len);
throwPNGError("de");
}
str = "";
@ -927,7 +927,7 @@ Encoding functions
try {
return Ox.decodeDeflate(str);
} catch(e) {
console.log(e.toString());
Ox.print(e.toString());
throwPNGError("de");
}
}

View file

@ -254,7 +254,7 @@ requires
return {
// make these bind, trigger, unbind
publish: function(event, data) {
console.log("publish", event, data);
Ox.print("publish", event, data);
if (events[event]) {
$.each(events[event], function(i, v) {
setTimeout(function() {
@ -264,7 +264,7 @@ requires
}
},
subscribe: function(event, callback) {
console.log("subscribe", event, callback);
Ox.print("subscribe", event, callback);
if (events[event]) {
events[event].push(callback);
} else {
@ -272,7 +272,7 @@ requires
}
},
unsubscribe: function(event, callback) {
console.log("unsubscribe", event, callback);
Ox.print("unsubscribe", event, callback);
$.each(events[event], function(i, v) {
if (Ox.startsWith(callback.toString(), v.toString())) {
events[event].splice(i, 1);
@ -820,6 +820,8 @@ requires
// public
that.bindEvent = function() {
// fixme: shouldn't this work the other way around,
// and bind a function to an event triggered by this widget?
/*
bindEvent(event, fn) or bindEvent({event0: fn0, event1: fn1, ...})
*/
@ -940,12 +942,12 @@ requires
that.opt = {};
that.ox = Ox.version;
that.id = Ox.uid();
//console.log("that.id", that.id)
//Ox.print("that.id", that.id)
that.$element = $("<" + (element || "div") + "/>")
//.addClass("OxElement")
.data("ox", that.id);
oxui.elements[that.id] = that;
// console.log("oxui.elements", oxui.elements)
// Ox.print("oxui.elements", oxui.elements)
//function setOption() {};
that.setOption = function() {};
/*
@ -999,10 +1001,10 @@ requires
var length = arguments.length,
args, ret;
if (length == 0) {
//console.log("getting all options", options);
//Ox.print("getting all options", options);
ret = that.opt;
} else if (length == 1 && typeof arguments[0] == "string") {
//console.log("getting one option", options, arguments[0], options[arguments[0]]);
//Ox.print("getting one option", options, arguments[0], options[arguments[0]]);
ret = that.opt[arguments[0]];
} else {
// translate ("key", "value") to {"key": "value"}
@ -1014,7 +1016,7 @@ requires
// that.trigger("OxElement" + that.id + "SetOptions", args);
$.each(args, function(k, v) {
that.setOption(k, v);
//console.log("triggering", "OxElement" + that.id + "SetOption", {k: v})
//Ox.print("triggering", "OxElement" + that.id + "SetOption", {k: v})
//that.trigger("OxElement" + that.id + "SetOption", {k: v});
})
ret = that;
@ -1071,9 +1073,9 @@ requires
// if the $element of an oxui object was returned
// then return the oxui object instead
// so we can do oxObj.jqFn().oxFn()
//console.log("v", v, "arguments", arguments)
//Ox.print("v", v, "arguments", arguments)
if (ret.jquery) {
//console.log("ret", ret, "ret.data('id')", ret.data("ox"))
//Ox.print("ret", ret, "ret.data('id')", ret.data("ox"))
}
return ret.jquery && oxui.elements[id = ret.data("ox")] ?
oxui.elements[id] : ret;
@ -1334,7 +1336,7 @@ requires
(self.options.selected ? " OxSelected": ""))
.mousedown(mousedown)
.click(click);
//console.log(self.options.value, self.options.disabled)
//Ox.print(self.options.value, self.options.disabled)
/*
that.bind("OxElement" + that.id + "SetOptions", function(e, data) {
if (typeof data.selected != "undefined") {
@ -1366,7 +1368,7 @@ requires
}
Ox.print(self.options);
if (self.options.values.length == 2) {
console.log("2 values")
Ox.print("2 values")
that.options({
value: self.options.value == self.options.values[0] ?
self.options.values[1] : self.options.values[0]
@ -1375,7 +1377,7 @@ requires
//self.options.click();
}
self.onChange = function(key, value) {
//console.log("setOption", option, value)
//Ox.print("setOption", option, value)
Ox.print("OxButton onChange", key, value)
if (key == "selected") {
if (value != that.hasClass("OxSelected")) {
@ -1485,20 +1487,20 @@ requires
.blur(blur);
/* doesn't work yet
function change() {
console.log("change", that.val(), that.hasClass("OxPlaceholder"))
Ox.print("change", that.val(), that.hasClass("OxPlaceholder"))
if ((that.val() !== "") != that.hasClass("OxPlaceholder")) {
that.toggleClass("OxPlaceholder");
}
}
*/
function focus() {
console.log("focus", that.val(), that.attr("class"))
Ox.print("focus", that.val(), that.attr("class"))
if (that.hasClass("OxPlaceholder")) {
that.val("").removeClass("OxPlaceholder");
}
}
function blur() {
console.log("blur", that.val(), that.attr("class"))
Ox.print("blur", that.val(), that.attr("class"))
if (that.val() === "") {
that.addClass("OxPlaceholder").val(that.attr("placeholder"));
}
@ -1598,7 +1600,7 @@ requires
c = $image[0].getContext('2d');
c.mozImageSmoothingEnabled = false; // we may want to remove this later
$.each(self.options.trackImages, function(i, v) {
//console.log(v)
//Ox.print(v)
$("<img/>")
.attr({
src: v
@ -1689,7 +1691,7 @@ requires
value: val
});
setThumb(animate);
//console.log("triggering OxRange" + that.id + "Change")
//Ox.print("triggering OxRange" + that.id + "Change")
that.triggerEvent("change", { value: val });
}
}
@ -1776,6 +1778,10 @@ requires
element: that.$button,
id: self.options.id,
items: self.options.items,
offset: {
left: 8,
top: 0
},
side: "bottom",
size: self.options.size
});