protected function getPluginScript($name, $element = null, $callback = null, $callbackCon = null)
    {
        $id = $element ? $element : "jQuery('#" . $this->options['id'] . "')";
        $script = '';
        if ($this->pluginOptions !== false) {
            $this->registerPluginOptions($name);
            $script = "{$id}.{$name}({$this->_hashVar})";
            if ($callbackCon != null) {
                $script = "{$id}.{$name}({$this->_hashVar}, {$callbackCon})";
            }

            if ($callback != null) {
                $script = "jQuery.when({$script}).done({$callback})";
            }

            $script .= ";\n";
        }

        $script = $this->pluginDestroyJs . "\n"  . $script;
        if (!empty($this->pluginEvents)) {
            foreach ($this->pluginEvents as $event => $handler) {
                $function = $handler instanceof JsExpression ? $handler : new JsExpression($handler);
                $script .= "{$id}.on('{$event}', {$function});\n";
            }
        }

        return $script;
    }