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
17 $.ajatus
.document = function(doc
, check_metadata
, check_schema
) {
18 if (typeof check_metadata
== 'undefined') {
19 var check_metadata
= true;
21 if (typeof check_schema
== 'undefined') {
22 var check_schema
= false;
28 $.each(doc
, function(i
,n
){
29 if ( (i
== '_id' && n
!= '')
30 || i
== 'id' && n
!= '') {
31 self
.ready_doc
['_id'] = n
;
32 } else if (i
== '_rev' && n
!= '') {
33 self
.ready_doc
[i
] = n
;
34 } else if (i
== 'key' && n
!= '') {
35 self
.ready_doc
[i
] = n
;
36 } else if (i
== 'value' && n
!= '') {
37 self
.ready_doc
[i
] = n
;
41 if (typeof this.ready_doc
['value'] == 'undefined') {
42 $.ajatus
.debug("Error: Document didn't have value field defined!", "ajatus.document");
43 return this.ready_doc
;
47 if (! this.ready_doc
.value
.metadata
) {
50 this.check_metadata();
54 if (! $.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
]) {
55 this.ready_doc
.value
._type
= 'note';
62 this.prepare_doc_title();
64 return this.ready_doc
;
66 $.extend($.ajatus
.document
.prototype, {
67 check_schema: function() {
69 var type
= $.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
];
71 var new_schema_parts
= {};
72 $.each(type
.original_schema
, function(k
,si
){
73 // console.log("self.ready_doc.value.metadata["+k+"]:"+self.ready_doc.value.metadata[k])
74 if (typeof(self
.ready_doc
.value
[k
]) == 'undefined') {
76 if (typeof si
['def_val'] != 'undefined') {
77 def_val
= si
['def_val'];
79 new_schema_parts
[k
] = {
85 def_val
= self
.ready_doc
.value
[k
].val
|| '';
86 if (typeof si
['def_val'] != 'undefined') {
87 def_val
= si
['def_val'];
89 self
.ready_doc
.value
[k
] = $.extend({
92 }, self
.ready_doc
.value
[k
]);
97 // console.log("Found schema parts that need to be updated:");
98 // console.log(new_schema_parts);
99 self
._fix_doc_schema(new_schema_parts
);
102 _fix_doc_schema: function(new_parts
) {
105 doc
= new $.ajatus
.document
.loader(_self
.ready_doc
._id
, _self
.ready_doc
._rev
, false, false);
106 doc
.value
= $.extend(doc
.value
, new_parts
);
108 var db_path
= $.ajatus
.preferences
.client
.content_database
;
109 if (doc
.value
._type
== 'tag') {
110 db_path
= $.ajatus
.preferences
.client
.tags_database
;
113 $.jqCouch
.connection('doc').save(db_path
, doc
);
114 _self
.ready_doc
= new $.ajatus
.document(doc
);
116 add_metadata: function() {
118 this.ready_doc
.value
.metadata
= {};
119 $.each($.ajatus
.document
.metadata
, function(k
,m
){
120 self
.ready_doc
.value
.metadata
[k
] = {
126 check_metadata: function() {
127 // console.log("check metadata");
130 var new_md_parts
= {};
131 $.each($.ajatus
.document
.metadata
, function(k
,m
){
132 // console.log("self.ready_doc.value.metadata["+k+"]:"+self.ready_doc.value.metadata[k])
133 if (typeof(self
.ready_doc
.value
.metadata
[k
]) == 'undefined') {
135 if (typeof m
['def_val'] != 'undefined') {
136 def_val
= m
['def_val'];
144 def_val
= self
.ready_doc
.value
.metadata
[k
].val
|| '';
145 if (typeof m
['def_val'] != 'undefined') {
146 def_val
= m
['def_val'];
148 self
.ready_doc
.value
.metadata
[k
] = $.extend({
151 }, self
.ready_doc
.value
.metadata
[k
]);
156 self
._fix_metadata(new_md_parts
);
159 _fix_metadata: function(new_metadata
) {
162 // console.log("_fix_metadata for: "+_self.ready_doc._id);
163 // console.log(new_metadata);
165 doc
= new $.ajatus
.document
.loader(_self
.ready_doc
._id
, _self
.ready_doc
._rev
, false);
167 // console.log("Before:");
168 // console.log(doc.value.metadata);
170 doc
.value
.metadata
= $.extend({}, doc
.value
.metadata
, new_metadata
);
172 // console.log("After:");
173 // console.log(doc.value.metadata);
175 var db_path
= $.ajatus
.preferences
.client
.content_database
;
176 if (doc
.value
._type
== 'tag') {
177 db_path
= $.ajatus
.preferences
.client
.tags_database
;
180 $.jqCouch
.connection('doc').save(db_path
, doc
);
181 _self
.ready_doc
= new $.ajatus
.document(doc
);
183 prepare_doc_title: function() {
186 if ( $.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
]['title_item']
187 && ( typeof(this.ready_doc
.value
['title']) == 'undefined'
188 || this.ready_doc
.value
['title'].val
!= '') ) {
189 $.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
].schema
['title'] = {
199 $.each($.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
]['title_item'], function(i
,part
){
200 if (self
.ready_doc
.value
[part
]) {
201 var widget
= new $.ajatus
.widget(self
.ready_doc
.value
[part
].widget
.name
, self
.ready_doc
.value
[part
].widget
.config
);
202 var val
= widget
.value_on_view(self
.ready_doc
.value
[part
].val
, 'plain');
203 if (typeof val
!= 'string') {
204 val
= self
.ready_doc
.value
[part
].val
;
208 title_val
+= $.ajatus
.i10n
.get(part
);
212 this.ready_doc
.value
['title'] = {
214 widget
: $.ajatus
.preferences
.client
.content_types
[this.ready_doc
.value
._type
].schema
['title'].widget
219 $.ajatus
.document
.loader = function(id
, rev
, check_metadata
) {
220 if (typeof check_metadata
== 'undefined') {
221 var check_metadata
= true;
226 if (typeof rev
!= 'undefined') {
230 original
= new $.ajatus
.document(
231 $.jqCouch
.connection('doc').get($.ajatus
.preferences
.client
.content_database
+ '/' + id
, args
),
238 $.ajatus
.document
.metadata
= {
290 $.ajatus
.document
.modify_metadata = function(doc
, metadata
) {
291 $.each(metadata
, function(k
,v
){
292 if ($.ajatus
.document
.metadata
[k
])
294 var wdgt
= new $.ajatus
.widget($.ajatus
.document
.metadata
[k
].widget
.name
, $.ajatus
.document
.metadata
[k
].widget
.config
);
295 doc
.value
.metadata
[k
] = {
296 val
: wdgt
.value_on_save(wdgt
.value_on_save(v
)),
297 widget
: $.ajatus
.document
.metadata
[k
].widget
304 $.ajatus
.document
.actions
= {
305 execute: function(action
, tmpdoc
) {
306 var doc
= new $.ajatus
.document
.loader(tmpdoc
._id
, tmpdoc
._rev
);
308 var act_info
= $.ajatus
.document
.actions
._get_action_info(action
);
310 var msg
= $.ajatus
.elements
.messages
.create(
311 $.ajatus
.i10n
.get('Unknown document action'),
312 $.ajatus
.i10n
.get('Unknown action %s requested for object %s!', [action
, doc
.value
.title
.val
])
317 if (act_info
.pool_action
)
319 var pa
= act_info
.pool_action
;
320 var pai
= $.ajatus
.document
.actions
._get_action_info(fa
);
326 var pool_id
= $.ajatus
.document
.history
.pool
.add(pool_action
);
330 if (act_info
.undoable
) {
331 $.ajatus
.document
.actions
._execute_temp(act_info
.action
, doc
);
333 $.ajatus
.document
.actions
._execute_final(act_info
.action
, doc
);
336 _execute_temp: function(action
, doc
) {
337 // console.log("_execute_temp: "+action);
340 var on_success = function(data
) {
345 var msg
= $.ajatus
.elements
.messages
.create(
346 $.ajatus
.i10n
.get('Object deleted'),
347 $.ajatus
.i10n
.get('Object %s moved to trash.', [doc
.value
.title
.val
]) + ' <a href="#undelete.'+doc
.value
._type
+'.'+doc
._id
+'" class="undo">' + $.ajatus
.i10n
.get('Undo') + '</a>'
349 msg
.bind_in_content('click', 'a.undo', function(e
){
350 $.ajatus
.document
.actions
.execute("undelete", tmpdoc
);
351 msg
.fade('out', true);
357 doc
= $.ajatus
.document
.modify_metadata(doc
, {
359 revised
: $.ajatus
.formatter
.date
.js_to_iso8601(new Date()),
360 revisor
: $.ajatus
.preferences
.local
.user
.email
363 $.jqCouch
.connection('doc', on_success
).save($.ajatus
.preferences
.client
.content_database
, doc
);
365 $('#object_'+doc
._id
, $.ajatus
.application_content_area
).hide().addClass('deleted');
369 _execute_final: function(action
, doc
) {
372 var on_success = function(data
) {
373 var msg
= $.ajatus
.elements
.messages
.create(
374 $.ajatus
.i10n
.get('Object deleted'),
375 $.ajatus
.i10n
.get('Object %s removed from Ajatus.', [doc
.value
.title
.val
])
380 $.jqCouch
.connection('doc', on_success
).del($.ajatus
.preferences
.client
.content_database
, doc
);
381 $('#object_'+doc
._id
, $.ajatus
.application_content_area
).remove();
384 var on_success = function(data
) {
385 var msg
= $.ajatus
.elements
.messages
.create(
386 $.ajatus
.i10n
.get('Object restored'),
387 $.ajatus
.i10n
.get('Object %s restored succesfully.', [doc
.value
.title
.val
])
392 doc
= $.ajatus
.document
.modify_metadata(doc
, {
394 revised
: $.ajatus
.formatter
.date
.js_to_iso8601(new Date()),
395 revisor
: $.ajatus
.preferences
.local
.user
.email
397 $.jqCouch
.connection('doc', on_success
).save($.ajatus
.preferences
.client
.content_database
, doc
);
399 $('#object_'+doc
._id
, $.ajatus
.application_content_area
).not('.deleted').remove();
400 $('#object_'+doc
._id
, $.ajatus
.application_content_area
).filter('.deleted').show().removeClass('deleted');
404 empty_pool: function () {
405 // console.log("empty_pool");
406 var items
= $.ajatus
.document
.history
.pool
.get_all();
407 if (items
.length
> 0) {
408 var msg
= $.ajatus
.elements
.messages
.create(
409 $.ajatus
.i10n
.get('Emptying action pool'),
410 $.ajatus
.i10n
.get('Running %d pooled actions.', [items
.length
])
413 $.each(items
, function(i
,item
){
414 $.ajatus
.document
.history
.pool
.remove(i
);
415 $.ajatus
.document
.actions
.execute(item
.action
, item
.doc
);
418 _get_action_info: function(action
) {
423 label
: $.ajatus
.i10n
.get('Delete'),
425 undo_label
: 'Undelete',
432 label
: $.ajatus
.i10n
.get('Delete'),
440 label
: $.ajatus
.i10n
.get('Undelete'),
451 $.ajatus
.document
.history
= {};
452 $.ajatus
.document
.history
.pool
= {
455 add: function(action
) {
456 var new_length
= $.ajatus
.document
.history
.pool
.items
.push(action
);
457 var pool_id
= new_length
-1;
460 remove: function(item_id
) {
461 $.ajatus
.document
.history
.pool
.items
= $.grep($.ajatus
.document
.history
.pool
.items
, function(n
,i
){
465 get_item: function(item_id
) {
466 if (items
[item_id
]) {
467 return items
[item_id
];
472 get_all: function() {
473 return $.ajatus
.document
.history
.pool
.items
;
477 $.ajatus
.document
.additionals
= {
486 $.extend($.ajatus
.document
.additionals
, {
487 create: function(content_type
, row_holder
, opts
) {
488 $.ajatus
.document
.additionals
._reset();
490 var id
= $.ajatus
.document
.additionals
._generate_id();
492 var options
= $.ajatus
.document
.additionals
.defaults
;
498 var af_win
= $.ajatus
.document
.additionals
._create_structure(id
, options
);
499 $('.title', af_win
).html($.ajatus
.i10n
.get('Add field'));
501 var jqform
= $('.form', af_win
);
502 var contents
= $('.contents', af_win
);
504 var wdgts
= $.ajatus
.document
.additionals
._generate_widget_list();
506 $('<label for="widget"/>').html($.ajatus
.i10n
.get('Widget')).appendTo(contents
);
507 var wdgt_sel_holder
= $('<div id="widget_selection_holder"/>');
508 wdgt_sel_holder
.html(wdgts
).appendTo(contents
);
510 var wdgt_details
= $('<div id="widget_details_holder"/>');
511 wdgt_details
.appendTo(contents
);
513 var wdgts_on_change = function(e
){
514 var sel_w
= e
.currentTarget
.value
;
516 wdgt_sel_holder
.html($.ajatus
.i10n
.get(sel_w
));
517 wdgt_sel_holder
.addClass('selected');
518 wdgt_details
.html($.ajatus
.document
.additionals
._generate_widget_details(sel_w
));
520 var field
= $('<input type="hidden" />').attr({
524 field
.appendTo(jqform
);
528 wdgts
.bind('change', wdgts_on_change
);
530 wdgt_sel_holder
.bind('dblclick', function(e
){
531 wdgt_sel_holder
.removeClass('selected');
532 wdgt_sel_holder
.html(wdgts
);
533 wdgts
.bind('change', wdgts_on_change
);
536 $('.actions #submit_save', af_win
).bind('click', function(e
){
537 var result
= $.ajatus
.document
.additionals
.save_widget(jqform
.formToArray(false), jqform
);
540 $.ajatus
.document
.additionals
.close(id
);
546 if (options
.auto_show
) {
547 $.ajatus
.document
.additionals
.show(id
);
550 edit: function(content_type
, row_holder
, data
, opts
) {
551 $.ajatus
.document
.additionals
._reset();
553 var id
= $.ajatus
.document
.additionals
._generate_id();
554 console
.log("Edit win id: "+id
);
556 var options
= $.ajatus
.document
.additionals
.defaults
;
562 var af_win
= $.ajatus
.document
.additionals
._create_structure(id
, options
);
563 $('.title', af_win
).html($.ajatus
.i10n
.get('Edit field %s', [data
.name
]));
565 $('.actions #submit_save', af_win
).bind('click', function(e
){
566 console
.log("save additional field (on edit)");
567 $.ajatus
.document
.additionals
.close(id
);
570 if (options
.auto_show
) {
571 $.ajatus
.document
.additionals
.show(id
);
574 config: function(widget
, prev_vals
, on_save
) {
575 if (typeof prev_vals
== 'undefined') {
578 if (typeof on_save
== 'undefined') {
579 var on_save
= '$.ajatus.document.additionals.save_widget_settings';
582 var id
= $.ajatus
.document
.additionals
._generate_id();
584 var af_win
= $.ajatus
.document
.additionals
._create_structure(id
);
585 $('.title', af_win
).html($.ajatus
.i10n
.get('Configure widget %s', [$.ajatus
.i10n
.get(widget
.name
)]));
587 var jqform
= $('.form', af_win
);
588 var contents
= $('.contents', af_win
);
590 var wdgt_settings
= $('<div id="widget_settings_holder" />');
591 wdgt_settings
.appendTo(contents
);
592 wdgt_settings
.html($.ajatus
.document
.additionals
._generate_widget_settings(widget
, prev_vals
));
594 $('.actions #submit_save', af_win
).bind('click', function(e
){
595 var parent_win
= $.ajatus
.document
.additionals
._get_parent();
598 if (typeof on_save
== 'string') {
601 var result
= fn
.apply(fn
, [jqform
.formToArray(false), parent_win
, jqform
]);
604 $.ajatus
.document
.additionals
.close(id
);
608 $.ajatus
.document
.additionals
.show(id
);
611 $.ajatus
.document
.additionals
.active
= id
;
612 $.ajatus
.document
.additionals
.open
.push(id
);
613 $.ajatus
.document
.additionals
._position(id
);
617 close: function(id
) {
618 if (typeof id
== 'undefined') {
619 var id
= $.ajatus
.document
.additionals
.active
;
624 var active_idx
= null;
625 var still_open
= $.grep($.ajatus
.document
.additionals
.open
, function(n
,i
){
635 && $.ajatus
.document
.additionals
.open
.length
-1 >= (active_idx
-1))
637 $.ajatus
.document
.additionals
.active
= still_open
[active_idx
-1];
639 $.ajatus
.document
.additionals
.active
= null;
642 $.ajatus
.document
.additionals
.open
= still_open
;
644 save_widget_settings: function(form_data
, parent_win_id
, form
) {
645 var form_values
= {};
647 $.each(form_data
, function(i
,row
){
648 if (row
.name
.toString().match(/__(.*?)/)) {
651 if (row
.name
.substr(0,6) != "widget") {
654 var prev_val
= false;
656 var name_parts_count
= 0;
657 if (row
.name
.toString().match(/;/g
)) {
658 name_parts
= row
.name
.toString().split(";");
659 name_parts_count
= name_parts
.length
;
662 $.each(form_data
, function(x
,r
){
663 if (r
.name
== 'widget['+row
.name
+':name]') {
664 widget
['name'] = r
.value
;
665 } else if (r
.name
== 'widget['+row
.name
+':config]') {
666 widget
['config'] = $.ajatus
.converter
.parseJSON(r
.value
);
667 } else if (r
.name
== 'widget['+row
.name
+':prev_val]') {
668 prev_val
= $.ajatus
.converter
.parseJSON(r
.value
);
672 var wdgt
= new $.ajatus
.widget(widget
['name'], widget
['config']);
674 item
['val'] = wdgt
.value_on_save(row
.value
, prev_val
);
675 item
['widget'] = widget
;
677 if (name_parts_count
> 0) {
679 for (var i
=0; i
< name_parts_count
; i
++) {
680 var key
= "['"+name_parts
[i
]+"']";
682 if (prevs
.length
> 0) {
684 $.each(prevs
, function(pi
, pk
){
685 key_prefix
= "['" + pk
+ "']" + key_prefix
;
687 key
= key_prefix
+ key
;
690 if (typeof eval("form_values"+key
) == 'undefined') {
691 eval("form_values"+key
+"={};");
694 prevs
.push(name_parts
[i
]);
695 if (i
== name_parts_count
-1) {
696 if ($.browser
.mozilla
) {
697 if (typeof item
== 'object') {
698 eval("form_values"+key
+"="+item
.toSource()+";");
700 eval("form_values"+key
+"="+item
+";");
703 eval("form_values"+key
+"="+item
+";");
708 form_values
[row
.name
] = item
;
713 var config_holder
= $('#'+parent_win_id
+' .saved_settings');
714 config_holder
.html('');
716 $.each(form_values
, function(k
,item
){
717 var field
= $('<input type="hidden" />').attr({
719 value
: $.ajatus
.converter
.toJSON(item
.val
)
721 field
.appendTo(config_holder
);
726 save_widget: function(form_data
, form
) {
727 var form_values
= {};
728 var sel_widget
= 'text';
730 // console.log(form_values);
732 $.each(form_data
, function(i
,row
){
733 if (row
.name
.toString().match(/__(.*?)/)) {
736 if (row
.name
== '_widget') {
737 sel_widget
= String(row
.value
);
739 else if (row
.name
.substr(0,6) != "widget") {
742 var prev_val
= false;
744 var name_parts_count
= 0;
746 if (row
.name
.toString().match(/;/g
)) {
747 name_parts
= row
.name
.toString().split(";");
748 name_parts_count
= name_parts
.length
;
751 $.each(form_data
, function(x
,r
){
752 if (r
.name
== 'widget['+row
.name
+':name]') {
753 widget
['name'] = r
.value
;
754 } else if (r
.name
== 'widget['+row
.name
+':config]') {
755 widget
['config'] = $.ajatus
.converter
.parseJSON(r
.value
);
756 } else if (r
.name
== 'widget['+row
.name
+':prev_val]') {
757 prev_val
= $.ajatus
.converter
.parseJSON(r
.value
);
761 if (typeof widget
['name'] == 'undefined') {
765 var wdgt
= new $.ajatus
.widget(widget
['name'], widget
['config']);
767 item
['val'] = wdgt
.value_on_save(row
.value
, prev_val
);
768 item
['widget'] = widget
;
770 if (name_parts_count
> 0) {
771 console
.log("name_parts_count > 0");
773 for (var i
=0; i
< name_parts_count
; i
++) {
774 var key
= "['"+name_parts
[i
]+"']";
776 if (prevs
.length
> 0) {
778 $.each(prevs
, function(pi
, pk
){
779 key_prefix
= "['" + pk
+ "']" + key_prefix
;
781 key
= key_prefix
+ key
;
784 if (typeof eval("form_values"+key
) == 'undefined') {
785 eval("form_values"+key
+"={};");
788 prevs
.push(name_parts
[i
]);
789 if (i
== name_parts_count
-1) {
790 if ($.browser
.mozilla
) {
791 if (typeof item
== 'object') {
792 eval("form_values"+key
+"="+item
.toSource()+";");
794 eval("form_values"+key
+"="+item
+";");
797 eval("form_values"+key
+"="+item
+";");
802 form_values
[row
.name
] = item
;
807 // var additional_items = {};
810 if (typeof form_values
['config'] != 'undefined') {
811 $.each(form_values
['config'], function(i
,n
){
812 if (typeof n
== 'object') {
813 config
[i
] = $.ajatus
.converter
.parseJSON(n
.val
);
820 var item_name
= form_values
.name
.val
.toString().toLowerCase();
822 if (item_name
== '') {
826 var additional_item
= {
827 label
: form_values
.label
.val
,
832 def_val
: form_values
.def_val
.val
,
833 required
: form_values
.required
.val
835 // additional_items[item_name] = additional_item;
836 // console.log(additional_items);
837 console
.log(additional_item
);
839 var row_holder
= $('.form_structure ul:eq(0)', $.ajatus
.forms
.active
);
841 $.ajatus
.renderer
.form_helpers
._add_additional_row('create', row_holder
, item_name
, additional_item
);
845 generate_item_actions_tpl: function(name
, widget
, doc
) {
847 'img', { className
: 'additional_edit_btn', src
: 'images/icons/edit.png', title
: $.ajatus
.i10n
.get('Edit'), alt
: $.ajatus
.i10n
.get('Edit') }, '',
848 'img', { className
: 'additional_delete_btn', src
: 'images/icons/trash.png', title
: $.ajatus
.i10n
.get('Delete'), alt
: $.ajatus
.i10n
.get('Delete') }, '',
851 _get_parent: function() {
852 var prev_id
= $.ajatus
.document
.additionals
.open
[$.ajatus
.document
.additionals
.open
.length
-2];
856 _position: function(id
) {
857 var win
= $('#' + id
);
858 var top
= $.ajatus
.document
.additionals
.top_start
;
859 var left
= $.ajatus
.document
.additionals
.left_start
;
861 if ($.ajatus
.document
.additionals
.open
.length
> 1) {
862 var incr
= $.ajatus
.document
.additionals
.open
.length
* 2;
872 _create_structure: function(id
, options
) {
873 var af_win
= $('<div class="additionals_window" />').attr({
876 var title
= $('<h2 class="title"/>');
877 var form
= $('<form id="additionals_window_form" class="form" />');
878 var content_area
= $('<div class="contents"/>');
879 var actions
= $('<div class="actions" />').html('<input type="submit" id="submit_save" name="save" value="' + $.ajatus
.i10n
.get('Save') + '" /><input type="submit" id="submit_cancel" name="cancel" value="' + $.ajatus
.i10n
.get('Cancel') + '" />');
881 af_win
.appendTo($.ajatus
.application_dynamic_elements
);
882 title
.appendTo(af_win
);
883 form
.appendTo(af_win
);
884 content_area
.appendTo(form
);
885 actions
.appendTo(af_win
);
887 $('#submit_cancel', actions
).bind('click', function(e
){
888 $.ajatus
.document
.additionals
.close(id
);
894 _generate_widget_list: function() {
895 var select
= $('<select id="widget" name="widget" />');
897 $.each($.ajatus
.widgets
.loaded_widgets
, function(i
,w
){
898 var opt
= $('<option />').attr({
900 }).html($.ajatus
.i10n
.get(w
));
901 opt
.appendTo(select
);
904 var opt
= $('<option />').attr({
907 }).html($.ajatus
.i10n
.get('Select one') + ' ');
908 opt
.prependTo(select
);
912 _generate_widget_details: function(widget_name
, data
) {
913 var widget
= $.ajatus
.widget(widget_name
);
914 var details
= $('<p>' + $.ajatus
.i10n
.get("Widget %s doesn't support dynamic creation.", [$.ajatus
.i10n
.get(widget_name
)]) + '</p>');
915 if (typeof(widget
['create_widget_details']) == 'function') {
916 details
= widget
.create_widget_details(data
|| {});
921 _generate_widget_settings: function(widget_name
, data
) {
922 var widget
= $.ajatus
.widget(widget_name
);
923 var details
= $('<p>' + $.ajatus
.i10n
.get("Widget %s doesn't support dynamic settings.", [$.ajatus
.i10n
.get(widget_name
)]) + '</p>');
924 if (typeof(widget
['create_widget_settings']) == 'function') {
925 details
= widget
.create_widget_settings(data
|| {});
931 $.ajatus
.document
.additionals
.open
= [];
932 $.ajatus
.document
.additionals
.active
= null;
933 $.ajatus
.application_dynamic_elements
.html('');
935 _generate_id: function()
937 return "additionals_window_" + $.ajatus
.utils
.generate_id();