commit
98540779da
46
3.0/modules/fittoscreen/controllers/admin_fittoscreen.php
Normal file
46
3.0/modules/fittoscreen/controllers/admin_fittoscreen.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
|
||||||
|
class Admin_fittoscreen_Controller extends Admin_Controller {
|
||||||
|
public function index() {
|
||||||
|
print $this->_get_view();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_view($form=null) {
|
||||||
|
$view = new Admin_View("admin.html");
|
||||||
|
$view->page_title = t("Fit to Screen parameters");
|
||||||
|
|
||||||
|
$view->content = new View("admin_fittoscreen.html");
|
||||||
|
$view->content->form = (empty($form) ? $this->_get_form() : $form) ;
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_form() {
|
||||||
|
$form = new Forge("admin/fittoscreen/save", "", "post", array("id" => "g-admin-form"));
|
||||||
|
|
||||||
|
$form->dropdown("width_unit")->label(t("Image width unit"))->options(array("px"=>"pixel margin","pr"=>"max pourcentage"))->selected(module::get_var("fittoscreen", "width_unit"));
|
||||||
|
$form->input("width")->label(t('width'))->rules("required|valid_numeric|length[1,5]")->value(module::get_var("fittoscreen", "width"));
|
||||||
|
$form->dropdown("height_unit")->label(t("Image height unit"))->options(array("px"=>"pixel margin","pr"=>"max pourcentage"))->selected(module::get_var("fittoscreen", "height_unit"));
|
||||||
|
$form->input("height")->label(t('height'))->rules("required|valid_numeric|length[1,5]")->value(module::get_var("fittoscreen", "height"));
|
||||||
|
|
||||||
|
$form->submit("submit")->value(t("Save"));
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(){
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
$form = $this->_get_form();
|
||||||
|
if ($form->validate()) {
|
||||||
|
module::set_var("fittoscreen", "width_unit", $form->width_unit->value);
|
||||||
|
module::set_var("fittoscreen", "width", $form->width->value);
|
||||||
|
module::set_var("fittoscreen", "height_unit", $form->height_unit->value);
|
||||||
|
module::set_var("fittoscreen", "height", $form->height->value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
print $this->_get_view($form);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
13
3.0/modules/fittoscreen/helpers/fittoscreen_event.php
Normal file
13
3.0/modules/fittoscreen/helpers/fittoscreen_event.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
|
||||||
|
class fittoscreen_event_Core {
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
$menu->get("settings_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("fittoscreen_menu")
|
||||||
|
->label(t("Fit to Screen"))
|
||||||
|
->url(url::site("admin/fittoscreen")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
14
3.0/modules/fittoscreen/helpers/fittoscreen_installer.php
Normal file
14
3.0/modules/fittoscreen/helpers/fittoscreen_installer.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
|
||||||
|
class fittoscreen_installer {
|
||||||
|
static function install() {
|
||||||
|
module::set_var("fittoscreen", "width", "150");
|
||||||
|
module::set_var("fittoscreen", "height", "200");
|
||||||
|
module::set_version("fittoscreen", 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
9
3.0/modules/fittoscreen/helpers/fittoscreen_theme.php
Normal file
9
3.0/modules/fittoscreen/helpers/fittoscreen_theme.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
|
||||||
|
class fittoscreen_theme {
|
||||||
|
static function photo_top($theme) {
|
||||||
|
return new View("fittoscreen_photo.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
7
3.0/modules/fittoscreen/module.info
Normal file
7
3.0/modules/fittoscreen/module.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name = "Fit to Screen"
|
||||||
|
description = "Dynamicaly resize the photo size to fit the screen.<br />Version 1.0 | By <a href=http://www.bouthors.fr>Matthieu Bouthors</a> | <a href=http://codex.gallery2.org/Gallery3:Modules:fittoscreen>Visit plugin Site</a> | <a href=http://gallery.menalto.com/node/103929>Support</a> | <a href=fittoscreen>Settings</a>"
|
||||||
|
version = 10
|
||||||
|
author_name = "Matthieu Bouthors"
|
||||||
|
author_url = "http://www.bouthors.fr"
|
||||||
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:Fittoscreen"
|
||||||
|
discuss_url = "http://gallery.menalto.com/node/103929"
|
7
3.0/modules/fittoscreen/views/admin_fittoscreen.html.php
Normal file
7
3.0/modules/fittoscreen/views/admin_fittoscreen.html.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= t("Fit to Screen parameters") ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<?= $form ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
35
3.0/modules/fittoscreen/views/fittoscreen_photo.html.php
Normal file
35
3.0/modules/fittoscreen/views/fittoscreen_photo.html.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function dynresize() {
|
||||||
|
var $maxheight = <?= $item->resize_height ?>;
|
||||||
|
var $maxwidth = <?= $item->resize_width ?>;
|
||||||
|
|
||||||
|
var $ratio = $maxwidth/$maxheight;
|
||||||
|
|
||||||
|
var $winwidth = $(window).width() <?= (module::get_var("fittoscreen", "width_unit")=="pr" ? "*".number_format(module::get_var("fittoscreen", "width")/100,2,".","") : "-".module::get_var("fittoscreen", "width")) ?>;
|
||||||
|
var $winheight = $(window).height() <?= (module::get_var("fittoscreen", "height_unit")=="pr" ? "*".number_format(module::get_var("fittoscreen", "height")/100,2,".","") : "-".module::get_var("fittoscreen", "height")) ?>;
|
||||||
|
|
||||||
|
if (($winwidth/$winheight)<$ratio) {
|
||||||
|
$finalwidth = ($winwidth > $maxwidth ? $maxwidth : $winwidth);
|
||||||
|
$finalheight = $finalwidth / $ratio;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$finalheight = ($winheight > $maxheight ? $maxheight : $winheight);
|
||||||
|
$finalwidth = $finalheight * $ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// $('body').prepend('<div>' + $finalheight + " " + $finalwidth + '</div>');
|
||||||
|
|
||||||
|
$("img.g-resize").attr({
|
||||||
|
height: $finalheight,
|
||||||
|
width: $finalwidth,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).resize(dynresize);
|
||||||
|
$(document).ready(dynresize);
|
||||||
|
</script>
|
Reference in New Issue
Block a user