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