Remove chk, all must be $defined.

This commit is contained in:
Paulo Veiga 2011-07-28 13:06:15 -03:00
parent d4fefed545
commit 899bf85545
10 changed files with 49 additions and 49 deletions

View File

@ -29,7 +29,7 @@ mindplot.BubbleTip = new Class({
height:null, height:null,
form:null form:null
}; };
if ($chk(this.options.form)) if ($defined(this.options.form))
this.scanElements(this.options.form); this.scanElements(this.options.form);
this.buildBubble(); this.buildBubble();
this._isMouseOver = false; this._isMouseOver = false;
@ -46,14 +46,14 @@ mindplot.BubbleTip = new Class({
var opts = this.options; var opts = this.options;
var panel = new Element('div').addClass('bubbleContainer'); var panel = new Element('div').addClass('bubbleContainer');
if ($chk(opts.height)) if ($defined(opts.height))
panel.setStyle('height', opts.height); panel.setStyle('height', opts.height);
if ($chk(opts.width)) if ($defined(opts.width))
panel.setStyle('width', opts.width); panel.setStyle('width', opts.width);
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue'); this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
this.center.inject(panel); this.center.inject(panel);
if (!$chk(opts.divContainer)) { if (!$defined(opts.divContainer)) {
opts.divContainer = document.body; opts.divContainer = document.body;
} }
panel.injectTop(opts.divContainer); panel.injectTop(opts.divContainer);
@ -76,7 +76,7 @@ mindplot.BubbleTip = new Class({
this.doOpen.delay(500, this, [content,source]); this.doOpen.delay(500, this, [content,source]);
}, },
doOpen : function(content, source) { doOpen : function(content, source) {
if ($chk(this._isMouseOver) && !$chk(this._open) && !$chk(this._opening)) { if ($defined(this._isMouseOver) && !$defined(this._open) && !$defined(this._opening)) {
this._opening = true; this._opening = true;
var container = new Element('div'); var container = new Element('div');
$(content).inject(container); $(content).inject(container);
@ -99,10 +99,10 @@ mindplot.BubbleTip = new Class({
}, },
doClose : function(event) { doClose : function(event) {
if (!$chk(this._isMouseOver) && $chk(this._opening)) if (!$defined(this._isMouseOver) && $defined(this._opening))
this.doClose.delay(500, this, this._evt); this.doClose.delay(500, this, this._evt);
if (!$chk(this._isMouseOver) && $chk(this._open)) { if (!$defined(this._isMouseOver) && $defined(this._open)) {
this.forceClose(); this.forceClose();
} }
}, },
@ -139,9 +139,9 @@ mindplot.BubbleTip = new Class({
}, },
moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) { moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) {
var f = 1, fX = 1; var f = 1, fX = 1;
if ($chk(invert)) if ($defined(invert))
f = 0; f = 0;
if ($chk(invertX)) if ($defined(invertX))
fX = 0; fX = 0;
var opts = this.options; var opts = this.options;
$(opts.panel).setStyles({left:offset.x - (panelWidth * fX), top:offset.y - (panelHeight * f)}); $(opts.panel).setStyles({left:offset.x - (panelWidth * fX), top:offset.y - (panelHeight * f)});

View File

@ -104,7 +104,7 @@ mindplot.IconGroup = new Class({
getImageIcon : function(icon) { getImageIcon : function(icon) {
var result = null; var result = null;
this.options.icons.each(function(el, index) { this.options.icons.each(function(el, index) {
if (result == null && $chk(el.getModel().isIconModel) && el.getId() == icon.getId() && el.getUiId() == icon.getUiId()) { if (result == null && $defined(el.getModel().isIconModel) && el.getId() == icon.getId() && el.getUiId() == icon.getUiId()) {
result = el; result = el;
} }
}, this); }, this);
@ -115,7 +115,7 @@ mindplot.IconGroup = new Class({
var result = null; var result = null;
this.options.icons.each(function(el, index) { this.options.icons.each(function(el, index) {
var elModel = el.getModel(); var elModel = el.getModel();
if (result == null && $chk(elModel.isIconModel) && elModel.getId() == iconModel.getId()) { if (result == null && $defined(elModel.isIconModel) && elModel.getId() == iconModel.getId()) {
result = el; result = el;
} }
}, this); }, this);

View File

@ -779,7 +779,7 @@ mindplot.MindmapDesigner = new Class({
var topic = null; var topic = null;
if (selectedTopics.length > 0) { if (selectedTopics.length > 0) {
topic = selectedTopics[0]; topic = selectedTopics[0];
if (!$chk(topic._hasLink)) { if (!$defined(topic._hasLink)) {
var msg = new Element('div'); var msg = new Element('div');
var urlText = new Element('div').inject(msg); var urlText = new Element('div').inject(msg);
urlText.innerHTML = "URL:" urlText.innerHTML = "URL:"
@ -832,7 +832,7 @@ mindplot.MindmapDesigner = new Class({
var topic = null; var topic = null;
if (selectedTopics.length > 0) { if (selectedTopics.length > 0) {
topic = selectedTopics[0]; topic = selectedTopics[0];
if (!$chk(topic._hasNote)) { if (!$defined(topic._hasNote)) {
var msg = new Element('div'); var msg = new Element('div');
var text = new Element('div').inject(msg); var text = new Element('div').inject(msg);
var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'}); var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'});
@ -944,7 +944,7 @@ mindplot.MindmapDesigner = new Class({
var key = evt.key; var key = evt.key;
if (!this._editor.isVisible()) { if (!this._editor.isVisible()) {
if (((evt.code >= 65 && evt.code <= 90) || (evt.code >= 48 && evt.code <= 57)) && !(evt.control || evt.meta)) { if (((evt.code >= 65 && evt.code <= 90) || (evt.code >= 48 && evt.code <= 57)) && !(evt.control || evt.meta)) {
if ($chk(evt.shift)) { if ($defined(evt.shift)) {
key = key.toUpperCase(); key = key.toUpperCase();
} }
this._showEditor(key); this._showEditor(key);

View File

@ -201,7 +201,7 @@ mindplot.TextEditor = new Class({
var textHeight = editor._currentNode.getTextShape().getHeight(); var textHeight = editor._currentNode.getTextShape().getHeight();
var iconGroup = editor._currentNode.getIconGroup(); var iconGroup = editor._currentNode.getIconGroup();
var iconGroupSize; var iconGroupSize;
if ($chk(iconGroup)) { if ($defined(iconGroup)) {
iconGroupSize = editor._currentNode.getIconGroup().getSize(); iconGroupSize = editor._currentNode.getIconGroup().getSize();
} }
else { else {

View File

@ -37,11 +37,11 @@ mindplot.Tip = new Class({
buildTip : function() { buildTip : function() {
var opts = this.options; var opts = this.options;
var panel = new Element('div').addClass('bubbleContainer'); var panel = new Element('div').addClass('bubbleContainer');
if ($chk(opts.height)) if ($defined(opts.height))
panel.setStyle('height', opts.height); panel.setStyle('height', opts.height);
if ($chk(opts.width)) if ($defined(opts.width))
panel.setStyle('width', opts.width); panel.setStyle('width', opts.width);
if (!$chk(opts.divContainer)) { if (!$defined(opts.divContainer)) {
opts.divContainer = document.body; opts.divContainer = document.body;
} }
panel.injectTop(opts.divContainer); panel.injectTop(opts.divContainer);
@ -67,7 +67,7 @@ mindplot.Tip = new Class({
}, },
doOpen : function(content, source) { doOpen : function(content, source) {
if ($chk(this._isMouseOver) && !$chk(this._open) && !$chk(this._opening)) { if ($defined(this._isMouseOver) && !$defined(this._open) && !$defined(this._opening)) {
this._opening = true; this._opening = true;
var container = new Element('div'); var container = new Element('div');
$(content).inject(container); $(content).inject(container);
@ -93,10 +93,10 @@ mindplot.Tip = new Class({
doClose : function(event) { doClose : function(event) {
if (!$chk(this._isMouseOver) && $chk(this._opening)) if (!$defined(this._isMouseOver) && $defined(this._opening))
this.doClose.delay(500, this, this._evt); this.doClose.delay(500, this, this._evt);
if (!$chk(this._isMouseOver) && $chk(this._open)) { if (!$defined(this._isMouseOver) && $defined(this._open)) {
this.forceClose(); this.forceClose();
} }
}, },

View File

@ -100,12 +100,12 @@ mindplot.Topic.prototype._setShapeType = function(type, updateModel)
//Move iconGroup to front ... //Move iconGroup to front ...
var iconGroup = this.getIconGroup(); var iconGroup = this.getIconGroup();
if($chk(iconGroup)){ if($defined(iconGroup)){
iconGroup.moveToFront(); iconGroup.moveToFront();
} }
//Move connector to front //Move connector to front
var connector = this.getShrinkConnector(); var connector = this.getShrinkConnector();
if($chk(connector)){ if($defined(connector)){
connector.moveToFront(); connector.moveToFront();
} }
@ -368,7 +368,7 @@ mindplot.Topic.prototype.removeIcon = function(iconModel){
//Removing the icon from UI //Removing the icon from UI
var iconGroup = this.getIconGroup(); var iconGroup = this.getIconGroup();
if($chk(iconGroup)) if($defined(iconGroup))
{ {
var imgIcon = iconGroup.findIconFromModel(iconModel); var imgIcon = iconGroup.findIconFromModel(iconModel);
iconGroup.removeImageIcon(imgIcon); iconGroup.removeImageIcon(imgIcon);
@ -385,7 +385,7 @@ mindplot.Topic.prototype.removeLink = function(){
var links = model.getLinks(); var links = model.getLinks();
model._removeLink(links[0]); model._removeLink(links[0]);
var iconGroup = this.getIconGroup(); var iconGroup = this.getIconGroup();
if($chk(iconGroup)) if($defined(iconGroup))
{ {
iconGroup.removeIcon(mindplot.LinkIcon.IMAGE_URL); iconGroup.removeIcon(mindplot.LinkIcon.IMAGE_URL);
if(iconGroup.getIcons().length==0){ if(iconGroup.getIcons().length==0){
@ -403,7 +403,7 @@ mindplot.Topic.prototype.removeNote = function(){
var notes = model.getNotes(); var notes = model.getNotes();
model._removeNote(notes[0]); model._removeNote(notes[0]);
var iconGroup = this.getIconGroup(); var iconGroup = this.getIconGroup();
if($chk(iconGroup)) if($defined(iconGroup))
{ {
iconGroup.removeIcon(mindplot.Note.IMAGE_URL); iconGroup.removeIcon(mindplot.Note.IMAGE_URL);
if(iconGroup.getIcons().length==0){ if(iconGroup.getIcons().length==0){
@ -484,7 +484,7 @@ mindplot.Topic.prototype._buildTextShape = function(disableEventsListeners)
mindplot.Topic.prototype.getIconOffset = function(){ mindplot.Topic.prototype.getIconOffset = function(){
var iconGroup = this.getIconGroup(); var iconGroup = this.getIconGroup();
var size = 0; var size = 0;
if($chk(iconGroup)) if($defined(iconGroup))
{ {
size = iconGroup.getSize().width; size = iconGroup.getSize().width;
} }

View File

@ -38,7 +38,7 @@ var Panel = new Class({
buildBody:function(){ buildBody:function(){
var opts = this.options; var opts = this.options;
opts.frame = new Element('div'); opts.frame = new Element('div');
if($chk(opts.content)) if($defined(opts.content))
{ {
this.setContent(opts.content); this.setContent(opts.content);
} }

View File

@ -169,7 +169,7 @@ var MooRainbow = new Class({
hex: hex hex: hex
}; };
if (!$chk(this.pickerPos.x)) if (!$defined(this.pickerPos.x))
this.autoSet(hsb); this.autoSet(hsb);
this.RedInput.value = rgb[0]; this.RedInput.value = rgb[0];
@ -382,7 +382,7 @@ var MooRainbow = new Class({
eventKeyup: function(e, el) { eventKeyup: function(e, el) {
var n = e.code, k = e.key, pass, prefix, chr = el.value.charAt(0); var n = e.code, k = e.key, pass, prefix, chr = el.value.charAt(0);
if (!$chk(el.value)) return; if (!$defined(el.value)) return;
if (el.className.test(/hexInput/)) { if (el.className.test(/hexInput/)) {
if (chr != "#" && el.value.length != 6) return; if (chr != "#" && el.value.length != 6) return;
if (chr == '#' && el.value.length != 7) return; if (chr == '#' && el.value.length != 7) return;
@ -419,7 +419,7 @@ var MooRainbow = new Class({
pass = el.value.hexToRgb(true); pass = el.value.hexToRgb(true);
if (isNaN(pass[0]) || isNaN(pass[1]) || isNaN(pass[2])) return; if (isNaN(pass[0]) || isNaN(pass[1]) || isNaN(pass[2])) return;
if ($chk(pass)) { if ($defined(pass)) {
this.manualSet(pass); this.manualSet(pass);
this.fireEvent('onChange', [this.sets, this]); this.fireEvent('onChange', [this.sets, this]);
} }

View File

@ -204,7 +204,7 @@ Arguments:
obj - object to inspect obj - object to inspect
*/ */
function $chk(obj) { function $defined(obj) {
return !!(obj || obj === 0); return !!(obj || obj === 0);
} }
; ;
@ -1445,7 +1445,7 @@ Function.extend({
'periodical': false, 'periodical': false,
'attempt': false 'attempt': false
}, options); }, options);
if ($chk(options.arguments) && $type(options.arguments) != 'array') options.arguments = [options.arguments]; if ($defined(options.arguments) && $type(options.arguments) != 'array') options.arguments = [options.arguments];
return function(event) { return function(event) {
var args; var args;
if (options.event) { if (options.event) {
@ -2261,7 +2261,7 @@ Element.extend({
getStyle: function(property) { getStyle: function(property) {
property = property.camelCase(); property = property.camelCase();
var result = this.style[property]; var result = this.style[property];
if (!$chk(result)) { if (!$defined(result)) {
if (property == 'opacity') return this.$tmp.opacity; if (property == 'opacity') return this.$tmp.opacity;
result = []; result = [];
for (var style in Element.Styles) { for (var style in Element.Styles) {
@ -2575,7 +2575,7 @@ Element.extend({
}); });
Element.fixStyle = function(property, result, element) { Element.fixStyle = function(property, result, element) {
if ($chk(parseInt(result))) return result; if ($defined(parseInt(result))) return result;
if (['height', 'width'].contains(property)) { if (['height', 'width'].contains(property)) {
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom']; var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'];
var size = 0; var size = 0;
@ -3955,7 +3955,7 @@ Fx.CSS = {
parse: function(el, property, fromTo) { parse: function(el, property, fromTo) {
if (!fromTo.push) fromTo = [fromTo]; if (!fromTo.push) fromTo = [fromTo];
var from = fromTo[0], to = fromTo[1]; var from = fromTo[0], to = fromTo[1];
if (!$chk(to)) { if (!$defined(to)) {
to = from; to = from;
from = el.getStyle(property); from = el.getStyle(property);
} }
@ -4409,7 +4409,7 @@ Fx.Scroll = Fx.Base.extend({
var values = {'x': x, 'y': y}; var values = {'x': x, 'y': y};
for (var z in el.size) { for (var z in el.size) {
var max = el.scrollSize[z] - el.size[z]; var max = el.scrollSize[z] - el.size[z];
if ($chk(values[z])) values[z] = ($type(values[z]) == 'number') ? values[z].limit(0, max) : max; if ($defined(values[z])) values[z] = ($type(values[z]) == 'number') ? values[z].limit(0, max) : max;
else values[z] = el.scroll[z]; else values[z] = el.scroll[z];
values[z] += this.options.offset[z]; values[z] += this.options.offset[z];
} }
@ -4932,7 +4932,7 @@ Drag.Base = new Class({
this.mouse.pos[z] = event.page[z] - this.value.now[z]; this.mouse.pos[z] = event.page[z] - this.value.now[z];
if (limit && limit[z]) { if (limit && limit[z]) {
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
if ($chk(limit[z][i])) this.limit[z][i] = ($type(limit[z][i]) == 'function') ? limit[z][i]() : limit[z][i]; if ($defined(limit[z][i])) this.limit[z][i] = ($type(limit[z][i]) == 'function') ? limit[z][i]() : limit[z][i];
} }
} }
} }
@ -4961,10 +4961,10 @@ Drag.Base = new Class({
if (!this.options.modifiers[z]) continue; if (!this.options.modifiers[z]) continue;
this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z]; this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
if (this.limit[z]) { if (this.limit[z]) {
if ($chk(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])) { if ($defined(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])) {
this.value.now[z] = this.limit[z][1]; this.value.now[z] = this.limit[z][1];
this.out = true; this.out = true;
} else if ($chk(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])) { } else if ($defined(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])) {
this.value.now[z] = this.limit[z][0]; this.value.now[z] = this.limit[z][0];
this.out = true; this.out = true;
} }
@ -5055,11 +5055,11 @@ Drag.Move = Drag.Base.extend({
var top = this.element.getStyle('top').toInt(); var top = this.element.getStyle('top').toInt();
var left = this.element.getStyle('left').toInt(); var left = this.element.getStyle('left').toInt();
if (this.position.element == 'absolute' && !['relative', 'absolute', 'fixed'].contains(this.position.container)) { if (this.position.element == 'absolute' && !['relative', 'absolute', 'fixed'].contains(this.position.container)) {
top = $chk(top) ? top : this.element.getTop(this.options.overflown); top = $defined(top) ? top : this.element.getTop(this.options.overflown);
left = $chk(left) ? left : this.element.getLeft(this.options.overflown); left = $defined(left) ? left : this.element.getLeft(this.options.overflown);
} else { } else {
top = $chk(top) ? top : 0; top = $defined(top) ? top : 0;
left = $chk(left) ? left : 0; left = $defined(left) ? left : 0;
} }
this.element.setStyles({'top': top, 'left': left, 'position': this.position.element}); this.element.setStyles({'top': top, 'left': left, 'position': this.position.element});
this.parent(this.element); this.parent(this.element);
@ -7079,7 +7079,7 @@ var Accordion = Fx.Elements.extend({
this.setOptions(options); this.setOptions(options);
this.previous = -1; this.previous = -1;
if (this.options.alwaysHide) this.options.wait = true; if (this.options.alwaysHide) this.options.wait = true;
if ($chk(this.options.show)) { if ($defined(this.options.show)) {
this.options.display = false; this.options.display = false;
this.previous = this.options.show; this.previous = this.options.show;
} }
@ -7100,7 +7100,7 @@ var Accordion = Fx.Elements.extend({
} }
}, this); }, this);
this.parent(this.elements); this.parent(this.elements);
if ($chk(this.options.display)) this.display(this.options.display); if ($defined(this.options.display)) this.display(this.options.display);
}, },
/* /*

View File

@ -469,7 +469,7 @@ Drag.Multi = Drag.extend({
mod.$limit = []; mod.$limit = [];
var limit = mod.limit; var limit = mod.limit;
if (limit) for (var i = 0; i < 2; i++) { if (limit) for (var i = 0; i < 2; i++) {
if ($chk(limit[i])) mod.$limit[i] = ($type(limit[i]) == 'function') ? limit[i](mod) : limit[i]; if ($defined(limit[i])) mod.$limit[i] = ($type(limit[i]) == 'function') ? limit[i](mod) : limit[i];
} }
}, this); }, this);
} }
@ -483,10 +483,10 @@ Drag.Multi = Drag.extend({
var z = mod.modifier, mouse = this.mouse.now[z]; var z = mod.modifier, mouse = this.mouse.now[z];
mod.out = false; mod.out = false;
mod.now = mod.fn.step(mod.start, mod.bind ? mod.bind.inverse : mouse, mod.direction); mod.now = mod.fn.step(mod.start, mod.bind ? mod.bind.inverse : mouse, mod.direction);
if (mod.$limit && $chk(mod.$limit[1]) && (mod.now > mod.$limit[1])) { if (mod.$limit && $defined(mod.$limit[1]) && (mod.now > mod.$limit[1])) {
mod.now = mod.$limit[1]; mod.now = mod.$limit[1];
mod.out = true; mod.out = true;
} else if (mod.$limit && $chk(mod.$limit[0]) && (mod.now < mod.$limit[0])) { } else if (mod.$limit && $defined(mod.$limit[0]) && (mod.now < mod.$limit[0])) {
mod.now = mod.$limit[0]; mod.now = mod.$limit[0];
mod.out = true; mod.out = true;
} }