<!-- jQuery Mobile CSS bits -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
+<!-- <link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />-->
<!-- Custom css -->
<link rel="stylesheet" href="css/custom.css" />
<script src="js/mobileinit.js"></script>
<script src="js/ios-orientationchange-fix.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
- <script src="js/application.js"></script>
+<!-- <script src="js/jquery.mobile-1.1.0.min.js"></script>-->
+
+ <!-- app -->
+ <script src="js/app/app.js"></script>
+ <script src="js/app/Config.js"></script>
+ <script src="js/app/Controller.js"></script>
+ <script src="js/app/TagList.js"></script>
+ <!-- /app -->
+
<!-- Add a Bookmark Bubble for iDevices, and adds a cookie if already shown -->
<script type="text/javascript" src="js/bookmark_bubble.js"></script>
<script type="text/javascript" src="js/example.js"></script>
<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script>
</head>
<body>
- <div data-role="page">
-
- <div data-role="header">
- <h1>jQuery Mobile Boilerplate 1.1</h1>
- </div>
+ <!-- Categories -->
+ <div data-role="page" id="page-categories">
+ <div data-role="content" style="padding: 15px">
+ <ul data-role="listview" data-divider-theme="b" data-inset="false" id="list-categories">
+ <li data-role="list-divider" role="heading">
+ Divider
+ </li>
+ <li data-theme="c">
+ <a href="#" data-transition="slide">
+ Button
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
- <div data-role="content">
-
- <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
- <li data-role="list-divider">Snippet Pages</li>
- <li><a href="snippets/buttons.html">Buttons</a></li>
- <li><a href="snippets/grids.html">Grids</a></li>
- <li><a href="snippets/collapsibles.html">Collapsible Boxes</a></li>
- <li><a href="snippets/collapsible-sets.html">Collapsible Sets</a></li>
- <li><a href="snippets/forms.html">Form Elements</a></li>
- <li><a href="snippets/lists.html">List Views</a></li>
- </ul>
+ <!-- Tag List -->
+ <div data-role="page" id="page-tags">
+ <div data-role="content" style="padding: 15px">
+ <ul data-role="listview" data-divider-theme="b" data-inset="false" id="list-tags">
+ <li data-role="list-divider" role="heading">
+ Divider
+ </li>
+ <li data-theme="c">
+ <a href="#" data-transition="slide">
+ Button
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
- </div>
-
- <div data-role="footer" data-theme="c">
- <p>© 2012 - jQuery Mobile Boilerplate</p>
- </div>
-
- </div>
</body>
-</html>
\ No newline at end of file
+</html>
--- /dev/null
+(function() {
+
+ Readings.TagList = (function() {
+
+ TagList.prototype.defaults = null;
+
+ function TagList(list, category, options) {
+ this.category = category;
+ this.options = $.extend(this.defaults, options);
+ }
+
+ TagList.prototype.load = function() {
+ return $.ajax({
+ url: Readings.config.get('wlurl') + ("/api/" + this.category),
+ success: function() {
+ return true;
+ }
+ });
+ };
+
+ return TagList;
+
+ })();
+
+}).call(this);
--- /dev/null
+
+class Readings.Config
+ constructor: (@opts) ->
+
+ get: (name) ->
+ @opts[name]
--- /dev/null
+(function() {
+
+ Readings.Config = (function() {
+
+ function Config(opts) {
+ this.opts = opts;
+ }
+
+ Config.prototype.get = function(name) {
+ return this.opts[name];
+ };
+
+ return Config;
+
+ })();
+
+}).call(this);
--- /dev/null
+# main controller
+
+Readings.category_list = (list) ->
+ list.empty()
+ for cat, labelname of Readings.config.get 'categories'
+ list.append "<li><a href=\"#page-tags?category=#{cat}\">#{labelname}</a></li>"
+ list.listview 'refresh'
\ No newline at end of file
--- /dev/null
+(function() {
+
+ Readings.category_list = function(list) {
+ var cat, labelname, _ref;
+ list.empty();
+ _ref = Readings.config.get('categories');
+ for (cat in _ref) {
+ labelname = _ref[cat];
+ list.append("<li><a href=\"#page-tags?category=" + cat + "\">" + labelname + "</a></li>");
+ }
+ return list.listview('refresh');
+ };
+
+}).call(this);
--- /dev/null
+
+class Readings.Tag
+ constructor: (record) ->
+ @href = record.href
+ @name = record.name
+ #@url = record.url
+ @slug = $.grep(@href.split('/'), (e) -> e != "")
+
+
+ render: ->
+ "<li"
+
+$.fn.Readings.TagList = (category) ->
+ this.each ->
+ list = $(this)
+ $.ajax
+ url: Readings.config.get('wlurl') + "/api/#{@category}"
+ contentType: "json"
+ success: (data) ->
+ console.log(data)
+ tags = $.map data, (rec) -> new Readings.Tag(rec)
+ list.empty()
+ for t in tags
+ list.append t.render()
+
+
+class Readings.TagList
+ defaults: null
+ constructor: (list, options) ->
+ @options = $.extend @defaults, options
+ if not list.tag_list?
+ list.tag_list = this
+ list.tag_list
+
+ load: ->
+ $.ajax
+ url: Readings.config.get('wlurl') + "/api/#{@category}"
+ success: ->
+ true
--- /dev/null
+(function() {
+
+ Readings.Tag = (function() {
+
+ function Tag(record) {
+ this.href = record.href;
+ this.name = record.name;
+ this.slug = $.grep(this.href.split('/'), function(e) {
+ return e !== "";
+ });
+ }
+
+ Tag.prototype.render = function() {
+ return "<li";
+ };
+
+ return Tag;
+
+ })();
+
+ $.fn.Readings.TagList = function(category) {
+ return this.each(function() {
+ var list;
+ list = $(this);
+ return $.ajax({
+ url: Readings.config.get('wlurl') + ("/api/" + this.category),
+ contentType: "json",
+ success: function(data) {
+ var t, tags, _i, _len, _results;
+ console.log(data);
+ tags = $.map(data, function(rec) {
+ return new Readings.Tag(rec);
+ });
+ list.empty();
+ _results = [];
+ for (_i = 0, _len = tags.length; _i < _len; _i++) {
+ t = tags[_i];
+ _results.push(list.append(t.render()));
+ }
+ return _results;
+ }
+ });
+ });
+ };
+
+ Readings.TagList = (function() {
+
+ TagList.prototype.defaults = null;
+
+ function TagList(list, options) {
+ this.options = $.extend(this.defaults, options);
+ if (!(list.tag_list != null)) list.tag_list = this;
+ list.tag_list;
+ }
+
+ TagList.prototype.load = function() {
+ return $.ajax({
+ url: Readings.config.get('wlurl') + ("/api/" + this.category),
+ success: function() {
+ return true;
+ }
+ });
+ };
+
+ return TagList;
+
+ })();
+
+}).call(this);
--- /dev/null
+
+window.Readings = {}
+$.fn.Readings = {}
+
+
+$(document).on 'pageinit', (ev) ->
+ Readings.config = new Readings.Config
+ wlurl: 'http://readings.local'
+ categories:
+ 'authors': 'autor',
+ 'epochs': 'epoka',
+ 'genres': 'gatunek',
+ 'kinds': 'rodzaj',
+ 'themes': 'motyw'
+
+ Readings.category_list $('#list-categories')
\ No newline at end of file
--- /dev/null
+(function() {
+
+ window.Readings = {};
+
+ $.fn.Readings = {};
+
+ $(document).on('pageinit', function(ev) {
+ Readings.config = new Readings.Config({
+ wlurl: 'http://readings.local',
+ categories: {
+ 'authors': 'autor',
+ 'epochs': 'epoka',
+ 'genres': 'gatunek',
+ 'kinds': 'rodzaj',
+ 'themes': 'motyw'
+ }
+ });
+ return Readings.category_list($('#list-categories'));
+ });
+
+}).call(this);