Skip to content

Commit

Permalink
Merge branch 'fabio'
Browse files Browse the repository at this point in the history
  • Loading branch information
anutron committed May 25, 2009
2 parents e195079 + 3c17e81 commit 3d69710
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 115 deletions.
8 changes: 4 additions & 4 deletions Source/Element/Element.js
Expand Up @@ -262,7 +262,7 @@ var attributes = {
'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'
};
var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];
var camels = ['value', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];
var camels = ['value', 'type', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];

bools = bools.associate(bools);

Expand Down Expand Up @@ -336,7 +336,7 @@ Element.implement({
},

setProperty: function(attribute, value){
var key = attributes[attribute];
var key = attributes[attribute.toLowerCase()];
if (value == undefined) return this.removeProperty(attribute);
if (key && bools[attribute]) value = !!value;
(key) ? this[key] = value : this.setAttribute(attribute, '' + value);
Expand All @@ -349,7 +349,7 @@ Element.implement({
},

getProperty: function(attribute){
var key = attributes[attribute];
var key = attributes[attribute.toLowerCase()];
var value = (key) ? this[key] : this.getAttribute(attribute, 2);
return (bools[attribute]) ? !!value : (key) ? value : value || null;
},
Expand All @@ -360,7 +360,7 @@ Element.implement({
},

removeProperty: function(attribute){
var key = attributes[attribute];
var key = attributes[attribute.toLowerCase()];
(key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute);
return this;
},
Expand Down
108 changes: 21 additions & 87 deletions Specs/Assets/Scripts/Builder.js
Expand Up @@ -10,96 +10,30 @@ Note:
*/

var Builder = {

root: '../',

paths: {
source: 'Source',
specs: 'Specs'
},

included: {
source: {},
specs: {},
docs: {}
},

scripts: {
source: {
'Core' : ['Core', 'Browser'],
'Native' : ['Array', 'Function', 'Number', 'String', 'Hash', 'Event'],
'Class' : ['Class', 'Class.Extras'],
'Element' : ['Element', 'Element.Event', 'Element.Style', 'Element.Dimensions'],
'Utilities' : ['Selectors', 'DomReady', 'JSON', 'Cookie', 'Swiff'],
'Fx' : ['Fx', 'Fx.CSS', 'Fx.Tween', 'Fx.Morph', 'Fx.Transitions'],
'Request' : ['Request', 'Request.HTML', 'Request.JSON']
},

specs: {
'Core' : ['Core', 'Browser'],
'Native' : ['Array', 'String', 'Function', 'Number', 'Hash'],
'Class' : ['Class', 'Class.Extras'],
'Element' : ['Element', 'Element.Style', 'Element.Dimensions'],
'Utilities' : ['Selectors']
}
},

initialize: function(root){
if (root) this.root = root;
this.includeType('source');
return this;
},

getFolder: function(type, file){
var scripts = this.scripts[type];
for (var folder in scripts){
for (var i = 0; i < scripts[folder].length; i++){
var script = scripts[folder][i];
if (script == file) return folder;
includeFiles: function(path, files){
switch(typeof files){
case 'object':
if( files.constructor == Array ){
for(var i=0; i< files.length; i++){
this.includeJs(path + files[i]);
}
}
else{
for(key in files){
this.includeFiles(path + key + '/', files[key]);
}
}
break;
case 'string':
this.includeJs(path + files);
}
return false;
},

getRequest: function(){
var pairs = window.location.search.substring(1).split('&');
var obj = {};
for (var i = 0, l = pairs.length; i < l; i++){
var pair = pairs[i].split('=');
obj[pair[0]] = pair[1];
}
return obj;
},

includeFile: function(type, folder, file){
folder = folder || this.getFolder(type, file);
if (!folder) return false;
this.included[type][folder] = this.included[type][folder] || [];
var files = this.included[type][folder];
for (var i = 0; i < files.length; i++){
if (files[i] == file) return false;
}
this.included[type][folder].push(file);
return document.writeln('<script type="text/javascript" src="' + this.root + this.paths[type] + '/' + folder + '/' + file + '.js?' + new Date().getTime() + '"></script>');
},

includeFolder: function(type, folder){
var scripts = this.scripts[type][folder];
for (var i = 0, l = scripts.length; i < l; i++) this.includeFile(type, folder, scripts[i]);
},

includeType: function(type){
for (var folder in this.scripts[type]) this.includeFolder(type, folder);
includeJs: function(filePath){
document.writeln('<script type="text/javascript" src="' + filePath + '.js?' + new Date().getTime() + '"><\/script>');
},

includeRequest: function(type){
var req = this.getRequest();
if (!req.files && !req.folders) return false;
var files = (req.files) ? req.files.split('+') : [];
var folders = (req.folders) ? req.folders.split('+') : [];
for (var j = 0; j < files.length; j++) this.includeFile(type, null, files[j]);
for (var i = 0; i < folders.length; i++) this.includeFolder(type, folders[i]);
return true;

build: function(root, filesTree){
this.includeFiles(root, filesTree);
}

};
3 changes: 2 additions & 1 deletion Specs/Element/Element.Dimensions.js
Expand Up @@ -18,7 +18,8 @@ License:
padding: 3,
border: '1px solid black',
visibility: 'hidden',
display: 'block',
//display: 'block',
display: 'none',
position: 'absolute',
top: 100,
left: 100
Expand Down
25 changes: 22 additions & 3 deletions Specs/Element/Element.js
Expand Up @@ -1183,6 +1183,15 @@ describe('Element.getProperty', {

var input2 = new Element('input', {type: 'checkbox'});
value_of(input2.getProperty('type')).should_be('checkbox');

var div = new Element('div', {'html':
'<select name="test" id="test" multiple="multiple">' +
'<option value="1">option-value</option>' +
'</select>'
});
var input3 = div.getElement('select');
value_of(input3.getProperty('type')).should_be('select-multiple');
value_of(input3.getProperty('name')).should_be('test');
},

'should getPropety checked from an input Element': function(){
Expand Down Expand Up @@ -1278,6 +1287,15 @@ describe('Element.setProperty', {

var readonly3 = new Element('input', { type: 'text' }).setProperty('readonly', false);
value_of(readonly3.getProperty('readonly')).should_be_false();
},

'should setProperty defaultValue of an input Element': function(){
var form = new Element('form');
var defaultValue = new Element('input', {'type': 'text', 'value': '321'}).setProperty('defaultValue', '123');
form.grab(defaultValue);
value_of(defaultValue.getProperty('value')).should_be('321');
form.reset();
value_of(defaultValue.getProperty('value')).should_be('123');
}

});
Expand Down Expand Up @@ -1305,10 +1323,11 @@ describe('Element.setProperties', {
describe('Element.removeProperty', {

'should removeProperty from an Element': function () {
var readonly = new Element('input', { type: 'text', readonly: 'readonly' });
var readonly = new Element('input', { type: 'text', readonly: 'readonly', maxlenght: 10 });
readonly.removeProperty('readonly');
var props = readonly.getProperties('type', 'readonly');
value_of(props).should_be({ type: 'text', readonly: false });
readonly.removeProperty('maxlength');
var props = readonly.getProperties('type', 'readonly', 'maxlength');
value_of(props).should_be({ type: 'text', readonly: false, maxlength: 0});
}

});
Expand Down
52 changes: 32 additions & 20 deletions Specs/index.html
Expand Up @@ -2,25 +2,37 @@

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>MooTools Specs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" media="screen" href="Assets/Styles/Specs.css" />
<script type="text/javascript" src="Assets/Scripts/JSSpec.js"></script>
<script type="text/javascript" src="Assets/Scripts/DiffMatchPatch.js"></script>
<script type="text/javascript" src="Assets/Scripts/Builder.js"></script>

<script type="text/javascript" charset="utf-8">
Builder.includeType('source');
if (!Builder.includeRequest('specs')) Builder.includeType('specs');
</script>


</head>

<body>

</body>
<head>
<title>MooTools Specs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" media="screen" href="Assets/Styles/Specs.css" />
<script type="text/javascript" src="Assets/Scripts/JSSpec.js"></script>
<script type="text/javascript" src="Assets/Scripts/DiffMatchPatch.js"></script>
<script type="text/javascript" src="Assets/Scripts/Builder.js"></script>
<script type="text/javascript" charset="utf-8">
Builder.build('../', {
Source: {
'Core' : ['Core', 'Browser'],
'Native' : ['Array', 'Function', 'Number', 'String', 'Hash', 'Event'],
'Class' : ['Class', 'Class.Extras'],
'Element' : ['Element', 'Element.Event', 'Element.Style', 'Element.Dimensions'],
'Utilities' : ['Selectors', 'DomReady', 'JSON', 'Cookie', 'Swiff'],
'Fx' : ['Fx', 'Fx.CSS', 'Fx.Tween', 'Fx.Morph', 'Fx.Transitions'],
'Request' : ['Request', 'Request.HTML', 'Request.JSON']
},
Specs: {
'Core' : ['Core', 'Browser'],
'Native' : ['Array', 'String', 'Function', 'Number', 'Hash'],
'Class' : ['Class', 'Class.Extras'],
'Element' : ['Element', 'Element.Style', 'Element.Dimensions'],
'Utilities' : ['Selectors']
}
});
</script>
</head>

<body>

</body>

</html>

0 comments on commit 3d69710

Please sign in to comment.