1(function($) { 2 var RiotTagsChildren = { 3 init: function() { 4 this.one('update', function() { 5 if(!this.skip_children) { 6 this.processChildren() 7 this.mountChildren() 8 } 9 }); 10 11 this.on('*', this.propagateEvent); 12 }, 13 getChildExtraOptions: function(c) { 14 return {} 15 }, 16 processChildren: function() { 17 this.children = [] 18 if(this.opts && typeof this.opts.children != 'undefined' && this.opts.children != null) { 19 for(var c in this.opts.children) { 20 var children = this.opts.children[c].hasOwnProperty('children') ? this.opts.children[c].children : null 21 var opts = this.opts.children[c].options 22 this.children.push({ 23 plugin: this.opts.children[c].plugin_id, 24 weight: this.opts.children[c].plugin_weight, 25 options: Object.assign(opts, { 'children': children }, this.getChildExtraOptions(this.opts.children[c])), 26 tag: this.opts.children[c].html_tag 27 }) 28 } 29 this.sortChildren() 30 } 31 }, 32 hasChildByPlugin: function(cls) { 33 for(var ind in this.children) { 34 if(this.children[ind].plugin == cls) { 35 return true 36 } 37 } 38 return false 39 }, 40 getChildByPlugin: function(cls) { 41 for(var ind in this.children) { 42 if(this.children[ind].plugin == cls) { 43 return this.children[ind] 44 } 45 } 46 return null 47 }, 48 mountChildren: function() { 49 var self = this, 50 l = this.children.length; 51 $(this.children).each(function() { 52 if(!this.mounted) { 53 var tag = $('<' + this.tag + ' />') 54 $(self.root).append(tag) 55 riot.mount(tag, this.tag, this.options) 56 this.mounted = true 57 l--; 58 if(!l) { 59 self.trigger('childrenMounted'); 60 } 61 } 62 $(self.root).addClass('haschild-' + this.tag); 63 }) 64 }, 65 sortChildren: function() { 66 this.children.sort(function(a, b) { 67 var aw = Number(a.weight), bw = Number(b.weight) 68 if(aw < bw) { 69 return -1 70 } 71 if(aw > bw) { 72 return 1 73 } 74 return 0 75 }) 76 }, 77 getChildTags: function () { 78 var elements = []; 79 80 for (var i = 0; i < this.root.childNodes.length; i++) { 81 if (typeof this.root.childNodes[i]._tag === 'object') { 82 elements.push(this.root.childNodes[i]); 83 } 84 } 85 86 return elements.map(function (element) { 87 return element._tag; 88 }); 89 }, 90 propagateEvent: function () { 91 var propagatingArgs = arguments; 92 93 if (typeof this.getChildTags === 'function') { 94 this.getChildTags().map(function (child) { 95 child.trigger.apply(child, propagatingArgs); 96 }); 97 } 98 } 99 }; 100 riot.mixin('RiotTagsChildren', RiotTagsChildren); 101})(jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.