PageRenderTime 59ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/build/app.js

https://bitbucket.org/benluo/shlug_slides_201205
JavaScript | 310 lines | 301 code | 6 blank | 3 comment | 25 complexity | abdb87c817d85c46236cf2225a6bbca7 MD5 | raw file
Possible License(s): Apache-2.0
  1. // App.js
  2. enyo.kind({
  3. name: "App",
  4. fit: !0,
  5. components: [ {
  6. name: "snapscroller",
  7. kind: "SnapScroller",
  8. classes: "scroller",
  9. horizontal: "scroll",
  10. vertical: "hidden"
  11. }, {
  12. kind: "Button",
  13. content: "<",
  14. slide: "prev",
  15. ontap: "buttonTapHandler"
  16. }, {
  17. kind: "Button",
  18. content: ">",
  19. slide: "next",
  20. ontap: "buttonTapHandler"
  21. } ],
  22. buttonTapHandler: function(a, b) {
  23. a.slide == "prev" ? this.$.snapscroller.prev() : this.$.snapscroller.next();
  24. },
  25. create: function() {
  26. this.inherited(arguments), this.$.snapscroller.createComponents(slides), this.$.snapscroller.render();
  27. }
  28. });
  29. // Slides.js
  30. slides = [ {
  31. classes: "scroller-slide",
  32. components: [ {
  33. tag: "h1",
  34. content: "Enyo 2 \u4e0e\u65e0 template \u7684 python web \u5e94\u7528"
  35. } ]
  36. }, {
  37. classes: "scroller-slide",
  38. components: [ {
  39. tag: "h1",
  40. content: "\u5173\u4e8e\u6211"
  41. }, {
  42. content: "\u81ea\u7531\u8f6f\u4ef6\u8ddf\u4ece\u8005"
  43. }, {
  44. content: "email: benluo@gmail.com"
  45. } ]
  46. }, {
  47. classes: "scroller-slide",
  48. components: [ {
  49. tag: "h1",
  50. content: "\u8bb2\u5ea7\u5b89\u6392"
  51. }, {
  52. content: "Enyo \u7b80\u4ecb"
  53. }, {
  54. content: "Python Web \u6846\u67b6\u9009\u578b"
  55. }, {
  56. content: "Enyo + Zerkzeug + SQLAlchemy \u6846\u67b6"
  57. }, {
  58. content: "\u95ee\u7b54"
  59. } ]
  60. }, {
  61. classes: "scroller-slide",
  62. components: [ {
  63. tag: "h1",
  64. content: "Enyo \u5386\u53f2"
  65. }, {
  66. tag: "h2",
  67. content: "Enyo \u53f2\u524d\u53f2"
  68. }, {
  69. content: "Palm OS 5 \u8fd0\u884c\u5728 Treo \u624b\u673a\u4e0a"
  70. }, {
  71. content: "Mojo \u8fd0\u884c\u5728 Pre/Pixi/Veer \u624b\u673a\u4e0a"
  72. }, {
  73. tag: "h2",
  74. content: "Enyo \u5386\u53f2"
  75. }, {
  76. content: "Enyo 1 \u8fd0\u884c\u5728 Touchpad \u5e73\u677f\u7535\u8111\u4e0a"
  77. }, {
  78. content: "Enyo 2 \u8ba1\u5212\u8fd0\u884c\u5728\u5c06\u6765\u51fa\u7684 open webOS \u624b\u673a\u4e0a"
  79. } ]
  80. }, {
  81. classes: "scroller-slide",
  82. components: [ {
  83. tag: "h1",
  84. content: "Enyo 2 \u7684\u7279\u70b9"
  85. }, {
  86. content: "HTML \u53ea\u662fJS \u6587\u4ef6\u7684\u5bb9\u5668"
  87. }, {
  88. content: "\u57fa\u672c\u4e0a\u662fJS\u548cCSS\u6765\u5b9e\u73b0\u7f51\u9875\u5e94\u7528"
  89. }, {
  90. content: "\u539f\u5219\u4e0a\u662f\u8de8\u5e73\u53f0\u7684"
  91. }, {
  92. content: "Enyo 2 \u662f\u76f4\u63a5\u4ece Enyo 1 \u6765\u7684\uff0c\u5e94\u8be5\u5bf9\u624b\u673a\u5e94\u7528\u6700\u9002\u5408"
  93. } ]
  94. }, {
  95. classes: "scroller-slide",
  96. components: [ {
  97. tag: "h1",
  98. content: "Enyo 2 \u7684\u5178\u578b\u7a0b\u5e8f"
  99. }, {
  100. content: "index.html \u4f5c\u4e3a\u7a0b\u5e8f\u7684\u5165\u53e3"
  101. }, {
  102. content: "enyo \u76ee\u5f55\u91cc\u5305\u542b enyo.js \u548c enyo.css \u662f enyo \u7684\u6838\u5fc3\u5e93\u3002"
  103. }, {
  104. content: "source \u6216\u5176\u5b83\u76ee\u5f55\u4e0b\u4fdd\u5b58\u5e94\u7528\u7684 JS \u6587\u4ef6\u3002"
  105. }, {
  106. content: "source \u6216\u5176\u5b83\u76ee\u5f55\u4e0b\u4fdd\u5b58\u5e94\u7528\u7684 css \u6587\u4ef6"
  107. } ]
  108. }, {
  109. classes: "scroller-slide",
  110. components: [ {
  111. tag: "h1",
  112. content: "index.html"
  113. } ]
  114. }, {
  115. classes: "scroller-slide",
  116. components: [ {
  117. tag: "h1",
  118. content: "\u5e94\u7528\u7684 JS \u4e3b\u7a0b\u5e8f"
  119. } ]
  120. }, {
  121. classes: "scroller-slide",
  122. components: [ {
  123. tag: "h1",
  124. content: "Python web \u6846\u67b6\u9009\u578b"
  125. }, {
  126. content: "Django \u592a\u91cd\uff0c\u800c\u4e14\u6709 template "
  127. }, {
  128. content: "Flask \u5c01\u88c5\u591a\uff0c\u6709\u4e9b\u6211\u4e0d\u559c\u6b22\u7684\u5c01\u88c5, \u6709 template"
  129. }, {
  130. content: "CherryPy \u4e0d\u6d3b\u8dc3\uff0c\u4e0d\u559c\u6b22\u5b83\u7684 url \u5206\u53d1\u7684\u65b9\u5f0f"
  131. }, {
  132. content: "Pyride \u6709 template, \u6709zope \u8840\u7edf"
  133. }, {
  134. content: "Tornado \u4ecb\u7ecd\u4e2d\u592a\u5f3a\u608d\uff0c\u800c\u4e14\u7528\u4e86 eventloop, \u6709\u70b9\u62c5\u5fc3"
  135. }, {
  136. tag: "h2",
  137. content: "\u6700\u7ec8\u9009\u62e9 Zerkzurg -- Flask \u5e95\u5c42\u7684\u5e93"
  138. }, {
  139. content: "\u65e0 template"
  140. }, {
  141. content: "\u591f\u8f7b\u91cf"
  142. }, {
  143. content: "\u548c SQLAlchemy \u914d\u5408"
  144. }, {
  145. content: "URL \u5206\u53d1\u7ecf\u8fc7\u5c01\u88c5\u53ef\u4ee5\u6bd4\u8f83\u597d\u770b"
  146. } ]
  147. }, {
  148. classes: "scroller-slide",
  149. components: [ {
  150. tag: "h1",
  151. content: "\u76f8\u5173\u94fe\u63a5"
  152. }, {
  153. tag: "a href='http://enyojs.com'",
  154. content: "Enyo 2 -- \u4ece webOS \u6f14\u5316\u6765\u7684 JS \u5e93"
  155. }, {
  156. tag: "br"
  157. }, {
  158. tag: "a href='http://www.djangoproject.com'",
  159. content: "Django -- \u6d41\u884c\u7684 Python Web \u6846\u67b6"
  160. }, {
  161. tag: "br"
  162. }, {
  163. tag: "a href='http://flask.pocoo.org'",
  164. content: "Flask \uff0d\uff0d \u65b0\u664b\u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6"
  165. }, {
  166. tag: "br"
  167. }, {
  168. tag: "a href='http://cherrypy.org'",
  169. content: "CherryPy \uff0d\uff0d \u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6"
  170. }, {
  171. tag: "br"
  172. }, {
  173. tag: "a href='http://www.pylonsproject.org/projects'",
  174. content: "Pyride \uff0d\uff0d \u8f7b\u91cf\u7ea7 Python Web \u6846\u67b6\uff0cZope \u8840\u7edf"
  175. }, {
  176. tag: "br"
  177. }, {
  178. tag: "a href='http://http://www.tornadoweb.org/'",
  179. content: "Tornado \uff0d\uff0d \u4ece FaceBook \u6765\u7684 Python Web \u6846\u67b6"
  180. }, {
  181. tag: "br"
  182. }, {
  183. tag: "a href='http://Zerkzeug.pocoo.org'",
  184. content: "Zerkzeug \uff0d\uff0d Flask \u7684\u5e95\u5c42\u5e93"
  185. }, {
  186. tag: "br"
  187. }, {
  188. tag: "a href='http://http://www.sqlalchemy.org/'",
  189. content: "SQLAlchemy\u3000\uff0d\uff0d\u3000Python \u4e2d\u6700\u6d41\u884c\u7684 ORM \u5e93"
  190. } ]
  191. }, {
  192. classes: "scroller-slide",
  193. components: [ {
  194. tag: "h1",
  195. content: "\u4ee3\u7801\u5c55\u793a"
  196. }, {
  197. tag: "a href='https://benluo@bitbucket.org/benluo/meixigeshidan-werkzeug-enyo'",
  198. content: "\u6885\u73ba\u9601\u98df\u5355"
  199. }, {
  200. tag: "br"
  201. }, {
  202. tag: 'a href="https://benluo@bitbucket.org/benluo/shlug_slides_201205"',
  203. content: "\u672c\u8bb2\u5ea7\u6f14\u793a\u6587\u6863"
  204. }, {
  205. tag: "br"
  206. } ]
  207. }, {
  208. classes: "scroller-slide",
  209. components: [ {
  210. tag: "h1",
  211. content: "\u95ee\u7b54"
  212. } ]
  213. } ];
  214. // SnapScroller.js
  215. enyo.kind({
  216. name: "SnapScroller",
  217. kind: "Scroller",
  218. strategyKind: "TouchScrollStrategy",
  219. thumb: !1,
  220. published: {
  221. index: 0,
  222. peek: ""
  223. },
  224. events: {
  225. onSnap: "",
  226. onSnapFinish: ""
  227. },
  228. handlers: {
  229. onScroll: "doScroll",
  230. onScrollStart: "doScrollStart",
  231. onScrollStop: "doScrollStop"
  232. },
  233. create: function() {
  234. this.position = {
  235. start: null,
  236. current: null,
  237. previous: null,
  238. to: null
  239. }, this.inherited(arguments), this.$.strategy.$.scrollMath.kFrictionDamping = .85, this.horizontal == "scroll" || this.horizontal == "auto" || this.horizontal == "default" ? this.scrollHorizontal = !0 : this.scrollHorizontal = !1;
  240. },
  241. rendered: function() {
  242. this.inherited(arguments), this.peekChanged();
  243. },
  244. peekChanged: function() {
  245. var a = this.getPeek(), b = this.$.strategy.$.client;
  246. 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")));
  247. },
  248. indexChanged: function() {
  249. var a = this.calculatePosition(this.index);
  250. a !== undefined && this.directScrollTo(a);
  251. },
  252. doScrollStart: function(a, b) {
  253. this.position.start = this.getCurrentPosition(), this.position.previous = this.position.start;
  254. },
  255. doScroll: function(a, b) {
  256. this.position.current = this.getCurrentPosition(), this.$.strategy.dragging ? this.cansnap = !0 : !this.snapping && this.cansnap && (this.cansnap = !1, this.snap());
  257. },
  258. doScrollStop: function(a, b) {
  259. if (this.snapping) {
  260. var c = this.getCurrentPosition();
  261. this.snapping = !1, c != this.position.to && this.directScrollTo(this.position.to), this.doSnapFinish();
  262. }
  263. },
  264. snapScrollTo: function(a) {
  265. this.snapping = !0, this.position.to = a, this.scrollHorizontal ? this.scrollTo(a, 0) : this.scrollTo(0, a);
  266. },
  267. directScrollTo: function(a) {
  268. this.scrollHorizontal ? this.setScrollLeft(a) : this.setScrollTop(a);
  269. },
  270. snap: function() {
  271. var a = this.calculateSnapIndex();
  272. a !== undefined && this.snapTo(a);
  273. },
  274. getCurrentPosition: function() {
  275. var a = this.scrollHorizontal ? this.getScrollLeft() : this.getScrollTop();
  276. return a;
  277. },
  278. calculatePosition: function(a) {
  279. var b = this.getControls().slice(1), c = b[a];
  280. if (c && c.hasNode()) {
  281. var d = c.hasNode(), e = this.scrollHorizontal ? d.offsetLeft : d.offsetTop;
  282. this.peek && (e -= this.peek);
  283. }
  284. return e;
  285. },
  286. calculateSnapIndex: function() {
  287. var a = this.position.current - this.position.previous > 0, b = this.getControls().slice(1);
  288. for (var c = 0; c < b.length; c++) {
  289. var d = b[c].hasNode(), e = this.scrollHorizontal ? d.offsetLeft : d.offsetTop;
  290. if (this.position.current < e) return a ? c : c - 1;
  291. }
  292. },
  293. snapTo: function(a) {
  294. this.prevIndex = this.index;
  295. var b = this.calculatePosition(a);
  296. b !== undefined && (this.doSnap(), this.index = parseInt(a), this.index != this.oldIndex && this.snapScrollTo(b));
  297. },
  298. prev: function() {
  299. !this.snapping && this.snapTo(this.index - 1);
  300. },
  301. next: function() {
  302. !this.snapping && this.snapTo(this.index + 1);
  303. }
  304. });