root.libs.composum.nodes.commons.components.js.components.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of composum-nodes-commons Show documentation
Show all versions of composum-nodes-commons Show documentation
general components and objects to use the Sling API
(function(){CPM.namespace("core.components");(function(c,d,e){c.const=_.extend(c.const||{},{form:{css:{base:"form-widget",action:{slingPost:"form-action_Sling-POST"},status:{valid:"valid-form",invalid:"invalid-form"},selector:{item:".multi-form-item"},tab:{base:"composum-commons-form-tab",tabbed:"composum-commons-form-tabbed",_nav:"-nav",_panel:"-panel"}},translate:{uri:{object:"/bin/cpm/core/translate.object.json",status:"/bin/cpm/core/translate.status.json"}}}});c.FormWidget=Backbone.View.extend({initialize:function(a){this.isSlingPost=
this.$el.hasClass(c.const.form.css.action.slingPost);this.initTabs()},registerWidget:function(a){a.changed("FormWidget",_.bind(this.onChanged,this))},onChanged:function(a){this.formChanged=!0},isChanged:function(){return!0===this.formChanged},isValid:function(a){this.validationReset();return this.validate(a)},initTabs:function(){var a=c.const.form.css.tab;if(1===this.$("."+a.tabbed).length){this.tabbed={$el:this.$("."+a.tabbed)};var b=this.tabbed.$nav=this.$("."+a.base+a._nav),f=this.tabbed.map={};
b.html("");this.tabbed.$el.find("."+a.base+a._panel).each(function(){var a=$(this),c=a.attr("id"),d=a.data("label");b.append('\x3cli role\x3d"presentation"\x3e\x3ca role\x3d"tab" data-toggle\x3d"tab" href\x3d"#'+c+'" data-key\x3d"'+a.data("key")+'"\x3e'+d+"\x3c/a\x3e\x3c/li\x3e");f[c]={id:c,label:d,panel:a}})}},validationReset:function(){var a=c.const.form.css;this.tabbed&&this.tabbed.$nav.find("li").removeClass("has-error");this.$(d.const.css.selector.general).each(function(){this.view&&_.isFunction(this.view.validationReset)&&
this.view.validationReset.apply(this.view)});this.$el.removeClass(a.status.invalid);this.$el.addClass(a.status.valid)},onValidationFault:function(){var a=c.const.form.css;this.$el.removeClass(a.status.valid);this.$el.addClass(a.status.invalid);if(this.tabbed){var b=this,f=void 0;this.tabbed.list.forEach(function(a){a=$(a);0a.indexOf("("))a=a.split(",");else try{var c=eval(a);_.isFunction(c)&&(a=c)}catch(h){}return _.isFunction(a)||_.isArray(a)?{minLength:1,source:a}:a}},focus:function(){this.$textField.focus()},
selectAll:function(){this.$textField.select()},textField:function(){return this.$input},reset:function(){this.valid=void 0;this.$textField.closest(".form-group").removeClass("has-error");this.$textField.val(void 0)}});d.register(".widget.text-field-widget",c.TextFieldWidget);c.ComboBoxWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[a]);this.$menu=this.$(".dropdown-menu");this.$menu.find("li a").click(_.bind(this.optionSelected,this));this.$textField.on("change.combobox",
_.bind(this.onValueChange,this))},onValueChange:function(){var a=this.getValue();this.$("[data-value-class]").each(function(){var b=$(this),c=b.data("value-class").replace(/\$/g,a);b.removeClass().addClass(c)});this.$menu.find("li").removeClass("active");this.$menu.find('li[data-value\x3d"'+a+'"]').addClass("active")},optionSelected:function(a){a.preventDefault();a=$(a.currentTarget).closest("li").data("value");this.setValue(a,!0);this.$menu.dropdown("toggle");return!1}});d.register(".widget.combobox-widget",
c.ComboBoxWidget);c.TextAreaWidget=d.Widget.extend({initialize:function(a){d.Widget.prototype.initialize.apply(this,[a]);this.initRules(this.$input);this.rules&&(this.$input.on("keyup.validate",_.bind(this.validate,this)),this.$input.on("change.validate",_.bind(this.validate,this)))},retrieveInput:function(){return this.$el.is("textarea")?this.$el:this.$("textarea")},getValue:function(){return this.$input[0].value},setValue:function(a,b){""+this.$input.text()!==""+a&&(this.$input[0].value=a,b&&this.$input.trigger("change"))},
focus:function(){this.$input.focus()},selectAll:function(){this.$input.select()},reset:function(){this.valid=void 0;this.$input.closest(".form-group").removeClass("has-error");this.$input.val(void 0)}});d.register(".widget.text-area-widget",c.TextAreaWidget);c.PathSelector=d.Widget.extend({initialize:function(a){d.Widget.prototype.initialize.apply(this,[a]);this.setPathWidget(a.pathWidget)},setPathWidget:function(a){this.pathWidget&&this.pathWidget.$input.off("change."+this.getEventId());if(this.pathWidget=
a)this.pathWidget.$input.on("change."+this.getEventId(),_.bind(this.pathInputChanged,this))},pathInputChanged:function(){if(!this.busy){this.busy=!0;var a=this.pathWidget.getValue();a!==this.lastPathSelected&&0===a.indexOf("/")&&e.getJson("/bin/cpm/nodes/node.tree.json"+e.encodePath(a),_.bind(function(a){this.lastPathSelected=a.path;this.onPathChanged(a.path)},this));this.busy=!1}}});c.PathWidget=c.TextFieldWidget.extend({initialize:function(a){a=_.extend({selector:{button:"button.select"},typeahead:{minLength:1,
source:_.bind(function(a,c){if(0===a.indexOf("/")){var b=this.getRootPath();"/"!==b&&(a=b+a);e.getJson("/bin/cpm/nodes/node.typeahead.json"+a,function(a){if("/"!==b)for(var d=0;dthis.maxValue&&(a=this.maxValue));c.TextFieldWidget.prototype.setValue.apply(this,[void 0!==a?a:this.blankAllowed()?void 0:this.defValue,b])},blankAllowed:function(){return void 0===
this.rules||this.rules.blank||!0!==this.rules.required},getNumber:function(a){void 0===a&&(a=this.getValue());if(void 0!==a){try{a=parseInt(a)}catch(b){}isNaN(a)&&(a=void 0)}return a},increment:function(){if(this.stepSize){var a=this.getNumber();this.setValue(void 0!==a?a+this.stepSize:void 0!==this.defValue?this.defValue:this.minValue,!0)}},decrement:function(){if(this.stepSize){var a=this.getNumber();this.setValue(void 0!==a?a-this.stepSize:void 0!==this.defValue?this.defValue:this.maxValue,!0)}},
clear:function(){this.setValue(void 0,!0)},extValidate:function(a){a=this.getNumber(a);var b=void 0!==a||this.blankAllowed();b&&void 0!==a&&(void 0!==this.minValue&&(b=a>=this.minValue),b&&void 0!==this.maxValue&&(b=a<=this.maxValue));return b}});d.register(".widget.number-field-widget",c.NumberFieldWidget);c.DateTimeWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[a]);this.data={locale:this.$el.data("locale")||"en",format:this.$el.data("format")||
"YYYY-MM-DD HH:mm:ss",options:{weeks:e.toBoolean(this.$el.data("weeks"),!0)}};this.$el.datetimepicker({locale:this.data.locale,format:this.data.format,extraFormats:"YY-MM-DD;YY-MM-DD HH:mm;YY-MM-DD HH:mm ZZ;YY-MM-DD HH:mm:ss;YY-MM-DD HH:mm:ss ZZ;YYYY-MM-DD;YYYY-MM-DD HH:mm;YYYY-MM-DD HH:mm ZZ;YYYY-MM-DD HH:mm:ss;YYYY-MM-DD HH:mm:ss ZZ;DD.MM.YY;DD.MM.YY HH:mm;DD.MM.YY HH:mm ZZ;DD.MM.YY HH:mm:ss;DD.MM.YY HH:mm:ss ZZ;DD.MM.YYYY;DD.MM.YYYY HH:mm;DD.MM.YYYY HH:mm ZZ;DD.MM.YYYY HH:mm:ss;DD.MM.YYYY HH:mm:ss ZZ;D. MMMM YYYY;D. MMMM YYYY HH:mm;D. MMMM YYYY HH:mm ZZ;D MMM YYYY;D MMM YYYY HHmm;D MMM YYYY HHmm ZZ;D MMM YYYY HH:mm;D MMM YYYY HH:mm ZZ;MMMM D, YYYY;MMMM D, YYYY HHmm;MMMM D, YYYY HHmm ZZ;MMMM D, YYYY HH:mm;MMMM D, YYYY HH:mm ZZ;MM/DD/YYYY;MM/DD/YYYY HHmm;MM/DD/YYYY HHmm ZZ;MM/DD/YYYY HH:mm;MM/DD/YYYY HH:mm ZZ".split(";"),
calendarWeeks:this.data.options.weeks,showTodayButton:!0,showClear:!0,showClose:!0});this.datetimepicker=this.$el.data("DateTimePicker")},setValue:function(a,b){this.datetimepicker.date(a?moment(a,this.data.format):null);this.validate();b&&this.$el.trigger("change",[a])}});d.register(".widget.date-time-widget",c.DateTimeWidget);c.FileUploadWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[a]);var b=this.$el.data("options");a.showPreview=!0;
a.showUpload=!1;a.fileType="any";b&&(0<=b.indexOf("hidePreview")&&(a.showPreview=!1,a.showUploadedThumbs=!1),0<=b.indexOf("showUpload")&&(a.showUpload=!0),this.getOptionText(a,b,"browse"),this.getOptionText(a,b,"remove"),this.getOptionText(a,b,"upload"));if(b=this.$el.data("type"))a.fileType=b;this.whatever=this.$textField.fileinput(a);this.$widget=this.$el.closest(".file-input-new");this.$inputCaption=this.$widget.find(".kv-fileinput-caption")},getOptionText:function(a,b,c){var d;0<=(d=b.indexOf(c+
":"))&&(a[c+"Label"]=b.substring(d+c.length+1).trim(),0<(d=a[c+"Label"].indexOf(","))&&(a[c+"Label"]=a[c+"Label"].substring(0,d).trim()),0<(d=a[c+"Label"].indexOf(":"))&&(a[c+"Title"]=a[c+"Label"].substring(d+1).trim(),a[c+"Label"]=a[c+"Label"].substring(0,d).trim()))},setValue:function(a,b){},grabFocus:function(){this.$inputCaption.focus()},reset:function(){this.$textField.fileinput("clear")},setName:function(a){this.$textField.attr("name",a)},getFileName:function(){var a=this.$textField.fileinput("getFileStack");
return 1===a.length?a[0].name:void 0}});d.register(".widget.file-upload-widget",c.FileUploadWidget);c.PropertyNameWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[_.extend({typeahead:{autocomplete:"auto",minLength:1,source:"jcr:data jcr:description jcr:lastModified jcr:lastModifiedBy jcr:mixinTypes jcr:primaryType jcr:title sling:redirect sling:resourceType".split(" ")}},a)])}});d.register(".widget.property-name-widget",c.PropertyNameWidget);
c.RepositoryNameWidget=c.TextFieldWidget.extend({nameChanged:function(a,b){"jcr:primaryType"===a?b.setWidgetType.apply(b,["jcr-primaryType"]):"jcr:mixinTypes"===a&&b.setWidgetType.apply(b,["jcr-mixinTypes"])}});d.register(".widget.repository-name-widget",c.RepositoryNameWidget);c.PrimaryTypeWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[_.extend({typeahead:"/bin/cpm/core/system.primaryTypes.json"},a)])}});d.register(".widget.primary-type-widget",
c.PrimaryTypeWidget);c.MixinTypeWidget=c.TextFieldWidget.extend({initialize:function(a){c.TextFieldWidget.prototype.initialize.apply(this,[_.extend({typeahead:"/bin/cpm/core/system.mixinTypes.json"},a)])}});d.register(".widget.mixin-type-widget",c.MixinTypeWidget)})(CPM.core.components,CPM.widgets,CPM.core)})();
© 2015 - 2025 Weber Informatics LLC | Privacy Policy