diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a4edf6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.project diff --git a/CHANGELOG b/CHANGELOG index c7e8092..4562fa1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +v6 11/20/2010 + Simplified the "setDefault" functions to be a single function call that takes in a selector + Implemented issue 5 -- JSS now supports comma delimited selectors (ex "#Label1,#Label2,.Label3 { text: 'Hi!' }") + Fixed issue 7 -- includeJSSGlobal broken by subdirectories + Implemented issue 8 -- Create test / demo project + Included json.org's JSON2 functions as redux.JSON to contend with Titanium's misimplementation on Android + Tweaked global storage to use json.org's JSON2 functions instead of Titanium's + v5 11/18/2010 Added two new include functions: includeJSSGlobal and includeGlobal JSS now caches cross context, so the parsing performance hit is reduced diff --git a/README b/README index 45ab823..acf9083 100644 --- a/README +++ b/README @@ -40,18 +40,14 @@ Include files or JSS across all of your JavaScript contexts, so long as they hav **Normal Code**
 /* In every file */
-Ti.include('a.js');
-Ti.include('b.js');
-Ti.include('c.js');
+Ti.include('a.js', 'b.js', 'c.js');
 
**Redux Code**
 /* In your app.js */
 Ti.include('redux.js');
-includeGlobal('a.js');
-includeGlobal('b.js');
-includeGlobal('c.js');
+includeGlobal('a.js', 'b.js', 'c.js');
 includeJSSGlobal('d.jss');
 
 /* In your other js files */
@@ -120,7 +116,7 @@ var label = new Label();
 alert(label.font.fontWeight == 'bold');
-UI PROPERTY DEFAULTS BY ID AND CLASS NAME +UI PROPERTY DEFAULTS BY SELECTOR ---------------------------------------------- Using a similar method to setting UI Property Defaults by Element Type, you can set them @@ -131,8 +127,8 @@ important than default properties by element type and class names, and will over
Not Supported
**Redux Code** -
$.setDefaultByID('myID', { text: 'Hello, World!', color: 'red' });	
-$.setDefaultByClassName('myClass', { font: { fontSize: 12 }, color: 'green' });
+
$.setDefault('#myID', { text: 'Hello, World!', color: 'red' });	
+$.setDefault('.myClassName', { font: { fontSize: 12 }, color: 'green' });
 var label = new Label({ id: 'myID', className: 'myClass', color: 'blue' });	
 alert(label.text == 'Hello, World!');	
 alert(label.color == 'blue');
@@ -207,11 +203,15 @@ Label {
     text: 'Hello, World!'
 }
 [Platform.locale="es"] #HelloWorld {
-    text: 'ˇBienvenido, Mundo!'
+    text: 'Bienvenido, Mundo!'
 }
-/* select by className */
+/* by className */
 .myClass {
 	text: 'Set by class'
+}
+/* by multiple selectors */
+.selector1, #selector2, Label {
+  text: 'Set for all three selectors'
 }
