Coder Social home page Coder Social logo

zerotohero-dev / o2.js Goto Github PK

View Code? Open in Web Editor NEW
74.0 10.0 11.0 17.93 MB

A Coherent Solution to Your JavaScript Dilemma

Home Page: http://o2js.com/

License: Other

JavaScript 21.67% Shell 0.17% CSS 0.61% PHP 0.16% XSLT 3.62% HTML 73.76% ApacheConf 0.01% Batchfile 0.01%

o2.js's Introduction

NOTE

This project is no longer maintained (at least for a while).

If you want to be the maintainer of it contact me at [email protected]

Although this branch is (by definition) stable, it's missing a lot of features since it's being rewritten.

The recent 1.x version with a larger feature set may be found at https://github.com/v0lkan/o2.js/releases/tag/v.0.25.8

...

In Progress…

read CONTRIBUTE.md for now.

also read INSTALL.md for installation instructions.

Installation

Dependencies

Each folder in src/o2/ is a separate NPM module.

Although some these modules depend on one another, the dependencies are not explicitly set in package.json; instead these dependencies are checked at runtime as in…

var o = require('../object/core'),

    ...

    if (!o) {
        throw new Error('Please run `npm install o2.object` first.');
    }

So if you see an error message in the console, make sure you npm install necessary modules first.

Release Policy

// TODO: to be edited. This is a very rough outline right now.

Versions are in the form MAJOR.MINOR.PATCH

  • PATCH: (backwards compatible) bug fixes (no new features)
  • MINOR: (backwards compatible) features
  • MAJOR: non-backwards-compatible changes.

every feature/bugfix to be added is forked into a feature branch (under features/branchname)

feature branches branch off from develop and merge back to develop.

every release branch branches off from develop and merges back to develop and master

release branches should not contain featured (i.e., only minor version increases in release branches)

release branch is higher than the version number in package.json

for for version: 2.0.12 the release branch should be at least 'release-2.1'.

before merging, make sure that the release branch does not have any CI build failures.

more info at http://semver.org/ and http://nvie.com/posts/a-successful-git-branching-model/

o2.js's People

Contributors

v0lkan avatar josecapablanca avatar ndrut avatar

Stargazers

Roman avatar Senchabot avatar Yasin ATEŞ avatar Velnae avatar Ghustavh97 avatar Martin Wright avatar Evandro Cavalcante Santos avatar Genesis Gabiola avatar Surya avatar Wahab Labi avatar Vitaly Doroshko avatar mkwtys avatar Ingvar Stepanyan avatar Harrison Powers avatar Manuel Loayza avatar  avatar BJR Matos avatar Claudio d'Angelis avatar Brisk.io avatar Everton Yoshitani avatar  avatar  avatar  avatar Umar Hansa avatar David Wells avatar Adam Gedney avatar Arman Kara avatar Sinan Acikal avatar Emre Barack Sokullu avatar Valery Lyatsevich avatar Şaban Ulutaş avatar Mustafa İlhan avatar Jazz Yao-Tsung Wang avatar Jack Liu Shurui avatar Mike Chen avatar Alan Sha avatar  avatar  avatar Ted avatar YuLun Shih avatar Carter Tsai avatar Bo-Yi Wu avatar DDH avatar Allen Galler avatar Gray avatar Cory Armbrecht avatar floydwch avatar Amadu Bah avatar Jared Wright avatar  avatar  avatar Owenet avatar Meni Koppenhol avatar Stéphane Gomes avatar Ferit Topcu avatar Gun.io Robot avatar Oguz Serdar avatar gasbakid avatar Suleyman Melikoglu avatar ersan avatar Gianni Furger avatar Ahmet Ardal avatar Reshad Noorzay avatar Fabian Morón Zirfas avatar Chandu avatar Halil Özgür avatar Andrew Kane avatar Cornelius Toole avatar Seyhun Akyürek avatar Erhan BURHAN avatar Hasan Tayyar Beşik avatar Oleg Efimov avatar Joakim Bick avatar Alexandre Morgaut avatar Volkan Altan avatar

Watchers

Thao Le avatar Oleg Efimov avatar Allen Galler avatar Everton Yoshitani avatar Amadu Bah avatar keketa avatar James Cloos avatar  avatar  avatar Gaurav Castle avatar

