new file: view/theme/smoothly/js/jquery.ae.image.resize.js
new file: view/theme/smoothly/js/jquery.ae.image.resize.min.js modified: view/theme/smoothly/theme.php
This commit is contained in:
parent
c616b05a33
commit
002168ebd9
|
@ -0,0 +1,69 @@
|
||||||
|
(function( $ ) {
|
||||||
|
|
||||||
|
$.fn.aeImageResize = function( params ) {
|
||||||
|
|
||||||
|
var aspectRatio = 0
|
||||||
|
// Nasty I know but it's done only once, so not too bad I guess
|
||||||
|
// Alternate suggestions welcome :)
|
||||||
|
, isIE6 = $.browser.msie && (6 == ~~ $.browser.version)
|
||||||
|
;
|
||||||
|
|
||||||
|
// We cannot do much unless we have one of these
|
||||||
|
if ( !params.height && !params.width ) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate aspect ratio now, if possible
|
||||||
|
if ( params.height && params.width ) {
|
||||||
|
aspectRatio = params.width / params.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach handler to load
|
||||||
|
// Handler is executed just once per element
|
||||||
|
// Load event required for Webkit browsers
|
||||||
|
return this.one( "load", function() {
|
||||||
|
|
||||||
|
// Remove all attributes and CSS rules
|
||||||
|
this.removeAttribute( "height" );
|
||||||
|
this.removeAttribute( "width" );
|
||||||
|
this.style.height = this.style.width = "";
|
||||||
|
|
||||||
|
var imgHeight = this.height
|
||||||
|
, imgWidth = this.width
|
||||||
|
, imgAspectRatio = imgWidth / imgHeight
|
||||||
|
, bxHeight = params.height
|
||||||
|
, bxWidth = params.width
|
||||||
|
, bxAspectRatio = aspectRatio;
|
||||||
|
|
||||||
|
// Work the magic!
|
||||||
|
// If one parameter is missing, we just force calculate it
|
||||||
|
if ( !bxAspectRatio ) {
|
||||||
|
if ( bxHeight ) {
|
||||||
|
bxAspectRatio = imgAspectRatio + 1;
|
||||||
|
} else {
|
||||||
|
bxAspectRatio = imgAspectRatio - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only resize the images that need resizing
|
||||||
|
if ( (bxHeight && imgHeight > bxHeight) || (bxWidth && imgWidth > bxWidth) ) {
|
||||||
|
|
||||||
|
if ( imgAspectRatio > bxAspectRatio ) {
|
||||||
|
bxHeight = ~~ ( imgHeight / imgWidth * bxWidth );
|
||||||
|
} else {
|
||||||
|
bxWidth = ~~ ( imgWidth / imgHeight * bxHeight );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.height = bxHeight;
|
||||||
|
this.width = bxWidth;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.each(function() {
|
||||||
|
|
||||||
|
// Trigger load event (for Gecko and MSIE)
|
||||||
|
if ( this.complete || isIE6 ) {
|
||||||
|
$( this ).trigger( "load" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})( jQuery );
|
|
@ -0,0 +1 @@
|
||||||
|
(function(d){d.fn.aeImageResize=function(a){var i=0,j=d.browser.msie&&6==~~d.browser.version;if(!a.height&&!a.width)return this;if(a.height&&a.width)i=a.width/a.height;return this.one("load",function(){this.removeAttribute("height");this.removeAttribute("width");this.style.height=this.style.width="";var e=this.height,f=this.width,g=f/e,b=a.height,c=a.width,h=i;h||(h=b?g+1:g-1);if(b&&e>b||c&&f>c){if(g>h)b=~~(e/f*c);else c=~~(f/e*b);this.height=b;this.width=c}}).each(function(){if(this.complete||j)d(this).trigger("load")})}})(jQuery);
|
|
@ -2,18 +2,118 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: Smoothly
|
* Name: Smoothly
|
||||||
* Version: Version 0.3
|
* Description: Theme opzimized for Tablets
|
||||||
* Author: Alex <info@pixelbits.de>
|
* Version: 0.4
|
||||||
* Maintainer: Alex alex@friendica.pixelbits.de>
|
* Author: Alex <https://friendica.pixelbits.de/profile/alex>
|
||||||
* Description: Theme optimized for Tablets (iPad etc.)
|
* Maintainer: Alex <https://friendica.pixelbits.de/profile/alex>
|
||||||
* Screenshot: <a href="screenshot.png">Screenshot</a>
|
* Screenshot: <a href="screenshot.jpg">Screenshot</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$a->theme_info = array(
|
||||||
|
'extends' => 'smoothly',
|
||||||
|
);
|
||||||
|
function smoothly_init(&$a) {
|
||||||
$a->page['htmlhead'] .= <<< EOT
|
$a->page['htmlhead'] .= <<< EOT
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
function insertFormatting(comment,BBcode,id) {
|
||||||
|
|
||||||
|
var tmpStr = $("#comment-edit-text-" + id).val();
|
||||||
|
if(tmpStr == comment) {
|
||||||
|
tmpStr = "";
|
||||||
|
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
|
||||||
|
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
|
||||||
|
openMenu("comment-edit-submit-wrapper-" + id);
|
||||||
|
$("#comment-edit-text-" + id).val(tmpStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea = document.getElementById("comment-edit-text-" +id);
|
||||||
|
if (document.selection) {
|
||||||
|
textarea.focus();
|
||||||
|
selected = document.selection.createRange();
|
||||||
|
if (BBcode == "url"){
|
||||||
|
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
|
||||||
|
} else
|
||||||
|
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
|
||||||
|
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
|
||||||
|
var start = textarea.selectionStart;
|
||||||
|
var end = textarea.selectionEnd;
|
||||||
|
if (BBcode == "url"){
|
||||||
|
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
|
||||||
|
} else
|
||||||
|
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cmtBbOpen(id) {
|
||||||
|
$(".comment-edit-bb-" + id).show();
|
||||||
|
}
|
||||||
|
function cmtBbClose(comment, id) {
|
||||||
|
$(".comment-edit-bb-" + id).hide();
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('html').click(function() { $("#nav-notifications-menu" ).hide(); });
|
$('.group-edit-icon').hover(
|
||||||
|
function() {
|
||||||
|
$(this).addClass('icon'); $(this).removeClass('iconspacer');},
|
||||||
|
function() {
|
||||||
|
$(this).removeClass('icon'); $(this).addClass('iconspacer');}
|
||||||
|
);
|
||||||
|
|
||||||
|
$('.sidebar-group-element').hover(
|
||||||
|
function() {
|
||||||
|
id = $(this).attr('id');
|
||||||
|
$('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
|
||||||
|
|
||||||
|
function() {
|
||||||
|
id = $(this).attr('id');
|
||||||
|
$('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$('.savedsearchdrop').hover(
|
||||||
|
function() {
|
||||||
|
$(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
|
||||||
|
function() {
|
||||||
|
$(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
|
||||||
|
);
|
||||||
|
|
||||||
|
$('.savedsearchterm').hover(
|
||||||
|
function() {
|
||||||
|
id = $(this).attr('id');
|
||||||
|
$('#drop-' + id).addClass('icon'); $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
|
||||||
|
|
||||||
|
function() {
|
||||||
|
id = $(this).attr('id');
|
||||||
|
$('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
EOT;
|
EOT;
|
||||||
|
// get resize configuration
|
||||||
|
|
||||||
|
$resize=false;
|
||||||
|
$site_resize = get_config('smoothly', 'resize' );
|
||||||
|
if(local_user()) $resize = get_pconfig(local_user(), 'smoothly', 'resize' );
|
||||||
|
|
||||||
|
if ($resize===false) $resize=$site_resize;
|
||||||
|
if ($resize===false) $resize=0;
|
||||||
|
|
||||||
|
if (intval($resize) > 0) {
|
||||||
|
//load jquery.ae.image.resize.js
|
||||||
|
$imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/smoothly/js/jquery.ae.image.resize.js";
|
||||||
|
$a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
|
||||||
|
$a->page['htmlhead'] .= '
|
||||||
|
<script>
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$(".wall-item-content img").aeImageResize({height: '.$resize.', width: '.$resize.'});
|
||||||
|
});
|
||||||
|
</script>';}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user