From 37d7c7ef2ba43d643ae90d8d3d523cf22f9bad1d Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Mon, 10 Oct 2011 10:38:50 +0100 Subject: [PATCH] Upgraded javascript to be compatible with mootools 1.3 (master branch) --- Source/Core/Mif.Tree.Draw.js | 6 +++--- Source/Core/Mif.Tree.Hover.js | 6 +++--- Source/Core/Mif.Tree.Load.js | 10 +++++----- Source/Core/Mif.Tree.Node.js | 16 ++++++++-------- Source/Core/Mif.Tree.Selection.js | 4 +++- Source/Core/Mif.Tree.js | 6 +++--- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Source/Core/Mif.Tree.Draw.js b/Source/Core/Mif.Tree.Draw.js index 4f30cf3..420a4e7 100644 --- a/Source/Core/Mif.Tree.Draw.js +++ b/Source/Core/Mif.Tree.Draw.js @@ -16,7 +16,7 @@ Mif.Tree.Draw = { getHTML: function(node,html){ var prefix = node.tree.DOMidPrefix; - if($defined(node.state.checked)){ + if(node.state.checked != null){ if(!node.hasCheckbox) node.state.checked='nochecked'; var checkbox = ''+Mif.Tree.Draw.zeroSpace+''; }else{ @@ -58,7 +58,7 @@ Mif.Tree.Draw = { }, forestRoot: function(tree){ - var container = new Element('div').addClass('mif-tree-children-root').injectInside(tree.wrapper); + var container = new Element('div').addClass('mif-tree-children-root').inject(tree.wrapper, 'inside'); Mif.Tree.Draw.children(tree.root, container); }, @@ -118,5 +118,5 @@ Mif.Tree.Draw = { }; -Mif.Tree.Draw.zeroSpace = Browser.Engine.trident ? '­' : (Browser.Engine.webkit ? '​' : ''); +Mif.Tree.Draw.zeroSpace = Browser.ie ? '­' : ((Browser.chrome || Browser.safari) ? '​' : ''); diff --git a/Source/Core/Mif.Tree.Hover.js b/Source/Core/Mif.Tree.Hover.js index e6662fb..d221551 100644 --- a/Source/Core/Mif.Tree.Hover.js +++ b/Source/Core/Mif.Tree.Hover.js @@ -25,13 +25,13 @@ Mif.Tree.implement({ name: false, node: false }; - this.hoverState = $unlink(this.defaultHoverState); + this.hoverState = Object.clone(this.defaultHoverState); }, hover: function(){ var cnode = this.mouse.node; var ctarget = this.mouse.target; - $each(this.hoverState, function(node, target, state){ + Object.each(this.hoverState, function(node, target, state){ if(node == cnode && (target == 'node'||target==ctarget)) return; if(node) { Mif.Tree.Hover.out(node, target); @@ -49,7 +49,7 @@ Mif.Tree.implement({ }, updateHover: function(){ - this.hoverState = $unlink(this.defaultHoverState); + this.hoverState = Object.clone(this.defaultHoverState); this.hover(); } diff --git a/Source/Core/Mif.Tree.Load.js b/Source/Core/Mif.Tree.Load.js index 5d30a62..9e77589 100644 --- a/Source/Core/Mif.Tree.Load.js +++ b/Source/Core/Mif.Tree.Load.js @@ -41,7 +41,7 @@ Mif.Tree.implement({ load: function(options){ var tree = this; - this.loadOptions = this.loadOptions||$lambda({}); + this.loadOptions = this.loadOptions||Function.from({}); function success(json){ if(tree.forest){ tree.root = new Mif.Tree.Node({ @@ -58,8 +58,8 @@ Mif.Tree.implement({ tree.fireEvent('load'); return tree; } - options = $extend($extend({ - isSuccess: $lambda(true), + options = Object.append(Object.append({ + isSuccess: Function.from(true), secure: true, onSuccess: success, method: 'get' @@ -88,8 +88,8 @@ Mif.Tree.Node.implement({ self.tree.fireEvent('loadNode', self); return self; } - options=$extend($extend($extend({ - isSuccess: $lambda(true), + options=Object.append(Object.append(Object.append({ + isSuccess: Function.from(true), secure: true, onSuccess: success, method: 'get' diff --git a/Source/Core/Mif.Tree.Node.js b/Source/Core/Mif.Tree.Node.js index 420c04d..b99a66a 100644 --- a/Source/Core/Mif.Tree.Node.js +++ b/Source/Core/Mif.Tree.Node.js @@ -17,12 +17,12 @@ Mif.Tree.Node = new Class({ Implements: [Events], initialize: function(structure, options) { - $extend(this, structure); + Object.append(this, structure); this.children = []; this.type = options.type || this.tree.dfltType; this.property = options.property || {}; this.data = options.data; - this.state = $extend($unlink(this.tree.dfltState), options.state); + this.state = Object.append(Object.clone(this.tree.dfltState), options.state); this.$calculate(); this.UID = Mif.Tree.Node.UID++; Mif.Tree.Nodes[this.UID] = this; @@ -33,13 +33,13 @@ Mif.Tree.Node = new Class({ }, $calculate: function(){ - $extend(this, $unlink(this.tree.defaults)); - this.type = $splat(this.type); + Object.append(this, Object.clone(this.tree.defaults)); + this.type = Array.from(this.type); this.type.each(function(type){ var props = this.tree.types[type]; - if(props) $extend(this, props); + if(props) Object.append(this, props); }, this); - $extend(this, this.property); + Object.append(this, this.property); return this; }, @@ -92,7 +92,7 @@ Mif.Tree.Node = new Class({ }, recursive: function(fn, args){ - args=$splat(args); + args=Array.from(args); if(fn.apply(this, args) !== false){ this.children.each(function(node){ if(node.recursive(fn, args) === false){ @@ -322,4 +322,4 @@ Mif.Tree.Node = new Class({ }); Mif.Tree.Node.UID = 0; -Mif.Tree.Nodes = {}; \ No newline at end of file +Mif.Tree.Nodes = {}; diff --git a/Source/Core/Mif.Tree.Selection.js b/Source/Core/Mif.Tree.Selection.js index 735b562..91e4bf5 100644 --- a/Source/Core/Mif.Tree.Selection.js +++ b/Source/Core/Mif.Tree.Selection.js @@ -16,7 +16,9 @@ Mif.Tree.implement({ initSelection: function(){ this.defaults.selectClass = ''; - this.wrapper.addEvent('mousedown', this.attachSelect.bindWithEvent(this)); + this.wrapper.addEvent('mousedown', function(event) { + this.attachSelect(event); + }.bind(this)); }, attachSelect: function(event){ diff --git a/Source/Core/Mif.Tree.js b/Source/Core/Mif.Tree.js index 7052311..78a7362 100644 --- a/Source/Core/Mif.Tree.js +++ b/Source/Core/Mif.Tree.js @@ -24,7 +24,7 @@ Mif.Tree = new Class({ version: '1.2.2', - Implements: [new Events, new Options], + Implements: [Events, Options], options:{ types: {}, @@ -37,7 +37,7 @@ Mif.Tree = new Class({ initialize: function(options){ this.setOptions(options); - $extend(this, { + Object.append(this, { types: this.options.types, forest: this.options.forest, animateScroll: this.options.animateScroll, @@ -63,7 +63,7 @@ Mif.Tree = new Class({ this.updateOpenState(); if(this.options.expandTo) this.initExpandTo(); this.DOMidPrefix='mif-tree-'; - this.wrapper = new Element('div').addClass('mif-tree-wrapper').injectInside(this.container); + this.wrapper = new Element('div').addClass('mif-tree-wrapper').inject(this.container, 'inside'); this.initEvents(); this.initScroll(); this.initSelection();