Author: ornicar2
Date: 2010-01-18 15:19:10 +0100 (Mon, 18 Jan 2010)
New Revision: 26817
Added:
plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontAjaxPager.js
Modified:
plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontCtrl.js
plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontEditCtrl.js
plugins/diemPlugin/trunk/dmFrontPlugin/web/js/page/dmWidget.js
Log:
[Diem]
- enhanced front edition javascripts
Added: plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontAjaxPager.js
===================================================================
--- plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontAjaxPager.js
(rev 0)
+++ plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontAjaxPager.js
2010-01-18 14:19:10 UTC (rev 26817)
@@ -0,0 +1,10 @@
+(function($)
+{
+
+ $('#dm_page div.dm_pager_ajax_links a.link').live('click', function()
+ {
+ $(this).closest('div.dm_widget_inner').load($(this).metadata().href);
+ return false;
+ });
+
+}(jQuery));
\ No newline at end of file
Modified: plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontCtrl.js
===================================================================
--- plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontCtrl.js
2010-01-18 14:17:46 UTC (rev 26816)
+++ plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontCtrl.js
2010-01-18 14:19:10 UTC (rev 26817)
@@ -5,7 +5,11 @@
init: function()
{
- this.launchControllers($('#dm_page'));
+ var $page = $('#dm_page');
+
+ this.launchControllers($page);
+
+ $page.find('div.dm_widget').trigger('dmWidgetLaunch');
}
});
Modified: plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontEditCtrl.js
===================================================================
--- plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontEditCtrl.js
2010-01-18 14:17:46 UTC (rev 26816)
+++ plugins/diemPlugin/trunk/dmFrontPlugin/web/js/dmFrontEditCtrl.js
2010-01-18 14:19:10 UTC (rev 26817)
@@ -5,23 +5,19 @@
init: function()
{
- this.launchControllers($('#dm_page'));
+ var $page = $('#dm_page').dmPage();
+
+ this.launchControllers($page);
+
+ $page.find('div.dm_widget').trigger('dmWidgetLaunch');
this.bars();
this.liveEvents();
- this.page();
-
this.hotkeys();
-
- this.test();
},
- test: function()
- {
- },
-
hotkeys: function()
{
$("#dm_page").click(function(e)
@@ -38,11 +34,6 @@
});
},
- page: function()
- {
- $('#dm_page').dmPage();
- },
-
bars: function()
{
$('#dm_page_bar').dmFrontPageBar();
Modified: plugins/diemPlugin/trunk/dmFrontPlugin/web/js/page/dmWidget.js
===================================================================
--- plugins/diemPlugin/trunk/dmFrontPlugin/web/js/page/dmWidget.js
2010-01-18 14:17:46 UTC (rev 26816)
+++ plugins/diemPlugin/trunk/dmFrontPlugin/web/js/page/dmWidget.js
2010-01-18 14:19:10 UTC (rev 26817)
@@ -18,25 +18,18 @@
return;
}
- var $dialog = $.dm.ctrl.ajaxJsonDialog({
+ var $dialog = $.dm.ctrl.ajaxDialog({
url: $.dm.ctrl.getHref('+/dmWidget/edit'),
data: { widget_id: widget.getId() },
title: $('a.dm_widget_edit', widget.element).attr('title'),
width: 370,
'class': dialog_class,
- beforeClose: function() {
- if (widget.deleted) return;
- $.ajax({
- dataType: 'json',
- url: $.dm.ctrl.getHref('+/dmWidget/getInner'),
- data: { widget_id: widget.getId() },
- success: function(data) {
- widget.element.attr('class', data.widget_classes[0])
- .find('div.dm_widget_inner')
- .attr('class',
data.widget_classes[1])
- .html(data.widget_html);
- }
- });
+ beforeClose: function()
+ {
+ if (!widget.deleted)
+ {
+ widget.reload();
+ }
}
}).bind('dmAjaxResponse', function() {
$dialog.prepare();
@@ -95,10 +88,8 @@
* ( usefull when uploading files )
*/
$form.find('form').dmAjaxForm({
- dataType: 'json',
beforeSubmit: function(data) {
$dialog.block();
- widget.element.block();
if ($tabbedFormActiveTab =
$form.find('ul.ui-tabs-nav > li.ui-tabs-selected:first').orNot())
{
activeTab =
$tabbedFormActiveTab.find('>a').attr('href');
@@ -110,48 +101,27 @@
widget.element.unblock();
$.dm.ctrl.errorDialog('Error
when updating the widget', xhr.responseText);
},
- success: function(data)
+ success: function(data)
{
- if (data.widget_html)
- {
- widget.element
- .attr('class',
data.widget_classes[0])
- .find('div.dm_widget_inner')
- .attr('class',
data.widget_classes[1]);
-
- if ('__DM_ASYNC__' ==
data.widget_html)
- {
-
setTimeout(function() { $dialog.find('form').submit(); }, 100);
- }
- else
- {
-
widget.element.find('div.dm_widget_inner').html(data.widget_html);
- }
- }
-
- if (data.stylesheets)
- {
-
$.loadStylesheets(data.stylesheets);
- }
-
- if (data.js)
- {
- $.globalEval(data.js);
- }
-
- widget.element.unblock();
-
- $form.trigger('submitSuccess');
-
- if (data.type == 'close') {
+ if('saved' == data)
+ {
$dialog.dialog('close');
return;
}
-
- $dialog.html(data.html).trigger('dmAjaxResponse');
+
+ parts = data.split(/\_\_DM\_SPLIT\_\_/);
+
+ // update widget content
+ widget.replace(parts[1]);
+
+ $form.trigger('submitSuccess');
+
+ // update dialog content
+ $dialog.html(parts[0]).trigger('dmAjaxResponse');
}
});
}
+
$('a.delete', $dialog).click(function() {
if (confirm($(this).attr('title')+" ?")) {
widget._delete();
@@ -163,16 +133,44 @@
_delete: function()
{
- var widget = this;
- this.deleted = true;
+ var self = this;
+ self.deleted = true;
$.ajax({
url: $.dm.ctrl.getHref('+/dmWidget/delete'),
- data: { widget_id: this.getId() }
+ data: { widget_id: self.getId() }
});
- this.element.slideUp(500, function() { widget.destroy();
widget.element.remove(); });
+ self.element.slideUp(500, function() { self.destroy();
self.element.remove(); });
},
+
+ reload: function()
+ {
+ var self = this;
+
+ self.element.block();
+
+ $.ajax({
+ url: $.dm.ctrl.getHref('+/dmWidget/getFull'),
+ data: { widget_id: self.getId() },
+ success: function(html)
+ {
+ self.replace(html);
+ }
+ });
+ },
+
+ replace: function(html)
+ {
+ this.element
+ .attr('class', $('>div:first', '<div>'+html+'</div>').attr('class'))
+ .find('>div.dm_widget_inner')
+ .html($('>div.dm_widget_inner', html).html())
+ .attr('class', $('>div.dm_widget_inner', html).attr('class'))
+ .end()
+ .unblock()
+ .trigger('dmWidgetLaunch');
+ },
initialize: function()
{
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.