/build/app.js
JavaScript | 310 lines | 301 code | 6 blank | 3 comment | 25 complexity | abdb87c817d85c46236cf2225a6bbca7 MD5 | raw file
Possible License(s): Apache-2.0
- // App.js
- enyo.kind({
- name: "App",
- fit: !0,
- components: [ {
- name: "snapscroller",
- kind: "SnapScroller",
- classes: "scroller",
- horizontal: "scroll",
- vertical: "hidden"
- }, {
- kind: "Button",
- content: "<",
- slide: "prev",
- ontap: "buttonTapHandler"
- }, {
- kind: "Button",
- content: ">",
- slide: "next",
- ontap: "buttonTapHandler"
- } ],
- buttonTapHandler: function(a, b) {
- a.slide == "prev" ? this.$.snapscroller.prev() : this.$.snapscroller.next();
- },
- create: function() {
- this.inherited(arguments), this.$.snapscroller.createComponents(slides), this.$.snapscroller.render();
- }
- });
- // Slides.js
- slides = [ {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "Enyo 2 \u4e0e\u65e0 template \u7684 python web \u5e94\u7528"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u5173\u4e8e\u6211"
- }, {
- content: "\u81ea\u7531\u8f6f\u4ef6\u8ddf\u4ece\u8005"
- }, {
- content: "email: benluo@gmail.com"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u8bb2\u5ea7\u5b89\u6392"
- }, {
- content: "Enyo \u7b80\u4ecb"
- }, {
- content: "Python Web \u6846\u67b6\u9009\u578b"
- }, {
- content: "Enyo + Zerkzeug + SQLAlchemy \u6846\u67b6"
- }, {
- content: "\u95ee\u7b54"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "Enyo \u5386\u53f2"
- }, {
- tag: "h2",
- content: "Enyo \u53f2\u524d\u53f2"
- }, {
- content: "Palm OS 5 \u8fd0\u884c\u5728 Treo \u624b\u673a\u4e0a"
- }, {
- content: "Mojo \u8fd0\u884c\u5728 Pre/Pixi/Veer \u624b\u673a\u4e0a"
- }, {
- tag: "h2",
- content: "Enyo \u5386\u53f2"
- }, {
- content: "Enyo 1 \u8fd0\u884c\u5728 Touchpad \u5e73\u677f\u7535\u8111\u4e0a"
- }, {
- content: "Enyo 2 \u8ba1\u5212\u8fd0\u884c\u5728\u5c06\u6765\u51fa\u7684 open webOS \u624b\u673a\u4e0a"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "Enyo 2 \u7684\u7279\u70b9"
- }, {
- content: "HTML \u53ea\u662fJS \u6587\u4ef6\u7684\u5bb9\u5668"
- }, {
- content: "\u57fa\u672c\u4e0a\u662fJS\u548cCSS\u6765\u5b9e\u73b0\u7f51\u9875\u5e94\u7528"
- }, {
- content: "\u539f\u5219\u4e0a\u662f\u8de8\u5e73\u53f0\u7684"
- }, {
- content: "Enyo 2 \u662f\u76f4\u63a5\u4ece Enyo 1 \u6765\u7684\uff0c\u5e94\u8be5\u5bf9\u624b\u673a\u5e94\u7528\u6700\u9002\u5408"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "Enyo 2 \u7684\u5178\u578b\u7a0b\u5e8f"
- }, {
- content: "index.html \u4f5c\u4e3a\u7a0b\u5e8f\u7684\u5165\u53e3"
- }, {
- content: "enyo \u76ee\u5f55\u91cc\u5305\u542b enyo.js \u548c enyo.css \u662f enyo \u7684\u6838\u5fc3\u5e93\u3002"
- }, {
- content: "source \u6216\u5176\u5b83\u76ee\u5f55\u4e0b\u4fdd\u5b58\u5e94\u7528\u7684 JS \u6587\u4ef6\u3002"
- }, {
- content: "source \u6216\u5176\u5b83\u76ee\u5f55\u4e0b\u4fdd\u5b58\u5e94\u7528\u7684 css \u6587\u4ef6"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "index.html"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u5e94\u7528\u7684 JS \u4e3b\u7a0b\u5e8f"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "Python web \u6846\u67b6\u9009\u578b"
- }, {
- content: "Django \u592a\u91cd\uff0c\u800c\u4e14\u6709 template "
- }, {
- content: "Flask \u5c01\u88c5\u591a\uff0c\u6709\u4e9b\u6211\u4e0d\u559c\u6b22\u7684\u5c01\u88c5, \u6709 template"
- }, {
- content: "CherryPy \u4e0d\u6d3b\u8dc3\uff0c\u4e0d\u559c\u6b22\u5b83\u7684 url \u5206\u53d1\u7684\u65b9\u5f0f"
- }, {
- content: "Pyride \u6709 template, \u6709zope \u8840\u7edf"
- }, {
- content: "Tornado \u4ecb\u7ecd\u4e2d\u592a\u5f3a\u608d\uff0c\u800c\u4e14\u7528\u4e86 eventloop, \u6709\u70b9\u62c5\u5fc3"
- }, {
- tag: "h2",
- content: "\u6700\u7ec8\u9009\u62e9 Zerkzurg -- Flask \u5e95\u5c42\u7684\u5e93"
- }, {
- content: "\u65e0 template"
- }, {
- content: "\u591f\u8f7b\u91cf"
- }, {
- content: "\u548c SQLAlchemy \u914d\u5408"
- }, {
- content: "URL \u5206\u53d1\u7ecf\u8fc7\u5c01\u88c5\u53ef\u4ee5\u6bd4\u8f83\u597d\u770b"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u76f8\u5173\u94fe\u63a5"
- }, {
- tag: "a href='http://enyojs.com'",
- content: "Enyo 2 -- \u4ece webOS \u6f14\u5316\u6765\u7684 JS \u5e93"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://www.djangoproject.com'",
- content: "Django -- \u6d41\u884c\u7684 Python Web \u6846\u67b6"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://flask.pocoo.org'",
- content: "Flask \uff0d\uff0d \u65b0\u664b\u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://cherrypy.org'",
- content: "CherryPy \uff0d\uff0d \u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://www.pylonsproject.org/projects'",
- content: "Pyride \uff0d\uff0d \u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6\uff0cZope \u8840\u7edf"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://http://www.tornadoweb.org/'",
- content: "Tornado \uff0d\uff0d \u4ece FaceBook \u6765\u7684 Python Web \u6846\u67b6"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://Zerkzeug.pocoo.org'",
- content: "Zerkzeug \uff0d\uff0d Flask \u7684\u5e95\u5c42\u5e93"
- }, {
- tag: "br"
- }, {
- tag: "a href='http://http://www.sqlalchemy.org/'",
- content: "SQLAlchemy\u3000\uff0d\uff0d\u3000Python \u4e2d\u6700\u6d41\u884c\u7684 ORM \u5e93"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u4ee3\u7801\u5c55\u793a"
- }, {
- tag: "a href='https://benluo@bitbucket.org/benluo/meixigeshidan-werkzeug-enyo'",
- content: "\u6885\u73ba\u9601\u98df\u5355"
- }, {
- tag: "br"
- }, {
- tag: 'a href="https://benluo@bitbucket.org/benluo/shlug_slides_201205"',
- content: "\u672c\u8bb2\u5ea7\u6f14\u793a\u6587\u6863"
- }, {
- tag: "br"
- } ]
- }, {
- classes: "scroller-slide",
- components: [ {
- tag: "h1",
- content: "\u95ee\u7b54"
- } ]
- } ];
- // SnapScroller.js
- enyo.kind({
- name: "SnapScroller",
- kind: "Scroller",
- strategyKind: "TouchScrollStrategy",
- thumb: !1,
- published: {
- index: 0,
- peek: ""
- },
- events: {
- onSnap: "",
- onSnapFinish: ""
- },
- handlers: {
- onScroll: "doScroll",
- onScrollStart: "doScrollStart",
- onScrollStop: "doScrollStop"
- },
- create: function() {
- this.position = {
- start: null,
- current: null,
- previous: null,
- to: null
- }, this.inherited(arguments), this.$.strategy.$.scrollMath.kFrictionDamping = .85, this.horizontal == "scroll" || this.horizontal == "auto" || this.horizontal == "default" ? this.scrollHorizontal = !0 : this.scrollHorizontal = !1;
- },
- rendered: function() {
- this.inherited(arguments), this.peekChanged();
- },
- peekChanged: function() {
- var a = this.getPeek(), b = this.$.strategy.$.client;
- a && b && (this.scrollHorizontal ? (b.applyStyle("padding-left", "" + a + "px"), b.applyStyle("padding-right", "" + a + "px")) : (b.applyStyle("padding-top", "" + a + "px"), b.applyStyle("padding-left", "" + a + "px")));
- },
- indexChanged: function() {
- var a = this.calculatePosition(this.index);
- a !== undefined && this.directScrollTo(a);
- },
- doScrollStart: function(a, b) {
- this.position.start = this.getCurrentPosition(), this.position.previous = this.position.start;
- },
- doScroll: function(a, b) {
- this.position.current = this.getCurrentPosition(), this.$.strategy.dragging ? this.cansnap = !0 : !this.snapping && this.cansnap && (this.cansnap = !1, this.snap());
- },
- doScrollStop: function(a, b) {
- if (this.snapping) {
- var c = this.getCurrentPosition();
- this.snapping = !1, c != this.position.to && this.directScrollTo(this.position.to), this.doSnapFinish();
- }
- },
- snapScrollTo: function(a) {
- this.snapping = !0, this.position.to = a, this.scrollHorizontal ? this.scrollTo(a, 0) : this.scrollTo(0, a);
- },
- directScrollTo: function(a) {
- this.scrollHorizontal ? this.setScrollLeft(a) : this.setScrollTop(a);
- },
- snap: function() {
- var a = this.calculateSnapIndex();
- a !== undefined && this.snapTo(a);
- },
- getCurrentPosition: function() {
- var a = this.scrollHorizontal ? this.getScrollLeft() : this.getScrollTop();
- return a;
- },
- calculatePosition: function(a) {
- var b = this.getControls().slice(1), c = b[a];
- if (c && c.hasNode()) {
- var d = c.hasNode(), e = this.scrollHorizontal ? d.offsetLeft : d.offsetTop;
- this.peek && (e -= this.peek);
- }
- return e;
- },
- calculateSnapIndex: function() {
- var a = this.position.current - this.position.previous > 0, b = this.getControls().slice(1);
- for (var c = 0; c < b.length; c++) {
- var d = b[c].hasNode(), e = this.scrollHorizontal ? d.offsetLeft : d.offsetTop;
- if (this.position.current < e) return a ? c : c - 1;
- }
- },
- snapTo: function(a) {
- this.prevIndex = this.index;
- var b = this.calculatePosition(a);
- b !== undefined && (this.doSnap(), this.index = parseInt(a), this.index != this.oldIndex && this.snapScrollTo(b));
- },
- prev: function() {
- !this.snapping && this.snapTo(this.index - 1);
- },
- next: function() {
- !this.snapping && this.snapTo(this.index + 1);
- }
- });