1// ----------------------------------------------------------------------- 2// Copyright 2016 Sitecore Corporation A/S 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 4// except in compliance with the License. You may obtain a copy of the License at 5// http://www.apache.org/licenses/LICENSE-2.0 6// 7// Unless required by applicable law or agreed to in writing, software distributed under the 8// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 9// either express or implied. See the License for the specific language governing permissions 10// and limitations under the License. 11// ------------------------------------------------------------------------------------------- 12 13(function (root, factory) { 14 'use strict'; 15 if (typeof define === 'function' && define.amd) { 16 // use AMD define funtion to support AMD modules if in use 17 define(['exports'], factory); 18 } else if (typeof exports === 'object') { 19 // to support CommonJS 20 factory(exports); 21 } 22 23 root.CXAForm = factory; 24}(this, function (element) { 25 var form = { 26 RootElement: element 27 }; 28 form.FormRoot = $(form.RootElement).find('form'); 29 form.SubmitButton = $(form.FormRoot).find(':submit'); 30 31 form.Disable = function () { 32 $(form.RootElement).find('input') 33 .attr('disabled', 'disabled'); 34 $(form.RootElement).find('button') 35 .attr('disabled', 'disabled'); 36 $(form.RootElement).find('a') 37 .attr('disabled', 'disabled'); 38 }; 39 40 form.Enable = function () { 41 $(form.RootElement).find('input') 42 .removeAttr('disabled'); 43 $(form.RootElement).find('button') 44 .removeAttr('disabled'); 45 $(form.RootElement).find('a') 46 .removeAttr('disabled'); 47 }; 48 49 form.EnableInDesignEditing = function () { 50 var $inDesignButtons = $(form.RootElement).find(".disabled-in-design"); 51 52 $inDesignButtons.removeAttr("disabled"); 53 54 $inDesignButtons.on("click", function (e) { 55 e.preventDefault(); 56 return false; 57 }); 58 }; 59 60 form.OnBegin = function () { 61 MessageContext.ClearAllMessages(); 62 $(form.SubmitButton).button('loading'); 63 form.Disable(); 64 }; 65 form.OnSuccess = function (data) { 66 // To be overridden by actual component 67 }; 68 69 form.OnComplete = function () { 70 $(form.SubmitButton).button('reset'); 71 form.Enable(); 72 }; 73 74 form.Init = function (instance) { 75 if (CXAApplication.RunningMode === RunningModes.ExperienceEditor) { 76 form.Disable(); 77 } 78 79 if (!instance.RootElement) { instance.RootElement = form.RootElement; } 80 if (!instance.OnBegin) { instance.OnBegin = form.OnBegin; } 81 if (!instance.OnComplete) { instance.OnComplete = form.OnComplete; } 82 if (!instance.OnSuccess) { instance.OnSuccess = form.OnSuccess; } 83 }; 84 85 return form; 86}));
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.