| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- MWF.xApplication.Selector = MWF.xApplication.Selector || {};
- MWF.xApplication.Template = MWF.xApplication.Template || {};
- MWF.xApplication.Template.Selector = MWF.xApplication.Template.Selector || {};
- MWF.xDesktop.requireApp("Selector", "Person", null, false);
- MWF.xApplication.Template.Selector.Custom = new Class({
- Extends: MWF.xApplication.Selector.Person,
- options: {
- "style": "default",
- "count": 0,
- "title": "选择列表",
- "selectableItems" : [],
- "values": [],
- "expand": false
- },
- initialize: function(container, options){
- this.setOptions(options);
- this.path = "/x_component_Selector/$Selector/";
- this.cssPath = "/x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
- this._loadCss(true);
- this.container = $(container);
- this.selectedItems = [];
- this.items = [];
- },
- loadSelectItems: function(addToNext){
- this.options.selectableItems.each( function( it ){
- var name = typeOf( it ) == "string" ? it : it.name;
- var id = typeOf( it ) == "string" ? it : it.id;
- var item = this._newItem({ name : name, id : id }, this, this.itemAreaNode );
- this.items.push(item);
- }.bind(this))
- },
- _scrollEvent: function(y){
- return true;
- },
- _getChildrenItemIds: function(data){
- return data.viewList || [];
- },
- _listItemByKey: function(callback, failure, key){
- return false;
- },
- _getItem: function(callback, failure, id, async){
- this.action.getProcess(function(json){
- if (callback) callback.apply(this, [json]);
- }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
- },
- _newItemSelected: function(data, selector, item){
- return new MWF.xApplication.Template.Selector.Custom.ItemSelected(data, selector, item)
- },
- _listItemByPinyin: function(callback, failure, key){
- return false;
- },
- _newItem: function(data, selector, container, level){
- return new MWF.xApplication.Template.Selector.Custom.Item(data, selector, container, level);
- }
- });
- MWF.xApplication.Template.Selector.Custom.Item = new Class({
- Extends: MWF.xApplication.Selector.Person.Item,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Organization/Selector/$Selector/default/icon/processicon.png)");
- },
- loadSubItem: function(){
- return false;
- },
- checkSelectedSingle: function(){
- var selectedItem = this.selector.options.values.filter(function(item, index){
- if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
- if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
- return false;
- }.bind(this));
- if (selectedItem.length){
- this.selectedSingle();
- }
- },
- checkSelected: function(){
- var selectedItem = this.selector.selectedItems.filter(function(item, index){
- return (item.data.id === this.data.id) || (item.data.name === this.data.name);
- }.bind(this));
- if (selectedItem.length){
- //selectedItem[0].item = this;
- selectedItem[0].addItem(this);
- this.selectedItem = selectedItem[0];
- this.setSelected();
- }
- }
- });
- MWF.xApplication.Template.Selector.Custom.ItemSelected = new Class({
- Extends: MWF.xApplication.Selector.Person.ItemSelected,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Organization/Selector/$Selector/default/icon/processicon.png)");
- },
- check: function(){
- if (this.selector.items.length){
- var items = this.selector.items.filter(function(item, index){
- return (item.data.id === this.data.id) || (item.data.name === this.data.name);
- }.bind(this));
- this.items = items;
- if (items.length){
- items.each(function(item){
- item.selectedItem = this;
- item.setSelected();
- }.bind(this));
- }
- }
- }
- });
|