o2.js's Issues

update js-doc documentation

  1. the new update removed the namespaces from the js-doc documentations. add those namespaces back
  2. some of the method signatures and behaviors have changed (especially in DomHelper modules) update them as well.

some of the functions are closing over DOM nodes, avoid it.

For example:

    el = $(el);

    if (!el) {
        return null;
    }

    if (el.querySelectorAll) {
        me.getElementsByClassName = function(el, c) {
            el = $(el);

            if (!el) {
                return null;
            }

            return el.querySelectorAll(['.', c].join(kEmpty));
        };

        return me.getElementsByClassName(el, c);
    }

The closure closes over el, it's a bad in terms of memory utilization. We should take the closure out.

DomHelper additional methods required.

---> todo: create a getParentWithStyle method
---> todo: create a getParentWithClass method
--> todo: add get**_withStyle and get**_withclass methos.,
getParentByStyle
getParentByClass
getParentbyAttribute

getParentWithAttribute classname fix required

    getAttribute : function(obj, attribute) {
        obj = $(obj);

        if(!obj || !attribute) {

            return null;
        }

        ///////////////////////////////////////////////////////
        if(attribute == 'class'  || attribute == 'className'){
            var value = obj.className;

            if(value !== UNDEFINED) {

                return value;
            }                
        }
        //////////////////////////////////////////////////////


        if( typeof obj.getAttribute == 'function') {

            var value = obj.getAttribute(attribute);

            if(value !== UNDEFINED) {

                return value;
            }
        }

        return obj[attribute] ? obj[attribute] : null;

    }

};

o2.ui.Slider

A slider component that utilizes the Droppable for the sliding operations.

o2.ui.Droppable

A droppable component that utilized HTML5 drag drop api when possible and uses a fallback technique otherwise.

cache commonly used functions in modules as static "aliases" in modules.

... and also cache those aliases if they are excessively used within loops.

for instance:

/*
 * Aliases.
 */
var toCamelCase = o2.StringHelper.toCamelCase;

...

me.addStyle = function(obj, style) {

    var toCamelCaseCached = toCamelCase;

    if(!obj || typeof obj != 'object') {
        return;
    }

    for(var key in style) {
        if(style.hasOwnProperty(key)) {
            obj.style[toCamelCaseCached(key)] = style[key];
        }
    }

};

o2.DomHelper.loadCss should accept success and fail callbacks.

Well this is way too complicated than the o2.DomHelper.loadScirpt case.

Here are a dozen of people who have struggled with the issue, without much luck (in terms of cross-browser support, without using browser sniffing, or nasty hacks)

http://www.phpied.com/when-is-a-stylesheet-really-loaded/
http://plugins.jquery.com/files/jquery.xLazyLoader.js.txt

polling the cssRules collection is an option, but it will fail if the css is going to be loaded from a different domain.
http://www.zachleat.com/web/load-css-dynamically/

we can use something like

// dummy element in the html

// dummy element in the css

cssloaded { height:1px; }

but it's a "nasty" hack. and if we don't have control over the css we're gonna load, it will not work as well.

And here are a set of bugs in different browsers, regarding the issue:
https://bugs.webkit.org/show_bug.cgi?id=38995 (that's open)
https://bugzilla.mozilla.org/show_bug.cgi?id=185236 (that's fixed)
http://code.google.com/p/chromium/issues/detail?id=67522 (that's open)

Besides, I don't see any use (other than fullfilling academic curiosity) of detecting when a stylesheet has loaded, or failed; and firing callbacks afterwards.

So I need to think about this...

complete TODO's

A lot of TODO's have accumulated in the source code. complete and remove them.

o2.DomHelper.loadScript should accept a success callback, and a failure callback

This can be done using script's onload/onreadystatechange (depending on the browser) and onerror even handlers (with an IE caveat, as always)

Loading a script with an error HTTP response:
Firefox 3.5: onerror
Safari 4: onerror
Chrome 4: onerror
IE 7: onreadystatechange
IE 8: onreadystatechange

Loading a good script:
Firefox 3.5: onload
Safari 4: onload
Chrome 4: onload
IE 7: onreadystatechange (if not cached)
IE 8: onreadystatechange (if not cached)

