diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-03-06 13:58:10 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-03-06 13:58:10 +0400 |
commit | e2024eeb63f9a43359a9c39b290da7baafada301 (patch) | |
tree | 0291f58a7545da48a691bccf7c29e010de9bb310 | |
parent | 455bf2b15e2aacb75f6d25b63c6bb162a6429981 (diff) |
Small fixes/refactor
-rw-r--r-- | core/AssetManager.php | 48 | ||||
-rwxr-xr-x | plugins/Annotations/templates/annotations.js | 8 | ||||
-rw-r--r-- | plugins/CoreHome/templates/datatable.js | 34 | ||||
-rw-r--r-- | plugins/CoreHome/templates/jqplot.js | 2 |
4 files changed, 53 insertions, 39 deletions
diff --git a/core/AssetManager.php b/core/AssetManager.php index 836a6dff8a..3ef46bf0d3 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -126,23 +126,30 @@ class Piwik_AssetManager $mergedContent = cssmin::minify($mergedContent); $mergedContent = str_replace("\n", "\r\n", $mergedContent); - // Remove the previous file - self::removeMergedAsset(self::MERGED_CSS_FILE); + Piwik_PostEvent('AssetManager.filterMergedCss', $mergedContent); - // Tries to open the new file - $newFilePath = self::getAbsoluteMergedFileLocation(self::MERGED_CSS_FILE); - $newFile = @fopen($newFilePath, "w"); + self::writeAssetToFile($mergedContent, self::MERGED_CSS_FILE); + } - if (!$newFile) { - throw new Exception ("The file : " . $newFile . " can not be opened in write mode."); - } + private static function writeAssetToFile($mergedContent, $name) + { + // Remove the previous file + self::removeMergedAsset($name); - // Write the content in the new file - fwrite($newFile, $mergedContent); - fclose($newFile); - } + // Tries to open the new file + $newFilePath = self::getAbsoluteMergedFileLocation($name); + $newFile = @fopen($newFilePath, "w"); - /** + if (!$newFile) { + throw new Exception ("The file : " . $newFile . " can not be opened in write mode."); + } + + // Write the content in the new file + fwrite($newFile, $mergedContent); + fclose($newFile); + } + + /** * Returns individual CSS file inclusion directive(s) using the markup <link> * * @return string @@ -235,20 +242,9 @@ class Piwik_AssetManager } $mergedContent = str_replace("\n", "\r\n", $mergedContent); - // Remove the previous file - self::removeMergedAsset(self::MERGED_JS_FILE); - - // Tries to open the new file - $newFilePath = self::getAbsoluteMergedFileLocation(self::MERGED_JS_FILE); - $newFile = @fopen($newFilePath, "w"); - - if (!$newFile) { - throw new Exception ("The file : " . $newFile . " can not be opened in write mode."); - } + Piwik_PostEvent('AssetManager.filterMergedJs', $mergedContent); - // Write the content in the new file - fwrite($newFile, $mergedContent); - fclose($newFile); + self::writeAssetToFile($mergedContent, self::MERGED_JS_FILE); } /** diff --git a/plugins/Annotations/templates/annotations.js b/plugins/Annotations/templates/annotations.js index 0c6975f011..62f63a59aa 100755 --- a/plugins/Annotations/templates/annotations.js +++ b/plugins/Annotations/templates/annotations.js @@ -489,8 +489,12 @@ var showAnnotationViewer = function(domElem, idSite, date, period, lastN, callba annotationCount = +$(this).attr('data-count'); // modify the starred count & make sure the correct image is used - var newStarCount = starredCount + starAmt, - newImg = 'themes/default/images/' + (newStarCount > 0 ? 'yellow_marker.png' : 'grey_marker.png'); + var newStarCount = starredCount + starAmt; + if(newStarCount > 0) { + var newImg = 'themes/default/images/yellow_marker.png'; + } else { + var newImg = 'themes/default/images/grey_marker.png'; + } $(this).attr('data-starred', newStarCount).find('img').attr('src', newImg); // modify the annotation count & hide/show based on new count diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js index 52ff2558f3..705cab4175 100644 --- a/plugins/CoreHome/templates/datatable.js +++ b/plugins/CoreHome/templates/datatable.js @@ -358,7 +358,26 @@ dataTable.prototype = handleSort: function(domElem) { var self = this; - if( self.param.enable_sort ) + + function getSortImageSrc() { + var imageSortSrc = false; + if (currentIsSubDataTable) { + if (self.param.filter_sort_order == 'asc') { + imageSortSrc = 'themes/default/images/sort_subtable_asc.png'; + } else { + imageSortSrc = 'themes/default/images/sort_subtable_desc.png'; + } + } else { + if (self.param.filter_sort_order == 'asc') { + imageSortSrc = 'themes/default/images/sortasc.png'; + } else { + imageSortSrc = 'themes/default/images/sortdesc.png'; + } + } + return imageSortSrc; + } + + if( self.param.enable_sort ) { $('.sortable', domElem).off('click.dataTableSort').on('click.dataTableSort', function() @@ -372,19 +391,14 @@ dataTable.prototype = { // are we in a subdatatable? var currentIsSubDataTable = $(domElem).parent().hasClass('cellSubDataTable'); - - var prefixSortIcon = ''; - if(currentIsSubDataTable) - { - prefixSortIcon = '_subtable_'; - } - var imageSortWidth = 16; - var imageSortHeight = 16; + var imageSortSrc = getSortImageSrc(); + var imageSortWidth = 16; + var imageSortHeight = 16; // we change the style of the column currently used as sort column // adding an image and the class columnSorted to the TD $(".sortable#"+self.param.filter_sort_column+' #thDIV', domElem).parent() .addClass('columnSorted') - .prepend('<div id="sortIconContainer"><img id="sortIcon" width="'+imageSortWidth+'" height="'+imageSortHeight+'" src="themes/default/images/sort'+prefixSortIcon+ self.param.filter_sort_order+'.png" /></div>'); + .prepend('<div id="sortIconContainer"><img id="sortIcon" width="'+imageSortWidth+'" height="'+imageSortHeight+'" src="'+ imageSortSrc +'" /></div>'); } } }, diff --git a/plugins/CoreHome/templates/jqplot.js b/plugins/CoreHome/templates/jqplot.js index 34f6d88c52..36180dc842 100644 --- a/plugins/CoreHome/templates/jqplot.js +++ b/plugins/CoreHome/templates/jqplot.js @@ -275,7 +275,7 @@ JQPlot.prototype = { // ------------------------------------------------------------ - // EVOLTION CHART + // EVOLUTION CHART // ------------------------------------------------------------ prepareEvolutionChart: function(targetDivId, lang) { |