MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Dokumentation
Wechseln zu:Navigation, Suche
 
(9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
$("#tree").fancytree({
+
$.fn.extend({
  checkbox: true,
+
     treed: function (o) {
  selectMode: 3,
 
  source: {
 
     url:
 
      "https://cdn.rawgit.com/mar10/fancytree/72e03685/demo/ajax-tree-products.json"
 
  },
 
  lazyLoad: function(event, data) {
 
    data.result = {url: "https://cdn.rawgit.com/mar10/fancytree/72e03685/demo/ajax-sub2.json"};
 
  },
 
  
  activate: function(event, data) {
+
      var openedClass = 'fa-minus-circle';
    $("#statusLine").text(event.type + ": " + data.node);
+
      var closedClass = 'fa-plus-circle';
  },
+
 
  select: function(event, data) {
+
      if (typeof o != 'undefined'){
    $("#statusLine").text(
+
        if (typeof o.openedClass != 'undefined'){
      event.type + ": " + data.node.isSelected() + " " + data.node
+
        openedClass = o.openedClass;
    );
+
        }
  }
+
        if (typeof o.closedClass != 'undefined'){
 +
        closedClass = o.closedClass;
 +
        }
 +
      };
 +
 
 +
        //initialize each of the top levels
 +
        var tree = $(this);
 +
        tree.addClass("tree");
 +
        tree.find('li').has("ul").each(function () {
 +
            var branch = $(this); //li with children ul
 +
            branch.prepend("");
 +
            branch.addClass('branch');
 +
            branch.on('click', function (e) {
 +
                if (this == e.target) {
 +
                    var icon = $(this).children('i:first');
 +
                    icon.toggleClass(openedClass + " " + closedClass);
 +
                    $(this).children().children().toggle();
 +
                }
 +
            })
 +
            branch.children().children().toggle();
 +
        });
 +
        //fire event from the dynamically added icon
 +
      tree.find('.branch .indicator').each(function(){
 +
        $(this).on('click', function () {
 +
            $(this).closest('li').click();
 +
        });
 +
      });
 +
        //fire event to open branch if the li contains an anchor instead of text
 +
        tree.find('.branch>a').each(function () {
 +
            $(this).on('click', function (e) {
 +
                $(this).closest('li').click();
 +
                e.preventDefault();
 +
            });
 +
        });
 +
        //fire event to open branch if the li contains a button instead of text
 +
        tree.find('.branch>button').each(function () {
 +
            $(this).on('click', function (e) {
 +
                $(this).closest('li').click();
 +
                e.preventDefault();
 +
            });
 +
        });
 +
    }
 
});
 
});
  
// Sample button
+
//Initialization of treeviews
$("#button1").click(function() {
+
 
  var tree = $.ui.fancytree.getTree(),
+
$('#tree1').treed();
    node = tree.findFirst(function(n) {
+
 
      return n.title === "The Hobbit";
+
$('#tree2').treed({openedClass:'fa-folder-open', closedClass:'fa-folder'});
     });
+
 
 +
 
 +
$('#tree').treeview({
 +
    data: tree,
 +
    levels: 5,
 +
    backColor: 'white',
 +
    expandIcon: "glyphicon glyphicon-triangle-right",
 +
    collapseIcon: "glyphicon glyphicon-triangle-bottom",
 +
    showBorder: false,
 +
     enableLinks: true
 +
});
 +
      var tree = [
 +
    {
 +
        text: "Assets",
 +
        href: "http://localhost:63690/asset/index",
 +
        nodes: [
 +
        {
 +
            text: "Barcode"
 +
        },
 +
        {
 +
            text: "Importation"
 +
        }
 +
        ]
 +
    },
 +
]
  
   node.toggleSelected();
+
// Blockieren Rechtsklick Videos
 +
$(document).ready(function () {
 +
   $('video').on('contextmenu', function (e) {
 +
    return false;
 +
  });
 
});
 
});

Aktuelle Version vom 19. Mai 2025, 09:22 Uhr

$.fn.extend({
    treed: function (o) {

      var openedClass = 'fa-minus-circle';
      var closedClass = 'fa-plus-circle';

      if (typeof o != 'undefined'){
        if (typeof o.openedClass != 'undefined'){
        openedClass = o.openedClass;
        }
        if (typeof o.closedClass != 'undefined'){
        closedClass = o.closedClass;
        }
      };

        //initialize each of the top levels
        var tree = $(this);
        tree.addClass("tree");
        tree.find('li').has("ul").each(function () {
            var branch = $(this); //li with children ul
            branch.prepend("");
            branch.addClass('branch');
            branch.on('click', function (e) {
                if (this == e.target) {
                    var icon = $(this).children('i:first');
                    icon.toggleClass(openedClass + " " + closedClass);
                    $(this).children().children().toggle();
                }
            })
            branch.children().children().toggle();
        });
        //fire event from the dynamically added icon
      tree.find('.branch .indicator').each(function(){
        $(this).on('click', function () {
            $(this).closest('li').click();
        });
      });
        //fire event to open branch if the li contains an anchor instead of text
        tree.find('.branch>a').each(function () {
            $(this).on('click', function (e) {
                $(this).closest('li').click();
                e.preventDefault();
            });
        });
        //fire event to open branch if the li contains a button instead of text
        tree.find('.branch>button').each(function () {
            $(this).on('click', function (e) {
                $(this).closest('li').click();
                e.preventDefault();
            });
        });
    }
});

//Initialization of treeviews

$('#tree1').treed();

$('#tree2').treed({openedClass:'fa-folder-open', closedClass:'fa-folder'});


 $('#tree').treeview({
    data: tree,
    levels: 5,
    backColor: 'white',
    expandIcon: "glyphicon glyphicon-triangle-right",
    collapseIcon: "glyphicon glyphicon-triangle-bottom",
    showBorder: false,
    enableLinks: true
});
       var tree = [
    {
        text: "Assets",
        href: "http://localhost:63690/asset/index",
        nodes: [
        {
            text: "Barcode"
        },
        {
            text: "Importation"
        }
        ]
    },
]

// Blockieren Rechtsklick Videos
$(document).ready(function () {
  $('video').on('contextmenu', function (e) {
    return false;
  });
});