so...
The onerror attribute works on all browsers but IE.
For IE, onreadystatechange is available.
No browser supports both of them, so a handler hooked up to both of them will fire exactly once.

A timer can be used to detect load failures in IE (say, the attempt times out after 20 seconds)

Another complication on IE is that onreadystatechange doesn't differentiate whether the download succeeded or not. Downloading a non-cached version looks the same as a download failure.
Thus, any code using onreadystatechange needs to check whether the download succeeded or not.
Another option would be to disable caching in IE by ammending a random number to the end of the script, but that is counter-productive.

I have to think about all these.
I may not provide a failure callback, if I'm not satisfied with the method's cross-browser behavior.

Additional o2.DomHelper.get*** Methods

//TODO: getChildrenById & comma delim

//TODO: getChildrenWithId & comma delim

//TODO: getElementsById & comma delim

//TODO: getElementsWithId & comma delim

//TODO: getElementsByAttribute & comma delim & space delim

//TODO: getElementsWithAttribute & comma delim & space delim

//TODO: getElementsByClassName belongs here & comma delim & space delim

//TODO: getElementsWithClassName & comma delim & space delim

//TODO: getFirstChildById

//TODO: getFirstChildWithId

//TODO: getLastChildById

//TODO: getLastChildWithID

//TODO: getFirstChildByClassName

//TODO: getFirstChildWithClassName

//TODO: getFirstChildByAttribute

//TODO: getFirstChildWithAttribute

//TODO: getLastChildByAttribute

//TODO: getLastChildWithAttribute

Enhance o2.CollectionHelper

each, map, reduce, detect, select, reject, all, any, include, invoke, pluck, max, min, sortBy, groupBy, toArray, sizeOf, first, rest, last, compact, flatten, without, union, intersection, difference, uniq, zip, indexOf, lastIndexOf, range, bind, bindAll, memoize, delay, defer, throttle, debounce, once, after, wrap, compose, keys, values, functions, extend, defaults, clone, tap

are a few methods that can be added

implement a PHP counterpart for the template engine.

The o2.Template class uses JavaScript arrays as a basis for templating.
And this enables extremely fast and efficient template rendering when compared to alternatives (such as mustache)

[
    "<ul>",
    [
        "each users",
        [
            "<li>{name}</li>"
        ]
    ],
    "</ul>"
]

Yeah I know, o2.Template is incomplete and its rule engine is rather primitive. But that's not the point.
The point is; it's darn fast!

The good part is that the above template expression is also a valid JSON. -- which means that it can be easily converted to a PHP nested array. This will enable us implement the same templating logic in the PHP side as well.

Therefore we can have identical server-side and client-side rendering of the templates.

Identify which platforms does o2.js target

I plan to support IE7+ (and to hell with IE6)

The core objects will be platform-agnostic, they will be equally usable in mobile and desktop browsers.
Though individual mobile plug-ins / components may be developed on the long run.

...

Anyway, once you are clear with which platforms you support, add it to the README file.

Prepare Unit Tests

Before that, a simple unit testing framework should be built.

I plan to extend o2.Debugger object for this purpose.

The unit testing framework will not be anything fancy.
Just simple assertion functions and basic methods.
... and a "runner" module to run all the unit tests consequentially and collect results.

me want UI components!

    Autocompleter
    Calendar
    Colorpicker
    Dialog
    In Place Edit
    Lightbox
    Rater
    Resizable
    Rte
    Selectable
    Slider
    Sortable
    Tabs
    Tags
    Tooltips
    Uploader

are a few.

add examples

It will be better to start adding examples after having completed the unit tests.

o2.DomHelper.get*** methods should be able to select more than one classname, id, tags etc.

this may be a duplicate issue.

for instance

o2.DomHelper.getElementsByClassName(node, 'class1, class2');

should return all the inner nodes with "class1" OR "class2" as a classname.

o2.DomHelper.getElementsByClassName(node, 'class1 class2');

should return all the inner nodes with "class1" AND "class2" as a classname.

All the getters should be revised accordingly.

The end-result will NOT be a sizzle-like selector engine, though. Because giving too much selector freedom ofter results in a performance sacrifice. -- In fact, imho in 99% of the cases document.getElementById is the best selector possible. -- and if one does not bother to give a darn ID to their elements, they are in the wrong path, and I do not want to lead them further into that path.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.