public function addInlineStyle($text, $order = self::DEFAULT_ORDER)
	{
		if (!empty($text)) {
			$this->document->addStyleDeclaration($text);

		}
	}
	/**
	 * Test...
	 *
	 * @covers  JDocument::addStyleDeclaration
	 *
	 * @return void
	 */
	public function testAddStyleDeclaration()
	{
		$this->object = new JDocument;

		$this->object->addStyleDeclaration('My Style');
		$this->assertThat(
			$this->object->_style['text/css'],
			$this->equalTo('My Style'),
			'JDocument->addStyleDeclaration failed'
		);

		$this->object->addStyleDeclaration('My Style', 'my/type');
		$this->assertThat(
			$this->object->_style['my/type'],
			$this->equalTo('My Style'),
			'JDocument->addStyleDeclaration failed'
		);

		$this->object->addStyleDeclaration('My Second Style');
		$this->assertThat(
			$this->object->_style['text/css'],
			$this->equalTo('My Style' . chr(13) . 'My Second Style'),
			'JDocument->addStyleDeclaration failed'
		);
	}
Beispiel #3
0
 public function populate()
 {
     if (!empty($this->script_files)) {
         ksort($this->script_files);
         foreach ($this->script_files as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $this->document->addScript($entry);
             }
         }
     }
     if (!empty($this->inline_scripts)) {
         ksort($this->inline_scripts);
         foreach ($this->inline_scripts as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $this->document->addScriptDeclaration($entry);
             }
         }
     }
     if (!empty($this->style_files)) {
         ksort($this->style_files);
         foreach ($this->style_files as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $this->document->addStyleSheet($entry);
             }
         }
     }
     if (!empty($this->inline_styles)) {
         ksort($this->inline_styles);
         foreach ($this->inline_styles as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $this->document->addStyleDeclaration($entry);
             }
         }
     }
     // Generate domready script
     if (!empty($this->domready_scripts)) {
         ksort($this->domready_scripts);
         $strHtml = 'window.addEvent(\'domready\', function() {';
         foreach ($this->domready_scripts as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $strHtml .= chr(13) . $entry;
             }
         }
         $strHtml .= chr(13) . '});' . chr(13);
         $this->document->addScriptDeclaration($strHtml);
     }
     if (!empty($this->loadevent_scripts)) {
         ksort($this->loadevent_scripts);
         $strHtml = 'window.addEvent(\'load\', function() {';
         foreach ($this->loadevent_scripts as $order => $order_entries) {
             foreach ($order_entries as $entry_key => $entry) {
                 $strHtml .= chr(13) . $entry;
             }
         }
         $strHtml .= chr(13) . '});' . chr(13);
         $this->document->addScriptDeclaration($strHtml);
     }
     $this->populated = true;
     $this->reset();
 }
 /**
  * Method to return the button label of this plugin
  *
  * @return string
  *
  * @since  3.7.0
  */
 public function onMediaEditorButtonLabel()
 {
     $this->doc->addStyleDeclaration('.icon-imagecropper:before { content: "\\2a"; }');
     return JText::_('PLG_MEDIA_EDITOR_IMAGECROPPER_BUTTON_LABEL');
 }
 /**
  * Wrapper for JDocumentHTML::addStyleDeclaration()
  */
 public function addStyleDeclaration($content, $type = 'text/css')
 {
     return $this->document->addStyleDeclaration($content, $type);
 }
Beispiel #6
0
 /**
  * @testdox  Test that calling addStyleDeclaration twice returns an instance of $this
  */
 public function testEnsureTwoAddStyleDeclarationCallsReturnsThisObject()
 {
     $this->assertSame($this->object, $this->object->addStyleDeclaration('<style>div { padding: 0; }</style>'));
     $this->assertSame($this->object, $this->object->addStyleDeclaration('<style>h1 { font-size: 4px; }</style>'));
 }
Beispiel #7
0
 /**
  * @param $text
  */
 public function addInlineStyle($text)
 {
     $this->document->addStyleDeclaration($text);
 }
Beispiel #8
0
 /**
  * @param JDocument $doc
  * @param object $location
  *
  * @return string
  */
 private function getMapCode($doc, $location)
 {
     // Set Google map API key and load the script
     $apiKey = "";
     if ($this->params->get("google_maps_key")) {
         $apiKey = "&amp;key=" . $apiKey;
     }
     $doc->addScript("//maps.googleapis.com/maps/api/js?sensor=false" . $apiKey);
     // Put the JS code that initializes the map.
     $js = '
     function initialize() {
             
         var cfLatlng = new google.maps.LatLng(' . $location->latitude . ', ' . $location->longitude . ');
             
         var map_canvas = document.getElementById("crowdf_map_canvas");
         var map_options = {
           center: cfLatlng,
           disableDefaultUI: true,
           zoom: 8,
           mapTypeId: google.maps.MapTypeId.ROADMAP
         }
         var map = new google.maps.Map(map_canvas, map_options)
                 
         var marker = new google.maps.Marker({
             position: cfLatlng,
             map: map
         });
                 
           
       }
     google.maps.event.addDomListener(window, "load", initialize);
     ';
     $doc->addScriptDeclaration($js);
     // Put the map element style
     $style = '#crowdf_map_canvas {
             width:  ' . $this->params->get("google_maps_width", 300) . 'px;
         height: ' . $this->params->get("google_maps_height", 300) . 'px;
     }';
     $doc->addStyleDeclaration($style);
     // Prepare the HTML code
     $code = '
         <div class="col-md-5">
             <div id="crowdf_map_canvas"></div>
         </div>';
     return $code;
 }