Changeset 277 in t29-www for shared/js-v6


Ignore:
Timestamp:
Jul 8, 2012, 2:13:09 AM (12 years ago)
Author:
sven
Message:

JavaScript-Preferences-System, mit dem die Einstellungen fuers Menue erhalten bleiben. Refactoring des menu.js-Codes. startup.js um Reihenfolge der Scripte festzulegen. Diverse Bugfixes im PHP und Inhalt.

Location:
shared/js-v6/modules
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • shared/js-v6/modules/auto_bildbreite.js

    r260 r277  
    1515
    1616if(!t29) window.t29 = {}; // the t29 namespace
    17  
    18 t29.auto_bildbreite = function() {
     17
     18t29.auto_bildbreite = {};
     19t29.auto_bildbreite.setup = function() {
    1920        $("div.auto-bildbreite, div.desc-right, div.desc-left")
    2021                .each(function(){ $(this).css("width", $("img", this).width()); });
    2122}
    22 
    23 $(t29.auto_bildbreite);
  • shared/js-v6/modules/defaultvalue.js

    r260 r277  
    2929        });
    3030};
    31 
    32 $(t29.defaultvalue.setup);
  • shared/js-v6/modules/heading_links.js

    r260 r277  
    1313
    1414if(!t29) window.t29 = {}; // the t29 namespace
    15  
    16 t29.heading_links = function() {
     15
     16t29.heading_links = {};
     17t29.heading_links.setup = function() {
    1718        $("#content").find("h2,h3").not("h2:first").each(function(){
    1819                anchor = ($(this).attr("title") || $(this).attr("id") || $(this).text())
     
    3031                $('html, body').scrollTop(link.parent().offset().top); // springen
    3132}
    32 
    33 $(t29.heading_links);
  • shared/js-v6/modules/img_license.js

    r260 r277  
    7070};
    7171
    72 // use this function from outer, see onload for help.
     72// use this function from outer, see setup for help.
    7373// improvement possibility: converse to $.fn so can call $("img#my").img_license();
    7474t29.img_license.apply = function($elem) {
     
    7676};
    7777
    78 t29.img_license.onload = function() {
     78t29.img_license.setup = function() {
    7979        $("body").append('<div id="img-license-tag"><p>'+t29._('js-img-license')+'</p></div>');
    8080        t29.img_license.tag = $("#img-license-tag");
     
    8686        t29.img_license.apply( $("img").not(t29.img_license.settings.exclude) );
    8787};
    88 
    89 $(t29.img_license.onload);
  • shared/js-v6/modules/lightbox.js

    r260 r277  
    88 
    99if(!t29) window.t29 = {}; // the t29 namespace
    10  
    11 t29.lightbox = function() {
     10
     11t29.lightbox = {};
     12t29.lightbox.setup = function() {
    1213        var elements = $("#content .popup");
    1314        if(elements.length) {
     
    3536        } // if lightbox elements
    3637}
    37 
    38 $(t29.lightbox);
  • shared/js-v6/modules/menu.js

    r276 r277  
    2525};
    2626
    27 //////////////////////////// Menu Collapsed System.
     27/***************************************************************************************
     28  1. Collapsable Menu system  t29.menu.collapsed
     29 
     30     The collapsable menu system is capable of collapse parts of the menu by user
     31     interaction or program request. The current state is stored in t29.prefs.
     32
     33***************************************************************************************/
     34
     35/**
     36 * Construct a new collapsible. It needs three named arguments:
     37 *   c = new t29.menu.Collapsible({
     38 *       id: 'foobar',  // a senseful id for the t29.prefs cookie system
     39 *       lists: $(".your ul"),  // some element which should be collapsed
     40 *       button: $("<button/>").appendTo("body"); // some button which should do the work
     41 *   });
     42 *
     43 **/
     44t29.menu.Collapsible = function(arglist) {
     45        for (var n in arguments[0]) { this[n] = arguments[0][n]; }
     46        this.store_key = 'menu-collapsible-'+this.id; // key for t29.prefs.get/set
     47
     48        // default values
     49        if(!this.button)
     50                this.button = $('<span class="button collapse-menu"></span>')
     51                              .addClass('for-'+this.id).appendTo("nav.side");
     52
     53        // constants for the 'set' method
     54        this.FOLD = true;   this.EXPAND = false;
     55        this.QUICK = true;  this.ANIMATE = false;
     56
     57        // set initial state
     58        this.set(t29.prefs.get(this.store_key, this.FOLD), this.QUICK);
     59       
     60        // set button callback
     61        this.button.click($.proxy(function(){ this.set(); }, this));
     62}
     63
    2864/**
    2965 * Menu ein- oder ausklappen.
     66 *
    3067 * @param target_state  true: Eingeklappt, false: ausgeklappt
    3168 * @param quick  true=keine Animation, false/undefined=Animation
    3269 **/
    33 t29.menu.collapsed.set = function(collapse, quick) {
    34         if(collapse==undefined) collapse = !t29.menu.collapsed.is();
    35         log("Collapse zu "+(collapse?"KLEIN":"GROß")+" quick="+quick);
    36         if(quick) collapse ? t29.menu.collapsed.lists.hide() : t29.menu.collapsed.lists.show();
    37         else      collapse ? t29.menu.collapsed.lists.slideUp() : t29.menu.collapsed.lists.slideDown();
    38         t29.menu.collapsed.but.text(t29._(collapse ? "js-menu-collapse-out" : "js-menu-collapse-in"));
    39         collapse ? $("html").addClass("collapsed-menu") : $("html").removeClass("collapsed-menu");
     70t29.menu.Collapsible.prototype.set = function(collapse, quick) {
     71        if(collapse == undefined)
     72                collapse = ! this.is_collapsed();
     73        log("Collapsing "+this.id+" to " +(collapse==this.FOLD ? "klein (fold)" : "gross (expand)")+" quick = " + (quick==this.QUICK ? "quick!" : "animated"));
     74        if(quick) collapse ? this.lists.hide()    : this.lists.show();
     75        else      collapse ? this.lists.slideUp() : this.lists.slideDown();
     76        this.button.text(t29._(collapse ? "js-menu-collapse-out" : "js-menu-collapse-in"));
     77        //collapse ? $("html").addClass("collapsed-menu") : $("html").removeClass("collapsed-menu");
     78        t29.prefs.set(this.store_key, collapse);
    4079}
     80
    4181// returns whether menu is collapsed (boolean).
    42 t29.menu.collapsed.is = function() { return $("html").hasClass("collapsed-menu"); };
     82t29.menu.Collapsible.prototype.is_collapsed = function() { return t29.prefs.get(this.store_key) == this.FOLD; }
     83
    4384t29.menu.collapsed.setup = function() {
    44         t29.menu.collapsed.but = $('<span class="button collapse-menu"></span>').appendTo("nav.side");
    45         t29.menu.collapsed.lists = $("nav.side .u3").not("nav.side li.active > .u3"); // ein/auszuklappende Listen
    46         t29.menu.collapsed.set(true, true); // initial state
    47         t29.menu.collapsed.but.click(function(){ t29.menu.collapsed.set(); });
     85        // set up some collapsible lists
     86        t29.menu.collapsed.u3 = new t29.menu.Collapsible({
     87                id: 'u3',
     88                lists: $("nav.side .u3").not("nav.side li.active > .u3, .geraete"),
     89        });
     90
     91        /*t29.menu.collapsed.geraete = new t29.menu.Collapsible({
     92                id: 'geraete',
     93                lists: $("nav.side ul.geraete"),
     94        });*/
     95       
     96        // hide geraete
     97        //t29.menu.collapsed.geraete.button.hide();
     98        $("ul.geraete").hide();
    4899};
    49100
    50 //////////////////////////// Menu Scroll System
     101/***************************************************************************************
     102  2. Menu scroll system  t29.menu.scroll
     103 
     104     The scrollable menu system can handle a position:fixed navigation area with dynamic
     105     switching to static or absolute positioning. It is narrowly toothed to the
     106     collapse system. Current state is stored in t29.prefs.
     107
     108***************************************************************************************/
     109
    51110// enums, die CSS-Klassen im <html> entsprechen:
    52111t29.menu.scroll.States = Object.freeze({STATIC:"static-menu",FIX:"fixed-menu",STICK_TOP:"stick-top-menu",STICK_BOTTOM:"stick-bottom-menu"});
     
    76135                case t29.menu.scroll.States.STATIC:
    77136                        // die CSS-Klassen regeln eigentlich alles.
    78                         t29.menu.collapsed.but.show();
     137                        t29.menu.collapsed.u3.button.show();
    79138                        t29.menu.scroll.but.text(t29._("js-menu-scroll-show"));
    80139                        t29.menu.side.show();
     
    99158                        }*/
    100159
    101                         t29.menu.collapsed.set(true, true); // Sicherstellen, dass Navi eingeklappt.
    102                         t29.menu.collapsed.but.hide(); // Ausgeklappte Navi passt auf keinen Bildschirm.
     160                        t29.menu.collapsed.u3.set(true, true); // Sicherstellen, dass Navi eingeklappt.
     161                        t29.menu.collapsed.u3.button.hide(); // Ausgeklappte Navi passt auf keinen Bildschirm.
    103162                        t29.menu.scroll.but.text(t29._("js-menu-scroll-hide"));
    104163                        break;
     
    114173t29.menu.scroll.setup = function() {
    115174        t29.menu.scroll.but = $('<span class="button get-menu"></span>').appendTo("section.sidebar");
    116         t29.menu.scroll.set(t29.menu.scroll.States.STATIC); // initial state
     175
     176        /**
     177         * t29.prefs and t29.menu.scroll: Valid values are only FIX and STATIC.
     178         * Crossover states like STICK_BOTTOM, STICK_TOP shall not be stored.
     179         **/
     180        t29.menu.scroll.store_key = 'menu-scroll'; // key for accessing t29.prefs value
     181       
     182        // set initial state:
     183        initial = t29.prefs.get(t29.menu.scroll.store_key, t29.menu.scroll.States.STATIC);
     184        switch(initial) {
     185                case t29.menu.scroll.States.STATIC:
     186                        t29.menu.scroll.set(initial);
     187                        break;
     188                case t29.menu.scroll.States.FIX:
     189                        // davon ausgehend, dass wir uns ganz oben befinden beim Seiten-Laden.
     190                        // TODO / PENDING: Wenn man mit Anker #foobar auf die Seite reinkommt,
     191                        //                 ist das nicht der Fall! Das kann kombiniert werden
     192                        //                 mit t29.smoothscroll!
     193                        t29.menu.scroll.set(t29.menu.scroll.States.STICK_TOP);
     194                        break;
     195                default:
     196                        log("t29.menu.scroll.setup: Invalid value "+initial+" for initial prefs");
     197        }
    117198       
    118199        t29.menu.scroll.but.click(function(){
     
    123204                                t29.menu.scroll.set(t29.menu.scroll.States.FIX);
    124205                                t29.menu.side.fadeIn();
     206                                t29.prefs.set(t29.menu.scroll.store_key, t29.menu.scroll.States.FIX);
    125207                                break;
    126208                        case t29.menu.scroll.States.FIX:
     
    128210                                // zu Static uebergehen, mit Animation.
    129211                                t29.menu.side.fadeOut(function(){
    130                                         t29.menu.scroll.set(t29.menu.scroll.States.STATIC); });
     212                                        t29.menu.scroll.set(t29.menu.scroll.States.STATIC);
     213                                });
     214                                t29.prefs.set(t29.menu.scroll.store_key, t29.menu.scroll.States.STATIC);
    131215                                break;
    132216                        case t29.menu.scroll.States.STICK_TOP:
     
    158242                                if(y > t29.menu.scroll.origin_top) {
    159243                                        // wir sind wieder weiter runter gescrollt.
    160                                         if(t29.menu.collapsed.is())
     244                                        if(t29.menu.collapsed.u3.is_collapsed())
    161245                                                // und der Benutzer hat zwischenzeitlich nicht das Menue ausgeklappt
    162246                                                t29.menu.scroll.set(t29.menu.scroll.States.FIX);
     
    186270
    187271
    188 //////////////////////////// Footer Guided Tour System (auch Menu)
     272/***************************************************************************************
     273  2. Footer Guided Tour System   t29.menu.guide
     274 
     275     The "beam" is a fancy jquery application where the menu is cloned and displayed
     276     in the footer in a very other way. This is quite static compared to the
     277     applications above.
     278
     279***************************************************************************************/
    189280t29.menu.guide.setup = function() {
    190281        // Zentraler Hauptschritt: Das Menue ab oberster Ebene klonen und im Footer dranhaengen,
     
    250341        */
    251342};
    252 
    253 $(t29.menu.setup);
  • shared/js-v6/modules/pagescripts.js

    r275 r277  
    5959}
    6060
    61 t29.common = function(){
     61t29.page.setup = function(){
    6262        pagename = t29.conf.seiten_id;
    63         if(t29.page[pagename])
     63        if(t29.page[pagename]
     64          && (pagename != "setup")) // no recursion
    6465                t29.page[pagename]();
    6566};
    6667
    6768// to execute, run:
    68 $(t29.common);
     69//$(t29.common);
  • shared/js-v6/modules/smoothscroll.js

    r275 r277  
    77if(!t29) window.t29 = {}; // the t29 namespace
    88
    9 t29.smoothscroll = function() {
     9t29.smoothscroll = {};
     10t29.smoothscroll.setup = function() {
    1011        $("nav.side a").smoothScroll();
    1112       
     
    1718};
    1819
    19 $(t29.smoothscroll);
     20//$(t29.smoothscroll);
    2021
    2122
  • shared/js-v6/modules/tr_preloader.js

    r260 r277  
    4646}
    4747
    48 $(t29.tr.preloader);
     48//$(t29.tr.preloader);
Note: See TracChangeset for help on using the changeset viewer.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License