Merge lp:~openerp-dev/openerp-web/trunk-bug-908216-vda into lp:openerp-web

Proposed by Vaibhav Darji
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~openerp-dev/openerp-web/trunk-bug-908216-vda
Merge into: lp:openerp-web
Diff against target: 213 lines (+184/-0)
3 files modified
addons/web/__openerp__.py (+2/-0)
addons/web/static/lib/jquery.ui/css/smoothness/jquery.dialog.css (+9/-0)
addons/web/static/lib/jquery.ui/js/jquery.dialog.js (+173/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-bug-908216-vda
Reviewer Review Type Date Requested Status
OpenERP R&D Web Team Pending
Review via email: mp+86925@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Fabien Meghazi (OpenERP) (fme) wrote :

Not sure we will merge this. We prefer to keep vanilla jQueryUI#dialog

Unmerged revisions

1838. By Vaibhav Darji

[ADD] forgot to add files.

1837. By Vaibhav Darji

[IMP] Maximize and restore dialog.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/__openerp__.py'
--- addons/web/__openerp__.py 2011-12-19 16:32:22 +0000
+++ addons/web/__openerp__.py 2011-12-27 08:18:24 +0000
@@ -26,6 +26,7 @@
26 "static/lib/jquery.superfish/js/superfish.js",26 "static/lib/jquery.superfish/js/superfish.js",
27 "static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js",27 "static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js",
28 "static/lib/jquery.ui/js/jquery-ui-timepicker-addon.js",28 "static/lib/jquery.ui/js/jquery-ui-timepicker-addon.js",
29 "static/lib/jquery.ui/js/jquery.dialog.js",
29 "static/lib/jquery.ui.notify/js/jquery.notify.js",30 "static/lib/jquery.ui.notify/js/jquery.notify.js",
30 "static/lib/jquery.deferred-queue/jquery.deferred-queue.js",31 "static/lib/jquery.deferred-queue/jquery.deferred-queue.js",
31 "static/lib/jquery.scrollTo/jquery.scrollTo-min.js",32 "static/lib/jquery.scrollTo/jquery.scrollTo-min.js",
@@ -56,6 +57,7 @@
56 'css' : [57 'css' : [
57 "static/lib/jquery.superfish/css/superfish.css",58 "static/lib/jquery.superfish/css/superfish.css",
58 "static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css",59 "static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css",
60 "static/lib/jquery.ui/css/smoothness/jquery.dialog.css",
59 "static/lib/jquery.ui.notify/css/ui.notify.css",61 "static/lib/jquery.ui.notify/css/ui.notify.css",
60 "static/lib/jquery.tipTip/tipTip.css",62 "static/lib/jquery.tipTip/tipTip.css",
61 "static/src/css/base.css",63 "static/src/css/base.css",
6264
=== added file 'addons/web/static/lib/jquery.ui/css/smoothness/jquery.dialog.css'
--- addons/web/static/lib/jquery.ui/css/smoothness/jquery.dialog.css 1970-01-01 00:00:00 +0000
+++ addons/web/static/lib/jquery.ui/css/smoothness/jquery.dialog.css 2011-12-27 08:18:24 +0000
@@ -0,0 +1,9 @@
1.ui-dialog .ui-dialog-titlebar-maximize { position: absolute; right: 1.5em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
2.ui-dialog .ui-dialog-titlebar-maximize span { display: block; margin: 1px; }
3
4.ui-icon-maximizethick { background-position: -32px -82px; }
5
6.ui-dialog .ui-dialog-titlebar-restore { position: absolute; right: 1.5em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
7.ui-dialog .ui-dialog-titlebar-restore span { display: block; margin: 1px; }
8
9.ui-icon-restorethick { background-position: -49px -82px; }
0\ No newline at end of file10\ No newline at end of file
111
=== added file 'addons/web/static/lib/jquery.ui/js/jquery.dialog.js'
--- addons/web/static/lib/jquery.ui/js/jquery.dialog.js 1970-01-01 00:00:00 +0000
+++ addons/web/static/lib/jquery.ui/js/jquery.dialog.js 2011-12-27 08:18:24 +0000
@@ -0,0 +1,173 @@
1(function($) {
2 var _init = $.ui.dialog.prototype._init;
3 $.ui.dialog.prototype._init = function() {
4 var self = this;
5 _init.apply(this, arguments);
6 uiDialogTitlebar = this.uiDialogTitlebar;
7// this.originalSize();
8 $(uiDialogTitlebar).append(
9 $('<a>',
10 {'href': '#',
11 'class': 'ui-dialog-titlebar-maximize ui-corner-all',
12 'role':'button'
13 })
14 .hover(function() {
15 $(this).addClass("ui-state-hover")
16 }, function() {
17 $(this).removeClass("ui-state-hover")
18 })
19 .focus(function () {
20 $(this).addClass("ui-state-focus")
21 })
22 .blur(function() {
23 $(this).removeClass("ui-state-focus")
24 })
25 .click(function() {
26 self.maximize();
27 return false;
28 })
29 .append(
30 $('<span>',
31 {'class': 'ui-icon ui-icon-maximizethick'
32 }).html('Max')
33 ));
34
35 /* Adding restore button */
36 uiDialogTitlebar.append(
37 $('<a>',
38 {'href': '#',
39 'class': 'ui-dialog-titlebar-restore ui-corner-all',
40 'role':'button'
41 }
42 )
43 .hover(function() {
44 $(this).addClass("ui-state-hover")
45 }, function() {
46 $(this).removeClass("ui-state-hover")
47 })
48 .focus(function () {
49 $(this).addClass("ui-state-focus")
50 })
51 .blur(function() {
52 $(this).removeClass("ui-state-focus")
53 }).hide()
54 .click(function() {
55 self.restore();
56 return false;
57 })
58 .append(
59 $('<span>',
60 {
61 'class': 'ui-icon ui-icon-restorethick'
62 }).html('Restore'))
63 );
64 }
65
66 $.extend($.ui.dialog.prototype, {
67 /* Allow restore the dialog */
68 restore: function() {
69 this.maximized=false; /* reset both states (restored) */
70 $('.ui-dialog-content').show();
71 this.uiDialog.css({width: this.options.width, height:this.options.height});
72 this.size();
73 $('.ui-dialog-titlebar-restore').css('right','1.5em');
74 this.adjustScrollContent();
75 this.position(this.options.position);
76
77 $('.ui-dialog-titlebar-maximize').show();
78 $('.ui-dialog-titlebar-restore').hide();
79 this.uiDialog.css('position','absolute');
80 },
81
82 /* Maximize to the whole visible size of the window */
83 maximize: function() {
84 this.maximized=true; /* save the current state: maximized */
85 $('.ui-dialog-content').show();
86 $('.ui-dialog-titlebar-restore').css('right','1.5em');
87 this.uiDialog.animate(
88 {left:0, top:0, width: $('body').width()-15, height:$('body').height()-15
89 },'slow', function() {
90 $('.ui-dialog-content').css('width',$(this).width()-15)
91 });
92 this.size();
93 this.adjustScrollContent();
94 $('.ui-dialog-titlebar-restore').show();
95 $('.ui-dialog-titlebar-maximize').hide();
96 this.uiDialog.css('position','absolute');
97 this.uiDialog.data({"resizable": true, "draggable": true});
98 },
99
100 size: function() {
101 var container = this.uiDialogTitlebar.parent(),
102 titlebar = this.uiDialogTitlebar,
103 content = this.element,
104 tbMargin = parseInt(content.css('margin-top'),10) + parseInt(content.css('margin-bottom'),10),
105 lrMargin = parseInt(content.css('margin-left'),10) + parseInt(content.css('margin-right'),10);
106
107 content.height(container.height() - titlebar.outerHeight() - tbMargin /* More precision on scroll content */ - 8);
108 content.width(container.width() - lrMargin);
109 },
110
111 /* Adjuste the content inside the dialog on maximize/restore */
112 adjustScrollContent: function () {
113 $('.ui-dialog-content').css('width', this.uiDialog.width()-16, 'height', this.uiDialog.height()-16);
114 },
115
116 /* Store the size of dialog, before it gets minimized or maximized */
117 originalSize: function() {
118 this.options.height = this.uiDialog.height();
119 this.options.width = this.uiDialog.width();
120 },
121
122 /* Saves all css related to the dialog position before maximize or minimize */
123 position: function(pos) {
124 var wnd = $(window), doc = $(document),
125 pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
126 minTop = pTop;
127
128 if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
129 pos = [
130 pos == 'right' || pos == 'left' ? pos : 'center',
131 pos == 'top' || pos == 'bottom' ? pos : 'middle'
132 ];
133 }
134 if (pos.constructor != Array) {
135 pos = ['center', 'middle'];
136 }
137 if (pos[0].constructor == Number) {
138 pLeft += pos[0];
139 } else {
140 switch (pos[0]) {
141 case 'left':
142 pLeft += 0;
143 break;
144 case 'right':
145 pLeft += wnd.width() - this.uiDialog.width();
146 break;
147 default:
148 case 'center':
149 pLeft += (wnd.width() - this.uiDialog.width()) / 2;
150 }
151 }
152 if (pos[1].constructor == Number) {
153 pTop += pos[1];
154 } else {
155 switch (pos[1]) {
156 case 'top':
157 pTop += 0;
158 break;
159 case 'bottom':
160 pTop += wnd.height() - this.uiDialog.height();
161 break;
162 default:
163 case 'middle':
164 pTop += (wnd.height() - this.uiDialog.height()) / 2;
165 }
166 }
167
168 // prevent the dialog from being too high (make sure the titlebar is accessible)
169 pTop = Math.max(pTop, minTop);
170 this.uiDialog.css({top: pTop, left: pLeft});
171 },
172 });
173})(jQuery);
0\ No newline at end of file174\ No newline at end of file