Source

imagegallery1 /

Filename Size Date modified Message
assets
6 B
3.7 KB
2.2 KB
102.8 KB

Image Gallery1

by:

Christian Salazar. christiansalazarh@gmail.com @yiienespanol, dic. 2012.

Screen Capture

http://opensource.org/licenses/bsd-license.php

Repository at Bit Bucket !

Requirement:

Yii 1.1.11

What it does ?

This widget Presents an image list (css & jQuery based) containing a delete icon and a select radio button for each image passed in the 'image' argument, when a user press this buttons your controller is informed via ajax action and manipulates the selected image (mark it as default image for your model or simply delete the image, in server side of course).

The Delete button: Is a button located at the bottom-right of each image, when pressed an action is fired, is your responsability to delete the referenced image on server side.

The Select radio button:
Is located at the left-bottom of each image, when clicked an action is fired and is your responsability to make it the default image for your model.

Usage

Insert and configure the Widget.

[php]
$this->widget('ext.imagegallery1.ImageGallery1',array(
    'images'=>array("<img alt='120' src='bla'>",...more images....),
    'action'=>array('/site/myaction'),  
    'modelId'=>'article12',     // $model->primarykey (as an example)
    'selectedImageId'=>'120',   // the ID for your image...any unique ID
    'onSuccess'=>'function(data){  }',
    'onError'=>'function(e){ alert(e);  }',
));

Handling the request.

[php]
    /**
        the widget invokes this action whenever a user press the delete
        button or the select radio button.

        arguments:

        $action:    'delete' or 'select'.
        $modelid:   the same value passed to the widget in 'modelId'.
        $id:        the unique id image identificator.

        you must act in response to $action.
     */
    public function actionMyAction($modelid, $id, $action){
        // ..do something based on the $action argument
        /   
        if($action == 'select') { ..mark the image $id as default..  } 
        if($action == 'delete') { ... delete the image ref by $id... }
    }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.