annotate vakata-jstree-3.3.5/src/vakata-jstree.js @ 6:afa1774dc49b draft default tip

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 10:26:31 -0500
parents 803f4888f36a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
1 (function (factory) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
2 "use strict";
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
3 if (typeof define === 'function' && define.amd) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
4 define('jstree.checkbox', ['jquery','jstree'], factory);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
5 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
6 else if(typeof exports === 'object') {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
7 factory(require('jquery'), require('jstree'));
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
8 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
9 else {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
10 factory(jQuery);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
11 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
12 }(function ($, undefined) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
13 "use strict";
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
14 if(document.registerElement && Object && Object.create) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
15 var proto = Object.create(HTMLElement.prototype);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
16 proto.createdCallback = function () {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
17 var c = { core : {}, plugins : [] }, i;
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
18 for(i in $.jstree.plugins) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
19 if($.jstree.plugins.hasOwnProperty(i) && this.attributes[i]) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
20 c.plugins.push(i);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
21 if(this.getAttribute(i) && JSON.parse(this.getAttribute(i))) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
22 c[i] = JSON.parse(this.getAttribute(i));
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
23 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
24 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
25 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
26 for(i in $.jstree.defaults.core) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
27 if($.jstree.defaults.core.hasOwnProperty(i) && this.attributes[i]) {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
28 c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
29 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
30 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
31 $(this).jstree(c);
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
32 };
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
33 // proto.attributeChangedCallback = function (name, previous, value) { };
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
34 try {
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
35 document.registerElement("vakata-jstree", { prototype: proto });
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
36 } catch(ignore) { }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
37 }
803f4888f36a planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff changeset
38 }));