4 * Ajatus - Distributed CRM
5 * @requires jQuery v1.2.1
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
16 $.ajatus = $.ajatus || {};
18 $.ajatus.development = {
20 // $.extend($.ajatus.development, {
23 $.ajatus.development.view = {
25 icon: 'development.png',
27 application_view: true,
28 history_support: true,
29 has_additional_views: true,
32 generate_additional_views: function(add, icongrid) {
35 if (typeof add == 'undefined') {
38 if (typeof icongrid == 'undefined') {
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;
55 if (typeof view.icon != 'undefined') {
56 view_data.icon = view.icon;
59 views[name] = view_data;
63 var app_tab_holder = $('#tabs-application ul');
65 $.ajatus.development.view.icongrid = new $.ajatus.renderer.icongrid({
66 title: 'Development tools',
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>');
79 $.ajatus.development.view.icongrid.add_item({
80 title: $.ajatus.i10n.get(data.title),
86 tab.appendTo(app_tab_holder);
93 render: function(view) {
94 if ( typeof view == 'undefined'
95 || view == 'frontpage')
98 $.ajatus.development.view.generate_additional_views(true);
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({
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();
130 // $.ajatus.views.system.archive.get_view_items(view);
135 $.ajatus.development.subview = {
136 base_class: 'development',
138 'generator', 'templating'
142 $.ajatus.development.subview.generator = {
143 title: 'Object generator',
144 view_hash: '#view.development.generator',
145 icon: 'generator.png',
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({
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 = {
167 view_hash: '#view.development.templating',
168 //icon: 'templating.png',
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({
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,
190 id: type.name + '_list_holder',
197 'static': type.name+'/list'
204 var doc_count = $.jqCouch.connection('view').get($.ajatus.preferences.client.content_database, type.name+'/list', {
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);
219 $.jqCouch.connection('view', on_success).get($.ajatus.preferences.client.content_database, type.name+'/list', {