Git Product home page Git Product logo

panjs's Introduction

#panJS v1.0.2

A 40 ko javascript framework

Change log.

API documentation

panJs is a javascript framework that uses Jquery and allows you to create easily applications, making resusable components.
You can integrate panJS in a existing application (only parts of the application can be managed by panJs).

Basic demo

TodoMVC example

TodoMVC X2 example

Circles example

Tutorial

Licence

Licence Creative Commons


Panjs de Christophe Toesca est mis à disposition selon les termes de la licence Creative Commons Attribution - Pas d'Utilisation Commerciale - Pas de Modification 4.0 International. Les autorisations au-delà du champ de cette licence peuvent être obtenues à cette adresse: https://github.com/ctoesca.

Feature Highlights

  • A component is a HTML file that contains CSS, JS, HTML like any Html file
  • Components can be integrated in a page or in other components with html markup
  • Components (and their dependencies) are dynamically loaded and you don't have to add js/css in the <head> of the page.
  • Cache management (Js/css/html): the framework adds '?v=x.x.x' in all loaded files, or can store components in localstorage (max speed).
  • Inheritance on classes and components (HTML / CSS / JS).
  • Static classes
  • Encapsulation
  • Lazy loading of components and classes
  • You can use LESS in components. panJs converts LESS to CSS.
  • Includes Ajax facilities (Class TrestClient.js)
  • Easy to make a one page application (but not mandatory)
  • States, hash routing
  • Errors management: in production, a component with a runtime error/syntax error/XML error will be replaced by a special error component showing the error: the application is not interrupted (showing a white page etc).
  • ...

###What panJs doesn't do:

  • panJs doesn't choose the architecture of your application (MVC, MVVC etc)
  • Data binding (but you can use some data binding frameworks if you want like KnockoutJS, Mustach ...)
  • panJs isn't a UI library (but there is already some UI components available)

What is a panJS component?

You put a component in HTML page (or in another HTML component) like this:

<div data-compo="app.myComponent.html"/>

myComponent.html:

``` <style type="text/css"> .TmyComponent .result { font-weight: bold; color: #428bca } </style>
<script subtype="text/x-class-definition">
//<![CDATA[      
defineClass("TmyComponent", "panjs.core.display.Telement", { 
   baseElement: "div",  
   clickCount:0,
   constructor: function(args){
      this._super.constructor.call(this,args);  
   },
   onSubmit: function(){
      this.clickCount ++;
      /* this.result is a jquery object ! */
      this.result.html("You have clicked "+this.clickCount+" times");
   }
});
//]]>
</script>
Click here ```

##Getting started

<html>
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
 
    <script>
    //<![CDATA[  
          //panjs settings:
          var panjs = {
            logLevel: "DEBUG",
            env: "dev", // dev or prod
            appName: "myapp"
            appVersion: "1.0.2", 
            
            namespaces:{
              "core": {path: "../core"},    //panjs "core" directory
              "ui":   {path: "../ui"},        //panjs "ui" directory (optionnal)
              "helpers":   {path: "../helpers"},
              "app":  {path: "components"}   //path on your app components (example)
            }
          };
         
          $(document).ready(function() 
          {
            logger.debug("READY");
            panjs.load($(document.body));           
          });
    //]]>
    </script>
    
    <script src="../core/panjs_core.dev.min.js"></script>
    <!-- If you want to enable LESS-->
    <!-- <script src="../core/panjs_core_with_less.dev.min.js"></script>-->

    <!-- Production (error management enabled) -->
    <!-- <script src="../core/panjs_core.prod.min.js"></script>-->
    <!-- <script src="../core/panjs_core_with_less.prod.min.js"></script>-->

  </head>
  <body>
      <!-- panjs component: path : './components/myComponent.html' -->
      <div data-compo="app.myComponent.html"/>

  </body>
</html>

panjs's People

Contributors

ctoesca avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

panjs's Issues

Less and JS minify in HTML components

It's more easy to create components using LESS code, but:

  • LESS doesn't works well with IE8
  • LESS code is injected at runtime by panjs: it's note for production (it's heavy).

So, LESS code of HTML components should be converted to CSS for production use.
This conversion should also minify the script parts of the components.

Less and JS minified in HTML components

It's more easy to create components using LESS code, but:

  • LESS doesn't works well with IE8
  • LESS code is injected at runtime by panjs: it's note for production (it's heavy).

So, LESS code of HTML components should be converted to CSS for production use.
This conversion should also minify the script parts of the components.

Async load of components and classes

Each component and js is loaded synchronously.
It's because a component is instanciated only where all its dependencies are loaded.
It's possible to do it asynchronously but it's hard.

And the "uses" function will not block, so the implementations of the existing applications will need to be updated.

Routing

The components can manage there state with hash route (enableHashManager:true) on the component properties.

For example:

One component can do:
this.setHash("home")

Another component can do:
this.setHash("tabPane1")

the hash in the browser will be:

compo1=home&compo2=tabPane1

If the hash of a component changes, the function onHashChange(hash) will be fired on this component.

The problem is that we can only set a simple "string" hash for each component.
Sometimes, it's userful for a component to store more info.

Imports and globals in LESS

The base URL of imports is the directory of the html file main page.
Sometimes we want to import a less file relative to the path of the component.

Not tested the use of globals within components.

Class hierarchy

The hierarchy:

Tobject
TeventDispatcher
TdisplayObject
TdisplayObjectContainer
Telement

is not efficient.
First, we should separate components that can have a external content (like panel, tabnav etc).

Telement is only for components that can be use with HTML markup.
TdisplayObjectContainer.js and TdisplayObject.js should have HTML, STYLE etc properties.

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.