af.ui.json 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. [
  2. {
  3. "tags": [
  4. {
  5. "type": "copyright",
  6. "string": "2011-2014 Intel"
  7. },
  8. {
  9. "type": "author",
  10. "string": "Intel"
  11. },
  12. {
  13. "type": "version",
  14. "string": "3.0"
  15. }
  16. ],
  17. "description": {
  18. "full": "<p>appframework.ui - A User Interface library for App Framework applications</p>",
  19. "summary": "<p>appframework.ui - A User Interface library for App Framework applications</p>",
  20. "body": ""
  21. },
  22. "isPrivate": false,
  23. "ignore": false
  24. },
  25. {
  26. "tags": [],
  27. "description": {
  28. "full": "<p>global FastClick</p>",
  29. "summary": "<p>global FastClick</p>",
  30. "body": ""
  31. },
  32. "ignore": false
  33. },
  34. {
  35. "tags": [],
  36. "description": {
  37. "full": "<p>jshint camelcase:false</p>",
  38. "summary": "<p>jshint camelcase:false</p>",
  39. "body": ""
  40. },
  41. "ignore": false,
  42. "code": "(function($) {\n \"use strict\";\n var startPath = window.location.pathname + window.location.search;\n var defaultHash = window.location.hash;\n var previousTarget = defaultHash;\n var AFUi = function() {\n // Init the page\n var that = this;\n\n\n if (typeof define === \"function\" && define.amd) {\n that.autoLaunch=false;\n define(\"appframeworkui\", [], function() {\n return $.afui;\n });\n } else if (typeof module !== \"undefined\" && module.exports) {\n that.autoLaunch=false;\n $.afui = that;\n }\n\n var setupAFDom = function() {\n setupCustomTheme();\n if(window.FastClick)\n FastClick.attach(document.documentElement);\n };\n\n if (document.readyState === \"complete\" || document.readyState === \"loaded\") {\n setupAFDom();\n if(that.init)\n that.autoBoot();\n else{\n $(window).one(\"afui:init\", function() {\n that.autoBoot();\n });\n }\n } else $(document).ready(\n function() {\n setupAFDom();\n if(that.init)\n that.autoBoot();\n else{\n $(window).one(\"afui:init\", function() {\n that.autoBoot();\n });\n }\n },\n false);\n\n //click back event\n window.addEventListener(\"popstate\", function() {\n\n if(!that.useInternalRouting) return;\n var id = that.getPanelId(document.location.hash);\n var hashChecker = document.location.href.replace(document.location.origin + \"/\", \"\");\n //make sure we allow hash changes outside afui\n\n if (hashChecker === \"#\") return;\n if (id === \"\" && that.history.length === 1) //Fix going back to first panel and an empty hash\n id = \"#\" + that.firstPanel.id;\n if (id === \"\") return;\n if (af(id).filter(\".panel\").length === 0) return;\n\n if (id !== \"#\" + that.activeDiv.id) that.goBack();\n\n }, false);\n\n\n window.addEventListener(\"orientationchange\",function(){\n window.scrollTo(0, 0);\n });\n\n function setupCustomTheme() {\n\n if (that.useOSThemes) {\n var $el=$(document.body);\n $el.removeClass(\"ios ios7 win8 tizen bb android light dark firefox\");\n if ($.os.android)\n $el.addClass(\"android\");\n else if ($.os.ie) {\n $el.addClass(\"win8\");\n } else if ($.os.blackberry||$.os.blackberry10||$.os.playbook) {\n $el.addClass(\"bb\");\n that.backButtonText = \"Back\";\n } else if ($.os.ios7){\n $el.addClass(\"ios7\");\n } else if ($.os.ios)\n $el.addClass(\"ios7\");\n else if($.os.tizen)\n $el.addClass(\"tizen\");\n else if($.os.fennec)\n $el.addClass(\"firefox\");\n }\n if($.os.ios7&&that.overlayStatusbar){\n that.ready(function(){\n $(document.body).addClass(\"overlayStatusbar\");\n });\n }\n }\n };\n\n\n var clickHandlers=[];\n AFUi.prototype = {\n init:false,\n showLoading: true,\n loadingText: \"Loading Content\",\n remotePages: {},\n history: [],\n views:{},\n _readyFunc: null,\n doingTransition: false,\n ajaxUrl: \"\",\n transitionType: \"slide\",\n firstPanel: \"\",\n hasLaunched: false,\n isLaunching:false,\n launchCompleted: false,\n activeDiv: \"\",\n customClickHandler: \"\",\n useOSThemes: true,\n overlayStatusbar: false,\n useAutoPressed: true,\n useInternalRouting:true,\n autoBoot: function() {\n this.hasLaunched = true;\n if (this.autoLaunch) {\n this.launch();\n }\n },"
  43. },
  44. {
  45. "tags": [
  46. {
  47. "type": "api",
  48. "visibility": "private"
  49. }
  50. ],
  51. "description": {
  52. "full": "<p>This blocks the page from bouncing on iOS</p>",
  53. "summary": "<p>This blocks the page from bouncing on iOS</p>",
  54. "body": ""
  55. },
  56. "isPrivate": true,
  57. "ignore": false,
  58. "code": "blockPageBounce:function(enable){\n if(enable===false){\n window.removeEventListener(\"touchmove\",this.handlePageBounce,false);\n window.removeEventListener(\"touchstart\",this.handlePageBounce,false);\n return;\n }\n\n window.addEventListener(\"touchmove\",this.handlePageBounce,false);\n window.addEventListener(\"touchstart\",this.handlePageBounce,false);\n\n },"
  59. },
  60. {
  61. "tags": [
  62. {
  63. "type": "api",
  64. "visibility": "private"
  65. }
  66. ],
  67. "description": {
  68. "full": "<p>Handle touch events for scrolling divs</p>",
  69. "summary": "<p>Handle touch events for scrolling divs</p>",
  70. "body": ""
  71. },
  72. "isPrivate": true,
  73. "ignore": false,
  74. "code": "handlePageBounce:function(evt){\n if(evt.type===\"touchstart\"){\n this._startTouchY=evt.touches[0].screenY;\n return;\n }\n var panel=$(evt.target).closest(\".panel\");\n if(panel.length===0) return evt.preventDefault();\n var el=panel.get(0);\n\n var canScroll=el.scrollHeight>el.clientHeight;\n var hasTouchOverflow=$(el).computedStyle(\"-webkit-overflow-scrolling\")===\"touch\";\n var hasOverflow=$(el).computedStyle(\"overflowY\")!==\"hidden\";\n var height=parseInt($(el).computedStyle(\"height\"),10);\n if(canScroll&&hasTouchOverflow&&hasOverflow){\n\n var currY=evt.touches[0].screenY;\n var scrollAtTop=((this._startTouchY<=currY)&&(el.scrollTop===0));\n var scrollAtBottom=((this._startTouchY>=currY)&&((el.scrollHeight-el.scrollTop)===height));\n if(scrollAtTop||scrollAtBottom)\n evt.preventDefault();\n return;\n }\n\n },"
  75. },
  76. {
  77. "tags": [
  78. {
  79. "type": "param",
  80. "types": [
  81. "string"
  82. ],
  83. "name": "selector",
  84. "description": ""
  85. },
  86. {
  87. "type": "param",
  88. "types": [
  89. "function"
  90. ],
  91. "name": "callback",
  92. "description": "to execute"
  93. },
  94. {
  95. "type": "title",
  96. "string": "$.afui.registerDataDirective"
  97. }
  98. ],
  99. "description": {
  100. "full": "<p>Register a data directive for a click event. Plugins use this to allow<br />html based execution (see af.popup.js)<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.registerDataDirective(\"[data-foo]\",function(){<br /> console.log(\"foo was clicked\");<br /> })<br /> </pre></div></p>",
  101. "summary": "<p>Register a data directive for a click event. Plugins use this to allow<br />html based execution (see af.popup.js)<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.registerDataDirective(\"[data-foo]\",function(){<br /> console.log(\"foo was clicked\");<br /> })<br /> </pre></div></p>",
  102. "body": ""
  103. },
  104. "isPrivate": false,
  105. "ignore": false,
  106. "code": "registerDataDirective:function(selector,cb){\n clickHandlers.push({sel:selector,cb:cb});\n },"
  107. },
  108. {
  109. "tags": [],
  110. "description": {
  111. "full": "<p>This enables the tab bar ability to keep pressed states on elements<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.enableTabBar();<br /> </pre></div><br /> @title $.afui.enableTabBar</p>",
  112. "summary": "<p>This enables the tab bar ability to keep pressed states on elements<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.enableTabBar();<br /> </pre></div><br /> @title $.afui.enableTabBar</p>",
  113. "body": ""
  114. },
  115. "ignore": false,
  116. "code": "enableTabBar:function(){\n $(document).on(\"click\",\".button-grouped.tabbed\",function(e){\n var $el=$(e.target);\n $el.closest(\".tabbed\").find(\".button\").data(\"ignore-pressed\",\"true\").removeClass(\"pressed\");\n //this is a hack, but the touchEvents plugin will remove pressed\n $el.closest(\".button\").addClass(\"pressed\");\n setTimeout(function(){\n $el.closest(\".button\").addClass(\"pressed\");\n });\n });\n },"
  117. },
  118. {
  119. "tags": [
  120. {
  121. "type": "title",
  122. "string": "$.afui.disableTabBar"
  123. }
  124. ],
  125. "description": {
  126. "full": "<p>This disables the tab bar ability to keep pressed states on elements<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.disableTabBar();<br /> </pre></div></p>",
  127. "summary": "<p>This disables the tab bar ability to keep pressed states on elements<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.disableTabBar();<br /> </pre></div></p>",
  128. "body": ""
  129. },
  130. "isPrivate": false,
  131. "ignore": false,
  132. "code": "disableTabBar:function(){\n $(document).off(\"click\",\".button-grouped.tabbed\");\n $(\".button-grouped.tabbed .button\").removeAttr(\"data-ignore-pressed\");\n },"
  133. },
  134. {
  135. "tags": [
  136. {
  137. "type": "title",
  138. "string": "$.afui.manageHistory"
  139. }
  140. ],
  141. "description": {
  142. "full": "<p>This is a boolean property. When set to true, we manage history and update the hash<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.manageHistory=false;//Don't manage for apps using Backbone<br /> </pre></div></p>",
  143. "summary": "<p>This is a boolean property. When set to true, we manage history and update the hash<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.manageHistory=false;//Don't manage for apps using Backbone<br /> </pre></div></p>",
  144. "body": ""
  145. },
  146. "isPrivate": false,
  147. "ignore": false,
  148. "code": "manageHistory: true,"
  149. },
  150. {
  151. "tags": [
  152. {
  153. "type": "title",
  154. "string": "$.afui.loadDefaultHash"
  155. }
  156. ],
  157. "description": {
  158. "full": "<p>This is a boolean property. When set to true (default) it will load that panel when the app is started<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDefaultHash=false; //Never load the page from the hash when the app is started<br /> $.afui.loadDefaultHash=true; //Default<br /> </pre></div></p>",
  159. "summary": "<p>This is a boolean property. When set to true (default) it will load that panel when the app is started<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDefaultHash=false; //Never load the page from the hash when the app is started<br /> $.afui.loadDefaultHash=true; //Default<br /> </pre></div></p>",
  160. "body": ""
  161. },
  162. "isPrivate": false,
  163. "ignore": false,
  164. "code": "loadDefaultHash: true,"
  165. },
  166. {
  167. "tags": [
  168. {
  169. "type": "param",
  170. "types": [
  171. "(string",
  172. "Array.<string>)"
  173. ],
  174. "name": "links",
  175. "description": ""
  176. },
  177. {
  178. "type": "title",
  179. "string": "$.afui.actionsheet()"
  180. }
  181. ],
  182. "description": {
  183. "full": "<p>This is a shorthand call to the $.actionsheet plugin. We wire it to the afui div automatically<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.actionsheet(\"<a href='javascript:;' class='button'>Settings</a> <a href='javascript:;' class='button red'>Logout</a>\")<br /> $.afui.actionsheet(\"[{<br /> text: 'back',<br /> cssClasses: 'red',<br /> handler: function () { $.afui.goBack(); ; }<br /> }, {<br /> text: 'show alert 5',<br /> cssClasses: 'blue',<br /> handler: function () { alert(\"hi\"); }<br /> }, {<br /> text: 'show alert 6',<br /> cssClasses: '',<br /> handler: function () { alert(\"goodbye\"); }<br /> }]\");<br /> </pre></div></p>",
  184. "summary": "<p>This is a shorthand call to the $.actionsheet plugin. We wire it to the afui div automatically<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.actionsheet(\"<a href='javascript:;' class='button'>Settings</a> <a href='javascript:;' class='button red'>Logout</a>\")<br /> $.afui.actionsheet(\"[{<br /> text: 'back',<br /> cssClasses: 'red',<br /> handler: function () { $.afui.goBack(); ; }<br /> }, {<br /> text: 'show alert 5',<br /> cssClasses: 'blue',<br /> handler: function () { alert(\"hi\"); }<br /> }, {<br /> text: 'show alert 6',<br /> cssClasses: '',<br /> handler: function () { alert(\"goodbye\"); }<br /> }]\");<br /> </pre></div></p>",
  185. "body": ""
  186. },
  187. "isPrivate": false,
  188. "ignore": false,
  189. "code": "actionsheet: function(opts) {\n return $.query(document.body).actionsheet(opts);\n },"
  190. },
  191. {
  192. "tags": [
  193. {
  194. "type": "param",
  195. "types": [
  196. "(object",
  197. "string)"
  198. ],
  199. "name": "options",
  200. "description": ""
  201. },
  202. {
  203. "type": "title",
  204. "string": "$.afui.popup(opts)"
  205. }
  206. ],
  207. "description": {
  208. "full": "<p>This is a wrapper to $.popup.js plugin. If you pass in a text string, it acts like an alert box and just gives a message<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.popup(opts);<br /> $.afui.popup( {<br /> title:\"Alert! Alert!\",<br /> message:\"This is a test of the emergency alert system!! Don't PANIC!\",<br /> cancelText:\"Cancel me\",<br /> cancelCallback: function(){console.log(\"cancelled\");},<br /> doneText:\"I'm done!\",<br /> doneCallback: function(){console.log(\"Done for!\");},<br /> cancelOnly:false<br /> });<br /> $.afui.popup('Hi there');<br /> </pre></div></p>",
  209. "summary": "<p>This is a wrapper to $.popup.js plugin. If you pass in a text string, it acts like an alert box and just gives a message<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.popup(opts);<br /> $.afui.popup( {<br /> title:\"Alert! Alert!\",<br /> message:\"This is a test of the emergency alert system!! Don't PANIC!\",<br /> cancelText:\"Cancel me\",<br /> cancelCallback: function(){console.log(\"cancelled\");},<br /> doneText:\"I'm done!\",<br /> doneCallback: function(){console.log(\"Done for!\");},<br /> cancelOnly:false<br /> });<br /> $.afui.popup('Hi there');<br /> </pre></div></p>",
  210. "body": ""
  211. },
  212. "isPrivate": false,
  213. "ignore": false,
  214. "code": "popup: function(opts) {\n return $.query(document.body).popup(opts);\n },"
  215. },
  216. {
  217. "tags": [
  218. {
  219. "type": "param",
  220. "types": [
  221. "string"
  222. ],
  223. "name": "id",
  224. "description": "of drawer"
  225. },
  226. {
  227. "type": "param",
  228. "types": [
  229. "string"
  230. ],
  231. "name": "position",
  232. "description": "(left|right)"
  233. },
  234. {
  235. "type": "param",
  236. "types": [
  237. "string"
  238. ],
  239. "name": "transition",
  240. "description": "(push, cover, reveal)"
  241. },
  242. {
  243. "type": "title",
  244. "string": "$.afui.drawer.show"
  245. }
  246. ],
  247. "description": {
  248. "full": "<p>This is a reference to the drawer plugin.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.drawer.show('#left','left','reveal')<br /> </pre></div></p>",
  249. "summary": "<p>This is a reference to the drawer plugin.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.drawer.show('#left','left','reveal')<br /> </pre></div></p>",
  250. "body": ""
  251. },
  252. "isPrivate": false,
  253. "ignore": false
  254. },
  255. {
  256. "tags": [
  257. {
  258. "type": "param",
  259. "types": [
  260. "number"
  261. ],
  262. "name": "opacity",
  263. "description": ""
  264. },
  265. {
  266. "type": "title",
  267. "string": "$.afui.blockUI(opacity)"
  268. }
  269. ],
  270. "description": {
  271. "full": "<p>This will throw up a mask and block the UI<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.blockUI(.9)<br /> </pre></div>`</p>",
  272. "summary": "<p>This will throw up a mask and block the UI<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.blockUI(.9)<br /> </pre></div>`</p>",
  273. "body": ""
  274. },
  275. "isPrivate": false,
  276. "ignore": false,
  277. "code": "blockUI: function(opacity) {\n $.blockUI(opacity);\n },"
  278. },
  279. {
  280. "tags": [
  281. {
  282. "type": "title",
  283. "string": "$.afui.unblockUI()"
  284. }
  285. ],
  286. "description": {
  287. "full": "<p>This will remove the UI mask<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.unblockUI()<br /> </pre></div>`</p>",
  288. "summary": "<p>This will remove the UI mask<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.unblockUI()<br /> </pre></div>`</p>",
  289. "body": ""
  290. },
  291. "isPrivate": false,
  292. "ignore": false,
  293. "code": "unblockUI: function() {\n $.unblockUI();\n },"
  294. },
  295. {
  296. "tags": [
  297. {
  298. "type": "title",
  299. "string": "$.afui.autoLaunch"
  300. }
  301. ],
  302. "description": {
  303. "full": "<p>Boolean if you want to auto launch afui<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.autoLaunch = false; //<br /> </pre></div></p>",
  304. "summary": "<p>Boolean if you want to auto launch afui<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.autoLaunch = false; //<br /> </pre></div></p>",
  305. "body": ""
  306. },
  307. "isPrivate": false,
  308. "ignore": false,
  309. "code": "autoLaunch: true,"
  310. },
  311. {
  312. "tags": [
  313. {
  314. "type": "param",
  315. "types": [
  316. "function"
  317. ],
  318. "name": "param",
  319. "description": "function to execute"
  320. },
  321. {
  322. "type": "title",
  323. "string": "$.afui.ready"
  324. }
  325. ],
  326. "description": {
  327. "full": "<p>function to fire when afui is ready and completed launch<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.ready(function(){console.log('afui is ready');});<br /> </pre></div></p>",
  328. "summary": "<p>function to fire when afui is ready and completed launch<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.ready(function(){console.log('afui is ready');});<br /> </pre></div></p>",
  329. "body": ""
  330. },
  331. "isPrivate": false,
  332. "ignore": false,
  333. "code": "ready: function(param) {\n if (this.launchCompleted)\n param();\n else {\n $(document).one(\"afui:ready\", function() {\n param();\n });\n }\n },"
  334. },
  335. {
  336. "tags": [
  337. {
  338. "type": "title",
  339. "string": "$.afui.goBack()"
  340. },
  341. {
  342. "type": "param",
  343. "types": [
  344. "number="
  345. ],
  346. "name": "delta",
  347. "description": "relative position from the last element (> 0)"
  348. }
  349. ],
  350. "description": {
  351. "full": "<p>Initiate a back transition<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.goBack()<br /> </pre></div></p>",
  352. "summary": "<p>Initiate a back transition<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.goBack()<br /> </pre></div></p>",
  353. "body": ""
  354. },
  355. "isPrivate": false,
  356. "ignore": false,
  357. "code": "goBack: function(e) {\n //find the view\n var view=$(this.activeDiv).closest(\".view\");\n if(e&&e.target)\n view=$(e.target).closest(\".view\");\n\n if(view.length===0) return;\n\n //history entry\n if(!this.views[view.prop(\"id\")]) return;\n var hist=this.views[view.prop(\"id\")];\n\n if(hist.length===0) return;\n var item=hist.pop();\n\n if(item.length===0) return;\n if(hist.length>0){\n\n var toTarget=hist[hist.length-1].target;\n if(!toTarget||item.target===toTarget) return;\n this.runTransition(item.transition,item.target,toTarget,true);\n this.loadContentData(toTarget,view,true);\n\n this.updateHash(toTarget.id);\n }\n else {\n //try to dismiss the view\n try{\n this.dismissView(item.target,item.transition);\n }\n catch(ex){\n }\n\n }\n },"
  358. },
  359. {
  360. "tags": [
  361. {
  362. "type": "title",
  363. "string": "$.afui.clearHistory()"
  364. }
  365. ],
  366. "description": {
  367. "full": "<p>Clear the history queue for the current view based off the active div<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.clearHistory()<br /> </pre></div></p>",
  368. "summary": "<p>Clear the history queue for the current view based off the active div<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.clearHistory()<br /> </pre></div></p>",
  369. "body": ""
  370. },
  371. "isPrivate": false,
  372. "ignore": false,
  373. "code": "clearHistory: function() {\n //find the view\n var view=this.findViewTarget(this.activeDiv);\n this.views[view.prop(\"id\")]=[];\n this.setBackButtonVisibility(false);\n },"
  374. },
  375. {
  376. "tags": [
  377. {
  378. "type": "api",
  379. "visibility": "private"
  380. },
  381. {
  382. "type": "title",
  383. "string": "$.afui.pushHistory()"
  384. }
  385. ],
  386. "description": {
  387. "full": "<p>PushHistory<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.pushHistory(previousPage, newPage, transition, hashExtras)<br /> </pre></div></p>",
  388. "summary": "<p>PushHistory<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.pushHistory(previousPage, newPage, transition, hashExtras)<br /> </pre></div></p>",
  389. "body": ""
  390. },
  391. "isPrivate": true,
  392. "ignore": false,
  393. "code": "pushHistory: function(previousPage, newPage, transition, hashExtras) {\n //push into local history\n\n\n //push into the browser history\n try {\n if (!this.manageHistory) return;\n window.history.pushState(newPage, newPage, startPath + \"#\" + newPage + hashExtras);\n $(window).trigger(\"hashchange\", null, {\n newUrl: startPath + \"#\" + newPage + hashExtras,\n oldUrl: startPath + previousPage\n });\n } catch (e) {}\n },"
  394. },
  395. {
  396. "tags": [
  397. {
  398. "type": "param",
  399. "types": [
  400. "string"
  401. ],
  402. "name": "newHash",
  403. "description": "New Hash value"
  404. },
  405. {
  406. "type": "title",
  407. "string": "$.afui.updateHash(newHash)"
  408. },
  409. {
  410. "type": "api",
  411. "visibility": "private"
  412. }
  413. ],
  414. "description": {
  415. "full": "<p>Updates the current window hash</p>",
  416. "summary": "<p>Updates the current window hash</p>",
  417. "body": ""
  418. },
  419. "isPrivate": true,
  420. "ignore": false,
  421. "code": "updateHash: function(newHash) {\n if (!this.manageHistory) return;\n newHash = newHash.indexOf(\"#\") === -1 ? \"#\" + newHash : newHash; //force having the # in the begginning as a standard\n previousTarget = newHash;\n\n var previousHash = window.location.hash;\n var panelName = this.getPanelId(newHash).substring(1); //remove the #\n try {\n window.history.replaceState(panelName, panelName, startPath + newHash);\n $(window).trigger(\"hashchange\", null, {\n newUrl: startPath + newHash,\n oldUrl: startPath + previousHash\n });\n } catch (e) {}\n },"
  422. },
  423. {
  424. "tags": [
  425. {
  426. "type": "api",
  427. "visibility": "private"
  428. }
  429. ],
  430. "description": {
  431. "full": "<p>gets the panel name from an hash</p>",
  432. "summary": "<p>gets the panel name from an hash</p>",
  433. "body": ""
  434. },
  435. "isPrivate": true,
  436. "ignore": false,
  437. "code": "getPanelId: function(hash) {\n var firstSlash = hash.indexOf(\"/\");\n return firstSlash === -1 ? hash : hash.substring(0, firstSlash);\n },"
  438. },
  439. {
  440. "tags": [
  441. {
  442. "type": "param",
  443. "types": [
  444. "string"
  445. ],
  446. "name": "text",
  447. "description": ""
  448. },
  449. {
  450. "type": "title",
  451. "string": "$.afui.setBackButtonText(title)"
  452. }
  453. ],
  454. "description": {
  455. "full": "<p>set the back button text<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setBackButtonText(\"about\");<br /> </pre></div></p>",
  456. "summary": "<p>set the back button text<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setBackButtonText(\"about\");<br /> </pre></div></p>",
  457. "body": ""
  458. },
  459. "isPrivate": false,
  460. "ignore": false,
  461. "code": "setBackButtonText:function(text){\n $(this.activeDiv).parent().find(\"header .backButton\").html(text);\n },"
  462. },
  463. {
  464. "tags": [
  465. {
  466. "type": "param",
  467. "types": [
  468. "string",
  469. "object"
  470. ],
  471. "name": "String",
  472. "description": "or DOM node to get the title from"
  473. },
  474. {
  475. "type": "title",
  476. "string": "$.afui.setTitle"
  477. }
  478. ],
  479. "description": {
  480. "full": "<p>Set the title of the active header from<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setTitle(\"New Title\")<br /> </pre></div></p>",
  481. "summary": "<p>Set the title of the active header from<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setTitle(\"New Title\")<br /> </pre></div></p>",
  482. "body": ""
  483. },
  484. "isPrivate": false,
  485. "ignore": false,
  486. "code": "setTitle:function(item){\n //find the header\n var title=\"\";\n if(typeof(item)===\"string\"){\n title=item;\n item=$(this.activeDiv).closest(\".view\");\n }\n else if($(item).attr(\"data-title\"))\n title=$(item).attr(\"data-title\");\n else if($(item).attr(\"title\"))\n title=$(item).attr(\"title\");\n\n if(title)\n $(item).closest(\".view\").children(\"header\").find(\"h1\").html(title);\n\n },"
  487. },
  488. {
  489. "tags": [
  490. {
  491. "type": "title",
  492. "string": "$.afui.getTitle"
  493. }
  494. ],
  495. "description": {
  496. "full": "<p>Get the title of the active header<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.getTitle()<br /> </pre></div></p>",
  497. "summary": "<p>Get the title of the active header<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.getTitle()<br /> </pre></div></p>",
  498. "body": ""
  499. },
  500. "isPrivate": false,
  501. "ignore": false,
  502. "code": "getTitle:function(){\n return $(this.activeDiv).closest(\".view\").children(\"header\").find(\"h1\").html();\n },"
  503. },
  504. {
  505. "tags": [
  506. {
  507. "type": "param",
  508. "types": [
  509. "boolean"
  510. ],
  511. "name": "Boolean",
  512. "description": "to set the visibility. true show, false hide"
  513. },
  514. {
  515. "type": "title",
  516. "string": "$.afui.setBackButtonVisbility"
  517. }
  518. ],
  519. "description": {
  520. "full": "<p>Set the visibility of the back button for the current header<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setBackButtonVisbility(true)<br /> </pre></div></p>",
  521. "summary": "<p>Set the visibility of the back button for the current header<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setBackButtonVisbility(true)<br /> </pre></div></p>",
  522. "body": ""
  523. },
  524. "isPrivate": false,
  525. "ignore": false,
  526. "code": "setBackButtonVisibility:function(what){\n var visibility=what?\"visibile\":\"hidden\";\n $(this.activeDiv).closest(\".view\").children(\"header\").find(\".backButton\").css(\"visibility\",visibility);\n },"
  527. },
  528. {
  529. "tags": [
  530. {
  531. "type": "param",
  532. "types": [
  533. "string"
  534. ],
  535. "name": "target",
  536. "description": ""
  537. },
  538. {
  539. "type": "param",
  540. "types": [
  541. "string"
  542. ],
  543. "name": "value",
  544. "description": ""
  545. },
  546. {
  547. "type": "param",
  548. "types": [
  549. "string="
  550. ],
  551. "name": "position",
  552. "description": ""
  553. },
  554. {
  555. "type": "param",
  556. "types": [
  557. "(string=",
  558. "object)"
  559. ],
  560. "name": "color",
  561. "description": "Color or CSS hash"
  562. },
  563. {
  564. "type": "title",
  565. "string": "$.afui.updateBadge(target,value,[position],[color])"
  566. }
  567. ],
  568. "description": {
  569. "full": "<p>Update a badge on the selected target. Position can be<br /> bl = bottom left<br /> tl = top left<br /> br = bottom right<br /> tr = top right (default)<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.updateBadge(\"#mydiv\",\"3\",\"bl\",\"green\");<br /> </pre></div></p>",
  570. "summary": "<p>Update a badge on the selected target. Position can be<br /> bl = bottom left<br /> tl = top left<br /> br = bottom right<br /> tr = top right (default)<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.updateBadge(\"#mydiv\",\"3\",\"bl\",\"green\");<br /> </pre></div></p>",
  571. "body": ""
  572. },
  573. "isPrivate": false,
  574. "ignore": false,
  575. "code": "updateBadge: function(target, value, position, color) {\n if (position === undefined) position = \"\";\n\n var $target = $(target);\n var badge = $target.find(\"span.af-badge\");\n\n if (badge.length === 0) {\n if ($target.css(\"position\") !== \"absolute\") $target.css(\"position\", \"relative\");\n badge = $.create(\"span\", {\n className: \"af-badge \" + position,\n html: value\n });\n $target.append(badge);\n } else badge.html(value);\n badge.removeClass(\"tl bl br tr\");\n badge.addClass(position);\n if (color === undefined)\n color = \"red\";\n if ($.isObject(color)) {\n badge.css(color);\n } else if (color) {\n badge.css(\"background\", color);\n }\n badge.data(\"ignore-pressed\", \"true\");\n\n\n },"
  576. },
  577. {
  578. "tags": [
  579. {
  580. "type": "param",
  581. "types": [
  582. "string"
  583. ],
  584. "name": "target",
  585. "description": ""
  586. },
  587. {
  588. "type": "title",
  589. "string": "$.afui.removeBadge(target)"
  590. }
  591. ],
  592. "description": {
  593. "full": "<p>Removes a badge from the selected target.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.removeBadge(\"#mydiv\");<br /> </pre></div></p>",
  594. "summary": "<p>Removes a badge from the selected target.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.removeBadge(\"#mydiv\");<br /> </pre></div></p>",
  595. "body": ""
  596. },
  597. "isPrivate": false,
  598. "ignore": false,
  599. "code": "removeBadge: function(target) {\n $(target).find(\"span.af-badge\").remove();\n },"
  600. },
  601. {
  602. "tags": [
  603. {
  604. "type": "param",
  605. "types": [
  606. "string="
  607. ],
  608. "name": "text",
  609. "description": ""
  610. },
  611. {
  612. "type": "title",
  613. "string": "$.afui.showMask(text);"
  614. }
  615. ],
  616. "description": {
  617. "full": "<p>Show the loading mask with specificed text<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.showMask()<br /> $.afui.showMask('Fetching data...')<br /> </pre></div></p>",
  618. "summary": "<p>Show the loading mask with specificed text<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.showMask()<br /> $.afui.showMask('Fetching data...')<br /> </pre></div></p>",
  619. "body": ""
  620. },
  621. "isPrivate": false,
  622. "ignore": false,
  623. "code": "showMask: function(text) {\n if (!text) text = this.loadingText || \"\";\n $.query(\"#afui_mask>h1\").html(text);\n $.query(\"#afui_mask\").show();\n },"
  624. },
  625. {
  626. "tags": [
  627. {
  628. "type": "title",
  629. "string": "$.afui.hideMask();"
  630. }
  631. ],
  632. "description": {
  633. "full": "<p>Hide the loading mask<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.hideMask();<br /> </pre></div></p>",
  634. "summary": "<p>Hide the loading mask<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.hideMask();<br /> </pre></div></p>",
  635. "body": ""
  636. },
  637. "isPrivate": false,
  638. "ignore": false,
  639. "code": "hideMask: function() {\n $.query(\"#afui_mask\").hide();\n },"
  640. },
  641. {
  642. "tags": [],
  643. "description": {
  644. "full": "<p>@api private</p>",
  645. "summary": "<p>@api private</p>",
  646. "body": ""
  647. },
  648. "ignore": false,
  649. "code": "dismissView:function(target,transition){\n transition=transition.replace(\":dismiss\",\"\");\n var theView=$(target).closest(\".view\");\n this.runTransition(transition,theView,null,true,$(target.hash).addClass(\"active\").closest(\".view\"));\n //this.activeDiv=target;\n this.activeDiv=$(\".view\").not(theView).find(\".panel.active\").get(0);\n this.updateHash(this.activeDiv.id);\n },"
  650. },
  651. {
  652. "tags": [
  653. {
  654. "type": "param",
  655. "types": [
  656. "string"
  657. ],
  658. "name": "target",
  659. "description": ""
  660. },
  661. {
  662. "type": "param",
  663. "types": [
  664. "boolean="
  665. ],
  666. "name": "newtab",
  667. "description": "(resets history)"
  668. },
  669. {
  670. "type": "param",
  671. "types": [
  672. "boolean="
  673. ],
  674. "name": "go",
  675. "description": "back (initiate the back click)"
  676. },
  677. {
  678. "type": "param",
  679. "types": [
  680. "string="
  681. ],
  682. "name": "transition",
  683. "description": ""
  684. },
  685. {
  686. "type": "param",
  687. "types": [
  688. "object="
  689. ],
  690. "name": "anchor",
  691. "description": ""
  692. },
  693. {
  694. "type": "title",
  695. "string": "$.afui.loadContent(target, newTab, goBack, transition, anchor);"
  696. },
  697. {
  698. "type": "api",
  699. "visibility": "public"
  700. }
  701. ],
  702. "description": {
  703. "full": "<p>This is called to initiate a transition or load content via ajax.<br />We can pass in a hash+id or URL.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadContent(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  704. "summary": "<p>This is called to initiate a transition or load content via ajax.<br />We can pass in a hash+id or URL.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadContent(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  705. "body": ""
  706. },
  707. "isPrivate": false,
  708. "ignore": false,
  709. "code": "loadContent: function(target, newView, back, transition, anchor) {\n\n if (this.doingTransition) {\n return;\n }\n\n if (target.length === 0) return;\n if(target.indexOf(\"#\")!==-1){\n this.loadDiv(target, newView, back, transition,anchor);\n }\n else{\n this.loadAjax(target, newView, back, transition,anchor);\n }\n },"
  710. },
  711. {
  712. "tags": [
  713. {
  714. "type": "param",
  715. "types": [
  716. "string"
  717. ],
  718. "name": "target",
  719. "description": ""
  720. },
  721. {
  722. "type": "param",
  723. "types": [
  724. "boolean="
  725. ],
  726. "name": "newview",
  727. "description": "(resets history)"
  728. },
  729. {
  730. "type": "param",
  731. "types": [
  732. "boolean="
  733. ],
  734. "name": "back",
  735. "description": "Go back (initiate the back click)"
  736. },
  737. {
  738. "type": "param",
  739. "types": [
  740. "string="
  741. ],
  742. "name": "transition",
  743. "description": ""
  744. },
  745. {
  746. "type": "title",
  747. "string": "$.afui.loadDiv(target,newTab,goBack,transition);"
  748. },
  749. {
  750. "type": "api",
  751. "visibility": "private"
  752. }
  753. ],
  754. "description": {
  755. "full": "<p>This is called internally by loadContent. Here we are loading a div instead of an Ajax link<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDiv(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  756. "summary": "<p>This is called internally by loadContent. Here we are loading a div instead of an Ajax link<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDiv(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  757. "body": ""
  758. },
  759. "isPrivate": true,
  760. "ignore": false,
  761. "code": "loadDiv: function(target, newView, back, transition,anchor) {\n // load a div\n var newDiv = target.replace(\"#\", \"\");\n\n var slashIndex = newDiv.indexOf(\"/\");\n var hashLink = \"\";\n var what=target;\n if (slashIndex !== -1) {\n // Ignore everything after the slash for loading\n hashLink = what.substr(slashIndex);\n newDiv = what.substr(0, slashIndex);\n }\n\n newDiv = $.query(\"#\" + newDiv).get(0);\n\n if (!newDiv) {\n $(document).trigger(\"missingpanel\", null, {missingTarget: target});\n this.doingTransition=false;\n return;\n }\n\n if (newDiv === this.activeDiv && !back) {\n //toggle the menu if applicable\n this.doingTransition=false;\n return;\n }\n\n this.transitionType = transition;\n\n var view=this.findViewTarget(newDiv);\n var previous=this.findPreviousPanel(newDiv,view);\n\n\n\n //check current view\n var currentView;\n if(anchor){\n currentView=this.findViewTarget(anchor);\n }\n else\n currentView=this.findViewTarget(this.activeDiv);\n\n //Check if we are dealing with the same view\n\n var isSplitViewParent=(currentView&&currentView.get(0)!==view.get(0)&&currentView.closest(\".splitview\").get(0)===view.closest(\".splitview\").get(0)&&currentView.closest(\".splitview\").length!==0);\n if(isSplitViewParent){\n newView=false;\n }\n $(newDiv).trigger(\"panelbeforeload\");\n $(previous).trigger(\"panelbeforeunload\");\n var isNewView=false;\n\n if(!isSplitViewParent&&(newView||currentView&&currentView.get(0)!==view.get(0))){\n //Need to transition the view\n newView=currentView||newView;\n this.runViewTransition(transition,view,newView,newDiv,back);\n this.updateViewHistory(view,newDiv,transition,target);\n isNewView=true;\n }\n else{\n this.runTransition(transition,previous, newDiv, back);\n this.updateViewHistory(view,newDiv,transition,target);\n }\n\n //Let's check if it has a function to run to update the data\n //Need to call after parsePanelFunctions, since new headers can override\n this.loadContentData(newDiv,view,false,isNewView);\n\n },"
  762. },
  763. {
  764. "tags": [],
  765. "description": {
  766. "full": "<p>@api private</p>",
  767. "summary": "<p>@api private</p>",
  768. "body": ""
  769. },
  770. "ignore": false,
  771. "code": "findViewTarget:function(panel){\n var view=$(panel).closest(\".view\");\n if(!view) return false;\n if(!this.views[view.prop(\"id\")])\n this.views[view.prop(\"id\")]=[];\n return view;\n },"
  772. },
  773. {
  774. "tags": [],
  775. "description": {
  776. "full": "<p>@api private</p>",
  777. "summary": "<p>@api private</p>",
  778. "body": ""
  779. },
  780. "ignore": false,
  781. "code": "findPreviousPanel:function(div,view){\n var item=$(view).find(\".panel.active\").not(div);\n if(item.length===0)\n item=$(view).find(\".panel:first-of-type\");\n return item.get(0);\n },"
  782. },
  783. {
  784. "tags": [
  785. {
  786. "type": "param",
  787. "types": [
  788. "string"
  789. ],
  790. "name": "target",
  791. "description": ""
  792. },
  793. {
  794. "type": "param",
  795. "types": [
  796. "boolean="
  797. ],
  798. "name": "newtab",
  799. "description": "(resets history)"
  800. },
  801. {
  802. "type": "param",
  803. "types": [
  804. "boolean="
  805. ],
  806. "name": "go",
  807. "description": "back (initiate the back click)"
  808. },
  809. {
  810. "type": "title",
  811. "string": "$.afui.loadContentData(target,newTab,goBack);"
  812. },
  813. {
  814. "type": "api",
  815. "visibility": "private"
  816. }
  817. ],
  818. "description": {
  819. "full": "<p>This is called internally by loadDiv. This sets up the back button in the header and scroller for the panel<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadContentData(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  820. "summary": "<p>This is called internally by loadDiv. This sets up the back button in the header and scroller for the panel<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadContentData(\"#main\",false,false,\"up\");<br /> </pre></div></p>",
  821. "body": ""
  822. },
  823. "isPrivate": true,
  824. "ignore": false,
  825. "code": "loadContentData: function(what,view,back,isNewView) {\n this.activeDiv = what;\n this.setTitle(what,view,back,isNewView);\n this.showBackButton(view,isNewView);\n this.setActiveTab(what,view);\n },"
  826. },
  827. {
  828. "tags": [],
  829. "description": {
  830. "full": "<p>Set the active tab in the footer<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setActiveTab(\"main\",currView)<br /> </pre></div><br /> @param {string|Node} id or DOM node for footer tab<br /> @param {Node} DOM node of the current view to set the footer<br /> @title $.afui.setActiveTab</p>",
  831. "summary": "<p>Set the active tab in the footer<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.setActiveTab(\"main\",currView)<br /> </pre></div><br /> @param {string|Node} id or DOM node for footer tab<br /> @param {Node} DOM node of the current view to set the footer<br /> @title $.afui.setActiveTab</p>",
  832. "body": ""
  833. },
  834. "ignore": false,
  835. "code": "setActiveTab:function(ele,view){\n var hash;\n if(typeof(ele)!==\"string\")\n hash=$(ele).prop(\"id\");\n hash=\"#\"+hash;\n view.find(\"footer\").find(\"a\").removeClass(\"pressed\").attr(\"data-ignore-pressed\",\"true\").filter(\"[href='\"+hash+\"']\").addClass(\"pressed\");\n },"
  836. },
  837. {
  838. "tags": [],
  839. "description": {
  840. "full": "<p>Show or hide the back button<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.showBackButton(view,isNewView)<br /> </pre></div><br /> @param {Node} DOM node of current view<br /> @param {boolean} Are we loading a new view (hide the back button)<br /> @title $.afui.showBackButton</p>",
  841. "summary": "<p>Show or hide the back button<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.showBackButton(view,isNewView)<br /> </pre></div><br /> @param {Node} DOM node of current view<br /> @param {boolean} Are we loading a new view (hide the back button)<br /> @title $.afui.showBackButton</p>",
  842. "body": ""
  843. },
  844. "ignore": false,
  845. "code": "showBackButton:function(view,isNewView) {\n var items=(this.views[view.prop(\"id\")].length);\n var hdr=view.children(\"header\");\n if(hdr.length===0) return;\n\n if(items>=2&&isNewView!==true){\n //Add the back button if it's not there\n if(hdr.find(\".backButton\").length===1) return;\n hdr.prepend(\"<a class='backButton back'>Back</a>\");\n }\n else {\n hdr.find(\".backButton\").remove();\n }\n },"
  846. },
  847. {
  848. "tags": [
  849. {
  850. "type": "param",
  851. "types": [
  852. "string"
  853. ],
  854. "name": "target",
  855. "description": ""
  856. },
  857. {
  858. "type": "param",
  859. "types": [
  860. "boolean="
  861. ],
  862. "name": "newtab",
  863. "description": "(resets history)"
  864. },
  865. {
  866. "type": "param",
  867. "types": [
  868. "boolean="
  869. ],
  870. "name": "go",
  871. "description": "back (initiate the back click)"
  872. },
  873. {
  874. "type": "param",
  875. "types": [
  876. "string="
  877. ],
  878. "name": "transition",
  879. "description": ""
  880. },
  881. {
  882. "type": "param",
  883. "types": [
  884. "object="
  885. ],
  886. "name": "anchor",
  887. "description": ""
  888. },
  889. {
  890. "type": "title",
  891. "string": "$.afui.loadDiv(target,newTab,goBack,transition);"
  892. },
  893. {
  894. "type": "api",
  895. "visibility": "private"
  896. }
  897. ],
  898. "description": {
  899. "full": "<p>This is called internally by loadContent. Here we are using Ajax to fetch the data<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDiv(\"page.html\",false,false,\"up\");<br /> </pre></div></p>",
  900. "summary": "<p>This is called internally by loadContent. Here we are using Ajax to fetch the data<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.loadDiv(\"page.html\",false,false,\"up\");<br /> </pre></div></p>",
  901. "body": ""
  902. },
  903. "isPrivate": true,
  904. "ignore": false,
  905. "code": "loadAjax: function(target, newTab, back, transition, anchor) {\n var that=this;\n var crc=crc32(target);\n var found=$(\".panel[data-crc='\"+crc+\"']\");\n var forceRefresh=anchor.getAttribute(\"data-refresh\");\n\n if(found.length>0){\n\n if(forceRefresh){\n that.showLoading&&that.showMask(\"Loading Content\");\n $.ajax(target).then(function(res){\n found.html(res);\n that.showLoading&&that.hideMask();\n return that.loadContent(\"#\"+found.prop(\"id\"),newTab,back,transition,anchor);\n });\n }\n else\n return that.loadContent(\"#\"+found.prop(\"id\"),newTab,back,transition,anchor);\n }\n that.showLoading&&that.showMask(\"Loading Content\");\n $.ajax(target).then(function(res){\n var $res=$.create(\"div\",{html:res});\n if(!$res.hasClass(\".panel\")){\n $res=$res.attr(\"data-title\",(target));\n $res.prop(\"id\",crc);\n $res.addClass(\"panel\");\n }\n else {\n $res=$res.find(\".panel\");\n }\n $(that.activeDiv).closest(\".pages\").append($res);\n $res.attr(\"data-crc\",crc);\n that.showLoading&&that.hideMask();\n that.loadContent(\"#\"+$res.prop(\"id\"),newTab,back,transition,anchor);\n }).fail(function(res){\n that.showLoading&&that.hideMask();\n console.log(\"Error with ajax request\",res);\n });\n\n },"
  906. },
  907. {
  908. "tags": [
  909. {
  910. "type": "api",
  911. "visibility": "private"
  912. },
  913. {
  914. "type": "title",
  915. "string": "$.afui.runTransition(transition,oldDiv,currDiv,back)"
  916. }
  917. ],
  918. "description": {
  919. "full": "<p>This executes the transition for the panel<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.runTransition(transition,oldDiv,currDiv,back)<br /> </pre></div></p>",
  920. "summary": "<p>This executes the transition for the panel<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.runTransition(transition,oldDiv,currDiv,back)<br /> </pre></div></p>",
  921. "body": ""
  922. },
  923. "isPrivate": true,
  924. "ignore": false,
  925. "code": "runTransition: function(transition,previous,target, back,noTrans) {\n\n if(!transition)\n transition=\"slide\";\n\n if(transition.indexOf(\":back\")!==-1){\n transition=transition.replace(\":back\",\"\");\n back=true;\n }\n\n var that=this;\n var show=back?previous:target;\n var hide=back?target:previous;\n var doPush=false;\n if(transition.indexOf(\"-reveal\")!==-1){\n transition=transition.replace(\"-reveal\",\"\");\n doPush=true;\n }\n\n\n $(show).css(\"zIndex\",\"10\");\n $(hide).css(\"zIndex\",\"1\");\n $(noTrans).css(\"zIndex\",\"1\").addClass(\"active\");\n\n var from=$(hide).animation().remove(transition+\"-in\");\n if(!doPush&&from){\n if(back)\n from.reverse();\n from.end(function(){\n if(!back){\n this.classList.remove(\"active\");\n $(this).trigger(\"panelunload\");\n }\n else{\n\n this.classList.add(\"active\");\n $(this).trigger(\"panelload\");\n }\n that.doingTransition=false;\n }).run(transition+\"-out\");\n }\n else {\n if(!back){\n $(hide).trigger(\"panelunload\");\n }\n else{\n $(hide).trigger(\"panelload\");\n $(hide).addClass(\"activeDiv\");\n\n }\n }\n\n var to=$(show).animation().remove(transition+\"-out\");\n if(back)\n to.reverse();\n to.end(function(){\n that.doingTransition=false;\n if(!back){\n\n this.classList.add(\"active\");\n $(this).trigger(\"panelload\");\n $(noTrans).trigger(\"panelload\");\n }\n else{\n if(noTrans){\n $(noTrans).css(\"zIndex\",\"10\");\n\n }\n\n this.classList.remove(\"active\");\n $(this).trigger(\"panelunload\");\n }\n }).run(transition+\"-in\");\n },"
  926. },
  927. {
  928. "tags": [
  929. {
  930. "type": "api",
  931. "visibility": "private"
  932. },
  933. {
  934. "type": "title",
  935. "string": "$.afui.runViewTransition(transition,view, active, newDiv,back)"
  936. }
  937. ],
  938. "description": {
  939. "full": "<p>This executes the transition of a view<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.runViewTransition(transition,view, active, newDiv,back)<br /> </pre></div></p>",
  940. "summary": "<p>This executes the transition of a view<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.runViewTransition(transition,view, active, newDiv,back)<br /> </pre></div></p>",
  941. "body": ""
  942. },
  943. "isPrivate": true,
  944. "ignore": false,
  945. "code": "runViewTransition:function(transition,view,active,newDiv,back){\n //find the active\n\n view.addClass(\"active\");\n //view.find(\".panel\").removeClass(\"active\");\n $(newDiv).addClass(\"active\");\n\n if(transition===\"none\"){\n this.doingTransition=false;\n\n setTimeout(function(){\n active.removeClass(\"active\");\n },50);\n\n return;\n }\n this.runTransition(transition,active,view,back,newDiv);\n },"
  946. },
  947. {
  948. "tags": [
  949. {
  950. "type": "param",
  951. "types": [
  952. "Node"
  953. ],
  954. "name": "DOM",
  955. "description": "node for view"
  956. },
  957. {
  958. "type": "param",
  959. "types": [
  960. "Node"
  961. ],
  962. "name": "DOM",
  963. "description": "node for div adding to the history"
  964. },
  965. {
  966. "type": "param",
  967. "types": [
  968. "string"
  969. ],
  970. "name": "string",
  971. "description": "for the transition"
  972. },
  973. {
  974. "type": "param",
  975. "types": [
  976. "string"
  977. ],
  978. "name": "string",
  979. "description": "of the hash for the div"
  980. },
  981. {
  982. "type": "api",
  983. "visibility": "private"
  984. },
  985. {
  986. "type": "title",
  987. "string": "$.afui.updateViewHistory(view, div, transition, target)"
  988. }
  989. ],
  990. "description": {
  991. "full": "<p>This updates the history of the view cache<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.updateViewHistory(view, div, transition, target)<br /> </pre></div></p>",
  992. "summary": "<p>This updates the history of the view cache<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.updateViewHistory(view, div, transition, target)<br /> </pre></div></p>",
  993. "body": ""
  994. },
  995. "isPrivate": true,
  996. "ignore": false,
  997. "code": "updateViewHistory:function(view,div,transition,target){\n var ref=this.views[view.prop(\"id\")];\n if(!ref)\n ref=this.views[view.prop(\"id\")]=[];\n if(ref.length>=1&&ref[ref.length-1].target===div) return;\n //pushHistory: function(previousPage, newPage, transition, hashExtras) {)\n this.pushHistory(div.id,div.id,transition,target.replace(div.id,\"\").replace(\"#\",\"\"));\n this.views[view.prop(\"id\")].push({\n target:div,\n transition:transition\n });\n },"
  998. },
  999. {
  1000. "tags": [
  1001. {
  1002. "type": "title",
  1003. "string": "$.afui.launch();"
  1004. }
  1005. ],
  1006. "description": {
  1007. "full": "<p>This is callled when you want to launch afui. If autoLaunch is set to true, it gets called on DOMContentLoaded.<br />If autoLaunch is set to false, you can manually invoke it.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.autoLaunch=false;<br /> $.afui.launch();<br /> </pre></div></p>",
  1008. "summary": "<p>This is callled when you want to launch afui. If autoLaunch is set to true, it gets called on DOMContentLoaded.<br />If autoLaunch is set to false, you can manually invoke it.<br /> <div class=\"highlight\"><pre lang=\"\"> $.afui.autoLaunch=false;<br /> $.afui.launch();<br /> </pre></div></p>",
  1009. "body": ""
  1010. },
  1011. "isPrivate": false,
  1012. "ignore": false,
  1013. "code": "launch: function() {\n if (this.hasLaunched === false || this.launchCompleted) {\n this.hasLaunched = true;\n return;\n }\n if(this.isLaunching)\n return true;\n this.isLaunching=true;\n this.blockPageBounce();\n var that = this;\n\n var maskDiv = $.create(\"div\", {\n id: \"afui_mask\",\n className: \"ui-loader\",\n html: \"<span class='ui-icon ui-icon-loading spin'></span><h1>Loading Content</h1>\"\n }).css({\n \"z-index\": 20000,\n display: \"none\"\n });\n document.body.appendChild(maskDiv.get(0));\n //setup modalDiv\n //get first div, defer\n\n var first=$(\".view[data-default='true']\");\n if(first.length===0)\n first=$(\".view\").eq(0);\n else\n throw (\"You need to create a view\");\n\n first.addClass(\"active\");\n //history\n this.views[first.prop(\"id\")]=[];\n var firsthash=window.location.hash;\n var firstPanel=first.find(\".panel[data-selected='true']\").length===0?first.find(\".panel\").eq(0):first.find(\".panel[data-selected='true']\");\n firstPanel.addClass(\"active\");\n this.activeDiv=firstPanel.get(0);\n this.views[first.prop(\"id\")].push({\n target:firstPanel.get(0),\n transition:this.transitionType\n });\n this.defaultPanel=firstPanel.get(0);\n this.loadContentData(firstPanel.get(0),first,false,true);\n this.updateHash(firstPanel.get(0).id);\n\n if(this.loadDefaultHash){\n //delay launch so events can be registered/handled\n\n setTimeout(function(){\n this.loadContent(firsthash,false,0,\"none\");\n\n }.bind(this));\n }\n this.enableTabBar();\n\n $(document).on(\"click\", \"a\", function(e) {\n if(that.useInternalRouting)\n checkAnchorClick(e, e.currentTarget);\n });"
  1014. },
  1015. {
  1016. "tags": [],
  1017. "description": {
  1018. "full": "<p>This is our data directive processor</p>",
  1019. "summary": "<p>This is our data directive processor</p>",
  1020. "body": ""
  1021. },
  1022. "ignore": false,
  1023. "code": "$(document).on(\"click\",function(e){\n\n var len=clickHandlers.length;\n var $el=$(e.target);\n for(var i=0;i<len;i++){\n var handler=clickHandlers[i];\n var checker=$el.closest(handler.sel);\n if(checker.length>0)\n handler.cb.call(that,checker.get(0),e);\n }\n });\n\n $(document).on(\"click\", \".backButton, [data-back]\", that.goBack.bind(that));\n //Check for includes\n\n var items=$(\"[data-include]\");\n if(items.length===0){\n this.launchCompleted=true;\n $(document).trigger(\"afui:ready\");\n }\n else{\n var deferred=[];\n items.each(function(){\n var url=this.getAttribute(\"data-include\");\n var self=$(this);\n deferred.push($.get(url,function(res){\n self.append(res);\n }));\n });\n $.when.apply($,deferred).then(function(){\n this.launchCompleted=true;\n $(document).trigger(\"afui:ready\");\n }).fail(function(){\n this.launchCompleted=true;\n $(document).trigger(\"afui:ready\");\n });\n }\n\n $(document).on(\"click\",\"footer a:not(.button)\",function(e){\n var $item=$(e.target);\n $item.parent().find(\"a:not(.button)\").attr(\"data-ignore-pressed\",\"true\").removeClass(\"pressed\");\n $item.addClass(\"pressed\");\n });\n }"
  1024. },
  1025. {
  1026. "tags": [
  1027. {
  1028. "type": "api",
  1029. "visibility": "private"
  1030. }
  1031. ],
  1032. "description": {
  1033. "full": "<p>END</p>",
  1034. "summary": "<p>END</p>",
  1035. "body": ""
  1036. },
  1037. "isPrivate": true,
  1038. "ignore": false,
  1039. "code": "};\n\n\n //lookup for a clicked anchor recursively and fire UI own actions when applicable\n var checkAnchorClick = function(e, theTarget) {\n theTarget=theTarget||e.currentTarget;\n if (theTarget === document) {\n return;\n }\n\n //this technique fails when considerable content exists inside anchor, should be recursive ?\n if (theTarget.tagName.toLowerCase() !== \"a\" && theTarget.parentNode) return checkAnchorClick(e, theTarget.parentNode); //let's try the parent (recursive)\n //anchors\n if (theTarget.tagName !== \"undefined\" && theTarget.tagName.toLowerCase() === \"a\") {\n if (theTarget.href.toLowerCase().indexOf(\"javascript:\") !== -1 || theTarget.getAttribute(\"data-ignore\")) {\n return;\n }"
  1040. },
  1041. {
  1042. "tags": [],
  1043. "description": {
  1044. "full": "<p>IE 10 fixes</p>",
  1045. "summary": "<p>IE 10 fixes</p>",
  1046. "body": ""
  1047. },
  1048. "ignore": false,
  1049. "code": "var href = theTarget.href,\n prefix = location.protocol + \"//\" + location.hostname + \":\" + location.port + location.pathname;\n if (href.indexOf(prefix) === 0) {\n href = href.substring(prefix.length);\n }\n //empty links\n if (href === \"#\" || (href.indexOf(\"#\") === href.length - 1) || (href.length === 0 && theTarget.hash.length === 0)) return e.preventDefault();\n\n //internal links\n //http urls\n var urlRegex=/^((http|https|file):\\/\\/)/;\n //only call prevent default on http/fileurls. If it's a protocol handler, do not call prevent default.\n //It will fall through to the ajax call and fail\n if(theTarget.href.indexOf(\":\") !== -1 &&urlRegex.test(theTarget.href))\n e.preventDefault();\n\n var mytransition = theTarget.getAttribute(\"data-transition\");\n if(!mytransition&&$(theTarget).closest(\"footer\").length>0)\n mytransition=\"none\";\n\n if(mytransition&&mytransition.indexOf(\":dismiss\")!==-1){\n return $.afui.dismissView(theTarget,mytransition);\n }\n href = theTarget.hash.length > 0 ? theTarget.hash : href;\n $.afui.loadContent(href, false, 0, mytransition, theTarget);\n return;\n }\n };\n\n var table = \"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D\";",
  1050. "ctx": {
  1051. "type": "declaration",
  1052. "name": "href",
  1053. "value": "theTarget.href,",
  1054. "string": "href"
  1055. }
  1056. },
  1057. {
  1058. "tags": [],
  1059. "description": {
  1060. "full": "<p>Number</p>",
  1061. "summary": "<p>Number</p>",
  1062. "body": ""
  1063. },
  1064. "ignore": false,
  1065. "code": "var crc32 = function(",
  1066. "ctx": {
  1067. "type": "function",
  1068. "name": "crc32",
  1069. "string": "crc32()"
  1070. }
  1071. },
  1072. {
  1073. "tags": [],
  1074. "description": {
  1075. "full": "<p>String</p>",
  1076. "summary": "<p>String</p>",
  1077. "body": ""
  1078. },
  1079. "ignore": false,
  1080. "code": "str,"
  1081. },
  1082. {
  1083. "tags": [],
  1084. "description": {
  1085. "full": "<p>Number</p>",
  1086. "summary": "<p>Number</p>",
  1087. "body": ""
  1088. },
  1089. "ignore": false,
  1090. "code": "crc) {\n if (crc === undefined) crc = 0;\n var n = 0; //a number between 0 and 255\n var x = 0; //an hex number\n crc = crc ^ (-1);\n for (var i = 0, iTop = str.length; i < iTop; i++) {\n n = (crc ^ str.charCodeAt(i)) & 0xFF;\n x = \"0x\" + table.substr(n * 9, 8);\n crc = (crc >>> 8) ^ x;\n }\n return (crc ^ (-1))>>>0;\n };\n\n $.afui = new AFUi();\n $.afui.init=true;\n\n $(window).trigger(\"afui:preinit\");\n $(window).trigger(\"afui:init\");\n})(jQuery);"
  1091. }
  1092. ]