1( 2 function () { 3 var VERSION = "1.0"; 4 var NAME = "com.web.components.footercontact"; 5 var scripts = ["js/templates.js"]; 6 var styles = ["css/footercontact.css"]; 7 8 WebCom.ResourceLoader.loadLib("com.jquery", null, true); 9 WebCom.ResourceLoader.loadScript("com.jquery", null, "jquery.json-2.2.min.js"); 10 WebCom.ResourceLoader.loadLib('com.jqueryvalidate', '', true); 11 WebCom.ResourceLoader.loadLib('com.web.components.form', '1.0', true); 12 var lib = new WebCom.ResourceLoader.Library("WebCom.Components.FooterContact", NAME, VERSION, scripts, styles ); 13 WebCom.ResourceLoader.importLib(lib); 14 15 function WebCom_Components_FooterContact() { 16 17 WebCom.Components.Component.apply(this,[lib]); 18 19 var self = this; 20 var config = null; 21 var isFooterContactShowing = false; 22 23 this.init = function (id, config) { 24 self.id = id; 25 self.renderMode = config.miscData.renderMode; 26 self.config = config; 27 28 if (config.listeners) { 29 for (var eventName in config.listeners) { 30 self.on(eventName, config.listeners[eventName].handler, config.listeners[eventName].scope); 31 } 32 } 33 34 formattingValues = { 35 instanceId: self.id, 36 q: config.miscData.q, 37 email: config.componentData.email, 38 emailHtml: (config.componentData.emailHtml == undefined) ? config.componentData.email : config.componentData.emailHtml 39 }; 40 }; 41 42 this.getMasterTemplate = function(/*RenderMode*/ mode) { 43 return self.getTemplate("MasterTemplate", mode); 44 }; 45 46 this.getFormattingValues = function () { 47 if (self.renderMode == 'Edit') { 48 formattingValues.onload = ''; 49 } 50 return formattingValues; 51 }; 52 53 resizeOverlay = function() { 54 55 $('.fc_overlay').css('width', getFullWidth()); 56 $('.fc_overlay').css('height', getFullHeight()); 57 58 function getFullHeight() { 59 return Math.max( 60 $(document).height(), 61 $(window).height(), 62 document.documentElement.clientHeight 63 ); 64 }; 65 66 function getFullWidth() { 67 return Math.min( 68 $(document).width(), 69 $(window).width(), 70 $('html').width(), 71 document.documentElement.clientWidth 72 ); 73 }; 74 }; 75 76 this.redirectFromForms = function() { 77 var strHref = window.location.href; 78 if ( strHref.indexOf("#fc_form_container") > -1 ) { 79 return true; 80 } 81 return false; 82 }; 83 84 this.setupCloseDialog = function() { 85 function closeFormWindow() { 86 isFooterContactShowing = false; 87 if(self.redirectFromForms()) { 88 window.location = window.location.href.replace('#fc_form_container?Ok',''); 89 } else { 90 self.closeWindow(); 91 } 92 } 93 94 $('.fc_close').click(function() { 95 closeFormWindow(); 96 }); 97 $(document).keyup(function(e) { 98 if (e.keyCode == 27 && isFooterContactShowing) { 99 closeFormWindow(); 100 } 101 return true; 102 }); 103 } 104 105 this.onLoad = function(instance) { 106 //Init Form 107 $(window).resize(resizeOverlay); 108 this.initContactForm(); 109 this.setupCloseDialog(); 110 111 if(self.redirectFromForms()) { 112 //If it is a redirect from the forms webapp, show thank you message. 113 self.showFooterContactDialog(instance); 114 } else { 115 //Direct visit to website, show form when user clicks the email link 116 if (self.renderMode != 'Edit') { 117 $('.footer_contact_email').click(function(){ 118 self.showFooterContactDialog(instance); 119 return false; 120 }); 121 } 122 } 123 124 }; 125 126 this.closeWindow = function () { 127 $('.fc_overlay').hide(); 128 $('.fc_container').hide(); 129 } 130 131 this.showFooterContactDialog = function(instance) { 132 var self = this; 133 isFooterContactShowing = true; 134 $('.fc_container').show(); 135 $('.fc_overlay').show(); 136 resizeOverlay(); 137 138 $('.fc_container').css('left', ($(window).width()/2)-$('#fc_form_container').width()/2); 139 }; 140 141 this.initContactForm = function() { 142 var formData = { 143 "id": "fc_form_container", 144 "componentData": { 145 "form": { 146 "id": "webcom-layout-area", 147 "template": "ContactUs", 148 "title": "", 149 "formProcessorUrl": "#", 150 "description": "", 151 "name": "Test", 152 "settings": { 153 "emailDelivery": "copy", 154 "form2db": false, 155 "isSecure": false, 156 "postSubmission": { 157 "message": "Thanks for your submission!", 158 "errorValue": "Oops! There was a problem submitting your form. Please try again.", 159 "type": "showMessage", 160 "url": "http://yourdomain.com/thankyou.html" 161 }, 162 "formatting": { 163 "useCustomStyle": true, 164 "errorMsgColor": "#c70202", 165 "postSubmissionMsgColor": "", 166 "requiredTextColor": "#c70202", 167 "label": { 168 "fontWeight": "", 169 "color": "", 170 "fontFace": "", 171 "size": "" 172 }, 173 "formAlignment": "" 174 } 175 }, 176 "creationTime": {}, 177 "elements": [{ 178 "height": "medium", 179 "validators": [], 180 "isRequired": true, 181 "name": "Name", 182 "width": "large", 183 "children": [],
184 "label": "Name", 185 "type": "TextBox", 186 "defaultValue": "", 187 "options": {} 188 }, { 189 "height": "medium", 190 "validators": [{ 191 "type": "Email" 192 }], 193 "isRequired": true, 194 "name": "customer-email", 195 "width": "large", 196 "children": [], 197 "label": "Email", 198 "type": "Email", 199 "defaultValue": "", 200 "options": {} 201 }, { 202 "height": "medium", 203 "validators": [], 204 "isRequired": false, 205 "name": "subject", 206 "width": "large", 207 "children": [], 208 "label": "Subject", 209 "type": "TextBox", 210 "defaultValue": "", 211 "options": {} 212 }, { 213 "height": "medium", 214 "validators": [], 215 "isRequired": false, 216 "name": "message", 217 "width": "large", 218 "children": [], 219 "label": "Message", 220 "type": "TextArea", 221 "defaultValue": "", 222 "options": {} 223 }, { 224 "height": "medium", 225 "validators": [], 226 "isRequired": false, 227 "name": "Submit", 228 "width": "small", 229 "value": "Submit", 230 "children": [], 231 "label": "Untitled", 232 "type": "Submit", 233 "defaultValue": "", 234 "options": {} 235 }] 236 } 237 }, 238 "miscData": { 239 "q": self.config.miscData.q, 240 "renderMode": self.renderMode 241 }, 242 "settings": { 243 "emailDelivery": "copy", 244 "form2db": false, 245 "isSecure": false, 246 "submissionEmail": { 247 "toAddresses": "[email protected]", 248 "subject": "Someone submitted your Contact Us form", 249 "from": "Contact Us" 250 }, 251 "postSubmission": { 252 "message": "Thanks for your submission!", 253 "errorValue": "Oops! There was a problem submitting your form. Please try again.", 254 "type": "showMessage", 255 "url": "http://yourdomain.com/thankyou.html" 256 }, 257 "formatting": { 258 "useCustomStyle": false, 259 "errorMsgColor": "#c70202", 260 "postSubmissionMsgColor": "", 261 "requiredTextColor": "#c70202", 262 "label": { 263 "fontWeight": "", 264 "color": "", 265 "fontFace": "", 266 "size": "" 267 }, 268 "formAlignment": "" 269 } 270 } 271 }; 272 WebCom.Components.Form.renderInstances([formData],null, { 273 //protocal relative 274// serviceEndPointURL: 'http://forms.services.matrixbuilder.com/forms/footercontact', 275// serviceSecureEndPointURL:'https://forms-services.matrixbuilder.com/forms/footercontact' 276 serviceEndPointURL: '//forms.services.matrixbuilder.com/forms/footercontact', 277 serviceSecureEndPointURL:'//forms-services.matrixbuilder.com/forms/footercontact' 278 }); 279 var formDataInput = $('<input type="hidden" name="formData"/>'); 280 formDataInput.val($.toJSON( formData.componentData )); 281 $('#fc_form_container-form').append(formDataInput); 282 if ( $.browser.msie ) { 283 $("#fc_form_container-form input[type=submit]").click(function(){ 284 var form = $("#fc_form_container-form"); 285 if(form.find("input[name=Name]").val() == "" || form.find("input[name=customer-email]").val() == "") { 286 alert("Please fill out Name & Email"); 287 return false;
288 } 289 290 }); 291 } 292 } 293 } 294 295 WebCom_Components_FooterContact.prototype = new WebCom.Components.Component(); 296 WebCom.Components.FooterContact = { 297 initInstances : function (instances, globalSettings) { 298 for (var i=0; i < instances.length; i++) { 299 var inst = instances[i]; 300 301 if (globalSettings && globalSettings.listeners) { 302 if (inst["listeners"] == null) { 303 inst["listeners"] = globalSettings.listeners; 304 } else { 305 var listeners = inst["listeners"]; 306 for (var eventName in globalSettings.listeners) { 307 if (listeners[eventName] == null) { 308 listeners[eventName] = globalSettings.listeners[listenerName]; 309 } 310 } 311 } 312 } 313 314 var comp = new WebCom_Components_FooterContact(); 315 comp.init(inst.id, inst); 316 comp.render(comp.renderMode); 317 comp.onLoad(inst); 318 } 319 } 320 321 }; 322 323 324 } 325)();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.