Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
f97e2be3
Commit
f97e2be3
authored
Mar 10, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify code
parent
1980ca54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
33 deletions
+47
-33
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
...Item/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
+47
-33
No files found.
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
View file @
f97e2be3
...
...
@@ -27,62 +27,52 @@
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
function
requestMaximize
(
param_dict
,
element
)
{
if
(
this
.
props
.
maximize_restore_state
)
{
function
gadgetRequestMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
)
{
if
(
gadget
.
props
.
maximize_restore_state
)
{
return
false
;
// do not raise, like html5 requestFullScreen
}
this
.
props
.
maximize_restore_state
=
{
gadget_scope
:
param_dict
.
gadget_scope
,
gadget
.
props
.
maximize_restore_state
=
{
gadget_scope
:
sub
gadget_scope
,
scrollTop
:
window
.
pageYOffset
,
scrollLeft
:
window
.
pageXOffset
};
element
.
className
=
(
element
.
className
||
""
)
+
"
"
+
this
.
props
.
maximize_classname
;
// XXX tell sub gadget that now it is maximized (call
param_dict.
gadget.onMaximizeChange?)
"
"
+
gadget
.
props
.
maximize_classname
;
// XXX tell sub gadget that now it is maximized (call
sub
gadget.onMaximizeChange?)
// this way the parent gadget can decide to set the sub gadget unmaximized later
// for instance: if the user clicks on a button that changes the ui, the maximized
// gadget should have to be unmaximized.
return
true
;
}
function
leaveMaximize
(
param_dict
,
element
)
{
if
(
!
this
.
props
.
maximize_restore_state
||
this
.
props
.
maximize_restore_state
.
gadget_scope
!==
param_dict
.
gadget_scope
)
{
function
gadgetLeaveMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
)
{
if
(
!
gadget
.
props
.
maximize_restore_state
||
gadget
.
props
.
maximize_restore_state
.
gadget_scope
!==
sub
gadget_scope
)
{
return
false
;
// do not raise, like html5 requestFullScreen
}
var
maximized_element_list
=
this
.
props
.
element
.
querySelectorAll
(
"
.
"
+
this
.
props
.
maximize_classname
var
maximized_element_list
=
gadget
.
props
.
element
.
querySelectorAll
(
"
.
"
+
gadget
.
props
.
maximize_classname
);
if
([].
indexOf
.
call
(
maximized_element_list
,
element
)
<
0
)
{
return
false
;
// do not raise, like html5 requestFullScreen
}
element
.
className
=
(
element
.
className
||
""
)
.
replace
(
this
.
props
.
maximize_classname_search_regexp
,
"
"
)
.
replace
(
gadget
.
props
.
maximize_classname_search_regexp
,
"
"
)
.
replace
(
/
(?:
^
\s
+|
\s
+$
)
/g
,
""
);
// remove trailing spaces
window
.
scrollTo
(
this
.
props
.
maximize_restore_state
.
scrollLeft
,
this
.
props
.
maximize_restore_state
.
scrollTop
gadget
.
props
.
maximize_restore_state
.
scrollLeft
,
gadget
.
props
.
maximize_restore_state
.
scrollTop
);
delete
this
.
props
.
maximize_restore_state
;
// XXX tell sub gadget that now it is unmaximized (call
param_dict.
gadget.onMaximizeChange?)
delete
gadget
.
props
.
maximize_restore_state
;
// XXX tell sub gadget that now it is unmaximized (call
sub
gadget.onMaximizeChange?)
return
true
;
}
function
toggleMaximize
(
param_dict
,
element
)
{
if
(
this
.
props
.
maximize_restore_state
)
{
return
leaveMaximize
.
call
(
this
,
param_dict
,
element
);
function
gadgetToggleMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
)
{
if
(
gadget
.
props
.
maximize_restore_state
)
{
return
gadgetLeaveMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
);
}
return
requestMaximize
.
call
(
this
,
param_dict
,
element
);
}
function
makeMaximizeMethod
(
fn
)
{
return
function
(
_
,
gadget_scope
)
{
var
param_dict
=
{
gadget_scope
:
gadget_scope
};
return
this
.
getDeclaredGadget
(
gadget_scope
).
push
(
function
(
gadget
)
{
param_dict
.
gadget
=
gadget
;
return
gadget
.
getElement
();
}).
push
(
fn
.
bind
(
this
,
param_dict
));
};
return
gadgetRequestMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
);
}
rJS
(
window
)
...
...
@@ -107,9 +97,33 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
allowPublicAcquisition
(
'
requestMaximize
'
,
makeMaximizeMethod
(
requestMaximize
))
.
allowPublicAcquisition
(
'
leaveMaximize
'
,
makeMaximizeMethod
(
leaveMaximize
))
.
allowPublicAcquisition
(
'
toggleMaximize
'
,
makeMaximizeMethod
(
toggleMaximize
))
.
allowPublicAcquisition
(
'
requestMaximize
'
,
function
(
_
,
subgadget_scope
)
{
var
gadget
=
this
,
subgadget
;
return
this
.
getDeclaredGadget
(
gadget_scope
).
push
(
function
(
g
)
{
subgadget
=
g
;
return
g
.
getElement
();
}).
push
(
function
(
element
)
{
return
gadgetRequestMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
);
});
})
.
allowPublicAcquisition
(
'
leaveMaximize
'
,
function
(
_
,
subgadget_scope
)
{
var
gadget
=
this
,
subgadget
;
return
this
.
getDeclaredGadget
(
gadget_scope
).
push
(
function
(
g
)
{
subgadget
=
g
;
return
g
.
getElement
();
}).
push
(
function
(
element
)
{
return
gadgetLeaveMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
);
});
})
.
allowPublicAcquisition
(
'
toggleMaximize
'
,
function
(
_
,
subgadget_scope
)
{
var
gadget
=
this
,
subgadget
;
return
this
.
getDeclaredGadget
(
gadget_scope
).
push
(
function
(
g
)
{
subgadget
=
g
;
return
g
.
getElement
();
}).
push
(
function
(
element
)
{
return
gadgetToggleMaximize
(
gadget
,
subgadget
,
subgadget_scope
,
element
);
});
})
.
declareService
(
function
()
{
var
g
=
this
,
i
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment