Logo

Docs

  • HOME

Source: widgets/JsWidgetsController.js

 /**
 * @namespace RMPWidgets
 * @deprecated
 * @see {@link RMPApplication}
 */
function JsWidgetsController()
{
    // members
    this.widgetsIdArray = new Array(); // Widgets Id
    this.widgetsArray = new Array(); // Widgets
        
    // methods
	/** @private */
    JsWidgetsController.prototype.addWidget= function( widget )
    {
    	// used to add none indexed widgets only
    	if( widget.conf.index != -1 ) return;
    	
    	var id = widget.conf.id;
        var elementIndex = this.findId( id );
        
        if( elementIndex == (-1) ) 
        {
        	this.widgetsIdArray.push( id );
            this.widgetsArray.push( widget );
        }
        else
        {
        	this.widgetsArray[ elementIndex ] = widget;
        }
    };
    /** @private */
    JsWidgetsController.prototype.removeLastIndexedWidget= function( id )
    {
    	var elementIndex = this.findId( id );
        
        if( elementIndex != (-1) )
        {
    		(this.widgetsArray[ elementIndex ]).pop(); // delete last element
        }
    };
    /** @private */
    JsWidgetsController.prototype.addArrayWidget= function( arrayWidget, id )
    {
    	var elementIndex = this.findId( id );
        
        if( elementIndex == (-1) )
        {
            this.widgetsIdArray.push( id );
            this.widgetsArray.push( arrayWidget );
        }
        else
        {
            this.widgetsArray[ elementIndex ] = arrayWidget;
        }
    };
    /** @private */
    JsWidgetsController.prototype.getWidget = function( id )
    {
        var result = null;
        var elementIndex = this.findId( id );

        if( elementIndex != (-1) )
        {   
            result = this.widgetsArray[ elementIndex ];
        }  
        
        return result;
    };
    /** @private */
    JsWidgetsController.prototype.getIndexedWidget = function( id, index )
    {
        var result = this.getWidget(id);
        if( result!=null && index>=0 ){
        	// indexed widget
        	return result[index];
        }
        return result;
    };
    /** @private */
    JsWidgetsController.prototype.didWidgetFound= function( id )
    {
    	return  this.findId( id ) != (-1) ;
        
    };
    /** @private */
    JsWidgetsController.prototype.size = function()
    {
        return (this.widgetsIdArray.length);  
    };
    /** @private */
    JsWidgetsController.prototype.clear = function()
    {
        for( var i = 0; i < this.widgetsIdArray.length; i++ )
        {
            this.widgetsIdArray.pop(); this.widgetsArray.pop();   
        }
    };
    /** @private */
    JsWidgetsController.prototype.widgetsIdSet = function()
    {
        return (this.widgetsIdArray);
    };
    /** @private */
    JsWidgetsController.prototype.findId = function( id )
    {
        var result = (-1);

        for( var i = 0; i < this.widgetsIdArray.length; i++ )
        {
            if( this.widgetsIdArray[ i ] == id )
            {
                result = i;
                break;
            }
        }
        return result;
    };
    /** @private */
    JsWidgetsController.prototype.removeWidget = function( id )
    {
        var elementIndex = this.findId( id );

        if( elementIndex != (-1) )
        {
    		this.widgetsIdArray = this.widgetsIdArray.removeAt(elementIndex);
            this.widgetsArray = this.widgetsArray.removeAt(elementIndex);
        }  
        
        return ;
    };
	/**
	 * This function calls a javascript function for each widget of web interface.
	 * @deprecated
	 * @see {@link RMPApplication.forEachWidget}
	 * @function RMPWidgets.forEachWidget
	 * @memberof RMPWidgets
	 * @param {RMPApplication~WidgetVisitor} visitor - The function applied to widgets
	 * @example
	 * <listing>
		 function visitor(widget) {
			try {
				widget.setEnabled(true);
			} catch(err){
				console.log(err);
			}
		 }
		 RMPWidgets.forEachWidget(visitor);
	 * </listing>
	 */
    JsWidgetsController.prototype.forEachWidget = function(functionToApply){
    	for( var i = 0; i < this.widgetsIdArray.length; i++ )
        {
            if( !this.widgetsArray[ i ].isIndexed() ) functionToApply( this.widgetsArray[ i ] );
            else
            {
            	var indexedWidget = this.widgetsArray[ i ];
            	for( var j=0; j<indexedWidget.length; j++ ) functionToApply( indexedWidget[ j ] );
            }
        }
    };

    /**
	 * This function returns all widgets of web interface.
	 * @deprecated
	 * @see {@link RMPApplication.getAllWidgets}
	 * @function RMPWidgets.getAllWidgets
	 * @memberof RMPWidgets
	 * @returns {Object[]}
	 * @example
	 * <listing>
		var widgetList = RMPWidgets.getAllWidgets();
		for( i=0 ; i< widgetList.length ; i++ ){
			widgetList[i].setVisible(true);
		}
	 * </listing>
	 */
    JsWidgetsController.prototype.getAllWidgets = function()
    {
        return (this.widgetsArray);   
    };

     /**
	 * This function returns all widgets' ID of web interface.
	 * @deprecated
	 * @see {@link RMPApplication.getAllWidgetsId}
	 * @function RMPWidgets.getAllWidgetsId
	 * @memberof RMPWidgets
	 * @returns {String[]}
	 */
    JsWidgetsController.prototype.getAllWidgetsId = function()
    {
        return (this.widgetsIdArray);   
    };
	/** @private */
    JsWidgetsController.prototype.removeAt = function( index )
    {
      var part1 = this.slice( 0, index);
      var part2 = this.slice( index+1 );

      return( part1.concat( part2 ) );
    };
    Array.prototype.removeAt = this.removeAt;
    
    
    // API for indexed widgets (JS array)
    Array.prototype.isIndexed = function(){ return true; };
    
    Array.prototype.forEachWidget = function( functionToApply ){
		for( var j=0; j<this.length; j++ ) functionToApply( this[ j ] );
    };
    
    Array.prototype.setActive = function( active ){
		for( var j=0; j<this.length; j++ ) this[ j ].setActive( active );
    };
}
//instantiate native widgets Controller
RMPWidgets = new JsWidgetsController();

Index

Widgets

  • RMP_Array

  • RMP_Button

  • RMP_Captcha

  • RMP_CheckBox

  • RMP_CustomWidget

  • RMP_FileUpload

  • RMP_GeoLocation

  • RMP_History

  • RMP_Html

  • RMP_HtmlPreview

  • RMP_Image

  • RMP_IncludedCollection

  • RMP_List

  • RMP_ListBox

  • RMP_ListenerComponent

  • RMP_MultiSelectionCheckBox

  • RMP_ProgressBar

  • RMP_RadioButton

  • RMP_Report

  • RMP_Scripter

  • RMP_Section

  • RMP_Spinner

  • RMP_StaticTextArea

  • RMP_TabPanel

  • RMP_TextInput

  • RMP_Tree

  • RMP_UrlInput

Static

  • JSON

  • RMP_RunMyApp

  • RMPApplication

  • RMPWidgets


© Akorbi Digital RMP. All Rights Reserved - Legal terms - Contact