Exemplo n.º 1
0
    /**
     * Print dynamic buttons javascript
     */
    protected function render_scripts()
    {
        // get all screens from the registry
        $items = $this->policy->registry()->get_all();
        // make sure we got some items
        if (count($items)) {
            // new script helper
            $script = new ICE_Script();
            $script->begin_logic();
            foreach ($items as $item) {
                $conf = null;
                $icons = $item->icon()->config();
                if ($icons) {
                    $conf = sprintf('{%s}', $icons);
                }
                // menu button and maybe toolbar button
                ?>
				$('a#<?php 
                $this->render_id('menu', 'item', $item->property('name'));
                ?>
').button(<?php 
                print $conf;
                ?>
);
				<?php 
                if ($item->property('toolbar')) {
                    ?>
					$('a#<?php 
                    $this->render_id('toolbarbutton', $item->property('name'));
                    ?>
').button(<?php 
                    print $conf;
                    ?>
);
				<?php 
                }
            }
            $logic = $script->end_logic();
            $logic->set_property('alias', true);
            $logic->set_property('ready', true);
        } else {
            return null;
        }
        // begin rendering
        ?>
		<script type="text/javascript">
			<?php 
        print $script->export();
        ?>
		</script><?php 
    }
Exemplo n.º 2
0
    /**
     * Generate all script for creating buttons and return script object
     *
     * @return ICE_Script
     */
    protected function get_button_script()
    {
        // script object
        $script = new ICE_Script();
        // loop all items
        foreach ($this->get_items() as $item_slug => $item) {
            // reset vars
            $conf = null;
            $icon_primary = null;
            $icon_secondary = null;
            // check for primary
            if (isset($item['icon_primary'])) {
                $icon_primary = $item['icon_primary'];
            }
            // check for secondary
            if (isset($item['icon_secondary'])) {
                $icon_secondary = $item['icon_secondary'];
            }
            // get any?
            if ($icon_primary || $icon_secondary) {
                // new icon object
                $icon = new ICE_Icon($icon_primary, $icon_secondary);
                // format conf
                $conf = sprintf('{%s}', $icon->config());
            }
            /*\*/
            if (0) {
            }
            ?>
<script><?php 
            /*\*/
            // start capturing
            $script->begin_logic();
            // the button statement
            ?>
			jQuery('a#<?php 
            print $this->element()->id($item_slug);
            ?>
').button(<?php 
            print $conf;
            ?>
); <?php 
            // end capturing
            $script->end_logic();
            /*\*/
            if (0) {
            }
            ?>
</script><?php 
            /*\*/
        }
        return $script;
    }