Skip to content

Instantly share code, notes, and snippets.

View jagjeetgit's full-sized avatar

Jagjeet Singh jagjeetgit

View GitHub Profile
@jagjeetgit
jagjeetgit / photograph-dor-integration.js
Created June 5, 2018 04:42
Value commit script for Image Field Integration with DOR
function readImage (file) {
var reader = new FileReader();
reader.addEventListener("load", function (e) {
$(".guide-fu-fileItemList").hide();
var image = new Image();
$(".photo-upload .preview .imageP").remove();
$(".photo-upload .preview .text").remove();
image.width = 170;image.height = 220;
image.className = "imageP";
image.addEventListener("load", function () {
@jagjeetgit
jagjeetgit / photograph-valueCommit.js
Last active May 15, 2018 12:26
Value Commit script for Photograph type Image Field in Adaptive Form
function readImage (file) {
var reader = new FileReader();
reader.addEventListener("load", function (e) {
$(".guide-fu-fileItemList").hide();
var image = new Image();
$(".photo-upload .preview .imageP").remove();
$(".photo-upload .preview .text").remove();
image.width = 170;image.height = 220;
image.className = "imageP";
image.addEventListener("load", function () {
@jagjeetgit
jagjeetgit / photograph-initialize.js
Last active May 15, 2018 12:24
Initialize script for Photograph type Image Field in Adaptive Form
$(".photo-upload").prepend(" <div class='preview'' style='border:2px solid;height:225px;width:175px;text-align:center'><br><br><div class='text'>3.5mm * 4.5mm<br>2Mb max<br>Min 600dpi</div></div><br>");
@jagjeetgit
jagjeetgit / autocomplete.js
Created February 23, 2018 02:03
Auto Complete Widget in AEM Forms
//Refer to the detailed working of autocomplete widget, if you are lost with the below javascript code.
//addressLookup is the name of widget
//Creating a widget extending the textfield.
$.widget( "xfaWidget.addressLookup", $.xfaWidget.textField, {
_widgetName:"addressLookup",
//overriding render function of text field.
render : function() {
var $control = $.xfaWidget.defaultWidget.prototype.render.apply(this, arguments);
if($control){
$control.autocomplete({
@jagjeetgit
jagjeetgit / root-panel-tap-out-validate.js
Created February 20, 2018 06:28
Uniform Field Validations on Tap out or Focus out using Root Panel Script
var classesToValidate = ["guideNumericBox"]; //add "," separated widget classes you want to validate on focus/tap out
this.visit(function(cmp) {
if(classesToValidate.indexOf(cmp.className) !== -1) {
$("." + cmp.name + " input").focusout(function() {
guideBridge.resolveNode(cmp.name).validate();
@jagjeetgit
jagjeetgit / tap-out-validation.js
Created February 20, 2018 05:52
Field Validation on Tap-out or Focus out
$(".numericbox1518941620523 input").focusout(function() {
guideBridge.resolveNode("numericbox1518941620523").validate(); //replace numericbox1518941620523 by the name of your text field
});
@jagjeetgit
jagjeetgit / customfunction3.js
Created February 18, 2018 06:55
Custom Function as an Object
var c = {
    b : {
        interest : function(p,r,t) {
              return p * r * t /100;
        }
    }
};
@jagjeetgit
jagjeetgit / customfunction2.js
Created February 18, 2018 06:50
Custom Function Expression Style
var interest;
interest = function(p,r,t) { 
   return p * r * t /100;
};
@jagjeetgit
jagjeetgit / customfunction1.js
Last active February 18, 2018 06:46
Custom Function - Function Style
/** JS DOC goes here*/
function interest(p,r,t) {
return p * r * t /100;
}
@jagjeetgit
jagjeetgit / jsdocexample.js
Created February 18, 2018 06:44
Custom Function JS DOc Example
/**
*Returns the simple interest
@name interest Simple Interest
@param {number} p Principal Amount
@param {number} r Rate Of Interest
@param {number} t Time of Loan (in Years)
@returns {number} calculated Simple Interest for the inputs
*/