MailPoet Newsletters (Previous) - Version 2.7.3

Version Description

  • 2016-08-08 =
  • Fixed issue with emoji when saving newsletters
  • Prevent encoding of "tel:" URLs
  • Fixed SQL injection vulnerability (Thanks to Force Interactive)
  • Fixed XSS vulnerability (Thanks to Sipke Mellema from Securify B.V.)
  • Fixed PHP warnings on Bounce management
  • Escape commma and quote marks during export
  • Fixed some editor issues
  • Fixed double signed DKIM emails
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (Previous)
Version 2.7.3
Comparing to
See all releases

Code changes from version 2.7.2 to 2.7.3

classes/WJ_Export.php CHANGED
@@ -173,6 +173,12 @@ class WJ_Export extends WYSIJA_object {
173
 
174
  // append content to the file
175
  foreach ( $data as $k => $row ) {
 
 
 
 
 
 
176
  $row_string = implode( $this->_fields_separator, $row );
177
  $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
178
  fwrite( $this->_file_handle, $encoded_string . ( $rows_count !== $k ? $this->_lines_separator : '' ) );
173
 
174
  // append content to the file
175
  foreach ( $data as $k => $row ) {
176
+ $row = array_map(function($value) {
177
+ $value = str_replace('"', '""', $value);
178
+ return (preg_match('/,/', $value)) ?
179
+ '"' . $value . '"' :
180
+ $value;
181
+ }, $row);
182
  $row_string = implode( $this->_fields_separator, $row );
183
  $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
184
  fwrite( $this->_file_handle, $encoded_string . ( $rows_count !== $k ? $this->_lines_separator : '' ) );
controllers/ajax/subscribers.php CHANGED
@@ -9,7 +9,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_front{
9
  parent::__construct();
10
  $data=array();
11
  foreach($_REQUEST['data'] as $vals){
12
- $data[$vals['name']]=$vals['value'];
13
  }
14
  if(isset($data['message_success'])){
15
  $this->messages['insert'][true]=$data['message_success'];
@@ -27,9 +27,9 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_front{
27
  $i=0;
28
  foreach($_REQUEST['data'] as $vals){
29
  if($vals['name']=='wysija[user_list][list_id][]'){
30
- $datarequested[str_replace('wysija[user_list][list_id][]', 'wysija[user_list][list_id]['.$i.']', $vals['name'])]=$vals['value'];
31
  $i++;
32
- }else $datarequested[$vals['name']]=$vals['value'];
33
  }
34
 
35
  $data=$this->convertUserData($datarequested);
9
  parent::__construct();
10
  $data=array();
11
  foreach($_REQUEST['data'] as $vals){
12
+ $data[esc_sql($vals['name'])]=esc_sql($vals['value']);
13
  }
14
  if(isset($data['message_success'])){
15
  $this->messages['insert'][true]=$data['message_success'];
27
  $i=0;
28
  foreach($_REQUEST['data'] as $vals){
29
  if($vals['name']=='wysija[user_list][list_id][]'){
30
+ $datarequested[str_replace('wysija[user_list][list_id][]', 'wysija[user_list][list_id]['.$i.']', esc_sql($vals['name']))]=esc_sql($vals['value']);
31
  $i++;
32
+ }else $datarequested[esc_sql($vals['name'])]=esc_sql($vals['value']);
33
  }
34
 
35
  $data=$this->convertUserData($datarequested);
core/base.php CHANGED
@@ -19,7 +19,7 @@ class WYSIJA_object{
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
- static $version = '2.7.2';
23
 
24
  function __construct(){}
25
 
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
+ static $version = '2.7.3';
23
 
24
  function __construct(){}
25
 
helpers/bounce.php CHANGED
@@ -190,7 +190,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
190
 
191
  function getMessage($msgNB) {
192
  if ($this->usepear) {
193
- $message = null;
194
  $message->headerString = $this->mailbox->getRawHeaders($msgNB);
195
  if (empty($message->headerString))
196
  return false;
@@ -234,11 +234,11 @@ class WYSIJA_help_bounce extends WYSIJA_help {
234
  $this->_message->text = '';
235
  $this->_message->html = $this->mailbox->getBody($this->_message->messageNB);
236
  $this->_message->subject = $this->_decodeHeader($this->_message->headerinfo['subject']);
237
- $this->_message->header->sender_email = @$this->_message->headerinfo['return-path'];
238
  if (is_array($this->_message->header->sender_email))
239
- $this->_message->header->sender_email = reset($this->_message->header->sender_email);
240
  if (preg_match($this->detectEmail, $this->_message->header->sender_email, $results)) {
241
- $this->_message->header->sender_email = $results[0];
242
  }
243
  $this->_message->header->sender_name = (isset($this->_message->headerinfo['from'])) ? strip_tags(@$this->_message->headerinfo['from']) : '';
244
  $this->_message->header->reply_to_email = $this->_message->header->sender_email;
@@ -1033,7 +1033,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
1033
  if (!empty($this->_message->text))
1034
  $email_saved_as_array[] = 'TEXT_VERSION::' . nl2br(htmlentities($this->_message->text));
1035
  $this->_message->header->reply_to_name = (property_exists($this->_message->header, 'reply_to_name')) ? $this->_message->header->reply_to_name : '';
1036
- $this->_message->header->from_name = (property_exists($this->_message->header, 'from_name')) ? $this->_message->header->from_name : '';
1037
  $email_saved_as_array[] = 'REPLYTO_ADDRESS::' . $this->_message->header->reply_to_name . ' ( ' . $this->_message->header->reply_to_email . ' )';
1038
  $email_saved_as_array[] = 'FROM_ADDRESS::' . $this->_message->header->from_name . ' ( ' . $this->_message->header->from_email . ' )';
1039
  $email_saved_as_array[] = print_r($this->_message->headerinfo, true);
@@ -1063,7 +1063,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
1063
  //original-rcpt-to ? http://tools.ietf.org/html/rfc5965
1064
  $this->mailer->Body .= print_r($this->_message->headerinfo, true);
1065
  $this->_message->header->reply_to_name = (property_exists($this->_message->header, 'reply_to_name')) ? $this->_message->header->reply_to_name : '';
1066
- $this->_message->header->from_name = (property_exists($this->_message->header, 'from_name')) ? $this->_message->header->from_name : '';
1067
  $this->mailer->AddReplyTo($this->_message->header->reply_to_email, $this->_message->header->reply_to_name);
1068
  $this->mailer->setFrom($this->_message->header->from_email, $this->_message->header->from_name);
1069
  if ($this->mailer->send()) {
190
 
191
  function getMessage($msgNB) {
192
  if ($this->usepear) {
193
+ $message = new \stdClass;
194
  $message->headerString = $this->mailbox->getRawHeaders($msgNB);
195
  if (empty($message->headerString))
196
  return false;
234
  $this->_message->text = '';
235
  $this->_message->html = $this->mailbox->getBody($this->_message->messageNB);
236
  $this->_message->subject = $this->_decodeHeader($this->_message->headerinfo['subject']);
237
+ $this->_message->header->sender_email = (isset($this->_message->headerinfo['return-path'])) ? $this->_message->headerinfo['return-path'] : '';
238
  if (is_array($this->_message->header->sender_email))
239
+ $this->_message->header->sender_email = reset($this->_message->header->sender_email);
240
  if (preg_match($this->detectEmail, $this->_message->header->sender_email, $results)) {
241
+ $this->_message->header->sender_email = $results[0];
242
  }
243
  $this->_message->header->sender_name = (isset($this->_message->headerinfo['from'])) ? strip_tags(@$this->_message->headerinfo['from']) : '';
244
  $this->_message->header->reply_to_email = $this->_message->header->sender_email;
1033
  if (!empty($this->_message->text))
1034
  $email_saved_as_array[] = 'TEXT_VERSION::' . nl2br(htmlentities($this->_message->text));
1035
  $this->_message->header->reply_to_name = (property_exists($this->_message->header, 'reply_to_name')) ? $this->_message->header->reply_to_name : '';
1036
+ $this->_message->header->from_name = (property_exists($this->_message->header, 'from_name')) ? $this->_message->header->from_name : '';
1037
  $email_saved_as_array[] = 'REPLYTO_ADDRESS::' . $this->_message->header->reply_to_name . ' ( ' . $this->_message->header->reply_to_email . ' )';
1038
  $email_saved_as_array[] = 'FROM_ADDRESS::' . $this->_message->header->from_name . ' ( ' . $this->_message->header->from_email . ' )';
1039
  $email_saved_as_array[] = print_r($this->_message->headerinfo, true);
1063
  //original-rcpt-to ? http://tools.ietf.org/html/rfc5965
1064
  $this->mailer->Body .= print_r($this->_message->headerinfo, true);
1065
  $this->_message->header->reply_to_name = (property_exists($this->_message->header, 'reply_to_name')) ? $this->_message->header->reply_to_name : '';
1066
+ $this->_message->header->from_name = (property_exists($this->_message->header, 'from_name')) ? $this->_message->header->from_name : '';
1067
  $this->mailer->AddReplyTo($this->_message->header->reply_to_email, $this->_message->header->reply_to_name);
1068
  $this->mailer->setFrom($this->_message->header->from_email, $this->_message->header->from_name);
1069
  if ($this->mailer->send()) {
helpers/mailer.php CHANGED
@@ -169,7 +169,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
169
  //$this->Hostname = '';
170
  $this->WordWrap = 150;
171
 
172
- if($this->config->getValue('dkim_active') && $this->config->getValue('dkim_pubk') && !$this->isElasticRest && !$this->isSendGridRest && $this->Mailer !='mailpoet' || $this->Mailer !='sparkpost'){
173
  // check that server can sign emails
174
  if(!function_exists('openssl_sign')){
175
  $this->error(__('You cannot use the DKIM signature option...',WYSIJA).' '.__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
@@ -939,7 +939,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
939
  function tracker_replaceusertags($email,$user){
940
  $urls = array();
941
  $results = array();// collect all links in email
942
- if(!preg_match_all('#href[ ]*=[ ]*"(?!mailto:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:)([^"]+)"#Ui',$email->body,$results)) return;
943
 
944
  $modelConf=WYSIJA::get('config','model');
945
 
169
  //$this->Hostname = '';
170
  $this->WordWrap = 150;
171
 
172
+ if($this->config->getValue('dkim_active') && $this->config->getValue('dkim_pubk') && !$this->isElasticRest && !$this->isSendGridRest && $this->Mailer !== 'mailpoet' && $this->Mailer !== 'sparkpost'){
173
  // check that server can sign emails
174
  if(!function_exists('openssl_sign')){
175
  $this->error(__('You cannot use the DKIM signature option...',WYSIJA).' '.__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
939
  function tracker_replaceusertags($email,$user){
940
  $urls = array();
941
  $results = array();// collect all links in email
942
+ if(!preg_match_all('#href[ ]*=[ ]*"(?!mailto:|tel:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:)([^"]+)"#Ui',$email->body,$results)) return;
943
 
944
  $modelConf=WYSIJA::get('config','model');
945
 
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters or automated emails. Capture subscribers with a widget. Import and manage your lists. MailPoet is a sweet plugin maintained and supported with love.
6
- Version: 2.7.2
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters or automated emails. Capture subscribers with a widget. Import and manage your lists. MailPoet is a sweet plugin maintained and supported with love.
6
+ Version: 2.7.3
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
js/base-script-64.js CHANGED
@@ -1 +1 @@
1
- var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=Base64._utf8_encode(r);C<r.length;)t=r.charCodeAt(C++),e=r.charCodeAt(C++),o=r.charCodeAt(C++),a=t>>2,h=(3&t)<<4|e>>4,n=(15&e)<<2|o>>6,c=63&o,isNaN(e)?n=c=64:isNaN(o)&&(c=64),d=d+this._keyStr.charAt(a)+this._keyStr.charAt(h)+this._keyStr.charAt(n)+this._keyStr.charAt(c);return d},decode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");C<r.length;)a=this._keyStr.indexOf(r.charAt(C++)),h=this._keyStr.indexOf(r.charAt(C++)),n=this._keyStr.indexOf(r.charAt(C++)),c=this._keyStr.indexOf(r.charAt(C++)),t=a<<2|h>>4,e=(15&h)<<4|n>>2,o=(3&n)<<6|c,d+=String.fromCharCode(t),64!=n&&(d+=String.fromCharCode(e)),64!=c&&(d+=String.fromCharCode(o));return d=Base64._utf8_decode(d)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);128>o?t+=String.fromCharCode(o):o>127&&2048>o?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)o=r.charCodeAt(e),128>o?(t+=String.fromCharCode(o),e++):o>191&&224>o?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
1
+ var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",utoa:function(r){return window.btoa(unescape(encodeURIComponent(r)))},atou:function(r){return decodeURIComponent(escape(window.atob(r)))},encode:function(r){if(window.btoa)return this.utoa(r);var t,e,o,n,a,c,h,d="",i=0;for(r=Base64._utf8_encode(r);i<r.length;)t=r.charCodeAt(i++),e=r.charCodeAt(i++),o=r.charCodeAt(i++),n=t>>2,a=(3&t)<<4|e>>4,c=(15&e)<<2|o>>6,h=63&o,isNaN(e)?c=h=64:isNaN(o)&&(h=64),d=d+this._keyStr.charAt(n)+this._keyStr.charAt(a)+this._keyStr.charAt(c)+this._keyStr.charAt(h);return d},decode:function(r){if(window.btoa)return this.atoa(r);var t,e,o,n,a,c,h,d="",i=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");i<r.length;)n=this._keyStr.indexOf(r.charAt(i++)),a=this._keyStr.indexOf(r.charAt(i++)),c=this._keyStr.indexOf(r.charAt(i++)),h=this._keyStr.indexOf(r.charAt(i++)),t=n<<2|a>>4,e=(15&a)<<4|c>>2,o=(3&c)<<6|h,d+=String.fromCharCode(t),64!=c&&(d+=String.fromCharCode(e)),64!=h&&(d+=String.fromCharCode(o));return d=Base64._utf8_decode(d)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);128>o?t+=String.fromCharCode(o):o>127&&2048>o?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)o=r.charCodeAt(e),128>o?(t+=String.fromCharCode(o),e++):o>191&&224>o?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
js/wysija-editor.js CHANGED
@@ -1,3 +1,3 @@
1
  "use strict";function info(t){if(Wysija.options.verbose!==!1){window.console&&console.log||!function(){for(var t=function(){},e=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"],i=e.length,s=window.console={};i--;)s[e[i]]=t}();try{console.log("[INFO] "+t)}catch(e){}}}Object.extend(Prototype.Browser,{ie6:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&6===Number(RegExp.$1)?!0:!1,ie7:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&7===Number(RegExp.$1)?!0:!1,ie8:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&8===Number(RegExp.$1)?!0:!1,ie9:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&9===Number(RegExp.$1)?!0:!1}),Event.cacheDelegated={},Object.extend(document,function(){function t(t){return o[t]=o[t]||{}}function e(e,i){var s=t(e);return s[i]=s[i]||[]}function i(t,i,s){var n=e(t,i);return n.find(function(t){return t.handler===s})}function s(e,s,n){var o=t(e);if(!o[s])return!1;var a=i(e,s,n);return o[s]=o[s].without(a),a}function n(t,i,s,n){var o,a=e(t,i);return a.pluck("handler").include(s)?!1:(o=function(e){var i=e.findElement(t);i&&s.call(n||i,e,i)},o.handler=s,a.push(o),o)}var o=Event.cacheDelegated;return{delegate:function(t,e){var i=n.apply(null,arguments);return i&&document.observe(e,i),document},stopDelegating:function(i,n){var a=arguments.length;switch(a){case 2:e(i,n).each(function(t){document.stopDelegating(i,n,t.handler)});break;case 1:Object.keys(t(i)).each(function(t){document.stopDelegating(i,t)});break;case 0:Object.keys(o).each(function(t){document.stopDelegating(t)});break;default:var r=s.apply(null,arguments);r&&document.stopObserving(n,r)}return document}}}());var Observable=function(){function t(t,e){return t=t.substring(2),e&&(t=e+":"+t),t.underscore().split("_").join(":")}function e(e){var s=e.prototype,n=s.namespace;return Object.keys(s).grep(/^on/).inject($H(),function(o,a){return"onDomLoaded"===a?o:(o.set(t(a,n),i(s[a],e)),o)})}function i(t,e){return function(i){return t.call(new e(this),i,i.memo)}}function s(t,e){$$(t).each(function(t){new e(t).onDomLoaded()})}return{observe:function(t){if(this.handlers||(this.handlers={}),!this.handlers[t]){var i=this;this.prototype.onDomLoaded&&(document.loaded?s(t,i):document.observe("dom:loaded",s.curry(t,i))),this.handlers[t]=e(i).each(function(e){document.delegate(t,e.key,e.value)})}},stopObserving:function(t){this.handlers&&this.handlers[t]&&(this.handlers[t].each(function(e){document.stopDelegating(t,e.key,e.value)}),delete this.handlers[t])}}}();Object.extend(Droppables,{deactivate:Droppables.deactivate.wrap(function(t,e,i){return e.onLeave&&e.onLeave(i,e.element),t(e)}),activate:Droppables.activate.wrap(function(t,e,i){return e.onEnter&&e.onEnter(i,e.element),t(e)}),togglePlaceholders:function(t,e){if(0!==this.drops.length&&!($$(".block_placeholder.hover, .text_placeholder.hover, .image_placeholder.hover").length>0)){var i=document.viewport.getDimensions(),s=document.viewport.getScrollOffsets();this.drops.each(function(n){if(void 0===n.overlap){var o=!1,a=n.element.cumulativeOffset(),r=Math.max(30,n.element.getHeight()),l=t.element.hasClassName("image"),h=t.element.hasClassName("text");if(a.top>s.top+i.height)return;if(a.top<s.top&&a.top+r<s.top)return;if(l===!1&&-1!==n.accept.indexOf("image"))return;if(h===!1&&-1!==n.accept.indexOf("text"))return;if(l===!0){if(-1!==n.accept.indexOf("text"))return;if(t.element.readAttribute("wysija_src")===n.element.readAttribute("wysija_src"))return}var c=a.top-2*Wysija.options.blockDropTreshold,m=a.top+r+Wysija.options.blockDropTreshold;c<e.pageY&&e.pageY<m&&(o=!0);var d=n.element.up();o===!0?(d&&d.addClassName("active"),n.element.addClassName("active")):(d&&d.removeClassName("active"),n.element.removeClassName("active"))}})}},hidePlaceholders:function(){0!==this.drops.length&&$$(".block_placeholder.active, .text_placeholder.active, .image_placeholder.active, .wysija_image.active").invoke("removeClassName","active")}});var Wysija={version:"2.3",options:{debug:!1,verbose:!1,css:"wj_css",toolbar:"wysija_toolbar",notices:"wysija_notices",wrapper:"wysija_wrapper",container:"wysija_container",header:"wysija_header",body:"wysija_body",footer:"wysija_footer",blockDropTreshold:30,imageDropTreshold:30,minTextPlaceholderWidth:45},toolbar:{effect:null,x:null,y:null,top:null,left:null},scroll:{top:0,left:0},locks:{dragging:!1,selectingColor:!1,showingTools:!1},flags:{displayImages:!0,doSave:!1},defaults:{contentAlignment:"left",imageAlignment:"center",galleryAlignment:"center"},autoSave:function(){Wysija.flags.doSave===!1&&(Wysija.flags.doSave=!0)},save:function(){var t,e=1,i={},s=$H();s.set("version",Wysija.version);var n=Wysija.getHeader();i=n.block.save(),i.type="header",s.set("header",i);var o=$H();Wysija.getBlocks().each(function(s){t=s.block,t.save&&(i=t.save(),null!==i&&(i.position=e,i.type=s.elementType,i.background_color=t.element.readAttribute("wysija_bg_color"),o.set("block-"+e,i),e++))}),s.set("body",o);var a=Wysija.getFooter();return i=a.block.save(),i.type="footer",s.set("footer",i),Object.toJSON(s).gsub('\\"','"').gsub('"[{',"[{").gsub('}]"',"}]")},blockDropOptions:{accept:$w("wysija_widget"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={},s=null;i.elementType=t.readAttribute("wysija_type"),i.element=t,"image"===i.elementType?(i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,s=t.readAttribute("wysija_parent"),null!==$(s)&&(i.elementData=Wysija.get($(s)).block.image.getData())):"divider"===i.elementType?(i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height")):"text"===i.elementType&&(i.elementText=Wysija_i18n.clickToEditText),e.fire("item:drop",i),$(e).removeClassName("hover"),null!==$(s)&&(s=Wysija.get($(s)),s.block.image.removeImage())}},imageDropOptions:{accept:$w("image"),onEnter:function(t,e){$(e).addClassName("hover"),($(e).up(".wysija_block")||$(e).up(".wysija_header")||$(e).up(".wysija_footer")).addClassName("image_hover")},onLeave:function(t,e){$(e).removeClassName("hover"),$$(".image_hover").invoke("removeClassName","image_hover")},onDrop:function(t,e){if(e.readAttribute("wysija_src")===t.readAttribute("wysija_src"))return Wysija.hideTools(),!1;var i={},s=t.readAttribute("wysija_parent");i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,null!==$(s)&&(s=Wysija.get($(s)),i.elementData=s.block.image.getData()),e.fire("image:drop",i),$(e).removeClassName("hover"),null!==$(s)&&s.block.image.removeImage()}},textDropOptions:{accept:$w("text"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={};i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementText=Wysija_i18n.clickToEditText,e.fire("text:drop",i),$(e).removeClassName("hover")}},instances:{},get:function(t,e){void 0===e&&(e="block");var i=t.identify(),s=Wysija.instances[i]||new(Wysija[e.capitalize().camelize()])(i);return Wysija.instances[i]=s,s},getTheme:function(){var t=$("wysija_widgets_settings").down(".theme");return void 0!==t&&t.innerHTML.length>0?t.innerHTML:"default"},getHeader:function(){return Wysija.get(Wysija.getHeaderElement(),"header")},getHeaderElement:function(){return $$("div.wysija_header")[0]},getFooter:function(){return Wysija.get(Wysija.getFooterElement(),"footer")},getFooterElement:function(){return $$("div.wysija_footer")[0]},getBlocks:function(){return Wysija.getBlockElements().map(function(t){return Wysija.get(t)})},getBlockElements:function(){return $$("div.wysija_block")},startBlockPositions:function(t,e){e.element.hasClassName("wysija_block")&&(Wysija.locks.dragging=!0,Wysija.hideEditors())},setScrollOffsets:function(){Wysija.scroll=document.viewport.getScrollOffsets()},setBlockPositions:function(t,e){Wysija.locks.dragging=!1;var i=1;Wysija.getBlocks().each(function(t){t.setPosition(i++),t.block.element.setStyle({zIndex:""});var e=$$(".block_placeholder[data-parent="+t.block.element.identify()+"]").first();void 0!==e&&t.block.element.insert({before:e})}),void 0!==e&&$$(".wysija_auto-post").length>1&&"auto-post"===e.element.readAttribute("wysija_type")&&(Wysija.initAutoPost(),Wysija.setBackgroundColors()),Wysija.autoSave()},init:function(){Wysija.setScrollOffsets(),Wysija.getHeader(),Wysija.getFooter(),Wysija.makeDroppable(),Wysija.makeSortable(),Wysija.hideControls(),Wysija.hideTools(),Wysija.hideSettings(),Wysija.setSettingsPosition(),Wysija.initSettings(),Wysija.initAutoPost(),Wysija.setBackgroundColors(),Wysija.setToolbarPosition(),Wysija.setImagesDisplay()},initToolbarPosition:function(){null===Wysija.toolbar.top&&(Wysija.toolbar.top=parseInt($(Wysija.options.wrapper).positionedOffset().top)),null===Wysija.toolbar.left&&(Wysija.toolbar.left=parseInt($(Wysija.options.wrapper).positionedOffset().left)),null===Wysija.toolbar.x&&(Wysija.toolbar.x=parseInt(Wysija.toolbar.left+$(Wysija.options.wrapper).getDimensions().width+15)),Wysija.toolbar.y=parseInt(Wysija.scroll.top>=Wysija.toolbar.top-20?20+Wysija.scroll.top:Wysija.toolbar.top+Wysija.scroll.top)},setToolbarPosition:function(){Wysija.initToolbarPosition(),$(Wysija.options.toolbar).setStyle({top:Wysija.toolbar.y+"px",left:Wysija.toolbar.x+"px",opacity:0}).appear({duration:.5}),$(Wysija.options.notices).hide()},updateToolbarPosition:function(){Wysija.initToolbarPosition(),null!==Wysija.toolbar.effect&&Wysija.toolbar.effect.cancel(),Wysija.scroll.top>=Wysija.toolbar.top-20?(Wysija.toolbar.y=parseInt(20+Wysija.scroll.top),Wysija.toolbar.effect=new Effect.Move(Wysija.options.toolbar,{x:Wysija.toolbar.x,y:Wysija.toolbar.y,mode:"absolute",duration:.2})):$(Wysija.options.toolbar).setStyle({left:Wysija.toolbar.x+"px",top:Wysija.toolbar.top+"px"})},editorCleanup:function(t,e){switch(t){case"get_from_editor":e=e.gsub(/<h1><\/h1>/,"<br />"),e=e.gsub(/<h2><\/h2>/,"<br />"),e=e.gsub(/<h3><\/h3>/,"<br />"),e=e.gsub(/<p><\/p>/,"<p>&nbsp;</p>");break;case"insert_to_editor":break;case"submit_content":break;case"get_from_editor_dom":break;case"insert_to_editor_dom":break;case"setup_content_dom":break;case"submit_content_dom":}return e},updateCSSColor:function(t,e){var i=[],s="color",n=$(Wysija.options.css).innerHTML.strip();switch(t.endsWith("BgColorInput")&&(s="background-color"),e=""===e?"transparent":"#"+e,t){case"bodyColorInput":i.push("wysija_editable"),i.push("wysija_editable ul li"),i.push("wysija_editable ol li");break;case"h1ColorInput":i.push("wysija_editable h1");break;case"h2ColorInput":i.push("wysija_editable h2");break;case"h3ColorInput":i.push("wysija_editable h3");break;case"linksColorInput":i.push("wysija_editable a"),i.push("wysija_editable h1 a"),i.push("wysija_editable h2 a"),i.push("wysija_editable h3 a");break;case"unsubscribeColorInput":i.push("wysija_unsubscribe p");break;case"viewbrowserColorInput":i.push("wysija_viewbrowser p");break;case"htmlBgColorInput":i.push("wysija_wrapper");break;case"headerBgColorInput":i.push("wysija_header");break;case"bodyBgColorInput":i.push("wysija_body");break;case"footerBgColorInput":i.push("wysija_footer")}i.length>0&&null!==s&&(i.each(function(t){var i=new RegExp("([\\.|#]"+t+".*?{.*?"+s+":\\s*)(#?[a-z0-9]*)*(.*?})","i");n=n.replace(i,"$1"+e+"$3")}),n.length>0&&Wysija.updateCSS(n))},updateCSS:function(t){void 0!==$(Wysija.options.css)&&$(Wysija.options.css).remove();var e=document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Wysija.options.css,i.type="text/css",i.styleSheet?i.innerHTML=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},setTextStyles:function(t){var e=t.editorId+"_ifr",i=$(e);if(null!==i&&(i.doc=null,i.contentDocument?i.doc=i.contentDocument:i.contentWindow?i.doc=i.contentWindow.document:i.document&&(i.doc=i.document),null!==i.doc)){var s=i.doc.getElementsByTagName("head")[0],n=i.doc.createElement("style"),o=$(Wysija.options.css).innerHTML.strip();n.type="text/css",n.id="wj_iframe_css",n.styleSheet?n.innerHTML=o:n.appendChild(document.createTextNode(o)),s.appendChild(n)}},setBackgroundColors:function(){Wysija.getBlocks().invoke("setBackgroundColor"),$$(".wysija_auto-post .wysija_content, .wysija_auto-post .wysija_divider .wysija_raw").each(function(t){var e=t.readAttribute("wysija_bg_color");""===e?t.setStyle({backgroundColor:"transparent"}):null!==e&&t.setStyle({backgroundColor:"#"+e})})},hideBlockControls:function(){$$(".wysija_controls").invoke("hide"),this.getBlockElements().invoke("removeClassName","hover")},hideEditors:function(){tinymce.editors.length>0&&Wysija.getBlocks().each(function(t){"content"===t.elementType&&null!==t.block.contents&&t.block.contents.disableEditor()})},hideControls:function(){return Wysija.getBlocks().invoke("hideControls")},hideTools:function(){$$(".resize-controls").invoke("hide"),$$(".wysija_tools").invoke("hide"),Wysija.locks.showingTools=!1},makeDroppable:function(){Droppables.add("block_placeholder",Wysija.blockDropOptions)},makeSortable:function(){var t=$(Wysija.options.body);Sortable.create(t,{tag:"div",only:"wysija_block",scroll:window,handle:"handle",constraint:"vertical"}),Draggables.removeObserver(t),Draggables.addObserver({element:t,onStart:Wysija.startBlockPositions,onEnd:Wysija.setBlockPositions})},setDivider:function(t,e){$("wysija_widgets_settings").down(".divider").update(t),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_src",e.src),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_width",e.width),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_height",e.height)},replaceDividers:function(){$$(".wysija_block .wysija_divider").invoke("replace",$("wysija_widgets_settings").down(".divider").innerHTML)},toggleImages:function(){return Wysija.flags.displayImages=!Wysija.flags.displayImages,this.setImagesDisplay()},setImagesDisplay:function(){return Wysija.flags.displayImages===!0?($$(".wysija_image img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"visible"}),!0):($$(".wysija_image img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"hidden"}),!1)},flyToTheMoon:function(){if($("wysija-konami")){var t=document.viewport.getDimensions(),e=t.width;$("wysija-konami-overlay").show(),$("wysija-konami-bird").show(),$("wysija-konami-bird").setStyle({left:"-1000px",top:"100px"}),new Effect.Morph("wysija-konami-bird",{style:{left:e+"px"},duration:5,beforeStart:function(){},afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:300px;left:"+e+'px;-moz-transform: scaleX(-1);-o-transform: scaleX(-1);-webkit-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;-ms-filter: "FlipH";')}}),new Effect.Morph("wysija-konami-bird",{queue:"end",style:{left:"-1000px"},duration:5,afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:100px;left:-1000px;"),$("wysija-konami-overlay").hide(),$("wysija-konami-bird").hide()}})}},hideSettings:function(){$$(".wysija_settings").invoke("hide")},initSettings:function(){Event.stopObserving("scroll"),Event.observe(window,"scroll",function(){Wysija.setScrollOffsets(),Wysija.setSettingsPosition(),Wysija.updateToolbarPosition(),WysijaPopup.setPosition()}),Event.stopObserving("resize"),Event.observe(window,"resize",function(){WysijaPopup.setPosition()})},setSettingsPosition:function(){var t=document.viewport.getHeight(),e=25;$$(".wysija_settings").each(function(i){var s=i.up(".wysija_block").getDimensions(),n=i.up(".wysija_block").cumulativeOffset(),o=n.top<=Wysija.scroll.top+t?!0:!1,a=100;if(o){var r=parseInt(Wysija.scroll.top+(t/2-i.getHeight()/2)),l=parseInt(n.top-e),h=parseInt(n.top+s.height-e);a=parseInt(s.height)<200?parseInt(s.height/2-i.getHeight()/2):r+100>h+e?parseInt(s.height-100):l+e>r-100?100:parseInt(r-n.top)}new Effect.Move(i,{x:parseInt(s.width/2-i.getWidth()/2),y:a,mode:"absolute",duration:.2})})},initAutoPost:function(){var t=$("wysija_widgets_settings").down(".autopost").innerHTML,e=$$(".wysija_auto-post").length;"single"===t&&(e>0?($("wysija-widget-autopost").addClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",Wysija_i18n.autoPostImmediateNotice)):($("wysija-widget-autopost").removeClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",""))),Wysija.getBlocks().each(function(t){"auto-post"===t.elementType&&t.block.loadContent()})},encodeHtmlValue:function(t){return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},encodeURIComponent:function(t){var e=new RegExp(/^http[s]?:\/\//),i=e.exec(t);return null===i?encodeURIComponent(t).replace(/[!'()*]/g,escape):1===i.length?encodeURI(t).replace(/[!'()*]/g,escape):void 0}};document.observe("dom:loaded",Wysija.init),Wysija.Block=Class.create({initialize:function(t){return info("block -> init"),this.element=$(t),this.elementType=this.element.readAttribute("wysija_type"),this.block=new(Wysija[this.elementType.capitalize().camelize()])(this.element),1===parseInt(this.element.readAttribute("wysija_new"))&&(this.block.draw(),this.element.writeAttribute("wysija_new",0)),this.block.makeBlockDroppable(),void 0!==this.block.setup&&this.block.setup(),this},getCustomData:function(t){return void 0!==this.element.down(".wysija_options."+t)?(info("got options for "+t),this.element.down(".wysija_options."+t).innerHTML.toQueryParams("&amp;")):(info("no options to get for "+t),null)},getOptions:function(){return this.options},setOptions:function(t){return void 0===t&&(t={}),void 0===this.options&&(this.options=new Hash),this.options=this.options.update(t),this},setPosition:function(t){this.element.writeAttribute("wysija_position",t)},hideControls:function(){this.getControls&&(this.element.removeClassName("hover"),this.getControls().hide())},showControls:function(){this.getControls&&(this.element.addClassName("hover"),this.getControls().show())},makeBlockDroppable:function(){if(this.isBlockDroppableEnabled()===!1){var t=this.getBlockDroppable();Droppables.add(t.identify(),Wysija.blockDropOptions),t.addClassName("enabled")}},removeBlockDroppable:function(){if(this.isBlockDroppableEnabled()){var t=this.getBlockDroppable();Droppables.remove(t.identify()),t.removeClassName("enabled"),t.remove()}},isBlockDroppableEnabled:function(){return this.element.hasClassName("static")?!0:this.getBlockDroppable().hasClassName("enabled")},createBlockDroppable:function(){return this.element.insert({before:'<div class="block_placeholder" data-parent="'+this.element.identify()+'">'+Wysija_i18n.drop_block_here+"</div>"})},getBlockDroppable:function(){var t=this.element.identify();return 0===$$('.block_placeholder[data-parent="'+t+'"]').length&&this.createBlockDroppable(),$$('.block_placeholder[data-parent="'+t+'"]').first()},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){if(this.controls=this.getControls(),this.controls){this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&this.hideControls()}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.removeBlock(),this.removeButton.stopObserving("click")}.bind(this)),this.bgColorButton=this.controls.down(".bgcolor");var t=this;jQuery(this.bgColorButton).modcoder_excolor({default_color:t.element.readAttribute("wysija_bg_color"),hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_init:function(){Wysija.locks.selectingColor=!0},callback_on_select:function(e){t.setBackgroundColor(e)},callback_on_ok:function(e,i){i===!0&&t.setBackgroundColor(e),Wysija.locks.selectingColor=!1,t.hideControls()}})}return this},setBackgroundColor:function(t){void 0!==t&&this.element.writeAttribute("wysija_bg_color",t);var e=this.element.readAttribute("wysija_bg_color");""===e?this.element.setStyle({backgroundColor:"transparent"}):null!==e&&this.element.setStyle({backgroundColor:"#"+e}),Wysija.autoSave()},replaceBlock:function(t){return this.removeBlockDroppable(),this.element.replace(t)},removeBlock:function(t){info("block -> removeBlock"),this.removeBlockDroppable(),Effect.Fade(this.element.identify(),{duration:.2,afterFinish:function(){void 0!==this.element.next(".wysija_block")&&t!==!1&&Wysija.get(this.element.next(".wysija_block")).block.showControls(),this.element.remove(),Wysija.setBlockPositions(),void 0!==t&&"function"==typeof t&&t(),delete Wysija.instances[this.element.identify()]}.bind(this)})}}),document.observe("item:drop",function(t){Wysija.Block.create(t.memo,t.target),Wysija.hideBlockControls(),Wysija.setImagesDisplay()}),Wysija.Block.create=function(t,e){var i='<li class="handle_container"><a class="handle" href="javascript:;"><span></span></a></li><li><a class="bgcolor" href="javascript:;"><span></span></a></li><li><a class="remove" href="javascript:;"><span></span></a></li>';"image"===t.elementType&&(t.elementOptions='<span class="wysija_options image">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.imageAlignment),"text"===t.elementType&&(t.elementOptions='<span class="wysija_options text">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.contentAlignment),"divider"===t.elementType&&(t.elementOptions='<span class="wysija_options divider">#{options}</span>'.interpolate({options:Object.toQueryString(t)}));var s,n=$(Wysija.options.body),o=new Template('<div class="wysija_block" wysija_type="#{elementType}" wysija_new="1"><ul class="wysija_controls">'+i+'</ul>#{elementOptions}<div class="wysija_#{elementType} #{blockAlignment}" wysija_align="#{blockAlignment}"></div></div>');"block_placeholder"===e.identify()?(n.insert(o.evaluate(t)),s=n.childElements().last()):(e.insert({before:o.evaluate(t)}),s=e.previous(".wysija_block")),Wysija.makeSortable(),Wysija.setBlockPositions();var a=Wysija.get(s);"object"==typeof t.elementData&&a.block.image.setData(t.elementData),a.element.fire("block:insert"),void 0!==a.block.contents&&a.block.contents.isEmpty()===!1&&a.block.contents.setFocus()},Wysija.Header=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Footer=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Banner=Class.create(Wysija.Block,{image:null,constraints:{left:{minHeight:20,minWidth:20,maxWidth:600},right:{minHeight:20,minWidth:20,maxWidth:600},center:{minHeight:20,minWidth:20,maxWidth:600},full:{minHeight:20,minWidth:20,maxWidth:600}},initialize:function(t){return this.element=$(t),this.elementArea=this.element.readAttribute("wysija_type"),this.getImageContainer()&&(this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea)),this},save:function(){var t={};return t.text=null,null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&($("wysija_"+this.elementArea).innerHTML=$("wysija_default_"+this.elementArea).innerHTML,Wysija.init())},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("banner -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();i.width>e.width||i.height>e.height?(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:e.width,height:e.height})):(i.width<t.width||i.height<t.height)&&(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:t.width,height:t.height})),this.image.getImageContainer().setStyle("center"===this.image.alignment?{width:i.readAttribute("width")+"px"}:{width:"auto"}),this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_"+this.elementArea)}}),Wysija.Gallery=Class.create(Wysija.Block,{items:$H(),constraints:{left:{minWidth:20,maxWidth:562},right:{minWidth:20,maxWidth:562},center:{minWidth:20,maxWidth:562}},initialize:function(t){info("gallery -> init"),this.element=$(t),this.alignment=this.getDefaultAlignment();for(var e=this.getCells(),i=this.element.identify(),s=[],n=0;n<e.length;n++)s[n]=new Wysija.GalleryImage(e[n]);return this.items.set(i,s),this},getDefaultAlignment:function(){return this.getGalleryElement().readAttribute("wysija_align")||Wysija.defaults.galleryAlignment},draw:function(){info("gallery -> draw")},setup:function(){info("gallery -> setup"),this.createResizeControls(),this.setupResizeControls(),this.setupControls(),this.setupTools(),this.setBlockAlignment(this.getDefaultAlignment()),this.items.get(this.element.id).each(function(t){t.setup()},this)},save:function(){info("gallery -> save");var t={};return t.width=this.getGalleryElement().getWidth(),t.alignment=this.alignment,t.items=[],this.items.get(this.element.id).each(function(e){t.items.push(e.save())},this),t},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.getGalleryElement().observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.getGalleryElement().observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},remove:function(){this.items.unset(this.element.id),this.removeBlock()},getTools:function(){return this.getGalleryElement().down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},setBlockAlignment:function(t){return info("gallery -> setBlockAlignment"),this.getGalleryElement().removeClassName("left").removeClassName("center").removeClassName("right"),this.getGalleryElement().writeAttribute("wysija_align",t),this.getGalleryElement().addClassName(t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this[t+"Button"].addClassName("active"),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("gallery -> constrainSize");var t=this.getGalleryElement().getDimensions(),e=this.getCells(0).length,i=t.width-this.minWidth();this.getCells().each(function(t){t.setStyle({width:t.down("img").getWidth()+Math.floor(i/e)+"px"})})},getCells:function(t){return t=0|t,this.getGalleryElement().select(".wysija_row")[t].select(".wysija_cell")},minWidth:function(){return info("gallery -> minWidth"),this.getCells(0).inject(0,function(t,e){return t+e.down("img").getWidth()})},maxWidth:function(){return this.constraints[this.alignment].maxWidth},maxHeight:function(){return this.getCells(0).first().getHeight()},setupResizeControls:function(){return this.handle=this.getResizeControls().down(".resize-handle"),this.information=this.getResizeControls().down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),"right"===this.alignment&&this.getGalleryElement().insert(this.handle)},dragSnap:function(t,e){var i=this.minWidth(),s=this.maxWidth();if("right"===this.alignment){var n=this.getGalleryElement().getWidth(),o=n-t;o>s&&(t=n-s,o=s),i>o&&(t=n-i,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}else{var o=t+this.handleSize.width;o>s&&(t=s-this.handleSize.width,o=s),i>o&&(t=i-this.handleSize.width,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}return[t,e]},dragChange:function(){if("right"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left=e.width-t.left+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.getResizeControls().setStyle({left:e.width-t.left+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top-2*this.borderWidth()+"px"})}else if("left"===this.alignment){var t=this.handle.positionedOffset();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}else if("center"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({left:(e.width-t.left+this.borderWidth())/2+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1,$$("body")[0].setStyle({cursor:""});var t=this.minWidth(),e=this.getResizeControls().getWidth();t>e&&(e=t),this.setDimensions(e),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.getResizeControls().insert(this.handle),this.getResizeControls().writeAttribute("style","")):"center"===this.alignment&&this.getResizeControls().writeAttribute("style",""),Wysija.hideTools(),this.getGalleryElement().fire("drag:end")},setDimensions:function(t){var t=void 0===t?this.maxWidth():t,e=this.maxHeight();
2
- this.getGalleryElement().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().writeAttribute("style","")},borderWidth:function(){return 2},createResizeControls:function(){void 0===this.getResizeControls()&&this.getGalleryElement().insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},getResizeControls:function(){return this.getGalleryElement().down(".resize-controls")},getGalleryElement:function(){return this.element.down(".wysija_gallery")}}),Wysija.Content=Class.create(Wysija.Block,{contents:null,image:null,constraints:{left:{minHeight:20,minWidth:32,maxWidth:325},right:{minHeight:20,minWidth:32,maxWidth:325},center:{minHeight:20,minWidth:32,maxWidth:562},full:{minHeight:20,minWidth:32,maxWidth:562}},initialize:function(t){return this.element=$(t),this.getTextContainer()&&(this.contents=new Wysija.Text(this.getTextContainer())),this.getImageContainer()&&(this.image=new Wysija.Image(this.getImageContainer())),this},save:function(){var t={};return null!==this.contents&&(t.text=this.contents.save()),null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.Image(this.getImageContainer()),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),null===this.contents&&(this.element.childElements().last().insert(this.drawContainer("text")),this.contents=new Wysija.Text(this.getTextContainer()),this.contents.setOptions(this.getCustomData("text")),this.getTextContainer().insert(this.contents.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getTextContainer:function(){return this.element.down(".wysija_text")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.isAlone()?this.constraints.full.maxWidth:this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){info("content -> setup"),this.setupControls(),null!==this.contents&&this.contents.setup(),null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&this.contents.isEmpty()&&this.removeBlock()},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),this.alignment=t,null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),null!==this.contents&&this.contents.setAlignment(t),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("content -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();if(this.image.getImageContainer().writeAttribute("style",""),i.width>e.width||i.height>e.height?i.writeAttribute({width:e.width,height:e.height}):(i.width<t.width||i.height<t.height)&&i.writeAttribute({width:t.width,height:t.height}),this.image.isEmpty()===!1&&this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px",height:null}),this.image.isEmpty()||this.contents.isEmpty()){if(this.contents.isEmpty()){this.contents.getTextContainer().writeAttribute("style","");var s=this.image.getImageElement().getDimensions(),n=this.constraints[this.contents.alignment].maxWidth;if("center"!==this.contents.alignment&&s.width>n)this.contents.getTextPlaceholder().setStyle({width:s.width-2+"px","float":this.contents.alignment,lineHeight:null});else switch(this.contents.alignment){case"left":case"right":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-s.width-15-2+"px",height:s.height-2+"px",lineHeight:s.height-2+"px","float":"left"===this.contents.alignment?"right":"none"});break;case"center":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-2+"px",height:null,lineHeight:null})}}else this.image.isEmpty()&&(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px",height:"auto","float":"none"}),this.image.getImageContainer().setStyle({width:"auto"}),"center"===this.contents.alignment&&i.writeAttribute("width",e.width));this.contents.getTools()&&this.contents.getTools().setStyle({right:0})}else if(this.contents.isEditing()){switch(this.contents.getTextContainer().setStyle({width:"auto","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),this.contents.alignment){case"left":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px","float":"right"});break;case"right":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px"});break;case"center":this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px"})}this.contents.getTextContainer().setStyle({height:"auto"})}else{if(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()+"px","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),"right"===this.contents.alignment&&this.contents.getTools()&&Prototype.Browser.ie7===!1){var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTools().setStyle({right:o+15+2+"px"})}if(this.contents.isEmpty()===!1){var a=this.contents.getTextArea().getHeight(),r=parseInt(this.image.getImageElement().readAttribute("height"));this.contents.getTextContainer().setStyle("right"===this.contents.alignment||"left"===this.contents.alignment?r>a?{height:r+"px"}:{height:"auto"}:20>a?{height:"20px"}:{height:"auto"})}}this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_block")}});var WysijaImageAbstract={initialize:function(t,e){return info("image abstract -> init"),this.element=$(t),this.elementArea=void 0===e?"block":e,this.alignment=this.getDefaultAlignment(),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),alignment:this.alignment,"static":this.getImageElement().hasClassName("static")}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:$("wysija_widgets_settings").down(".image").innerHTML,elementRatio:1,elementClass:"empty",elementWidth:106,elementHeight:80});var t=this.getOptions();return this.setRatio(t.get("elementRatio")||1),void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" wysija_src="#{elementSrc}" height="#{elementHeight}" wysija_height="#{elementHeight}" width="#{elementWidth}" wysija_width="#{elementWidth}" alt="" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.alignmentLeft+'" class="alignment-left"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.alignmentCenter+'" class="alignment-center"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.alignmentRight+'" class="alignment-right"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEmpty()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.removeImage(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},addLink:function(){var t=wysijaAJAX.adminurl+"?page=wysija_campaigns&action=image_data";void 0!==this.params.get("url")&&null!==this.params.get("url")&&(t+="&url="+Wysija.encodeURIComponent(this.params.get("url"))),void 0!==this.params.get("alt")&&(t+="&alt="+Wysija.encodeURIComponent(this.params.get("alt"))),WysijaPopup.open(Wysija_i18n.addLinkTitle,t,this.setData.bind(this))},setData:function(t){"undefined"!=typeof t.url&&this.params.set("url",t.url),"undefined"!=typeof t.alt&&this.params.set("alt",t.alt),void 0!==this.params.get("url")&&null!==this.params.get("url")?this.showLink():this.hideLink(),Wysija.autoSave(),Wysija.init()},getData:function(){return{url:this.params.get("url"),alt:this.params.get("alt")}},removeLink:function(){this.params.set("url",null),this.hideLink()},showLink:function(){this.addLinkButton.writeAttribute("title",decodeURIComponent(this.params.get("url"))),this.addLinkButton.addClassName("active")},hideLink:function(){this.addLinkButton.writeAttribute("title",Wysija_i18n.addImageLink),this.addLinkButton.removeClassName("active")},setBlockAlignment:function(t){info("image -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},removeImage:function(){info("image -> remove"),this.params=new Hash,this.element.fire("image:remove")},makeDroppable:function(){info("image -> make droppable"),Droppables.add(this.getImageElement().identify(),Wysija.imageDropOptions)},removeDroppable:function(){info("image -> remove droppable"),Droppables.remove(this.getImageElement().identify())},setup:function(){return info("image -> setup"),this.createControls(),this.setupControls(),this.setupTools(),this.makeDroppable(),this.getParameters(),this[this.alignment+"Button"]&&this[this.alignment+"Button"].addClassName("active"),this},getParameters:function(){info("image -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!==e&&(this.params.set("url",e),this.showLink());var i=$F(t.down('input[name="alt"]'));""!==i&&this.params.set("alt",i)}return this},createControls:function(){this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")||void 0!==this.getResizeControls()||this.element.insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},setupControls:function(){return this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")?void 0:(this.ratio=this.getRatio(),this.controls=this.getControls(),this.handle=this.controls.down(".resize-handle"),this.information=this.controls.down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this)},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},getResizeControls:function(){return this.element.down(".resize-controls")},minSize:function(){var t=this.minWidth();return{width:t,height:Math.floor(t/this.ratio)}},maxSize:function(){var t=this.maxWidth();return{width:t,height:Math.floor(t/this.ratio)}},getRatio:function(){return this.getImageContainer().readAttribute("wysija_ratio")||(this.getImageElement().width/this.getImageElement().height*1e3).round()/1e3},setRatio:function(t){return this.element.writeAttribute("wysija_ratio",t),this},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},isAlone:function(){return this.getImageContainer().hasClassName("alone")},setAlone:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("alone")},setAlignment:function(t){return this.isEmpty()?void 0:(info("image -> setAlignment = "+t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this.getResizeControls().writeAttribute("style",""),this[t+"Button"].addClassName("active"),this)},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.imageAlignment},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),this.imageDimensions=this.getImageElement().getDimensions(),this.controls.setStyle({width:this.imageDimensions.width+"px",height:this.imageDimensions.height+"px"});var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.addClassName("dragging"),"right"===this.alignment&&this.element.insert(this.handle)},dragSnap:function(t,e){var i=this.constraints[this.alignment].minWidth,s=this.constraints[this.alignment].maxWidth,n=this.constraints[this.alignment].minHeight;if(this.isAlone()&&(s=this.constraints.full.maxWidth),"right"===this.alignment){var o=this.imageDimensions.width,a=o-t;a>s&&(t=o-s,a=s),i>a&&(t=o-i,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=o-Math.floor(n*this.ratio)),e-=this.handleSize.height}else{var a=t+this.handleSize.width;a>s&&(t=s-this.handleSize.width,a=s),i>a&&(t=i-this.handleSize.width,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=Math.floor(n*this.ratio)-this.handleSize.height),e-=this.handleSize.height}return[t-this.borderWidth(),e-this.borderWidth()]},dragChange:function(){var t=this.handle.positionedOffset();"right"===this.alignment?(t.left=this.imageDimensions.width-t.left,t.top+=this.handleSize.height,this.controls.setStyle({left:Math.floor(this.imageDimensions.width-t.left)+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top+"px"}),this.handle.setStyle({left:parseInt(this.handle.getStyle("left"))+this.borderWidth()+"px",top:parseInt(this.handle.getStyle("top"))+this.borderWidth()+"px"})):"left"===this.alignment?(t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.controls.setStyle({width:t.left+"px",height:t.top+"px"})):"center"===this.alignment&&(t.left+=this.handleSize.width+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.controls.setStyle({left:Math.floor((this.imageDimensions.width-t.left)/2)+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})),this.setInformation(!0)},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1;var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.removeClassName("dragging"),void 0!==t.block.contents&&t.block.contents.isEmpty()&&t.block.contents.getTextArea().setStyle({height:""}),$$("body")[0].setStyle({cursor:""});var e=this.constraints[this.alignment].minWidth,i=(this.constraints[this.alignment].minHeight,this.controls.getWidth()),s=this.controls.getHeight();e>i&&(i=e),this.setDimensions(i,s),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.controls.insert(this.handle),this.controls.writeAttribute("style",""),this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})):"center"===this.alignment?(this.controls.writeAttribute("style",""),this.element.setStyle({width:i+"px",height:s+"px"})):(this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})),Wysija.hideTools(),this.element.fire("drag:end")},setDimensions:function(t,e){var t=void 0===t?this.maxWidth():parseInt(t,10),e=void 0===e?(t/this.ratio*1e3).round()/1e3:parseInt(e,10),i=this.getImageElement();i.writeAttribute("width",t),i.writeAttribute("height",e),this.controls.setStyle({width:t-this.borderWidth()+"px",height:e-this.borderWidth()+"px"})},borderWidth:function(){return 2},getControls:function(){return this.element.down(".resize-controls")},getInformation:function(){return this.controls.down(".resize-info")},setInformation:function(t){if(void 0===t&&(t=!1),this.controls=this.getControls(),void 0!==this.controls&&(this.information=this.getInformation(),void 0!==this.information)){if(t)var e=this.controls.getDimensions();else var e=this.element.getDimensions();void 0!==this.information&&this.information.update("#{width} x #{height}".interpolate(e))}}};Wysija.Image=Class.create(Wysija.Content,WysijaImageAbstract),Wysija.BannerImage=Class.create(Wysija.Banner,WysijaImageAbstract);var WysijaGalleryItemAbstract={initialize:function(t){return info("gallery item -> init"),this.element=$(t),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),cellWidth:parseInt(this.getImageContainer().getWidth()),cellHeight:parseInt(this.getImageContainer().getHeight())}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementRatio:1.48,elementClass:"empty",elementHeight:135,elementWidth:200});var t=this.getOptions();return void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){this.getTools().hide(),Wysija.locks.showingTools=!1},showTools:function(){this.getTools().show(),Wysija.locks.showingTools=!0},remove:function(){info("gallery item -> remove"),this.element.fire("image:remove")},setup:function(){return info("gallery item -> setup"),this.setupControls(),this.setupTools(),this.getParameters(),this},getParameters:function(){info("gallery item -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!=e&&this.params.set("url",e);var i=$F(t.down('input[name="alt"]'));""!=i&&this.params.set("alt",i)}return this},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},setPosition:function(t){this.element.writeAttribute("wysija_position",t)}};Wysija.GalleryImage=Class.create(Wysija.Gallery,WysijaGalleryItemAbstract);var WysijaTextAbstract={initialize:function(t){return this.element=$(t),this.alignment=this.getDefaultAlignment(),this},save:function(){return this.isEmpty()?null:{value:Base64.encode(this.getTextArea().innerHTML)}},draw:function(){return info("text -> draw"),this.customDraw()+this.customTools()},customDraw:function(){info("text -> custom draw");var t=this.getOptions();return void 0!==this.getTextArea()&&t.set("elementId",this.getTextArea().identify()),void 0===t.get("elementText")?(t.set("placeholderText",Wysija_i18n.drop_block_here),'<div class="text_placeholder empty" id="#{elementId}">#{placeholderText}</div>'.interpolate(this.getOptions())):'<div class="wysija_editable" id="#{elementId}">#{elementText}</div>'.interpolate(this.getOptions())},makeDroppable:function(){this.isDroppable()&&Droppables.add(this.getTextArea().identify(),Wysija.textDropOptions)},removeDroppable:function(){Droppables.remove(this.getTextArea().identify())},hasContent:function(){return void 0!==this.getTextArea()},isDroppable:function(){return this.getTextArea().hasClassName("text_placeholder")},isEmpty:function(){return this.getTextArea().hasClassName("empty")},isEditing:function(){return this.element.hasClassName("wysija_editing")},setup:function(){info("text -> setup"),this.setupEditor(),this.setAlignment(this.getDefaultAlignment()),this.setupTools(),this.makeDroppable()},setAlignment:function(t){return info("text -> setAlignment = "+t),this.alignment=t,this.isEmpty()===!1&&this.disableEditor(),this},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.contentAlignment},setBlockAlignment:function(t){info("text -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},setupEditor:function(){info("text -> setupEditor"),this.getTextContainer().observe("click",this.enableEditor.bind(this))},customTools:function(){return void 0===this.getOptions().get("elementText")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.removeText+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEditing()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&this.showTools()}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.selectingColor!==!0&&this.hideTools()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show()},remove:function(){info("text -> remove"),this.element.fire("text:remove")},enableEditor:function(){this.isEditing()||(info("text -> enableEditor"),Wysija.hideEditors(),this.element.addClassName("wysija_editing"),tinyMCE.execCommand("mceAddControl",!1,this.getTextArea().identify()),this.element.fire("editor:enable"))},disableEditor:function(){this.isEditing()!==!1&&(info("text -> disableEditor"),this.element.removeClassName("wysija_editing"),tinyMCE.execCommand("mceRemoveControl",!1,this.getTextArea().identify()),this.element.fire("editor:disable"))},setFocus:function(){info("text -> setFocus"),this.enableEditor()},getTextContainer:function(){return this.element},getTextArea:function(){return this.element.down(".wysija_editable")||this.getTextPlaceholder()},getTextPlaceholder:function(){return this.element.down(".text_placeholder")},getTextEditor:function(){return tinymce.get(this.getTextArea().identify())},isAlone:function(){return this.getTextContainer().hasClassName("alone")},setAlone:function(t){this.getTextContainer()[t?"addClassName":"removeClassName"]("alone")}};Wysija.Text=Class.create(Wysija.Content,WysijaTextAbstract),Wysija.Divider=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions(this.getCustomData("divider")),this},save:function(){return void 0===this.getDivider()?null:{src:this.getDivider().readAttribute("src"),width:parseInt(this.getDivider().readAttribute("width")),height:parseInt(this.getDivider().readAttribute("height"))}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){return info("divider -> custom draw"),void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementHeight:1,elementWidth:564}),'<img class="divider" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_divider")},getDivider:function(){return this.getContainer().down("img")}}),Wysija.Raw=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions({elementRaw:""}),this},save:function(){return void 0===this.getRaw()?null:{raw:Base64.encode(this.getRaw().innerHTML)}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){info("raw -> custom draw");var t=this.getOptions();return void 0!==this.getRaw()&&t.set("elementId",this.getRaw().identify()),void 0===t.get("elementRaw")?'<div class="raw empty" id="#{elementId}"></div>'.interpolate(this.getOptions()):'<div class="raw" id="#{elementId}">#{elementRaw}</div>'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_raw")},getRaw:function(){return this.getContainer().down(".raw")}}),Wysija.Post=Class.create(Wysija.Block,{initialize:function(t){return info("post -> init"),this.element=$(t),this},draw:function(){WysijaPopup.open(Wysija_i18n.articleSelectionTitle,WysijaPopup.formatURI(wysijaAJAX.adminurl,"page=wysija_campaigns&action=articles"),this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.AutoPost=Class.create(Wysija.Block,{initialize:function(t){return info("autopost -> init"),this.element=$(t),this},draw:function(){info("autopost -> draw")},setup:function(){info("autopost -> setup"),this.setupControls()},save:function(){info("autopost -> save");var t={};return this.getParameters(),t.params=this.params,t},getParameters:function(){info("autopost -> get parameters"),this.params=[];var t=this.element.down(".wysija_params");return void 0!==t&&t.select("input").each(function(t){this.params.push($H({key:t.name,value:t.value}))}.bind(this)),this},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){return this.controls=this.getControls(),this.controls&&(this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls(),this.element.down(".wysija_settings").show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideControls(),this.element.down(".wysija_settings").hide())}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)),this.settingsButton=this.element.down(".settings"),this.settingsButton.observe("click",function(){this.editSettings()}.bind(this))),this},editSettings:function(){this.getParameters();var t=this.formatParameters();WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.callback.bind(this))},callback:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},formatParameters:function(){var t=["autopost_count="+$$(".wysija_auto-post").length,"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML];return void 0!==this.params&&this.params.length>0&&(this.params.each(function(e){t.push(e.get("key")+"="+e.get("value"))}),t=t.join("&")),t},loadContent:function(){var t=this.element.previousSiblings();if(t.length>0){var e=[];t.each(function(t){"auto-post"===t.readAttribute("wysija_type")&&void 0!==t.down('input[name="post_ids"]')&&e.push(t.down('input[name="post_ids"]').value)}),e.length>0&&(e=e.join(","))}this.getParameters();var i=this.formatParameters();void 0!==e&&e.length>0&&(i+="&exclude="+e);var s=this;wysijaAJAX.task="load_auto_post",wysijaAJAX.wysijaData=i,new Ajax.Request(wysijaAJAX.ajaxurl,{method:"post",asynchronous:!1,parameters:wysijaAJAX,onSuccess:function(t){s.getAutoPostElement().update(Base64.decode(t.responseJSON.result)),Wysija.setSettingsPosition.delay(1)},onFailure:function(){}})},remove:function(){info("autopost remove"),this.removeBlock(function(){Wysija.initAutoPost(),Wysija.setBackgroundColors()})},getAutoPostElement:function(){return this.element.down(".wysija_auto-post")},getSettings:function(){return this.element.down(".wysija_settings")}}),Wysija.PopupAutoPost=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this},draw:function(){var t=["autopost_count="+parseInt($$(".wysija_auto-post").length+1),"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML].join("&");WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.PopupBookmark=Class.create(Wysija.Block,{initialize:function(t){return info("popup bookmark -> init"),this.element=$(t),this},draw:function(){var t="theme="+$("wysija_widgets_settings").down(".theme").innerHTML;WysijaPopup.open(Wysija_i18n.bookmarkSelectionTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=bookmarks&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){t&&Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}});var WysijaPopup={initialized:!1,opened:!1,locked:!1,title:null,url:null,popupWidth:null,popupHeight:null,onSuccess:null,onCancel:null,setSize:function(t,e){return WysijaPopup.popupWidth=t,WysijaPopup.popupHeight=e,this},formatURI:function(t,e){return-1===t.indexOf("?")?t+"?"+e:t+"&"+e},init:function(){if(WysijaPopup.initialized===!1){info("init popup");var t='<div id="wysija_popup_overlay"></div><div id="wysija_popup"><div id="wysija_popup_title"><h3></h3><a id="wysija_popup_close" href="javascript:;"></a></div><div id="wysija_popup_content" class="clearfix"><iframe id="wysija_popup_iframe" marginheight="0" marginwidth="0" frameborder="0"></iframe></div></div>';
3
  $$("body")[0].insert(t),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_close").observe("click",WysijaPopup.cancel),$("wysija_popup_overlay").observe("click",function(t){"wysija_popup_overlay"===t.target.id&&WysijaPopup.cancel()}),WysijaPopup.initialized=!0,$("wysija_popup_iframe").observe("load",function(){null!==$(this).readAttribute("src")&&setTimeout(function(){WysijaPopup.opened=!0,WysijaPopup.setDimensions(),WysijaPopup.hideLoading(),WysijaPopup.showOverlay(),setTimeout(function(){$("wysija_popup").setStyle({visibility:"visible"})},101)},0)})}},lock:function(){WysijaPopup.locked=!0},unlock:function(){WysijaPopup.locked=!1},isLocked:function(){return WysijaPopup.locked},setPosition:function(){if(WysijaPopup.init(),WysijaPopup.opened!==!1){var t=$("wysija_popup").getDimensions(),e=document.viewport.getDimensions(),i=parseInt(Wysija.scroll.top+e.height/2-t.height/2-15,10),s=parseInt(Wysija.scroll.left+e.width/2-t.width/2,10);i<Wysija.scroll.top&&(i=parseInt(Wysija.scroll.top,10)),s<Wysija.scroll.left&&(s=parseInt(Wysija.scroll.left,10)),$("wysija_popup").setStyle({top:i+"px",left:s+"px"})}},setDimensions:function(){if(WysijaPopup.opened!==!1){var t=$("wysija_popup_iframe");if(null!==t){t.doc=null,t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document);var e=0,i=0,s=document.viewport.getDimensions();setTimeout(function(){if($("wysija_popup_iframe").writeAttribute("width",null),$("wysija_popup_iframe").writeAttribute("height",null),null===WysijaPopup.popupWidth||null===WysijaPopup.popupHeight){var n=null;n=WysijaPopup.getElementSize(t.doc.querySelectorAll(".popup_content").length>0?t.doc.querySelectorAll(".popup_content")[0]:t.doc.getElementsByClassName(".popup_content")[0]),i=n.width,e=n.height}else i=WysijaPopup.popupWidth,e=WysijaPopup.popupHeight;e+50>s.height&&(e=s.height-50),$("wysija_popup").setStyle({width:i+"px",height:e+20+"px"}),$("wysija_popup_iframe").writeAttribute("width",i),$("wysija_popup_iframe").writeAttribute("height",e+20),WysijaPopup.setPosition()},100)}}},getElementSize:function(t){var e=t.currentStyle||window.getComputedStyle(t),i=t.offsetWidth;i+=parseInt(e.marginLeft),i+=parseInt(e.marginRight);var s=t.offsetHeight;return s+=parseInt(e.marginTop),s+=parseInt(e.marginBottom),{width:i,height:s}},loadContent:function(t,e){$("wysija_popup_iframe").writeAttribute("src",e),$("wysija_popup_title").down("h3").update(t)},showOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"visible"})},showLoading:function(){$("wysija_popup_overlay").addClassName("loading")},hideOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"hidden"})},hideLoading:function(){$("wysija_popup_overlay").removeClassName("loading")},open:function(t,e,i,s){WysijaPopup.init(),WysijaPopup.showLoading(),WysijaPopup.showOverlay(),void 0!==i&&(WysijaPopup.onSuccess=i),void 0!==s&&(WysijaPopup.onCancel=s),WysijaPopup.loadContent(t,e)},success:function(t){null!==WysijaPopup.onSuccess&&WysijaPopup.onSuccess(t),WysijaPopup.close()},cancel:function(t){null!==WysijaPopup.onCancel&&WysijaPopup.onCancel(t),WysijaPopup.close()},close:function(){return WysijaPopup.isLocked()===!0?!1:($("wysija_popup").writeAttribute("style",""),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_iframe").writeAttribute("src",null),$("wysija_popup_iframe").writeAttribute("height",null),$("wysija_popup_iframe").writeAttribute("width",null),WysijaPopup.onSuccess=null,WysijaPopup.onCancel=null,WysijaPopup.popupWidth=null,WysijaPopup.popupHeight=null,WysijaPopup.opened=!1,!1)}};Wysija.DraggableItem=Class.create({initialize:function(t){this.elementType=$(t).readAttribute("wysija_type"),this.element=$(t).down()||$(t),this.clone=null,t.hasClassName("wysija_item")===!1&&(this.elementType="block_image")},STYLES:new Template("position: absolute; top: #{top}px; left: #{left}px;"),cloneElement:function(){var t=this.element.clone(),e=this.element.cumulativeOffset();if(this.element.hasClassName("wysija_item")){var i=this.getList(),s=this.STYLES.evaluate({top:e.top-i.scrollTop,left:e.left-i.scrollLeft});t.addClassName("wysija_widget"),t.addClassName(this.elementType)}else{var s=this.STYLES.evaluate({top:e.top,left:e.left,width:this.element.getWidth()+"px",height:this.element.getHeight()+"px"});t.writeAttribute("wysija_height",this.element.readAttribute("wysija_height")),t.writeAttribute("wysija_width",this.element.readAttribute("wysija_width")),t.writeAttribute("wysija_src",this.element.readAttribute("wysija_src")),this.element.hasClassName("image_placeholder")&&t.writeAttribute("wysija_parent",(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer")).identify()),t.addClassName("wysija_widget image")}return t.setStyle(s),"image"===this.elementType||"block_image"===this.elementType?t.writeAttribute({elementRatio:this.calculateRatio(),wysija_type:"image"}):t.innerHTML=this.element.innerHTML,t},getOffset:function(){return this.element.offsetTop-this.getList().scrollTop},getList:function(){return this.element.up("ul")},insert:function(){$$("body")[0].insert(this.clone)},onMousedown:function(t){if("block_image"!==this.elementType||"img"===this.element.tagName.toLowerCase()&&"span"!==t.target.tagName.toLowerCase()){null===this.clone&&(this.clone=this.cloneElement(),this.insert());var e=new Draggable(this.clone,{scroll:window,isImage:!1,onStart:function(t,e){this.isImage=t.element.hasClassName("wysija_widget image"),this.isImage===!0&&t.element.setStyle({left:e.pageX+"px",top:e.pageY+"px"}),Wysija.locks.dragging=!0,Wysija.hideTools(),Wysija.hideBlockControls(),Droppables.togglePlaceholders(t,e)},onDrag:function(t,e){Droppables.togglePlaceholders(t,e)},snap:function(t,e,i){return this.isImage===!0?[t+i.offset[0],e+i.offset[1]]:[t,e]},onEnd:function(t){t.destroy(),t.element.remove(),Wysija.locks.dragging=!1,Droppables.hidePlaceholders()},starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction});return e.initDrag(t),e.startDrag(t),e}},calculateRatio:function(){return(this.element.readAttribute("wysija_width")/this.element.readAttribute("wysija_height")*1e3).round()/1e3}}),Object.extend(Wysija.DraggableItem,Observable).observe('a[class="wysija_item"], .wysija_image'),Wysija.ImagePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=parseInt(t.readAttribute("wysija_height"),10),i=parseInt(t.readAttribute("wysija_width"),10),s=(i/e*1e3).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_images_preview").insert(t),$("wj_images_preview").down("img").writeAttribute({width:i,height:e}),$("wj_images_preview").show()}}},onMouseout:function(){$("wj_images_preview").update(""),$("wj_images_preview").hide()}}),Wysija.ThemePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=t.readAttribute("wysija_height"),i=t.readAttribute("wysija_width"),s=(i/e*1e3).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_themes_preview").insert(t),$("wj_themes_preview").down("img").writeAttribute("width",i),$("wj_themes_preview").down("img").writeAttribute("height",e),$("wj_themes_preview").show()}}},onMouseout:function(){$("wj_themes_preview").update(""),$("wj_themes_preview").hide()}}),Object.extend(Wysija.ThemePreview,Observable).observe(".wj_themes li a"),Wysija.TextLinks=Class.create({initialize:function(t){this.element=$(t)},onClick:function(t){return t.stop(),!1}}),Object.extend(Wysija.TextLinks,Observable).observe(".wysija_editable a"),window.document.observe("mousedown",function(t){if(tinymce.editors.length>0){if("mceModalBlocker"===t.target.id)return;if(t.target.hasClassName("mceClose"))return;if(t.target.hasClassName("mceMenu")||void 0!==t.target.up(".mceMenu"))return;void 0===t.target.up(".wysija_text")&&void 0===t.target.up(".wysija_editable")&&t.target.hasClassName("mceText")===!1&&(Wysija.hideEditors(),Wysija.autoSave())}}),document.on("image:drop",function(t,e){var i,s=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i=t.memo.elementData,delete t.memo.elementData,s.block.image.removeDroppable(),s.block.image.setOptions(t.memo),s.block.getImageContainer().writeAttribute("style",""),s.block.getImageContainer().update(s.block.image.draw()),s.block.image.setup(),"object"==typeof i&&s.block.image.setData(i),void 0===s.block.contents?s.block.image.setAlone(!0):(s.block.contents.setAlone(s.block.image.isEmpty()),s.block.image.setAlone(s.block.contents.isEmpty()),s.block.setBlockAlignment(s.block.contents.getDefaultAlignment())),Wysija.hideTools(),s.block.image.setEmpty(!1),s.block.constrainSize(),Wysija.hideTools(),Wysija.autoSave()}),document.on("text:drop",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.removeDroppable(),i.block.contents.setOptions(t.memo),i.block.getTextContainer().update(i.block.contents.draw()),i.block.contents.setup(),i.block.image.isEmpty()===!1?(i.block.image.setAlone(!1),i.block.setBlockAlignment(i.block.image.alignment)):i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.contents.setFocus(),Wysija.hideControls(),Wysija.hideTools(),Wysija.autoSave()}),document.on("image:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.image.hideTools(),i.block.image.removeDroppable(),i.block.image.setOptions({elementSrc:void 0}),i.block.image.element.update(i.block.image.draw()),i.block.image.makeDroppable(),i.block.image.setEmpty(!0),void 0!==i.block.contents&&i.block.contents.isEmpty()===!1&&i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("text:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.getTextContainer().stopObserving("click"),i.block.contents.removeDroppable(),i.block.contents.setOptions({elementText:void 0}),i.block.contents.element.update(i.block.contents.draw()),i.block.contents.makeDroppable(),i.block.image.isEmpty()===!1&&i.block.image.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("editor:enable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("editor:disable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("block:insert",function(t,e){var i=Wysija.get(e);"content"===i.elementType&&(i.block.image.setAlone(i.block.contents.isEmpty()),i.block.contents.setAlone(i.block.image.isEmpty()),i.block.image.setEmpty(i.block.image.isEmpty()),i.block.constrainSize(),Wysija.hideTools())}),document.on("drag:end",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.constrainSize()}),document.observe("dom:loaded",function(){$("wysija_toggle_images").observe("click",function(){return Wysija.toggleImages()===!0?this.addClassName("on").removeClassName("off"):this.addClassName("off").removeClassName("on"),!1})});
1
  "use strict";function info(t){if(Wysija.options.verbose!==!1){window.console&&console.log||!function(){for(var t=function(){},e=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"],i=e.length,s=window.console={};i--;)s[e[i]]=t}();try{console.log("[INFO] "+t)}catch(e){}}}Object.extend(Prototype.Browser,{ie6:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&6===Number(RegExp.$1)?!0:!1,ie7:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&7===Number(RegExp.$1)?!0:!1,ie8:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&8===Number(RegExp.$1)?!0:!1,ie9:/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&9===Number(RegExp.$1)?!0:!1}),Event.cacheDelegated={},Object.extend(document,function(){function t(t){return o[t]=o[t]||{}}function e(e,i){var s=t(e);return s[i]=s[i]||[]}function i(t,i,s){var n=e(t,i);return n.find(function(t){return t.handler===s})}function s(e,s,n){var o=t(e);if(!o[s])return!1;var a=i(e,s,n);return o[s]=o[s].without(a),a}function n(t,i,s,n){var o,a=e(t,i);return a.pluck("handler").include(s)?!1:(o=function(e){var i=e.findElement(t);i&&s.call(n||i,e,i)},o.handler=s,a.push(o),o)}var o=Event.cacheDelegated;return{delegate:function(t,e){var i=n.apply(null,arguments);return i&&document.observe(e,i),document},stopDelegating:function(i,n){var a=arguments.length;switch(a){case 2:e(i,n).each(function(t){document.stopDelegating(i,n,t.handler)});break;case 1:Object.keys(t(i)).each(function(t){document.stopDelegating(i,t)});break;case 0:Object.keys(o).each(function(t){document.stopDelegating(t)});break;default:var r=s.apply(null,arguments);r&&document.stopObserving(n,r)}return document}}}());var Observable=function(){function t(t,e){return t=t.substring(2),e&&(t=e+":"+t),t.underscore().split("_").join(":")}function e(e){var s=e.prototype,n=s.namespace;return Object.keys(s).grep(/^on/).inject($H(),function(o,a){return"onDomLoaded"===a?o:(o.set(t(a,n),i(s[a],e)),o)})}function i(t,e){return function(i){return t.call(new e(this),i,i.memo)}}function s(t,e){$$(t).each(function(t){new e(t).onDomLoaded()})}return{observe:function(t){if(this.handlers||(this.handlers={}),!this.handlers[t]){var i=this;this.prototype.onDomLoaded&&(document.loaded?s(t,i):document.observe("dom:loaded",s.curry(t,i))),this.handlers[t]=e(i).each(function(e){document.delegate(t,e.key,e.value)})}},stopObserving:function(t){this.handlers&&this.handlers[t]&&(this.handlers[t].each(function(e){document.stopDelegating(t,e.key,e.value)}),delete this.handlers[t])}}}();Object.extend(Droppables,{deactivate:Droppables.deactivate.wrap(function(t,e,i){return e.onLeave&&e.onLeave(i,e.element),t(e)}),activate:Droppables.activate.wrap(function(t,e,i){return e.onEnter&&e.onEnter(i,e.element),t(e)}),togglePlaceholders:function(t,e){if(0!==this.drops.length&&!($$(".block_placeholder.hover, .text_placeholder.hover, .image_placeholder.hover").length>0)){var i=document.viewport.getDimensions(),s=document.viewport.getScrollOffsets();this.drops.each(function(n){if(void 0===n.overlap){var o=!1,a=n.element.cumulativeOffset(),r=Math.max(30,n.element.getHeight()),l=t.element.hasClassName("image"),h=t.element.hasClassName("text");if(a.top>s.top+i.height)return;if(a.top<s.top&&a.top+r<s.top)return;if(l===!1&&-1!==n.accept.indexOf("image"))return;if(h===!1&&-1!==n.accept.indexOf("text"))return;if(l===!0){if(-1!==n.accept.indexOf("text"))return;if(t.element.readAttribute("wysija_src")===n.element.readAttribute("wysija_src"))return}var c=a.top-2*Wysija.options.blockDropTreshold,m=a.top+r+Wysija.options.blockDropTreshold;c<e.pageY&&e.pageY<m&&(o=!0);var d=n.element.up();o===!0?(d&&d.addClassName("active"),n.element.addClassName("active")):(d&&d.removeClassName("active"),n.element.removeClassName("active"))}})}},hidePlaceholders:function(){0!==this.drops.length&&$$(".block_placeholder.active, .text_placeholder.active, .image_placeholder.active, .wysija_image.active").invoke("removeClassName","active")}});var Wysija={version:"2.3",options:{debug:!1,verbose:!1,css:"wj_css",toolbar:"wysija_toolbar",notices:"wysija_notices",wrapper:"wysija_wrapper",container:"wysija_container",header:"wysija_header",body:"wysija_body",footer:"wysija_footer",blockDropTreshold:30,imageDropTreshold:30,minTextPlaceholderWidth:45},toolbar:{effect:null,x:null,y:null,top:null,left:null},scroll:{top:0,left:0},locks:{dragging:!1,selectingColor:!1,showingTools:!1},flags:{displayImages:!0,doSave:!1},defaults:{contentAlignment:"left",imageAlignment:"center",galleryAlignment:"center"},autoSave:function(){Wysija.flags.doSave===!1&&(Wysija.flags.doSave=!0)},save:function(){var t,e=1,i={},s=$H();s.set("version",Wysija.version);var n=Wysija.getHeader();i=n.block.save(),i.type="header",s.set("header",i);var o=$H();Wysija.getBlocks().each(function(s){t=s.block,t.save&&(i=t.save(),null!==i&&(i.position=e,i.type=s.elementType,i.background_color=t.element.readAttribute("wysija_bg_color"),o.set("block-"+e,i),e++))}),s.set("body",o);var a=Wysija.getFooter();return i=a.block.save(),i.type="footer",s.set("footer",i),Object.toJSON(s).gsub('\\"','"').gsub('"[{',"[{").gsub('}]"',"}]")},blockDropOptions:{accept:$w("wysija_widget"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={},s=null;i.elementType=t.readAttribute("wysija_type"),i.element=t,"image"===i.elementType?(i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,s=t.readAttribute("wysija_parent"),null!==$(s)&&(i.elementData=Wysija.get($(s)).block.image.getData())):"divider"===i.elementType?(i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height")):"text"===i.elementType&&(i.elementText=Wysija_i18n.clickToEditText),e.fire("item:drop",i),$(e).removeClassName("hover"),null!==$(s)&&(s=Wysija.get($(s)),s.block.image.removeImage())}},imageDropOptions:{accept:$w("image"),onEnter:function(t,e){$(e).addClassName("hover"),($(e).up(".wysija_block")||$(e).up(".wysija_header")||$(e).up(".wysija_footer")).addClassName("image_hover")},onLeave:function(t,e){$(e).removeClassName("hover"),$$(".image_hover").invoke("removeClassName","image_hover")},onDrop:function(t,e){if(e.readAttribute("wysija_src")===t.readAttribute("wysija_src"))return Wysija.hideTools(),!1;var i={},s=t.readAttribute("wysija_parent");i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,null!==$(s)&&(s=Wysija.get($(s)),i.elementData=s.block.image.getData()),e.fire("image:drop",i),$(e).removeClassName("hover"),null!==$(s)&&s.block.image.removeImage()}},textDropOptions:{accept:$w("text"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={};i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementText=Wysija_i18n.clickToEditText,e.fire("text:drop",i),$(e).removeClassName("hover")}},instances:{},get:function(t,e){void 0===e&&(e="block");var i=t.identify(),s=Wysija.instances[i]||new(Wysija[e.capitalize().camelize()])(i);return Wysija.instances[i]=s,s},getTheme:function(){var t=$("wysija_widgets_settings").down(".theme");return void 0!==t&&t.innerHTML.length>0?t.innerHTML:"default"},getHeader:function(){return Wysija.get(Wysija.getHeaderElement(),"header")},getHeaderElement:function(){return $$("div.wysija_header")[0]},getFooter:function(){return Wysija.get(Wysija.getFooterElement(),"footer")},getFooterElement:function(){return $$("div.wysija_footer")[0]},getBlocks:function(){return Wysija.getBlockElements().map(function(t){return Wysija.get(t)})},getBlockElements:function(){return $$("div.wysija_block")},startBlockPositions:function(t,e){e.element.hasClassName("wysija_block")&&(Wysija.locks.dragging=!0,Wysija.hideEditors())},setScrollOffsets:function(){Wysija.scroll=document.viewport.getScrollOffsets()},setBlockPositions:function(t,e){Wysija.locks.dragging=!1;var i=1;Wysija.getBlocks().each(function(t){t.setPosition(i++),t.block.element.setStyle({zIndex:""});var e=$$(".block_placeholder[data-parent="+t.block.element.identify()+"]").first();void 0!==e&&t.block.element.insert({before:e})}),void 0!==e&&$$(".wysija_auto-post").length>1&&"auto-post"===e.element.readAttribute("wysija_type")&&(Wysija.initAutoPost(),Wysija.setBackgroundColors()),Wysija.autoSave()},init:function(){Wysija.setScrollOffsets(),Wysija.getHeader(),Wysija.getFooter(),Wysija.makeDroppable(),Wysija.makeSortable(),Wysija.hideControls(),Wysija.hideTools(),Wysija.hideSettings(),Wysija.setSettingsPosition(),Wysija.initSettings(),Wysija.initAutoPost(),Wysija.setBackgroundColors(),Wysija.setToolbarPosition(),Wysija.setImagesDisplay()},initToolbarPosition:function(){null===Wysija.toolbar.top&&(Wysija.toolbar.top=parseInt($(Wysija.options.wrapper).positionedOffset().top)),null===Wysija.toolbar.left&&(Wysija.toolbar.left=parseInt($(Wysija.options.wrapper).positionedOffset().left)),null===Wysija.toolbar.x&&(Wysija.toolbar.x=parseInt(Wysija.toolbar.left+$(Wysija.options.wrapper).getDimensions().width+15)),Wysija.toolbar.y=parseInt(Wysija.scroll.top>=Wysija.toolbar.top-20?20+Wysija.scroll.top:Wysija.toolbar.top+Wysija.scroll.top)},setToolbarPosition:function(){Wysija.initToolbarPosition(),$(Wysija.options.toolbar).setStyle({top:Wysija.toolbar.y+"px",left:Wysija.toolbar.x+"px",opacity:0}).appear({duration:.5}),$(Wysija.options.notices).hide()},updateToolbarPosition:function(){Wysija.initToolbarPosition(),null!==Wysija.toolbar.effect&&Wysija.toolbar.effect.cancel(),Wysija.scroll.top>=Wysija.toolbar.top-20?(Wysija.toolbar.y=parseInt(20+Wysija.scroll.top),Wysija.toolbar.effect=new Effect.Move(Wysija.options.toolbar,{x:Wysija.toolbar.x,y:Wysija.toolbar.y,mode:"absolute",duration:.2})):$(Wysija.options.toolbar).setStyle({left:Wysija.toolbar.x+"px",top:Wysija.toolbar.top+"px"})},editorCleanup:function(t,e){switch(t){case"get_from_editor":e=e.gsub(/<h1><\/h1>/,"<br />"),e=e.gsub(/<h2><\/h2>/,"<br />"),e=e.gsub(/<h3><\/h3>/,"<br />"),e=e.gsub(/<p><\/p>/,"<p>&nbsp;</p>");break;case"insert_to_editor":break;case"submit_content":break;case"get_from_editor_dom":break;case"insert_to_editor_dom":break;case"setup_content_dom":break;case"submit_content_dom":}return e},updateCSSColor:function(t,e){var i=[],s="color",n=$(Wysija.options.css).innerHTML.strip();switch(t.endsWith("BgColorInput")&&(s="background-color"),e=""===e?"transparent":"#"+e,t){case"bodyColorInput":i.push("wysija_editable"),i.push("wysija_editable ul li"),i.push("wysija_editable ol li");break;case"h1ColorInput":i.push("wysija_editable h1");break;case"h2ColorInput":i.push("wysija_editable h2");break;case"h3ColorInput":i.push("wysija_editable h3");break;case"linksColorInput":i.push("wysija_editable a"),i.push("wysija_editable h1 a"),i.push("wysija_editable h2 a"),i.push("wysija_editable h3 a");break;case"unsubscribeColorInput":i.push("wysija_unsubscribe p");break;case"viewbrowserColorInput":i.push("wysija_viewbrowser p");break;case"htmlBgColorInput":i.push("wysija_wrapper");break;case"headerBgColorInput":i.push("wysija_header");break;case"bodyBgColorInput":i.push("wysija_body");break;case"footerBgColorInput":i.push("wysija_footer")}i.length>0&&null!==s&&(i.each(function(t){var i=new RegExp("([\\.|#]"+t+".*?{.*?"+s+":\\s*)(#?[a-z0-9]*)*(.*?})","i");n=n.replace(i,"$1"+e+"$3")}),n.length>0&&Wysija.updateCSS(n))},updateCSS:function(t){void 0!==$(Wysija.options.css)&&$(Wysija.options.css).remove();var e=document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Wysija.options.css,i.type="text/css",i.styleSheet?i.innerHTML=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},setTextStyles:function(t){var e=t.editorId+"_ifr",i=$(e);if(null!==i&&(i.doc=null,i.contentDocument?i.doc=i.contentDocument:i.contentWindow?i.doc=i.contentWindow.document:i.document&&(i.doc=i.document),null!==i.doc)){var s=i.doc.getElementsByTagName("head")[0],n=i.doc.createElement("style"),o=$(Wysija.options.css).innerHTML.strip();n.type="text/css",n.id="wj_iframe_css",n.styleSheet?n.innerHTML=o:n.appendChild(document.createTextNode(o)),s.appendChild(n)}},setBackgroundColors:function(){Wysija.getBlocks().invoke("setBackgroundColor"),$$(".wysija_auto-post .wysija_content, .wysija_auto-post .wysija_divider .wysija_raw").each(function(t){var e=t.readAttribute("wysija_bg_color");""===e?t.setStyle({backgroundColor:"transparent"}):null!==e&&t.setStyle({backgroundColor:"#"+e})})},hideBlockControls:function(){$$(".wysija_controls").invoke("hide"),this.getBlockElements().invoke("removeClassName","hover")},hideEditors:function(){tinymce.editors.length>0&&Wysija.getBlocks().each(function(t){"content"===t.elementType&&null!==t.block.contents&&t.block.contents.disableEditor()})},hideControls:function(){return Wysija.getBlocks().invoke("hideControls")},hideTools:function(){$$(".resize-controls").invoke("hide"),$$(".wysija_tools").invoke("hide"),Wysija.locks.showingTools=!1},makeDroppable:function(){Droppables.add("block_placeholder",Wysija.blockDropOptions)},makeSortable:function(){var t=$(Wysija.options.body);Sortable.create(t,{tag:"div",only:"wysija_block",scroll:window,handle:"handle",constraint:"vertical"}),Draggables.removeObserver(t),Draggables.addObserver({element:t,onStart:Wysija.startBlockPositions,onEnd:Wysija.setBlockPositions})},setDivider:function(t,e){$("wysija_widgets_settings").down(".divider").update(t),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_src",e.src),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_width",e.width),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_height",e.height)},replaceDividers:function(){$$(".wysija_block .wysija_divider").invoke("replace",$("wysija_widgets_settings").down(".divider").innerHTML)},toggleImages:function(){return Wysija.flags.displayImages=!Wysija.flags.displayImages,this.setImagesDisplay()},setImagesDisplay:function(){return Wysija.flags.displayImages===!0?($$(".wysija_image img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"visible"}),!0):($$(".wysija_image img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"hidden"}),!1)},flyToTheMoon:function(){if($("wysija-konami")){var t=document.viewport.getDimensions(),e=t.width;$("wysija-konami-overlay").show(),$("wysija-konami-bird").show(),$("wysija-konami-bird").setStyle({left:"-1000px",top:"100px"}),new Effect.Morph("wysija-konami-bird",{style:{left:e+"px"},duration:5,beforeStart:function(){},afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:300px;left:"+e+'px;-moz-transform: scaleX(-1);-o-transform: scaleX(-1);-webkit-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;-ms-filter: "FlipH";')}}),new Effect.Morph("wysija-konami-bird",{queue:"end",style:{left:"-1000px"},duration:5,afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:100px;left:-1000px;"),$("wysija-konami-overlay").hide(),$("wysija-konami-bird").hide()}})}},hideSettings:function(){$$(".wysija_settings").invoke("hide")},initSettings:function(){Event.stopObserving("scroll"),Event.observe(window,"scroll",function(){Wysija.setScrollOffsets(),Wysija.setSettingsPosition(),Wysija.updateToolbarPosition(),WysijaPopup.setPosition()}),Event.stopObserving("resize"),Event.observe(window,"resize",function(){WysijaPopup.setPosition()})},setSettingsPosition:function(){var t=document.viewport.getHeight(),e=25;$$(".wysija_settings").each(function(i){var s=i.up(".wysija_block").getDimensions(),n=i.up(".wysija_block").cumulativeOffset(),o=n.top<=Wysija.scroll.top+t?!0:!1,a=100;if(o){var r=parseInt(Wysija.scroll.top+(t/2-i.getHeight()/2)),l=parseInt(n.top-e),h=parseInt(n.top+s.height-e);a=parseInt(s.height)<200?parseInt(s.height/2-i.getHeight()/2):r+100>h+e?parseInt(s.height-100):l+e>r-100?100:parseInt(r-n.top)}new Effect.Move(i,{x:parseInt(s.width/2-i.getWidth()/2),y:a,mode:"absolute",duration:.2})})},initAutoPost:function(){var t=$("wysija_widgets_settings").down(".autopost").innerHTML,e=$$(".wysija_auto-post").length;"single"===t&&(e>0?($("wysija-widget-autopost").addClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",Wysija_i18n.autoPostImmediateNotice)):($("wysija-widget-autopost").removeClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",""))),Wysija.getBlocks().each(function(t){"auto-post"===t.elementType&&t.block.loadContent()})},encodeHtmlValue:function(t){return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},encodeURIComponent:function(t){var e=new RegExp(/^http[s]?:\/\//),i=e.exec(t);return null===i?encodeURIComponent(t).replace(/[!'()*]/g,escape):1===i.length?encodeURI(t).replace(/[!'()*]/g,escape):void 0}};document.observe("dom:loaded",Wysija.init),Wysija.Block=Class.create({initialize:function(t){return info("block -> init"),this.element=$(t),this.elementType=this.element.readAttribute("wysija_type"),this.block=new(Wysija[this.elementType.capitalize().camelize()])(this.element),1===parseInt(this.element.readAttribute("wysija_new"))&&(this.block.draw(),this.element.writeAttribute("wysija_new",0)),this.block.makeBlockDroppable(),void 0!==this.block.setup&&this.block.setup(),this},getCustomData:function(t){return void 0!==this.element.down(".wysija_options."+t)?(info("got options for "+t),this.element.down(".wysija_options."+t).innerHTML.toQueryParams("&amp;")):(info("no options to get for "+t),null)},getOptions:function(){return this.options},setOptions:function(t){return void 0===t&&(t={}),void 0===this.options&&(this.options=new Hash),this.options=this.options.update(t),this},setPosition:function(t){this.element.writeAttribute("wysija_position",t)},hideControls:function(){this.getControls&&(this.element.removeClassName("hover"),this.getControls().hide())},showControls:function(){this.getControls&&(this.element.addClassName("hover"),this.getControls().show())},makeBlockDroppable:function(){if(this.isBlockDroppableEnabled()===!1){var t=this.getBlockDroppable();Droppables.add(t.identify(),Wysija.blockDropOptions),t.addClassName("enabled")}},removeBlockDroppable:function(){if(this.isBlockDroppableEnabled()){var t=this.getBlockDroppable();Droppables.remove(t.identify()),t.removeClassName("enabled"),t.remove()}},isBlockDroppableEnabled:function(){return this.element.hasClassName("static")?!0:this.getBlockDroppable().hasClassName("enabled")},createBlockDroppable:function(){return this.element.insert({before:'<div class="block_placeholder" data-parent="'+this.element.identify()+'">'+Wysija_i18n.drop_block_here+"</div>"})},getBlockDroppable:function(){var t=this.element.identify();return 0===$$('.block_placeholder[data-parent="'+t+'"]').length&&this.createBlockDroppable(),$$('.block_placeholder[data-parent="'+t+'"]').first()},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){if(this.controls=this.getControls(),this.controls){this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&this.hideControls()}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.removeBlock(),this.removeButton.stopObserving("click")}.bind(this)),this.bgColorButton=this.controls.down(".bgcolor");var t=this;jQuery(this.bgColorButton).modcoder_excolor({default_color:t.element.readAttribute("wysija_bg_color"),hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_init:function(){Wysija.locks.selectingColor=!0},callback_on_select:function(e){t.setBackgroundColor(e)},callback_on_ok:function(e,i){i===!0&&t.setBackgroundColor(e),Wysija.locks.selectingColor=!1,t.hideControls()}})}return this},setBackgroundColor:function(t){void 0!==t&&this.element.writeAttribute("wysija_bg_color",t);var e=this.element.readAttribute("wysija_bg_color");""===e?this.element.setStyle({backgroundColor:"transparent"}):null!==e&&this.element.setStyle({backgroundColor:"#"+e}),Wysija.autoSave()},replaceBlock:function(t){return this.removeBlockDroppable(),this.element.replace(t)},removeBlock:function(t){info("block -> removeBlock"),this.removeBlockDroppable(),Effect.Fade(this.element.identify(),{duration:.2,afterFinish:function(){void 0!==this.element.next(".wysija_block")&&t!==!1&&Wysija.get(this.element.next(".wysija_block")).block.showControls(),this.element.remove(),Wysija.setBlockPositions(),void 0!==t&&"function"==typeof t&&t(),delete Wysija.instances[this.element.identify()]}.bind(this)})}}),document.observe("item:drop",function(t){Wysija.Block.create(t.memo,t.target),Wysija.hideBlockControls(),Wysija.setImagesDisplay()}),Wysija.Block.create=function(t,e){var i='<li class="handle_container"><a class="handle" href="javascript:;"><span></span></a></li><li><a class="bgcolor" href="javascript:;"><span></span></a></li><li><a class="remove" href="javascript:;"><span></span></a></li>';"image"===t.elementType&&(t.elementOptions='<span class="wysija_options image">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.imageAlignment),"text"===t.elementType&&(t.elementOptions='<span class="wysija_options text">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.contentAlignment),"divider"===t.elementType&&(t.elementOptions='<span class="wysija_options divider">#{options}</span>'.interpolate({options:Object.toQueryString(t)}));var s,n=$(Wysija.options.body),o=new Template('<div class="wysija_block" wysija_type="#{elementType}" wysija_new="1"><ul class="wysija_controls">'+i+'</ul>#{elementOptions}<div class="wysija_#{elementType} #{blockAlignment}" wysija_align="#{blockAlignment}"></div></div>');"block_placeholder"===e.identify()?(n.insert(o.evaluate(t)),s=n.childElements().last()):(e.insert({before:o.evaluate(t)}),s=e.previous(".wysija_block")),Wysija.makeSortable(),Wysija.setBlockPositions();var a=Wysija.get(s);"object"==typeof t.elementData&&a.block.image.setData(t.elementData),a.element.fire("block:insert"),void 0!==a.block.contents&&a.block.contents.isEmpty()===!1&&a.block.contents.setFocus()},Wysija.Header=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Footer=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Banner=Class.create(Wysija.Block,{image:null,constraints:{left:{minHeight:20,minWidth:20,maxWidth:600},right:{minHeight:20,minWidth:20,maxWidth:600},center:{minHeight:20,minWidth:20,maxWidth:600},full:{minHeight:20,minWidth:20,maxWidth:600}},initialize:function(t){return this.element=$(t),this.elementArea=this.element.readAttribute("wysija_type"),this.getImageContainer()&&(this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea)),this},save:function(){var t={};return t.text=null,null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&($("wysija_"+this.elementArea).innerHTML=$("wysija_default_"+this.elementArea).innerHTML,Wysija.init())},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("banner -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();i.width>e.width||i.height>e.height?(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:e.width,height:e.height})):(i.width<t.width||i.height<t.height)&&(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:t.width,height:t.height})),this.image.getImageContainer().setStyle("center"===this.image.alignment?{width:i.readAttribute("width")+"px"}:{width:"auto"}),this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_"+this.elementArea)}}),Wysija.Gallery=Class.create(Wysija.Block,{items:$H(),constraints:{left:{minWidth:20,maxWidth:562},right:{minWidth:20,maxWidth:562},center:{minWidth:20,maxWidth:562}},initialize:function(t){info("gallery -> init"),this.element=$(t),this.alignment=this.getDefaultAlignment();for(var e=this.getCells(),i=this.element.identify(),s=[],n=0;n<e.length;n++)s[n]=new Wysija.GalleryImage(e[n]);return this.items.set(i,s),this},getDefaultAlignment:function(){return this.getGalleryElement().readAttribute("wysija_align")||Wysija.defaults.galleryAlignment},draw:function(){info("gallery -> draw")},setup:function(){info("gallery -> setup"),this.createResizeControls(),this.setupResizeControls(),this.setupControls(),this.setupTools(),this.setBlockAlignment(this.getDefaultAlignment()),this.items.get(this.element.id).each(function(t){t.setup()},this)},save:function(){info("gallery -> save");var t={};return t.width=this.getGalleryElement().getWidth(),t.alignment=this.alignment,t.items=[],this.items.get(this.element.id).each(function(e){t.items.push(e.save())},this),t},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.getGalleryElement().observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.getGalleryElement().observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},remove:function(){this.items.unset(this.element.id),this.removeBlock()},getTools:function(){return this.getGalleryElement().down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},setBlockAlignment:function(t){return info("gallery -> setBlockAlignment"),this.getGalleryElement().removeClassName("left").removeClassName("center").removeClassName("right"),this.getGalleryElement().writeAttribute("wysija_align",t),this.getGalleryElement().addClassName(t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this[t+"Button"].addClassName("active"),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("gallery -> constrainSize");var t=this.getGalleryElement().getDimensions(),e=this.getCells(0).length,i=t.width-this.minWidth();this.getCells().each(function(t){t.setStyle({width:t.down("img").getWidth()+Math.floor(i/e)+"px"})})},getCells:function(t){return t=0|t,this.getGalleryElement().select(".wysija_row")[t].select(".wysija_cell")},minWidth:function(){return info("gallery -> minWidth"),this.getCells(0).inject(0,function(t,e){return t+e.down("img").getWidth()})},maxWidth:function(){return this.constraints[this.alignment].maxWidth},maxHeight:function(){return this.getCells(0).first().getHeight()},setupResizeControls:function(){return this.handle=this.getResizeControls().down(".resize-handle"),this.information=this.getResizeControls().down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),"right"===this.alignment&&this.getGalleryElement().insert(this.handle)},dragSnap:function(t,e){var i=this.minWidth(),s=this.maxWidth();if("right"===this.alignment){var n=this.getGalleryElement().getWidth(),o=n-t;o>s&&(t=n-s,o=s),i>o&&(t=n-i,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}else{var o=t+this.handleSize.width;o>s&&(t=s-this.handleSize.width,o=s),i>o&&(t=i-this.handleSize.width,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}return[t,e]},dragChange:function(){if("right"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left=e.width-t.left+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.getResizeControls().setStyle({left:e.width-t.left+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top-2*this.borderWidth()+"px"})}else if("left"===this.alignment){var t=this.handle.positionedOffset();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}else if("center"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({left:(e.width-t.left+this.borderWidth())/2+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1,$$("body")[0].setStyle({cursor:""});var t=this.minWidth(),e=this.getResizeControls().getWidth();t>e&&(e=t),this.setDimensions(e),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.getResizeControls().insert(this.handle),this.getResizeControls().writeAttribute("style","")):"center"===this.alignment&&this.getResizeControls().writeAttribute("style",""),Wysija.hideTools(),this.getGalleryElement().fire("drag:end")},setDimensions:function(t){var t=void 0===t?this.maxWidth():t,e=this.maxHeight();
2
+ this.getGalleryElement().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().writeAttribute("style","")},borderWidth:function(){return 2},createResizeControls:function(){void 0===this.getResizeControls()&&this.getGalleryElement().insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},getResizeControls:function(){return this.getGalleryElement().down(".resize-controls")},getGalleryElement:function(){return this.element.down(".wysija_gallery")}}),Wysija.Content=Class.create(Wysija.Block,{contents:null,image:null,constraints:{left:{minHeight:20,minWidth:32,maxWidth:325},right:{minHeight:20,minWidth:32,maxWidth:325},center:{minHeight:20,minWidth:32,maxWidth:562},full:{minHeight:20,minWidth:32,maxWidth:562}},initialize:function(t){return this.element=$(t),this.getTextContainer()&&(this.contents=new Wysija.Text(this.getTextContainer())),this.getImageContainer()&&(this.image=new Wysija.Image(this.getImageContainer())),this},save:function(){var t={};return null!==this.contents&&(t.text=this.contents.save()),null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.Image(this.getImageContainer()),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),null===this.contents&&(this.element.childElements().last().insert(this.drawContainer("text")),this.contents=new Wysija.Text(this.getTextContainer()),this.contents.setOptions(this.getCustomData("text")),this.getTextContainer().insert(this.contents.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getTextContainer:function(){return this.element.down(".wysija_text")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.isAlone()?this.constraints.full.maxWidth:this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){info("content -> setup"),this.setupControls(),null!==this.contents&&this.contents.setup(),null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&this.contents.isEmpty()&&this.removeBlock()},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),this.alignment=t,null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),null!==this.contents&&this.contents.setAlignment(t),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("content -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();if(this.image.getImageContainer().writeAttribute("style",""),i.width>e.width||i.height>e.height?i.writeAttribute({width:e.width,height:e.height}):(i.width<t.width||i.height<t.height)&&i.writeAttribute({width:t.width,height:t.height}),this.image.isEmpty()===!1&&this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px",height:null}),this.image.isEmpty()||this.contents.isEmpty()){if(this.contents.isEmpty()){this.contents.getTextContainer().writeAttribute("style","");var s=this.image.getImageElement().getDimensions(),n=this.constraints[this.contents.alignment].maxWidth;if("center"!==this.contents.alignment&&s.width>n)this.contents.getTextPlaceholder().setStyle({width:s.width-2+"px","float":this.contents.alignment,lineHeight:null});else switch(this.contents.alignment){case"left":case"right":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-s.width-15-2+"px",height:s.height-2+"px",lineHeight:s.height-2+"px","float":"left"===this.contents.alignment?"right":"none"});break;case"center":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-2+"px",height:null,lineHeight:null})}}else this.image.isEmpty()&&(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px",height:"auto","float":"none"}),this.image.getImageContainer().setStyle({width:"auto"}),"center"===this.contents.alignment&&i.writeAttribute("width",e.width));this.contents.getTools()&&this.contents.getTools().setStyle({right:0})}else if(this.contents.isEditing()){switch(this.contents.getTextContainer().setStyle({width:"auto","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),this.contents.alignment){case"left":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px","float":"right"});break;case"right":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px"});break;case"center":this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px"})}this.contents.getTextContainer().setStyle({height:"auto"})}else{if(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()+"px","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),"right"===this.contents.alignment&&this.contents.getTools()&&Prototype.Browser.ie7===!1){var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTools().setStyle({right:o+15+2+"px"})}if(this.contents.isEmpty()===!1){var a=this.contents.getTextArea().getHeight(),r=parseInt(this.image.getImageElement().readAttribute("height"));this.contents.getTextContainer().setStyle("right"===this.contents.alignment||"left"===this.contents.alignment?r>a?{height:r+"px"}:{height:"auto"}:20>a?{height:"20px"}:{height:"auto"})}}this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_block")}});var WysijaImageAbstract={initialize:function(t,e){return info("image abstract -> init"),this.element=$(t),this.elementArea=void 0===e?"block":e,this.alignment=this.getDefaultAlignment(),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),alignment:this.alignment,"static":this.getImageElement().hasClassName("static")}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:$("wysija_widgets_settings").down(".image").innerHTML,elementRatio:1,elementClass:"empty",elementWidth:106,elementHeight:80});var t=this.getOptions();return this.setRatio(t.get("elementRatio")||1),void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" wysija_src="#{elementSrc}" height="#{elementHeight}" wysija_height="#{elementHeight}" width="#{elementWidth}" wysija_width="#{elementWidth}" alt="" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.alignmentLeft+'" class="alignment-left"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.alignmentCenter+'" class="alignment-center"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.alignmentRight+'" class="alignment-right"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEmpty()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.removeImage(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},addLink:function(){var t=wysijaAJAX.adminurl+"?page=wysija_campaigns&action=image_data";void 0!==this.params.get("url")&&null!==this.params.get("url")&&(t+="&url="+Wysija.encodeURIComponent(this.params.get("url"))),void 0!==this.params.get("alt")&&(t+="&alt="+Wysija.encodeURIComponent(this.params.get("alt"))),WysijaPopup.open(Wysija_i18n.addLinkTitle,t,this.setData.bind(this))},setData:function(t){"undefined"!=typeof t.url&&this.params.set("url",t.url),"undefined"!=typeof t.alt&&this.params.set("alt",t.alt),void 0!==this.params.get("url")&&null!==this.params.get("url")?this.showLink():this.hideLink(),Wysija.autoSave(),Wysija.init()},getData:function(){return{url:this.params.get("url"),alt:this.params.get("alt")}},removeLink:function(){this.params.set("url",null),this.hideLink()},showLink:function(){this.addLinkButton.writeAttribute("title",decodeURIComponent(this.params.get("url"))),this.addLinkButton.addClassName("active")},hideLink:function(){this.addLinkButton.writeAttribute("title",Wysija_i18n.addImageLink),this.addLinkButton.removeClassName("active")},setBlockAlignment:function(t){info("image -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},removeImage:function(){info("image -> remove"),this.params=new Hash,this.element.fire("image:remove")},makeDroppable:function(){info("image -> make droppable"),Droppables.add(this.getImageElement().identify(),Wysija.imageDropOptions)},removeDroppable:function(){info("image -> remove droppable"),Droppables.remove(this.getImageElement().identify())},setup:function(){return info("image -> setup"),this.createControls(),this.setupControls(),this.setupTools(),this.makeDroppable(),this.getParameters(),this[this.alignment+"Button"]&&this[this.alignment+"Button"].addClassName("active"),this},getParameters:function(){info("image -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!==e&&(this.params.set("url",e),this.showLink());var i=$F(t.down('input[name="alt"]'));""!==i&&this.params.set("alt",i)}return this},createControls:function(){this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")||void 0!==this.getResizeControls()||this.element.insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},setupControls:function(){return this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")?void 0:(this.ratio=this.getRatio(),this.controls=this.getControls(),this.handle=this.controls.down(".resize-handle"),this.information=this.controls.down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this)},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},getResizeControls:function(){return this.element.down(".resize-controls")},minSize:function(){var t=this.minWidth();return{width:t,height:Math.floor(t/this.ratio)}},maxSize:function(){var t=this.maxWidth();return{width:t,height:Math.floor(t/this.ratio)}},getRatio:function(){return this.getImageContainer().readAttribute("wysija_ratio")||(this.getImageElement().width/this.getImageElement().height*1e3).round()/1e3},setRatio:function(t){return this.element.writeAttribute("wysija_ratio",t),this},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},isAlone:function(){return this.getImageContainer().hasClassName("alone")},setAlone:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("alone")},setAlignment:function(t){return this.isEmpty()?void 0:(info("image -> setAlignment = "+t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this.getResizeControls().writeAttribute("style",""),this[t+"Button"].addClassName("active"),this)},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.imageAlignment},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),this.imageDimensions=this.getImageElement().getDimensions(),this.controls.setStyle({width:this.imageDimensions.width+"px",height:this.imageDimensions.height+"px"});var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.addClassName("dragging"),"right"===this.alignment&&this.element.insert(this.handle)},dragSnap:function(t,e){var i=this.constraints[this.alignment].minWidth,s=this.constraints[this.alignment].maxWidth,n=this.constraints[this.alignment].minHeight;if(this.isAlone()&&(s=this.constraints.full.maxWidth),"right"===this.alignment){var o=this.imageDimensions.width,a=o-t;a>s&&(t=o-s,a=s),i>a&&(t=o-i,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=o-Math.floor(n*this.ratio)),e-=this.handleSize.height}else{var a=t+this.handleSize.width;a>s&&(t=s-this.handleSize.width,a=s),i>a&&(t=i-this.handleSize.width,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=Math.floor(n*this.ratio)-this.handleSize.height),e-=this.handleSize.height}return[t-this.borderWidth(),e-this.borderWidth()]},dragChange:function(){var t=this.handle.positionedOffset();"right"===this.alignment?(t.left=this.imageDimensions.width-t.left,t.top+=this.handleSize.height,this.controls.setStyle({left:Math.floor(this.imageDimensions.width-t.left)+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top+"px"}),this.handle.setStyle({left:parseInt(this.handle.getStyle("left"))+this.borderWidth()+"px",top:parseInt(this.handle.getStyle("top"))+this.borderWidth()+"px"})):"left"===this.alignment?(t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.controls.setStyle({width:t.left+"px",height:t.top+"px"})):"center"===this.alignment&&(t.left+=this.handleSize.width+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.controls.setStyle({left:Math.floor((this.imageDimensions.width-t.left)/2)+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})),this.setInformation(!0)},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1;var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.removeClassName("dragging"),void 0!==t.block.contents&&t.block.contents.isEmpty()&&t.block.contents.getTextArea().setStyle({height:""}),$$("body")[0].setStyle({cursor:""});var e=this.constraints[this.alignment].minWidth,i=(this.constraints[this.alignment].minHeight,this.controls.getWidth()),s=this.controls.getHeight();e>i&&(i=e),this.setDimensions(i,s),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.controls.insert(this.handle),this.controls.writeAttribute("style",""),this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})):"center"===this.alignment?(this.controls.writeAttribute("style",""),this.element.setStyle({width:i+"px",height:s+"px"})):(this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})),Wysija.hideTools(),this.element.fire("drag:end")},setDimensions:function(t,e){var t=void 0===t?this.maxWidth():parseInt(t,10),e=void 0===e?(t/this.ratio*1e3).round()/1e3:parseInt(e,10),i=this.getImageElement();i.writeAttribute("width",t),i.writeAttribute("height",e),this.controls.setStyle({width:t-this.borderWidth()+"px",height:e-this.borderWidth()+"px"})},borderWidth:function(){return 2},getControls:function(){return this.element.down(".resize-controls")},getInformation:function(){return this.controls.down(".resize-info")},setInformation:function(t){if(void 0===t&&(t=!1),this.controls=this.getControls(),void 0!==this.controls&&(this.information=this.getInformation(),void 0!==this.information)){if(t)var e=this.controls.getDimensions();else var e=this.element.getDimensions();void 0!==this.information&&this.information.update("#{width} x #{height}".interpolate(e))}}};Wysija.Image=Class.create(Wysija.Content,WysijaImageAbstract),Wysija.BannerImage=Class.create(Wysija.Banner,WysijaImageAbstract);var WysijaGalleryItemAbstract={initialize:function(t){return info("gallery item -> init"),this.element=$(t),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),cellWidth:parseInt(this.getImageContainer().getWidth()),cellHeight:parseInt(this.getImageContainer().getHeight())}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementRatio:1.48,elementClass:"empty",elementHeight:135,elementWidth:200});var t=this.getOptions();return void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li><li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){this.getTools().hide(),Wysija.locks.showingTools=!1},showTools:function(){this.getTools().show(),Wysija.locks.showingTools=!0},remove:function(){info("gallery item -> remove"),this.element.fire("image:remove")},setup:function(){return info("gallery item -> setup"),this.setupControls(),this.setupTools(),this.getParameters(),this},getParameters:function(){info("gallery item -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!=e&&this.params.set("url",e);var i=$F(t.down('input[name="alt"]'));""!=i&&this.params.set("alt",i)}return this},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},setPosition:function(t){this.element.writeAttribute("wysija_position",t)}};Wysija.GalleryImage=Class.create(Wysija.Gallery,WysijaGalleryItemAbstract);var WysijaTextAbstract={initialize:function(t){return this.element=$(t),this.alignment=this.getDefaultAlignment(),this},save:function(){return this.isEmpty()?null:{value:Base64.encode(this.getTextArea().innerHTML)}},draw:function(){return info("text -> draw"),this.customDraw()+this.customTools()},customDraw:function(){info("text -> custom draw");var t=this.getOptions();return void 0!==this.getTextArea()&&t.set("elementId",this.getTextArea().identify()),void 0===t.get("elementText")?(t.set("placeholderText",Wysija_i18n.drop_block_here),'<div class="text_placeholder empty" id="#{elementId}">#{placeholderText}</div>'.interpolate(this.getOptions())):'<div class="wysija_editable" id="#{elementId}">#{elementText}</div>'.interpolate(this.getOptions())},makeDroppable:function(){this.isDroppable()&&Droppables.add(this.getTextArea().identify(),Wysija.textDropOptions)},removeDroppable:function(){Droppables.remove(this.getTextArea().identify())},hasContent:function(){return void 0!==this.getTextArea()},isDroppable:function(){return this.getTextArea().hasClassName("text_placeholder")},isEmpty:function(){return this.getTextArea().hasClassName("empty")},isEditing:function(){return this.element.hasClassName("wysija_editing")},setup:function(){info("text -> setup"),this.setupEditor(),this.setAlignment(this.getDefaultAlignment()),this.setupTools(),this.makeDroppable()},setAlignment:function(t){return info("text -> setAlignment = "+t),this.alignment=t,this.isEmpty()===!1&&this.disableEditor(),this},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.contentAlignment},setBlockAlignment:function(t){info("text -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},setupEditor:function(){info("text -> setupEditor"),this.getTextContainer().observe("click",this.enableEditor.bind(this))},customTools:function(){return void 0===this.getOptions().get("elementText")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.removeText+'" class="remove"><span></span></a></li></ul>'},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEditing()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&this.showTools()}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.selectingColor!==!0&&this.hideTools()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show()},remove:function(){info("text -> remove"),this.element.fire("text:remove")},enableEditor:function(){!this.isEditing()&&this.element.getElementsByClassName("wysija_editable").length&&(info("text -> enableEditor"),Wysija.hideEditors(),this.element.addClassName("wysija_editing"),tinyMCE.execCommand("mceAddControl",!1,this.getTextArea().identify()),this.element.fire("editor:enable"))},disableEditor:function(){this.isEditing()!==!1&&(info("text -> disableEditor"),this.element.removeClassName("wysija_editing"),tinyMCE.execCommand("mceRemoveControl",!1,this.getTextArea().identify()),this.element.fire("editor:disable"))},setFocus:function(){info("text -> setFocus"),this.enableEditor()},getTextContainer:function(){return this.element},getTextArea:function(){return this.element.down(".wysija_editable")||this.getTextPlaceholder()},getTextPlaceholder:function(){return this.element.down(".text_placeholder")},getTextEditor:function(){return tinymce.get(this.getTextArea().identify())},isAlone:function(){return this.getTextContainer().hasClassName("alone")},setAlone:function(t){this.getTextContainer()[t?"addClassName":"removeClassName"]("alone")}};Wysija.Text=Class.create(Wysija.Content,WysijaTextAbstract),Wysija.Divider=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions(this.getCustomData("divider")),this},save:function(){return void 0===this.getDivider()?null:{src:this.getDivider().readAttribute("src"),width:parseInt(this.getDivider().readAttribute("width")),height:parseInt(this.getDivider().readAttribute("height"))}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){return info("divider -> custom draw"),void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementHeight:1,elementWidth:564}),'<img class="divider" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_divider")},getDivider:function(){return this.getContainer().down("img")}}),Wysija.Raw=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions({elementRaw:""}),this},save:function(){return void 0===this.getRaw()?null:{raw:Base64.encode(this.getRaw().innerHTML)}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){info("raw -> custom draw");var t=this.getOptions();return void 0!==this.getRaw()&&t.set("elementId",this.getRaw().identify()),void 0===t.get("elementRaw")?'<div class="raw empty" id="#{elementId}"></div>'.interpolate(this.getOptions()):'<div class="raw" id="#{elementId}">#{elementRaw}</div>'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_raw")},getRaw:function(){return this.getContainer().down(".raw")}}),Wysija.Post=Class.create(Wysija.Block,{initialize:function(t){return info("post -> init"),this.element=$(t),this},draw:function(){WysijaPopup.open(Wysija_i18n.articleSelectionTitle,WysijaPopup.formatURI(wysijaAJAX.adminurl,"page=wysija_campaigns&action=articles"),this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.AutoPost=Class.create(Wysija.Block,{initialize:function(t){return info("autopost -> init"),this.element=$(t),this},draw:function(){info("autopost -> draw")},setup:function(){info("autopost -> setup"),this.setupControls()},save:function(){info("autopost -> save");var t={};return this.getParameters(),t.params=this.params,t},getParameters:function(){info("autopost -> get parameters"),this.params=[];var t=this.element.down(".wysija_params");return void 0!==t&&t.select("input").each(function(t){this.params.push($H({key:t.name,value:t.value}))}.bind(this)),this},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){return this.controls=this.getControls(),this.controls&&(this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls(),this.element.down(".wysija_settings").show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideControls(),this.element.down(".wysija_settings").hide())}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)),this.settingsButton=this.element.down(".settings"),this.settingsButton.observe("click",function(){this.editSettings()}.bind(this))),this},editSettings:function(){this.getParameters();var t=this.formatParameters();WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.callback.bind(this))},callback:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},formatParameters:function(){var t=["autopost_count="+$$(".wysija_auto-post").length,"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML];return void 0!==this.params&&this.params.length>0&&(this.params.each(function(e){t.push(e.get("key")+"="+e.get("value"))}),t=t.join("&")),t},loadContent:function(){var t=this.element.previousSiblings();if(t.length>0){var e=[];t.each(function(t){"auto-post"===t.readAttribute("wysija_type")&&void 0!==t.down('input[name="post_ids"]')&&e.push(t.down('input[name="post_ids"]').value)}),e.length>0&&(e=e.join(","))}this.getParameters();var i=this.formatParameters();void 0!==e&&e.length>0&&(i+="&exclude="+e);var s=this;wysijaAJAX.task="load_auto_post",wysijaAJAX.wysijaData=i,new Ajax.Request(wysijaAJAX.ajaxurl,{method:"post",asynchronous:!1,parameters:wysijaAJAX,onSuccess:function(t){s.getAutoPostElement().update(Base64.decode(t.responseJSON.result)),Wysija.setSettingsPosition.delay(1)},onFailure:function(){}})},remove:function(){info("autopost remove"),this.removeBlock(function(){Wysija.initAutoPost(),Wysija.setBackgroundColors()})},getAutoPostElement:function(){return this.element.down(".wysija_auto-post")},getSettings:function(){return this.element.down(".wysija_settings")}}),Wysija.PopupAutoPost=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this},draw:function(){var t=["autopost_count="+parseInt($$(".wysija_auto-post").length+1),"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML].join("&");WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.PopupBookmark=Class.create(Wysija.Block,{initialize:function(t){return info("popup bookmark -> init"),this.element=$(t),this},draw:function(){var t="theme="+$("wysija_widgets_settings").down(".theme").innerHTML;WysijaPopup.open(Wysija_i18n.bookmarkSelectionTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=bookmarks&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){t&&Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}});var WysijaPopup={initialized:!1,opened:!1,locked:!1,title:null,url:null,popupWidth:null,popupHeight:null,onSuccess:null,onCancel:null,setSize:function(t,e){return WysijaPopup.popupWidth=t,WysijaPopup.popupHeight=e,this},formatURI:function(t,e){return-1===t.indexOf("?")?t+"?"+e:t+"&"+e},init:function(){if(WysijaPopup.initialized===!1){info("init popup");var t='<div id="wysija_popup_overlay"></div><div id="wysija_popup"><div id="wysija_popup_title"><h3></h3><a id="wysija_popup_close" href="javascript:;"></a></div><div id="wysija_popup_content" class="clearfix"><iframe id="wysija_popup_iframe" marginheight="0" marginwidth="0" frameborder="0"></iframe></div></div>';
3
  $$("body")[0].insert(t),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_close").observe("click",WysijaPopup.cancel),$("wysija_popup_overlay").observe("click",function(t){"wysija_popup_overlay"===t.target.id&&WysijaPopup.cancel()}),WysijaPopup.initialized=!0,$("wysija_popup_iframe").observe("load",function(){null!==$(this).readAttribute("src")&&setTimeout(function(){WysijaPopup.opened=!0,WysijaPopup.setDimensions(),WysijaPopup.hideLoading(),WysijaPopup.showOverlay(),setTimeout(function(){$("wysija_popup").setStyle({visibility:"visible"})},101)},0)})}},lock:function(){WysijaPopup.locked=!0},unlock:function(){WysijaPopup.locked=!1},isLocked:function(){return WysijaPopup.locked},setPosition:function(){if(WysijaPopup.init(),WysijaPopup.opened!==!1){var t=$("wysija_popup").getDimensions(),e=document.viewport.getDimensions(),i=parseInt(Wysija.scroll.top+e.height/2-t.height/2-15,10),s=parseInt(Wysija.scroll.left+e.width/2-t.width/2,10);i<Wysija.scroll.top&&(i=parseInt(Wysija.scroll.top,10)),s<Wysija.scroll.left&&(s=parseInt(Wysija.scroll.left,10)),$("wysija_popup").setStyle({top:i+"px",left:s+"px"})}},setDimensions:function(){if(WysijaPopup.opened!==!1){var t=$("wysija_popup_iframe");if(null!==t){t.doc=null,t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document);var e=0,i=0,s=document.viewport.getDimensions();setTimeout(function(){if($("wysija_popup_iframe").writeAttribute("width",null),$("wysija_popup_iframe").writeAttribute("height",null),null===WysijaPopup.popupWidth||null===WysijaPopup.popupHeight){var n=null;n=WysijaPopup.getElementSize(t.doc.querySelectorAll(".popup_content").length>0?t.doc.querySelectorAll(".popup_content")[0]:t.doc.getElementsByClassName(".popup_content")[0]),i=n.width,e=n.height}else i=WysijaPopup.popupWidth,e=WysijaPopup.popupHeight;e+50>s.height&&(e=s.height-50),$("wysija_popup").setStyle({width:i+"px",height:e+20+"px"}),$("wysija_popup_iframe").writeAttribute("width",i),$("wysija_popup_iframe").writeAttribute("height",e+20),WysijaPopup.setPosition()},100)}}},getElementSize:function(t){var e=t.currentStyle||window.getComputedStyle(t),i=t.offsetWidth;i+=parseInt(e.marginLeft),i+=parseInt(e.marginRight);var s=t.offsetHeight;return s+=parseInt(e.marginTop),s+=parseInt(e.marginBottom),{width:i,height:s}},loadContent:function(t,e){$("wysija_popup_iframe").writeAttribute("src",e),$("wysija_popup_title").down("h3").update(t)},showOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"visible"})},showLoading:function(){$("wysija_popup_overlay").addClassName("loading")},hideOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"hidden"})},hideLoading:function(){$("wysija_popup_overlay").removeClassName("loading")},open:function(t,e,i,s){WysijaPopup.init(),WysijaPopup.showLoading(),WysijaPopup.showOverlay(),void 0!==i&&(WysijaPopup.onSuccess=i),void 0!==s&&(WysijaPopup.onCancel=s),WysijaPopup.loadContent(t,e)},success:function(t){null!==WysijaPopup.onSuccess&&WysijaPopup.onSuccess(t),WysijaPopup.close()},cancel:function(t){null!==WysijaPopup.onCancel&&WysijaPopup.onCancel(t),WysijaPopup.close()},close:function(){return WysijaPopup.isLocked()===!0?!1:($("wysija_popup").writeAttribute("style",""),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_iframe").writeAttribute("src",null),$("wysija_popup_iframe").writeAttribute("height",null),$("wysija_popup_iframe").writeAttribute("width",null),WysijaPopup.onSuccess=null,WysijaPopup.onCancel=null,WysijaPopup.popupWidth=null,WysijaPopup.popupHeight=null,WysijaPopup.opened=!1,!1)}};Wysija.DraggableItem=Class.create({initialize:function(t){this.elementType=$(t).readAttribute("wysija_type"),this.element=$(t).down()||$(t),this.clone=null,t.hasClassName("wysija_item")===!1&&(this.elementType="block_image")},STYLES:new Template("position: absolute; top: #{top}px; left: #{left}px;"),cloneElement:function(){var t=this.element.clone(),e=this.element.cumulativeOffset();if(this.element.hasClassName("wysija_item")){var i=this.getList(),s=this.STYLES.evaluate({top:e.top-i.scrollTop,left:e.left-i.scrollLeft});t.addClassName("wysija_widget"),t.addClassName(this.elementType)}else{var s=this.STYLES.evaluate({top:e.top,left:e.left,width:this.element.getWidth()+"px",height:this.element.getHeight()+"px"});t.writeAttribute("wysija_height",this.element.readAttribute("wysija_height")),t.writeAttribute("wysija_width",this.element.readAttribute("wysija_width")),t.writeAttribute("wysija_src",this.element.readAttribute("wysija_src")),this.element.hasClassName("image_placeholder")&&t.writeAttribute("wysija_parent",(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer")).identify()),t.addClassName("wysija_widget image")}return t.setStyle(s),"image"===this.elementType||"block_image"===this.elementType?t.writeAttribute({elementRatio:this.calculateRatio(),wysija_type:"image"}):t.innerHTML=this.element.innerHTML,t},getOffset:function(){return this.element.offsetTop-this.getList().scrollTop},getList:function(){return this.element.up("ul")},insert:function(){$$("body")[0].insert(this.clone)},onMousedown:function(t){if("block_image"!==this.elementType||"img"===this.element.tagName.toLowerCase()&&"span"!==t.target.tagName.toLowerCase()){null===this.clone&&(this.clone=this.cloneElement(),this.insert());var e=new Draggable(this.clone,{scroll:window,isImage:!1,onStart:function(t,e){this.isImage=t.element.hasClassName("wysija_widget image"),this.isImage===!0&&t.element.setStyle({left:e.pageX+"px",top:e.pageY+"px"}),Wysija.locks.dragging=!0,Wysija.hideTools(),Wysija.hideBlockControls(),Droppables.togglePlaceholders(t,e)},onDrag:function(t,e){Droppables.togglePlaceholders(t,e)},snap:function(t,e,i){return this.isImage===!0?[t+i.offset[0],e+i.offset[1]]:[t,e]},onEnd:function(t){t.destroy(),t.element.remove(),Wysija.locks.dragging=!1,Droppables.hidePlaceholders()},starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction});return e.initDrag(t),e.startDrag(t),e}},calculateRatio:function(){return(this.element.readAttribute("wysija_width")/this.element.readAttribute("wysija_height")*1e3).round()/1e3}}),Object.extend(Wysija.DraggableItem,Observable).observe('a[class="wysija_item"], .wysija_image'),Wysija.ImagePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=parseInt(t.readAttribute("wysija_height"),10),i=parseInt(t.readAttribute("wysija_width"),10),s=(i/e*1e3).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_images_preview").insert(t),$("wj_images_preview").down("img").writeAttribute({width:i,height:e}),$("wj_images_preview").show()}}},onMouseout:function(){$("wj_images_preview").update(""),$("wj_images_preview").hide()}}),Wysija.ThemePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=t.readAttribute("wysija_height"),i=t.readAttribute("wysija_width"),s=(i/e*1e3).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_themes_preview").insert(t),$("wj_themes_preview").down("img").writeAttribute("width",i),$("wj_themes_preview").down("img").writeAttribute("height",e),$("wj_themes_preview").show()}}},onMouseout:function(){$("wj_themes_preview").update(""),$("wj_themes_preview").hide()}}),Object.extend(Wysija.ThemePreview,Observable).observe(".wj_themes li a"),Wysija.TextLinks=Class.create({initialize:function(t){this.element=$(t)},onClick:function(t){return t.stop(),!1}}),Object.extend(Wysija.TextLinks,Observable).observe(".wysija_editable a"),window.document.observe("mousedown",function(t){if(tinymce.editors.length>0){if("mceModalBlocker"===t.target.id)return;if(t.target.hasClassName("mceClose"))return;if(t.target.hasClassName("mceMenu")||void 0!==t.target.up(".mceMenu"))return;void 0===t.target.up(".wysija_text")&&void 0===t.target.up(".wysija_editable")&&t.target.hasClassName("mceText")===!1&&(Wysija.hideEditors(),Wysija.autoSave())}}),document.on("image:drop",function(t,e){var i,s=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i=t.memo.elementData,delete t.memo.elementData,s.block.image.removeDroppable(),s.block.image.setOptions(t.memo),s.block.getImageContainer().writeAttribute("style",""),s.block.getImageContainer().update(s.block.image.draw()),s.block.image.setup(),"object"==typeof i&&s.block.image.setData(i),void 0===s.block.contents?s.block.image.setAlone(!0):(s.block.contents.setAlone(s.block.image.isEmpty()),s.block.image.setAlone(s.block.contents.isEmpty()),s.block.setBlockAlignment(s.block.contents.getDefaultAlignment())),Wysija.hideTools(),s.block.image.setEmpty(!1),s.block.constrainSize(),Wysija.hideTools(),Wysija.autoSave()}),document.on("text:drop",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.removeDroppable(),i.block.contents.setOptions(t.memo),i.block.getTextContainer().update(i.block.contents.draw()),i.block.contents.setup(),i.block.image.isEmpty()===!1?(i.block.image.setAlone(!1),i.block.setBlockAlignment(i.block.image.alignment)):i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.contents.setFocus(),Wysija.hideControls(),Wysija.hideTools(),Wysija.autoSave()}),document.on("image:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.image.hideTools(),i.block.image.removeDroppable(),i.block.image.setOptions({elementSrc:void 0}),i.block.image.element.update(i.block.image.draw()),i.block.image.makeDroppable(),i.block.image.setEmpty(!0),void 0!==i.block.contents&&i.block.contents.isEmpty()===!1&&i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("text:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.getTextContainer().stopObserving("click"),i.block.contents.removeDroppable(),i.block.contents.setOptions({elementText:void 0}),i.block.contents.element.update(i.block.contents.draw()),i.block.contents.makeDroppable(),i.block.image.isEmpty()===!1&&i.block.image.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("editor:enable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("editor:disable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("block:insert",function(t,e){var i=Wysija.get(e);"content"===i.elementType&&(i.block.image.setAlone(i.block.contents.isEmpty()),i.block.contents.setAlone(i.block.image.isEmpty()),i.block.image.setEmpty(i.block.image.isEmpty()),i.block.constrainSize(),Wysija.hideTools())}),document.on("drag:end",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.constrainSize()}),document.observe("dom:loaded",function(){$("wysija_toggle_images").observe("click",function(){return Wysija.toggleImages()===!0?this.addClassName("on").removeClassName("off"):this.addClassName("off").removeClassName("on"),!1})});
languages/wysija-newsletters-da_DK.mo CHANGED
Binary file
languages/wysija-newsletters-el.mo CHANGED
Binary file
languages/wysija-newsletters-fr_CA.mo CHANGED
Binary file
languages/wysija-newsletters-hr_HR.mo CHANGED
Binary file
languages/wysija-newsletters-ko_KR.mo CHANGED
Binary file
languages/wysija-newsletters-mn.mo ADDED
Binary file
languages/wysija-newsletters-nb_NO.mo CHANGED
Binary file
languages/wysija-newsletters-nl_NL.mo CHANGED
Binary file
languages/wysija-newsletters-oc.mo CHANGED
Binary file
languages/wysija-newsletters-pt_PT.mo CHANGED
Binary file
languages/wysija-newsletters-ru_RU.mo CHANGED
Binary file
languages/wysija-newsletters-sl_SI.mo CHANGED
Binary file
languages/wysija-newsletters-sq.mo CHANGED
Binary file
languages/wysija-newsletters-sv_SE.mo CHANGED
Binary file
languages/wysija-newsletters-vi.mo CHANGED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wysija
3
  Tags: newsletter, newsletters, email newsletter, email subscription, newsletter signup, post notification, autoresponder, newsletter alert, auto newsletter, automatic post notification, email newsletters, email signup, auto post notifications, newsletter widget, newsletter builder, subscribe widget, signup widget, email subscription, newsletter plugin, widget, subscription, emailing, mailpoet, wysija, mandrill, sendgrid
4
  Requires at least: 3.3
5
  Tested up to: 4.5.2
6
- Stable tag: 2.7.2
7
  Send newsletters post notifications or autoresponders from WordPress easily, and beautifully. Start to capture subscribers with our widget now.
8
 
9
  == Description ==
@@ -132,6 +132,16 @@ Our [support site](http://support.mailpoet.com/) has plenty of articles and a ti
132
 
133
  == Changelog ==
134
 
 
 
 
 
 
 
 
 
 
 
135
  = 2.7.2 - 2016-06-01 =
136
  * Fixed broken CSS for Premium page
137
  * Fixed Custom Fields not saving on front-end
3
  Tags: newsletter, newsletters, email newsletter, email subscription, newsletter signup, post notification, autoresponder, newsletter alert, auto newsletter, automatic post notification, email newsletters, email signup, auto post notifications, newsletter widget, newsletter builder, subscribe widget, signup widget, email subscription, newsletter plugin, widget, subscription, emailing, mailpoet, wysija, mandrill, sendgrid
4
  Requires at least: 3.3
5
  Tested up to: 4.5.2
6
+ Stable tag: 2.7.3
7
  Send newsletters post notifications or autoresponders from WordPress easily, and beautifully. Start to capture subscribers with our widget now.
8
 
9
  == Description ==
132
 
133
  == Changelog ==
134
 
135
+ = 2.7.3 - 2016-08-08 =
136
+ * Fixed issue with emoji when saving newsletters
137
+ * Prevent encoding of "tel:" URLs
138
+ * Fixed SQL injection vulnerability (Thanks to Force Interactive)
139
+ * Fixed XSS vulnerability (Thanks to Sipke Mellema from Securify B.V.)
140
+ * Fixed PHP warnings on Bounce management
141
+ * Escape commma and quote marks during export
142
+ * Fixed some editor issues
143
+ * Fixed double signed DKIM emails
144
+
145
  = 2.7.2 - 2016-06-01 =
146
  * Fixed broken CSS for Premium page
147
  * Fixed Custom Fields not saving on front-end
views/front/widget_nl.php CHANGED
@@ -212,7 +212,8 @@ class WYSIJA_view_front_widget_nl extends WYSIJA_view_front {
212
  $list_fields_hidden='<input type="hidden" name="wysija[user_list][list_ids]" value="'.$list_exploded.'" />';
213
  }
214
 
215
- $submitbutton=$list_fields.'<input type="submit" '.$disabled_submit.' class="wysija-submit wysija-submit-field" name="submit" value="'.esc_attr($params['submit']).'"/>';
 
216
  $dataCf=$this->customFields($params,$form_id_real,$submitbutton);
217
 
218
  if($dataCf){
@@ -231,11 +232,12 @@ class WYSIJA_view_front_widget_nl extends WYSIJA_view_front {
231
  $data.=$submitbutton.'</p>';
232
  }
233
 
 
234
  // few hiddn field
235
  $data.='<input type="hidden" name="formid" value="'.esc_attr($form_id_real).'" />
236
  <input type="hidden" name="action" value="save" />
237
  '.$list_fields_hidden.'
238
- <input type="hidden" name="message_success" value="'.esc_attr($params["success"]).'" />
239
  <input type="hidden" name="controller" value="subscribers" />';
240
  $data.='<input type="hidden" value="1" name="wysija-page" />';
241
 
212
  $list_fields_hidden='<input type="hidden" name="wysija[user_list][list_ids]" value="'.$list_exploded.'" />';
213
  }
214
 
215
+ $submit_value = (!empty($params['submit'])) ? $params['submit'] : __('Submit', WYSIJA);
216
+ $submitbutton=$list_fields.'<input type="submit" '.$disabled_submit.' class="wysija-submit wysija-submit-field" name="submit" value="'.esc_attr($submit_value).'"/>';
217
  $dataCf=$this->customFields($params,$form_id_real,$submitbutton);
218
 
219
  if($dataCf){
232
  $data.=$submitbutton.'</p>';
233
  }
234
 
235
+ $success_value = (!empty($params['success'])) ? $params['success'] : __('Success', WYSIJA);
236
  // few hiddn field
237
  $data.='<input type="hidden" name="formid" value="'.esc_attr($form_id_real).'" />
238
  <input type="hidden" name="action" value="save" />
239
  '.$list_fields_hidden.'
240
+ <input type="hidden" name="message_success" value="'.esc_attr($success_value).'" />
241
  <input type="hidden" name="controller" value="subscribers" />';
242
  $data.='<input type="hidden" value="1" name="wysija-page" />';
243
 
widgets/wysija_nl.php CHANGED
@@ -237,6 +237,7 @@ class WYSIJA_NL_Widget extends WP_Widget {
237
 
238
  function widget( $args, $instance = null ) {
239
  // this lines feed local variables such as $before_widget ,$after_widget etc...
 
240
  extract( $args );
241
 
242
  //in some case we may pass only one argument, in which case we will just assign the first to the second
@@ -303,7 +304,7 @@ class WYSIJA_NL_Widget extends WP_Widget {
303
  if ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ){
304
  continue;
305
  }
306
- if ( $field == 'success' && $instance[ $field ] == $this->successmsgsub . ' ' . $this->successmsgconf ){
307
  if ( ! $model_config->getValue( 'confirm_dbleoptin' ) ){
308
  $instance[ $field ] = $this->successmsgsub;
309
  }
237
 
238
  function widget( $args, $instance = null ) {
239
  // this lines feed local variables such as $before_widget ,$after_widget etc...
240
+ $args = array_map('sanitize_text_field', $args);
241
  extract( $args );
242
 
243
  //in some case we may pass only one argument, in which case we will just assign the first to the second
304
  if ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ){
305
  continue;
306
  }
307
+ if ( $field == 'success' && !empty($instance[ $field ]) && $instance[ $field ] == $this->successmsgsub . ' ' . $this->successmsgconf ){
308
  if ( ! $model_config->getValue( 'confirm_dbleoptin' ) ){
309
  $instance[ $field ] = $this->successmsgsub;
310
  }