Create @options at first in constructor to have it accessible in @log if used before.

This commit is contained in:
Martin Edenhofer 2015-11-25 12:55:02 +01:00
parent 8df0a19cff
commit 8ea3f6b132
3 changed files with 66 additions and 66 deletions

View file

@ -73,6 +73,7 @@ do($ = window.jQuery, window) ->
return window.zammadChatTemplates[name](options) return window.zammadChatTemplates[name](options)
constructor: (options) -> constructor: (options) ->
@options = $.extend {}, @defaults, options
# check prerequisites # check prerequisites
if !window.WebSocket or !sessionStorage if !window.WebSocket or !sessionStorage
@ -80,12 +81,11 @@ do($ = window.jQuery, window) ->
@log 'notice', 'Chat: Browser not supported!' @log 'notice', 'Chat: Browser not supported!'
return return
if !options.chatId if !@options.chatId
@state = 'unsupported' @state = 'unsupported'
@log 'error', 'Chat: need chatId as option!' @log 'error', 'Chat: need chatId as option!'
return return
@options = $.extend {}, @defaults, options
@el = $(@view('chat')( @el = $(@view('chat')(
title: @options.title title: @options.title
)) ))

View file

@ -134,17 +134,17 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.view = bind(this.view, this); this.view = bind(this.view, this);
this.log = bind(this.log, this); this.log = bind(this.log, this);
this.T = bind(this.T, this); this.T = bind(this.T, this);
this.options = $.extend({}, this.defaults, options);
if (!window.WebSocket || !sessionStorage) { if (!window.WebSocket || !sessionStorage) {
this.state = 'unsupported'; this.state = 'unsupported';
this.log('notice', 'Chat: Browser not supported!'); this.log('notice', 'Chat: Browser not supported!');
return; return;
} }
if (!options.chatId) { if (!this.options.chatId) {
this.state = 'unsupported'; this.state = 'unsupported';
this.log('error', 'Chat: need chatId as option!'); this.log('error', 'Chat: need chatId as option!');
return; return;
} }
this.options = $.extend({}, this.defaults, options);
this.el = $(this.view('chat')({ this.el = $(this.view('chat')({
title: this.options.title title: this.options.title
})); }));
@ -683,6 +683,67 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return window.ZammadChat = ZammadChat; return window.ZammadChat = ZammadChat;
})(window.jQuery, window); })(window.jQuery, window);
if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {};
}
window.zammadChatTemplates["agent"] = function (__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
if (!__escape) {
__escape = __obj.escape = function(value) {
return ('' + value)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
}
(function() {
(function() {
if (this.agent.avatar) {
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
__out.push(__sanitize(this.agent.avatar));
__out.push('">\n');
}
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
__out.push(__sanitize(this.agent.name));
__out.push('</span>\n</span>');
}).call(this);
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
};
/*! /*!
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42): * "THE BEER-WARE LICENSE" (Revision 42):
@ -760,67 +821,6 @@ jQuery.fn.autoGrow = function(options) {
}); });
}; };
if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {};
}
window.zammadChatTemplates["agent"] = function (__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
if (!__escape) {
__escape = __obj.escape = function(value) {
return ('' + value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
}
(function() {
(function() {
if (this.agent.avatar) {
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
__out.push(__sanitize(this.agent.avatar));
__out.push('">\n');
}
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
__out.push(__sanitize(this.agent.name));
__out.push('</span>\n</span>');
}).call(this);
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
};
if (!window.zammadChatTemplates) { if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {}; window.zammadChatTemplates = {};
} }

File diff suppressed because one or more lines are too long