wip: js modularization of lightbox and cleanup

This commit is contained in:
Florian BLOUET
2016-02-29 17:31:29 +01:00
parent 203521d991
commit ab368a7dee
21 changed files with 966 additions and 991 deletions

View File

@@ -26,6 +26,7 @@ gulp.task('build-common-css', ['build-common-font-css'],function(){
gulp.task('build-common-js', function(){ gulp.task('build-common-js', function(){
var commonGroup = [ var commonGroup = [
config.paths.src + 'common/js/components/utils.js',
config.paths.src + 'common/js/components/user.js', config.paths.src + 'common/js/components/user.js',
// config.paths.dist + 'assets/bootstrap/js/bootstrap.js', // should append no conflict // config.paths.dist + 'assets/bootstrap/js/bootstrap.js', // should append no conflict
config.paths.src + 'vendors/jquery-mousewheel/js/jquery.mousewheel.js', config.paths.src + 'vendors/jquery-mousewheel/js/jquery.mousewheel.js',

View File

@@ -84,7 +84,6 @@ gulp.task('build-prod-js', function(){
config.paths.src + 'prod/js/components/workzone/workzone-basket.js', config.paths.src + 'prod/js/components/workzone/workzone-basket.js',
config.paths.src + 'prod/js/components/workzone/workzone-facets.js', config.paths.src + 'prod/js/components/workzone/workzone-facets.js',
config.paths.src + 'prod/js/components/workzone/workzone-thesaurus.js', config.paths.src + 'prod/js/components/workzone/workzone-thesaurus.js',
config.paths.src + 'prod/js/components/utils.js',
config.paths.src + 'prod/js/components/cgu.js', config.paths.src + 'prod/js/components/cgu.js',
config.paths.src + 'prod/js/components/preferences.js', config.paths.src + 'prod/js/components/preferences.js',
// config.paths.src + 'prod/js/jquery.form.2.49.js', // config.paths.src + 'prod/js/jquery.form.2.49.js',

View File

@@ -1,8 +1,23 @@
; ;
var dialogModule = (function ($) { var dialogModule = (function ($) {
var $body = null;
var bodySize = {};
var _dialog = {}; var _dialog = {};
$('document').ready(function(){
$body = $('body');
$(window).on('resize', function () {
bodySize.y = $body.height();
bodySize.x = $body.width();
//@TODO modal resize should be in a stream
$('.overlay').height(bodySize.y).width(bodySize.x);
//_resizeAll();
});
});
function getLevel(level) { function getLevel(level) {
level = parseInt(level); level = parseInt(level);
@@ -79,6 +94,10 @@ var dialogModule = (function ($) {
height = dimension[1]; height = dimension[1];
width = dimension[0]; width = dimension[0];
} else { } else {
bodySize.y = $body.height();
bodySize.x = $body.width();
switch (this.options.size) { switch (this.options.size) {
case 'Full': case 'Full':
height = bodySize.y - 30; height = bodySize.y - 30;

File diff suppressed because it is too large Load Diff

View File

@@ -450,7 +450,6 @@ var recordEditorModule = (function (p4) {
} }
function _setPreviewEdit() { function _setPreviewEdit() {
console.log('set preview edit on resize')
if (!$('#TH_Opreview').is(':visible')) if (!$('#TH_Opreview').is(':visible'))
return false; return false;

View File

@@ -44,11 +44,11 @@ var pushModule = (function (window, p4) {
return; return;
}, },
error: function () { error: function () {
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
return; return;
}, },
timeout: function () { timeout: function () {
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
return; return;
} }
}); });
@@ -159,7 +159,7 @@ var pushModule = (function (window, p4) {
return false; return false;
} }
$dialog.Close(); $dialog.close();
$('input[name="name"]', $FeedBackForm).val($('input[name="name"]', $dialog.getDomElement()).val()); $('input[name="name"]', $FeedBackForm).val($('input[name="name"]', $dialog.getDomElement()).val());
$('input[name="duration"]', $FeedBackForm).val($('select[name="duration"]', $dialog.getDomElement()).val()); $('input[name="duration"]', $FeedBackForm).val($('select[name="duration"]', $dialog.getDomElement()).val());
@@ -454,11 +454,11 @@ var pushModule = (function (window, p4) {
return; return;
}, },
error: function () { error: function () {
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
return; return;
}, },
timeout: function () { timeout: function () {
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
return; return;
} }
}); });
@@ -492,7 +492,7 @@ var pushModule = (function (window, p4) {
var callbackOK = function () { var callbackOK = function () {
$('a.list_refresh', $container).trigger('click'); $('a.list_refresh', $container).trigger('click');
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
}; };
var name = $('input[name="name"]', dialogModule.dialog.get(2).getDomElement()).val(); var name = $('input[name="name"]', dialogModule.dialog.get(2).getDomElement()).val();
@@ -630,7 +630,7 @@ var pushModule = (function (window, p4) {
var callbackOK = function () { var callbackOK = function () {
$('#ListManager .all-lists a.list_refresh').trigger('click'); $('#ListManager .all-lists a.list_refresh').trigger('click');
dialogModule.dialog.get(2).Close(); dialogModule.dialog.get(2).close();
}; };
var List = new document.List(list_id); var List = new document.List(list_id);

View File

@@ -133,30 +133,6 @@
} }
} }
/*function is_ctrl_key(event) {
if (event.altKey)
return true;
if (event.ctrlKey)
return true;
if (event.metaKey) // apple key opera
return true;
if (event.keyCode == '17') // apple key opera
return true;
if (event.keyCode == '224') // apple key mozilla
return true;
if (event.keyCode == '91') // apple key safari
return true;
return false;
}
function is_shift_key(event) {
if (event.shiftKey)
return true;
return false;
}*/
Selectable.prototype = { Selectable.prototype = {
push: function (element) { push: function (element) {
if (this.options.allow_multiple === true || !this.has(element)) { if (this.options.allow_multiple === true || !this.has(element)) {

View File

@@ -88,7 +88,7 @@ var prodModule = (function (p4, humane) {
$dialog.getDomElement().find('form').bind('submit.conbo', function () { $dialog.getDomElement().find('form').bind('submit.conbo', function () {
$(this).unbind('submit.conbo'); $(this).unbind('submit.conbo');
$dialog.Close(); $dialog.close();
return false; return false;
}); });
@@ -623,12 +623,10 @@ var prodModule = (function (p4, humane) {
}); });
function _resizeAll() { function _resizeAll() {
var body = $('#mainContainer'); var body = $('body');
bodySize.y = body.height(); bodySize.y = body.height();
bodySize.x = body.width(); bodySize.x = body.width();
$('.overlay').height(bodySize.y).width(bodySize.x);
var headBlockH = $('#headBlock').outerHeight(); var headBlockH = $('#headBlock').outerHeight();
var bodyY = bodySize.y - headBlockH - 2; var bodyY = bodySize.y - headBlockH - 2;
var bodyW = bodySize.x - 2; var bodyW = bodySize.x - 2;
@@ -845,7 +843,7 @@ var prodModule = (function (p4, humane) {
$('.tabs', dialog.getDomElement()).tabs(); $('.tabs', dialog.getDomElement()).tabs();
$('.close_button', dialog.getDomElement()).bind('click', function () { $('.close_button', dialog.getDomElement()).bind('click', function () {
dialog.Close(); dialog.close();
}); });
return false; return false;

View File

@@ -80,7 +80,7 @@
{% if app['conf'].get(['registry', 'actions', 'auth-required-for-export']) and app.getAuthenticatedUser().isGuest() %} {% if app['conf'].get(['registry', 'actions', 'auth-required-for-export']) and app.getAuthenticatedUser().isGuest() %}
<script type="text/javascript"> <script type="text/javascript">
dialogModule.dialog.get(1).Close(); dialogModule.dialog.get(1).close();
var $dialog = dialogModule.dialog.create({ var $dialog = dialogModule.dialog.create({
size : '500x100', size : '500x100',
closeOnEscape : true, closeOnEscape : true,
@@ -615,7 +615,7 @@
}); });
$('.close_button').bind('click',function(){ $('.close_button').bind('click',function(){
dialog.Close(); dialog.close();
}); });
/*define([ /*define([
@@ -676,7 +676,7 @@
} }
$('#download form').submit(); $('#download form').submit();
dialog.Close(); dialog.close();
}); });
$('#order .order_button').bind('click',function(){ $('#order .order_button').bind('click',function(){
@@ -714,7 +714,7 @@
if(!data.error) if(!data.error)
{ {
humane.info(data.msg); humane.info(data.msg);
dialog.Close(); dialog.close();
} else { } else {
humane.error(data.msg); humane.error(data.msg);
} }
@@ -751,7 +751,7 @@
if(data.success) { if(data.success) {
humane.info(data.message); humane.info(data.message);
dialog.Close(); dialog.close();
} else { } else {
var alert = dialogModule.dialog.create({ var alert = dialogModule.dialog.create({
size : 'Alert', size : 'Alert',
@@ -808,7 +808,7 @@
} }
$('#sendmail form').submit(); $('#sendmail form').submit();
dialog.Close(); dialog.close();
}); });
$('.datepicker', dialog.getDomElement()).datepicker({ $('.datepicker', dialog.getDomElement()).datepicker({

View File

@@ -178,7 +178,7 @@
<div id="dialog_dwnl" title="{{ 'action : exporter' | trans }}" style="display:none;"></div> <div id="dialog_dwnl" title="{{ 'action : exporter' | trans }}" style="display:none;"></div>
<script type="text/javascript"> <script type="text/javascript">
{% if basket.getValidation() %} {% if basket.getValidation() %}
p4.releasable = {% if basket.getValidation().getParticipant(app.getAuthenticatedUser()).isReleasable() %}"{{ 'Do you want to send your report ?' | trans }}"{% else %}false{% endif %} lightboxModule.setReleasable({% if basket.getValidation().getParticipant(app.getAuthenticatedUser()).isReleasable() %}"{{ 'Do you want to send your report ?' | trans }}"{% else %}false{% endif %});
{% endif %} {% endif %}
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -202,7 +202,7 @@
alert(data.message); alert(data.message);
} }
p4.WorkZone.refresh('current'); p4.WorkZone.refresh('current');
dialogModule.dialog.get(1).Close(); dialogModule.dialog.get(1).close();
return; return;
}, },

View File

@@ -29,7 +29,7 @@
}, },
success: function(data){ success: function(data){
$dialog = dialogModule.dialog.get(1).Close(); $dialog = dialogModule.dialog.get(1).close();
if(data.success) { if(data.success) {
humane.info(data.message); humane.info(data.message);
return p4.WorkZone.refresh(data.basket.id); return p4.WorkZone.refresh(data.basket.id);

View File

@@ -210,7 +210,7 @@
alert(data.message); alert(data.message);
} }
p4.WorkZone.refresh('current', null, false, 'story'); p4.WorkZone.refresh('current', null, false, 'story');
dialogModule.dialog.get(1).Close(); dialogModule.dialog.get(1).close();
return; return;
}, },

View File

@@ -188,11 +188,11 @@
data: {}, data: {},
success: function(datas){ success: function(datas){
if(datas.success) { if(datas.success) {
confirmBox.Close(); confirmBox.close();
$('form[name="BasketBrowser"]', $container).trigger('submit'); $('form[name="BasketBrowser"]', $container).trigger('submit');
p4.WorkZone.refresh(); p4.WorkZone.refresh();
} else { } else {
confirmBox.Close(); confirmBox.close();
var alertBox = dialogModule.dialog.create({ var alertBox = dialogModule.dialog.create({
size : 'Alert', size : 'Alert',
closeOnEscape : true, closeOnEscape : true,
@@ -203,7 +203,7 @@
} }
}, },
error: function() { error: function() {
confirmBox.Close(); confirmBox.close();
var alertBox = dialogModule.dialog.create({ var alertBox = dialogModule.dialog.create({
size : 'Alert', size : 'Alert',
closeOnEscape : true, closeOnEscape : true,

View File

@@ -157,10 +157,10 @@ $(function() {
data: {}, data: {},
success: function(datas){ success: function(datas){
if(datas.success) { if(datas.success) {
confirmBox.Close(); confirmBox.close();
pushModule.reloadBridge(managerUrl); pushModule.reloadBridge(managerUrl);
} else { } else {
confirmBox.Close(); confirmBox.close();
var alertBox = dialogModule.dialog.create({ var alertBox = dialogModule.dialog.create({
size : 'Alert', size : 'Alert',
closeOnEscape : true, closeOnEscape : true,

View File

@@ -151,7 +151,7 @@
var $dialogBox = $dialog.getDomElement(); var $dialogBox = $dialog.getDomElement();
$("button.cancel", $dialogBox).bind("click", function(){ $("button.cancel", $dialogBox).bind("click", function(){
$dialog.Close(); $dialog.close();
}); });
$("button.submiter", $dialogBox).bind("click", function(){ $("button.submiter", $dialogBox).bind("click", function(){
@@ -169,7 +169,7 @@
loader.show(); loader.show();
}, },
success: function(data){ success: function(data){
$dialog.Close(); $dialog.close();
}, },
complete: function(){ complete: function(){
$this.attr("disabled", false); $this.attr("disabled", false);

View File

@@ -59,7 +59,7 @@
var $dialogBox = $dialog.getDomElement(); var $dialogBox = $dialog.getDomElement();
$("button.cancel", $dialogBox).bind("click", function(){ $("button.cancel", $dialogBox).bind("click", function(){
$dialog.Close(); $dialog.close();
}); });
$("button.submiter", $dialogBox).bind("click", function(){ $("button.submiter", $dialogBox).bind("click", function(){
@@ -77,7 +77,7 @@
loader.show(); loader.show();
}, },
success: function(data){ success: function(data){
$dialog.Close(); $dialog.close();
}, },
complete: function(){ complete: function(){
$this.attr("disabled", false); $this.attr("disabled", false);

View File

@@ -383,7 +383,7 @@ $(document).ready(function(){
humane.error(data.message); humane.error(data.message);
}else{ }else{
var dialog = dialogModule.dialog.get(1); var dialog = dialogModule.dialog.get(1);
dialog.Close(); dialog.close();
} }
}, },
complete: function(){ complete: function(){
@@ -396,7 +396,7 @@ $(document).ready(function(){
$(".action_cancel", $scope).bind("click", function(){ $(".action_cancel", $scope).bind("click", function(){
var dialog = dialogModule.dialog.get(1); var dialog = dialogModule.dialog.get(1);
dialog.Close(); dialog.close();
return false; return false;
}); });
@@ -570,8 +570,8 @@ $(document).ready(function(){
if(data.success) if(data.success)
{ {
dialog.Close(); dialog.close();
dialogModule.dialog.get(1).Close(); dialogModule.dialog.get(1).close();
} }
else else
{ {

View File

@@ -35,7 +35,7 @@
var $cancelButton = $("button.cancel", $dialogBox); var $cancelButton = $("button.cancel", $dialogBox);
$cancelButton.bind("click", function(){ $cancelButton.bind("click", function(){
$dialog.Close(); $dialog.close();
}); });
$("button.submiter", $dialogBox).bind("click", function(){ $("button.submiter", $dialogBox).bind("click", function(){
@@ -56,7 +56,7 @@
loader.show(); loader.show();
}, },
success: function(data){ success: function(data){
$dialog.Close(); $dialog.close();
$.each(data,function(i,n){ $.each(data,function(i,n){
var imgt = $('#IMGT_'+n), var imgt = $('#IMGT_'+n),
chim = $('.CHIM_'+n), chim = $('.CHIM_'+n),

View File

@@ -110,7 +110,7 @@ function T_replaceBy2(f)
cancelButton: true, cancelButton: true,
buttons: { buttons: {
"Ok" : function() { "Ok" : function() {
confirmBox.Close(); confirmBox.close();
T_replaceCandidates_OK(); T_replaceCandidates_OK();
} }
} }
@@ -248,7 +248,7 @@ function T_replaceCandidates_OK()
trees.C._toReplace = null; trees.C._toReplace = null;
thesauShowWizard("wiz_0", false); thesauShowWizard("wiz_0", false);
replacingBox.Close(); replacingBox.close();
if(result.msg != '') if(result.msg != '')
{ {
@@ -346,10 +346,10 @@ function T_acceptCandidates_OK()
} }
trees.C._toAccept = null; trees.C._toAccept = null;
thesauShowWizard("wiz_0",false); thesauShowWizard("wiz_0",false);
acceptingBox.Close(); acceptingBox.close();
}, },
error:function(){acceptingBox.Close();}, error:function(){acceptingBox.close();},
timeout:function(){acceptingBox.Close();}, timeout:function(){acceptingBox.close();},
_ret: null // private alchemy _ret: null // private alchemy
}; };
@@ -387,7 +387,7 @@ function C_deleteCandidates_OK()
timeout:10*60*1000, // 10 minutes ! timeout:10*60*1000, // 10 minutes !
success: function(result, textStatus) success: function(result, textStatus)
{ {
deletingBox.Close(); deletingBox.close();
if(result.msg != '') if(result.msg != '')
{ {
@@ -451,7 +451,7 @@ function T_acceptCandidates(menuItem, menu, type)
cancelButton: true, cancelButton: true,
buttons: { buttons: {
"Ok" : function() { "Ok" : function() {
confirmBox.Close(); confirmBox.close();
T_acceptCandidates_OK(); T_acceptCandidates_OK();
} }
} }
@@ -573,7 +573,7 @@ function C_MenuOption(menuItem, menu, option, parm)
cancelButton: true, cancelButton: true,
buttons: { buttons: {
"Ok" : function() { "Ok" : function() {
confirmBox.Close(); confirmBox.close();
C_deleteCandidates_OK(); C_deleteCandidates_OK();
} }
} }
@@ -638,7 +638,7 @@ function Xclick(e)
{ {
tids.pop(); tids.pop();
var tid3 = tids.join('.'); var tid3 = tids.join('.');
if(!is_ctrl_key(e) && !is_shift_key(e)) if(!utilsModule.is_ctrl_key(e) && !utilsModule.is_shift_key(e))
{ {
$("LI", trees[type].tree).removeClass('selected'); $("LI", trees[type].tree).removeClass('selected');
p4.thesau.lastClickedCandidate = null; p4.thesau.lastClickedCandidate = null;