diff --git a/RoboFile.php b/RoboFile.php index f37ced8..7cd1aaa 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -29,4 +29,27 @@ class RoboFile extends \Robo\Tasks { $this->taskExec( 'lessc css/laps.less css/laps.css' )->run(); } + + /** + * Copies tooltip.js from Bootstrap sources and edits plugin name. + */ + public function tooltip() { + + $tooltip = 'js/tooltip.js'; + + $this->taskWriteToFile( $tooltip ) + ->textFromFile( 'vendor/twbs/bootstrap/js/tooltip.js' ) + ->run(); + + $replacements = array( + '+function ($) {' => '// modified to use lapstooltip as plugin name' . "\n\n" . '+function ($) {', + 'this.init(\'tooltip\'' => 'this.init(\'lapstooltip\'', + 'bs.tooltip' => 'bs.lapstooltip', + '$.fn.tooltip' => '$.fn.lapstooltip', + ); + + foreach ( $replacements as $from => $to ) { + $this->taskReplaceInFile( $tooltip )->from( $from )->to( $to )->run(); + } + } } \ No newline at end of file