include request info on transport exception, sanity check tag parser results
[ajatus.git] / js / ajatus.development.js
blob86ee56d534b2fbe07ac507df5c7a2a0b9dbc5c34
1 /*
2 * This file is part of
4 * Ajatus - Distributed CRM
5 * @requires jQuery v1.2.1
6 *
7 * Copyright (c) 2007 Jerry Jalava <jerry.jalava@gmail.com>
8 * Copyright (c) 2007 Nemein Oy <http://nemein.com>
9 * Website: http://ajatus.info
10 * Licensed under the GPL license
11 * http://www.gnu.org/licenses/gpl.html
15 (function($){
16 $.ajatus = $.ajatus || {};
18 $.ajatus.development = {
20 // $.extend($.ajatus.development, {
21 // });
23 $.ajatus.development.view = {
24 title: 'Development',
25 icon: 'development.png',
26 options: {},
27 application_view: true,
28 history_support: true,
29 has_additional_views: true,
30 icongrid: null,
32 generate_additional_views: function(add, icongrid) {
33 var views = {};
35 if (typeof add == 'undefined') {
36 var add = false;
38 if (typeof icongrid == 'undefined') {
39 var icongrid = true;
42 $.each($.ajatus.development.subview.available, function(i, name){
43 var view = $.ajatus.development.subview[name];
45 var vhash = '#view.development.'+name;
46 if (typeof view.view_hash != 'undefined') {
47 vhash = view.view_hash;
50 var view_data = {
51 title: view.title,
52 view_hash: vhash
55 if (typeof view.icon != 'undefined') {
56 view_data.icon = view.icon;
59 views[name] = view_data;
60 });
62 if (add) {
63 var app_tab_holder = $('#tabs-application ul');
64 if (icongrid) {
65 $.ajatus.development.view.icongrid = new $.ajatus.renderer.icongrid({
66 title: 'Development tools',
67 width: 50,
68 attach: false
69 });
72 app_tab_holder.html('');
73 $.each(views, function(name, data){
74 var tab = $('<li><a href="'+data.view_hash+'"><span>'+$.ajatus.i10n.get(data.title)+'</span></a></li>');
75 if (typeof data.icon != 'undefined') {
76 tab = $('<li class="iconified"><a href="'+data.view_hash+'" title="'+$.ajatus.i10n.get(data.title)+'"><img src="'+ $.ajatus.preferences.client.theme_icons_url + data.icon + '" /></a></li>');
78 if (icongrid) {
79 $.ajatus.development.view.icongrid.add_item({
80 title: $.ajatus.i10n.get(data.title),
81 icon: data.icon,
82 hash: data.view_hash
83 });
86 tab.appendTo(app_tab_holder);
87 });
90 return views;
93 render: function(view) {
94 if ( typeof view == 'undefined'
95 || view == 'frontpage')
97 view = 'frontpage';
98 $.ajatus.development.view.generate_additional_views(true);
99 } else {
100 $.ajatus.development.view.generate_additional_views(false);
103 if ( view != 'frontpage'
104 && typeof $.ajatus.development.subview[view] != 'undefined')
106 return $.ajatus.development.subview[view].render();
109 $.ajatus.application_content_area.html('');
111 var body_class = 'development';
112 var view_hash = '#view.development';
113 var view_title = $.ajatus.i10n.get('Development');
115 $.ajatus.layout.title.update({
116 view: view_title
117 });
118 $.ajatus.layout.body.set_class(body_class);
119 $.ajatus.views.on_change(view_hash, true);
121 $.ajatus.toolbar.init();
123 if ($.ajatus.development.view.icongrid != null) {
124 $.ajatus.development.view.icongrid.render();
127 // if (view == 'frontpage') {
128 // $.ajatus.views.system.archive.get_items();
129 // } else {
130 // $.ajatus.views.system.archive.get_view_items(view);
131 // }
135 $.ajatus.development.subview = {
136 base_class: 'development',
137 available: [
138 'generator', 'templating'
142 $.ajatus.development.subview.generator = {
143 title: 'Object generator',
144 view_hash: '#view.development.generator',
145 icon: 'generator.png',
147 render: function() {
148 $.ajatus.application_content_area.html('');
150 var body_class = $.ajatus.development.subview.base_class + ' generator';
151 var view_title = $.ajatus.i10n.get('Development') + ' - ' + $.ajatus.i10n.get($.ajatus.development.subview.generator.title);
153 $.ajatus.layout.title.update({
154 view: view_title
155 });
156 $.ajatus.layout.body.set_class(body_class);
157 $.ajatus.views.on_change($.ajatus.development.subview.generator.view_hash, true);
159 $.ajatus.toolbar.init();
165 $.ajatus.development.subview.templating = {
166 title: 'Templating',
167 view_hash: '#view.development.templating',
168 //icon: 'templating.png',
170 render: function() {
171 $.ajatus.application_content_area.html('');
173 var body_class = $.ajatus.development.subview.base_class + ' templating';
174 var view_title = $.ajatus.i10n.get('Development') + ' - ' + $.ajatus.i10n.get($.ajatus.development.subview.templating.title);
176 $.ajatus.layout.title.update({
177 view: view_title
178 });
179 $.ajatus.layout.body.set_class(body_class);
180 $.ajatus.views.on_change($.ajatus.development.subview.templating.view_hash, true);
182 $.ajatus.toolbar.init();
184 var type = $.ajatus.preferences.client.content_types['note'];
186 var renderer = new $.ajatus.renderer.list_tpl(
187 $.ajatus.application_content_area,
188 type,
190 id: type.name + '_list_holder',
191 pool: {
192 enabled: true,
193 settings: {
194 type: 'scroll',
195 use_db: true,
196 db: {
197 'static': type.name+'/list'
204 var doc_count = $.jqCouch.connection('view').get($.ajatus.preferences.client.content_database, type.name+'/list', {
205 count: 0
206 }).total_rows;
208 var on_success = function(data) {
209 $.each(data.rows, function(i,doc){
210 var doc = new $.ajatus.document(doc);
211 renderer.add_item(doc);
214 renderer.add_total_count(doc_count);
216 return data;
219 $.jqCouch.connection('view', on_success).get($.ajatus.preferences.client.content_database, type.name+'/list', {
220 count: 40,
221 descending: true
224 renderer.render();
228 })(jQuery);