@@ -224,11 +224,9 @@ Here are some key features to note--you'll want to use them: 6) White space doesn't matter; put it where you want it. 7) You can localize your app using the [Platform.locale="whatever"] attribute. 8) The includeJSS function can take in multiple files or just one; it's up to you. - 9) #HelloWorld has higher precedence than the Label rule. - -Here are some things you CANNOT do yet, but that will be supported soon: - 1) Chaining selectors (ie Window, Label { backgroundColor: '#fff' }). - 2) Chaining attributes (ie Window[Platform.osname="iphone"][Platform.osname="ipad"]). + 9) #HelloWorld has higher precedence than the Label rule. + 10) Chain selectors to reduce the amount of JSS you need to write (ie Window, Label { backgroundColor: '#fff' }). + 11) Chaining attributes (ie [Platform.osname="iphone"][Platform.osname="ipad"] Window { backgroundColor: '#bef'}). CONTACT INFORMATION diff --git a/redux.js b/redux.js index 66a7879..0796d18 100644 --- a/redux.js +++ b/redux.js @@ -1,60 +1,197 @@ /*! -* Appcelerator Redux v5 by Dawson Toth +* Appcelerator Redux v6 by Dawson Toth * http://tothsolutions.com/ +* +* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. */ /** -* Create shorthand for commonly used functions. -*/ + * Create shorthand for commonly used functions. + */ var info = Ti.API.info, - error = Ti.API.error, - warn = Ti.API.warn, - log = Ti.API.log, - include = Ti.include; +error = Ti.API.error, +warn = Ti.API.warn, +log = Ti.API.log, +include = Ti.include; /** -* Provide a central context for dealing with elements and configuring redux. -*/ + * Provide a central context for dealing with elements and configuring redux. + */ var redux = function (selector) { return new redux.fn.init(selector); }; +/* + * Include the json2.js JSON definition, because Titanium's Android JSON function doesn't stringify arrays properly as of 1.4.2. + * + * http://www.JSON.org/json2.js + * 2010-11-17 + * Public Domain. + * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + * See http://www.JSON.org/js.html + */ +redux.JSON={}; +(function() { + function l(b) { + return b<10?"0"+b:b; + } + + function o(b) { + p.lastIndex=0; + return p.test(b)?'"'+b.replace(p, function(f) { + var c=r[f]; + return typeof c==="string"?c:"\\u"+("0000"+f.charCodeAt(0).toString(16)).slice(-4); + })+'"':'"'+b+'"'; + } + + function m(b,f) { + var c,d,g,j,i=h,e,a=f[b]; + if(a&&typeof a==="object"&&typeof a.toJSON==="function") { + a=a.toJSON(b); + } + if(typeof k==="function") { + a=k.call(f,b,a); + } + switch(typeof a) { + case "string": + return o(a); + case "number": + return isFinite(a)?String(a):"null"; + case "boolean": + case "null": + return String(a); + case "object": + if(!a) { + return"null"; + } + h+=n; + e=[]; + if(Object.prototype.toString.apply(a)==="[object Array]") { + j=a.length; + for(c=0;c + + + + + + + diff --git a/test/build/android/.gitignore b/test/build/android/.gitignore new file mode 100644 index 0000000..8a790b2 --- /dev/null +++ b/test/build/android/.gitignore @@ -0,0 +1,5 @@ +src +lib +bin +res +AndroidManifest.xml diff --git a/test/build/android/.project b/test/build/android/.project new file mode 100644 index 0000000..1c1a6ad --- /dev/null +++ b/test/build/android/.project @@ -0,0 +1,33 @@ + + + Redux Test + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/test/build/iphone/.gitignore b/test/build/iphone/.gitignore new file mode 100644 index 0000000..756346d --- /dev/null +++ b/test/build/iphone/.gitignore @@ -0,0 +1,5 @@ +Classes +tmp +build +headers +lib diff --git a/test/manifest b/test/manifest new file mode 100644 index 0000000..7a2b47c --- /dev/null +++ b/test/manifest @@ -0,0 +1,8 @@ +#appname: Redux Test +#publisher: dawson +#url: http://tothsolutions.com/ +#image: appicon.png +#appid: com.tothsolutions.redux.test +#desc: undefined +#type: mobile +#guid: 2ce77904-6b50-461e-bd0a-cca95c3e50a9 diff --git a/test/tiapp.xml b/test/tiapp.xml new file mode 100644 index 0000000..d284c6f --- /dev/null +++ b/test/tiapp.xml @@ -0,0 +1,19 @@ + + +com.tothsolutions.redux.test +Redux Test +1.0 +Dawson Toth +http://tothsolutions.com/ +Tests and demonstrates the basic functionality of Redux +Open Source, have at it +default_app_logo.png + false + false + default + false + false + false + true +2ce77904-6b50-461e-bd0a-cca95c3e50a9 +