| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- fred.combo.ExtendedBoolean = function (config) {
- config.useInt = config.useInt || false;
- var data = [
- [
- _('fred.global.any'),
- null,
- _('fred.global.any')
- ],
- [
- _('yes'),
- (config.useInt ? 1 : true),
- _('yes')
- ],
- [
- _('no'),
- (config.useInt ? 0 : false),
- _('no')
- ]
- ];
- if (config.dataLabel) {
- data = [
- [
- config.dataLabel + ': ' + _('fred.global.any'),
- null,
- _('fred.global.any')
- ],
- [
- config.dataLabel + ': ' + _('yes'),
- (config.useInt ? 1 : true),
- _('yes')
- ],
- [
- config.dataLabel + ': ' + _('no'),
- (config.useInt ? 0 : false),
- _('no')
- ]
- ];
- }
- config = config || {};
- Ext.applyIf(config, {
- store: new Ext.data.SimpleStore({
- fields: ['d', 'v', 'cleanLabel'],
- data: data
- }),
- displayField: 'd',
- valueField: 'v',
- mode: 'local',
- triggerAction: 'all',
- editable: false,
- selectOnFocus: false,
- preventRender: true,
- forceSelection: true,
- enableKeyEvents: true,
- tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{cleanLabel}</div></tpl>')
- });
- fred.combo.ExtendedBoolean.superclass.constructor.call(this, config);
- };
- Ext.extend(fred.combo.ExtendedBoolean, MODx.combo.ComboBox);
- Ext.reg('fred-combo-extended-boolean', fred.combo.ExtendedBoolean);
- fred.combo.Boolean = function (config) {
- config.useInt = config.useInt || false;
- var data = [
- [
- _('yes'),
- (config.useInt ? 1 : true),
- _('yes')
- ],
- [
- _('no'),
- (config.useInt ? 0 : false),
- _('no')
- ]
- ];
- if (config.dataLabel) {
- data = [
- [
- config.dataLabel + ': ' + _('yes'),
- (config.useInt ? 1 : true), _('yes')
- ],
- [
- config.dataLabel + ': ' + _('no'),
- (config.useInt ? 0 : false), _('no')
- ]
- ];
- }
- config = config || {};
- Ext.applyIf(config, {
- store: new Ext.data.SimpleStore({
- fields: ['d', 'v', 'cleanLabel'],
- data: data
- }),
- displayField: 'd',
- valueField: 'v',
- mode: 'local',
- triggerAction: 'all',
- editable: false,
- selectOnFocus: false,
- preventRender: true,
- forceSelection: true,
- enableKeyEvents: true,
- tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{cleanLabel}</div></tpl>')
- });
- fred.combo.Boolean.superclass.constructor.call(this, config);
- };
- Ext.extend(fred.combo.Boolean, MODx.combo.ComboBox, {
- setValue: function (value) {
- if ((value !== undefined) && (this.config.useInt === true)) {
- if (value === '') {
- value = null;
- }
- if (value !== '') {
- value = +value;
- }
- }
- fred.combo.Boolean.superclass.setValue.call(this, value);
- }
- });
- Ext.reg('fred-combo-boolean', fred.combo.Boolean);
- fred.combo.BlueprintCategories = function (config) {
- config = config || {};
- Ext.applyIf(config, {
- name: 'category',
- hiddenName: 'category',
- displayField: 'name',
- valueField: 'id',
- fields: ['name', 'id'],
- pageSize: 20,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/blueprint_categories/getlist',
- addAll: config.addAll || 0
- }
- });
- fred.combo.BlueprintCategories.superclass.constructor.call(this, config);
- };
- Ext.extend(fred.combo.BlueprintCategories, MODx.combo.ComboBox);
- Ext.reg('fred-combo-blueprint-categories', fred.combo.BlueprintCategories);
- fred.combo.ElementCategories = function (config) {
- config = config || {};
- Ext.applyIf(config, {
- name: 'category',
- hiddenName: 'category',
- displayField: 'name',
- valueField: 'id',
- fields: ['name', 'id'],
- pageSize: 20,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/element_categories/getlist',
- addAll: config.addAll || 0
- }
- });
- fred.combo.ElementCategories.superclass.constructor.call(this, config);
- };
- Ext.extend(fred.combo.ElementCategories, MODx.combo.ComboBox);
- Ext.reg('fred-combo-element-categories', fred.combo.ElementCategories);
- fred.combo.ElementOptionSets = function (config) {
- config = config || {};
- Ext.applyIf(config, {
- name: 'option_set',
- hiddenName: 'option_set',
- displayField: 'name',
- valueField: 'id',
- fields: ['name', 'id', 'description'],
- tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name:htmlEncode}</span>',
- '<tpl if="description"> - <span style="font-style:italic">{description:htmlEncode}</span></tpl>',
- '</div></tpl>'),
- pageSize: 20,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/element_option_sets/getlist',
- addEmpty: config.addEmpty || 0
- }
- });
- fred.combo.ElementOptionSets.superclass.constructor.call(this, config);
- };
- Ext.extend(fred.combo.ElementOptionSets, MODx.combo.ComboBox);
- Ext.reg('fred-combo-element-option-sets', fred.combo.ElementOptionSets);
- fred.combo.Themes = function (config) {
- config = config || {};
- Ext.applyIf(config, {
- name: 'theme',
- hiddenName: 'theme',
- displayField: 'name',
- valueField: 'id',
- fields: ['name', 'id', 'theme_folder'],
- pageSize: 20,
- isUpdate: false,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/themes/getlist',
- addAll: config.addAll || 0
- }
- });
- fred.combo.Themes.superclass.constructor.call(this, config);
- if (config.isUpdate === false) {
- this.store.load();
- this.store.on('load', function(store, r) {
- this.setValue(r[0].id);
- this.fireEvent('select', this, r[0]);
- }, this, {single: true});
- }
- };
- Ext.extend(fred.combo.Themes, MODx.combo.ComboBox);
- Ext.reg('fred-combo-themes', fred.combo.Themes);
- fred.combo.Template = function (config, getStore) {
- config = config || {};
- if (!config.clearBtnCls) {
- if (MODx.config.connector_url) {
- config.clearBtnCls = 'x-form-trigger';
- } else {
- config.clearBtnCls = null;
- }
- }
- if (!config.expandBtnCls) {
- if (MODx.config.connector_url) {
- config.expandBtnCls = 'x-form-trigger';
- } else {
- config.expandBtnCls = null;
- }
- }
- Ext.applyIf(config, {
- name: 'templates',
- hiddenName: 'templates[]',
- displayField: 'templatename',
- valueField: 'id',
- fields: ['templatename', 'id'],
- mode: 'remote',
- triggerAction: 'all',
- typeAhead: true,
- editable: true,
- forceSelection: false,
- pageSize: 20,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/extra/gettemplates',
- hideUsed: 1
- }
- });
- Ext.applyIf(config, {
- store: new Ext.data.JsonStore({
- url: config.url,
- root: 'results',
- totalProperty: 'total',
- fields: config.fields,
- errorReader: MODx.util.JSONReader,
- baseParams: config.baseParams || {},
- remoteSort: config.remoteSort || false,
- autoDestroy: true
- })
- });
- if (getStore === true) {
- config.store.load();
- return config.store;
- }
- fred.combo.Template.superclass.constructor.call(this, config);
- this.config = config;
- return this;
- };
- Ext.extend(fred.combo.Template, Ext.ux.form.SuperBoxSelect);
- Ext.reg('fred-combo-template', fred.combo.Template);
- fred.combo.RootCategory = function (config, getStore) {
- config = config || {};
- if (!config.clearBtnCls) {
- if (MODx.config.connector_url) {
- config.clearBtnCls = 'x-form-trigger';
- } else {
- config.clearBtnCls = null;
- }
- }
- if (!config.expandBtnCls) {
- if (MODx.config.connector_url) {
- config.expandBtnCls = 'x-form-trigger';
- } else {
- config.expandBtnCls = null;
- }
- }
- Ext.applyIf(config, {
- name: 'categories',
- hiddenName: 'categories[]',
- displayField: 'category',
- valueField: 'category',
- fields: ['category'],
- mode: 'remote',
- triggerAction: 'all',
- typeAhead: true,
- editable: true,
- forceSelection: false,
- pageSize: 20,
- url: fred.config.connectorUrl,
- baseParams: {
- action: 'mgr/extra/getcategories',
- parent: 0
- }
- });
- Ext.applyIf(config, {
- store: new Ext.data.JsonStore({
- url: config.url,
- root: 'results',
- totalProperty: 'total',
- fields: config.fields,
- errorReader: MODx.util.JSONReader,
- baseParams: config.baseParams || {},
- remoteSort: config.remoteSort || false,
- autoDestroy: true
- })
- });
- if (getStore === true) {
- config.store.load();
- return config.store;
- }
- fred.combo.RootCategory.superclass.constructor.call(this, config);
- this.config = config;
- return this;
- };
- Ext.extend(fred.combo.RootCategory, Ext.ux.form.SuperBoxSelect);
- Ext.reg('fred-combo-root-category', fred.combo.RootCategory);
- fred.combo.InstalledPackages = function (config) {
- config = config || {};
- Ext.applyIf(config, {
- name: 'package',
- hiddenName: 'package',
- displayField: 'package_name',
- valueField: 'package_name',
- fields: ['package_name'],
- pageSize: 20,
- isUpdate: false,
- url: fred.config.connectorUrl,
- editable: true,
- forceSelection: false,
- typeAhead: false,
- selectOnFocus: false,
- baseParams: {
- action: 'mgr/extra/getinstalledpackages'
- }
- });
- fred.combo.Themes.superclass.constructor.call(this, config);
- if (config.isUpdate === false) {
- this.store.load();
- this.store.on('load', function(store, r) {
- this.setValue(r[0].id);
- this.fireEvent('select', this, r[0]);
- }, this, {single: true});
- }
- };
- Ext.extend(fred.combo.InstalledPackages, MODx.combo.ComboBox);
- Ext.reg('fred-combo-installed-packages', fred.combo.InstalledPackages);
|