@@ -27,52 +27,71 @@ Class.create("AjxpMailer", {
27
27
res . loadCSSResource ( "plugins/core.mailer/AjxpMailer.css" ) ;
28
28
} ,
29
29
30
+ selectedLoginToSpan : function ( loginLabel , entryId , isGroup ) {
31
+ var field = this . _mailerPane . down ( '#tofield' ) ;
32
+ var fieldParent = this . _mailerPane . down ( '.mailer_tofield_line' ) ;
33
+ var el = new Element ( 'span' , {
34
+ className :'user' ,
35
+ 'data-entry_id' :entryId ,
36
+ 'data-is_group' :isGroup
37
+ } ) . update ( loginLabel + '<span class="icon-remove"></span>' ) ;
38
+
39
+ field . insert ( { before : el } ) ;
40
+ el . down ( '.icon-remove' ) . observe ( 'click' , el . remove . bind ( el ) ) ;
41
+ field . setValue ( '' ) ;
42
+ var offset = Element . positionedOffset ( field ) ;
43
+ var height = fieldParent . getHeight ( ) - parseInt ( fieldParent . getStyle ( 'marginBottom' ) ) - parseInt ( fieldParent . getStyle ( 'marginTop' ) ) - 5 ;
44
+ if ( ! fieldParent . ORIGINAL_HEIGHT ) fieldParent . ORIGINAL_HEIGHT = fieldParent . getHeight ( ) ;
45
+ if ( offset . top >= height ) {
46
+ fieldParent . setStyle ( { height : ( parseInt ( fieldParent . getHeight ( ) ) + fieldParent . ORIGINAL_HEIGHT ) + 'px' } ) ;
47
+ } else if ( offset . top < ( height - fieldParent . ORIGINAL_HEIGHT ) ) {
48
+ fieldParent . setStyle ( { height : ( parseInt ( fieldParent . getHeight ( ) ) - fieldParent . ORIGINAL_HEIGHT ) + 'px' } ) ;
49
+ }
50
+ field . focus ( ) ;
51
+ } ,
52
+
30
53
buildMailPane :function ( subject , body , recipientsList , paneTitle ) {
31
54
if ( ! $ ( "mailer_message" ) ) {
32
55
$ ( document . body ) . insert ( "<div id='mailer_message'></div>" ) ;
33
56
}
34
- var recipientString = '' ;
35
- var hiddenRecipientString = [ ] ;
36
- var hiddenGroupsString = [ ] ;
37
- if ( recipientsList ) {
38
- recipientsList . select ( "div.user_entry" ) . each ( function ( el ) {
39
- recipientString += el . down ( "span.user_entry_label" ) . innerHTML + ", " ;
40
- if ( el . hasClassName ( "group_entry" ) ) {
41
- hiddenGroupsString . push ( el . getAttribute ( "data-entry_id" ) ) ;
42
- } else {
43
- hiddenRecipientString . push ( el . getAttribute ( "data-entry_id" ) ) ;
44
- }
45
- } ) ;
46
- recipientString = recipientString . substring ( 0 , recipientString . length - 2 ) ;
47
- hiddenGroupsString = hiddenGroupsString . join ( "," ) ;
48
- hiddenRecipientString = hiddenRecipientString . join ( "," ) ;
49
- }
50
57
var fromString = ajaxplorer . user . id ;
51
- $ ( "mailer_message" ) . update ( "<div id='mailer_message' style='position: relative;'><div id='emails_autocomplete' style='position:absolute'></div><div class='message_body'><form>" +
58
+ $ ( "mailer_message" ) . update ( "<div id='mailer_message' style='position: relative;'><div id='emails_autocomplete' style='position:absolute;z-index:1200; '></div><div class='message_body'><form>" +
52
59
"<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>From:</span><input class='mailer_input_field' type='text' name='from' value='" + fromString + "'/></div>" +
53
- "<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>To:</span><input class='mailer_input_field' type='text' name='to' id='tofield' value='" + recipientString + " '/></div>" +
60
+ "<div class='grey_gradient_light_inputs mailer_input_line mailer_tofield_line '><span class='mailer_input_label' style='float: left;' >To:</span><input class='mailer_input_field' type='text' name='to' id='tofield' value=''/></div>" +
54
61
"<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>Subject:</span><input class='mailer_input_field' type='text' name='subject' value='" + subject + "'/></div>" +
55
62
"<textarea name='message' class='grey_gradient_light_inputs'>" + body + "</textarea>" +
56
- "<input type='hidden' name='users_ids' value='" + hiddenRecipientString + "'/> " +
57
- "<input type='hidden' name='groups_ids' value='" + hiddenGroupsString + "'/> " +
58
63
"</form></div></div>" ) ;
59
64
if ( paneTitle ) {
60
65
$ ( "mailer_message" ) . insert ( { top :new Element ( "div" , { className :"dialogContentMainTitle" } ) . update ( paneTitle ) } ) ;
61
66
}
62
67
63
68
this . _mailerPane = $ ( "mailer_message" ) ;
64
69
70
+ if ( recipientsList ) {
71
+ recipientsList . select ( "div.user_entry" ) . each ( function ( el ) {
72
+ var loginLabel = el . down ( "span.user_entry_label" ) . innerHTML ;
73
+ this . selectedLoginToSpan ( loginLabel , el . getAttribute ( "data-entry_id" ) , el . hasClassName ( "group_entry" ) ) ;
74
+ } . bind ( this ) ) ;
75
+ }
76
+
65
77
this . _autocompleter = new AjxpUsersCompleter (
66
78
this . _mailerPane . down ( '#tofield' ) ,
67
79
null ,
68
80
this . _mailerPane . down ( '#emails_autocomplete' ) ,
69
81
{
70
82
tmpUsersPrefix :'' ,
71
83
usersOnly : true ,
84
+ existingOnly : true ,
72
85
updateUserEntryAfterCreate :null ,
73
86
createUserPanel :null ,
74
87
indicator : null ,
75
- minChars :parseInt ( ajaxplorer . getPluginConfigs ( "conf" ) . get ( "USERS_LIST_COMPLETE_MIN_CHARS" ) )
88
+ minChars :parseInt ( ajaxplorer . getPluginConfigs ( "conf" ) . get ( "USERS_LIST_COMPLETE_MIN_CHARS" ) ) ,
89
+ afterUpdateElement : function ( elem , selectedLi ) {
90
+ this . selectedLoginToSpan (
91
+ selectedLi . readAttribute ( 'data-label' ) ,
92
+ selectedLi . readAttribute ( 'data-entry_id' ) ,
93
+ selectedLi . hasClassName ( 'group_entry' ) ) ;
94
+ } . bind ( this )
76
95
}
77
96
) ;
78
97
@@ -85,6 +104,11 @@ Class.create("AjxpMailer", {
85
104
this . _mailerPane . down ( "form" ) . getElements ( ) . each ( function ( el ) {
86
105
params . set ( el . name , el . getValue ( ) ) ;
87
106
} ) ;
107
+ var aa = [ ] ;
108
+ this . _mailerPane . down ( ".mailer_tofield_line" ) . select ( 'span.user' ) . each ( function ( el ) {
109
+ aa . push ( el . readAttribute ( 'data-entry_id' ) ) ;
110
+ } ) ;
111
+ params . set ( 'emails[]' , aa ) ;
88
112
var connexion = new Connexion ( ) ;
89
113
connexion . setMethod ( "post" ) ;
90
114
connexion . setParameters ( params ) ;
0 commit comments