Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial ideas

  • Loading branch information...
commit e4b241b8ce10480bc7fd14b50bd6cd2298eebdf5 1 parent 42d747d
James Pearce jamesgpearce authored
0  README → README.md
File renamed without changes
36 examples/index.html
... ... @@ -0,0 +1,36 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 + <head>
  4 + <title>Z</title>
  5 + <script type='text/javascript' src='../lib/touch/sencha-touch-debug.js'></script>
  6 + <link rel='stylesheet' type='text/css' href='../lib/touch/resources/css/sencha-touch.css'/>
  7 + <script type='text/javascript' src='../src/z.js'></script>
  8 + </head>
  9 +
  10 + <body data-xtype='tabpanel' data-ui='light'>
  11 +
  12 + <div data-title='List'>
  13 + <h1>A list
  14 + <button>Info</button>
  15 + </h1>
  16 + <ul>
  17 + <li>Alice</li>
  18 + <li>Bob</li>
  19 + <li>Charlie</li>
  20 + <li>Doug</li>
  21 + </ul>
  22 + </div>
  23 +
  24 + <div data-title='Carousel'>
  25 + <h1>My photos</h1>
  26 + ...
  27 + </div>
  28 +
  29 + <div data-title='Map'>
  30 + <h1>My home</h1>
  31 + ...
  32 + </div>
  33 +
  34 + </body>
  35 +
  36 +</html>
BIN  lib/.DS_Store
Binary file not shown
1  lib/touch
159 src/z.js
... ... @@ -0,0 +1,159 @@
  1 +var Z = Ext.extend(Ext.Application, {
  2 + name: 'z',
  3 +
  4 + onBeforeLaunch: function(config) {
  5 + this.managers.init();
  6 + this.config = this.managers.generateItem(Ext.getBody(), {
  7 + xtype:'panel',
  8 + fullscreen:true
  9 + });
  10 + Z.superclass.onBeforeLaunch.call(this, config);
  11 + },
  12 +
  13 + launch: function () {
  14 + console.log(this.config);
  15 + var panel = Ext.Panel;
  16 + for(component in Ext) {
  17 + if(component.toLowerCase()==this.config.xtype) {
  18 + panel = Ext[component];
  19 + break;
  20 + }
  21 + }
  22 + new panel(this.config);
  23 + },
  24 +
  25 + managers: {
  26 + init: function () {
  27 + this.generateItem = function (element, config, managerName, index) {
  28 + var dataAttributeNames = [];
  29 + Ext.each(element.dom.attributes, function (attribute) {
  30 + if (attribute.name.substr(0,5)=='data-') {
  31 + config[attribute.name.substr(5)] = attribute.value;
  32 + dataAttributeNames.push(attribute.name);
  33 + }
  34 + });
  35 + var manager = (
  36 + this[managerName + 'Manager'] ||
  37 + this[element.getAttribute('data-zmanager') + 'Manager'] ||
  38 + this[element.getAttribute('data-xtype') + 'Manager'] ||
  39 + this[element.getAttribute('data-xtype') ? 'genericManager' : null] ||
  40 + this[element.dom.nodeName.toLowerCase() + 'Manager']
  41 + );
  42 + for(name in dataAttributeNames) {
  43 + element.dom.removeAttribute(dataAttributeNames[name]);
  44 + }
  45 + if (manager) {
  46 + for (var propertyFunction in manager) {
  47 + if (propertyFunction[0]=='_' && manager['do' + propertyFunction]!==false) {
  48 + var value = manager[propertyFunction](element, config, this, index);
  49 + if (value!==null) {
  50 + config[propertyFunction.substr(1)] = value;
  51 + }
  52 + }
  53 + }
  54 + return config;
  55 + }
  56 + return null;
  57 + };
  58 +
  59 + this.bodyManager = this.genericManager = {
  60 +
  61 + do_xtype: true,
  62 + _xtype: function (element, config) {
  63 + return element.getAttribute('data-xtype') || null;
  64 + },
  65 +
  66 + do_items: true,
  67 + doChildItem: function (childElement) {return true;},
  68 + childItemManagerName: function (childElement) {},
  69 + _items: function (element, config, managers) {
  70 + return this.items(element, config, managers, this.doChildItem);
  71 + },
  72 +
  73 + do_docked_items: true,
  74 + doDockedChildItem: function (childElement) {return false;},
  75 + childItemManagerName: function (childElement) {},
  76 + _docked_items: function (element, config, managers) {
  77 + return this.items(element, config, managers, this.doDockedChildItem);
  78 + },
  79 +
  80 + items: function (element, config, managers, doChildItem) {
  81 + var items = [];
  82 + Ext.each(element.dom.childNodes, function (childNode, index) {
  83 + var childElement = Ext.get(childNode);
  84 + if (childElement && doChildItem(childElement)) {
  85 + var childItem = managers.generateItem(childElement, {}, this.childItemManagerName(childElement), index);
  86 + if (childItem) {
  87 + items.push(childItem);
  88 + childElement.remove();
  89 + }
  90 + }
  91 + }, this);
  92 + return items.length>0 ? items : null;
  93 + },
  94 +
  95 + do_html: true,
  96 + _html: function (element) {
  97 + var html = element.getHTML();
  98 + element.setHTML('');
  99 + return html ? html : null;
  100 + }
  101 + };
  102 +
  103 +
  104 + this.h1Manager = this.toolbarManager = Ext.apply({}, {
  105 + _xtype: function (element) { return 'toolbar'; },
  106 + do_html: false,
  107 + _title: function (element) {
  108 + return this._html(element);
  109 + }
  110 + }, this.genericManager);
  111 +
  112 + this.buttonManager = Ext.apply({}, {
  113 + _xtype: function (element) { return 'button'; },
  114 + do_html: false,
  115 + _text: function (element) {
  116 + return this._html(element);
  117 + }
  118 + }, this.genericManager);
  119 +
  120 + this.olManager = this.ulManager = this.listManager = Ext.apply({}, {
  121 + _xtype: function () { return 'list'; },
  122 + do_items: false,
  123 + do_html: false,
  124 + _itemTpl: function (element) {
  125 + return '{text}';
  126 + },
  127 + _store: function (element, config, managers) {
  128 + return new Ext.data.Store({
  129 + model: Ext.regModel('', {
  130 + fields: [{name:'text', type:'string'}]
  131 + }),
  132 + data: this._items(element, config, managers)
  133 + });
  134 + }
  135 + }, this.genericManager);
  136 +
  137 + this.liManager = {
  138 + _text: function (element) {
  139 + return element.getHTML();
  140 + }
  141 + };
  142 +
  143 + this.tabpanelManager = Ext.apply({}, {
  144 + childItemManagerName: function (childElement) { return 'tab';},
  145 + do_html: false
  146 + }, this.genericManager);
  147 +
  148 + this.tabManager = Ext.apply({}, {
  149 + _title: function (element, config, managers, index) {
  150 + return config['title'] || 'Tab ' + index;
  151 + }
  152 + }, this.genericManager);
  153 +
  154 +
  155 + }
  156 + }
  157 +});
  158 +
  159 +var z = new Z();

0 comments on commit e4b241b

Please sign in to comment.
Something went wrong with that request. Please try again.