joonis Logo

KSS openURL Plugin

This KSS plugin opens a URL in the window specified by target. The target property can be the name of a window, frame, iframe or one of the values _self (default), _parent, _top or _blank. If the window name does not exist a new window will be opened with all properties passed to openURL (width and height defaults to 60%). If the redirect property is set to true the current URL will be replaced without creating an additional history entry. You can also navigate through the browser history by passing an integer value for the href parameter.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
    openURL_plugin.js - URL navigator for KSS

    Copyright (c) 2009, joonis new media
    Author: Thimo Kraemer <thimo.kraemer@joonis.de>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    MA 02110-1301, USA.
*/

(function(){

var wnd_map = {
'_self': self,
'_parent': parent,
'_top': top
};

kukit.actionsGlobalRegistry.register('openURL', function (oper) {

    var predefined = {
        'target': '_self',
        'width': '60%',
        'height': '60%',
        'redirect': 'false',
        'focus': 'true'
        };
    oper.evaluateParameters(['href'], predefined, 'Open URL', true);

    var parms = oper.parms;
    parms.redirect = (parms.redirect.toLowerCase() == 'true');
    parms.focus = (parms.focus.toLowerCase() == 'true');
    if (!parms.target) {
        parms.target = predefined.target;
    }

    // Get target window
    var wnd = wnd_map[parms.target] || {closed: true};

    // Set options
    var flags = [];
    if (wnd.closed) {
        var w, h;
        if (window.opera) {
            w = window.innerWidth;
            h = window.innerHeight;
        } else {
            w = screen.availWidth;
            h = screen.availHeight;
        }

        if (parms.width && parms.width.substr(parms.width.length-1) == '%') {
            parms.width = Math.round(w / 100 * parseInt(parms.width));
        }

        if (parms.height && parms.height.substr(parms.height.length-1) == '%') {
            parms.height = Math.round(h / 100 * parseInt(parms.height));
        }

        if (!parms.left) {
            parms.left = Math.round((w - parms.width) / 2);
        }
        else if (parms.left.substr(parms.left.length-1) == '%') {
            parms.left = Math.round(w / 100 * parseInt(parms.left));
        }

        if (!parms.top) {
            parms.top = Math.round((h - parms.height) / 2);
        }
        else if (parms.top.substr(parms.top.length-1) == '%') {
            parms.top = Math.round(h / 100 * parseInt(parms.top));
        }

        for (var key in parms) {
            if (key != 'href' && key != 'target' && key != 'redirect' && key != 'focus') {
                flags.push(key+'='+parms[key]);
            }
        }
    }
    flags = flags.join(',');

    // Open window or navigate to url/history
    if (parms.href == '') {
        // Also on parms.href == '0'?
        if (wnd.closed) {
            return;
        }
        wnd.location.reload(true);
    }
    else if (isFinite(parms.href) && !isNaN(parms.href)) {
        if (wnd.closed) {
            return;
        }
        wnd.history.go(parseInt(parms.href));
    }
    else if (parms.redirect && !wnd.closed) {
        wnd.location.replace(parms.href);
    }
    else {
        wnd = window.open(parms.href, parms.target, flags);
        if (parms.target != '_blank') {
            wnd_map[parms.target] = wnd;
        }
    }
    if (parms.focus) {
        wnd.focus();
    }
});
kukit.commandsGlobalRegistry.registerFromAction('openURL', kukit.cr.makeGlobalCommand);

})();

Example:

a.popup:click {
    evt-click-preventdefault: true;
    action-client: openURL;
    openURL-href: nodeAttr(href);
    openURL-target: "_blank";
    openURL-width: 60%;
    openURL-height: 60%;
    openURL-top: 15%;
    openURL-location: no;
    openURL-menubar: no;
    openURL-resizeable: yes;
    openURL-scrollbars: yes;
    openURL-status: no;
    openURL-toolbar: no;
}

.history-back:click {
    action-client: openURL;
    openURL-href: -1;
}

Kann ich
  Ihnen helfen?


Schreiben Sie mir
doch einfach unter
giraffe@joonis.de