| 134 | // Event binding and data-options updating. |
| 135 | |
| 136 | var bindings = function (method, options) { |
| 137 | var self = this, |
| 138 | should_bind_events = !S(this).data(this.attr_name(true)); |
| 139 | |
| 140 | if (S(this.scope).is('[' + this.attr_name() +']')) { |
| 141 | S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope)))); |
| 142 | |
| 143 | if (should_bind_events) { |
| 144 | this.events(this.scope); |
| 145 | } |
| 146 | |
| 147 | } else { |
| 148 | S('[' + this.attr_name() +']', this.scope).each(function () { |
| 149 | var should_bind_events = !S(this).data(self.attr_name(true) + '-init'); |
| 150 | S(this).data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this)))); |
| 151 | |
| 152 | if (should_bind_events) { |
| 153 | self.events(this); |
| 154 | } |
| 155 | }); |
| 156 | } |
| 157 | // # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating. |
| 158 | if (typeof method === 'string') { |
| 159 | return this[method].call(this, options); |
| 160 | } |
| 161 | |
| 162 | }; |
| 163 | |
| 164 | var single_image_loaded = function (image, callback) { |
| 165 | function loaded () { |